Skip to content

Package: SWTCustomControl_PTest$TestHandel

SWTCustomControl_PTest$TestHandel

nameinstructionbranchcomplexitylinemethod
SWTCustomControl_PTest.TestHandel(SWTCustomControl_PTest, VView, VControl)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getCustomControl()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getView()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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: * Johannes Faltermeier
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.view.custom.ui.swt.test;
16:
17: import static org.junit.Assert.assertEquals;
18: import static org.junit.Assert.assertNotNull;
19: import static org.junit.Assert.assertSame;
20: import static org.junit.Assert.assertTrue;
21:
22: import org.eclipse.emf.ecp.view.spi.custom.model.VCustomControl;
23: import org.eclipse.emf.ecp.view.spi.custom.model.VCustomDomainModelReference;
24: import org.eclipse.emf.ecp.view.spi.custom.model.VCustomFactory;
25: import org.eclipse.emf.ecp.view.spi.model.VControl;
26: import org.eclipse.emf.ecp.view.spi.model.VElement;
27: import org.eclipse.emf.ecp.view.spi.model.VView;
28: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
29: import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
30: import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
31: import org.eclipse.emf.ecp.view.test.common.swt.spi.DatabindingClassRunner;
32: import org.eclipse.emf.ecp.view.test.common.swt.spi.SWTViewTestHelper;
33: import org.eclipse.emf.emfstore.bowling.BowlingFactory;
34: import org.eclipse.emf.emfstore.bowling.Fan;
35: import org.eclipse.emfforms.spi.swt.core.EMFFormsNoRendererException;
36: import org.eclipse.swt.widgets.Composite;
37: import org.eclipse.swt.widgets.Shell;
38: import org.junit.Ignore;
39: import org.junit.Test;
40: import org.junit.runner.RunWith;
41:
42: @RunWith(DatabindingClassRunner.class)
43: public class SWTCustomControl_PTest {
44:
45:         /**
46:          * @author Jonas
47:          *
48:          */
49:         public class TestHandel {
50:
51:                 private final VView view;
52:
53:                 private final VControl customControl;
54:
55:                 /**
56:                  * @param view
57:                  * @param customControl
58:                  */
59:
60:                 public TestHandel(VView view, VControl customControl) {
61:                         this.view = view;
62:                         this.customControl = customControl;
63:                 }
64:
65:                 /**
66:                  * @return the view
67:                  */
68:                 public VView getView() {
69:                         return view;
70:                 }
71:
72:                 /**
73:                  * @return the customControl
74:                  */
75:
76:                 public VControl getCustomControl() {
77:                         return customControl;
78:                 }
79:
80:         }
81:
82:         private static final String BUNDLE_ID = "org.eclipse.emf.ecp.view.custom.ui.swt.test";
83:
84:         /**
85:          * @throws EMFFormsNoRendererException
86:          *
87:          */
88:         // FIXME what to expect
89:         @Test
90:         @Ignore
91:         public void testCustomControlinView() throws NoRendererFoundException, NoPropertyDescriptorFoundExeption,
92:                 EMFFormsNoRendererException {
93:                 final VElement controlInView = createCustomControlInView();
94:                 final Shell shell = SWTViewTestHelper.createShell();
95:                 final Composite composite = (Composite) SWTViewTestHelper.render(controlInView, shell);
96:                 assertSame(composite, CustomControlStub.getParent());
97:         }
98:
99:         /**
100:          * @return
101:          */
102:         private VElement createCustomControlInView() {
103:                 final VView view = VViewFactory.eINSTANCE.createView();
104:
105:                 final VCustomControl customControl = createCustomControl();
106:
107:                 view.getChildren().add(customControl);
108:                 customControl.setBundleName(BUNDLE_ID);
109:                 customControl.setClassName("org.eclipse.emf.ecp.view.custom.ui.swt.test.CustomControlStub");
110:                 // TODO check id
111:                 final VCustomDomainModelReference domainModelReference = VCustomFactory.eINSTANCE
112:                         .createCustomDomainModelReference();
113:                 domainModelReference.setBundleName(BUNDLE_ID);
114:                 domainModelReference.setClassName("org.eclipse.emf.ecp.view.custom.ui.swt.test.CustomControlStub");
115:                 customControl.setDomainModelReference(domainModelReference);
116:                 return view;
117:         }
118:
119:         @Test
120:         public void testCustomControlinViewWithoutClass() throws NoRendererFoundException,
121:                 NoPropertyDescriptorFoundExeption, EMFFormsNoRendererException {
122:                 final VView view = VViewFactory.eINSTANCE.createView();
123:
124:                 final VCustomControl customControl = createCustomControl();
125:
126:                 view.getChildren().add(customControl);
127:                 customControl.setBundleName(BUNDLE_ID);
128:                 customControl.setClassName("org.eclipse.emf.ecp.view.customcomposite.ui.swt.test.NoExisting");
129:                 // TODO check id
130:                 final VCustomDomainModelReference domainModelReference = VCustomFactory.eINSTANCE
131:                         .createCustomDomainModelReference();
132:                 domainModelReference.setBundleName(BUNDLE_ID);
133:                 domainModelReference.setClassName("org.eclipse.emf.ecp.view.customcomposite.ui.swt.test.NoExisting");
134:                 customControl.setDomainModelReference(domainModelReference);
135:                 // setup ui
136:                 final Shell shell = SWTViewTestHelper.createShell();
137:                 SWTViewTestHelper.render(view, shell);
138:                 assertEquals(1, shell.getChildren().length);
139:                 assertTrue(Composite.class.isInstance(shell.getChildren()[0]));
140:                 assertEquals(0, Composite.class.cast(shell.getChildren()[0]).getChildren().length);
141:         }
142:
143:         @Test
144:         public void testCustomControlInit() throws NoRendererFoundException, NoPropertyDescriptorFoundExeption,
145:                 EMFFormsNoRendererException {
146:                 final VView view = VViewFactory.eINSTANCE.createView();
147:
148:                 final VCustomControl customControl = createCustomControl();
149:
150:                 view.getChildren().add(customControl);
151:                 customControl.setBundleName(BUNDLE_ID);
152:                 customControl.setClassName("org.eclipse.emf.ecp.view.custom.ui.swt.test.CustomControlStub2");
153:                 // TODO check id
154:                 final VCustomDomainModelReference domainModelReference = VCustomFactory.eINSTANCE
155:                         .createCustomDomainModelReference();
156:                 domainModelReference.setClassName("org.eclipse.emf.ecp.view.custom.ui.swt.test.CustomControlStub2");
157:                 domainModelReference.setBundleName(BUNDLE_ID);
158:                 customControl.setDomainModelReference(domainModelReference);
159:
160:                 final Fan domainModel = BowlingFactory.eINSTANCE.createFan();
161:                 final Shell shell = SWTViewTestHelper.createShell();
162:                 SWTViewTestHelper.render(view, domainModel, shell);
163:                 // ViewModelContextFactory.INSTANCE.createViewModelContext(view, domainModel);
164:
165:                 assertNotNull(domainModel.getFavouriteMerchandise());
166:         }
167:
168:         /**
169:          * @return
170:          */
171:
172:         private VCustomControl createCustomControl() {
173:                 return VCustomFactory.eINSTANCE.createCustomControl();
174:
175:         }
176: }