/******************************************************************************* * Copyright (c) 2006-2013 The RCP Company and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * The RCP Company - initial API and implementation *******************************************************************************/ package com.rcpcompany.uibindings.grid.extests.structure; import static com.rcpcompany.test.utils.ui.UITestUtils.*; import static com.rcpcompany.uibindings.grid.extests.GridBaseTestUtils.*; import static org.junit.Assert.*; import java.util.Arrays; import java.util.Collection; import org.eclipse.nebula.widgets.grid.Grid; import org.eclipse.swt.SWT; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import com.rcpcompany.uibinding.tests.model.TestGrid; import com.rcpcompany.uibinding.tests.model.TestModelFactory; import com.rcpcompany.uibinding.tests.model.TestModelPackage; import com.rcpcompany.uibindings.IBindingContext; import com.rcpcompany.uibindings.grid.IGridBinding; import com.rcpcompany.uibindings.grid.extests.models.TestGridGridModel; import com.rcpcompany.uibindings.tests.utils.BaseUIBTestUtils; import com.rcpcompany.uibindings.tests.utils.views.UIBTestView; import com.rcpcompany.uibindings.utils.EditingDomainUtils; /** * Tests that the grid has the correct number of rows and columns. * * @author Tonny Madsen, The RCP Company */ @RunWith(Parameterized.class) public class GridStructureTest { @Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { { TestModelFactory.eINSTANCE.createTestGrid() }, { createTestGrid() }, }); } public GridStructureTest(TestGrid grid) { myTestGrid = grid; } private UIBTestView myView; private Grid myGrid; private IGridBinding myGridBinding; private final TestGrid myTestGrid; private TestGridGridModel myModel; @Before public void setup() { BaseUIBTestUtils.resetAll(); createModel(); createView(); } private void createModel() { myModel = new TestGridGridModel(EditingDomainUtils.getEditingDomain(), myTestGrid, TestModelPackage.Literals.TEST_GRID_CELL__DETAILS, null); } private void createView() { myView = BaseUIBTestUtils.createUIBTestView(this); myGrid = new Grid(myView.getBody(), SWT.NONE); final IBindingContext context = IBindingContext.Factory.createContext(myView.getBody()); myGridBinding = IGridBinding.Factory.createGrid(context, myGrid, myModel); context.finish(); yield(); myView.getBody().layout(); yield(); } @After public void disposeView() { if (myView != null) { myView.getSite().getPage().hideView(myView); } } @Test public void testSize() { assertEquals(myTestGrid.getColumns().size(), myGrid.getColumnCount()); assertEquals(myTestGrid.getRows().size(), myGrid.getItemCount()); } }