diff options
author | Build Agent <build@vaadin.com> | 2014-04-02 09:28:32 +0300 |
---|---|---|
committer | Build Agent <build@vaadin.com> | 2014-04-02 09:28:33 +0300 |
commit | e1a987f88d624e6099e2ceae4c463506f1a4b52c (patch) | |
tree | de3bdf837e6cc97fa52d5119b0df05a1de67b213 /uitest | |
parent | 92ad3c291e4371995d6757c0fcf50a24c02444b5 (diff) | |
parent | 7c569ca30267f1f506d6f8870c9c254c922f6568 (diff) | |
download | vaadin-framework-e1a987f88d624e6099e2ceae4c463506f1a4b52c.tar.gz vaadin-framework-e1a987f88d624e6099e2ceae4c463506f1a4b52c.zip |
Merge changes from origin/7.1
a71305c Removed unnecessary tooltips from LayoutTesterApplication.
7c569ca Replaced flaky TB2 test with stable TB3 test
Change-Id: I490aea06d1a9045ff071b64da1bfdc0f1b4937e6
Diffstat (limited to 'uitest')
6 files changed, 128 insertions, 196 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/UriFragment.java b/uitest/src/com/vaadin/tests/components/ui/UriFragment.java new file mode 100644 index 0000000000..c726c49b12 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UriFragment.java @@ -0,0 +1,64 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.server.Page; +import com.vaadin.server.Page.UriFragmentChangedEvent; +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; + +public class UriFragment extends AbstractTestUI { + + private final Label fragmentLabel = new Label(); + + @Override + protected void setup(VaadinRequest request) { + fragmentLabel.setId("fragmentLabel"); + addComponent(fragmentLabel); + updateLabel(); + getPage().addListener(new Page.UriFragmentChangedListener() { + @Override + public void uriFragmentChanged(UriFragmentChangedEvent event) { + updateLabel(); + } + }); + + addComponent(createButton("test", "Navigate to #test", "test")); + addComponent(createButton("empty", "Navigate to #", "")); + addComponent(createButton("null", "setUriFragment(null)", null)); + } + + private Button createButton(String id, String caption, final String fragment) { + Button button = new Button(caption, new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + getPage().setUriFragment(fragment); + } + }); + + button.setId(id); + + return button; + } + + private void updateLabel() { + String fragment = getPage().getUriFragment(); + if (fragment == null) { + fragmentLabel.setValue("No URI fragment set"); + } else { + fragmentLabel.setValue("Current URI fragment: " + fragment); + } + } + + @Override + public String getTestDescription() { + return "URI fragment status should be known when the page is loaded and retained while navigating to different fragments or using the back and forward buttons."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8048); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/UriFragmentTest.html b/uitest/src/com/vaadin/tests/components/ui/UriFragmentTest.html deleted file mode 100644 index ba24b55f64..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/UriFragmentTest.html +++ /dev/null @@ -1,136 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>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.UriFragmentTest?restartApplication#urifragment</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>Current URI fragment: urifragment</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>Current URI fragment: test</td> -</tr> -<tr> - <td>runScript</td> - <td>history.back()</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td></td> - <td>1000</td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>Current URI fragment: urifragment</td> -</tr> -<tr> - <td>runScript</td> - <td>history.forward()</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td></td> - <td>1000</td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>Current URI fragment: test</td> -</tr> -<!--Open other URL in between to ensure the page is loaded again (testbench doesn't like opening a URI that only changes the fragment)--> -<tr> - <td>open</td> - <td>/run/</td> - <td></td> -</tr> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.ui.UriFragmentTest?restartApplication</td> - <td></td> -</tr> -<!--Empty initial fragment--> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>No URI fragment set</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<!--Still no # after setting to null--> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>No URI fragment set</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<!--Empty # is added when setting to ""--> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Current URI fragment:</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Current URI fragment: test</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<!--Setting to null when there is a fragment actually sets it to #--> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Current URI fragment:</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/UriFragmentTest.java b/uitest/src/com/vaadin/tests/components/ui/UriFragmentTest.java index bfd784280a..e7fbf4f7ec 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UriFragmentTest.java +++ b/uitest/src/com/vaadin/tests/components/ui/UriFragmentTest.java @@ -1,68 +1,75 @@ package com.vaadin.tests.components.ui; -import com.vaadin.server.Page; -import com.vaadin.server.Page.UriFragmentChangedEvent; -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; - -public class UriFragmentTest extends AbstractTestUI { - - private final Label fragmentLabel = new Label(); - - @Override - protected void setup(VaadinRequest request) { - addComponent(fragmentLabel); - updateLabel(); - getPage().addListener(new Page.UriFragmentChangedListener() { +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class UriFragmentTest extends MultiBrowserTest { + + @Test + public void testUriFragment() throws Exception { + driver.get(getTestUrl() + "#urifragment"); + assertFragment("urifragment"); + navigateToTest(); + assertFragment("test"); + ((JavascriptExecutor) driver).executeScript("history.back()"); + + assertFragment("urifragment"); + ((JavascriptExecutor) driver).executeScript("history.forward()"); + assertFragment("test"); + + // Open other URL in between to ensure the page is loaded again + // (testbench doesn't like opening a URI that only changes the fragment) + driver.get(getBaseURL() + "/statictestfiles/"); + driver.get(getTestUrl()); + + // Empty initial fragment + assertEquals("No URI fragment set", getFragmentLabelValue()); + + navigateToNull(); + // Still no # after setting to null + assertEquals("No URI fragment set", getFragmentLabelValue()); + navigateToEmptyFragment(); + // Empty # is added when setting to "" + assertEquals("Current URI fragment:", getFragmentLabelValue()); + navigateToTest(); + assertFragment("test"); + navigateToNull(); // Setting to null when there is a fragment actually + // sets it to # + assertEquals("Current URI fragment:", getFragmentLabelValue()); + } + + private void assertFragment(String fragment) { + final String expectedText = "Current URI fragment: " + fragment; + waitUntil(new ExpectedCondition<Boolean>() { + @Override - public void uriFragmentChanged(UriFragmentChangedEvent event) { - updateLabel(); + public Boolean apply(WebDriver input) { + return expectedText.equals(getFragmentLabelValue()); } }); - addComponent(new Button("Navigate to #test", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setUriFragment("test"); - } - })); - - addComponent(new Button("Navigate to #", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setUriFragment(""); - } - })); - - addComponent(new Button("setUriFragment(null)", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setUriFragment(null); - } - })); + + } + + private void navigateToEmptyFragment() { + hitButton("empty"); } - private void updateLabel() { - String fragment = getPage().getUriFragment(); - if (fragment == null) { - fragmentLabel.setValue("No URI fragment set"); - } else { - fragmentLabel.setValue("Current URI fragment: " + fragment); - } + private void navigateToNull() { + hitButton("null"); } - @Override - public String getTestDescription() { - return "URI fragment status should be known when the page is loaded and retained while navigating to different fragments or using the back and forward buttons."; + private void navigateToTest() { + hitButton("test"); } - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(8048); + private String getFragmentLabelValue() { + return vaadinElementById("fragmentLabel").getText(); } } diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java index 971205ccbb..afa53c012e 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java @@ -97,8 +97,7 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { for (int i = 0; i < captions.length; i++) { component = getTestTabsheet(); component.setCaption(captions[i]); - component.setComponentError(new UserError( - "component error, user error")); + component.setComponentError(new UserError("")); vlo.addComponent(component); } baseLayout.addComponent(vlo); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java index 6ba5109ce7..0544be326a 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java @@ -25,7 +25,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.Select; -import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium; import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; @@ -117,7 +116,7 @@ public class LayoutTesterApplicationTest extends MultiBrowserTest { // Table does some extra layout phase and TestBench does not always // take this into account, grabbing screenshots before the layout // phase is done (see #12866). - sleep(350); + sleep(500); } compareScreen(screenshotPrefix + "-" + sanitize(driver.findElement(By.id(buttonId)).getText())); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java index 04cee2d68d..df9be8ffd0 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java @@ -96,8 +96,7 @@ public class VerticalLayoutTests extends AbstractLayoutTests { for (int i = 0; i < captions.length; i++) { component = getTestTabsheet(); component.setCaption(captions[i]); - component.setComponentError(new UserError( - "component error, user error")); + component.setComponentError(new UserError("")); vlo.addComponent(component); } baseLayout.addComponent(vlo); |