Skip to content

Package: NullSelectionProvider_Test

NullSelectionProvider_Test

nameinstructionbranchcomplexitylinemethod
NullSelectionProvider_Test()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
postSelectionListener()
M: 0 C: 25
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
selection()
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
selectionListener()
M: 0 C: 25
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2019 Christian W. Damus and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Christian W. Damus - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ui.view.spi.swt.selection.test;
15:
16: import static org.hamcrest.CoreMatchers.is;
17: import static org.hamcrest.MatcherAssert.assertThat;
18: import static org.mockito.Matchers.any;
19: import static org.mockito.Mockito.mock;
20: import static org.mockito.Mockito.never;
21: import static org.mockito.Mockito.verify;
22:
23: import org.eclipse.emf.ecp.view.spi.swt.selection.NullSelectionProvider;
24: import org.eclipse.jface.viewers.ISelection;
25: import org.eclipse.jface.viewers.ISelectionChangedListener;
26: import org.eclipse.jface.viewers.StructuredSelection;
27: import org.junit.Test;
28:
29: /**
30: * Test cases for the {@link NullSelectionProvider} class.
31: */
32: public class NullSelectionProvider_Test {
33:
34:         private final NullSelectionProvider fixture = NullSelectionProvider.INSTANCE;
35:
36:         /**
37:          * Initializes me.
38:          */
39:         public NullSelectionProvider_Test() {
40:                 super();
41:         }
42:
43:         @Test
44:         public void selection() {
45:                 ISelection sel = new StructuredSelection("Hello, world!");
46:                 fixture.setSelection(sel);
47:
48:                 sel = fixture.getSelection();
49:                 assertThat("Selection not empty", sel.isEmpty(), is(true));
50:         }
51:
52:         @Test
53:         public void selectionListener() {
54:                 final ISelectionChangedListener listener = mock(ISelectionChangedListener.class);
55:                 fixture.addSelectionChangedListener(listener);
56:
57:                 final ISelection sel = new StructuredSelection("Hello, world!");
58:                 fixture.setSelection(sel);
59:
60:                 verify(listener, never()).selectionChanged(any());
61:         }
62:
63:         @Test
64:         public void postSelectionListener() {
65:                 final ISelectionChangedListener listener = mock(ISelectionChangedListener.class);
66:                 fixture.addPostSelectionChangedListener(listener);
67:
68:                 final ISelection sel = new StructuredSelection("Hello, world!");
69:                 fixture.setSelection(sel);
70:
71:                 verify(listener, never()).selectionChanged(any());
72:         }
73:
74: }