summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-11-14 11:26:22 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2014-11-14 11:27:32 +0200
commitd1cd6ffce4a3107f869f9d9256ca105d718f3e46 (patch)
tree08789066be9deb5162ad83ff3b766ea2d4c4812d /uitest/src/com
parent1ac8b6bff007d997bf2cfc69954e69d8fa65e119 (diff)
parentee6f9483f36eeeecf32730016d02fb22e5cbaab3 (diff)
downloadvaadin-framework-d1cd6ffce4a3107f869f9d9256ca105d718f3e46.tar.gz
vaadin-framework-d1cd6ffce4a3107f869f9d9256ca105d718f3e46.zip
Merge remote-tracking branch 'origin/master' into grid
Change-Id: Iec61d9242be530edbb76ba952746ba0f9c9bd966
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/AbstractTestUI.java7
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForward.java132
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java99
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java109
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java119
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java39
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java41
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java42
-rw-r--r--uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponent.java82
-rw-r--r--uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java61
-rw-r--r--uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java125
-rw-r--r--uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNestingTest.java83
-rw-r--r--uitest/src/com/vaadin/tests/components/page/PageReload.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ContextMenuSize.java77
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java131
-rw-r--r--uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java86
-rw-r--r--uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java72
-rw-r--r--uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java92
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRowsTest.java48
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java10
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRow.java117
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRowTest.java65
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java110
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java88
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java46
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRowsTest.java182
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java67
-rw-r--r--uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocusedTest.java53
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabSheetClose.java72
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabSheetCloseTest.java58
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java98
-rw-r--r--uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabCloseTest.java171
-rw-r--r--uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java41
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java55
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java62
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthChameleonTest.java36
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthReindeerTest.java36
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthRunoTest.java36
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java59
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthValoTest.java36
-rw-r--r--uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java5
-rw-r--r--uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java10
-rw-r--r--uitest/src/com/vaadin/tests/push/BarInUIDL.java4
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java2
-rw-r--r--uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java2
-rw-r--r--uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java2
-rw-r--r--uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java6
-rw-r--r--uitest/src/com/vaadin/tests/push/ReconnectWebsocketTest.java2
-rw-r--r--uitest/src/com/vaadin/tests/push/RefreshCloseConnectionTest.java2
-rw-r--r--uitest/src/com/vaadin/tests/push/SendMultibyteCharacters.java23
-rw-r--r--uitest/src/com/vaadin/tests/push/SendMultibyteCharactersLongPollingTest.java9
-rw-r--r--uitest/src/com/vaadin/tests/push/SendMultibyteCharactersStreamingTest.java9
-rw-r--r--uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java42
-rw-r--r--uitest/src/com/vaadin/tests/push/SendMultibyteCharactersWebSocketTest.java19
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java97
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AffectedTB3Tests.java27
-rw-r--r--uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java158
-rw-r--r--uitest/src/com/vaadin/tests/tb3/ChangedTB3Tests.java41
-rw-r--r--uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java10
-rw-r--r--uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java218
-rw-r--r--uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java207
-rw-r--r--uitest/src/com/vaadin/tests/tb3/WebsocketTest.java24
-rw-r--r--uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java4
-rw-r--r--uitest/src/com/vaadin/tests/themes/valo/DateFields.java1
-rw-r--r--uitest/src/com/vaadin/tests/themes/valo/TableSortIndicator.java34
-rw-r--r--uitest/src/com/vaadin/tests/themes/valo/TableSortIndicatorTest.java46
-rw-r--r--uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java20
-rw-r--r--uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdating.java69
-rw-r--r--uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdatingTest.java46
79 files changed, 3824 insertions, 392 deletions
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java b/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java
index 8fc6d56161..206e763497 100644
--- a/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java
+++ b/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java
@@ -17,7 +17,6 @@ package com.vaadin.tests.applicationservlet;
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.Button.ClickListener;
@@ -26,15 +25,13 @@ public class SessionExpiration extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
getSession().getSession().setMaxInactiveInterval(2);
- Button b = new Button("Click to avoid expiration");
- b.addClickListener(new ClickListener() {
+ addButton("Click to avoid expiration", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
log("Clicked");
}
});
- addComponent(b);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
index 558379260b..3a7d42e29c 100644
--- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
+++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
@@ -10,6 +10,7 @@ import com.vaadin.shared.communication.PushMode;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
+import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
@@ -181,6 +182,12 @@ public abstract class AbstractTestUI extends UI {
getLayout().replaceComponent(oldComponent, newComponent);
}
+ protected void addButton(String caption, Button.ClickListener listener) {
+ Button button = new Button(caption);
+ button.addClickListener(listener);
+ addComponent(button);
+ }
+
protected String getTestDescription() {
return null;
};
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java
index 86e718596e..af54e15b5a 100644
--- a/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java
+++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveTab.java
@@ -53,16 +53,13 @@ public class AccordionRemoveTab extends AbstractTestUI {
Tab last = tabs.addTab(l);
last.setCaption("Three");
- Button remove = new Button("Remove First");
- remove.addClickListener(new Button.ClickListener() {
+ addButton("Remove First", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tabs.removeComponent(tabs.iterator().next());
}
});
-
- addComponent(remove);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForward.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForward.java
new file mode 100644
index 0000000000..5a21353d7d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForward.java
@@ -0,0 +1,132 @@
+/*
+ * 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.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Calendar;
+import com.vaadin.ui.Calendar.TimeFormat;
+import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
+import com.vaadin.ui.components.calendar.event.BasicEvent;
+
+/**
+ * Test: Vaadin Calendar: Navigation to invisible days of week (#12243)
+ *
+ * @author Vaadin Ltd
+ */
+@Theme("tests-calendar")
+public class CalendarBackwardForward extends AbstractTestUI {
+
+ private static final long serialVersionUID = 1L;
+ private Calendar calendar;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ calendar = new Calendar();
+
+ try {
+
+ BasicEvent event = new BasicEvent("EVENT NAME 1",
+ "EVENT TOOLTIP 1",
+ new SimpleDateFormat("yyyy-MM-dd HH:mm")
+ .parse("2013-09-05 15:30"), new SimpleDateFormat(
+ "yyyy-MM-dd HH:mm").parse("2013-09-07 22:20"));
+ event.setStyleName("color1");
+ calendar.addEvent(event);
+
+ event = new BasicEvent("EVENT NAME 2", "EVENT TOOLTIP 2",
+ new SimpleDateFormat("yyyy-MM-dd HH:mm")
+ .parse("2013-09-05 12:10"), new SimpleDateFormat(
+ "yyyy-MM-dd HH:mm").parse("2013-09-05 13:20"));
+ event.setStyleName("color2");
+ calendar.addEvent(event);
+
+ event = new BasicEvent("EVENT NAME 3", "EVENT TOOLTIP 3",
+ new SimpleDateFormat("yyyy-MM-dd HH:mm")
+ .parse("2013-09-01 11:30"), new SimpleDateFormat(
+ "yyyy-MM-dd HH:mm").parse("2013-09-29 15:20"));
+ event.setStyleName("color3");
+ calendar.addEvent(event);
+
+ event = new BasicEvent("EVENT NAME 4", "EVENT TOOLTIP 4",
+ new SimpleDateFormat("yyyy-MM-dd HH:mm")
+ .parse("2013-09-01 11:30"), new SimpleDateFormat(
+ "yyyy-MM-dd HH:mm").parse("2013-09-01 15:20"));
+ event.setStyleName("color4");
+ event.setAllDay(true);
+ calendar.addEvent(event);
+ } catch (ParseException e1) { // Nothing to do
+ e1.printStackTrace();
+ }
+
+ try {
+ calendar.setStartDate(new SimpleDateFormat("yyyy-MM-dd")
+ .parse("2013-09-01"));
+ calendar.setEndDate(new SimpleDateFormat("yyyy-MM-dd")
+ .parse("2013-09-30"));
+ } catch (ParseException e) { // Nothing to do
+
+ }
+
+ calendar.setImmediate(true);
+
+ // in english locale first day of week - sunday
+ calendar.setLocale(Locale.ENGLISH);
+ // show only working days: 2 - monday, 6 - friday
+ calendar.setFirstVisibleDayOfWeek(2);
+ calendar.setLastVisibleDayOfWeek(6);
+
+ calendar.setTimeFormat(TimeFormat.Format24H);
+ calendar.setHandler((EventResizeHandler) null);
+ setEnabled(true);
+
+ addComponent(calendar);
+ calendar.setSizeFull();
+ setSizeFull();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "If one uses the feature setVisibleDaysOfWeek of Calendar, the invisible days should be skipped in single-day-mode.";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 12243;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java
new file mode 100644
index 0000000000..98773f475b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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 static org.hamcrest.MatcherAssert.assertThat;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests: Vaadin Calendar: Navigation to invisible days of week (#12243)
+ *
+ * @author Vaadin Ltd
+ */
+public class CalendarBackwardForwardTest extends MultiBrowserTest {
+
+ @Test
+ public void testCalendar() throws InterruptedException, IOException {
+ openTestURL();
+
+ openWeekView();
+ openDayView();
+ clickCalendarNext();
+
+ WebElement headerDayElement = getDriver().findElement(
+ By.className("v-calendar-header-day"));
+
+ assertThat("This day should be Monday 9/9/13", headerDayElement
+ .getText().equals("Monday 9/9/13"));
+
+ for (int i = 0; i < 6; i++) {
+ clickCalendarBack();
+ }
+
+ headerDayElement = getDriver().findElement(
+ By.className("v-calendar-header-day"));
+
+ assertThat("This day should be Friday 8/30/13", headerDayElement
+ .getText().equals("Friday 8/30/13"));
+ }
+
+ private void openWeekView() {
+ List<WebElement> elements = getDriver().findElements(
+ By.className("v-calendar-week-number"));
+
+ for (WebElement webElement : elements) {
+ if (webElement.getText().equals("36")) {
+ webElement.click();
+ break;
+ }
+ }
+ }
+
+ private void openDayView() {
+ List<WebElement> elements = getDriver().findElements(
+ By.className("v-calendar-header-day"));
+
+ for (WebElement webElement : elements) {
+ if (webElement.getText().contains("Friday 9/6/13")) {
+ webElement.click();
+ break;
+ }
+ }
+ }
+
+ private void clickCalendarNext() {
+ List<WebElement> elements = getDriver().findElements(
+ By.className("v-calendar-next"));
+
+ elements.get(0).click();
+ }
+
+ private void clickCalendarBack() {
+ List<WebElement> elements = getDriver().findElements(
+ By.className("v-calendar-back"));
+
+ elements.get(0).click();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java
new file mode 100644
index 0000000000..b36b4d200e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java
@@ -0,0 +1,109 @@
+/*
+ * 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 for DnD regular (not all day event) in month view.
+ *
+ * @author Vaadin Ltd
+ */
+public class CalendarMonthViewDndEvent extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Calendar calendar = new Calendar("Test calendar");
+ final java.util.Calendar cal = getAdjustedCalendar();
+
+ Date from = cal.getTime();
+
+ Date start = new Date(from.getTime() - 24 * 3600000);
+ calendar.setStartDate(start);
+
+ cal.add(java.util.Calendar.HOUR, 1);
+ Date to = cal.getTime();
+
+ cal.add(java.util.Calendar.MONTH, 1);
+ calendar.setEndDate(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(String.valueOf(from.getTime()));
+ startLbl.addStyleName("start");
+ info.addComponent(startLbl);
+
+ final Label endLbl = new Label(String.valueOf(to.getTime()));
+ 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 "Allow DnD any events in Calendar Month view";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12413;
+ }
+
+ private java.util.Calendar getAdjustedCalendar() {
+ final java.util.Calendar cal = java.util.Calendar.getInstance();
+
+ 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/CalendarMonthViewDndEventTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java
new file mode 100644
index 0000000000..3248804eed
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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 how DnD works for regular (not all day event) in calendar month
+ * view.
+ *
+ * @author Vaadin Ltd
+ */
+public class CalendarMonthViewDndEventTest extends DndActionsTest {
+
+ @Test
+ public void dragAndDropEventToNextDay() {
+ openTestURL();
+
+ WebElement calendar = findElement(By.className("v-calendar"));
+ int calendarRight = calendar.getLocation().getX()
+ + calendar.getSize().getWidth();
+
+ WebElement event = findElement(By.className("v-calendar-event"));
+ int x = event.getLocation().getX();
+ int width = event.getSize().getWidth();
+
+ // does calendar have space on the right for one more event (i.e. day
+ // cell on the right).
+ boolean moveRight = event.getLocation().getX() + 2
+ * event.getSize().getWidth() <= calendarRight;
+
+ WebElement cell = getParentCell(event, "v-calendar-month-day");
+
+ int cellY = cell.getLocation().getY();
+ int cellHeight = cell.getSize().getHeight();
+
+ long origStart = getTime("start");
+ long origEnd = getTime("end");
+
+ if (moveRight) {
+ dragAndDrop(event, event.getSize().getWidth() + 5, 0);
+ } else {
+ dragAndDrop(event, -width / 2, 0);
+ }
+
+ event = findElement(By.className("v-calendar-event"));
+ int newX = event.getLocation().getX();
+ int newY = event.getLocation().getY();
+
+ Assert.assertTrue(
+ "Moved event has wrong Y position (not the same row), new Y position="
+ + newY + ", cell Y position=" + cellY
+ + ", cell height=" + cellHeight, newY >= cellY
+ && newY < cellY + cellHeight);
+ if (moveRight) {
+ Assert.assertTrue(
+ "Moved event has wrong X position (not after original event)",
+ newX >= x + width - 1);
+ } else {
+ width = event.getSize().getWidth();
+ Assert.assertTrue(
+ "Moved event has wrong X position (not after original event)",
+ x >= newX + width - 1);
+ }
+
+ long start = getTime("start");
+ long end = getTime("end");
+
+ int day = 24 * 3600000;
+ if (moveRight) {
+ Assert.assertEquals(
+ "Start date of moved event is not next day, same time",
+ origStart + day, start);
+ Assert.assertEquals(
+ "End date of moved event is not next day, same time",
+ origEnd + day, end);
+ } else {
+ Assert.assertEquals(
+ "Start date of moved event is not previous day, same time",
+ origStart - day, start);
+ Assert.assertEquals(
+ "End date of moved event is not previous day, same time",
+ origEnd - day, end);
+
+ }
+ }
+
+ private WebElement getParentCell(WebElement element, String style) {
+ WebElement parent = element;
+ do {
+ // ".." xpath expression chooses the parent of the element
+ parent = parent.findElement(By.xpath(".."));
+ } while (!parent.getAttribute("class").contains(style));
+ return parent;
+ }
+
+ private long getTime(String style) {
+ WebElement start = findElement(By.className(style));
+ return Long.parseLong(start.getText());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java
new file mode 100644
index 0000000000..c74f2a53e3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java
@@ -0,0 +1,39 @@
+package com.vaadin.tests.components.calendar;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Calendar;
+
+public class CalendarWeekSelection extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ Calendar calendar = new Calendar();
+ calendar.setLocale(Locale.US);
+
+ try {
+ calendar.setStartDate(new SimpleDateFormat("yyyy-MM-dd")
+ .parse("2013-12-15"));
+ calendar.setEndDate(new SimpleDateFormat("yyyy-MM-dd")
+ .parse("2014-01-15"));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ addComponent(calendar);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14783;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "December 2013 - January 2014. Clicking the week 1 "
+ + "should open the week view for the first week of 2014.";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java
new file mode 100644
index 0000000000..83f41994ae
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java
@@ -0,0 +1,41 @@
+package com.vaadin.tests.components.calendar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class CalendarWeekSelectionTest extends MultiBrowserTest {
+
+ @Test
+ public void correctYearIsSelected() {
+ openTestURL();
+
+ clickOnWeek("1");
+
+ assertThat(getFirstDayOfTheYear().getText(), is("Wednesday 1/1/14"));
+ }
+
+ private WebElement getFirstDayOfTheYear() {
+ WebElement header = findElement(By.className("v-calendar-header-week"));
+ List<WebElement> headerElements = header.findElements(By.tagName("td"));
+
+ // Wednesday is the first day of 2014.
+ return headerElements.get(4);
+ }
+
+ private void clickOnWeek(String week) {
+ for (WebElement e : findElements(By.className("v-calendar-week-number"))) {
+ if (e.getText().equals(week)) {
+ e.click();
+ break;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java
index d3f30f3b37..66d1c34ab7 100644
--- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldIsValid.java
@@ -7,7 +7,6 @@ import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
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.Button.ClickListener;
import com.vaadin.ui.DateField;
@@ -42,8 +41,7 @@ public class DateFieldIsValid extends AbstractTestUIWithLog {
}
});
addComponent(dateField);
- Button button = new Button("check dateField");
- button.addClickListener(new ClickListener() {
+ addButton("check dateField", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -51,7 +49,6 @@ public class DateFieldIsValid extends AbstractTestUIWithLog {
+ ", is valid: " + dateField.isValid());
}
});
- addComponent(button);
}
/**
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java
new file mode 100644
index 0000000000..60508a30d4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.DateField;
+
+public class DateFieldPopupClosing extends AbstractTestUI {
+
+ static final String DATEFIELD_ID = "datefield";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final DateField df = new DateField();
+ df.setId(DATEFIELD_ID);
+ addComponent(df);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "DateField popup should be closed when click on popup button";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14857;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java
new file mode 100644
index 0000000000..ecbd6dd667
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java
@@ -0,0 +1,42 @@
+package com.vaadin.tests.components.datefield;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DateFieldPopupClosingTest extends MultiBrowserTest {
+ /*
+ * try to open/close many times (not one time) because this defect is
+ * reproduced randomly (depends on timer)
+ */
+ private static final int N = 100;
+
+ @Test
+ public void testDateFieldPopupClosing() throws InterruptedException,
+ IOException {
+ openTestURL();
+
+ for (int i = 0; i < N; i++) {
+ clickDateDatePickerButton();
+
+ waitUntil(ExpectedConditions.visibilityOfElementLocated(By
+ .className("v-datefield-popup")));
+
+ clickDateDatePickerButton();
+
+ waitUntil(ExpectedConditions.invisibilityOfElementLocated(By
+ .className("v-datefield-popup")));
+ }
+ }
+
+ private void clickDateDatePickerButton() {
+ DateFieldElement dateField = $(DateFieldElement.class).first();
+ dateField.findElement(By.tagName("button")).click();
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponent.java b/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponent.java
new file mode 100644
index 0000000000..c873a7efe7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponent.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.layout;
+
+import com.vaadin.server.Page;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class EmptySpaceOnPageAfterExpandedComponent extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getLayout().setHeight("200px");
+
+ VerticalLayout container = new VerticalLayout();
+ container.setStyleName("mystyle");
+ container.setId("container");
+ container.setSpacing(true);
+ container.setSizeFull();
+ addComponent(container);
+
+ Page.getCurrent().getStyles()
+ .add(".mystyle {border: 1px solid black;}");
+
+ GridLayout grid = new GridLayout();
+ grid.setSpacing(true);
+
+ TextField text1 = new TextField();
+ text1.setCaption("Text1");
+ text1.setRequired(true);
+
+ grid.setColumns(1);
+ grid.setRows(1);
+
+ grid.addComponent(text1);
+
+ grid.setSizeUndefined();
+
+ Panel panel = new Panel();
+ panel.setContent(grid);
+
+ panel.setSizeUndefined();
+
+ container.addComponent(panel);
+
+ TextArea expand = new TextArea();
+ expand.setId("expandedElement");
+ expand.setSizeFull();
+ container.addComponent(expand);
+
+ container.setExpandRatio(expand, 1);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Height calculation should be correct in Chrome. There should not be any empty space after expanded component.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12672;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java b/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java
new file mode 100644
index 0000000000..09d19034e6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2013 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.layout;
+
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test to make sure that there is no any empty space (in Google Chrome) on page
+ * after expanded component (#12672)
+ *
+ * Layout:
+ *
+ * [ Panel (auto x auto) [ Grid (auto x auto) ]
+ *
+ * AnyComponent (100% x 100%)
+ *
+ * <HERE SHOULD NOT BE ANY EMPTY SPACE> ]
+ *
+ * @author Vaadin Ltd
+ */
+public class EmptySpaceOnPageAfterExpandedComponentTest extends
+ MultiBrowserTest {
+
+ @Test
+ public void testNoEmptySpaceOnPageAfterExpandedComponent() {
+ openTestURL();
+
+ final WebElement expandedElement = vaadinElementById("expandedElement");
+ final WebElement containerElement = vaadinElementById("container");
+
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ int expandedElementBottom = expandedElement.getLocation()
+ .getY() + expandedElement.getSize().getHeight();
+ int containerElementBottom = containerElement.getLocation()
+ .getY() + containerElement.getSize().getHeight();
+
+ return expandedElementBottom + 1 == containerElementBottom;
+ }
+ });
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java
new file mode 100644
index 0000000000..16a0896aa2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java
@@ -0,0 +1,125 @@
+/*
+ * 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.menubar;
+
+import com.vaadin.server.FontAwesome;
+import com.vaadin.server.Resource;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+/**
+ * A UI for testing VMenuBar.getSubPartElement(String). The UI contains two
+ * MenuBars, one without icons and one containing items with and without icons.
+ * Some of the icons are textual (using FontAwesome) and should behave like
+ * items with image icons: the icon should not be considered to be a part of the
+ * item's caption.
+ *
+ * @since
+ * @author Vaadin
+ */
+@SuppressWarnings("serial")
+public class MenuBarsWithNesting extends AbstractTestUI {
+
+ // The label displays the last selection.
+ private final Label label = new Label("Initial content");
+
+ // The captions and icons used in the second MenuBar.
+ public final static String[] itemNames = { "Icon item", "Arrow down",
+ "Arrow up", "Warning" };
+ private final static Resource[] itemIcons = {
+ new ThemeResource("window/img/restore.png"),
+ FontAwesome.ARROW_DOWN, FontAwesome.ARROW_UP, FontAwesome.WARNING };
+
+ // The last menu item is nested with the following submenu items.
+ public final static String[] nestedItemnames = { "No icon", "Font icon",
+ "Image icon" };
+ private final static Resource[] nestedItemIcons = { null, FontAwesome.LINK,
+ new ThemeResource("window/img/restore.png") };
+
+ private MenuBar.Command selectionCommand;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ selectionCommand = new MenuBar.Command() {
+ @Override
+ public void menuSelected(MenuItem selectedItem) {
+ label.setValue(selectedItem.getText());
+ }
+ };
+ addComponent(createFirstMenuBar());
+ addComponent(createSecondMenuBar());
+ addComponent(label);
+ }
+
+ /*
+ * Returns a menu bar with three levels of nesting but no icons.
+ */
+ private MenuBar createFirstMenuBar() {
+ MenuBar menuBar = new MenuBar();
+ MenuItem file = menuBar.addItem("File", null);
+ file.addItem("Open", selectionCommand);
+ file.addItem("Save", selectionCommand);
+ file.addItem("Save As..", selectionCommand);
+ file.addSeparator();
+ MenuItem export = file.addItem("Export..", null);
+ export.addItem("As PDF...", selectionCommand);
+ export.addItem("As Doc...", selectionCommand);
+ file.addSeparator();
+ file.addItem("Exit", selectionCommand);
+
+ MenuItem edit = menuBar.addItem("Edit", null);
+ edit.addItem("Copy", selectionCommand);
+ edit.addItem("Cut", selectionCommand);
+ edit.addItem("Paste", selectionCommand);
+
+ menuBar.addItem("Help", selectionCommand);
+ return menuBar;
+ }
+
+ /*
+ * Returns a menu bar containing items with icons. The last menu item is
+ * nested and its submenu contains items with and without icons.
+ */
+ private MenuBar createSecondMenuBar() {
+ MenuBar menuBar = new MenuBar();
+ int n = itemNames.length;
+ for (int i = 0; i < n - 1; i++) {
+ menuBar.addItem(itemNames[i], itemIcons[i], selectionCommand);
+ }
+ MenuItem last = menuBar.addItem(itemNames[n - 1], itemIcons[n - 1],
+ null);
+ for (int i = 0; i < nestedItemnames.length; i++) {
+ last.addItem(nestedItemnames[i], nestedItemIcons[i],
+ selectionCommand);
+ }
+ return menuBar;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "This UI is used for testing subpart functionality of MenuBar. The "
+ + "functionality is used in TestBench tests.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14879;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNestingTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNestingTest.java
new file mode 100644
index 0000000000..4c3383c5d6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarsWithNestingTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.menubar;
+
+import static com.vaadin.tests.components.menubar.MenuBarsWithNesting.itemNames;
+import static com.vaadin.tests.components.menubar.MenuBarsWithNesting.nestedItemnames;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.MenuBarElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * This class tests the method VMenuBar.getSubPartElement(String) by using
+ * Vaadin locators for finding the items of a MenuBar.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class MenuBarsWithNestingTest extends MultiBrowserTest {
+ private MenuBarElement firstMenuBar, secondMenuBar;
+ private LabelElement label;
+
+ @Before
+ public void init() {
+ openTestURL();
+ firstMenuBar = $(MenuBarElement.class).first();
+ secondMenuBar = $(MenuBarElement.class).get(1);
+ label = $(LabelElement.class).get(1);
+ }
+
+ @Test
+ public void testMenuWithoutIcons() {
+ WebElement fileMenu = firstMenuBar.findElement(By.vaadin("#File"));
+ fileMenu.click();
+ WebElement exportMenu = fileMenu.findElement(By.vaadin("#Export.."));
+ exportMenu.click();
+ waitUntil(ExpectedConditions.visibilityOfElementLocated(By
+ .xpath(".//*[text() = 'As PDF...']")));
+ }
+
+ @Test
+ public void testMenuWithIcons() throws InterruptedException {
+ // There is a separate test for the last item of the second menu.
+ for (int i = 0; i < itemNames.length - 1; i++) {
+ String itemName = itemNames[i];
+ secondMenuBar.findElement(By.vaadin("#" + itemName)).click();
+ waitUntil(ExpectedConditions.textToBePresentInElement(
+ label.getWrappedElement(), itemName));
+ }
+ }
+
+ @Test
+ public void testNestedMenuWithIcons() throws InterruptedException {
+ String selection = itemNames[itemNames.length - 1];
+ for (String itemName : nestedItemnames) {
+ WebElement lastMenuItem = secondMenuBar.findElement(By.vaadin("#"
+ + selection));
+ lastMenuItem.click();
+ lastMenuItem.findElement(By.vaadin("#" + itemName)).click();
+ waitUntil(ExpectedConditions.textToBePresentInElement(
+ label.getWrappedElement(), itemName));
+ }
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/page/PageReload.java b/uitest/src/com/vaadin/tests/components/page/PageReload.java
index c1799b29e3..033da4e0e8 100644
--- a/uitest/src/com/vaadin/tests/components/page/PageReload.java
+++ b/uitest/src/com/vaadin/tests/components/page/PageReload.java
@@ -2,7 +2,6 @@ package com.vaadin.tests.components.page;
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.Button.ClickListener;
@@ -10,14 +9,12 @@ public class PageReload extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
- Button b = new Button("Press to reload");
- b.addClickListener(new ClickListener() {
+ addButton("Press to reload", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getPage().reload();
}
});
- addComponent(b);
log("UI id: " + getUIId());
}
diff --git a/uitest/src/com/vaadin/tests/components/table/ContextMenuSize.java b/uitest/src/com/vaadin/tests/components/table/ContextMenuSize.java
new file mode 100644
index 0000000000..ec7301099f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/ContextMenuSize.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Table;
+
+/**
+ * Test UI for table context menu position and size.
+ *
+ * @author Vaadin Ltd
+ */
+public class ContextMenuSize extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Table table = new Table();
+ table.setPageLength(1);
+ table.addActionHandler(new Handler() {
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ }
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ return new Action[] { new Action("action1"),
+ new Action("action2"), new Action("action3"),
+ new Action("action4") };
+ }
+ });
+ BeanItemContainer<Bean> container = new BeanItemContainer<Bean>(
+ Bean.class);
+ container.addBean(new Bean());
+ table.setContainerDataSource(container);
+ addComponent(table);
+ }
+
+ @Override
+ public String getDescription() {
+ return "If context menu original position doesn't allow to show it then "
+ + "its bottom should be aligned with the window bottom and height "
+ + "should be reset after repositioning.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14863;
+ }
+
+ public static class Bean {
+
+ public String getName() {
+ return "name";
+ }
+
+ public void setName() {
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java b/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java
new file mode 100644
index 0000000000..bb7001bc97
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for context menu position and size.
+ *
+ * @author Vaadin Ltd
+ */
+public class ContextMenuSizeTest extends MultiBrowserTest {
+
+ @Test
+ public void testContextMenuBottom() {
+ openTestURL();
+
+ WebElement menu = openContextMenu();
+ int initialHeight = menu.getSize().getHeight();
+ int y = menu.getLocation().getY();
+
+ closeContextMenu();
+
+ Dimension size = getDriver().manage().window().getSize();
+
+ int windowHeight = y + initialHeight - 10;
+ if (isElementPresent(By.className("v-ff"))) {
+ // FF does something wrong with window height
+ windowHeight = y + initialHeight + 90;
+ } else if (isElementPresent(By.className("v-ch"))) {
+ // Chrome does something wrong with window height
+ windowHeight = y + initialHeight + 20;
+ }
+ getDriver().manage().window()
+ .setSize(new Dimension(size.getWidth(), windowHeight));
+
+ menu = openContextMenu();
+ int height = menu.getSize().getHeight();
+
+ Assert.assertEquals("Context menu height has been changed after "
+ + "window height update which allows to show context as is",
+ initialHeight, height);
+
+ }
+
+ @Test
+ public void testContextMenuSize() {
+ openTestURL();
+
+ WebElement menu = openContextMenu();
+ int initialHeight = menu.getSize().getHeight();
+ int y = menu.getLocation().getY();
+
+ closeContextMenu();
+
+ Dimension size = getDriver().manage().window().getSize();
+
+ int windowHeight = initialHeight - 10;
+ if (isElementPresent(By.className("v-ch"))) {
+ // Chrome does something wrong with window height
+ windowHeight = y + initialHeight;
+ }
+ getDriver().manage().window()
+ .setSize(new Dimension(size.getWidth(), windowHeight));
+
+ menu = openContextMenu();
+ int height = menu.getSize().getHeight();
+
+ Assert.assertTrue(
+ "Context menu height has not been descreased after "
+ + "window height update to value lower than context menu initial height",
+ initialHeight > height);
+ closeContextMenu();
+
+ getDriver().manage().window()
+ .setSize(new Dimension(size.getWidth(), size.getHeight()));
+ menu = openContextMenu();
+ height = menu.getSize().getHeight();
+ Assert.assertEquals("Context menu height has not been reset after "
+ + "window height reset", initialHeight, height);
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(
+ getAllBrowsers());
+
+ // context menu doesn't work in phantom JS and works wired with IE8 and
+ // selenium.
+ browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());
+ browsers.remove(Browser.IE8.getDesiredCapabilities());
+ return browsers;
+ }
+
+ private WebElement openContextMenu() {
+ Actions actions = new Actions(getDriver());
+ actions.contextClick(findElement(By.className("v-table-cell-wrapper")));
+ actions.perform();
+ return findElement(By.className("v-contextmenu"));
+ }
+
+ private void closeContextMenu() {
+ Actions actions = new Actions(getDriver());
+ actions.click().build().perform();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java b/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java
index 4c0bea77ac..177f4d68fc 100644
--- a/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java
+++ b/uitest/src/com/vaadin/tests/components/table/FocusOnSelectedItem.java
@@ -49,8 +49,7 @@ public class FocusOnSelectedItem extends AbstractTestUI {
}
addComponent(table);
- Button button = new Button("Select");
- button.addClickListener(new Button.ClickListener() {
+ addButton("Select", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setValue("Item 198");
@@ -58,7 +57,6 @@ public class FocusOnSelectedItem extends AbstractTestUI {
table.focus();
}
});
- addComponent(button);
}
/*
diff --git a/uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java b/uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java
new file mode 100644
index 0000000000..e9c948ddf7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDrag.java
@@ -0,0 +1,86 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+public class HeaderRightClickAfterDrag extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Table table = new Table();
+ table.setContainerDataSource(new BeanItemContainer<TestBean>(
+ TestBean.class));
+ for (int i = 0; i < 10; i++) {
+ table.addItem(new TestBean(i));
+ }
+
+ table.setPageLength(10);
+ table.setColumnReorderingAllowed(true);
+ table.addHeaderClickListener(new Table.HeaderClickListener() {
+ @Override
+ public void headerClick(Table.HeaderClickEvent event) {
+ if (MouseEventDetails.MouseButton.RIGHT.equals(event
+ .getButton())) {
+ Window window = new Window("Right-clicked:", new Label(
+ "<center>"
+ + event.getPropertyId().toString()
+ .toUpperCase() + "</center>",
+ ContentMode.HTML));
+ window.setPositionX(event.getClientX());
+ window.setPositionY(event.getClientY());
+ window.setResizable(false);
+ addWindow(window);
+ }
+ }
+ });
+
+ addComponent(table);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "1) Right click a column header and see a popup<br>"
+ + "2) Reorder (or at least start dragging) that column<br>"
+ + "3) Right click that same column header, and you should get a popup again.<br>"
+ + "Before fix: no popup, unless you first left-click the header.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 15167;
+ }
+
+ public class TestBean {
+
+ private String foo, bar, baz, fiz;
+
+ public TestBean(int i) {
+ foo = "Foo " + i;
+ bar = "Bar " + i;
+ baz = "Baz " + i;
+ fiz = "Fix " + i;
+ }
+
+ public String getFoo() {
+ return foo;
+ }
+
+ public String getBar() {
+ return bar;
+ }
+
+ public String getBaz() {
+ return baz;
+ }
+
+ public String getFiz() {
+ return fiz;
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java b/uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java
new file mode 100644
index 0000000000..f5f8bcce2a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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 org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.testbench.elements.WindowElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests whether right-click on a column header works after the column is
+ * dragged.
+ *
+ * @author Vaadin Ltd
+ */
+public class HeaderRightClickAfterDragTest extends MultiBrowserTest {
+
+ @Test
+ public void dragAndRightClick() {
+ openTestURL();
+
+ waitForElementPresent(By.className("v-table"));
+
+ TableElement table = $(TableElement.class).first();
+ TestBenchElement header0 = table.getHeaderCell(0);
+ Actions actions = new Actions(getDriver());
+ actions.contextClick(header0).perform();
+
+ // check that right-click opened a window
+ waitForElementPresent(By.className("v-window"));
+
+ closeWindow();
+
+ actions.clickAndHold(header0).moveToElement(table.getHeaderCell(1))
+ .release();
+
+ actions.contextClick(header0).perform();
+
+ // check that right-click still opened a window
+ waitForElementPresent(By.className("v-window"));
+ }
+
+ private void closeWindow() {
+ WindowElement window = $(WindowElement.class).first();
+ window.findElement(By.className("v-window-closebox")).click();
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver driver) {
+ return findElements(By.className("v-window")).isEmpty();
+ }
+ });
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java b/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java
index e783951d86..7789d0ae19 100644
--- a/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java
+++ b/uitest/src/com/vaadin/tests/components/table/LeftColumnAlignment.java
@@ -19,7 +19,6 @@ import com.vaadin.annotations.Theme;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.server.VaadinRequest;
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.Table;
@@ -53,15 +52,13 @@ public class LeftColumnAlignment extends AbstractTestUI {
addComponent(table);
- Button button = new Button("Align to Left");
- button.addClickListener(new ClickListener() {
+ addButton("Align to Left", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setColumnAlignment("name", Align.LEFT);
}
});
- addComponent(button);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java b/uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java
new file mode 100644
index 0000000000..745f2344a3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRows.java
@@ -0,0 +1,92 @@
+package com.vaadin.tests.components.table;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.vaadin.data.util.BeanContainer;
+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.Table;
+
+@SuppressWarnings("serial")
+public class TableCacheMinimizingOnFetchRows extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getLayout().setMargin(true);
+
+ final Table table = new Table("Beans of All Sorts");
+
+ BeanContainer<String, Bean> beans = new BeanContainer<String, Bean>(
+ Bean.class) {
+ @Override
+ public List<String> getItemIds(int startIndex, int numberOfIds) {
+
+ // numberOfIds should be about 60 after scrolling down the table
+ log.log("requested " + numberOfIds + " rows");
+
+ return super.getItemIds(startIndex, numberOfIds);
+ }
+ };
+ beans.setBeanIdProperty("name");
+
+ for (int i = 0; i < 10000; i++) {
+ beans.addBean(new Bean("Common bean" + i, i));
+ }
+
+ table.setContainerDataSource(beans);
+ table.setPageLength(20);
+ table.setVisibleColumns(new Object[] { "name", "value" });
+ table.setWidth("800px");
+
+ Button button = new Button("scroll down");
+ button.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ table.setCurrentPageFirstItemIndex(table.size());
+ }
+ });
+
+ addComponent(table);
+ addComponent(button);
+ }
+
+ public class Bean implements Serializable {
+
+ String name;
+ int value;
+
+ public Bean(String name, int value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Ensure that when scrolling from top to bottom in a big table with 10000 items, not all rows in the range are cached";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 13576;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRowsTest.java b/uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRowsTest.java
new file mode 100644
index 0000000000..edb0f3851a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableCacheMinimizingOnFetchRowsTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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 org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TableCacheMinimizingOnFetchRowsTest extends MultiBrowserTest {
+
+ @Test
+ public void testCacheSize() throws InterruptedException {
+
+ openTestURL();
+
+ scrollToBottomOfTable();
+
+ // the row request might vary slightly with different browsers
+ String logtext1 = "requested 60 rows";
+ String logtext2 = "requested 61 rows";
+
+ assertThat("Requested cached rows did not match expected",
+ logContainsText(logtext1) || logContainsText(logtext2));
+
+ }
+
+ private void scrollToBottomOfTable() {
+ waitForElementPresent(By.className("v-button"));
+ $(ButtonElement.class).first().click();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java b/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java
index 64f1a64558..4bdec81ccf 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java
@@ -38,7 +38,7 @@ public class TableClickAndDragOnIconAndComponents extends AbstractTestUI {
table.setId("testable-table");
addComponent(table);
for (int i = 0; i < 5; i++) {
- addItemAfter(i + "foo", null);
+ addItemAfter(i + "foo", null, false);
}
table.addGeneratedColumn("Label", new ColumnGenerator() {
@@ -118,14 +118,15 @@ public class TableClickAndDragOnIconAndComponents extends AbstractTestUI {
IndexedContainer container = (IndexedContainer) table
.getContainerDataSource();
+ boolean selected = table.getValue().equals(dragged);
container.removeItem(dragged);
- addItemAfter(dragged, target);
+ addItemAfter(dragged, target, selected);
}
});
}
@SuppressWarnings("unchecked")
- private void addItemAfter(Object itemId, Object afterItemId) {
+ private void addItemAfter(Object itemId, Object afterItemId, boolean select) {
Item item;
if (afterItemId != null) {
item = table.addItemAfter(afterItemId, itemId);
@@ -136,6 +137,9 @@ public class TableClickAndDragOnIconAndComponents extends AbstractTestUI {
item.getItemProperty("red").setValue("red " + itemId);
item.getItemProperty("icon").setValue(
new ThemeResource("../runo/icons/16/ok.png"));
+ if (select) {
+ table.select(itemId);
+ }
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRow.java b/uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRow.java
new file mode 100644
index 0000000000..349fbc73fe
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRow.java
@@ -0,0 +1,117 @@
+/*
+ * 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 java.util.Collection;
+
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.MultiSelectMode;
+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.Label;
+import com.vaadin.ui.Table;
+
+/**
+ * Test UI for delete rows operation in multiselect table.
+ *
+ * @author Vaadin Ltd
+ */
+public class TableDeleteSelectedRow extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Table table = new Table();
+ table.setSelectable(true);
+ table.setImmediate(true);
+
+ BeanItemContainer<TableBean> container = createContainer();
+
+ table.setContainerDataSource(container);
+
+ final Label selectedSize = new Label();
+ selectedSize.addStyleName("selected-rows");
+
+ Button changeMode = new Button("Set multiselect", new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ table.setMultiSelect(true);
+ table.setMultiSelectMode(MultiSelectMode.SIMPLE);
+
+ BeanItemContainer<TableBean> container = createContainer();
+
+ table.setContainerDataSource(container);
+ }
+ });
+ changeMode.addStyleName("multiselect");
+
+ Button delete = new Button("Delete selected", new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (table.getValue() instanceof Collection) {
+ Collection<?> rows = (Collection<?>) table.getValue();
+ for (Object row : rows) {
+ table.getContainerDataSource().removeItem(row);
+ }
+ rows = (Collection<?>) table.getValue();
+ selectedSize.setValue(String.valueOf(rows.size()));
+ } else {
+ table.getContainerDataSource().removeItem(table.getValue());
+ selectedSize.setValue(table.getValue() == null ? "0" : "1");
+ }
+ }
+ });
+ delete.addStyleName("delete");
+
+ addComponents(delete, changeMode, selectedSize, table);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Items deleted via container data source should not be available as selected in the table.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 13580;
+ }
+
+ private BeanItemContainer<TableBean> createContainer() {
+ BeanItemContainer<TableBean> container = new BeanItemContainer<TableBean>(
+ TableBean.class);
+ container.addBean(new TableBean("first"));
+ container.addBean(new TableBean("second"));
+ container.addBean(new TableBean("third"));
+ return container;
+ }
+
+ public static class TableBean {
+
+ TableBean(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ private String name;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRowTest.java b/uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRowTest.java
new file mode 100644
index 0000000000..0e807edf14
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableDeleteSelectedRowTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test to check selected rows in multiselect table after deletion.
+ *
+ * @author Vaadin Ltd
+ */
+public class TableDeleteSelectedRowTest extends MultiBrowserTest {
+
+ @Test
+ public void deleteSelectedRows() {
+ openTestURL();
+
+ // Select row in the table
+ findElement(By.className("v-table-row-odd")).click();
+
+ // Delete selected row
+ findElement(By.className("delete")).click();
+
+ WebElement selectedSize = findElement(By.className("selected-rows"));
+ int size = Integer.parseInt(selectedSize.getText());
+
+ Assert.assertEquals(
+ "Non empty collection of selected rows after remove via container",
+ 0, size);
+
+ // Reset table and set multiselect mode
+ findElement(By.className("multiselect")).click();
+
+ // Select row in the table
+ findElement(By.className("v-table-row-odd")).click();
+
+ // Delete selected row
+ findElement(By.className("delete")).click();
+
+ selectedSize = findElement(By.className("selected-rows"));
+ size = Integer.parseInt(selectedSize.getText());
+
+ Assert.assertEquals(
+ "Non empty collection of selected rows after remove via container",
+ 0, size);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java b/uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java
new file mode 100644
index 0000000000..92c9b8d988
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java
@@ -0,0 +1,110 @@
+/*
+ * 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 java.util.Arrays;
+
+import com.vaadin.annotations.PreserveOnRefresh;
+import com.vaadin.annotations.Theme;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+@PreserveOnRefresh
+@Theme("valo")
+public class TableExpandRatio extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ BeanItemContainer<MyItem> container = new BeanItemContainer<TableExpandRatio.MyItem>(
+ MyItem.class, Arrays.asList(new MyItem("one", 1), new MyItem(
+ "two", 2)));
+
+ final Table table = new Table(null, container);
+
+ table.setWidth("800px");
+ table.setImmediate(true);
+
+ Button widthButton = new Button("Set Width",
+ new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ table.setColumnWidth("value", 300);
+
+ }
+ });
+
+ Button expandButton = new Button("Set Expand Ratio",
+ new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ table.setColumnExpandRatio("value", 1);
+
+ }
+ });
+
+ widthButton.setId("widthbutton");
+ expandButton.setId("expandbutton");
+
+ VerticalLayout layout = new VerticalLayout(widthButton, expandButton,
+ table);
+ addComponent(layout);
+ }
+
+ public class MyItem {
+
+ private String name;
+ private Integer value;
+
+ public MyItem(String name, Integer value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getValue() {
+ return value;
+ }
+
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "When a column has fixed width and it is changed to expand ratio, the width should update accordingly";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 15101;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java b/uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java
new file mode 100644
index 0000000000..3cf66d4e4b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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 org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.number.IsCloseTo.closeTo;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TableExpandRatioTest extends MultiBrowserTest {
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+
+ openTestURL();
+ }
+
+ /*
+ * Needed for IE to get focus when button is clicked
+ */
+ @Override
+ protected boolean requireWindowFocusForIE() {
+
+ return true;
+ }
+
+ @Test
+ public void cellWidthUpdatesWhenExpandRatioSetAfterDefinedWidth() {
+
+ // test that after setting defined size to the second column, the first
+ // column will have correct size
+
+ setDefinedWidth();
+
+ assertThat(getFirstCellWidth(), closeTo(500, 10));
+
+ // test that after setting expandratio to the second column, it is
+ // correct
+
+ setExpandRatio();
+
+ assertThat(getFirstCellWidth(), closeTo(65, 5));
+
+ }
+
+ private void setExpandRatio() {
+ $(ButtonElement.class).id("expandbutton").click();
+ }
+
+ private void setDefinedWidth() {
+ $(ButtonElement.class).id("widthbutton").click();
+ }
+
+ private double getFirstCellWidth() {
+
+ List<WebElement> rows = $(TableElement.class).first()
+ .findElement(By.className("v-table-body"))
+ .findElements(By.tagName("tr"));
+ WebElement firstrow = rows.get(0);
+ List<WebElement> cells = firstrow.findElements(By
+ .className("v-table-cell-content"));
+
+ int cellwidth = cells.get(0).getSize().getWidth();
+ return cellwidth;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java b/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java
index df06580dae..bee0839663 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java
@@ -115,11 +115,11 @@ public class TableRepairsScrollPositionOnReAddingAllRows extends AbstractTestUI
}
});
- Button buttonReplaceByWholeSubsetPlusOnNew = new Button(
+ Button buttonReplaceByWholeSubsetPlusOneNew = new Button(
"Replace rows by whole subset plus one new item");
- buttonReplaceByWholeSubsetPlusOnNew
- .setId("buttonReplaceByWholeSubsetPlusOnNew");
- buttonReplaceByWholeSubsetPlusOnNew
+ buttonReplaceByWholeSubsetPlusOneNew
+ .setId("buttonReplaceByWholeSubsetPlusOneNew");
+ buttonReplaceByWholeSubsetPlusOneNew
.addClickListener(new ClickListener() {
@Override
@@ -136,6 +136,40 @@ public class TableRepairsScrollPositionOnReAddingAllRows extends AbstractTestUI
}
});
+ Button buttonRemoveAllAddOne = new Button(
+ "Remove all items and add only one new item");
+ buttonRemoveAllAddOne.setId("buttonRemoveAllAddOne");
+ buttonRemoveAllAddOne.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
+ cont.removeAllItems();
+ TableItem ti = new TableItem();
+ ti.setName("Item_" + 20);
+ cont.addBean(ti);
+ }
+ });
+
+ // This should be the last test as it changes the table datasource
+ Button buttonReplaceByNewDatasource = new Button(
+ "Remove all items and add new datasource");
+ buttonReplaceByNewDatasource.setId("buttonReplaceByNewDatasource");
+ buttonReplaceByNewDatasource.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
+ cont.removeAllItems();
+ BeanItemContainer<TableItem> newContainer = new BeanItemContainer<TableItem>(
+ TableItem.class);
+ for (int i = 0; i < 50; i++) {
+ TableItem ti = new TableItem();
+ ti.setName("Item_" + i);
+ newContainer.addBean(ti);
+ }
+ table.setContainerDataSource(newContainer);
+ }
+ });
+
for (int i = 0; i < 80; i++) {
TableItem ti = new TableItem();
ti.setName("Item_" + i);
@@ -147,7 +181,9 @@ public class TableRepairsScrollPositionOnReAddingAllRows extends AbstractTestUI
getLayout().addComponent(buttonReplaceByAnotherCollectionViaAddAll);
getLayout().addComponent(buttonReplaceByAnotherCollectionViaAdd);
getLayout().addComponent(buttonReplaceBySubsetOfSmallerSize);
- getLayout().addComponent(buttonReplaceByWholeSubsetPlusOnNew);
+ getLayout().addComponent(buttonReplaceByWholeSubsetPlusOneNew);
+ getLayout().addComponent(buttonRemoveAllAddOne);
+ getLayout().addComponent(buttonReplaceByNewDatasource);
getLayout().addComponent(buttonRestore);
getLayout().addComponent(table);
}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRowsTest.java b/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRowsTest.java
index a3e7f29dfe..4ca3ed406b 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRowsTest.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRowsTest.java
@@ -18,17 +18,10 @@ package com.vaadin.tests.components.table;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.number.IsCloseTo.closeTo;
+import org.junit.Before;
import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-import com.vaadin.testbench.commands.TestBenchCommandExecutor;
import com.vaadin.testbench.elements.TableElement;
-import com.vaadin.testbench.screenshot.ImageComparison;
-import com.vaadin.testbench.screenshot.ReferenceNameGenerator;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
@@ -40,138 +33,127 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
public class TableRepairsScrollPositionOnReAddingAllRowsTest extends
MultiBrowserTest {
- @Test
- public void testScrollRepairsAfterReAddingAllRows()
- throws InterruptedException {
- openTestURL();
-
- WebElement row0 = $(TableElement.class).first().getCell(0, 0);
- int rowLocation0 = row0.getLocation().getY();
+ private int rowLocation0;
- // case 1
- scrollUp();
+ @Override
+ @Before
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
- waitUntilNot(new ExpectedCondition<Boolean>() {
- @Override
- public Boolean apply(WebDriver input) {
- return $(TableElement.class).first().getCell(48, 0) == null;
- }
- }, 10);
+ rowLocation0 = getCellY(0);
+ scrollToBottom();
+ }
- WebElement row = $(TableElement.class).first().getCell(48, 0);
- int rowLocation = row.getLocation().getY();
+ @Test
+ public void testReAddAllViaAddAll() {
+ int rowLocation = getCellY(70);
// This button is for re-adding all rows (original itemIds) at once
// (removeAll() + addAll())
hitButton("buttonReAddAllViaAddAll");
- row = $(TableElement.class).first().getCell(48, 0);
- int newRowLocation = row.getLocation().getY();
+ int newRowLocation = getCellY(70);
- // ranged check because IE9 consistently misses the mark by 1 pixel
- assertThat(
+ assertCloseTo(
"Scroll position should be the same as before Re-Adding rows via addAll()",
- (double) newRowLocation,
- closeTo(rowLocation, row.getSize().height + 1));
-
- // case 2
- scrollUp();
+ newRowLocation, rowLocation);
- waitUntilNot(new ExpectedCondition<Boolean>() {
- @Override
- public Boolean apply(WebDriver input) {
- return $(TableElement.class).first().getCell(48, 0) == null;
- }
- }, 10);
+ }
- row = $(TableElement.class).first().getCell(48, 0);
- rowLocation = row.getLocation().getY();
+ @Test
+ public void testReplaceByAnotherCollectionViaAddAll() {
+ int rowLocation = getCellY(70);
// This button is for replacing all rows at once (removeAll() +
// addAll())
hitButton("buttonReplaceByAnotherCollectionViaAddAll");
- row = $(TableElement.class).first().getCell(48, 0);
- newRowLocation = row.getLocation().getY();
+ // new collection has one less element
+ int newRowLocation = getCellY(69);
- // ranged check because IE9 consistently misses the mark by 1 pixel
- assertThat(
+ assertCloseTo(
"Scroll position should be the same as before Replacing rows via addAll()",
- (double) newRowLocation,
- closeTo(rowLocation, row.getSize().height + 1));
+ newRowLocation, rowLocation);
+ }
+
+ @Test
+ public void testReplaceByAnotherCollectionViaAdd() {
- // case 3
// This button is for replacing all rows one by one (removeAll() + add()
// + add()..)
hitButton("buttonReplaceByAnotherCollectionViaAdd");
- row = $(TableElement.class).first().getCell(0, 0);
- newRowLocation = row.getLocation().getY();
+ int newRowLocation = getCellY(0);
- // ranged check because IE9 consistently misses the mark by 1 pixel
- assertThat("Scroll position should be 0", (double) newRowLocation,
- closeTo(rowLocation0, 1));
-
- // case 4
- // This button is for restoring initial list and for scrolling to 0
- // position
- hitButton("buttonRestore");
- scrollUp();
-
- waitUntilNot(new ExpectedCondition<Boolean>() {
- @Override
- public Boolean apply(WebDriver input) {
- return $(TableElement.class).first().getCell(48, 0) == null;
- }
- }, 10);
+ assertCloseTo("Scroll position should be 0", newRowLocation,
+ rowLocation0);
+ }
+ @Test
+ public void testReplaceBySubsetOfSmallerSize() {
// This button is for replacing all rows at once but the count of rows
// is less then first index to scroll
hitButton("buttonReplaceBySubsetOfSmallerSize");
- row = $(TableElement.class).first().getCell(5, 0);
+ int newRowLocation = getCellY(5);
- newRowLocation = row.getLocation().getY();
+ assertCloseTo("Scroll position should be 0", newRowLocation,
+ rowLocation0);
+ }
- // ranged check because IE9 consistently misses the mark by 1 pixel
- assertThat("Scroll position should be 0", (double) newRowLocation,
- closeTo(rowLocation0, 1));
+ @Test
+ public void testReplaceByWholeSubsetPlusOneNew() {
+ int rowLocation = getCellY(70);
- // case 5
- // This button is for restoring initial list and for scrolling to 0
- // position
- hitButton("buttonRestore");
- scrollUp();
+ // This button is for replacing by whole original sub-set of items plus
+ // one new
+ hitButton("buttonReplaceByWholeSubsetPlusOneNew");
- waitUntilNot(new ExpectedCondition<Boolean>() {
- @Override
- public Boolean apply(WebDriver input) {
- return $(TableElement.class).first().getCell(48, 0) == null;
- }
- }, 10);
+ int newRowLocation = getCellY(70);
- row = $(TableElement.class).first().getCell(48, 0);
- rowLocation = row.getLocation().getY();
+ assertCloseTo("Scroll position should be the same as before Replacing",
+ newRowLocation, rowLocation);
- // This button is for replacing by whole original sub-set of items plus
- // one new
- hitButton("buttonReplaceByWholeSubsetPlusOnNew");
+ }
- row = $(TableElement.class).first().getCell(48, 0);
- newRowLocation = row.getLocation().getY();
+ @Test
+ public void testRemoveAllAddOne() {
+ // This button is for removing all and then adding only one new item
+ hitButton("buttonRemoveAllAddOne");
- // ranged check because IE9 consistently misses the mark by 1 pixel
- assertThat("Scroll position should be the same as before Replacing",
- (double) newRowLocation,
- closeTo(rowLocation, row.getSize().height + 1));
+ int newRowLocation = getCellY(0);
+
+ assertCloseTo("Scroll position should be 0", newRowLocation,
+ rowLocation0);
+ }
+
+ @Test
+ public void testReplaceByNewDatasource() {
+ // This button is for remove all items and add new datasource
+ hitButton("buttonReplaceByNewDatasource");
+
+ int newRowLocation = getCellY(0);
+
+ assertCloseTo("Scroll position should be 0", newRowLocation,
+ rowLocation0);
+ }
+
+ private TableElement getTable() {
+ return $(TableElement.class).first();
+ }
+ private void scrollToBottom() {
+ scrollTable(getTable(), 80, 70);
}
- private void scrollUp() {
- WebElement actualElement = getDriver().findElement(
- By.className("v-table-body-wrapper"));
- JavascriptExecutor js = new TestBenchCommandExecutor(getDriver(),
- new ImageComparison(), new ReferenceNameGenerator());
- js.executeScript("arguments[0].scrollTop = " + 1205, actualElement);
+ private int getCellY(int row) {
+ return getTable().getCell(row, 0).getLocation().getY();
}
+
+ private void assertCloseTo(String reason, int actual, int expected) {
+ // ranged check because IE9 consistently misses the mark by 1 pixel
+ assertThat(reason, (double) actual, closeTo(expected, 1));
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java b/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java
index 79a85cd49b..bd84fab309 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableWidthItemRemove.java
@@ -17,7 +17,6 @@ package com.vaadin.tests.components.table;
import com.vaadin.server.VaadinRequest;
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.Table;
@@ -46,17 +45,14 @@ public class TableWidthItemRemove extends AbstractTestUI {
table.setColumnWidth("lastName", 100);
table.setColumnWidth("year", 50);
- Button cleanButton = new Button("Clean");
- cleanButton.addClickListener(new ClickListener() {
+ addButton("Clean", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.removeAllItems();
}
});
- addComponent(cleanButton);
- Button populateButton = new Button("Populate");
- populateButton.addClickListener(new ClickListener() {
+ addButton("Populate", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.addItem(
@@ -64,7 +60,6 @@ public class TableWidthItemRemove extends AbstractTestUI {
Math.random() * 1000);
}
});
- addComponent(populateButton);
addComponent(table);
}
diff --git a/uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java b/uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java
new file mode 100644
index 0000000000..231375c2ea
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocused.java
@@ -0,0 +1,67 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+
+public class UpdateTableWhenUnfocused extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ final Table table = createTable();
+
+ TabSheet tabSheet = new TabSheet();
+ tabSheet.addTab(table, "tab1");
+ tabSheet.setHeight("5000px");
+ tabSheet.setWidth("100%");
+ addComponent(tabSheet);
+
+ final Button button = new Button("Refresh table");
+ button.addClickListener(new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ button.focus();
+ table.refreshRowCache();
+ }
+ });
+ addComponent(button);
+
+ }
+
+ private Table createTable() {
+ Table table = new Table("Table");
+ table.setImmediate(true);
+ table.setMultiSelect(true);
+ table.setSizeFull();
+ table.setSelectable(true);
+
+ Container ds = new IndexedContainer();
+ ds.addContainerProperty("column", Integer.class, null);
+ for (int i = 0; i < 500; i++) {
+ Item item = ds.addItem(i);
+ item.getItemProperty("column").setValue(i);
+ }
+ table.setContainerDataSource(ds);
+
+ return table;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Clicking the button after selecting a row in the table should not cause the window to scroll.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12976;
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocusedTest.java b/uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocusedTest.java
new file mode 100644
index 0000000000..fcd73f541d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/UpdateTableWhenUnfocusedTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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 org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class UpdateTableWhenUnfocusedTest extends MultiBrowserTest {
+
+ @Test
+ public void testWindowIsNotScrolled() throws IOException {
+ openTestURL();
+
+ TestBenchElement cell = $(TableElement.class).first().getCell(3, 0);
+ cell.click();
+
+ TestBenchElement button = $(ButtonElement.class).first();
+ button.focus();
+
+ int buttonLocation = button.getLocation().getY();
+
+ button.click();
+
+ int newButtonLocation = button.getLocation().getY();
+
+ assertThat(
+ "Button location has changed after table refresh, window has scrolled and it shouldn't have",
+ newButtonLocation, is(buttonLocation));
+
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java
index b51a8dde08..0d7ec48a99 100644
--- a/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServer.java
@@ -2,7 +2,6 @@ package com.vaadin.tests.components.tabsheet;
import com.vaadin.server.VaadinRequest;
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;
@@ -59,15 +58,13 @@ public class TabSelectionRevertedByServer extends AbstractTestUI {
addComponent(tabsheet);
- Button button = new Button("Select Last Tab");
- button.addClickListener(new ClickListener() {
+ addButton("Select Last Tab", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tabsheet.setSelectedTab(lastTab);
}
});
- addComponent(button);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetClose.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetClose.java
new file mode 100644
index 0000000000..2cadde567f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetClose.java
@@ -0,0 +1,72 @@
+/*
+ * 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.CssLayout;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+/**
+ * This test UI is used for checking that when a tab is closed, another one is
+ * scrolled into view.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TabSheetClose extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ TabSheet tabsheet = new TabSheet();
+ for (int loop = 0; loop < 3; loop++) {
+ Tab tab = tabsheet.addTab(new CssLayout(), "tab " + loop);
+ tab.setClosable(true);
+ tab.setId("tab" + loop);
+ }
+ CssLayout layout = new CssLayout();
+ layout.addComponent(tabsheet);
+ layout.setWidth("150px");
+ addComponent(layout);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "When all tabs have not been closed, at least one tab should be visible. ";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 14348;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetCloseTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetCloseTest.java
new file mode 100644
index 0000000000..5314038d72
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetCloseTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests that when closing the last tab on a TabSheet, another tab gets selected
+ * with no error. Only the last tab should be visible, so the actual TabSheet
+ * width should be small.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TabSheetCloseTest extends MultiBrowserTest {
+
+ private static final String TAB_CLOSE = "//span[@class = 'v-tabsheet-caption-close']";
+ private static final String LAST_TAB = "//*[@id = 'tab2']/div/div";
+ private static final String SCROLLER_NEXT = "//button[@class = 'v-tabsheet-scrollerNext']";
+ private static final String FIRST_TAB = "//*[@id = 'tab0']";
+ private static final String SECOND_TAB = "//*[@id = 'tab1']";
+
+ @Test
+ public void testClosingOfLastTab() throws Exception {
+ openTestURL();
+
+ // Click next button twice to get to the last tab
+ findElement(By.xpath(SCROLLER_NEXT)).click();
+ findElement(By.xpath(SCROLLER_NEXT)).click();
+
+ findElement(By.xpath(LAST_TAB)).click();
+
+ // Closing last tab will take back to the second tab. Closing that
+ // will leave the first tab visible.
+ findElements(By.xpath(TAB_CLOSE)).get(2).click();
+ assertTrue(findElement(By.xpath(SECOND_TAB)).isDisplayed());
+ findElements(By.xpath(TAB_CLOSE)).get(1).click();
+ assertTrue(findElement(By.xpath(FIRST_TAB)).isDisplayed());
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java
new file mode 100644
index 0000000000..1400100f3b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabClose.java
@@ -0,0 +1,98 @@
+/*
+ * 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.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+/**
+ * This testUI is used for testing that the scroll position of a tab sheet does
+ * not change when tabs are removed. The exception is removing the leftmost
+ * visible tab.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TabSheetScrollOnTabClose extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ final TabSheet tabSheet = new TabSheet();
+ for (int i = 0; i < 10; i++) {
+ Tab tab = tabSheet.addTab(new CssLayout(), "tab " + i);
+ tab.setClosable(true);
+ tab.setId("tab" + i);
+ }
+ tabSheet.setWidth(250, Unit.PIXELS);
+ addComponent(tabSheet);
+ addComponent(new Label("Close tab number"));
+ for (int i = 0; i < 10; i++) {
+ final String tabCaption = "tab " + i;
+ final Button b = new Button("" + i);
+ b.addClickListener(new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ b.setEnabled(false);
+ tabSheet.removeTab(getTab(tabSheet, tabCaption));
+ }
+ });
+ addComponent(b);
+ }
+ }
+
+ private Tab getTab(TabSheet ts, String tabCaption) {
+ for (int i = 0; i < ts.getComponentCount(); i++) {
+ String caption = ts.getTab(i).getCaption();
+ if (tabCaption.equals(caption)) {
+ return ts.getTab(i);
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Scroll position should not change when closing tabs.";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 14348;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabCloseTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabCloseTest.java
new file mode 100644
index 0000000000..8247b436d0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetScrollOnTabCloseTest.java
@@ -0,0 +1,171 @@
+/*
+ * 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.util.List;
+import java.util.NoSuchElementException;
+
+import org.junit.Test;
+import org.openqa.selenium.StaleElementReferenceException;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TabSheetElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests removing tabs that have been scrolled out of view. This should cause no
+ * change to the scroll position.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TabSheetScrollOnTabCloseTest extends MultiBrowserTest {
+
+ @Test
+ public void testScrollPositionAfterClosing() throws Exception {
+ openTestURL();
+ TabSheetElement ts = $(TabSheetElement.class).first();
+ WebElement tabSheetScroller = ts.findElement(By
+ .className("v-tabsheet-scrollerNext"));
+ // scroll to the right
+ for (int i = 0; i < 4; i++) {
+ tabSheetScroller.click();
+ }
+ // check that tab 4 is the first visible tab
+ checkDisplayedStatus(ts, "tab3", false);
+ checkDisplayedStatus(ts, "tab4", true);
+ // remove tabs from the left, check that tab4 is still the first visible
+ // tab
+ for (int i = 0; i < 4; i++) {
+ $(ButtonElement.class).get(i).click();
+ checkDisplayedStatus(ts, "tab3" + i, false);
+ checkDisplayedStatus(ts, "tab4", true);
+ checkDisplayedStatus(ts, "tab6", true);
+ }
+ // remove tabs from the right and check scroll position
+ for (int i = 7; i < 10; i++) {
+ $(ButtonElement.class).get(i).click();
+ checkFirstTab(ts, "tab4");
+ checkDisplayedStatus(ts, "tab6", true);
+ }
+ }
+
+ /**
+ * Checks that the visible status of the tab with the given id is equal to
+ * shouldBeVisible. That is, the tab with the given id should be visible if
+ * and only if shouldBeVisible is true. Used for checking that the leftmost
+ * visible tab is the expected one when there should be tabs (hidden because
+ * of scroll position) to the left of tabId.
+ *
+ * If there is no tab with the specified id, the tab is considered not to be
+ * visible.
+ */
+ private void checkDisplayedStatus(TabSheetElement tabSheet, String tabId,
+ boolean shouldBeVisible) {
+ org.openqa.selenium.By locator = By.cssSelector("#" + tabId);
+ waitUntil(visibilityOfElement(locator, shouldBeVisible));
+ }
+
+ /**
+ * Checks that there are no hidden tabs in tabSheet and that the id of the
+ * first tab is tabId. Used for checking that the leftmost visible tab is
+ * the expected one when there are no tabs to the left of the tab with the
+ * given id. When there are tabs to the left of tabId, check instead that
+ * tabId is visible and the previous tab is hidden (see
+ * checkDisplayedStatus).
+ */
+ private void checkFirstTab(TabSheetElement tabSheet, String tabId) {
+ waitUntil(visibilityOfElement(
+ By.cssSelector(".v-tabsheet-tabitemcell[aria-hidden]"), false));
+ waitUntil(leftmostTabHasId(tabSheet, tabId));
+ }
+
+ /**
+ * An expectation for checking that the visibility status of the specified
+ * element is correct. If the element does not exist in the DOM, it is
+ * considered not to be visible. If several elements match the locator, only
+ * the visibility of the first matching element is considered.
+ *
+ * @param locator
+ * used to find the element
+ * @param expectedVisibility
+ * whether the element should be visible
+ */
+ private static ExpectedCondition<Boolean> visibilityOfElement(
+ final org.openqa.selenium.By locator,
+ final boolean expectedVisibility) {
+ return new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver driver) {
+ List<WebElement> matchingElements = driver
+ .findElements(locator);
+ if (matchingElements.isEmpty()) {
+ return !expectedVisibility;
+ } else {
+ try {
+ WebElement first = matchingElements.get(0);
+ return first.isDisplayed() == expectedVisibility;
+ } catch (StaleElementReferenceException e) {
+ // The element was initially in DOM but has been
+ // removed.
+ return !expectedVisibility;
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "element " + (expectedVisibility ? "" : "not ")
+ + "expected to be visible: " + locator;
+ }
+ };
+ }
+
+ /**
+ * An expectation for checking that the leftmost tab has id equal to tabId.
+ *
+ * @param tabSheet
+ * the tab sheet containing the tab
+ * @param tabId
+ * the id of the tab that should be the leftmost tab
+ */
+ private static ExpectedCondition<Boolean> leftmostTabHasId(
+ final TabSheetElement tabSheet, final String tabId) {
+ return new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver driver) {
+ try {
+ WebElement leftElement = tabSheet.findElement(By
+ .cssSelector(".v-tabsheet-tabitemcell"));
+ String leftId = leftElement.getAttribute("id");
+ return leftId.equals(tabId);
+ } catch (NoSuchElementException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "expected tab index of the leftmost tab in the tab sheet: "
+ + tabId;
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java
index 8b7890e63c..9031a76e66 100644
--- a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java
+++ b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java
@@ -32,8 +32,7 @@ public class TreeItemDoubleClick extends AbstractTestUIWithLog {
addComponent(tree);
- Button button = new Button("Change immediate flag");
- button.addClickListener(new Button.ClickListener() {
+ addButton("Change immediate flag", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -44,8 +43,6 @@ public class TreeItemDoubleClick extends AbstractTestUIWithLog {
});
- addComponent(button);
-
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java b/uitest/src/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java
new file mode 100644
index 0000000000..37766dd060
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.ui;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.UIElement;
+import com.vaadin.tests.components.button.ButtonClick;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class VaadinFinderLocatorUISearchTest extends MultiBrowserTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return ButtonClick.class;
+ }
+
+ @Test
+ public void getUIElementTest() {
+ openTestURL();
+ UIElement ui = $(UIElement.class).first();
+ Assert.assertNotNull("Couldn't find the UI Element on the page", ui);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java
new file mode 100644
index 0000000000..dcf2ac2784
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java
@@ -0,0 +1,41 @@
+package com.vaadin.tests.components.upload;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Upload;
+
+public class DisabledUploadButton extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Upload upload = new Upload();
+
+ addComponent(upload);
+
+ addButton("Set readonly", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ upload.setReadOnly(true);
+ }
+ });
+
+ addButton("Set disabled", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ upload.setEnabled(false);
+ }
+ });
+ }
+
+ @Override
+ public String getDescription() {
+ return "Upload button should be disabled when upload "
+ + "is set to readonly and/or disabled";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14655;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java
new file mode 100644
index 0000000000..cc97b4d7d1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java
@@ -0,0 +1,55 @@
+package com.vaadin.tests.components.upload;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.UploadElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DisabledUploadButtonTest extends MultiBrowserTest {
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
+ }
+
+ private String getUploadButtonClass() {
+ WebElement uploadButton = getUploadButton();
+
+ return uploadButton.getAttribute("class");
+ }
+
+ private void clickButton(String caption) {
+ $(ButtonElement.class).caption(caption).first().click();
+ }
+
+ private WebElement getUploadButton() {
+ UploadElement upload = $(UploadElement.class).first();
+ return upload.findElement(By.className("v-button"));
+ }
+
+ @Test
+ public void buttonIsReadonly() {
+ assertThat(getUploadButtonClass(), not(containsString("v-disabled")));
+
+ clickButton("Set readonly");
+
+ assertThat(getUploadButtonClass(), containsString("v-disabled"));
+ }
+
+ @Test
+ public void buttonIsDisabled() {
+ assertThat(getUploadButtonClass(), not(containsString("v-disabled")));
+
+ clickButton("Set disabled");
+
+ assertThat(getUploadButtonClass(), containsString("v-disabled"));
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java
new file mode 100644
index 0000000000..48dd96bc43
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.upload;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.VerticalLayout;
+
+// We're explicitly testing only immediate uploads here because non-immediate
+// width issues still require planning before we can provide a fix.
+public class UploadImmediateButtonWidth extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ // Let's use a separate layout without margins to make the
+ // button widths not dependent on the selected theme.
+ VerticalLayout layout = new VerticalLayout();
+ layout.setWidth("500px");
+
+ layout.addComponent(getImmediateUpload("upload1", "300px"));
+ layout.addComponent(getImmediateUpload("upload2", "50%"));
+ layout.addComponent(getImmediateUpload("upload3", ""));
+
+ addComponent(layout);
+ }
+
+ private Upload getImmediateUpload(String id, String width) {
+ Upload upload = new Upload();
+
+ upload.setId(id);
+ upload.setWidth(width);
+ upload.setImmediate(true);
+
+ return upload;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Width of the upload button should obey setWidth() when using immediate";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14485;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthChameleonTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthChameleonTest.java
new file mode 100644
index 0000000000..a0d6d471fb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthChameleonTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.upload;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.closeTo;
+
+import com.vaadin.ui.themes.*;
+import org.junit.Test;
+
+public class UploadImmediateButtonWidthChameleonTest extends
+ UploadImmediateButtonWidthTest {
+
+ @Override
+ protected String getTheme() {
+ return ChameleonTheme.THEME_NAME;
+ }
+
+ @Test
+ public void immediateButtonWithUndefinedWidth() {
+ assertThat(getButtonWidth("upload3"), closeTo(69, 4));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthReindeerTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthReindeerTest.java
new file mode 100644
index 0000000000..c22e416a25
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthReindeerTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.upload;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.closeTo;
+
+import com.vaadin.ui.themes.*;
+import org.junit.Test;
+
+public class UploadImmediateButtonWidthReindeerTest extends
+ UploadImmediateButtonWidthTest {
+
+ @Override
+ protected String getTheme() {
+ return Reindeer.THEME_NAME;
+ }
+
+ @Test
+ public void immediateButtonWithUndefinedWidth() {
+ assertThat(getButtonWidth("upload3"), closeTo(67, 8));
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthRunoTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthRunoTest.java
new file mode 100644
index 0000000000..0ab4fbbc7e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthRunoTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.upload;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.closeTo;
+
+import com.vaadin.ui.themes.*;
+import org.junit.Test;
+
+public class UploadImmediateButtonWidthRunoTest extends
+ UploadImmediateButtonWidthTest {
+
+ @Override
+ protected String getTheme() {
+ return Runo.THEME_NAME;
+ }
+
+ @Test
+ public void immediateButtonWithUndefinedWidth() {
+ assertThat(getButtonWidth("upload3"), closeTo(72, 6));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java
new file mode 100644
index 0000000000..b2a29c92e3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.upload;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public abstract class UploadImmediateButtonWidthTest extends MultiBrowserTest {
+
+ protected abstract String getTheme();
+
+ protected double getButtonWidth(String id) {
+ WebElement upload = driver.findElement(By.id(id));
+ WebElement button = upload.findElement(By.className("v-button"));
+
+ return button.getSize().getWidth();
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return UploadImmediateButtonWidth.class;
+ }
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+
+ openTestURL(String.format("theme=%s", getTheme()));
+ }
+
+ @Test
+ public void immediateButtonWithPixelWidth() {
+ assertThat(getButtonWidth("upload1"), is(300.0));
+ }
+
+ @Test
+ public void immediateButtonWithPercentageWidth() {
+ assertThat(getButtonWidth("upload2"), is(250.0));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthValoTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthValoTest.java
new file mode 100644
index 0000000000..9d8fe6ba9e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthValoTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.upload;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.closeTo;
+
+import com.vaadin.ui.themes.*;
+import org.junit.Test;
+
+public class UploadImmediateButtonWidthValoTest extends
+ UploadImmediateButtonWidthTest {
+
+ @Override
+ protected String getTheme() {
+ return ValoTheme.THEME_NAME;
+ }
+
+ @Test
+ public void immediateButtonWithUndefinedWidth() {
+ assertThat(getButtonWidth("upload3"), closeTo(89, 2));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java
index 73dc39009d..786e47cef1 100644
--- a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java
+++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java
@@ -19,6 +19,7 @@ import java.io.IOException;
import java.util.List;
import org.junit.Test;
+import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -27,7 +28,7 @@ public abstract class BaseAddReplaceMoveTest extends MultiBrowserTest {
@Test
public void LayoutAlignment() throws IOException, InterruptedException {
openTestURL();
- sleep(500);
+ waitForElementPresent(By.className("v-table"));
compareScreen("initial");
String[] states = { "add", "replace", "move", "remove" };
List<ButtonElement> buttons = $(ButtonElement.class).all();
@@ -35,7 +36,7 @@ public abstract class BaseAddReplaceMoveTest extends MultiBrowserTest {
// go through all buttons click them and see result
for (ButtonElement btn : buttons) {
btn.click();
- sleep(500);
+ waitForElementPresent(By.className("v-table"));
compareScreen(states[index]);
index++;
}
diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java
index 08f5aed808..036b053fb5 100644
--- a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java
+++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java
@@ -19,21 +19,17 @@ import java.io.IOException;
import java.util.List;
import org.junit.Test;
+import org.openqa.selenium.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-/**
- *
- * @since
- * @author Vaadin Ltd
- */
public abstract class BaseLayoutExpandTest extends MultiBrowserTest {
@Test
public void LayoutExpand() throws IOException, InterruptedException {
openTestURL();
- sleep(500);
+ waitForElementPresent(By.className("v-table"));
compareScreen("initial");
String[] states = { "expand_100_0", "expand_50_50", "expand_25_75" };
List<ButtonElement> buttons = $(ButtonElement.class).all();
@@ -41,7 +37,7 @@ public abstract class BaseLayoutExpandTest extends MultiBrowserTest {
// go through all buttons click them and see result
for (ButtonElement btn : buttons) {
btn.click();
- sleep(500);
+ waitForElementPresent(By.className("v-table"));
compareScreen(states[index]);
index++;
}
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
index b380edcb75..a5d23dcd1f 100644
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.java
+++ b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
@@ -35,14 +35,12 @@ public class BarInUIDL extends AbstractTestUI {
*/
@Override
protected void setup(VaadinRequest request) {
- Button button = new Button("Click Me");
- button.addClickListener(new Button.ClickListener() {
+ addButton("Click Me", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
addComponent(new Label("Thank you for clicking | bar"));
}
});
- addComponent(button);
}
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java
index 093ee348b8..cd779a7318 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java
@@ -24,6 +24,6 @@ import com.vaadin.tests.tb3.WebsocketTest;
public class BasicPushWebsocketTest extends BasicPushTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
- return WebsocketTest.getWebsocketBrowsers();
+ return getBrowsersSupportingWebSocket();
}
}
diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java
index c0b188bbab..54775d572d 100644
--- a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java
+++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java
@@ -26,6 +26,6 @@ public class ExtremelyLongPushTimeWebsocketTest extends
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
- return WebsocketTest.getWebsocketBrowsers();
+ return getBrowsersSupportingWebSocket();
}
}
diff --git a/uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java b/uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java
index 644dbd7580..7559d22264 100644
--- a/uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java
+++ b/uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java
@@ -30,6 +30,6 @@ public class IdlePushChannelWebsocketTest extends IdlePushChannelTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
- return WebsocketTest.getWebsocketBrowsers();
+ return getBrowsersSupportingWebSocket();
}
}
diff --git a/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java b/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
index 8834a05069..af19f8849f 100644
--- a/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
+++ b/uitest/src/com/vaadin/tests/push/PushWithPreserveOnRefresh.java
@@ -5,7 +5,6 @@ import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
@@ -24,16 +23,13 @@ public class PushWithPreserveOnRefresh extends AbstractTestUI {
addComponent(new Label("UI id: " + getUIId()));
addComponent(log);
- Button b = new Button("click me");
- b.addClickListener(new ClickListener() {
+ addButton("click me", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
log.log("Button has been clicked " + (++times) + " times");
}
});
-
- addComponent(b);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/push/ReconnectWebsocketTest.java b/uitest/src/com/vaadin/tests/push/ReconnectWebsocketTest.java
index efaf5d493e..bad00eba47 100644
--- a/uitest/src/com/vaadin/tests/push/ReconnectWebsocketTest.java
+++ b/uitest/src/com/vaadin/tests/push/ReconnectWebsocketTest.java
@@ -25,7 +25,7 @@ public class ReconnectWebsocketTest extends ReconnectTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
- return WebsocketTest.getWebsocketBrowsers();
+ return getBrowsersSupportingWebSocket();
}
@Override
diff --git a/uitest/src/com/vaadin/tests/push/RefreshCloseConnectionTest.java b/uitest/src/com/vaadin/tests/push/RefreshCloseConnectionTest.java
index ef461ab0da..42babb00d0 100644
--- a/uitest/src/com/vaadin/tests/push/RefreshCloseConnectionTest.java
+++ b/uitest/src/com/vaadin/tests/push/RefreshCloseConnectionTest.java
@@ -42,6 +42,6 @@ public class RefreshCloseConnectionTest extends MultiBrowserTest {
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
- return WebsocketTest.getWebsocketBrowsers();
+ return getBrowsersSupportingWebSocket();
}
}
diff --git a/uitest/src/com/vaadin/tests/push/SendMultibyteCharacters.java b/uitest/src/com/vaadin/tests/push/SendMultibyteCharacters.java
new file mode 100644
index 0000000000..e41f769724
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/SendMultibyteCharacters.java
@@ -0,0 +1,23 @@
+package com.vaadin.tests.push;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.TextArea;
+
+@Push
+public class SendMultibyteCharacters extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TextArea textArea = new TextArea();
+ textArea.setImmediate(true);
+
+ addComponent(textArea);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14674;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersLongPollingTest.java b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersLongPollingTest.java
new file mode 100644
index 0000000000..fd89982253
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersLongPollingTest.java
@@ -0,0 +1,9 @@
+package com.vaadin.tests.push;
+
+public class SendMultibyteCharactersLongPollingTest extends SendMultibyteCharactersTest {
+
+ @Override
+ protected String getTransport() {
+ return "long-polling";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersStreamingTest.java b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersStreamingTest.java
new file mode 100644
index 0000000000..7b9ec38487
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersStreamingTest.java
@@ -0,0 +1,9 @@
+package com.vaadin.tests.push;
+
+public class SendMultibyteCharactersStreamingTest extends SendMultibyteCharactersTest {
+
+ @Override
+ protected String getTransport() {
+ return "streaming";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java
new file mode 100644
index 0000000000..1ced2fb506
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java
@@ -0,0 +1,42 @@
+package com.vaadin.tests.push;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.TextAreaElement;
+import com.vaadin.tests.annotations.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+
+@TestCategory("push")
+public abstract class SendMultibyteCharactersTest extends MultiBrowserTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return SendMultibyteCharacters.class;
+ }
+
+ protected abstract String getTransport();
+
+ @Test
+ public void transportSupportsMultibyteCharacters() {
+ setDebug(true);
+ openTestURL("transport=" + getTransport());
+ openDebugLogTab();
+
+ TextAreaElement textArea = $(TextAreaElement.class).first();
+
+ StringBuilder text = new StringBuilder();
+ for(int i=0;i < 20;i++) {
+ text.append("之は日本語です、テストです。");
+ }
+
+ textArea.sendKeys(text.toString());
+
+ clearDebugMessages();
+
+ findElement(By.tagName("body")).click();
+
+ waitForDebugMessage("Variable burst to be sent to server:", 5);
+ waitForDebugMessage("Handling message from server", 10);
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersWebSocketTest.java b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersWebSocketTest.java
new file mode 100644
index 0000000000..f37fb2efcb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersWebSocketTest.java
@@ -0,0 +1,19 @@
+package com.vaadin.tests.push;
+
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import java.util.List;
+
+public class SendMultibyteCharactersWebSocketTest extends SendMultibyteCharactersTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ return getBrowsersSupportingWebSocket();
+ }
+
+ @Override
+ protected String getTransport() {
+ return "websocket";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java b/uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java
new file mode 100644
index 0000000000..a3bee26675
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java
@@ -0,0 +1,97 @@
+/*
+ * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AffectedTB3TestLocator extends TB3TestLocator {
+
+ private final ChangedTB3TestLocator changedTB3TestLocator;
+
+ public AffectedTB3TestLocator() {
+ changedTB3TestLocator = new ChangedTB3TestLocator();
+ }
+
+ @Override
+ protected <T> List<Class<? extends T>> findClasses(Class<T> baseClass,
+ String basePackage, String[] ignoredPackages) throws IOException {
+ List<Class<? extends T>> allTestClasses = super.findClasses(baseClass,
+ basePackage, ignoredPackages);
+
+ List<Class<? extends T>> changedTestClasses = changedTB3TestLocator
+ .findClasses(baseClass, basePackage, ignoredPackages);
+
+ return getAffectedTestClasses(allTestClasses, changedTestClasses);
+ }
+
+ private <T> List<Class<? extends T>> getAffectedTestClasses(
+ List<Class<? extends T>> allTestClasses,
+ List<Class<? extends T>> changedTestClasses) throws IOException {
+ List<Class<? extends T>> affectedWithPackageTestClasses = getTestClassesWithAffectedPackageName(allTestClasses);
+ List<Class<? extends T>> affectedTestClasses = new ArrayList<Class<? extends T>>();
+ affectedTestClasses.addAll(affectedWithPackageTestClasses);
+
+ // Removing duplicate entries before adding changed test classes.
+ for (Class<? extends T> changedTestClass : changedTestClasses) {
+ for (Class<? extends T> affectedTestClass : affectedWithPackageTestClasses) {
+ if (!changedTestClass.getName().equals(
+ affectedTestClass.getName())) {
+ affectedTestClasses.add(changedTestClass);
+
+ break;
+ }
+ }
+ }
+ return affectedTestClasses;
+ }
+
+ private <T> List<Class<? extends T>> getTestClassesWithAffectedPackageName(
+ List<Class<? extends T>> classes) {
+ List<Class<? extends T>> affectedTestClasses = new ArrayList<Class<? extends T>>();
+ List<String> affectedFiles = getAffectedFiles();
+
+ for (Class c : classes) {
+ String[] packageParts = c.getName().split("\\.");
+ String lastPart = packageParts[packageParts.length - 2];
+
+ for (String f : affectedFiles) {
+ if (f.toLowerCase().contains(lastPart.toLowerCase())) {
+ affectedTestClasses.add(c);
+
+ // Break here not to accidentally add the same test class
+ // multiple times if it matches more than one file.
+ break;
+ }
+ }
+ }
+
+ return affectedTestClasses;
+ }
+
+ private List<String> getAffectedFiles() {
+ List<String> affectedFilePaths = new ArrayList<String>();
+
+ for (String path : changedTB3TestLocator.getChangedFilePaths()) {
+ if (!path.toLowerCase().contains("test")) {
+ affectedFilePaths.add(path);
+ }
+ }
+
+ return affectedFilePaths;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/tb3/AffectedTB3Tests.java b/uitest/src/com/vaadin/tests/tb3/AffectedTB3Tests.java
new file mode 100644
index 0000000000..6736bc3990
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/AffectedTB3Tests.java
@@ -0,0 +1,27 @@
+package com.vaadin.tests.tb3;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.AffectedTB3Tests.AffectedTB3TestSuite;
+
+/**
+ * Test suite that runs tests from test classes which have changes or have
+ * similar package name compare the the changes files in the current workspace.
+ * If there are no changes in the workspace, it will run the changes to test
+ * classes introduced in the HEAD commit.
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(AffectedTB3TestSuite.class)
+public class AffectedTB3Tests {
+
+ public static class AffectedTB3TestSuite extends TB3TestSuite {
+
+ public AffectedTB3TestSuite(Class<?> klass) throws InitializationError {
+ super(klass, AbstractTB3Test.class, "com.vaadin.tests",
+ new String[] { "com.vaadin.tests.integration" },
+ new AffectedTB3TestLocator());
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java b/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java
new file mode 100644
index 0000000000..b425de48b5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java
@@ -0,0 +1,158 @@
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jgit.api.DiffCommand;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.diff.DiffEntry;
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;
+import org.eclipse.jgit.diff.DiffFormatter;
+import org.eclipse.jgit.diff.RawTextComparator;
+import org.eclipse.jgit.errors.AmbiguousObjectException;
+import org.eclipse.jgit.errors.IncorrectObjectTypeException;
+import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.io.DisabledOutputStream;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class ChangedTB3TestLocator extends TB3TestLocator {
+
+ @Override
+ protected <T> List<Class<? extends T>> findClasses(Class<T> baseClass,
+ String basePackage, String[] ignoredPackages) throws IOException {
+
+ return getChangedTestClasses(baseClass);
+ }
+
+ protected List<String> getChangedFilePaths() {
+ List<String> filePaths = new ArrayList<String>();
+
+ for (DiffEntry diff : getDiffs()) {
+ if (diff.getChangeType() != ChangeType.DELETE) {
+ filePaths.add(diff.getNewPath());
+ System.out.println("Using changed file: " + diff.getNewPath());
+ }
+ }
+
+ return filePaths;
+ }
+
+ private List<DiffEntry> getDiffs() {
+ try {
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
+ Repository repository = builder.setWorkTree(new File("."))
+ .readEnvironment() // scan environment GIT_* variables
+ .findGitDir() // scan up the file system tree
+ .build();
+
+ List<DiffEntry> diffsInWorkingTree = getDiffsInWorkingTree(repository);
+
+ if (diffsInWorkingTree.isEmpty()) {
+ return getDiffsInHead(repository);
+ }
+
+ return diffsInWorkingTree;
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (NoWorkTreeException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (GitAPIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private List<DiffEntry> getDiffsInWorkingTree(Repository repository)
+ throws GitAPIException {
+ Git git = new Git(repository);
+ DiffCommand diffCommand = git.diff();
+
+ List<DiffEntry> diffsInWorkingTree = new ArrayList<DiffEntry>();
+
+ for (DiffEntry diff : diffCommand.call()) {
+ // Exclude temporary junit files.
+ if (!diff.getNewPath().startsWith("uitest/junit")) {
+ diffsInWorkingTree.add(diff);
+ }
+ }
+
+ return diffsInWorkingTree;
+ }
+
+ private List<DiffEntry> getDiffsInHead(Repository repository)
+ throws AmbiguousObjectException, IncorrectObjectTypeException,
+ IOException, MissingObjectException {
+ RevWalk rw = new RevWalk(repository);
+ ObjectId head = repository.resolve(Constants.HEAD);
+ RevCommit commit = rw.parseCommit(head);
+ RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
+ DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
+ df.setRepository(repository);
+ df.setDiffComparator(RawTextComparator.DEFAULT);
+ df.setDetectRenames(true);
+ List<DiffEntry> diffs = df.scan(parent.getTree(), commit.getTree());
+
+ return diffs;
+ }
+
+ private <T> List<Class<? extends T>> getChangedTestClasses(
+ Class<T> baseClass) {
+ List<String> changedTestFilePaths = getTestFilePaths();
+ List<Class<? extends T>> testClasses = new ArrayList<Class<? extends T>>();
+
+ for (String filePath : changedTestFilePaths) {
+ String path = filePath.replace("uitest/src/", "").replace(".java",
+ "");
+ String className = path.replace("/", ".");
+ addClassIfMatches(testClasses, className, baseClass);
+ }
+
+ return testClasses;
+ }
+
+ private List<String> getTestFilePaths() {
+ List<String> changedTestFilePaths = new ArrayList<String>();
+
+ for (String filePath : getChangedFilePaths()) {
+ if (filePath.toLowerCase().startsWith("uitest")
+ && filePath.toLowerCase().endsWith(".java")) {
+ changedTestFilePaths.add(filePath);
+ }
+ }
+
+ return changedTestFilePaths;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/ChangedTB3Tests.java b/uitest/src/com/vaadin/tests/tb3/ChangedTB3Tests.java
new file mode 100644
index 0000000000..2200566b84
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/ChangedTB3Tests.java
@@ -0,0 +1,41 @@
+/*
+ * 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.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.ChangedTB3Tests.ChangedTB3TestsSuite;
+
+/**
+ * Test suite that runs tests from test classes which have changes in the
+ * current workspace. If there are no changes in the workspace, it will run the
+ * changes to test classes introduced in the HEAD commit.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+@RunWith(ChangedTB3TestsSuite.class)
+public class ChangedTB3Tests {
+ public static class ChangedTB3TestsSuite extends TB3TestSuite {
+ public ChangedTB3TestsSuite(Class<?> klass) throws InitializationError {
+ super(klass, AbstractTB3Test.class, "com.vaadin.tests",
+ new String[] { "com.vaadin.tests.integration" },
+ new ChangedTB3TestLocator());
+
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
index d6eed3e5c8..ebcb02002e 100644
--- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
+++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
@@ -40,6 +40,16 @@ import org.openqa.selenium.remote.DesiredCapabilities;
*/
public abstract class MultiBrowserTest extends PrivateTB3Configuration {
+ protected List<DesiredCapabilities> getBrowsersSupportingWebSocket() {
+ List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(getAllBrowsers());
+
+ browsers.remove(Browser.IE8.getDesiredCapabilities());
+ browsers.remove(Browser.IE9.getDesiredCapabilities());
+ browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());
+
+ return browsers;
+ }
+
protected List<DesiredCapabilities> getBrowsersExcludingPhantomJS() {
List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(getAllBrowsers());
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java b/uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java
new file mode 100644
index 0000000000..a0fbf51195
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java
@@ -0,0 +1,218 @@
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.net.JarURLConnection;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+
+public class TB3TestLocator {
+ /**
+ * Traverses the directory on the classpath (inside or outside a Jar file)
+ * specified by 'basePackage'. Collects all classes inside the location
+ * which can be assigned to 'baseClass' except for classes inside packages
+ * listed in 'ignoredPackages'.
+ *
+ * @param baseClass
+ * @param basePackage
+ * @param ignorePackages
+ * @return
+ */
+ public Class<?>[] findTests(Class<? extends AbstractTB3Test> baseClass,
+ String basePackage, String[] ignorePackages) {
+ try {
+ List<?> l = findClasses(baseClass, basePackage, ignorePackages);
+ return l.toArray(new Class[] {});
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Traverses the directory on the classpath (inside or outside a Jar file)
+ * specified by 'basePackage'. Collects all classes inside the location
+ * which can be assigned to 'baseClass' except for classes inside packages
+ * listed in 'ignoredPackages'.
+ *
+ * @param baseClass
+ * @param basePackage
+ * @param ignoredPackages
+ * @return
+ * @throws IOException
+ */
+ protected <T> List<Class<? extends T>> findClasses(Class<T> baseClass,
+ String basePackage, String[] ignoredPackages) throws IOException {
+ List<Class<? extends T>> classes = new ArrayList<Class<? extends T>>();
+ String basePackageDirName = "/" + basePackage.replace('.', '/');
+ URL location = baseClass.getResource(basePackageDirName);
+ if (location.getProtocol().equals("file")) {
+ try {
+ File f = new File(location.toURI());
+ if (!f.exists()) {
+ throw new IOException("Directory " + f.toString()
+ + " does not exist");
+ }
+ findPackages(f, basePackage, baseClass, classes,
+ ignoredPackages);
+ } catch (URISyntaxException e) {
+ throw new IOException(e.getMessage());
+ }
+ } else if (location.getProtocol().equals("jar")) {
+ JarURLConnection juc = (JarURLConnection) location.openConnection();
+ findClassesInJar(juc, basePackage, baseClass, classes);
+ }
+
+ Collections.sort(classes, new Comparator<Class<? extends T>>() {
+
+ @Override
+ public int compare(Class<? extends T> o1, Class<? extends T> o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+
+ });
+
+ return classes;
+ }
+
+ /**
+ * Traverses the given directory and collects all classes which are inside
+ * the given 'javaPackage' and can be assigned to the given 'baseClass'. The
+ * found classes are added to 'result'.
+ *
+ * @param parent
+ * The directory to traverse
+ * @param javaPackage
+ * The java package which 'parent' contains
+ * @param baseClass
+ * The class which the target classes extend
+ * @param result
+ * The collection to which found classes are added
+ * @param ignoredPackages
+ * A collection of packages (including sub packages) to ignore
+ */
+ private <T> void findPackages(File parent, String javaPackage,
+ Class<T> baseClass, Collection<Class<? extends T>> result,
+ String[] ignoredPackages) {
+ for (String ignoredPackage : ignoredPackages) {
+ if (javaPackage.equals(ignoredPackage)) {
+ return;
+ }
+ }
+
+ for (File file : parent.listFiles()) {
+ if (file.isDirectory()) {
+ findPackages(file, javaPackage + "." + file.getName(),
+ baseClass, result, ignoredPackages);
+ } else if (file.getName().endsWith(".class")) {
+ String fullyQualifiedClassName = javaPackage + "."
+ + file.getName().replace(".class", "");
+ addClassIfMatches(result, fullyQualifiedClassName, baseClass);
+ }
+ }
+
+ }
+
+ /**
+ * Traverses a Jar file using the given connection and collects all classes
+ * which are inside the given 'javaPackage' and can be assigned to the given
+ * 'baseClass'. The found classes are added to 'result'.
+ *
+ * @param javaPackage
+ * The java package containing the classes (classes may be in a
+ * sub package)
+ * @param baseClass
+ * The class which the target classes extend
+ * @param result
+ * The collection to which found classes are added
+ * @throws IOException
+ */
+ private <T> void findClassesInJar(JarURLConnection juc, String javaPackage,
+ Class<T> baseClass, Collection<Class<? extends T>> result)
+ throws IOException {
+ String javaPackageDir = javaPackage.replace('.', '/');
+ Enumeration<JarEntry> ent = juc.getJarFile().entries();
+ while (ent.hasMoreElements()) {
+ JarEntry e = ent.nextElement();
+ if (e.getName().endsWith(".class")
+ && e.getName().startsWith(javaPackageDir)) {
+ String fullyQualifiedClassName = e.getName().replace('/', '.')
+ .replace(".class", "");
+ addClassIfMatches(result, fullyQualifiedClassName, baseClass);
+ }
+ }
+ }
+
+ /**
+ * Verifies that the class represented by 'fullyQualifiedClassName' can be
+ * loaded, assigned to 'baseClass' and is not an abstract or anonymous
+ * class.
+ *
+ * @param result
+ * The collection to add to
+ * @param fullyQualifiedClassName
+ * The candidate class
+ * @param baseClass
+ * The class 'fullyQualifiedClassName' should be assignable to
+ */
+ @SuppressWarnings("unchecked")
+ protected <T> void addClassIfMatches(Collection<Class<? extends T>> result,
+ String fullyQualifiedClassName, Class<T> baseClass) {
+ try {
+ // Try to load the class
+
+ Class<?> c = Class.forName(fullyQualifiedClassName);
+ if (!baseClass.isAssignableFrom(c)) {
+ return;
+ }
+ if (!includeInSuite(c)) {
+ return;
+ }
+
+ if (!Modifier.isAbstract(c.getModifiers()) && !c.isAnonymousClass()) {
+ result.add((Class<? extends T>) c);
+ }
+ } catch (Exception e) {
+ // Could ignore that class cannot be loaded
+ e.printStackTrace();
+ } catch (LinkageError e) {
+ // Ignore. Client side classes will at least throw LinkageErrors
+ }
+
+ }
+
+ /**
+ * @return true if the class should be included in the suite, false if not
+ */
+ private boolean includeInSuite(Class<?> c) {
+ if (c.getAnnotation(ExcludeFromSuite.class) != null) {
+ return false;
+ }
+
+ return true;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
index 703d01c122..b0554ce0f6 100644
--- a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
+++ b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
@@ -16,21 +16,8 @@
package com.vaadin.tests.tb3;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Modifier;
-import java.net.JarURLConnection;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.jar.JarEntry;
import org.junit.runners.Suite;
import org.junit.runners.model.InitializationError;
@@ -59,194 +46,16 @@ public class TB3TestSuite extends Suite {
public TB3TestSuite(Class<?> klass,
Class<? extends AbstractTB3Test> baseClass, String basePackage,
String[] ignorePackages) throws InitializationError {
- super(klass, findTests(baseClass, basePackage, ignorePackages));
- setScheduler(new ParallelScheduler(service));
+ this(klass, baseClass, basePackage, ignorePackages,
+ new TB3TestLocator());
}
- /**
- * Traverses the directory on the classpath (inside or outside a Jar file)
- * specified by 'basePackage'. Collects all classes inside the location
- * which can be assigned to 'baseClass' except for classes inside packages
- * listed in 'ignoredPackages'.
- *
- * @param baseClass
- * @param basePackage
- * @param ignorePackages
- * @return
- */
- private static Class<?>[] findTests(
+ public TB3TestSuite(Class<?> klass,
Class<? extends AbstractTB3Test> baseClass, String basePackage,
- String[] ignorePackages) {
- try {
- List<?> l = findClasses(baseClass, basePackage, ignorePackages);
- return l.toArray(new Class[] {});
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * Traverses the directory on the classpath (inside or outside a Jar file)
- * specified by 'basePackage'. Collects all classes inside the location
- * which can be assigned to 'baseClass' except for classes inside packages
- * listed in 'ignoredPackages'.
- *
- * @param baseClass
- * @param basePackage
- * @param ignoredPackages
- * @return
- * @throws IOException
- */
- private static <T> List<Class<? extends T>> findClasses(Class<T> baseClass,
- String basePackage, String[] ignoredPackages) throws IOException {
- List<Class<? extends T>> classes = new ArrayList<Class<? extends T>>();
- String basePackageDirName = "/" + basePackage.replace('.', '/');
- URL location = baseClass.getResource(basePackageDirName);
- if (location.getProtocol().equals("file")) {
- try {
- File f = new File(location.toURI());
- if (!f.exists()) {
- throw new IOException("Directory " + f.toString()
- + " does not exist");
- }
- findPackages(f, basePackage, baseClass, classes,
- ignoredPackages);
- } catch (URISyntaxException e) {
- throw new IOException(e.getMessage());
- }
- } else if (location.getProtocol().equals("jar")) {
- JarURLConnection juc = (JarURLConnection) location.openConnection();
- findClassesInJar(juc, basePackage, baseClass, classes);
- }
-
- Collections.sort(classes, new Comparator<Class<? extends T>>() {
-
- @Override
- public int compare(Class<? extends T> o1, Class<? extends T> o2) {
- return o1.getName().compareTo(o2.getName());
- }
-
- });
- return classes;
- }
-
- /**
- * Traverses the given directory and collects all classes which are inside
- * the given 'javaPackage' and can be assigned to the given 'baseClass'. The
- * found classes are added to 'result'.
- *
- * @param parent
- * The directory to traverse
- * @param javaPackage
- * The java package which 'parent' contains
- * @param baseClass
- * The class which the target classes extend
- * @param result
- * The collection to which found classes are added
- * @param ignoredPackages
- * A collection of packages (including sub packages) to ignore
- */
- private static <T> void findPackages(File parent, String javaPackage,
- Class<T> baseClass, Collection<Class<? extends T>> result,
- String[] ignoredPackages) {
- for (String ignoredPackage : ignoredPackages) {
- if (javaPackage.equals(ignoredPackage)) {
- return;
- }
- }
-
- for (File file : parent.listFiles()) {
- if (file.isDirectory()) {
- findPackages(file, javaPackage + "." + file.getName(),
- baseClass, result, ignoredPackages);
- } else if (file.getName().endsWith(".class")) {
- String fullyQualifiedClassName = javaPackage + "."
- + file.getName().replace(".class", "");
- addClassIfMatches(result, fullyQualifiedClassName, baseClass);
- }
- }
-
- }
-
- /**
- * Traverses a Jar file using the given connection and collects all classes
- * which are inside the given 'javaPackage' and can be assigned to the given
- * 'baseClass'. The found classes are added to 'result'.
- *
- * @param javaPackage
- * The java package containing the classes (classes may be in a
- * sub package)
- * @param baseClass
- * The class which the target classes extend
- * @param result
- * The collection to which found classes are added
- * @throws IOException
- */
- private static <T> void findClassesInJar(JarURLConnection juc,
- String javaPackage, Class<T> baseClass,
- Collection<Class<? extends T>> result) throws IOException {
- String javaPackageDir = javaPackage.replace('.', '/');
- Enumeration<JarEntry> ent = juc.getJarFile().entries();
- while (ent.hasMoreElements()) {
- JarEntry e = ent.nextElement();
- if (e.getName().endsWith(".class")
- && e.getName().startsWith(javaPackageDir)) {
- String fullyQualifiedClassName = e.getName().replace('/', '.')
- .replace(".class", "");
- addClassIfMatches(result, fullyQualifiedClassName, baseClass);
- }
- }
- }
-
- /**
- * Verifies that the class represented by 'fullyQualifiedClassName' can be
- * loaded, assigned to 'baseClass' and is not an abstract or anonymous
- * class.
- *
- * @param result
- * The collection to add to
- * @param fullyQualifiedClassName
- * The candidate class
- * @param baseClass
- * The class 'fullyQualifiedClassName' should be assignable to
- */
- @SuppressWarnings("unchecked")
- private static <T> void addClassIfMatches(
- Collection<Class<? extends T>> result,
- String fullyQualifiedClassName, Class<T> baseClass) {
- try {
- // Try to load the class
-
- Class<?> c = Class.forName(fullyQualifiedClassName);
- if (!baseClass.isAssignableFrom(c)) {
- return;
- }
- if (!includeInSuite(c)) {
- return;
- }
-
- if (!Modifier.isAbstract(c.getModifiers()) && !c.isAnonymousClass()) {
- result.add((Class<? extends T>) c);
- }
- } catch (Exception e) {
- // Could ignore that class cannot be loaded
- e.printStackTrace();
- } catch (LinkageError e) {
- // Ignore. Client side classes will at least throw LinkageErrors
- }
-
- }
-
- /**
- * @return true if the class should be included in the suite, false if not
- */
- private static boolean includeInSuite(Class<?> c) {
- if (c.getAnnotation(ExcludeFromSuite.class) != null) {
- return false;
- }
-
- return true;
+ String[] ignorePackages, TB3TestLocator testLocator)
+ throws InitializationError {
+ super(klass, testLocator.findTests(baseClass, basePackage,
+ ignorePackages));
+ setScheduler(new ParallelScheduler(service));
}
}
diff --git a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java
index 778c8b9113..ddcc6d5d76 100644
--- a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java
+++ b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java
@@ -35,30 +35,10 @@ import com.vaadin.tests.tb3.MultiBrowserTest.Browser;
* @author Vaadin Ltd
*/
@TestCategory("push")
-public abstract class WebsocketTest extends PrivateTB3Configuration {
- private static List<DesiredCapabilities> websocketBrowsers = new ArrayList<DesiredCapabilities>();
- static {
- websocketBrowsers.addAll(MultiBrowserTest.getAllBrowsers());
- websocketBrowsers.remove(Browser.IE8.getDesiredCapabilities());
- websocketBrowsers.remove(Browser.IE9.getDesiredCapabilities());
- websocketBrowsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());
- }
-
- /**
- * @return All supported browsers which are actively tested and support
- * websockets
- */
- public static List<DesiredCapabilities> getWebsocketBrowsers() {
- return Collections.unmodifiableList(websocketBrowsers);
- }
+public abstract class WebsocketTest extends MultiBrowserTest {
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.AbstractTB3Test#getBrowserToRunOn()
- */
@Override
public List<DesiredCapabilities> getBrowsersToTest() {
- return new ArrayList<DesiredCapabilities>(getWebsocketBrowsers());
+ return new ArrayList<DesiredCapabilities>(getBrowsersSupportingWebSocket());
}
}
diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java
index ec22edd205..0ea5c18bc9 100644
--- a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java
+++ b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java
@@ -36,8 +36,7 @@ public class ThemeChangeOnTheFly extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
- Button inject = new Button("Inject blue background");
- inject.addClickListener(new ClickListener() {
+ addButton("Inject blue background", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -46,7 +45,6 @@ public class ThemeChangeOnTheFly extends AbstractTestUIWithLog {
}
});
- addComponent(inject);
GridLayout gl = new GridLayout(2, 4);
gl.setCaption("Change theme by clicking a button");
diff --git a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java
index 5a752cd985..4b29f83621 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java
@@ -203,6 +203,7 @@ public class DateFields extends VerticalLayout implements View {
item.addItemProperty("date", new ObjectProperty<Date>(getDefaultDate()));
FormLayout form = new FormLayout();
+ form.setMargin(false);
FieldGroup binder = new FieldGroup(item);
form.addComponent(binder.buildAndBind(
diff --git a/uitest/src/com/vaadin/tests/themes/valo/TableSortIndicator.java b/uitest/src/com/vaadin/tests/themes/valo/TableSortIndicator.java
new file mode 100644
index 0000000000..74e5fcd0ef
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/themes/valo/TableSortIndicator.java
@@ -0,0 +1,34 @@
+package com.vaadin.tests.themes.valo;
+
+import com.vaadin.annotations.*;
+import com.vaadin.server.*;
+import com.vaadin.tests.components.*;
+import com.vaadin.ui.*;
+
+@Theme("valo")
+public class TableSortIndicator extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ Table table = new Table();
+ table.addContainerProperty("Index", Integer.class, "");
+
+ for(int i=0;i<10;i++) {
+ table.addItem(new Object[] {i}, i);
+ }
+
+ table.setPageLength(0);
+
+ addComponent(table);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "For Valo, sorting indicators should point up when sorted asc " +
+ "and down when sorted desc.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 15123;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/themes/valo/TableSortIndicatorTest.java b/uitest/src/com/vaadin/tests/themes/valo/TableSortIndicatorTest.java
new file mode 100644
index 0000000000..42f0b2aeae
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/themes/valo/TableSortIndicatorTest.java
@@ -0,0 +1,46 @@
+package com.vaadin.tests.themes.valo;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.*;
+import org.junit.*;
+import org.openqa.selenium.*;
+
+import java.io.*;
+
+public class TableSortIndicatorTest extends MultiBrowserTest {
+
+ private void clickOnCellHeader() {
+ clickElementByClass("v-table-header-cell");
+ }
+
+ @Test
+ public void ascendingIndicatorIsShown() throws IOException {
+ openTestURL();
+
+ clickOnCellHeader();
+
+ compareScreen("ascending");
+ }
+
+ @Test
+ public void descendingIndicatorIsShown() throws IOException {
+ openTestURL();
+
+ clickOnCellHeader();
+ clickOnSortIndicator();
+
+ compareScreen("descending");
+ }
+
+ private void clickOnSortIndicator() {
+ clickElementByClass("v-table-sort-indicator");
+ }
+
+ private void clickElementByClass(String className) {
+ findElementByClass(className).click();
+ }
+
+ private WebElement findElementByClass(String className) {
+ return driver.findElement(By.className(className));
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
index d4ddf2dcf9..92cb837b38 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
@@ -133,6 +133,15 @@ public class ValoThemeUITest extends MultiBrowserTest {
}
@Test
+ public void treeTables() throws Exception {
+ openTestURL("test");
+ open("Tables");
+ check("Hierarchical");
+ check("Footer");
+ compareScreen("treetables");
+ }
+
+ @Test
public void dragging() throws Exception {
openTestURL("test");
open("Drag and Drop", "Dragging Components");
@@ -172,6 +181,17 @@ public class ValoThemeUITest extends MultiBrowserTest {
}
@Test
+ public void tabsClosableUnframed() throws Exception {
+ openTestURL("test");
+ open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
+ check("Closable");
+ // Framed option is checked by default so we are actually unchecking
+ check("Framed");
+ check("Overflow");
+ compareScreen("tabs-closable-unframed");
+ }
+
+ @Test
public void tabsAlignRight() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
diff --git a/uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdating.java b/uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdating.java
new file mode 100644
index 0000000000..c5e49d1af3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdating.java
@@ -0,0 +1,69 @@
+package com.vaadin.tests.tooltip;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.util.LoremIpsum;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * Test to see if the width of the tooltip element is updated if a narrower
+ * tooltip is opened to replace a tooltip with wider content.
+ *
+ * @author Vaadin Ltd
+ */
+public class TooltipWidthUpdating extends AbstractTestUI {
+
+ private static final long serialVersionUID = 1L;
+ protected static final String SHORT_TOOLTIP_TEXT = "This is a short tooltip";
+ protected static final String LONG_TOOLTIP_TEXT = LoremIpsum.get(5000);
+ protected static final Integer MAX_WIDTH = 500;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ NativeButton componentWithShortTooltip = new NativeButton(
+ "Short tooltip");
+ componentWithShortTooltip.setDescription(SHORT_TOOLTIP_TEXT);
+ componentWithShortTooltip.setId("shortTooltip");
+
+ getTooltipConfiguration().setMaxWidth(MAX_WIDTH);
+ getTooltipConfiguration().setCloseTimeout(200);
+
+ NativeButton componentWithLongTooltip = new NativeButton("Long tooltip");
+ componentWithLongTooltip.setId("longTooltip");
+ componentWithLongTooltip.setDescription(LONG_TOOLTIP_TEXT);
+
+ VerticalLayout vl = new VerticalLayout();
+
+ TextField component1 = new TextField("TextField");
+ component1.setId("component1");
+ TextField component2 = new TextField("TextField");
+ TextField component3 = new TextField("TextField");
+ TextField component4 = new TextField("TextField");
+ TextField component5 = new TextField("TextField");
+ TextField component6 = new TextField("TextField");
+ TextField component7 = new TextField("TextField");
+ TextField component8 = new TextField("TextField");
+
+ // some count of any components should be added before (between) buttons
+ // to make defect reproducible
+ vl.addComponents(component1, component2, component2, component3,
+ component4, component5, component5, component6, component7,
+ component8);
+
+ getLayout().addComponents(componentWithShortTooltip, vl,
+ componentWithLongTooltip);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Tests that tooltip element width is updated if a narrower tooltip is opened to replace a tooltip with wider content";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11871;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdatingTest.java b/uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdatingTest.java
new file mode 100644
index 0000000000..150d0e070e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tooltip/TooltipWidthUpdatingTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 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.tooltip;
+
+import static org.hamcrest.Matchers.lessThan;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.TooltipTest;
+
+public class TooltipWidthUpdatingTest extends TooltipTest {
+
+ @Test
+ public void testTooltipWidthUpdating() {
+ openTestURL();
+
+ WebElement btnLongTooltip = vaadinElementById("longTooltip");
+ WebElement btnShortTooltip = vaadinElementById("shortTooltip");
+
+ moveMouseToTopLeft(btnLongTooltip);
+ testBenchElement(btnLongTooltip).showTooltip();
+
+ moveMouseToTopLeft(btnShortTooltip);
+ testBenchElement(btnShortTooltip).showTooltip();
+
+ assertThat(getDriver().findElement(By.className("popupContent"))
+ .getSize().getWidth(), lessThan(TooltipWidthUpdating.MAX_WIDTH));
+ }
+
+} \ No newline at end of file