summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-11-06 09:15:15 +0200
committerVaadin Code Review <review@vaadin.com>2014-12-10 08:18:00 +0000
commit8ce89592362226d6687e1267632a75d85774b67d (patch)
tree5fb85426e2f0b66f02aeeb2bd49e7d3570ab0669 /uitest
parentf1f089772749a0eb4b031f1876b95bb684565473 (diff)
downloadvaadin-framework-8ce89592362226d6687e1267632a75d85774b67d.tar.gz
vaadin-framework-8ce89592362226d6687e1267632a75d85774b67d.zip
Position calendar popup on the left side if there is no space (#14757).
Change-Id: I83836bbf077033712a569c8eff52576b012b4dee
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java52
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java68
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java27
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java30
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java43
6 files changed, 263 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java
new file mode 100644
index 0000000000..4469ad3b1a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java
@@ -0,0 +1,52 @@
+/*
+ * 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.datefield;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupDateField;
+
+/**
+ * Test UI for date field Popup calendar.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class DateFieldPopupPosition extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ HorizontalLayout layout = new HorizontalLayout();
+ addComponent(layout);
+ Label gap = new Label();
+ gap.setWidth(250, Unit.PIXELS);
+ layout.addComponent(gap);
+ PopupDateField field = new PopupDateField();
+ layout.addComponent(field);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14757;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Calendar popup should not placed on the top of text field when "
+ + "there is no space on bottom.";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java
new file mode 100644
index 0000000000..f896519aae
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.datefield;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for date field popup calendar position.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class DateFieldPopupPositionTest extends MultiBrowserTest {
+
+ @Test
+ public void testPopupPosition() {
+ openTestURL();
+
+ int height = getFieldBottom() + 150;
+ adjustBrowserWindow(height);
+
+ openPopup();
+
+ checkPopupPosition();
+ }
+
+ protected abstract void checkPopupPosition();
+
+ protected WebElement getPopup() {
+ return findElement(By.className("v-datefield-popup"));
+ }
+
+ private void adjustBrowserWindow(int height) {
+ Dimension size = getDriver().manage().window().getSize();
+ getDriver().manage().window()
+ .setSize(new Dimension(size.getWidth(), height));
+ }
+
+ private int getFieldBottom() {
+ DateFieldElement dateField = $(DateFieldElement.class).first();
+ return dateField.getLocation().getY() + dateField.getSize().getHeight();
+ }
+
+ private void openPopup() {
+ findElement(By.className("v-datefield-button")).click();
+ if (!isElementPresent(By.className("v-datefield-popup"))) {
+ findElement(By.className("v-datefield-button")).click();
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java
new file mode 100644
index 0000000000..8e4de77837
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java
@@ -0,0 +1,27 @@
+/*
+ * 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.datefield;
+
+/**
+ * Test UI for date field Popup calendar in default theme.
+ *
+ * All UI initialization is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+public class DefaultDateFieldPopupPosition extends DateFieldPopupPosition {
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java
new file mode 100644
index 0000000000..61cc876a3f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.datefield;
+
+import org.junit.Assert;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+
+/**
+ * Test for date field popup calendar position in default theme.
+ *
+ * Test method is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+public class DefaultDateFieldPopupPositionTest extends
+ DateFieldPopupPositionTest {
+
+ @Override
+ protected void checkPopupPosition() {
+ DateFieldElement field = $(DateFieldElement.class).first();
+ int right = field.getLocation().getX() + field.getSize().getWidth();
+ WebElement popup = getPopup();
+
+ Assert.assertTrue("Calendar popup has wrong X coordinate="
+ + popup.getLocation().getX() + " , right side of the field is "
+ + right, popup.getLocation().getX() >= right);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java
new file mode 100644
index 0000000000..59ff6aa9e8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java
@@ -0,0 +1,30 @@
+/*
+ * 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.datefield;
+
+import com.vaadin.annotations.Theme;
+
+/**
+ * Test UI for date field Popup calendar in Valo theme.
+ *
+ * All UI initialization is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+@Theme("valo")
+public class ValoDateFieldPopupPosition extends DateFieldPopupPosition {
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java
new file mode 100644
index 0000000000..4009b9d991
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.datefield;
+
+import org.junit.Assert;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+
+/**
+ * Test for date field popup calendar position in Valo theme.
+ *
+ * Test method is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+public class ValoDateFieldPopupPositionTest extends DateFieldPopupPositionTest {
+
+ @Override
+ protected void checkPopupPosition() {
+ DateFieldElement field = $(DateFieldElement.class).first();
+ WebElement popup = getPopup();
+ int left = field.getLocation().getX();
+ int popupRight = popup.getLocation().getX()
+ + popup.getSize().getWidth();
+
+ Assert.assertTrue("Calendar popup has wrong X coordinate=" + popupRight
+ + " , left side of the field is " + left, popupRight <= left);
+ }
+}