aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java
new file mode 100644
index 0000000000..6ea72540b5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridDetailsLayoutExpandTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.number.IsCloseTo.closeTo;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.parallel.Browser;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests the layouting of Grid's details row when it contains a HorizontalLayout
+ * with expand ratios.
+ *
+ * @author Vaadin Ltd
+ */
+@TestCategory("grid")
+public class GridDetailsLayoutExpandTest extends MultiBrowserTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsersToTest = super.getBrowsersToTest();
+ // TODO: remove when #19326 is fixed
+ browsersToTest.remove(Browser.IE8.getDesiredCapabilities());
+ browsersToTest.remove(Browser.IE9.getDesiredCapabilities());
+ // for some reason PhantomJS doesn't find the label even if it detects
+ // the presence
+ browsersToTest.remove(Browser.PHANTOMJS.getDesiredCapabilities());
+ return browsersToTest;
+ }
+
+ @Test
+ public void testLabelWidths() {
+ openTestURL();
+ waitForElementPresent(By.className("v-grid"));
+
+ GridElement grid = $(GridElement.class).first();
+ int gridWidth = grid.getSize().width;
+
+ grid.getRow(2).click();
+ waitForElementPresent(By.id("lbl2"));
+
+ // space left over from first label should be divided equally
+ double expectedWidth = (double) (gridWidth - 200) / 2;
+ assertLabelWidth("lbl2", expectedWidth);
+ assertLabelWidth("lbl3", expectedWidth);
+ }
+
+ private void assertLabelWidth(String id, double expectedWidth) {
+ // 1px leeway for calculations
+ assertThat("Unexpected label width.", (double) $(LabelElement.class)
+ .id(id).getSize().width, closeTo(expectedWidth, 1d));
+ }
+}