summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAlexey Fansky <alexey.fansky@effective-soft.com>2015-02-20 17:13:55 -0800
committerVaadin Code Review <review@vaadin.com>2015-03-03 08:24:00 +0000
commit2ad8f945b2b4847a539d82b6593aee42095c8c56 (patch)
tree6524a65c73588dc07214c6c156bed08e2e8d4eff /uitest
parent0aa4af8f266a46a93ae7817c5e04dcef79389c94 (diff)
downloadvaadin-framework-2ad8f945b2b4847a539d82b6593aee42095c8c56.tar.gz
vaadin-framework-2ad8f945b2b4847a539d82b6593aee42095c8c56.zip
Restoring overflow-x and overflow-y in runWebkitOverflowAutoFix (#16650)
Change-Id: I7be1c1571ee5ede0ce481faf823f5f271a280a8a
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFix.java29
-rw-r--r--uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java43
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java137
3 files changed, 209 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFix.java b/uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFix.java
new file mode 100644
index 0000000000..d6d4bdb3da
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFix.java
@@ -0,0 +1,29 @@
+package com.vaadin.tests.components.customlayout;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.ui.AbstractComponent;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class OverflowAutoFix extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new RunOverflowFix());
+ }
+
+ public class RunOverflowFix extends AbstractComponent {
+ }
+
+ @Override
+ public String getTestDescription() {
+ return "Overflow-x and overflow-y should be restored when using runWebkitOverflowAutoFix.<br>"
+ + "Outer size: 300x200px, inner size: 350x250px";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 16650;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java b/uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java
new file mode 100644
index 0000000000..d56e07f60b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components.customlayout;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class OverflowAutoFixTest extends MultiBrowserTest {
+ @Test
+ public void testRestoreOverflowHidden() throws InterruptedException {
+ openTestURL();
+
+ click("run-button-one");
+
+ assertElementCssValueEquals("first-scrollbar", "overflow", "scroll");
+ assertElementCssValueEquals("second-scrollbar", "overflow-x", "hidden");
+ assertElementCssValueEquals("third-scrollbar", "overflow-y", "hidden");
+ }
+
+ @Test
+ public void testRestoreOverflowOther() throws InterruptedException {
+ openTestURL();
+
+ click("run-button-two");
+
+ assertElementCssValueEquals("first-scrollbar", "overflow", "visible");
+ assertElementCssValueEquals("second-scrollbar", "overflow-x", "scroll");
+ assertElementCssValueEquals("third-scrollbar", "overflow-y", "auto");
+ }
+
+ private void click(String className) {
+ findElement(By.className(className)).click();
+ }
+
+ private void assertElementCssValueEquals(String className,
+ String propertyName, String expected) {
+ Assert.assertEquals(String.format(
+ "Unexpected value for property '%s' on element '%s',",
+ propertyName, className), expected,
+ findElement(By.className(className)).getCssValue(propertyName));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java
new file mode 100644
index 0000000000..a6789ebaf6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/RunOverflowFixConnector.java
@@ -0,0 +1,137 @@
+package com.vaadin.tests.widgetset.client;
+
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Panel;
+import com.vaadin.client.ComponentConnector;
+import com.vaadin.client.ConnectorHierarchyChangeEvent;
+import com.vaadin.client.WidgetUtil;
+import com.vaadin.client.ui.AbstractComponentContainerConnector;
+import com.vaadin.client.ui.VVerticalLayout;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.orderedlayout.VerticalLayoutState;
+import com.vaadin.tests.components.customlayout.OverflowAutoFix;
+
+@SuppressWarnings("deprecation")
+@Connect(OverflowAutoFix.RunOverflowFix.class)
+public class RunOverflowFixConnector extends
+ AbstractComponentContainerConnector {
+
+ private static final String CONTENT1 = "Overflow:<br>Fix1 (scroll): Both scrollbars should be shown<br>Fix2 (visible): no scrollbars should be shown";
+ private static final String CONTENT2 = "OverflowX:<br>Fix1 (hidden): Horizontal scrollbar should be hidden, vertical shown<br>Fix2 (scroll): Both scrollbars should be shown";
+ private static final String CONTENT3 = "OverflowY:<br>Fix1 (hidden): Vertical scrollbar should be hidden, horizontal shown<br>Fix2 (auto): Both scrollbars should be shown";
+ private static final String BACKGROUND = "#ddd";
+
+ @Override
+ public void init() {
+ super.init();
+
+ final Panel overflow = createScrollPanel(CONTENT1);
+ overflow.addStyleName("first-scrollbar");
+ final Panel overflowX = createScrollPanel(CONTENT2);
+ overflowX.addStyleName("second-scrollbar");
+ final Panel overflowY = createScrollPanel(CONTENT3);
+ overflowY.addStyleName("third-scrollbar");
+
+ Button runFix = new Button("Click to runWebkitOverflowAutoFix",
+ new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ overflow.getElement().getStyle()
+ .setOverflow(Style.Overflow.SCROLL);
+ WidgetUtil.runWebkitOverflowAutoFix(overflow
+ .getElement());
+
+ overflowX.getElement().getStyle()
+ .setOverflowX(Style.Overflow.HIDDEN);
+ WidgetUtil.runWebkitOverflowAutoFix(overflowX
+ .getElement());
+
+ overflowY.getElement().getStyle()
+ .setOverflowY(Style.Overflow.HIDDEN);
+ WidgetUtil.runWebkitOverflowAutoFix(overflowY
+ .getElement());
+ }
+ });
+ runFix.addStyleName("run-button-one");
+ getWidget().add(runFix);
+
+ Button runFix2 = new Button("Click to runWebkitOverflowAutoFix 2",
+ new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ overflow.getElement().getStyle()
+ .setOverflow(Style.Overflow.VISIBLE);
+ WidgetUtil.runWebkitOverflowAutoFix(overflow
+ .getElement());
+
+ overflowX.getElement().getStyle()
+ .setOverflowX(Style.Overflow.SCROLL);
+ WidgetUtil.runWebkitOverflowAutoFix(overflowX
+ .getElement());
+
+ overflowY.getElement().getStyle()
+ .setOverflowY(Style.Overflow.AUTO);
+ WidgetUtil.runWebkitOverflowAutoFix(overflowY
+ .getElement());
+ }
+ });
+ runFix2.addStyleName("run-button-two");
+ getWidget().add(runFix2);
+
+ addSpacer(10);
+ getWidget().add(overflow);
+ addSpacer(60);
+ getWidget().add(overflowX);
+ addSpacer(60);
+ getWidget().add(overflowY);
+ }
+
+ private void addSpacer(double height) {
+ Element spacer = DOM.createDiv();
+ spacer.getStyle().setHeight(height, Unit.PX);
+ spacer.getStyle().setWidth(10, Unit.PX);
+ getWidget().getElement().appendChild(spacer);
+ }
+
+ private Panel createScrollPanel(String info) {
+ FlowPanel outer = new FlowPanel();
+ outer.setPixelSize(300, 200);
+ getWidget().add(outer);
+
+ HTML inner = new HTML(info);
+ inner.setPixelSize(350, 250);
+ inner.getElement().getStyle().setBackgroundColor(BACKGROUND);
+ // for some reason theme sets size to 0
+ inner.getElement().getStyle().setFontSize(12, Style.Unit.PX);
+ outer.add(inner);
+
+ return outer;
+ }
+
+ @Override
+ public VVerticalLayout getWidget() {
+ return (VVerticalLayout) super.getWidget();
+ }
+
+ @Override
+ public VerticalLayoutState getState() {
+ return (VerticalLayoutState) super.getState();
+ }
+
+ @Override
+ public void updateCaption(ComponentConnector connector) {
+ }
+
+ @Override
+ public void onConnectorHierarchyChange(
+ ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
+ }
+} \ No newline at end of file