]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged tests for initial fragment events (#9558) 21/21/1
authorArtur Signell <artur.signell@itmill.com>
Wed, 19 Sep 2012 15:13:55 +0000 (15:13 +0000)
committerArtur Signell <artur@vaadin.com>
Fri, 28 Sep 2012 19:01:01 +0000 (22:01 +0300)
Fix not needed in Vaadin 7

svn changeset:24491/svn branch:6.8

Change-Id: Id78475eac42fef47a523cf1e27b2d15f1789335f

uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html [new file with mode: 0644]

diff --git a/uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html b/uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html
new file mode 100644 (file)
index 0000000..8276f0f
--- /dev/null
@@ -0,0 +1,37 @@
+<?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://arturwin.office.itmill.com:9999/" />
+<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.InitialFragmentEvent?restartApplication#foo</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td></td>
+</tr>
+<!--Changing the fragment to the initial fragment should not cause an event-->
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td></td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html b/uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html
new file mode 100644 (file)
index 0000000..972d3d6
--- /dev/null
@@ -0,0 +1,79 @@
+<?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://arturwin.office.itmill.com:9999/" />
+<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.InitialFragmentEvent?restartApplication#initial</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td></td>
+</tr>
+<!--Reloading with the same fragment but without restartApplication should not cause any event-->
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.ui.InitialFragmentEvent#initial</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td></td>
+</tr>
+<!--Changing the fragment should cause an event-->
+<tr>
+       <td>runScript</td>
+       <td>window.location.hash='second'</td>
+       <td></td>
+</tr>
+<tr>
+       <td>pause</td>
+       <td>500</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td>1. Fragment changed from &quot;no event received&quot; to second</td>
+</tr>
+<!--Clearing the fragment should cause an event-->
+<tr>
+       <td>runScript</td>
+       <td>window.location.hash=''</td>
+       <td></td>
+</tr>
+<tr>
+       <td>pause</td>
+       <td>500</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td>2. Fragment changed from second to</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java b/uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java
new file mode 100644 (file)
index 0000000..b4a7d4e
--- /dev/null
@@ -0,0 +1,60 @@
+package com.vaadin.tests.components.ui;
+
+import com.vaadin.server.Page.FragmentChangedEvent;
+import com.vaadin.server.Page.FragmentChangedListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class InitialFragmentEvent extends AbstractTestUI {
+
+    private String lastKnownFragment = "\"no event received\"";
+    private Log log = new Log(5);
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        getPage().addFragmentChangedListener(new FragmentChangedListener() {
+
+            public void fragmentChanged(FragmentChangedEvent source) {
+                String newFragment = source.getFragment();
+                log.log("Fragment changed from " + lastKnownFragment + " to "
+                        + newFragment);
+                lastKnownFragment = newFragment;
+            }
+        });
+        addComponent(log);
+        addComponent(new Button("Set fragment to 'foo'",
+                new Button.ClickListener() {
+
+                    public void buttonClick(ClickEvent event) {
+                        setFragment("foo");
+                    }
+                }));
+        addComponent(new Button("Set fragment to 'bar'",
+                new Button.ClickListener() {
+
+                    public void buttonClick(ClickEvent event) {
+                        setFragment("bar");
+                    }
+                }));
+    }
+
+    protected void setFragment(String fragment) {
+        getPage().setFragment(fragment);
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    protected String getTestDescription() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html b/uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html
new file mode 100644 (file)
index 0000000..933274e
--- /dev/null
@@ -0,0 +1,47 @@
+<?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://arturwin.office.itmill.com:9999/" />
+<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.InitialFragmentEvent?restartApplication</td>
+       <td></td>
+</tr>
+<!--There is no fragment change event when the fragment is initially empty-->
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td></td>
+</tr>
+<tr>
+       <td>runScript</td>
+       <td>window.location.hash='bar'</td>
+       <td></td>
+</tr>
+<tr>
+       <td>pause</td>
+       <td>500</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td>
+       <td>1. Fragment changed from &quot;no event received&quot; to bar</td>
+</tr>
+</tbody></table>
+</body>
+</html>