aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2014-09-03 13:36:22 +0000
committerVaadin Code Review <review@vaadin.com>2014-09-03 13:36:22 +0000
commite29e468727a262983966e9413fee621124471b0a (patch)
tree8f8013e1675be5fd2e0775d8ccc6176f4e8c023d /uitest/src
parent1e282eed6be3f2aa84ce0da512b6bd8a768b90e1 (diff)
parent927e424acc1e43a12bdbbcd971302d00717af540 (diff)
downloadvaadin-framework-e29e468727a262983966e9413fee621124471b0a.tar.gz
vaadin-framework-e29e468727a262983966e9413fee621124471b0a.zip
Merge "Merge remote-tracking branch 'origin/master' into grid" into grid
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java1
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html41
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.java116
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java82
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java91
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java105
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java82
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java23
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java79
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java80
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/IntArrayRenderer.java17
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/RowAwareRenderer.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacing.java91
-rw-r--r--uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java104
-rw-r--r--uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java10
-rw-r--r--uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java79
-rw-r--r--uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java79
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java76
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElementTest.java147
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java7
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemove.java61
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java121
-rw-r--r--uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java15
-rw-r--r--uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java6
-rw-r--r--uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html239
-rw-r--r--uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java45
-rw-r--r--uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java200
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java10
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java12
-rw-r--r--uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java5
-rw-r--r--uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java5
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java12
-rw-r--r--uitest/src/com/vaadin/tests/tb3/DndActionsTest.java50
-rw-r--r--uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java1
-rw-r--r--uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java3
35 files changed, 1714 insertions, 390 deletions
diff --git a/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java b/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java
index b815705883..e118558528 100644
--- a/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java
+++ b/uitest/src/com/vaadin/tests/components/LayoutAttachListenerInfo.java
@@ -122,6 +122,7 @@ public class LayoutAttachListenerInfo extends TestBase {
final GridLayout g = new GridLayout(4, 4);
g.setWidth("300px");
g.setHeight("300px");
+ g.setHideEmptyRowsAndColumns(true);
g.addComponentAttachListener(new ComponentAttachListener() {
@Override
public void componentAttachedToContainer(ComponentAttachEvent event) {
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html
deleted file mode 100644
index 15bf29a0fd..0000000000
--- a/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8080/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.calendar.NotificationTestUI?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td>
- <td>83,11</td>
-</tr>
-<tr>
- <td>mouseMove</td>
- <td>vaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[3]/domChild[0]/domChild[3]</td>
- <td>10,10</td>
-</tr>
-<tr>
- <td>closeNotification</td>
- <td>//div[@id='runcomvaadintestscomponentscalendarNotificationTestUI-1842310749-overlays']/div</td>
- <td>0,0</td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>no-notification</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.java
new file mode 100644
index 0000000000..9b9a64624a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.java
@@ -0,0 +1,116 @@
+/*
+ * 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.calendar;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Calendar;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickEvent;
+import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickHandler;
+import com.vaadin.ui.components.calendar.event.BasicEvent;
+import com.vaadin.ui.components.calendar.event.CalendarEvent;
+import com.vaadin.ui.components.calendar.event.CalendarEventProvider;
+
+public class CalendarNotifications extends AbstractTestUIWithLog {
+
+ private DummyEventProvider provider;
+
+ private static class DummyEventProvider implements CalendarEventProvider {
+
+ private int index;
+ private List<CalendarEvent> events = new ArrayList<CalendarEvent>();
+
+ public void addEvent(Date date) {
+ BasicEvent e = new BasicEvent();
+ e.setAllDay(true);
+ e.setStart(date);
+ e.setEnd(date);
+ e.setCaption("Some event " + ++index);
+ events.add(e);
+ }
+
+ @Override
+ public List<CalendarEvent> getEvents(Date startDate, Date endDate) {
+ return events;
+ }
+
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ GridLayout content = new GridLayout(1, 2);
+ content.setSizeFull();
+ content.setRowExpandRatio(1, 1.0f);
+ addComponent(content);
+ final Button btn = new Button("Show working notification",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Notification
+ .show("This will disappear when you move your mouse!");
+ }
+ });
+ content.addComponent(btn);
+
+ provider = new DummyEventProvider();
+ final Calendar cal = new Calendar(provider);
+ cal.setLocale(Locale.US);
+ cal.setSizeFull();
+ cal.setHandler(new DateClickHandler() {
+ @Override
+ public void dateClick(DateClickEvent event) {
+ provider.addEvent(event.getDate());
+ log("Opening a notification");
+ Notification
+ .show("This should disappear when the mouse is moved.");
+
+ // this requestRepaint call interferes with the notification
+ cal.markAsDirty();
+ }
+ });
+ content.addComponent(cal);
+
+ java.util.Calendar javaCal = java.util.Calendar.getInstance();
+ javaCal.set(java.util.Calendar.YEAR, 2000);
+ javaCal.set(java.util.Calendar.MONTH, 0);
+ javaCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
+ Date start = javaCal.getTime();
+ javaCal.set(java.util.Calendar.DAY_OF_MONTH, 31);
+ Date end = javaCal.getTime();
+
+ cal.setStartDate(start);
+ cal.setEndDate(end);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Notifications should be opened and then closed after the user has moved the mouse.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6769;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java
new file mode 100644
index 0000000000..2431b2f4d0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.calendar;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests opening and closing of calendar notifications.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class CalendarNotificationsTest extends MultiBrowserTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return NotificationTestUI.class;
+ }
+
+ @Override
+ protected DesiredCapabilities getDesiredCapabilities() {
+ DesiredCapabilities desiredCapabilities = new DesiredCapabilities(
+ super.getDesiredCapabilities());
+ desiredCapabilities.setCapability("enablePersistentHover", false);
+ desiredCapabilities.setCapability("requireWindowFocus", true);
+
+ return desiredCapabilities;
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // TODO: IE testing is pending on #14312. For now, IE testing is handled
+ // with a logger.
+ return getBrowsersExcludingIE();
+ }
+
+ @Test
+ public void notificationTest() throws Exception {
+ openTestURL();
+
+ WebElement day = findElements(By.className("v-calendar-day-number"))
+ .get(2);
+ // IE8 requires you to click on the text part to fire the event
+ new Actions(getDriver()).moveToElement(day, 83, 11).click().perform();
+
+ Assert.assertTrue("There should be a notification",
+ $(NotificationElement.class).exists());
+
+ // move the mouse around a bit
+ new Actions(getDriver()).moveByOffset(5, 5).moveByOffset(100, 100)
+ .perform();
+
+ // wait until the notification has animated out
+ sleep(1000);
+
+ Assert.assertFalse("There should be no notification on the page",
+ $(NotificationElement.class).exists());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java
new file mode 100644
index 0000000000..7ab6f01113
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java
@@ -0,0 +1,91 @@
+/*
+ * 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.calendar;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests opening and closing of calendar notifications.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class CalendarNotificationsTestIE extends MultiBrowserTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return CalendarNotifications.class;
+ }
+
+ @Override
+ protected DesiredCapabilities getDesiredCapabilities() {
+ DesiredCapabilities desiredCapabilities = new DesiredCapabilities(
+ super.getDesiredCapabilities());
+ desiredCapabilities.setCapability("enablePersistentHover", false);
+ desiredCapabilities.setCapability("requireWindowFocus", true);
+
+ return desiredCapabilities;
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsers = super.getBrowsersToTest();
+ browsers.remove(Browser.CHROME.getDesiredCapabilities());
+ browsers.remove(Browser.FIREFOX.getDesiredCapabilities());
+ browsers.remove(Browser.OPERA.getDesiredCapabilities());
+ browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());
+ browsers.remove(Browser.SAFARI.getDesiredCapabilities());
+ return browsers;
+ }
+
+ @Test
+ public void notificationTest() throws Exception {
+ openTestURL();
+
+ WebElement day = findElements(By.className("v-calendar-day-number"))
+ .get(2);
+ // IE8 requires you to click on the text part to fire the event
+ new Actions(getDriver()).moveToElement(day, 83, 11).click().perform();
+
+ // check that a notification was opened, this is done with a log instead
+ // of a screenshot or element presence check due to problems with IE
+ // webdriver
+ String text = findElement(By.id("Log")).findElement(
+ By.className("v-label")).getText();
+ Assert.assertTrue("Notification should've opened",
+ "1. Opening a notification".equals(text));
+
+ // move the mouse around a bit
+ new Actions(getDriver()).moveByOffset(5, 5).moveByOffset(100, 100)
+ .perform();
+
+ // wait until the notification has animated out
+ sleep(1000);
+
+ Assert.assertFalse("There should be no notification on the page",
+ $(NotificationElement.class).exists());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java
new file mode 100644
index 0000000000..824ad0941f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java
@@ -0,0 +1,105 @@
+/*
+ * 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.calendar;
+
+import java.util.Date;
+import java.util.List;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Calendar;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.components.calendar.event.BasicEvent;
+import com.vaadin.ui.components.calendar.event.BasicEventProvider;
+import com.vaadin.ui.components.calendar.event.CalendarEvent;
+import com.vaadin.ui.components.calendar.event.CalendarEventProvider.EventSetChangeEvent;
+import com.vaadin.ui.components.calendar.event.CalendarEventProvider.EventSetChangeListener;
+
+/**
+ * Test UI to check ability to reschedule events unlimited times.
+ *
+ * @author Vaadin Ltd
+ */
+public class CalendarRescheduleEvent extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Calendar calendar = new Calendar("Test calendar");
+ final java.util.Calendar cal = getAdjustedCalendar(1);
+
+ Date from = cal.getTime();
+
+ cal.add(java.util.Calendar.HOUR, 1);
+ Date to = cal.getTime();
+
+ final BasicEvent basicEvent = new BasicEvent("event", "description",
+ from, to);
+
+ HorizontalLayout info = new HorizontalLayout();
+ info.setSpacing(true);
+ info.setMargin(true);
+ addComponent(info);
+ final Label startLbl = new Label();
+ startLbl.addStyleName("start");
+ info.addComponent(startLbl);
+
+ final Label endLbl = new Label();
+ endLbl.addStyleName("end");
+ info.addComponent(endLbl);
+
+ BasicEventProvider provider = new BasicEventProvider();
+ provider.addEvent(basicEvent);
+ calendar.setEventProvider(provider);
+ provider.addEventSetChangeListener(new EventSetChangeListener() {
+
+ @Override
+ public void eventSetChange(EventSetChangeEvent event) {
+ List<CalendarEvent> events = event.getProvider().getEvents(
+ new Date(0), new Date(Long.MAX_VALUE));
+ CalendarEvent calEvent = events.get(0);
+ Date startEvent = calEvent.getStart();
+ Date endEvent = calEvent.getEnd();
+
+ startLbl.setValue(String.valueOf(startEvent.getTime()));
+ endLbl.setValue(String.valueOf(endEvent.getTime()));
+ }
+ });
+
+ addComponent(calendar);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "It should be possible to reschedule events unlimited times.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 13233;
+ }
+
+ private java.util.Calendar getAdjustedCalendar(int hour) {
+ final java.util.Calendar cal = java.util.Calendar.getInstance();
+
+ cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
+ cal.set(java.util.Calendar.MINUTE, 0);
+ cal.set(java.util.Calendar.SECOND, 0);
+ cal.set(java.util.Calendar.MILLISECOND, 0);
+ return cal;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java
new file mode 100644
index 0000000000..fb8cce7d53
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.calendar;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.DndActionsTest;
+
+/**
+ * Test to check ability to reschedule events unlimited times.
+ *
+ * @author Vaadin Ltd
+ */
+public class CalendarRescheduleEventTest extends DndActionsTest {
+
+ @Test
+ public void rescheduleEventSeveralTimes() {
+ openTestURL();
+
+ // Reschedule event for the first time
+ int y = rescheduleEvent(20);
+
+ WebElement startElement = getDriver()
+ .findElement(By.className("start"));
+ WebElement endElement = getDriver().findElement(By.className("end"));
+
+ long start = Long.parseLong(startElement.getText());
+ long end = Long.parseLong(endElement.getText());
+
+ long duration = end - start;
+
+ // Reschedule event for the second time
+ int yNew = rescheduleEvent(20);
+
+ startElement = getDriver().findElement(By.className("start"));
+ endElement = getDriver().findElement(By.className("end"));
+
+ long newStart = Long.parseLong(startElement.getText());
+ long newEnd = Long.parseLong(endElement.getText());
+
+ Assert.assertTrue(
+ "Second rescheduling did not change the event start time",
+ newStart > start);
+ Assert.assertEquals(
+ "Duration of the event after second rescheduling has been changed",
+ duration, newEnd - newStart);
+ Assert.assertTrue(
+ "Second rescheduling did not change the event Y coordinate",
+ yNew > y);
+ }
+
+ /*
+ * DnD event by Y axis
+ */
+ private int rescheduleEvent(int yOffset) {
+ WebElement eventCaption = getDriver().findElement(
+ By.className("v-calendar-event-caption"));
+
+ dragAndDrop(eventCaption, 0, yOffset);
+
+ eventCaption = getDriver().findElement(
+ By.className("v-calendar-event-caption"));
+ return eventCaption.getLocation().getY();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java
index f664149cce..e3e5606089 100644
--- a/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java
@@ -24,15 +24,14 @@ import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.tests.tb3.DndActionsTest;
/**
*
* @author Vaadin Ltd
*/
-public class CalendarResizeOverlappingEventsTest extends MultiBrowserTest {
+public class CalendarResizeOverlappingEventsTest extends DndActionsTest {
private int noOverlapWidth;
private int oneOverlapWidth;
@@ -100,23 +99,7 @@ public class CalendarResizeOverlappingEventsTest extends MultiBrowserTest {
}
private void dragAndDrop(WebElement element, int yOffset) {
- /*
- * Selenium doesn't properly drag and drop items in IE8. It tries to
- * start dragging an element from a position above the element itself.
- */
- if (BrowserUtil.isIE8(getDesiredCapabilities())) {
- Actions action = new Actions(getDriver());
- action.moveToElement(element);
- action.moveByOffset(0, 1);
- action.clickAndHold();
- action.moveByOffset(0, yOffset);
- action.release();
- action.build().perform();
- } else {
- Actions action = new Actions(getDriver());
- action.dragAndDropBy(element, 0, yOffset);
- action.build().perform();
- }
+ dragAndDrop(element, 0, yOffset);
}
private void initParams() {
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java b/uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java
new file mode 100644
index 0000000000..f65b020bd1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java
@@ -0,0 +1,79 @@
+/*
+ * 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.combobox;
+
+import java.util.ArrayList;
+
+import com.vaadin.server.Page;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
+
+/**
+ * Test UI for combobox popup which should be closed on any click outside it.
+ *
+ * @author Vaadin Ltd
+ */
+public class ComboboxMenuBarAutoopen extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ HorizontalLayout layout = new HorizontalLayout();
+ layout.setSpacing(true);
+ ArrayList<String> options = new ArrayList<String>();
+ options.add("1");
+ options.add("2");
+ options.add("3");
+ ComboBox combo = new ComboBox(null, options);
+ layout.addComponent(combo);
+
+ MenuBar menubar = getMenubar();
+ layout.addComponent(menubar);
+
+ addComponent(layout);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Combobox popup should close on click to other popup or associated components.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14321;
+ }
+
+ private MenuBar getMenubar() {
+ MenuBar menubar = new MenuBar();
+ menubar.setAutoOpen(true);
+ MenuItem item = menubar.addItem("auto-open", null);
+ item.addItem("sub-item 1", new MenuBar.Command() {
+
+ @Override
+ public void menuSelected(MenuItem selectedItem) {
+ Notification notification = new Notification("Test",
+ Type.HUMANIZED_MESSAGE);
+ notification.show(Page.getCurrent());
+ }
+ });
+ return menubar;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java
new file mode 100644
index 0000000000..5c8c971194
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.combobox;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.ComboBoxElement;
+import com.vaadin.testbench.elements.MenuBarElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test that checks whether Combobox popup is closed on click to autoopen
+ * menubar and its item.
+ *
+ * @author Vaadin Ltd
+ */
+public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest {
+
+ @Test
+ public void closeComboboxPopupOnClickToMenuBar() {
+ openTestURL();
+
+ openPopup();
+ MenuBarElement menuBar = selectMenuBar();
+ menuBar.click();
+ Assert.assertFalse("Combobox popup items are visible",
+ isElementPresent(By.className("gwt-MenuItem")));
+
+ openPopup();
+ menuBar = selectMenuBar();
+
+ WebElement menuBarItem = findElement(By
+ .className("v-menubar-menuitem-caption"));
+ Actions actions = new Actions(getDriver());
+ actions.moveToElement(menuBarItem).build().perform();
+ menuBar.click();
+ Assert.assertFalse("Combobox popup items are visible",
+ isElementPresent(By.className("gwt-MenuItem")));
+ }
+
+ private void openPopup() {
+ ComboBoxElement combobox = $(ComboBoxElement.class).first();
+ combobox.click();
+ combobox.openPopup();
+ combobox.focus();
+
+ Actions actions = new Actions(getDriver());
+ actions.moveToElement(
+ getDriver().findElement(By.className("gwt-MenuItem"))).build()
+ .perform();
+ }
+
+ private MenuBarElement selectMenuBar() {
+ MenuBarElement menuBar = $(MenuBarElement.class).first();
+ menuBar.focus();
+
+ Actions actions = new Actions(getDriver());
+ actions.moveToElement(menuBar).build().perform();
+
+ return menuBar;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/IntArrayRenderer.java b/uitest/src/com/vaadin/tests/components/grid/IntArrayRenderer.java
index 142c370e13..ccedcc908a 100644
--- a/uitest/src/com/vaadin/tests/components/grid/IntArrayRenderer.java
+++ b/uitest/src/com/vaadin/tests/components/grid/IntArrayRenderer.java
@@ -15,22 +15,23 @@
*/
package com.vaadin.tests.components.grid;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.ui.components.grid.AbstractRenderer;
+import elemental.json.Json;
+import elemental.json.JsonArray;
+import elemental.json.JsonValue;
+
public class IntArrayRenderer extends AbstractRenderer<int[]> {
public IntArrayRenderer() {
super(int[].class);
}
@Override
- public Object encode(int[] value) {
- try {
- return new JSONArray(value);
- } catch (JSONException e) {
- throw new RuntimeException(e);
+ public JsonValue encode(int[] value) {
+ JsonArray valueArray = Json.createArray();
+ for (int i = 0; i < value.length; ++i) {
+ valueArray.set(i, value[i]);
}
+ return valueArray;
}
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/RowAwareRenderer.java b/uitest/src/com/vaadin/tests/components/grid/RowAwareRenderer.java
index f55f5f064c..41ccddc2cf 100644
--- a/uitest/src/com/vaadin/tests/components/grid/RowAwareRenderer.java
+++ b/uitest/src/com/vaadin/tests/components/grid/RowAwareRenderer.java
@@ -15,12 +15,13 @@
*/
package com.vaadin.tests.components.grid;
-import org.json.JSONObject;
-
import com.vaadin.tests.widgetset.client.grid.RowAwareRendererConnector.RowAwareRendererRpc;
import com.vaadin.ui.Label;
import com.vaadin.ui.components.grid.AbstractRenderer;
+import elemental.json.Json;
+import elemental.json.JsonValue;
+
public class RowAwareRenderer extends AbstractRenderer<Void> {
public RowAwareRenderer(final Label debugLabel) {
super(Void.class);
@@ -34,8 +35,8 @@ public class RowAwareRenderer extends AbstractRenderer<Void> {
}
@Override
- public Object encode(Void value) {
- return JSONObject.NULL;
+ public JsonValue encode(Void value) {
+ return Json.createNull();
}
}
diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacing.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacing.java
new file mode 100644
index 0000000000..ce59f9c89f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacing.java
@@ -0,0 +1,91 @@
+/*
+ * 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.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.GridLayout;
+
+public class GridLayoutExtraSpacing extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getUI().getPage()
+ .getStyles()
+ .add(".v-gridlayout {background: red;} .v-csslayout {background: white;}");
+
+ final GridLayout gl = new GridLayout(4, 4);
+
+ final CheckBox cb = new CheckBox("spacing");
+ cb.addValueChangeListener(new ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ gl.setSpacing(cb.getValue());
+ }
+ });
+ cb.setValue(true);
+ addComponent(cb);
+
+ final CheckBox cb2 = new CheckBox("hide empty rows/columns");
+ cb2.addValueChangeListener(new ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ gl.setHideEmptyRowsAndColumns(cb2.getValue());
+ }
+ });
+ addComponent(cb2);
+ gl.setWidth("1000px");
+ gl.setHeight("500px");
+
+ CssLayout ta = new CssLayout();
+ ta.setSizeFull();
+ // Only on last row
+ gl.addComponent(ta, 0, 3, 3, 3);
+
+ gl.setRowExpandRatio(3, 1);
+ addComponent(gl);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java
new file mode 100644
index 0000000000..64b9997dcc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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 java.io.IOException;
+
+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.testbench.elements.CssLayoutElement;
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class GridLayoutExtraSpacingTest extends MultiBrowserTest {
+
+ @Test
+ public void componentRowFour() throws IOException, Exception {
+ openTestURL();
+ CssLayoutElement component = $(CssLayoutElement.class).first();
+ GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
+
+ // Spacing on, not hiding empty rows/columns
+ // There should be 3 * 6px spacing (red) above the csslayout
+ verifySpacingAbove(3 * 6, gridLayout, component);
+
+ CheckBoxElement spacingCheckbox = $(CheckBoxElement.class).caption(
+ "spacing").first();
+ check(spacingCheckbox);
+
+ // Spacing off, not hiding empty rows/columns
+ // There should not be any spacing (red) above the csslayout
+ verifySpacingAbove(0, gridLayout, component);
+
+ CheckBoxElement hideRowsColumnsCheckbox = $(CheckBoxElement.class)
+ .caption("hide empty rows/columns").first();
+ check(hideRowsColumnsCheckbox);
+
+ // Spacing off, hiding empty rows/columns
+ // There should not be any spacing (red) above the csslayout
+ verifySpacingAbove(0, gridLayout, component);
+
+ check(spacingCheckbox);
+ // Spacing on, hiding empty rows/columns
+ // There should not be any spacing (red) above or below the csslayout
+
+ // Oh PhantomJs...
+ sleep(100);
+ // FIXME: This should be 0 but there is a bug somewhere
+ // verifySpacingAbove(0, gridLayout, component);
+ verifySpacingBelow(6, gridLayout, component);
+
+ }
+
+ /**
+ * workaround for http://dev.vaadin.com/ticket/13763
+ */
+ private void check(CheckBoxElement checkbox) {
+ WebElement cb = checkbox.findElement(By.xpath("input"));
+ if (BrowserUtil.isChrome(getDesiredCapabilities())) {
+ testBenchElement(cb).click(0, 0);
+ } else {
+ cb.click();
+ }
+ }
+
+ private void verifySpacingAbove(int spacing, GridLayoutElement gridLayout,
+ CssLayoutElement component) {
+ assertHeight(component, 500 - spacing, 1);
+ int offset = component.getLocation().getY()
+ - gridLayout.getLocation().getY();
+ Assert.assertEquals(spacing, offset);
+
+ }
+
+ private void verifySpacingBelow(int spacing, GridLayoutElement gridLayout,
+ CssLayoutElement component) {
+ assertHeight(component, 500 - spacing, 1);
+
+ int offset = component.getLocation().getY()
+ - gridLayout.getLocation().getY();
+ Assert.assertEquals(0, offset);
+
+ }
+
+ private void assertHeight(WebElement component, int height, int tolerance) {
+ Assert.assertTrue(Math.abs(height - component.getSize().getHeight()) <= tolerance);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
index 5a64cb6a00..bd7522aab7 100644
--- a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
+++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
@@ -19,9 +19,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.annotations.JavaScript;
import com.vaadin.server.ConnectorResource;
import com.vaadin.server.DownloadStream;
@@ -39,6 +36,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HasComponents;
import com.vaadin.ui.JavaScriptFunction;
+import elemental.json.JsonArray;
public class BasicJavaScriptComponent extends AbstractTestUI {
@@ -78,15 +76,15 @@ public class BasicJavaScriptComponent extends AbstractTestUI {
});
addFunction("messageToServer", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
log.log("Got callback message: " + arguments.getString(0));
}
});
addFunction("reportParentIds", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
- JSONArray parentIds = arguments.getJSONArray(0);
+ public void call(JsonArray arguments) {
+ JsonArray parentIds = arguments.getArray(0);
if (!parentIds.getString(0).equals(getConnectorId())) {
log.log("Connector ids doesn't match");
}
diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java
new file mode 100644
index 0000000000..ca91597aa2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java
@@ -0,0 +1,79 @@
+/*
+ * 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.popupview;
+
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.event.ShortcutListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.TextField;
+
+/**
+ * Test UI to check availability of shortcut action listener in the popup view
+ * oeverlay component.
+ *
+ * @author Vaadin Ltd
+ */
+public class PopupViewShortcutActionHandler extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new PopupView(new DemoPoupView()));
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Shortcut listener search should be executed in the end "
+ + "of request (after legacy UIDL request handling).";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14275;
+ }
+
+ private class DemoPoupView implements PopupView.Content {
+
+ @Override
+ public String getMinimizedValueAsHTML() {
+ return "Click Me";
+ }
+
+ @Override
+ public Component getPopupComponent() {
+ TextField field = new TextField("Enter text");
+ field.setImmediate(true);
+ field.addShortcutListener(new ShortcutListener("SearchAction",
+ ShortcutAction.KeyCode.ENTER, null) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void handleAction(Object sender, Object target) {
+ Label label = new Label(
+ "shortcut addedEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
+ label.addStyleName("shortcut-result");
+ addComponent(label);
+ }
+ });
+ return field;
+ }
+
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java
new file mode 100644
index 0000000000..f122e1a415
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.popupview;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.phantomjs.PhantomJSDriver;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.TestBench;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Check availability of shortcut action listener in the popup view.
+ *
+ * @author Vaadin Ltd
+ */
+public class PopupViewShortcutActionHandlerTest extends MultiBrowserTest {
+
+ @Test
+ public void testShortcutHandling() {
+ openTestURL();
+
+ getDriver().findElement(By.className("v-popupview")).click();
+ WebElement textField = getDriver().findElement(
+ By.className("v-textfield"));
+ textField.sendKeys("a", Keys.ENTER);
+
+ Assert.assertTrue(
+ "Unable to find label component which is the result of"
+ + " shortcut action handling.",
+ isElementPresent(By.className("shortcut-result")));
+ }
+
+ @Override
+ protected void setupDriver() throws Exception {
+ System.setProperty("phantomjs.binary.path",
+ "C:\\tmp\\phantom\\phantomjs.exe");
+ WebDriver dr = TestBench.createDriver(new PhantomJSDriver());
+ setDriver(dr);
+ }
+
+ @Override
+ protected String getScreenshotDirectory() {
+ return "C:\\tmp\\a";
+ }
+
+ @Override
+ protected void openTestURL() {
+ driver.get("http://localhost:8080/vaadin/run/PopupViewShortcutActionHandler");
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ return Collections.singletonList(Browser.FIREFOX
+ .getDesiredCapabilities());
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java b/uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java
new file mode 100644
index 0000000000..1515589b4c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElement.java
@@ -0,0 +1,76 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class TableMatchesMouseDownMouseUpElement extends AbstractTestUI {
+
+ static final String CLEAR_BUTTON_ID = "clear-button-id";
+
+ @Override
+ protected String getTestDescription() {
+ return "Both mouse down and mouse up should be done on same cell to be considered as a click.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14347;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Table table = new Table();
+ table.setHeight("500px");
+ table.setSelectable(true);
+ table.setNullSelectionAllowed(true);
+ table.addContainerProperty("Column 1", String.class, "");
+ table.addContainerProperty("Column 2", Component.class, "");
+ table.addContainerProperty("Column 3", Component.class, "");
+ table.addContainerProperty("Column 4", Component.class, "");
+
+ Item item = table.addItem("Item 1 (row 1)");
+ item.getItemProperty("Column 1").setValue("String A");
+ item.getItemProperty("Column 2").setValue(new Label("Label A"));
+ item.getItemProperty("Column 3").setValue(
+ new Label("<b>Label A</b>", ContentMode.HTML));
+ VerticalLayout l = new VerticalLayout();
+ l.setId("row-1");
+ l.setHeight(100, Unit.PIXELS);
+ item.getItemProperty("Column 4").setValue(l);
+
+ item = table.addItem("Item 2 (row 2)");
+ item.getItemProperty("Column 1").setValue("String B");
+ item.getItemProperty("Column 2").setValue(new Label("Label B"));
+ item.getItemProperty("Column 3")
+ .setValue(
+ new Label(
+ "<a style=\"color: blue\" href=\"javascript:false\">Label B</a>",
+ ContentMode.HTML));
+ l = new VerticalLayout();
+ l.setId("row-2");
+ l.setSizeFull();
+ item.getItemProperty("Column 4").setValue(l);
+
+ Button clear = new Button("Clear");
+ clear.setId(CLEAR_BUTTON_ID);
+ clear.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ table.setValue(null);
+ }
+ });
+ addComponent(table);
+ addComponent(clear);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElementTest.java b/uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElementTest.java
new file mode 100644
index 0000000000..ea730ea30e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableMatchesMouseDownMouseUpElementTest.java
@@ -0,0 +1,147 @@
+/*
+ * 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.table;
+
+import static com.vaadin.tests.components.table.TableMatchesMouseDownMouseUpElement.CLEAR_BUTTON_ID;
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Regular click cases already covered by @LabelEmbeddedClickThroughForTableTest
+ * Testing cases when mouse down and mouse up positions are different
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TableMatchesMouseDownMouseUpElementTest extends MultiBrowserTest {
+
+ TableElement table;
+
+ @Test
+ public void testClick() {
+ openTestURL();
+ table = $(TableElement.class).first();
+
+ testMoveOut(getBoldTag(0, 2));
+ testMoveIn(getBoldTag(0, 2));
+
+ testMoveOut(getLabel(0, 1));
+ testMoveIn(getLabel(0, 1));
+
+ testClickOnDifferentRows();
+ }
+
+ /**
+ * MouseDown on element and mouseUp outside element but on same cell
+ */
+ private void testMoveOut(WebElement element) {
+ clearSelection();
+ clickAndMove(element, 5, 5, 0, 50);
+ checkSelectedRowCount(1);
+ checkRowSelected(0);
+ }
+
+ /**
+ * MouseDown outside element but on same cell and mouseUp on element
+ */
+ private void testMoveIn(WebElement element) {
+ clearSelection();
+ clickAndMove(element, 5, 55, 0, -50);
+ checkSelectedRowCount(1);
+ checkRowSelected(0);
+ }
+
+ /**
+ * Mouse down in cell of row1 holds and mouse up in cell of row 2
+ */
+ public void testClickOnDifferentRows() {
+ clearSelection();
+ WebElement elementFrom = getCell(0, 1);
+ WebElement elementTo = getCell(0, 2);
+ clickAndMove(elementFrom, elementTo);
+ checkSelectedRowCount(0);
+ }
+
+ private WebElement getBoldTag(int row, int column) {
+ return table.getCell(row, column).findElement(By.className("v-label"))
+ .findElement(By.tagName("b"));
+ }
+
+ private WebElement getLabel(int row, int column) {
+ return table.getCell(row, column).findElement(By.className("v-label"));
+ }
+
+ private WebElement getCell(int row, int column) {
+ return table.getCell(row, column);
+ }
+
+ private void clearSelection() {
+ WebElement clearButton = vaadinElementById(CLEAR_BUTTON_ID);
+ clearButton.click();
+ }
+
+ /**
+ * Mouse down on element + initial offset -> Moves the "move offset" ->
+ * Mouse up
+ */
+ private void clickAndMove(WebElement element, int initialX, int initialY,
+ int moveX, int moveY) {
+ new Actions(driver).moveToElement(element, initialX, initialY)
+ .clickAndHold().perform();
+ new Actions(driver).moveByOffset(moveX, moveY).perform();
+ new Actions(driver).release().perform();
+ }
+
+ /**
+ * Mouse down on elementFrom -> Moves to elementTo -> Mouse up
+ */
+ private void clickAndMove(WebElement elementFrom, WebElement elementTo) {
+ new Actions(driver).moveToElement(elementFrom, 5, 5).clickAndHold()
+ .perform();
+ new Actions(driver).moveToElement(elementTo, 5, 5).perform();
+ new Actions(driver).release().perform();
+ }
+
+ private void checkRowSelected(int rowIndex) {
+ assertEquals(
+ "contents of the selected row don't match contents of the row #"
+ + rowIndex,
+ table.getCell(rowIndex, 0).getText(),
+ getSelectedRows().get(0)
+ .findElement(By.className("v-table-cell-wrapper"))
+ .getText());
+ }
+
+ private void checkSelectedRowCount(int expected) {
+ assertEquals("unexpected table selection size", expected,
+ getSelectedRows().size());
+ }
+
+ private List<WebElement> getSelectedRows() {
+ return table.findElement(By.className("v-table-body")).findElements(
+ By.className("v-selected"));
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java
index c21a38a0ac..710a4f8fe3 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java
@@ -19,8 +19,6 @@ package com.vaadin.tests.components.table;
import java.util.ArrayList;
import java.util.Collection;
-import org.json.JSONObject;
-
import com.vaadin.annotations.Push;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.StreamVariable;
@@ -30,6 +28,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ConnectorTracker;
import com.vaadin.ui.Table;
+import elemental.json.JsonObject;
@Push
public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI {
@@ -125,12 +124,12 @@ public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI {
}
@Override
- public JSONObject getDiffState(ClientConnector connector) {
+ public JsonObject getDiffState(ClientConnector connector) {
return tracker.getDiffState(connector);
}
@Override
- public void setDiffState(ClientConnector connector, JSONObject diffState) {
+ public void setDiffState(ClientConnector connector, JsonObject diffState) {
tracker.setDiffState(connector, diffState);
}
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemove.java b/uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemove.java
new file mode 100644
index 0000000000..939bd645ea
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemove.java
@@ -0,0 +1,61 @@
+/*
+ * 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.tabsheet;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+/**
+ * In case a selected tab is removed the new selected one should be a neighbor.
+ *
+ * In case an unselected tab is removed and the selected one is not visible, the
+ * scroll should not jump to the selected one.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class NewSelectionAfterTabRemove extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TabSheet tabSheet = new TabSheet();
+
+ for (int i = 0; i < 20; i++) {
+
+ String caption = "Tab " + i;
+ Label label = new Label(caption);
+
+ Tab tab = tabSheet.addTab(label, caption);
+ tab.setClosable(true);
+ }
+
+ addComponent(tabSheet);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "When a selected tab is removed, its neighbor should become selected.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6876;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java
new file mode 100644
index 0000000000..bffbc3ecdf
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.tabsheet;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Automatic test of the default TabSheet selection algorithm when removing a
+ * selected tab.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class NewSelectionAfterTabRemoveTest extends MultiBrowserTest {
+
+ @Test
+ public void testSelection() throws IOException, InterruptedException {
+ openTestURL();
+
+ while (scrollRight()) {
+ }
+
+ selectAndClose(tab(19));
+
+ Assert.assertTrue("Tab 18 selected", isTabSelected(tab(18)));
+
+ selectAndClose(tab(16));
+
+ Assert.assertTrue("Tab 17 selected", isTabSelected(tab(17)));
+ }
+
+ /*
+ * Select the specified tab and close it.
+ */
+ private void selectAndClose(TestBenchElement tab)
+ throws InterruptedException {
+ tab.click(5, 5);
+
+ sleep(10);
+
+ tabClose(tab).click(2, 2);
+
+ sleep(10);
+ }
+
+ /*
+ * Gets the selected state of the specified tab.
+ */
+ private boolean isTabSelected(TestBenchElement tab) {
+ return tab.getAttribute("class").contains(
+ "v-tabsheet-tabitemcell-selected")
+ && tab.getAttribute("class").contains(
+ "v-tabsheet-tabitemcell-focus");
+ }
+
+ /*
+ * Scroll the tabsheet bar to the right.
+ */
+ private boolean scrollRight() {
+ List<WebElement> scrollElements = getDriver().findElements(
+ By.className("v-tabsheet-scrollerNext"));
+ if (!scrollElements.isEmpty()) {
+ TestBenchElement rightScrollElement = (TestBenchElement) scrollElements
+ .get(0);
+ rightScrollElement.click(5, 5);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /*
+ * Provide the tab close button for the specified tab.
+ */
+ private TestBenchElement tabClose(TestBenchElement tab) {
+ return (TestBenchElement) tab.findElement(By
+ .className("v-tabsheet-caption-close"));
+ }
+
+ /*
+ * Provide the tab at specified index.
+ */
+ private TestBenchElement tab(int index) {
+ By by = By.className("v-tabsheet-tabitemcell");
+
+ List<WebElement> tabs = getDriver().findElements(by);
+
+ String expected = "Tab " + index;
+
+ for (WebElement tab : tabs) {
+ if (tab.getText().startsWith(expected)) {
+ return (TestBenchElement) tab;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java b/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java
index b89e16d755..4807bb9029 100644
--- a/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java
+++ b/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java
@@ -16,16 +16,15 @@
package com.vaadin.tests.extensions;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.JavaScript;
import com.vaadin.ui.JavaScriptFunction;
+import elemental.json.JsonArray;
+import elemental.json.JsonNull;
+
public class JavascriptManagerTest extends AbstractTestUI {
private Log log = new Log(5);
@@ -36,14 +35,14 @@ public class JavascriptManagerTest extends AbstractTestUI {
final JavaScript js = JavaScript.getCurrent();
js.addFunction("testing.doTest", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
log.log("Got " + arguments.length() + " arguments");
- log.log("Argument 1 as a number: " + arguments.getInt(0));
+ log.log("Argument 1 as a number: " + (int) arguments.getNumber(0));
log.log("Argument 2 as a string: " + arguments.getString(1));
log.log("Argument 3.p as a boolean: "
- + arguments.getJSONObject(2).getBoolean("p"));
+ + arguments.getObject(2).getBoolean("p"));
log.log("Argument 4 is JSONObject.NULL: "
- + (arguments.get(3) == JSONObject.NULL));
+ + (arguments.get(3) instanceof JsonNull));
js.removeFunction("testing.doTest");
}
});
diff --git a/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java b/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
index d3e0edf04c..6f14fb301c 100644
--- a/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
+++ b/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
@@ -16,9 +16,6 @@
package com.vaadin.tests.extensions;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.annotations.JavaScript;
import com.vaadin.annotations.StyleSheet;
import com.vaadin.server.AbstractJavaScriptExtension;
@@ -31,6 +28,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.JavaScriptFunction;
import com.vaadin.ui.Notification;
+import elemental.json.JsonArray;
public class SimpleJavaScriptExtensionTest extends AbstractTestUI {
@@ -71,7 +69,7 @@ public class SimpleJavaScriptExtensionTest extends AbstractTestUI {
});
addFunction("greetToServer", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
Notification.show(getState().getPrefix()
+ arguments.getString(0));
}
diff --git a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html
deleted file mode 100644
index 496994a60c..0000000000
--- a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.html
+++ /dev/null
@@ -1,239 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>TestLayoutClickListeners</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TestLayoutClickListeners</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.layouts.TestLayoutClickListeners?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td>initial</td>
-</tr>
-<!--GridLayout-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>43,11</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: left click on This is label 1</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>82,14</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: left click on This is tf5</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VGridLayout[0]</td>
- <td>130,41</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:GridLayout: left click on &lt;none&gt;</td>
-</tr>
-<!--VerticalLayout-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td>
- <td>74,13</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:VerticalLayout: left click on This is tf6</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]</td>
- <td>53,13</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:VerticalLayout: left click on This is label 3</td>
-</tr>
-<!--AbsoluteLayout-->
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:Button A button with its own click listener was clicked</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/VTextField[0]</td>
- <td>101,14</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>exact:AbsoluteLayout: left click on This is its caption</td>
-</tr>
-<!--CssLayout-->
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]</td>
- <td>108,13</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[3]/VCssLayout[0]/domChild[0]/domChild[0]</td>
- <td>41,7</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_1</td>
- <td>exact:CSSLayout: left click on This is its caption</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:CSSLayout: left click on This is its caption</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:Button A button with its own click listener was clicked</td>
-</tr>
-<!--Drag in GridLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>40,8</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>40,8</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:GridLayout: left click on This is label 1</td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>24,7</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>46,13</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:GridLayout: left click on This is label 1</td>
-</tr>
-<!--Drag in VerticalLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>25,9</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td>
- <td>25,9</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:VerticalLayout: left click on This is tf5</td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[8]/domChild[0]</td>
- <td>28,11</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VTextField[0]</td>
- <td>39,7</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:VerticalLayout: left click on This is tf5</td>
-</tr>
-<!--Drag in AbsoluteLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[2]/VAbsoluteLayout[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]</td>
- <td>21,9</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[2]/VAbsoluteLayout[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]</td>
- <td>21,9</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:AbsoluteLayout: left click on This is its caption</td>
-</tr>
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]/VTextField[0]</td>
- <td>54,7</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[1]/VTextField[0]</td>
- <td>52,10</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:AbsoluteLayout: left click on This is its caption</td>
-</tr>
-<!--Drag in CSSLayout-->
-<tr>
- <td>drag</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]</td>
- <td>51,7</td>
-</tr>
-<tr>
- <td>drop</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[3]/VCssLayout[0]/VCssLayout$FlowPane[0]/VTextField[0]</td>
- <td>51,7</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestslayoutsTestLayoutClickListeners::PID_SLog_row_0</td>
- <td>exact:CSSLayout: left click on This is its caption</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java
index c29e7710b7..22a37022c2 100644
--- a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java
+++ b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java
@@ -2,8 +2,8 @@ package com.vaadin.tests.layouts;
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.tests.util.Log;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
@@ -12,36 +12,22 @@ import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
-import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
-public class TestLayoutClickListeners extends AbstractTestCase {
-
- private Log log = new Log(5).setNumberLogRows(false);
+public class TestLayoutClickListeners extends AbstractTestUIWithLog {
@Override
- public void init() {
- LegacyWindow w = new LegacyWindow("main window");
- setMainWindow(w);
- setTheme("tests-tickets");
-
+ protected void setup(VaadinRequest request) {
HorizontalLayout layoutsLayout = new HorizontalLayout();
layoutsLayout.setSpacing(true);
- w.setContent(layoutsLayout);
+ addComponent(layoutsLayout);
layoutsLayout.addComponent(createClickableGridLayout());
layoutsLayout.addComponent(createClickableVerticalLayout());
layoutsLayout.addComponent(createClickableAbsoluteLayout());
layoutsLayout.addComponent(createClickableCSSLayout());
-
- VerticalLayout mainLayout = new VerticalLayout();
- mainLayout.setMargin(true);
- mainLayout.setSpacing(true);
- w.setContent(mainLayout);
- mainLayout.addComponent(log);
- mainLayout.addComponent(layoutsLayout);
}
private Component createClickableAbsoluteLayout() {
@@ -62,12 +48,12 @@ public class TestLayoutClickListeners extends AbstractTestCase {
@Override
public void buttonClick(
com.vaadin.ui.Button.ClickEvent event) {
- log.log("Button " + event.getButton().getCaption()
+ log("Button " + event.getButton().getCaption()
+ " was clicked");
}
}));
- al.addListener(new LayoutClickListener() {
+ al.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
@@ -96,12 +82,12 @@ public class TestLayoutClickListeners extends AbstractTestCase {
@Override
public void buttonClick(
com.vaadin.ui.Button.ClickEvent event) {
- log.log("Button " + event.getButton().getCaption()
+ log("Button " + event.getButton().getCaption()
+ " was clicked");
}
}));
- cl.addListener(new LayoutClickListener() {
+ cl.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
@@ -120,13 +106,14 @@ public class TestLayoutClickListeners extends AbstractTestCase {
gl.setWidth("564px");
gl.setStyleName("borders");
gl.setSpacing(true);
+ gl.setHideEmptyRowsAndColumns(true);
addContent(gl, 4);
TextArea largeTextarea = new TextArea("Large textarea");
largeTextarea.setWidth("100%");
largeTextarea.setHeight("99%");
gl.addComponent(largeTextarea, 0, 3, 3, 3);
- gl.addListener(new LayoutClickListener() {
+ gl.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
@@ -151,10 +138,7 @@ public class TestLayoutClickListeners extends AbstractTestCase {
if (event.isDoubleClick()) {
type = "double-click";
}
- log.log(layout + ": " + button + " " + type + " on " + target);
- // + ", coordinates relative to the layout ("
- // + event.getRelativeX() + ", " + event.getRelativeY() + ")");
-
+ log(layout + ": " + button + " " + type + " on " + target);
}
private Layout createClickableVerticalLayout() {
@@ -162,7 +146,7 @@ public class TestLayoutClickListeners extends AbstractTestCase {
VerticalLayout gl = new VerticalLayout();
addContent(gl, 5);
- gl.addListener(new LayoutClickListener() {
+ gl.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
@@ -196,7 +180,7 @@ public class TestLayoutClickListeners extends AbstractTestCase {
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "All layouts have click listeners attached and the events are shown in the event log at the top";
}
@@ -204,5 +188,4 @@ public class TestLayoutClickListeners extends AbstractTestCase {
protected Integer getTicketNumber() {
return 3541;
}
-
}
diff --git a/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java
new file mode 100644
index 0000000000..0c6b5cbff4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java
@@ -0,0 +1,200 @@
+/*
+ * 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.layouts;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.AbsoluteLayoutElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.CssLayoutElement;
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.testbench.elements.VerticalLayoutElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests LayoutClickListener on different layouts.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestLayoutClickListenersTest extends MultiBrowserTest {
+
+ @Before
+ public void before() {
+ openTestURL();
+ }
+
+ @Test
+ public void clickInGridLayout() {
+ GridLayoutElement layout = $(GridLayoutElement.class).first();
+
+ // click on a label
+ layout.$(LabelElement.class).first().click();
+ assertLogText("GridLayout 1st child clicked",
+ "1. GridLayout: left click on This is label 1");
+
+ // click on a text field
+ layout.$(TextFieldElement.class).get(1).click();
+ assertLogText("GridLayout 5th child clicked",
+ "2. GridLayout: left click on This is tf5");
+
+ // click on the layout body (not any component inside the layout)
+ layout.click(130, 41);
+ assertLogText("GridLayout body clicked",
+ "3. GridLayout: left click on <none>");
+ }
+
+ @Test
+ public void clickInVerticalLayout() {
+ VerticalLayoutElement layout = $(VerticalLayoutElement.class).get(4);
+
+ // click on a text field
+ layout.$(TextFieldElement.class).get(1).click();
+ assertLogText("VerticalLayout 6th child clicked",
+ "1. VerticalLayout: left click on This is tf6");
+
+ // click on a label
+ layout.$(LabelElement.class).get(3).click();
+ assertLogText("VerticalLayout 4th child clicked",
+ "2. VerticalLayout: left click on This is label 3");
+ }
+
+ @Test
+ public void clickInAbsoluteLayout() {
+ AbsoluteLayoutElement layout = $(AbsoluteLayoutElement.class).first();
+
+ // click on a button that has its own ClickListener (should be ignored
+ // by the LayoutClickListener)
+ layout.$(ButtonElement.class).first().click();
+ assertLogText("A button with a ClickListener clicked",
+ "1. Button A button with its own click listener was clicked");
+
+ // click on a text field's caption
+ layout.$(TextFieldElement.class).first().click();
+ assertLogText("AbsoluteLayout 1st child was clicked",
+ "2. AbsoluteLayout: left click on This is its caption");
+ }
+
+ @Test
+ public void clickInCSSLayout() {
+ CssLayoutElement layout = $(CssLayoutElement.class).first();
+
+ // click on a text field's caption
+ layout.$(TextFieldElement.class).first().click();
+ assertLogText("CSSLayout 1st child clicked",
+ "1. CSSLayout: left click on This is its caption");
+
+ // click on a button that has its own ClickListener (should be ignored
+ // by the LayoutClickListener)
+ layout.$(ButtonElement.class).first().click();
+ assertLogText("Abutton with a ClickListener was clicked",
+ "2. Button A button with its own click listener was clicked");
+ }
+
+ @Test
+ public void dragInGridLayout() {
+ GridLayoutElement layout = $(GridLayoutElement.class).first();
+
+ // Drag inside the first label in this layout
+ new Actions(getDriver())
+ .moveToElement(layout.$(LabelElement.class).first(), 40, 8)
+ .clickAndHold().moveByOffset(-20, 0).release().perform();
+ assertLogText("Mouse dragged in GridLayout",
+ "1. GridLayout: left click on This is label 1");
+
+ // Drag from the third label to a text field in this layout
+ new Actions(getDriver())
+ .moveToElement(layout.$(LabelElement.class).first(), 40, 8)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).get(3), 46, 33)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. GridLayout: left click on This is label 1");
+ }
+
+ @Test
+ public void dragInVerticalLayout() {
+ VerticalLayoutElement layout = $(VerticalLayoutElement.class).get(4);
+
+ // Drag inside the first text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 25, 9)
+ .clickAndHold().moveByOffset(-20, 0).release().perform();
+ assertLogText("Mouse dragged in VerticalLayout",
+ "1. VerticalLayout: left click on This is tf5");
+
+ // Drag from a caption to its text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).get(4), 28, 11)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).get(4), 39, 30)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. VerticalLayout: left click on This is tf5");
+ }
+
+ @Test
+ public void dragInAbsoluteLayout() {
+ AbsoluteLayoutElement layout = $(AbsoluteLayoutElement.class).first();
+
+ // Drag inside the first text field's caption
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 21, 9)
+ .clickAndHold().moveByOffset(-10, 0).release().perform();
+ assertLogText("Mouse dragged in AbsoluteLayout",
+ "1. AbsoluteLayout: left click on This is its caption");
+
+ // Drag from a text field to another text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).get(1), 54, 7)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).first(), 52, 10)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. AbsoluteLayout: left click on This is its caption");
+ }
+
+ @Test
+ public void dragInCSSLayout() {
+ CssLayoutElement layout = $(CssLayoutElement.class).first();
+
+ // Drag inside the first text field's caption
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 51, 7)
+ .clickAndHold().moveByOffset(-20, 0).release().perform();
+ assertLogText("Mouse dragged in CSSLayout",
+ "1. CSSLayout: left click on This is its caption");
+
+ // Drag from the first text field to the second text field
+ new Actions(getDriver())
+ .moveToElement(layout.$(TextFieldElement.class).first(), 51, 27)
+ .clickAndHold()
+ .moveToElement(layout.$(TextFieldElement.class).get(1), 51, 27)
+ .release().perform();
+ assertLogText("Expected the drag to be ignored between elements",
+ "1. CSSLayout: left click on This is its caption");
+ }
+
+ private void assertLogText(String message, String expected) {
+ String actual = $(LabelElement.class).first().getText();
+ Assert.assertEquals(message, expected, actual);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java
index f4aca81ffa..86666b12e8 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java
@@ -20,13 +20,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.annotations.JavaScript;
import com.vaadin.ui.AbstractJavaScriptComponent;
import com.vaadin.ui.JavaScriptFunction;
import com.vaadin.ui.Notification;
+import elemental.json.JsonArray;
@JavaScript({
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
@@ -42,9 +40,9 @@ public class Flot extends AbstractJavaScriptComponent {
});
addFunction("onPlotClick", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
- int seriesIndex = arguments.getInt(0);
- int dataIndex = arguments.getInt(1);
+ public void call(JsonArray arguments) {
+ int seriesIndex = (int) arguments.getNumber(0);
+ int dataIndex = (int) arguments.getNumber(1);
Notification.show("Clicked on [" + seriesIndex + ", "
+ dataIndex + "]");
}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java
index 8f1eda6816..e98fe6d066 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java
@@ -1,8 +1,5 @@
package com.vaadin.tests.minitutorials.v7a3;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.server.ExternalResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.JavaScript;
@@ -12,6 +9,9 @@ import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.UI;
+import elemental.json.JsonArray;
+import elemental.json.JsonException;
+
public class JSAPIUI extends UI {
@Override
public void init(VaadinRequest request) {
@@ -19,7 +19,7 @@ public class JSAPIUI extends UI {
JavaScript.getCurrent().addFunction("com.example.api.notify",
new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
try {
String caption = arguments.getString(0);
if (arguments.length() == 1) {
@@ -28,10 +28,10 @@ public class JSAPIUI extends UI {
} else {
// type should be in [1]
Notification.show(caption,
- Type.values()[arguments.getInt(1)]);
+ Type.values()[((int) arguments.getNumber(1))]);
}
- } catch (JSONException e) {
+ } catch (JsonException e) {
// We'll log in the console, you might not want to
JavaScript.getCurrent().execute(
"console.error('" + e.getMessage() + "')");
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
index 6e2784f21d..e7a74775bf 100644
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
@@ -23,8 +23,6 @@ import java.net.URL;
import javax.servlet.ServletContext;
import org.apache.commons.io.IOUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
import com.vaadin.annotations.JavaScript;
import com.vaadin.server.VaadinRequest;
@@ -32,6 +30,7 @@ import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinServletService;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.JavaScriptFunction;
+import elemental.json.JsonArray;
// Load vaadinPush.js so that jQueryVaadin is defined
@JavaScript("vaadin://vaadinPush.debug.js")
@@ -58,7 +57,7 @@ public class TrackMessageSizeUI extends AbstractTestUIWithLog {
getPage().getJavaScript().addFunction("logToServer",
new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
String message = arguments.getString(0);
log(message);
}
diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
index 47bb212347..dcba561599 100644
--- a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
+++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
@@ -86,9 +86,8 @@ public class SerializerTestTest extends MultiBrowserTest {
getLogRow(logRow++));
Assert.assertEquals("state.floatArray: [57, 0, -12]",
getLogRow(logRow++));
- Assert.assertEquals("state.floatObjectValue: 1.0000001",
- getLogRow(logRow++));
- Assert.assertEquals("state.floatValue: 3.14159", getLogRow(logRow++));
+ Assert.assertTrue(getLogRow(logRow++).startsWith("state.floatObjectValue: 1.0000001"));
+ Assert.assertTrue(getLogRow(logRow++).startsWith("state.floatValue: 3.14159"));
Assert.assertEquals("state.longArray: [-57841235865, 57]",
getLogRow(logRow++));
Assert.assertEquals("state.longObjectValue: 577431841360",
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index d2313a0709..1e1cbedbd6 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -30,13 +30,13 @@ import java.net.URL;
import java.util.Collections;
import java.util.List;
+import elemental.json.JsonObject;
+import elemental.json.impl.JsonUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -1247,7 +1247,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest(
"POST", sessionURL.toExternalForm());
HttpResponse response = client.execute(host, r);
- JSONObject object = extractObject(response);
+ JsonObject object = extractObject(response);
URL myURL = new URL(object.getString("proxyId"));
if ((myURL.getHost() != null) && (myURL.getPort() != -1)) {
return myURL.getHost();
@@ -1258,13 +1258,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
return null;
}
- private static JSONObject extractObject(HttpResponse resp)
- throws IOException, JSONException {
+ private static JsonObject extractObject(HttpResponse resp) throws IOException {
InputStream contents = resp.getEntity().getContent();
StringWriter writer = new StringWriter();
IOUtils.copy(contents, writer, "UTF8");
- JSONObject objToReturn = new JSONObject(writer.toString());
- return objToReturn;
+ return JsonUtil.parse(writer.toString());
}
}
diff --git a/uitest/src/com/vaadin/tests/tb3/DndActionsTest.java b/uitest/src/com/vaadin/tests/tb3/DndActionsTest.java
new file mode 100644
index 0000000000..e755a00a0d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/DndActionsTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.tb3;
+
+import org.junit.Ignore;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+/**
+ * Base class for TestBench 3+ tests that use DnD. This class contains utility
+ * methods for DnD operations.
+ *
+ * @author Vaadin Ltd
+ */
+@Ignore
+public abstract class DndActionsTest extends MultiBrowserTest {
+
+ public void dragAndDrop(WebElement element, int xOffset, int yOffset) {
+ /*
+ * Selenium doesn't properly drag and drop items in IE8. It tries to
+ * start dragging an element from a position above the element itself.
+ */
+ if (BrowserUtil.isIE8(getDesiredCapabilities())) {
+ Actions action = new Actions(getDriver());
+ action.moveToElement(element);
+ action.moveByOffset(0, 1);
+ action.clickAndHold();
+ action.moveByOffset(xOffset, yOffset);
+ action.release();
+ action.build().perform();
+ } else {
+ Actions action = new Actions(getDriver());
+ action.dragAndDropBy(element, xOffset, yOffset);
+ action.build().perform();
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java
index 62d76569dd..f30cec76cc 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java
@@ -175,6 +175,7 @@ public class ValoThemeUI extends UI {
break;
}
}
+ menu.removeStyleName("valo-menu-visible");
}
});
diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
index b5b7e16b34..71f770ab8f 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
@@ -276,6 +276,9 @@ public class ValoThemeUITest extends MultiBrowserTest {
+ getRemoteControlName());
open(link, caption, tries - 1);
+ } else {
+ // Done opening, scroll left panel to the top again for consistency
+ scrollTo(0, 0);
}
}