<commit_before>//Copyright 2015 <NAME>
//
//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.core;

import org.freedesktop.wayland.server.Display;
import org.freedesktop.wayland.shared.WlShmFormat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.westmalle.wayland.protocol.WlCompositor;
import org.westmalle.wayland.protocol.WlDataDeviceManager;
import org.westmalle.wayland.protocol.WlShell;
import org.westmalle.wayland.protocol.WlSubcompositor;

import static org.mockito.Matchers.startsWith;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class LifeCycleTest {

    @Mock
    private Display             display;
    @Mock
    private JobExecutor         jobExecutor;
    @Mock
    private WlCompositor        wlCompositor;
    @Mock
    private WlDataDeviceManager wlDataDeviceManager;
    @Mock
    private WlShell             wlShell;
    @Mock
    private WlSubcompositor     wlSubcompositor;

    @InjectMocks
    private LifeCycle lifeCycle;

    @Test
    public void testRun() throws Exception {
        //given
        when(this.display.addShmFormat(WlShmFormat.ARGB8888.value)).thenReturn(1234);
        when(this.display.addShmFormat(WlShmFormat.XRGB8888.value)).thenReturn(5678);

        //when
        this.lifeCycle.start();
        //then
        verify(this.jobExecutor).start();
        verify(this.display).initShm();
        verify(this.display).addSocket(startsWith("wayland-"));
        verify(this.display).run();
    }

    @Test
    public void testShutDown() throws Exception {
        //given
        //when<commit_msg>fixup lifecycle unit test<commit_after>//Copyright 2015 <NAME>
//
//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.core;

import org.freedesktop.wayland.server.Display;
import org.freedesktop.wayland.shared.WlShmFormat;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.westmalle.Signal;
import org.westmalle.wayland.protocol.WlCompositor;
import org.westmalle.wayland.protocol.WlDataDeviceManager;
import org.westmalle.wayland.protocol.WlShell;
import org.westmalle.wayland.protocol.WlSubcompositor;

import static org.mockito.Matchers.startsWith;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class LifeCycleTest {

    @Mock
    private Display             display;
    @Mock
    private JobExecutor         jobExecutor;
    @Mock
    private WlCompositor        wlCompositor;
    @Mock
    private WlDataDeviceManager wlDataDeviceManager;
    @Mock
    private WlShell             wlShell;
    @Mock
    private WlSubcompositor     wlSubcompositor;
    @Mock
    private LifeCycleSignals    lifeCycleSignals;

    @InjectMocks
    private LifeCycle lifeCycle;

    @Before
    public void setUp() throws Exception {
        when(this.lifeCycleSignals.getStartSignal()).thenReturn(mock(Signal.class));
        when(this.lifeCycleSignals.getStopSignal()).thenReturn(mock(Signal.class));
    }

    @Test
    public void testRun() throws Exception {
        //given
        when(this.display.addShmFormat(WlShmFormat.ARGB8888.value)).thenReturn(1234);
        when(this.display.addShmFormat(WlShmFormat.XRGB8888.value)).thenReturn(5678);

        //when
        this.lifeCycle.start();
        //then
        verify(this.jobExecutor).start();
        verify(this.display).initShm();
        verify(this.display).addSocket(startsWith("wayland-"));
        verify(this.display).run();
    }

    @Test
    public void testShutDown() throws Exception {
        //given
        //when
{'fraction_non_alphanumeric': 0.09725888324873097, 'fraction_numerical': 0.009746192893401015, 'mean_word_length': 3.4863387978142075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3872975', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1480, 'n_words': 345}