Skip to content

Package: TableColumnsDMRTableControl_Test

TableColumnsDMRTableControl_Test

nameinstructionbranchcomplexitylinemethod
TableColumnsDMRTableControl_Test()
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: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
gridDescription()
M: 0 C: 75
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 17
100%
M: 0 C: 1
100%
setUp()
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.internal.editor.controls;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.junit.Assert.assertFalse;
18: import static org.junit.Assert.assertTrue;
19: import static org.mockito.Mockito.mock;
20:
21: import org.eclipse.emf.ecp.test.common.DefaultRealm;
22: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
23: import org.eclipse.emf.ecp.view.spi.model.VControl;
24: import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider;
25: import org.eclipse.emfforms.spi.common.report.ReportService;
26: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
27: import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
28: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell;
29: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription;
30: import org.junit.After;
31: import org.junit.Before;
32: import org.junit.Test;
33:
34: /**
35: * Unit tests for {@link TableColumnsDMRTableControl}.
36: *
37: * @author Lucas Koehler
38: *
39: */
40: public class TableColumnsDMRTableControl_Test {
41:
42:         private TableColumnsDMRTableControl renderer;
43:         private DefaultRealm realm;
44:
45:         @Before
46:         public void setUp() {
47:                 realm = new DefaultRealm();
48:                 // need to extend mocks when rendering is tested
49:                 renderer = new TableColumnsDMRTableControl(mock(VControl.class), mock(ViewModelContext.class),
50:                         mock(ReportService.class),
51:                         mock(EMFFormsDatabinding.class), mock(EMFFormsLabelProvider.class), mock(VTViewTemplateProvider.class));
52:         }
53:
54:         @After
55:         public void after() {
56:                 realm.dispose();
57:         }
58:
59:         @Test
60:         public void gridDescription() {
61:                 final SWTGridDescription result = renderer.getGridDescription(mock(SWTGridDescription.class));
62:
63:                 assertEquals(3, result.getGrid().size());
64:                 assertEquals(1, result.getRows());
65:                 assertEquals(3, result.getColumns());
66:                 final SWTGridCell labelCell = result.getGrid().get(0);
67:                 final SWTGridCell validationCell = result.getGrid().get(1);
68:                 final SWTGridCell controlCell = result.getGrid().get(2);
69:
70:                 assertFalse(labelCell.isHorizontalGrab());
71:                 assertEquals(1, labelCell.getHorizontalSpan());
72:
73:                 assertFalse(validationCell.isHorizontalGrab());
74:                 assertEquals(1, validationCell.getHorizontalSpan());
75:
76:                 assertTrue(controlCell.isHorizontalGrab());
77:                 assertTrue(controlCell.isVerticalGrab());
78:                 assertEquals(1, controlCell.getHorizontalSpan());
79:                 assertTrue(controlCell.isHorizontalFill());
80:                 assertTrue(controlCell.isVerticalFill());
81:         }
82:
83: }