summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-11-01 14:11:39 +0200
committerVaadin Code Review <review@vaadin.com>2015-05-05 07:53:41 +0000
commitcdc296af3ce940eedbcff5bd9162d2ee0e8acae8 (patch)
tree24e360b6f9d46e20724263d87ea80d72158e031b
parentef2c0154e7b78b702520970d2c38f452620f9158 (diff)
downloadvaadin-framework-cdc296af3ce940eedbcff5bd9162d2ee0e8acae8.tar.gz
vaadin-framework-cdc296af3ce940eedbcff5bd9162d2ee0e8acae8.zip
Set display to inline-block for TOP_CENTER and TOP_RIGHT (#14137).
Change-Id: I317eefabfc93fd00a848f6b57cba9bd73600b3b6
-rw-r--r--WebContent/VAADIN/themes/base/layout/layout.scss4
-rw-r--r--uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignments.java62
-rw-r--r--uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java77
3 files changed, 142 insertions, 1 deletions
diff --git a/WebContent/VAADIN/themes/base/layout/layout.scss b/WebContent/VAADIN/themes/base/layout/layout.scss
index 049c527518..fe3fcd17ed 100644
--- a/WebContent/VAADIN/themes/base/layout/layout.scss
+++ b/WebContent/VAADIN/themes/base/layout/layout.scss
@@ -139,6 +139,8 @@ div.v-layout.v-horizontal.v-widget {
}
.v-align-middle > .v-widget,
+.v-align-right > .v-widget,
+.v-align-center > .v-widget,
.v-align-bottom > .v-widget {
display: inline-block;
}
@@ -216,4 +218,4 @@ div.v-layout.v-horizontal.v-widget {
vertical-align: middle;
}
-} \ No newline at end of file
+}
diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignments.java b/uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignments.java
new file mode 100644
index 0000000000..8b3cd02d9e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignments.java
@@ -0,0 +1,62 @@
+/*
+ * 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.gridlayout;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * Test UI for TOP_CENTER and TOP_RIGHT alignments in VerticalLayout.
+ *
+ * @author Vaadin Ltd
+ */
+public class ComponentAlignments extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ CheckBox topcenter = new CheckBox("Top Center");
+ topcenter.setSizeUndefined();
+ VerticalLayout verticalLayout1 = new VerticalLayout(topcenter);
+ verticalLayout1.setHeight("40px");
+ verticalLayout1.setWidth("140px");
+ verticalLayout1.setComponentAlignment(topcenter, Alignment.TOP_CENTER);
+ addComponent(verticalLayout1);
+
+ CheckBox topright = new CheckBox("Top Right");
+ topright.setSizeUndefined();
+ VerticalLayout verticalLayout2 = new VerticalLayout(topright);
+ verticalLayout2.setHeight("40px");
+ verticalLayout2.setWidth("140px");
+ verticalLayout2.setComponentAlignment(topright, Alignment.TOP_RIGHT);
+ addComponent(verticalLayout2);
+
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14137;
+ }
+
+ @Override
+ public String getDescription() {
+ return "TOP_CENTER and TOP_RIGHT alignments should work in VerticalLayout";
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java
new file mode 100644
index 0000000000..cdc8dc77f1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.gridlayout;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for TOP_CENTER and TOP_RIGHT alignments in VerticalLayout.
+ *
+ * @author Vaadin Ltd
+ */
+public class ComponentAlignmentsTest extends MultiBrowserTest {
+
+ @Test
+ public void testTopCenterAlignment() {
+ openTestURL();
+
+ CheckBoxElement checkbox = $(CheckBoxElement.class).first();
+ WebElement parent = checkbox.findElement(By.xpath(".."));
+
+ int leftSpaceSize = checkbox.getLocation().getX()
+ - parent.getLocation().getX();
+ int rightSpaceSize = parent.getLocation().getX()
+ + parent.getSize().getWidth() - checkbox.getLocation().getX()
+ - checkbox.getSize().getWidth();
+ Assert.assertTrue("No space on the left for centered element",
+ leftSpaceSize > 0);
+ Assert.assertTrue("No space on the right for centered element",
+ rightSpaceSize > 0);
+
+ int diff = Math.abs(rightSpaceSize - leftSpaceSize);
+ Assert.assertTrue("Element is not in the center, diff:" + diff,
+ diff <= 2); // IE11 2pixels
+ }
+
+ @Test
+ public void testTopRightAlignment() {
+ openTestURL();
+
+ CheckBoxElement checkbox = $(CheckBoxElement.class).get(1);
+ WebElement parent = checkbox.findElement(By.xpath(".."));
+
+ int leftSpaceSize = checkbox.getLocation().getX()
+ - parent.getLocation().getX();
+ int rightSpaceSize = parent.getLocation().getX()
+ + parent.getSize().getWidth() - checkbox.getLocation().getX()
+ - checkbox.getSize().getWidth();
+ Assert.assertTrue("No space on the left for centered element",
+ leftSpaceSize > 0);
+ Assert.assertTrue("There is some space on the right for the element",
+ rightSpaceSize <= 1);
+
+ int sizeDiff = parent.getSize().getWidth()
+ - checkbox.getSize().getWidth();
+ Assert.assertTrue("Element is not in aligned to the right",
+ Math.abs(sizeDiff - leftSpaceSize) <= 1);
+ }
+}