Skip to content

Package: ECPSWTViewImpl_PTest

ECPSWTViewImpl_PTest

nameinstructionbranchcomplexitylinemethod
ECPSWTViewImpl_PTest()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
createShell()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
destroyShell()
M: 0 C: 11
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
dispose()
M: 0 C: 33
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
dispose_control()
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
instantiation()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
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.internal.swt;
15:
16: import static org.hamcrest.CoreMatchers.is;
17: import static org.hamcrest.MatcherAssert.assertThat;
18: import static org.mockito.Mockito.atLeastOnce;
19: import static org.mockito.Mockito.never;
20: import static org.mockito.Mockito.verify;
21:
22: import org.eclipse.emf.ecp.view.internal.swt.ECPSWTViewImpl;
23: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
24: import org.eclipse.swt.widgets.Shell;
25: import org.junit.After;
26: import org.junit.Before;
27: import org.junit.Test;
28: import org.junit.runner.RunWith;
29: import org.mockito.Mock;
30: import org.mockito.runners.MockitoJUnitRunner;
31:
32: /**
33: * Unit tests for the {@link ECPSWTViewImpl} class.
34: */
35: @RunWith(MockitoJUnitRunner.class)
36: public class ECPSWTViewImpl_PTest {
37:
38:         @Mock
39:         private ViewModelContext context;
40:         private Shell shell;
41:
42:         /**
43:          * Initializes me.
44:          */
45:         public ECPSWTViewImpl_PTest() {
46:                 super();
47:         }
48:
49:         @Test
50:         public void instantiation() {
51:                 final ECPSWTViewImpl swtView = new ECPSWTViewImpl(shell, context);
52:
53:                 verify(context).addContextUser(swtView);
54:         }
55:
56:         @Test
57:         public void dispose() {
58:                 final ECPSWTViewImpl swtView = new ECPSWTViewImpl(shell, context);
59:
60:                 swtView.dispose();
61:
62:                 assertThat("Shell not disposed", shell.isDisposed(), is(true));
63:                 verify(context, atLeastOnce()).removeContextUser(swtView);
64:                 verify(context, never()).dispose();
65:         }
66:
67:         @Test
68:         public void dispose_control() {
69:                 final ECPSWTViewImpl swtView = new ECPSWTViewImpl(shell, context);
70:
71:                 shell.dispose();
72:
73:                 verify(context).removeContextUser(swtView);
74:         }
75:
76:         //
77:         // Test framework
78:         //
79:
80:         @Before
81:         public void createShell() {
82:                 shell = new Shell();
83:         }
84:
85:         @After
86:         public void destroyShell() {
87:                 // Just in case
88:•                if (!shell.isDisposed()) {
89:                         shell.dispose();
90:                 }
91:                 shell = null;
92:         }
93:
94: }