//Copyright 2015 Erik De Rijcke
//
//Licensed under the Apache License,Version2.0(the"License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing,software
//distributed under the License is distributed on an"AS IS"BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
package org.westmalle.wayland.protocol;

import org.freedesktop.wayland.server.Client;
import org.freedesktop.wayland.server.WlSubsurfaceResource;
import org.freedesktop.wayland.server.jna.WaylandServerLibrary;
import org.freedesktop.wayland.server.jna.WaylandServerLibraryMapping;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.westmalle.wayland.core.Subsurface;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest(WaylandServerLibrary.class)
public class WlSubsurfaceTest {

    @Mock
    private Subsurface        subsurface;

    @Mock
    private WaylandServerLibraryMapping waylandServerLibraryMapping;

    private WlSubsurface wlSubsurface;

    @Before
    public void setUp() throws Exception {
        PowerMockito.mockStatic(WaylandServerLibrary.class);
        when(WaylandServerLibrary.INSTANCE()).thenReturn(this.waylandServerLibraryMapping);
        this.wlSubsurface = new WlSubsurface(this.subsurface);
    }

    @Test
    public void testCreate() throws Exception {
        //given
        final Client client  = mock(Client.class);
        final int    version = 1;
        final int    id      = 15;
        //when
        final WlSubsurfaceResource wlSubsurfaceResource = this.wlSubsurface.create(client,
                                                                                   version,
                                                                                   id);
        //then
        assertThat(wlSubsurfaceResource).isNotNull();
        assertThat(wlSubsurfaceResource.getImplementation()).isSameAs(this.wlSubsurface);
    }
}
@@ -1442,23 +1442,16 @@
 surface 
-       
 subsurfa
@@ -1450,24 +1450,24 @@
 subsurface;%0A
+
 %0A    @Mock%0A 
@@ -2402,16 +2402,16 @@
 Null();%0A
-
         
@@ -2497,10 +2497,1648 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testSetPosition() throws Exception %7B%0A        //TODO%0A        //given: a wlsubsurface, a subsurface, an x and y coordinate%0A        //when: set position is called%0A        //then: subsurface set position is called with x and y coordinates%0A    %7D%0A%0A    @Test%0A    public void testPlaceAbove() throws Exception %7B%0A        //TODO%0A        //given: a wlsubsurface, a subsurface, a sibling or parent%0A        //when: place above is called%0A        //then: above is called on the subsurface%0A    %7D%0A%0A    @Test%0A    public void testPlaceAboveBadSibling() throws Exception %7B%0A        //TODO%0A        //given: a wlsubsurface, a bad sibling or parent%0A        //when: place above is called%0A        //then: a protocol error is raised%0A    %7D%0A%0A    @Test%0A    public void testPlaceBelow() throws Exception %7B%0A        //TODO%0A        //given: a wlsubsurface, a subsurface, a sibling or parent%0A        //when: place below is called%0A        //then: below is called on the subsurface%0A    %7D%0A%0A    @Test%0A    public void testPlaceBelowBadSibling() throws Exception %7B%0A        //TODO%0A        //given: a wlsubsurface, a bad sibling or parent%0A        //when: place below is called%0A        //then: a protocol error is raised%0A    %7D%0A%0A    @Test%0A    public void testSetSync() throws Exception %7B%0A        //TODO%0A        //given: a wlsubsurface, a subsurface%0A        //when: set sync is called%0A        //then: sync is called on the subsurface%0A    %7D%0A%0A    @Test%0A    public void testSetDesync() throws Exception %7B%0A        //TODO%0A        //given: a wlsubsurface, a subsurface%0A        //when: set desync is called%0A        //then: desync is called on the subsurface%0A    %7D
 %0A%7D

add wlsubsurface unit test skeleton methods