Skip to content

Package: CellReadOnly_PTest$2

CellReadOnly_PTest$2

nameinstructionbranchcomplexitylinemethod
run()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
{...}
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: * Eugen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.ui.editor.test;
15:
16: import org.eclipse.emf.ecore.EClass;
17: import org.eclipse.emf.ecore.EObject;
18: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
19: import org.eclipse.emf.ecore.EcoreFactory;
20: import org.eclipse.emf.ecore.EcorePackage;
21: import org.eclipse.emf.ecp.view.internal.table.swt.CellReadOnlyTesterHelper;
22: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
23: import org.eclipse.emf.ecp.view.spi.model.VView;
24: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
25: import org.eclipse.emf.ecp.view.spi.table.model.VTableControl;
26: import org.eclipse.emf.ecp.view.spi.table.swt.ECPCellReadOnlyTester;
27: import org.eclipse.emf.ecp.view.table.test.common.TableControlHandle;
28: import org.eclipse.emf.ecp.view.table.test.common.TableTestUtil;
29: import org.eclipse.swt.widgets.Display;
30: import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
31: import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
32:
33: /**
34: * @author Eugen
35: *
36: */
37: public class CellReadOnly_PTest extends ECPCommonSWTBotTest {
38:
39:         private EClass superType1;
40:         private EClass superType2;
41:
42:         /**
43:          * {@inheritDoc}
44:          *
45:          * @see org.eclipse.emf.ecp.view.ui.editor.test.ECPCommonSWTBotTest#createDomainObject()
46:          */
47:         @Override
48:         public EObject createDomainObject() {
49:                 final EClass eClass = EcoreFactory.eINSTANCE.createEClass();
50:                 superType1 = EcoreFactory.eINSTANCE.createEClass();
51:                 superType2 = EcoreFactory.eINSTANCE.createEClass();
52:                 eClass.getESuperTypes().add(superType1);
53:                 eClass.getESuperTypes().add(superType2);
54:
55:                 superType1.setName("a");
56:                 superType2.setName("b");
57:                 return eClass;
58:         }
59:
60:         /**
61:          * {@inheritDoc}
62:          *
63:          * @see org.eclipse.emf.ecp.view.ui.editor.test.ECPCommonSWTBotTest#createView()
64:          */
65:         @Override
66:         public VView createView() {
67:
68:                 final ECPCellReadOnlyTester tester = new ECPCellReadOnlyTester() {
69:
70:                         @Override
71:                         public boolean isCellReadOnly(VTableControl vTableControl, Setting setting) {
72:                                 if (!EClass.class.isInstance(setting.getEObject())) {
73:                                         return false;
74:                                 }
75:                                 if (!EcorePackage.eINSTANCE.getENamedElement_Name().equals(setting.getEStructuralFeature())) {
76:                                         return false;
77:                                 }
78:                                 final EClass eClass = EClass.class.cast(setting.getEObject());
79:                                 if ("a".equals(eClass.getName())) {
80:                                         return true;
81:                                 }
82:                                 return false;
83:                         }
84:                 };
85:                 CellReadOnlyTesterHelper.getInstance().registerCellReadOnlyTester(tester);
86:
87:                 final TableControlHandle tableControlHandle = TableTestUtil.createInitializedTableWithoutTableColumns();
88:
89:                 final VDomainModelReference tableColumn1 = TableTestUtil.createTableColumn(EcorePackage.eINSTANCE
90:                         .getENamedElement_Name());
91:                 tableControlHandle.addFirstTableColumn(tableColumn1);
92:
93:                 final VDomainModelReference tableColumn2 = TableTestUtil.createTableColumn(EcorePackage.eINSTANCE
94:                         .getEClass_Interface());
95:                 tableControlHandle.addSecondTableColumn(tableColumn2);
96:
97:                 final VView vview = VViewFactory.eINSTANCE.createView();
98:
99:                 vview.getChildren().add(tableControlHandle.getTableControl());
100:                 vview.setRootEClass(EcorePackage.eINSTANCE.getEClass());
101:
102:                 return vview;
103:         }
104:
105:         /**
106:          * {@inheritDoc}
107:          *
108:          * @see org.eclipse.emf.ecp.view.ui.editor.test.ECPCommonSWTBotTest#logic()
109:          */
110:         @Override
111:         public void logic() {
112:                 final SWTBotTable table = bot.table();
113:                 table.click(0, 1);
114:                 bot.sleep(1000);
115:                 Display.getDefault().syncExec(new Runnable() {
116:
117:                         @Override
118:                         public void run() {
119:                                 assertEquals(table.cell(0, 1), "a");
120:                         }
121:                 });
122:
123:                 table.click(0, 2);
124:                 Display.getDefault().syncExec(new Runnable() {
125:
126:                         @Override
127:                         public void run() {
128:                                 assertTrue(superType1.isInterface());
129:                         }
130:                 });
131:                 table.click(1, 1);
132:                 bot.sleep(1000);
133:                 final SWTBotText textCell11 = bot.text();
134:                 Display.getDefault().syncExec(new Runnable() {
135:
136:                         @Override
137:                         public void run() {
138:                                 assertTrue(textCell11.widget.getEditable());
139:                         }
140:                 });
141:                 table.click(1, 2);
142:                 Display.getDefault().syncExec(new Runnable() {
143:
144:                         @Override
145:                         public void run() {
146:                                 assertTrue(superType2.isInterface());
147:                         }
148:                 });
149:         }
150: }