summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/navigator/NavigatorTest.html107
-rw-r--r--uitest/src/com/vaadin/tests/navigator/NavigatorTest.java129
2 files changed, 236 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.html b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.html
new file mode 100644
index 0000000000..8c4e8f657b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.html
@@ -0,0 +1,107 @@
+<?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:8070" />
+<title>NavigatorTest</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">NavigatorTest</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.navigator.NavigatorTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
+ <td>1. Navigated to ListView with params</td>
+</tr>
+<tr>
+ <td>assertLocation</td>
+ <td>*#!list</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
+ <td>2. Navigated to EditView with params</td>
+</tr>
+<tr>
+ <td>assertLocation</td>
+ <td>*#!edit</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[3]/VTextField[0]</td>
+ <td>56,6</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[3]/VTextField[0]</td>
+ <td>param=value</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
+ <td>3. Navigated to ListView with params param=value</td>
+</tr>
+<tr>
+ <td>assertLocation</td>
+ <td>*#!list/param=value</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
+ <td>4. Navigated to EditView with params param=value</td>
+</tr>
+<tr>
+ <td>assertLocation</td>
+ <td>*#!edit/param=value</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsnavigatorNavigatorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
+ <td>5. Prevent navigation to ForbiddenView</td>
+</tr>
+<tr>
+ <td>assertLocation</td>
+ <td>*#!edit/param=value</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java
new file mode 100644
index 0000000000..bfb11f6b8c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java
@@ -0,0 +1,129 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.navigator;
+
+import com.vaadin.navigator.Navigator;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.server.WrappedRequest;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class NavigatorTest extends UI {
+
+ private Log log = new Log(5);
+ private Layout naviLayout = new VerticalLayout();
+ private TextField params = new TextField("Parameters");
+
+ private Navigator navi;
+
+ class ListView extends Table implements View {
+
+ public ListView() {
+ addContainerProperty("name", String.class, "");
+ addContainerProperty("value", String.class, "");
+ }
+
+ @Override
+ public void enter(ViewChangeEvent event) {
+ String params = event.getParameters();
+ log.log("Navigated to ListView with params " + params);
+ removeAllItems();
+ for (String arg : params.split(",")) {
+ addItem(arg.split("=|$", 2), arg);
+ }
+ }
+ }
+
+ class EditView extends RichTextArea implements View {
+
+ @Override
+ public void enter(ViewChangeEvent event) {
+ log.log("Navigated to EditView with params "
+ + event.getParameters());
+ setValue("Displaying edit view with parameters "
+ + event.getParameters());
+ }
+ }
+
+ class DefaultView extends Label implements View {
+
+ @Override
+ public void enter(ViewChangeEvent event) {
+ log.log("Navigated to DefaultView with params "
+ + event.getParameters());
+ setValue("Default view: " + event.getParameters());
+ }
+ }
+
+ class ForbiddenView implements View {
+
+ @Override
+ public void enter(ViewChangeEvent event) {
+ log.log("Navigated to ForbiddenView - this should not happen");
+ }
+ }
+
+ class NaviListener implements ViewChangeListener {
+
+ @Override
+ public boolean isViewChangeAllowed(ViewChangeEvent event) {
+ if (event.getNewView() instanceof ForbiddenView) {
+ log.log("Prevent navigation to ForbiddenView");
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void navigatorViewChanged(ViewChangeEvent event) {
+ }
+ };
+
+ class NaviButton extends Button {
+ public NaviButton(final String path) {
+ super("Navigate to " + path, new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ navi.navigateTo(path + "/" + params.getValue());
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void init(WrappedRequest req) {
+ try {
+ navi = new Navigator(naviLayout);
+
+ navi.addView("", new DefaultView());
+
+ navi.addView("list", new ListView());
+ navi.addView("edit", new EditView());
+ navi.addView("forbidden", new ForbiddenView());
+
+ navi.addViewChangeListener(new NaviListener());
+ // navi.navigate();
+
+ addComponent(new NaviButton("list"));
+ addComponent(new NaviButton("edit"));
+ addComponent(new NaviButton("forbidden"));
+
+ addComponent(params);
+ addComponent(log);
+ addComponent(naviLayout);
+ } catch (Exception e) {
+ log.log("Exception: " + e.getMessage());
+ }
+ }
+}