diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-06-07 14:12:41 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-06-07 14:12:41 +0300 |
commit | 808b65581554dad8b670538b1830a8f90b3db5db (patch) | |
tree | f2323317e420e7c76b17994660cdbbd0f78145b4 /uitest/src/com | |
parent | fe8d330c3c9f2ae2c0ace28fa5c34e5b2b131112 (diff) | |
parent | b0574f7b33c4d3d437c8c11cd53389e5522f6999 (diff) | |
download | vaadin-framework-808b65581554dad8b670538b1830a8f90b3db5db.tar.gz vaadin-framework-808b65581554dad8b670538b1830a8f90b3db5db.zip |
Merge changes from origin/7.1
2772641 OSGi support for vaadin-push (#11691)
42c4b20 Use "\0" instead of "|" as a push message delimiter (#11692)
778de06 Derive current servlet/portlet from the current service (#11779)
f8fb8b7 Upgrade to Atmosphere 1.0.13 (#11861)
fea4c5e Don't build and publish sources for package without source files
6a7683b Disable Atmosphere version number check (#11890)
ebb92e6 Improve error message if vaadinPush.js failed to load (#11673)
70131cd Extracted common code for number conveters to abstract super class (#11900)
0b63506 Fixed order of parameters in javadoc (#11158)
6bf83a4 Modified the logic in setPropertyDatasource which determines if a new converter is needed (#11863)
53a9c11 Fix TestingPushConnection.init signature (#11673)
05ef43f Updated client-compiler to depend on client-compiler-deps 1.0.2 #11879
9686323 Added isInitialStateChange to StateChangeEvent (#10477)
7cced5e Fixed test which had never passed
ada3311 Avoid creating an instance of every view while searching for the correct view (#11722)
5b35dd9 Added text file encoding and line delimiter info (#11907)
f8c4f99 Prevent spurious "Could not determine ApplicationConnection" error when using the debug window
8a42394 Fixed locators in test (aria div conflict)
6de01ac Fix text / javascript mismatch issue in Chrome (#11275)
f7f1e3e Added Java Date to Sql Date converter to better support sql dates (#11224)
2882cf9 Added Serializable where missing and ignore classes which do not need Serializable
4d7f190 Make access() enqueue the runnable if the session is locked (#11897)
4c2b86d Stop using PlaceHolder widgets in VTabsheet (#11026)
87018cd Add missing license header
cb1f63b Send window mode changes to the server immediately (#11737)
e52df7c Added ComponentConnector.isAttached (#11928)
2b5ba96 Define how CurrentInstance works with access() (#11897)
d345838 Remove ThreadLocal references from CurrentInstance (#11914)
bb7b404 Remove outdated testing (#11897)
f64d944 Merge "event not reported as target when context clicking in month view" to Vaadin 7.1 (#10217)
51c9fb5 Fix debug window SEVERE style, add styles for FINE, FINER and FINEST (#11891)
3b888fe Support nested SASS imports (#11909)
b2137f5 Ensure calendar panel is updated when range changes (#11940)
f8319eb Avoid deadlock checking in runPendingAccessTasks() (#11897)
51a98a3 Moved enums to avoid running them as tests
7c613d1 Exclude parsers from checkstyle as they are generated
35f3532 Fixes current text being overwritten in server update on RTA #11741
a744d21 Remove UI.runSafely and VaadinSession.runSafely (#11901)
84edd19 Make test independent of browser language (#11940)
a3ad62d Updated to custom build of Smartsprites 0.2.10 which includes a fix for SMARTSPRITES-36 (#9959)
a9afca6 Moved Locale data handling to LocaleService (#11378)
5e548ae Fixed javadoc compilation error
91182e2 Extract ProgressBar and deprecate ProgressIndicator (#11925)
a5b8209 Add primary style name support for ProgressBar/Indicator (#9913)
86b3689 Make ProgressInidcatorConnector use VProgressIndicator (#11925)
29fcadc Flush the output writer in case of SSE transport as well (#11955)
5e26b0b Fix streaming issue with iOS6 (#11934)
1b274c4 Limit sub window minimum size (#11510)
46cc08b Remove workarounds for broken Timer.cancel in IE (#11872)
d850db6 Add XML formatting instructions (#11956)
9a3dc4e Formatted XML files using defined rules (#11956)
57b7335 Fixed spelling mistake in API #11741
587e10b Fix stale info in javadoc for accessSynchronously (#11897)
36fd94a Remove IE6/IE7 permutation (#11954)
cccff37 Do not log legacy warnings in JUnit tests (#11963)
0f9b689 Throw exception if VaadinService has not been initialized (#11961)
1ed0980 Move ApplicationConnection.setOverlayContainerLabel to VOverlay (#11965)
0014563 Extracted dialog style to a separate block (#11734)
b82e60b Add missing dialog maximize/restore icons for Runo (#11734)
0d046d6 Add a separate debug window section for profiler output (#11950)
03830ae Ignore style resource that has already been added (#11667)
84bf5a7 Enabled drag & drop to Calendar #11048
6c36784 Merge commit '34e6c60a5a746c0306c3a84ae8d6c21dfd84d878' into 7.1
a82d57e Merge changes from origin/7.0
666dbb5 Use window.console instead of just console in vaadinPush to appease IE (#11980)
93751c1 Use correct day names when formatting dates (#6207)
19d0082 Fixed javadoc references
e6e752d Correctly decode summaries containing quotes (#11769)
54ed269 Log stack trace using fine when logging toString warnings
8d655f6 Move VaadinSession.runPendingAccessTasks to VaadinService (#11964)
b1ab27a Update broadcaster tutorial code
e63edcc Update deprecation javadoc for VaadinSession.getBrowser()
132eee5 Add @VaadinServletConfiguration (#11970)
aa99259 Send connector debug (highlight) using RPC (#11536)
6d4582e Change analyze layouts to use RPC (#11536)
6f912b1 Rename tests so they are run during build (Abstract* is ignored)
ebd4a5c Added missing rpc interface (#11536)
edca409 Allow customizing client-side push config on server side (#11867)
b0574f7 Add transport parameter to @Push (#11966)
Change-Id: I4670c783fec829f81890e2d645d93dd40860b909
Diffstat (limited to 'uitest/src/com')
37 files changed, 2195 insertions, 66 deletions
diff --git a/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java b/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java index bec8c0a10f..c88f482a7b 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java @@ -119,7 +119,7 @@ public class CloseUI extends AbstractTestUI { @Override public void run() { - ui.access(new Runnable() { + ui.accessSynchronously(new Runnable() { @Override public void run() { diff --git a/uitest/src/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java b/uitest/src/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java index ddc0f28664..c9af2c000d 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/UIRunSafelyThread.java @@ -11,7 +11,7 @@ public abstract class UIRunSafelyThread extends Thread { @Override public void run() { - ui.access(new Runnable() { + ui.accessSynchronously(new Runnable() { @Override public void run() { diff --git a/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java b/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java index 81ec4a9da4..8666956bdb 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java +++ b/uitest/src/com/vaadin/tests/components/AbstractComponentTestCase.java @@ -226,6 +226,13 @@ public abstract class AbstractComponentTestCase<T extends AbstractComponent> } }; + protected Command<T, String> primaryStyleNameCommand = new Command<T, String>() { + @Override + public void execute(T c, String value, Object data) { + c.setPrimaryStyleName(value); + } + }; + @Override protected String getDescription() { return "Generic test case for " + getTestClass().getSimpleName(); diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.html new file mode 100644 index 0000000000..425f95c529 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.html @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:7171/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.calendar.CalendarDragAndDrop?restartApplication</td> + <td></td> +</tr> +<!--// Test drag and drop in month view--> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]/domChild[0]/domChild[0]</td> + <td>76,7</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[5]/domChild[0]/domChild[2]</td> + <td>54,9</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[5]/domChild[0]/domChild[1]</td> + <td>12:00 AM Event 10</td> +</tr> +<!--//Test drag and drop in week view--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]</td> + <td>7,85</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[11]/domChild[0]/domChild[0]</td> + <td>34,12</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[15]</td> + <td>75,9</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarDragAndDrop::PID_SCalendar/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]</td> + <td>7:30 AM: Event 13</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java new file mode 100644 index 0000000000..7477fc84ce --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java @@ -0,0 +1,123 @@ +/* + * 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.calendar; + +import java.util.GregorianCalendar; +import java.util.Locale; + +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +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.Table; +import com.vaadin.ui.Table.TableDragMode; +import com.vaadin.ui.Table.TableTransferable; +import com.vaadin.ui.components.calendar.CalendarTargetDetails; +import com.vaadin.ui.components.calendar.event.BasicEvent; + +public class CalendarDragAndDrop extends AbstractTestUI { + + private Calendar calendar; + + private Table table; + + private class TestDropHandler implements DropHandler { + + @Override + public void drop(DragAndDropEvent event) { + CalendarTargetDetails details = (CalendarTargetDetails) event + .getTargetDetails(); + + TableTransferable transferable = (TableTransferable) event + .getTransferable(); + + calendar.addEvent(new BasicEvent(transferable.getItemId() + .toString(), "This event was dragged here", details + .getDropTime())); + + table.removeItem(transferable.getItemId()); + } + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + } + + @Override + protected void setup(VaadinRequest request) { + setSizeFull(); + getContent().setSizeFull(); + getLayout().setSizeFull(); + + HorizontalLayout root = new HorizontalLayout(); + root.setSizeFull(); + addComponent(root); + + Locale locale = new Locale("en", "US"); + GregorianCalendar cal = new GregorianCalendar(locale); + cal.set(2013, 0, 1); + + calendar = new Calendar(); + calendar.setId("Calendar"); + calendar.setLocale(locale); + calendar.setDropHandler(new TestDropHandler()); + calendar.setSizeFull(); + root.addComponent(calendar); + + calendar.setStartDate(cal.getTime()); + cal.add(java.util.Calendar.MONTH, 1); + calendar.setEndDate(cal.getTime()); + + table = new Table(); + table.setSizeFull(); + table.setDragMode(TableDragMode.ROW); + table.addGeneratedColumn("COLUMN", new Table.ColumnGenerator() { + + @Override + public Object generateCell(Table source, Object itemId, + Object columnId) { + return itemId; + } + }); + + for (int eventNum = 1; eventNum < 50; eventNum++) { + table.addItem("Event " + eventNum); + } + + root.addComponent(table); + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + return 11048; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java b/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java index 247478256f..015a974b3e 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java +++ b/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java @@ -104,6 +104,7 @@ public class CustomDateFormats extends TestBase { locale); addDateField(gridLayout, getDatePattern(locale, DateFormat.SHORT), locale); + addDateField(gridLayout, "EEE d MMMM yyyy", locale); } diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldLocale.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldLocale.java index 5d06895d11..a4fe2b0285 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldLocale.java +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldLocale.java @@ -16,7 +16,7 @@ public class DateFieldLocale extends TestBase { final DateField dateField = new DateField("DateField"); dateField.setLocale(new Locale("fi", "FI")); dateField.setCaption(dateField.getLocale().toString()); - dateField.setValue(new Date()); + dateField.setValue(new Date(2013 - 1900, 7 - 1, 27)); dateField.setResolution(DateField.RESOLUTION_DAY); addComponent(new Button("Change locale", new ClickListener() { diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPrimaryStyleNames.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPrimaryStyleNames.html index 31216ed1b0..38034fd0c8 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPrimaryStyleNames.html +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPrimaryStyleNames.html @@ -68,12 +68,12 @@ </tr> <tr> <td>assertCSSClass</td> - <td>//body/div[last()]/div[last()]</td> + <td>//body/div[2]/div[last()]</td> <td>my-datefield-popup</td> </tr> <tr> <td>assertCSSClass</td> - <td>//body/div[last()]/div[last()]</td> + <td>//body/div[2]/div[last()]</td> <td>my-datefield-day</td> </tr> <tr> @@ -188,12 +188,12 @@ </tr> <tr> <td>assertCSSClass</td> - <td>//body/div[last()]/div[last()]</td> + <td>//body/div[2]/div[last()]</td> <td>my-second-datefield-popup</td> </tr> <tr> <td>assertCSSClass</td> - <td>//body/div[last()]/div[last()]</td> + <td>//body/div[2]/div[last()]</td> <td>my-second-datefield-day</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html new file mode 100644 index 0000000000..77c610f211 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.datefield.DynamicallyChangeDateRange?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td> + <td>11,8</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[3]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[6]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[7]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::</td> + <td>201,401</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td> + <td>14,16</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[4]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[5]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[5]/td[4]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[5]/td[5]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::</td> + <td>237,338</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td> + <td>14,15</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[3]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[6]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[7]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/span</td> + <td>v-datefield-calendarpanel-day-outside-range</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java new file mode 100644 index 0000000000..fb0fb2a546 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java @@ -0,0 +1,93 @@ +package com.vaadin.tests.components.datefield; + +import java.util.Date; +import java.util.Locale; + +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.DateField; +import com.vaadin.ui.InlineDateField; +import com.vaadin.ui.PopupDateField; +import com.vaadin.ui.VerticalLayout; + +/** + * Main UI class + */ +@SuppressWarnings("serial") +public class DynamicallyChangeDateRange extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + setLocale(Locale.ENGLISH); + final VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + final PopupDateField df = new PopupDateField(); + df.setValue(new Date(2012 - 1900, 5 - 1, 12)); + setRange(df, 5); + layout.addComponent(df); + + final InlineDateField df2 = new InlineDateField(); + df2.setValue(new Date(2012 - 1900, 11 - 1, 16)); + + setRange(df2, 5); + // layout.addComponent(df2); + + Button button1 = new Button("Set Range Now+/-5d"); + button1.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + setRange(df, 5); + setRange(df2, 5); + } + }); + layout.addComponent(button1); + + Button button2 = new Button("Set Range Now+/-10d"); + button2.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + setRange(df, 10); + setRange(df2, 10); + } + }); + layout.addComponent(button2); + } + + /** + * @since + * @param df + * @param i + */ + private void setRange(DateField df, int days) { + df.setRangeStart(new Date(df.getValue().getTime() - days * 24 * 60 * 60 + * 1000)); + df.setRangeEnd(new Date(df.getValue().getTime() + days * 24 * 60 * 60 + * 1000)); + + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Verifies that the allowed date range can be updated dynamically"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 11940; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewAndFragment.html b/uitest/src/com/vaadin/tests/components/popupview/PopupViewAndFragment.html new file mode 100644 index 0000000000..28af578bac --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewAndFragment.html @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>PopupViewAndFragment</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">PopupViewAndFragment</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/PopupViewAndFragment?restartApplication#</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runPopupViewAndFragment::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewAndFragment.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewAndFragment.java new file mode 100644 index 0000000000..1606b78604 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewAndFragment.java @@ -0,0 +1,54 @@ +/* + * 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.popupview; + +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.Label; +import com.vaadin.ui.PopupView; + +public class PopupViewAndFragment extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final PopupView pw = new PopupView("Open", new Label("Oh, hi")); + addComponent(pw); + + final Button button = new Button("Open and change fragment", + new Button.ClickListener() { + @Override + public void buttonClick(final ClickEvent event) { + pw.setPopupVisible(true); + getPage().setUriFragment( + String.valueOf(System.currentTimeMillis())); + } + }); + addComponent(button); + } + + @Override + protected String getTestDescription() { + return "Changing frament should not automatically close PopupView"; + } + + @Override + protected Integer getTicketNumber() { + return 10530; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarGenericTest.java b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarGenericTest.java new file mode 100644 index 0000000000..79797c60a2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarGenericTest.java @@ -0,0 +1,55 @@ +package com.vaadin.tests.components.progressindicator; + +import java.util.LinkedHashMap; + +import com.vaadin.tests.components.abstractfield.AbstractFieldTest; +import com.vaadin.ui.ProgressBar; + +public class ProgressBarGenericTest extends AbstractFieldTest<ProgressBar> { + + private Command<ProgressBar, Boolean> indeterminate = new Command<ProgressBar, Boolean>() { + + @Override + public void execute(ProgressBar c, Boolean value, Object data) { + c.setIndeterminate(value); + } + }; + + @Override + protected Class<ProgressBar> getTestClass() { + return ProgressBar.class; + } + + @Override + protected void createActions() { + super.createActions(); + createBooleanAction("Indeterminate", CATEGORY_FEATURES, false, + indeterminate, null); + createValueSelection(CATEGORY_FEATURES); + createPrimaryStyleNameSelect(); + } + + /** + * @since + */ + protected void createPrimaryStyleNameSelect() { + LinkedHashMap<String, String> options = new LinkedHashMap<String, String>(); + String primaryStyle = getComponent().getPrimaryStyleName(); + options.put(primaryStyle, primaryStyle); + options.put(primaryStyle + "-foo", primaryStyle + "-foo"); + options.put("foo", "foo"); + createSelectAction("Primary style name", CATEGORY_DECORATIONS, options, + primaryStyle, primaryStyleNameCommand); + + } + + private void createValueSelection(String categorySelection) { + LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>(); + options.put("null", null); + for (float f = 0; f <= 1; f += 0.1) { + options.put("" + f, f); + } + createSelectAction("Value", categorySelection, options, null, + setValueCommand); + } +} diff --git a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarPrimaryStyleName.html b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarPrimaryStyleName.html new file mode 100644 index 0000000000..92f678947a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarPrimaryStyleName.html @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.progressindicator.ProgressBarGenericTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>v-progressbar</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>v-progressbar-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>v-progressbar-indicator</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_Smenu#item0</td> + <td>36,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>45,4</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[1]/VMenuBar[0]#item6</td> + <td>67,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[2]/VMenuBar[0]#item2</td> + <td>37,7</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>v-progressbar</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>foo</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>v-progressbar-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>foo-wrapper</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>v-progressbar-indicator</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>foo-indicator</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_Smenu#item0</td> + <td>20,13</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>34,11</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[1]/VMenuBar[0]#item6</td> + <td>51,4</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::Root/VOverlay[2]/VMenuBar[0]#item0</td> + <td>38,6</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent</td> + <td>v-progressbar</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]</td> + <td>v-progressbar-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarGenericTest::PID_StestComponent/domChild[0]/domChild[0]</td> + <td>v-progressbar-indicator</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarTest.html b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarTest.html new file mode 100644 index 0000000000..b7add101f9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarTest.html @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.progressindicator.ProgressBarTest?restartApplication</td> + <td></td> +</tr> +<!--Add ProgressBar and wait--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<!--Text should not have changed--> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> + <td>0</td> +</tr> +<!--Add ProgressIndicator and wait--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<!--Text should have changed--> +<tr> + <td>assertNotText</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> + <td>0</td> +</tr> +<!--Stop thread right away if we get this far (would otherwise continue running until the UI is detached)--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsprogressindicatorProgressBarTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarTest.java b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarTest.java new file mode 100644 index 0000000000..5afa874220 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressBarTest.java @@ -0,0 +1,125 @@ +/* + * 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.progressindicator; + +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.Label; +import com.vaadin.ui.ProgressBar; +import com.vaadin.ui.ProgressIndicator; + +public class ProgressBarTest extends AbstractTestUI { + + private Label updatedFromBackround; + private Thread updateThread = new Thread() { + @Override + public void run() { + Runnable updateTask = new Runnable() { + @Override + public void run() { + counter++; + updateLabel(); + } + }; + + while (true) { + access(updateTask); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + break; + } + } + } + }; + private ProgressBar progressBar; + private int counter = 0; + + @Override + protected void setup(VaadinRequest request) { + updatedFromBackround = new Label(); + updatedFromBackround.setCaption("Updated from background thread"); + updateLabel(); + addComponent(updatedFromBackround); + + addComponent(new Button("Use ProgressBar", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + useComponent(new ProgressBar()); + } + })); + + addComponent(new Button("Use ProgressIndicator", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + useComponent(new ProgressIndicator()); + } + })); + + addComponent(new Button("Stop background thread", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + stopUpdateThread(); + } + })); + updateThread.setDaemon(true); + updateThread.start(); + } + + private void useComponent(ProgressBar progressBar) { + if (this.progressBar != null) { + removeComponent(this.progressBar); + } + this.progressBar = progressBar; + addComponent(progressBar); + + counter = 0; + updateLabel(); + } + + @Override + public void detach() { + super.detach(); + stopUpdateThread(); + } + + private void stopUpdateThread() { + if (updateThread != null) { + updateThread.interrupt(); + updateThread = null; + } + } + + private void updateLabel() { + updatedFromBackround.setValue(String.valueOf(counter)); + } + + @Override + protected String getTestDescription() { + return "ProgressBar should work just as ProgressIndicator, just without the polling"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(11925); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaUpdateWhileTyping.html b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaUpdateWhileTyping.html new file mode 100644 index 0000000000..6ddd1b4097 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaUpdateWhileTyping.html @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:7070/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.richtextarea.RichTextAreaUpdateWhileTyping?restartApplication</td> + <td></td> +</tr> +<tr> + <td>selectFrame</td> + <td>xpath=//div[@id='rta']/iframe</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>//body</td> + <td>This text should be visible, even after an update while I type.</td> +</tr> +<tr> + <td>pause</td> + <td>2000</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>//body</td> + <td>This text should be visible, even after an update while I type.</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaUpdateWhileTyping.java b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaUpdateWhileTyping.java new file mode 100644 index 0000000000..df1d6df463 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaUpdateWhileTyping.java @@ -0,0 +1,51 @@ +package com.vaadin.tests.components.richtextarea; + +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.progressindicator.ProgressIndicatorServerRpc; +import com.vaadin.tests.components.AbstractComponentTest; +import com.vaadin.tests.components.AbstractTestCase; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ProgressIndicator; +import com.vaadin.ui.RichTextArea; + +public class RichTextAreaUpdateWhileTyping extends AbstractTestUI { + + private RichTextArea rta; + + @Override + protected void setup(VaadinRequest request) { + + // Progress indicator for changing the value of the RTA + ProgressIndicator pi = new ProgressIndicator() { + { + registerRpc(new ProgressIndicatorServerRpc() { + + @Override + public void poll() { + rta.markAsDirty(); + } + }); + } + }; + pi.setHeight("0px"); + addComponent(pi); + + rta = new RichTextArea(); + rta.setId("rta"); + rta.setImmediate(true); + addComponent(rta); + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + return 11741; + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableSqlContainer.html b/uitest/src/com/vaadin/tests/components/table/TableSqlContainer.html new file mode 100644 index 0000000000..96df94148c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSqlContainer.html @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.TableSqlContainer?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> + <td>May 24, 2013 12:00:00 AM</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> + <td>12,7</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VPopupCalendar[0]#field</td> + <td>5/24/13</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VPopupCalendar[0]#popupButton</td> + <td>9,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[5]/span</td> + <td>11,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> + <td>9,12</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> + <td>May 15, 2013 12:00:00 AM</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td> + <td>Apr 26, 2013 12:00:00 AM</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[1]/domChild[0]</td> + <td>May 27, 2013 12:00:00 AM</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstableTableSqlContainer::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[1]/domChild[0]</td> + <td>Apr 28, 2013 12:00:00 AM</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/table/TableSqlContainer.java b/uitest/src/com/vaadin/tests/components/table/TableSqlContainer.java new file mode 100644 index 0000000000..5191b1b86e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSqlContainer.java @@ -0,0 +1,142 @@ +package com.vaadin.tests.components.table; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Locale; + +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.data.util.sqlcontainer.SQLContainer; +import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; +import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; +import com.vaadin.data.util.sqlcontainer.query.TableQuery; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +public class TableSqlContainer extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + setLocale(Locale.ENGLISH); + VerticalLayout layout = new VerticalLayout(); + addComponent(layout); + + final Table table = new Table("Table with SQLContainer"); + layout.addComponent(table); + + final Label selectedLabel = new Label("Selected: null"); + layout.addComponent(selectedLabel); + + try { + JDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool( + "org.hsqldb.jdbc.JDBCDriver", + "jdbc:hsqldb:mem:sqlcontainer", "SA", "", 2, 20); + + createTestTable(connectionPool); + insertTestData(connectionPool); + + TableQuery q = new TableQuery("mytable", connectionPool); + q.setVersionColumn("version"); + SQLContainer myContainer = new SQLContainer(q); + + table.setContainerDataSource(myContainer); + + } catch (SQLException e) { + e.printStackTrace(); + } + + table.setImmediate(true); + table.setSizeFull(); + table.setSelectable(true); + table.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + selectedLabel.setValue("Selected: " + + event.getProperty().getValue()); + } + }); + + final CheckBox editMode = new CheckBox("Edit mode"); + editMode.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + table.setEditable(editMode.getValue()); + } + }); + addComponent(editMode); + } + + /** + * (Re)creates the test table + * + * @param connectionPool + */ + private void createTestTable(JDBCConnectionPool connectionPool) { + Connection conn = null; + try { + conn = connectionPool.reserveConnection(); + Statement statement = conn.createStatement(); + try { + statement.executeUpdate("DROP TABLE mytable"); + } catch (SQLException e) { + } + statement.execute("CREATE TABLE mytable " + + "(id INTEGER GENERATED BY DEFAULT AS IDENTITY, D DATE," + + "MYFIELD VARCHAR(45), " + "PRIMARY KEY(ID))"); + statement.close(); + conn.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + connectionPool.releaseConnection(conn); + } + } + + /** + * Adds test data to the test table + * + * @param connectionPool + * @throws SQLException + */ + private void insertTestData(JDBCConnectionPool connectionPool) + throws SQLException { + Connection conn = null; + try { + conn = connectionPool.reserveConnection(); + Statement statement = conn.createStatement(); + + statement + .executeUpdate("INSERT INTO mytable VALUES(1, '2013-05-24', 'A0')"); + statement + .executeUpdate("INSERT INTO mytable VALUES(2, '2013-04-26', 'A1')"); + statement + .executeUpdate("INSERT INTO mytable VALUES(3, '2013-05-27', 'B0')"); + statement + .executeUpdate("INSERT INTO mytable VALUES(4, '2013-04-28', 'B1')"); + + statement.close(); + conn.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + connectionPool.releaseConnection(conn); + } + } + + @Override + protected String getTestDescription() { + return "A test with Table connected to a SQLContainer using TableQuery"; + } + + @Override + protected Integer getTicketNumber() { + return 11224; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.html b/uitest/src/com/vaadin/tests/components/ui/UiAccess.html new file mode 100644 index 0000000000..613691623c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UiAccess.html @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.ui.UiAccess?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> + <td>exact:0. Access from UI thread future is done? false</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> + <td>1. Access from UI thread is run</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>exact:2. beforeClientResponse future is done? true</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> + <td>0. Initial background message</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>exact:1. Thread has current response? false</td> +</tr> +<tr> + <td>waitForText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> + <td>0. Initial background message</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>exact:2. Thread got lock, inital future done? true</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> + <td>0. Throwing exception in access</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> + <td>exact:1. firstFuture is done? true</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>2. Got exception from firstFuture: java.lang.RuntimeException: Catch me if you can</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>0. future was cancled, should not start</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> + <td>0. Waiting for thread to start</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> + <td>1. Thread started, waiting for interruption</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>2. I was interrupted</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_3</td> + <td>0. accessSynchronously has request? true</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> + <td>1. Test value in accessSynchronously: Set before accessSynchronosly</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> + <td>2. has request after accessSynchronously? true</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>3. Test value after accessSynchornously: Set in accessSynchronosly</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_3</td> + <td>0. access has request? false</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> + <td>1. Test value in access: Set before access</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> + <td>2. has request after access? true</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> + <td>3. Test value after access: Set before run pending</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java b/uitest/src/com/vaadin/tests/components/ui/UiAccess.java new file mode 100644 index 0000000000..2bc91fa7b4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UiAccess.java @@ -0,0 +1,307 @@ +/* + * 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.ui; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.locks.ReentrantLock; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinService; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.util.CurrentInstance; + +public class UiAccess extends AbstractTestUIWithLog { + + private Future<Void> checkFromBeforeClientResponse; + + private class CurrentInstanceTestType { + private String value; + + public CurrentInstanceTestType(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + } + + @Override + protected void setup(VaadinRequest request) { + addComponent(new Button("Access from UI thread", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + // Ensure beforeClientResponse is invoked + markAsDirty(); + checkFromBeforeClientResponse = access(new Runnable() { + @Override + public void run() { + log("Access from UI thread is run"); + } + }); + log("Access from UI thread future is done? " + + checkFromBeforeClientResponse.isDone()); + } + })); + addComponent(new Button("Access from background thread", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + final CountDownLatch latch = new CountDownLatch(1); + + new Thread() { + @Override + public void run() { + final boolean threadHasCurrentResponse = VaadinService + .getCurrentResponse() != null; + // session is locked by request thread at this + // point + final Future<Void> initialFuture = access(new Runnable() { + @Override + public void run() { + log("Initial background message"); + log("Thread has current response? " + + threadHasCurrentResponse); + } + }); + + // Let request thread continue + latch.countDown(); + + // Wait until thread can be locked + while (!getSession().getLockInstance() + .tryLock()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + try { + log("Thread got lock, inital future done? " + + initialFuture.isDone()); + setPollInterval(-1); + } finally { + getSession().unlock(); + } + } + }.start(); + + // Wait for thread to do initialize before continuing + try { + latch.await(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + setPollInterval(3000); + } + })); + addComponent(new Button("Access throwing exception", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + final Future<Void> firstFuture = access(new Runnable() { + @Override + public void run() { + log("Throwing exception in access"); + throw new RuntimeException( + "Catch me if you can"); + } + }); + access(new Runnable() { + @Override + public void run() { + log("firstFuture is done? " + + firstFuture.isDone()); + try { + firstFuture.get(); + log("Should not get here"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { + log("Got exception from firstFuture: " + + e.getMessage()); + } + } + }); + } + })); + addComponent(new Button("Cancel future before started", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + Future<Void> future = access(new Runnable() { + @Override + public void run() { + log("Should not get here"); + } + }); + future.cancel(false); + log("future was cancled, should not start"); + } + })); + addComponent(new Button("Cancel running future", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + final ReentrantLock interruptLock = new ReentrantLock(); + + final Future<Void> future = access(new Runnable() { + @Override + public void run() { + log("Waiting for thread to start"); + while (!interruptLock.isLocked()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + log("Premature interruption"); + throw new RuntimeException(e); + } + } + + log("Thread started, waiting for interruption"); + try { + interruptLock.lockInterruptibly(); + } catch (InterruptedException e) { + log("I was interrupted"); + } + } + }); + + new Thread() { + @Override + public void run() { + interruptLock.lock(); + // Wait until UI thread has started waiting for + // the lock + while (!interruptLock.hasQueuedThreads()) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + future.cancel(true); + } + }.start(); + } + })); + addComponent(new Button("CurrentInstance accessSynchronously values", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + // accessSynchronously should maintain values + CurrentInstance.set(CurrentInstanceTestType.class, + new CurrentInstanceTestType( + "Set before accessSynchronosly")); + accessSynchronously(new Runnable() { + @Override + public void run() { + log.log("accessSynchronously has request? " + + (VaadinService.getCurrentRequest() != null)); + log.log("Test value in accessSynchronously: " + + CurrentInstance + .get(CurrentInstanceTestType.class)); + CurrentInstance.set( + CurrentInstanceTestType.class, + new CurrentInstanceTestType( + "Set in accessSynchronosly")); + } + }); + log.log("has request after accessSynchronously? " + + (VaadinService.getCurrentRequest() != null)); + log("Test value after accessSynchornously: " + + CurrentInstance + .get(CurrentInstanceTestType.class)); + } + })); + addComponent(new Button("CurrentInstance access values", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + // accessSynchronously should maintain values + CurrentInstance + .setInheritable(CurrentInstanceTestType.class, + new CurrentInstanceTestType( + "Set before access")); + access(new Runnable() { + @Override + public void run() { + log.log("access has request? " + + (VaadinService.getCurrentRequest() != null)); + log.log("Test value in access: " + + CurrentInstance + .get(CurrentInstanceTestType.class)); + CurrentInstance.setInheritable( + CurrentInstanceTestType.class, + new CurrentInstanceTestType( + "Set in access")); + } + }); + CurrentInstance.setInheritable( + CurrentInstanceTestType.class, + new CurrentInstanceTestType( + "Set before run pending")); + + getSession().getService().runPendingAccessTasks( + getSession()); + + log.log("has request after access? " + + (VaadinService.getCurrentRequest() != null)); + log("Test value after access: " + + CurrentInstance + .get(CurrentInstanceTestType.class)); + } + })); + } + + @Override + public void beforeClientResponse(boolean initial) { + if (checkFromBeforeClientResponse != null) { + log("beforeClientResponse future is done? " + + checkFromBeforeClientResponse.isDone()); + checkFromBeforeClientResponse = null; + } + } + + @Override + protected String getTestDescription() { + return "Test for various ways of using UI.access"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(11897); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html index d734cab9ea..63e371e379 100644 --- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html +++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html @@ -64,6 +64,22 @@ <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> <td>My tooltip</td> </tr> +<!-- Hide tooltip in Window --> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> </tbody></table> </body> </html> diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html index 945564f298..dcdfa05687 100644 --- a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html +++ b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html @@ -162,17 +162,6 @@ <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VNativeButton[0]</td> <td>43,12</td> </tr> -<!--Remove the following two commands once #11737 is fixed--> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VNativeButton[0]</td> - <td>43,12</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VNativeButton[0]</td> - <td>43,12</td> -</tr> <!--maximize window 2 content--> <tr> <td>mouseClick</td> @@ -234,6 +223,37 @@ <td></td> <td>window-1-maximized-with-doubleclick</td> </tr> +<!--Test that size and position is preserved when maximizing and restoring--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>8,4</td> +</tr> +<tr> + <td>dragAndDrop</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>-200,-200</td> +</tr> +<tr> + <td>dragAndDrop</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]</td> + <td>+100,+100</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>6,5</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>5,8</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>window-1-moved-maximized-restored</td> +</tr> </tbody></table> </body> </html> diff --git a/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/Broadcaster.java b/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/Broadcaster.java index 57ad0d97ba..78d0af6283 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/Broadcaster.java +++ b/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/Broadcaster.java @@ -16,44 +16,25 @@ package com.vaadin.tests.minitutorials.broadcastingmessages; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public class Broadcaster { - private static List<BroadcastListener> listeners = new ArrayList<BroadcastListener>(); + private static final List<BroadcastListener> listeners = new CopyOnWriteArrayList<BroadcastListener>(); - public synchronized static void register(BroadcastListener listener) { + public static void register(BroadcastListener listener) { listeners.add(listener); } - public synchronized static void unregister(BroadcastListener listener) { + public static void unregister(BroadcastListener listener) { listeners.remove(listener); } - private synchronized static List<BroadcastListener> getListeners() { - List<BroadcastListener> listenerCopy = new ArrayList<BroadcastListener>(); - listenerCopy.addAll(listeners); - return listenerCopy; - } - public static void broadcast(final String message) { - // Make a copy of the listener list while synchronized, can't be - // synchronized while firing the event or we would have to fire each - // event in a separate thread. - final List<BroadcastListener> listenerCopy = getListeners(); - - // We spawn another thread to avoid potential deadlocks with - // multiple UIs locked simultaneously - Thread eventThread = new Thread() { - @Override - public void run() { - for (BroadcastListener listener : listenerCopy) { - listener.receiveBroadcast(message); - } - } - }; - eventThread.start(); + for (BroadcastListener listener : listeners) { + listener.receiveBroadcast(message); + } } public interface BroadcastListener { diff --git a/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java b/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java index 06ead20db3..68b5925f48 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/broadcastingmessages/BroadcasterUI.java @@ -1,5 +1,6 @@ package com.vaadin.tests.minitutorials.broadcastingmessages; +import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.minitutorials.broadcastingmessages.Broadcaster.BroadcastListener; import com.vaadin.ui.Button; @@ -10,6 +11,7 @@ import com.vaadin.ui.TextArea; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; +@Push public class BroadcasterUI extends UI implements BroadcastListener { @Override diff --git a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java new file mode 100644 index 0000000000..37a8afd819 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java @@ -0,0 +1,12 @@ +package com.vaadin.tests.push; + +import com.vaadin.annotations.Push; +import com.vaadin.shared.ui.ui.Transport; + +@Push(transport = Transport.STREAMING) +public class BasicPushStreaming extends BasicPush { + @Override + protected void setup(com.vaadin.server.VaadinRequest request) { + addComponent(new PushConfigurator(this)); + } +} diff --git a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java new file mode 100644 index 0000000000..6fc27e8974 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java @@ -0,0 +1,8 @@ +package com.vaadin.tests.push; + +import com.vaadin.annotations.Push; +import com.vaadin.shared.ui.ui.Transport; + +@Push(transport = Transport.WEBSOCKET) +public class BasicPushWebsocket extends BasicPush { +} diff --git a/uitest/src/com/vaadin/tests/push/PushConfiguration.html b/uitest/src/com/vaadin/tests/push/PushConfiguration.html new file mode 100644 index 0000000000..c3786b1cc1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushConfiguration.html @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<!--Websocket--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertNotText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td> + <td>label=WEBSOCKET</td> +</tr> +<tr> + <td>assertNotText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> + <td>label=AUTOMATIC</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td> + <td>*fallbackTransport: streaming*transport: websocket*</td> +</tr> +<tr> + <td>assertNotText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<tr> + <td>waitForText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<!--Use debug console to verify we used the correct transport type--> +<tr> + <td>assertTextPresent</td> + <td>Push connection established using websocket</td> + <td></td> +</tr> +<tr> + <td>assertTextNotPresent</td> + <td>Push connection established using streaming</td> + <td>Push connection established using streaming</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> + <td>label=DISABLED</td> +</tr> +<!--Streaming--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertNotText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td> + <td>label=STREAMING</td> +</tr> +<tr> + <td>assertNotText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> + <td>label=AUTOMATIC</td> +</tr> +<tr> + <td>assertNotText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td> + <td>*fallbackTransport: streaming*transport: streaming*</td> +</tr> +<tr> + <td>waitForText</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> + <td>4</td> +</tr> +<!--Use debug console to verify we used the correct transport type--> +<tr> + <td>assertTextNotPresent</td> + <td>Push connection established using websocket</td> + <td></td> +</tr> +<tr> + <td>assertTextPresent</td> + <td>Push connection established using streaming</td> + <td></td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> + <td>label=DISABLED</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java new file mode 100644 index 0000000000..b57e9732cc --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java @@ -0,0 +1,102 @@ +package com.vaadin.tests.push; + +import java.util.Date; +import java.util.Timer; +import java.util.TimerTask; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; + +public class PushConfigurationTest extends AbstractTestUI { + + private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0); + + private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0); + + private final Timer timer = new Timer(true); + + private final TimerTask task = new TimerTask() { + + @Override + public void run() { + access(new Runnable() { + @Override + public void run() { + counter2.setValue(counter2.getValue() + 1); + } + }); + } + }; + + @Override + protected void setup(VaadinRequest request) { + addComponent(new PushConfigurator(this)); + spacer(); + + /* + * Client initiated push. + */ + Label lbl = new Label(counter); + lbl.setCaption("Client counter (click 'increment' to update):"); + addComponent(lbl); + + addComponent(new Button("Increment", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + counter.setValue(counter.getValue() + 1); + } + })); + + spacer(); + + /* + * Server initiated push. + */ + lbl = new Label(counter2); + lbl.setCaption("Server counter (updates each 1s by server thread) :"); + addComponent(lbl); + + addComponent(new Button("Reset", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + counter2.setValue(0); + } + })); + } + + @Override + protected String getTestDescription() { + return "This test tests the very basic operations of push. " + + "It tests that client initiated changes are " + + "recieved back to the client as well as server " + + "initiated changes are correctly updated to the client."; + } + + @Override + protected Integer getTicketNumber() { + return 11494; + } + + private void spacer() { + addComponent(new Label("<hr/>", ContentMode.HTML)); + } + + @Override + public void attach() { + super.attach(); + timer.scheduleAtFixedRate(task, new Date(), 1000); + } + + @Override + public void detach() { + super.detach(); + timer.cancel(); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurator.java b/uitest/src/com/vaadin/tests/push/PushConfigurator.java new file mode 100644 index 0000000000..6528366b59 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushConfigurator.java @@ -0,0 +1,152 @@ +/* + * 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.push; + +import java.util.ArrayList; +import java.util.Collections; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.shared.communication.PushMode; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.PushConfiguration; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since 7.1 + * @author Vaadin Ltd + */ +public class PushConfigurator extends VerticalLayout { + private NativeSelect pushMode = new NativeSelect("Push mode"); + private NativeSelect transport = new NativeSelect("Transport"); + private NativeSelect fallbackTransport = new NativeSelect("Fallback"); + private TextField parameter = new TextField("Parameter"); + private TextField value = new TextField("Value"); + private Button set = new Button("Set"); + private HorizontalLayout paramValue = new HorizontalLayout(); + private VerticalLayout vl = new VerticalLayout(); + private UI ui; + + private Label status = new Label("", ContentMode.PREFORMATTED); + + public PushConfigurator(UI ui) { + this.ui = ui; + construct(); + refreshStatus(); + } + + /** + * @since + */ + private void refreshStatus() { + PushConfiguration pc = ui.getPushConfiguration(); + String value = ""; + ArrayList<String> names = new ArrayList<String>(); + names.addAll(pc.getParameterNames()); + Collections.sort(names); + for (String param : names) { + value += param + ": " + pc.getParameter(param) + "\n"; + } + status.setValue(value); + } + + /** + * @since + */ + private void construct() { + pushMode.addItem(PushMode.DISABLED); + pushMode.addItem(PushMode.MANUAL); + pushMode.addItem(PushMode.AUTOMATIC); + + for (Transport t : Transport.values()) { + transport.addItem(t.toString()); + fallbackTransport.addItem(t.toString()); + } + transport.addItem(""); + fallbackTransport.addItem(""); + + pushMode.setImmediate(true); + transport.setImmediate(true); + fallbackTransport.setImmediate(true); + + listeners(); + + paramValue.setDefaultComponentAlignment(Alignment.BOTTOM_RIGHT); + paramValue.addComponents(parameter, value, set); + vl.addComponents(pushMode, transport, fallbackTransport, paramValue, + new Label("<hr/>", ContentMode.HTML), status); + addComponent(vl); + + } + + /** + * @since + */ + private void listeners() { + pushMode.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + ui.getPushConfiguration().setPushMode( + (PushMode) pushMode.getValue()); + refreshStatus(); + } + }); + + transport.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + Transport t = Transport.valueOf((String) transport.getValue()); + ui.getPushConfiguration().setTransport(t); + refreshStatus(); + } + }); + + fallbackTransport.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + Transport t = Transport.valueOf((String) fallbackTransport + .getValue()); + ui.getPushConfiguration().setFallbackTransport(t); + refreshStatus(); + } + }); + + set.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + ui.getPushConfiguration().setParameter(parameter.getValue(), + value.getValue()); + refreshStatus(); + } + }); + + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html b/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html new file mode 100644 index 0000000000..854dd458bb --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.push.BasicPushStreaming?debug&restartApplication</td> + <td></td> +</tr> +<tr> + <td>waitForTextPresent</td> + <td>Push connection established using streaming</td> + <td></td> +</tr> +<tr> + <td>assertTextNotPresent</td> + <td>Push connection established using websocket</td> + <td></td> +</tr> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.push.BasicPushWebsocket?debug&restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertTextNotPresent</td> + <td>Push connection established using streaming</td> + <td></td> +</tr> +<tr> + <td>waitForTextPresent</td> + <td>Push connection established using websocket</td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.java b/uitest/src/com/vaadin/tests/push/TogglePush.java index 37687260dd..c0bdc54ee0 100644 --- a/uitest/src/com/vaadin/tests/push/TogglePush.java +++ b/uitest/src/com/vaadin/tests/push/TogglePush.java @@ -22,19 +22,22 @@ public class TogglePush extends AbstractTestUI { updateCounter(); addComponent(counterLabel); - setPushMode("disabled".equals(request.getParameter("push")) ? PushMode.DISABLED - : PushMode.AUTOMATIC); + getPushConfiguration() + .setPushMode( + "disabled".equals(request.getParameter("push")) ? PushMode.DISABLED + : PushMode.AUTOMATIC); CheckBox pushSetting = new CheckBox("Push enabled"); - pushSetting.setValue(Boolean.valueOf(getPushMode().isEnabled())); + pushSetting.setValue(Boolean.valueOf(getPushConfiguration() + .getPushMode().isEnabled())); pushSetting.setImmediate(true); pushSetting.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (event.getProperty().getValue() == Boolean.TRUE) { - setPushMode(PushMode.AUTOMATIC); + getPushConfiguration().setPushMode(PushMode.AUTOMATIC); } else { - setPushMode(PushMode.DISABLED); + getPushConfiguration().setPushMode(PushMode.DISABLED); } } }); diff --git a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.html b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.html index 05a0f256c2..0c70d6f711 100644 --- a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.html +++ b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.html @@ -51,7 +51,16 @@ <td></td> <td>world-red</td> </tr> - +<tr> + <td>click</td> + <td>vaadin=runcomvaadinteststhemesCSSInjectTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>world-still-red</td> +</tr> </tbody></table> </body> </html> diff --git a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java index f4448bf326..738d8fc681 100644 --- a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java +++ b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java @@ -22,14 +22,16 @@ public class CSSInjectTest extends TestBase { final Styles stylesheet = Page.getCurrent().getStyles(); // Inject some resources initially - stylesheet.add(new StreamResource(new StreamResource.StreamSource() { + final StreamResource initialResource = new StreamResource( + new StreamResource.StreamSource() { - @Override - public InputStream getStream() { - return new ByteArrayInputStream( - ".hello, .world { color:silver; }".getBytes()); - } - }, "mystyles-" + System.currentTimeMillis() + ".css")); + @Override + public InputStream getStream() { + return new ByteArrayInputStream( + ".hello, .world { color:silver; }".getBytes()); + } + }, "mystyles-" + System.currentTimeMillis() + ".css"); + stylesheet.add(initialResource); Label hello = new Label( "<span class='hello'>Hello</span> <span class='world'>world</span>", @@ -72,6 +74,14 @@ public class CSSInjectTest extends TestBase { } }); addComponent(injectRandom); + + addComponent(new Button("Inject initial again!", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + stylesheet.add(initialResource); + } + })); } @Override diff --git a/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml b/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml index 1b47a86113..fd52e5cd0e 100644 --- a/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml +++ b/uitest/src/com/vaadin/tests/widgetset/TestingWidgetSet.gwt.xml @@ -1,15 +1,16 @@ <module> - <!-- WS Compiler: manually edited --> + <!-- WS Compiler: manually edited --> + + <!-- Inherit the DefaultWidgetSet --> + <inherits name="com.vaadin.DefaultWidgetSet" /> - <!-- Inherit the DefaultWidgetSet --> - <inherits name="com.vaadin.DefaultWidgetSet" /> - <replace-with class="com.vaadin.tests.widgetset.client.CustomUIConnector"> <when-type-is class="com.vaadin.client.ui.ui.UIConnector" /> </replace-with> - - <replace-with class="com.vaadin.tests.widgetset.client.TestingPushConnection"> + + <replace-with + class="com.vaadin.tests.widgetset.client.TestingPushConnection"> <when-type-is class="com.vaadin.client.communication.PushConnection" /> </replace-with> - + </module> diff --git a/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java b/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java index 8d00598907..4dae8892e7 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java @@ -2,15 +2,19 @@ package com.vaadin.tests.widgetset.client; import com.google.gwt.user.client.Window; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ApplicationConnection.CommunicationErrorHandler; import com.vaadin.client.communication.AtmospherePushConnection; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; public class TestingPushConnection extends AtmospherePushConnection { private String transport; @Override - public void init(ApplicationConnection connection) { - super.init(connection); + public void init(ApplicationConnection connection, + PushConfigurationState pushConfiguration, + CommunicationErrorHandler errorHandler) { + super.init(connection, pushConfiguration, errorHandler); transport = Window.Location.getParameter("transport"); } |