From afa50a4cb6a0ebef4ff396389daeb29d9ee7c60f Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 19 Sep 2012 15:13:55 +0000 Subject: [PATCH] Merged tests for initial fragment events (#9558) Fix not needed in Vaadin 7 svn changeset:24491/svn branch:6.8 Change-Id: Id78475eac42fef47a523cf1e27b2d15f1789335f --- .../ChangeFragmentOnServerToMatchClient.html | 37 +++++++++ .../components/ui/FragmentChangeEvents.html | 79 +++++++++++++++++++ .../components/ui/InitialFragmentEvent.java | 60 ++++++++++++++ .../components/ui/InitiallyEmptyFragment.html | 47 +++++++++++ 4 files changed, 223 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html create mode 100644 uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html create mode 100644 uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java create mode 100644 uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html 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 index 0000000000..8276f0fd89 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html @@ -0,0 +1,37 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.ui.InitialFragmentEvent?restartApplication#foo
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0
clickvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0
+ + 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 index 0000000000..972d3d6143 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html @@ -0,0 +1,79 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.ui.InitialFragmentEvent?restartApplication#initial
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0
open/run/com.vaadin.tests.components.ui.InitialFragmentEvent#initial
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0
runScriptwindow.location.hash='second'
pause500
waitForVaadin
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_01. Fragment changed from "no event received" to second
runScriptwindow.location.hash=''
pause500
waitForVaadin
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_02. Fragment changed from second to
+ + 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 index 0000000000..b4a7d4e181 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java @@ -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 index 0000000000..933274eae6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html @@ -0,0 +1,47 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.ui.InitialFragmentEvent?restartApplication
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0
runScriptwindow.location.hash='bar'
pause500
waitForVaadin
assertTextvaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_01. Fragment changed from "no event received" to bar
+ + -- 2.39.5