<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.x11;

import org.freedesktop.jaccall.Pointer;
import org.freedesktop.wayland.server.Display;
import org.freedesktop.wayland.server.EventLoop;
import org.freedesktop.wayland.server.EventSource;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.westmalle.wayland.core.Compositor;
import org.westmalle.wayland.core.Output;
import org.westmalle.wayland.core.OutputFactory;
import org.westmalle.wayland.core.events.Signal;
import org.westmalle.wayland.core.events.Slot;
import org.westmalle.wayland.nativ.libX11.LibX11;
import org.westmalle.wayland.nativ.libX11xcb.LibX11xcb;
import org.westmalle.wayland.nativ.libc.Libc;
import org.westmalle.wayland.nativ.libxcb.Libxcb;
import org.westmalle.wayland.nativ.libxcb.xcb_generic_event_t;
import org.westmalle.wayland.nativ.libxcb.xcb_intern_atom_reply_t;
import org.westmalle.wayland.nativ.libxcb.xcb_screen_iterator_t;
import org.westmalle.wayland.nativ.libxcb.xcb_screen_t;
import org.westmalle.wayland.protocol.WlOutput;
import org.westmalle.wayland.protocol.WlOutputFactory;
import org.westmalle.wayland.x11.config.X11ConnectorConfig;
import org.westmalle.wayland.x11.config.X11PlatformConfig;
import org.westmalle.wayland.x11.egl.X11EglPlatformFactory;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;

import static com.google.common.truth.Truth.assertThat;
import static org.freedesktop.jaccall.Pointer.malloc;
import static org.freedesktop.jaccall.Pointer.ref;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyByte;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyShort;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;

@RunWith(PowerMockRunner.class)
@PrepareForTest({WlOutputFactory.class,
                 OutputFactory.class,
                 X11EventBusFactory.class,
                 EventSource.class})
public class X11PlatformFactoryTest {

    @Rule
    public ExpectedException exception = ExpectedException.none();

    @Mock
    private Display                   display;
    @Mock
    private LibX11                    libX11;
    @Mock
    private Libxcb                    libxcb;
    @Mock
    private LibX11xcb                 libX11xcb;
    @Mock
    private PrivateX11PlatformFactory privateX11PlatformFactory;
    @Mock
    private WlOutputFactory           wlOutputFactory;
    @Mock
    private OutputFactory             outputFactory;
    @Mock
    private X11EventBusFactory        x11EventBusFactory;
    @Mock
    private X11ConnectorFactory       x11ConnectorFactory;
    @Mock
    private X11PlatformConfig         x11PlatformConfig;

    @InjectMocks
    private X11PlatformFactory x11PlatformFactory;

    @Before
    public void setUp() {
        when(this.x11PlatformConfig.getDisplay()).thenReturn(":0");
        final X11ConnectorConfig x11ConnectorConfig = mock(X11ConnectorConfig.class);
        when(x11ConnectorConfig.getX()).thenReturn(10);
        when(x11ConnectorConfig.getY()).thenReturn(20);
        when(x11ConnectorConfig.getWidth()).thenReturn(100);
        when(x11ConnectorConfig.getHeight()).thenReturn(200);
        when(this.x11PlatformConfig.getX11ConnectorConfigs()).thenReturn(Collections.singletonList(x11ConnectorConfig));
    }

    @Test
    public void testCreateOpenDisplayFailed() throws Exception {
        //given
        this.exception.expect(RuntimeException.class);
        this.exception.expectMessage("XOpenDisplay() failed: :0");
<commit_msg>fix test missing a name config value<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.x11;

import org.freedesktop.jaccall.Pointer;
import org.freedesktop.wayland.server.Display;
import org.freedesktop.wayland.server.EventLoop;
import org.freedesktop.wayland.server.EventSource;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.westmalle.wayland.core.Compositor;
import org.westmalle.wayland.core.Output;
import org.westmalle.wayland.core.OutputFactory;
import org.westmalle.wayland.core.events.Signal;
import org.westmalle.wayland.core.events.Slot;
import org.westmalle.wayland.nativ.libX11.LibX11;
import org.westmalle.wayland.nativ.libX11xcb.LibX11xcb;
import org.westmalle.wayland.nativ.libc.Libc;
import org.westmalle.wayland.nativ.libxcb.Libxcb;
import org.westmalle.wayland.nativ.libxcb.xcb_generic_event_t;
import org.westmalle.wayland.nativ.libxcb.xcb_intern_atom_reply_t;
import org.westmalle.wayland.nativ.libxcb.xcb_screen_iterator_t;
import org.westmalle.wayland.nativ.libxcb.xcb_screen_t;
import org.westmalle.wayland.protocol.WlOutput;
import org.westmalle.wayland.protocol.WlOutputFactory;
import org.westmalle.wayland.x11.config.X11ConnectorConfig;
import org.westmalle.wayland.x11.config.X11PlatformConfig;
import org.westmalle.wayland.x11.egl.X11EglPlatformFactory;

import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;

import static com.google.common.truth.Truth.assertThat;
import static org.freedesktop.jaccall.Pointer.malloc;
import static org.freedesktop.jaccall.Pointer.ref;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyByte;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyShort;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;

@RunWith(PowerMockRunner.class)
@PrepareForTest({WlOutputFactory.class,
                 OutputFactory.class,
                 X11EventBusFactory.class,
                 EventSource.class})
public class X11PlatformFactoryTest {

    @Rule
    public ExpectedException exception = ExpectedException.none();

    @Mock
    private Display                   display;
    @Mock
    private LibX11                    libX11;
    @Mock
    private Libxcb                    libxcb;
    @Mock
    private LibX11xcb                 libX11xcb;
    @Mock
    private PrivateX11PlatformFactory privateX11PlatformFactory;
    @Mock
    private WlOutputFactory           wlOutputFactory;
    @Mock
    private OutputFactory             outputFactory;
    @Mock
    private X11EventBusFactory        x11EventBusFactory;
    @Mock
    private X11ConnectorFactory       x11ConnectorFactory;
    @Mock
    private X11PlatformConfig         x11PlatformConfig;

    @InjectMocks
    private X11PlatformFactory x11PlatformFactory;

    @Before
    public void setUp() {
        when(this.x11PlatformConfig.getDisplay()).thenReturn(":0");
        final X11ConnectorConfig x11ConnectorConfig = mock(X11ConnectorConfig.class);
        when(x11ConnectorConfig.getX()).thenReturn(10);
        when(x11ConnectorConfig.getY()).thenReturn(20);
        when(x11ConnectorConfig.getWidth()).thenReturn(100);
        when(x11ConnectorConfig.getHeight()).thenReturn(200);
        when(x11ConnectorConfig.getName()).thenReturn("testWindow");
        when(this.x11PlatformConfig.getX11ConnectorConfigs()).thenReturn(Collections.singletonList(x11ConnectorConfig));
    }

    @Test
    public void testCreateOpenDisplayFailed() throws Exception {
        //given
        this.exception.expect(RuntimeException.class);
        this.exception.expectMessage("XOpenDisplay() failed: :0");

{'fraction_non_alphanumeric': 0.0922309488431331, 'fraction_numerical': 0.020802377414561663, 'mean_word_length': 4.183168316831683, 'pattern_counts': {'":': 2, '<': 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': '7323404', 'n_tokens_mistral': 3009, 'n_tokens_neox': 2892, 'n_words': 545}