Skip to content

Package: SectionLeafSWTRenderer_ITest

SectionLeafSWTRenderer_ITest

nameinstructionbranchcomplexitylinemethod
SectionLeafSWTRenderer_ITest()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
after()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
before()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createFirstColumn()
M: 0 C: 101
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 22
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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 - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.section.swt;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.junit.Assert.assertNotEquals;
18:
19: import java.util.Arrays;
20: import java.util.LinkedHashSet;
21:
22: import org.eclipse.emf.ecp.test.common.DefaultRealm;
23: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
24: import org.eclipse.emf.ecp.view.spi.section.model.VSection;
25: import org.eclipse.emf.ecp.view.spi.section.model.VSectionFactory;
26: import org.eclipse.emf.ecp.view.spi.section.model.VSectionedArea;
27: import org.eclipse.emf.ecp.view.template.model.VTStyleProperty;
28: import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider;
29: import org.eclipse.emf.ecp.view.template.style.alignment.model.AlignmentType;
30: import org.eclipse.emf.ecp.view.template.style.alignment.model.VTControlLabelAlignmentStyleProperty;
31: import org.eclipse.emf.ecp.view.template.style.wrap.model.VTLabelWrapStyleProperty;
32: import org.eclipse.emfforms.spi.common.report.ReportService;
33: import org.eclipse.swt.SWT;
34: import org.eclipse.swt.widgets.Composite;
35: import org.eclipse.swt.widgets.Control;
36: import org.eclipse.swt.widgets.Label;
37: import org.eclipse.swt.widgets.Shell;
38: import org.junit.After;
39: import org.junit.Before;
40: import org.junit.Test;
41: import org.mockito.Mockito;
42:
43: public class SectionLeafSWTRenderer_ITest {
44:
45:         private DefaultRealm realm;
46:         private Shell shell;
47:
48:         @Before
49:         public void before() {
50:                 realm = new DefaultRealm();
51:                 shell = new Shell();
52:         }
53:
54:         @After
55:         public void after() {
56:                 shell.dispose();
57:                 realm.dispose();
58:         }
59:
60:         @Test
61:         public void createFirstColumn() {
62:                 /* setup */
63:                 final VSectionedArea sectionedArea = VSectionFactory.eINSTANCE.createSectionedArea();
64:                 final VSection section = VSectionFactory.eINSTANCE.createSection();
65:                 sectionedArea.setRoot(section);
66:
67:                 final ViewModelContext viewModelContext = Mockito.mock(ViewModelContext.class);
68:                 final ReportService reportService = Mockito.mock(ReportService.class);
69:                 final VTViewTemplateProvider viewTemplateProvider = Mockito.mock(VTViewTemplateProvider.class);
70:
71:                 final VTLabelWrapStyleProperty wrapStyleProperty = Mockito.mock(VTLabelWrapStyleProperty.class);
72:                 Mockito.doReturn(true).when(wrapStyleProperty).isWrapLabel();
73:
74:                 final VTControlLabelAlignmentStyleProperty labelAlignmentStyleProperty = Mockito
75:                         .mock(VTControlLabelAlignmentStyleProperty.class);
76:                 Mockito.doReturn(AlignmentType.RIGHT).when(labelAlignmentStyleProperty).getType();
77:
78:                 Mockito
79:                         .doReturn(new LinkedHashSet<VTStyleProperty>(
80:                                 Arrays.asList(wrapStyleProperty, labelAlignmentStyleProperty)))
81:                         .when(viewTemplateProvider)
82:                         .getStyleProperties(section, viewModelContext);
83:
84:                 final SectionLeafSWTRenderer sectionLeafSWTRenderer = new SectionLeafSWTRenderer(section, viewModelContext,
85:                         reportService, viewTemplateProvider);
86:
87:                 /* act */
88:                 final Control firstColumn = sectionLeafSWTRenderer.createFirstColumn(shell);
89:
90:                 /* assert */
91:                 final Label label = (Label) Composite.class.cast(firstColumn).getChildren()[0];
92:                 assertNotEquals(0, label.getStyle() & SWT.WRAP);
93:                 assertEquals(SWT.RIGHT, label.getAlignment());
94:         }
95:
96: }