Skip to content

Package: GridViewerColumnBuilder_ITest

GridViewerColumnBuilder_ITest

nameinstructionbranchcomplexitylinemethod
GridViewerColumnBuilder_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%
setUp()
M: 0 C: 98
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 18
100%
M: 0 C: 1
100%
tearDown()
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%
testConfigureDatabinding()
M: 0 C: 81
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 15
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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.table.nebula.grid;
15:
16: import static org.junit.Assert.assertEquals;
17: import static org.mockito.Mockito.mock;
18: import static org.mockito.Mockito.when;
19:
20: import org.eclipse.core.databinding.observable.value.IObservableValue;
21: import org.eclipse.emf.databinding.EMFDataBindingContext;
22: import org.eclipse.emf.ecp.view.test.common.swt.spi.DatabindingClassRunner;
23: import org.eclipse.emfforms.common.Optional;
24: import org.eclipse.emfforms.common.Property;
25: import org.eclipse.emfforms.spi.swt.table.ColumnConfiguration;
26: import org.eclipse.jface.viewers.CellLabelProvider;
27: import org.eclipse.jface.viewers.EditingSupport;
28: import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
29: import org.eclipse.nebula.jface.gridviewer.GridViewerColumn;
30: import org.eclipse.swt.widgets.Shell;
31: import org.junit.After;
32: import org.junit.Before;
33: import org.junit.Test;
34: import org.junit.runner.RunWith;
35:
36: @RunWith(DatabindingClassRunner.class)
37: public class GridViewerColumnBuilder_ITest {
38:
39:         private EMFDataBindingContext dataBindingContext;
40:         private GridTableViewer tableViewer;
41:         private Shell shell;
42:         private ColumnConfiguration config;
43:
44:         @SuppressWarnings({ "unchecked", "rawtypes" })
45:         @Before
46:         public void setUp() throws Exception {
47:                 dataBindingContext = new EMFDataBindingContext();
48:                 shell = new Shell();
49:                 tableViewer = new GridTableViewer(shell);
50:
51:                 config = mock(ColumnConfiguration.class);
52:                 final CellLabelProvider labelProvider = mock(CellLabelProvider.class);
53:                 when(config.createLabelProvider(tableViewer)).thenReturn(labelProvider);
54:                 final Optional<EditingSupport> editingSupport = Optional.empty();
55:                 when(config.createEditingSupport(tableViewer)).thenReturn(editingSupport);
56:                 final Property visibleProperty = mock(Property.class);
57:                 when(visibleProperty.getValue()).thenReturn(Boolean.TRUE);
58:                 when(config.visible()).thenReturn(visibleProperty);
59:                 final Property showFilterProperty = mock(Property.class);
60:                 when(showFilterProperty.getValue()).thenReturn(Boolean.FALSE);
61:                 when(config.showFilterControl()).thenReturn(showFilterProperty);
62:                 final Property matchFilterProperty = mock(Property.class);
63:                 when(matchFilterProperty.getValue()).thenReturn(Boolean.FALSE);
64:                 when(config.matchFilter()).thenReturn(matchFilterProperty);
65:         }
66:
67:         @After
68:         public void tearDown() throws Exception {
69:                 shell.dispose();
70:         }
71:
72:         @SuppressWarnings("rawtypes")
73:         @Test
74:         public void testConfigureDatabinding() {
75:
76:                 final IObservableValue tooltipObservable = mock(IObservableValue.class);
77:                 final String tooltip = "Foo";
78:                 when(tooltipObservable.getValue()).thenReturn(tooltip);
79:                 when(tooltipObservable.getRealm()).thenReturn(dataBindingContext.getValidationRealm());
80:                 when(config.getColumnTooltip()).thenReturn(tooltipObservable);
81:
82:                 final IObservableValue textObservable = mock(IObservableValue.class);
83:                 when(textObservable.getValue()).thenReturn("Bar");
84:                 when(textObservable.getValueType()).thenReturn(String.class);
85:                 when(textObservable.getRealm()).thenReturn(dataBindingContext.getValidationRealm());
86:                 when(config.getColumnText()).thenReturn(textObservable);
87:
88:                 final GridViewerColumnBuilder builder = new GridViewerColumnBuilder(config);
89:                 builder.withDatabinding(dataBindingContext);
90:                 final GridViewerColumn column = builder.build(tableViewer);
91:                 assertEquals(tooltip, column.getColumn().getHeaderTooltip());
92:         }
93:
94: }