]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged (partly by hand) [9399]
authorArtur Signell <artur.signell@itmill.com>
Mon, 2 Nov 2009 14:22:47 +0000 (14:22 +0000)
committerArtur Signell <artur.signell@itmill.com>
Mon, 2 Nov 2009 14:22:47 +0000 (14:22 +0000)
svn changeset:9575/svn branch:6.2

tests/src/com/vaadin/tests/components/loginform/LoginFormTest.html [new file with mode: 0644]
tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java

diff --git a/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.html b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.html
new file mode 100644 (file)
index 0000000..281e587
--- /dev/null
@@ -0,0 +1,142 @@
+<?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>LoginFormTest</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">LoginFormTest</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.loginform.LoginFormTest?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>undefinedsize</td>
+</tr>
+<tr>
+       <td>enterCharacter</td>
+       <td>username</td>
+       <td>username</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>enterCharacter</td>
+       <td>password</td>
+       <td>password</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>clickAndWait</td>
+       <td>//form[@id='loginf']/div[5]/div/span/span</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
+       <td>User 'username', password='password' logged in</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>loggedin</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>undefinedsize</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>fixed-height</td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>fixed-size</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>waitForVaadin</td>
+       <td></td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>fixed-width</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
index f8e8b96f62b2b222d5f7fb2a82d3b6f6933b6c31..38dea89515a3fc614e25575b8bde981ca5782a5d 100644 (file)
@@ -2,8 +2,10 @@ package com.vaadin.tests.components.loginform;
 
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.LoginForm;
+import com.vaadin.ui.VerticalLayout;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Button.ClickListener;
 import com.vaadin.ui.LoginForm.LoginEvent;
@@ -11,12 +13,17 @@ import com.vaadin.ui.LoginForm.LoginListener;
 
 public class LoginFormTest extends TestBase {
 
+    private HorizontalLayout loginFormLayout;
     private LoginForm loginForm;
 
     @Override
     protected void setup() {
+        loginFormLayout = new HorizontalLayout();
+
         loginForm = new LoginForm();
-        getLayout().setSizeFull();
+        loginForm.setSizeUndefined();
+
+        updateCaption();
         loginForm.addListener(new LoginListener() {
 
             /**
@@ -25,34 +32,81 @@ public class LoginFormTest extends TestBase {
             private static final long serialVersionUID = 1L;
 
             public void onLogin(LoginEvent event) {
-                login(event.getLoginParameter("user"), event
+                login((LoginForm) event.getSource(), event
+                        .getLoginParameter("username"), event
                         .getLoginParameter("password"));
 
             }
         });
-        addComponent(loginForm);
+
+        loginFormLayout.addComponent(loginForm);
+
+        Button changeWidth = new Button("Change width", new ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                if (loginForm.getWidth() < 0) {
+                    loginForm.setWidth("300px");
+                } else {
+                    loginForm.setWidth(null);
+                }
+                updateCaption();
+            }
+        });
+
+        Button changeHeight = new Button("Change height", new ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                if (loginForm.getHeight() < 0) {
+                    loginForm.setHeight("200px");
+                } else {
+                    loginForm.setHeight(null);
+                }
+                updateCaption();
+            }
+        });
+
+        addComponent(loginFormLayout);
+        addComponent(changeWidth);
+        addComponent(changeHeight);
 
     }
 
-    protected void login(String user, String password) {
+    protected void updateCaption() {
+        float width = loginForm.getWidth();
+        float height = loginForm.getHeight();
+
+        String w = width < 0 ? "auto" : (int) width + "px";
+        String h = height < 0 ? "auto" : (int) height + "px";
+
+        loginForm.setCaption("LoginForm (" + w + "/" + h + ")");
+    }
+
+    protected void login(LoginForm loginForm, String user, String password) {
+        VerticalLayout infoLayout = new VerticalLayout();
+
         Label info = new Label("User '" + user + "', password='" + password
                 + "' logged in");
-        getLayout().removeAllComponents();
-        getLayout().addComponent(info);
-        getLayout().addComponent(new Button("Log out", new ClickListener() {
+        Button logoutButton = new Button("Log out", new ClickListener() {
 
             public void buttonClick(ClickEvent event) {
-                getLayout().removeAllComponents();
-                getLayout().addComponent(loginForm);
+                Button b = event.getButton();
+                loginFormLayout.replaceComponent(b.getParent(), (LoginForm) b
+                        .getData());
             }
 
-        }));
+        });
+        logoutButton.setData(loginForm);
+
+        infoLayout.addComponent(info);
+        infoLayout.addComponent(logoutButton);
+
+        loginFormLayout.replaceComponent(loginForm, infoLayout);
 
     }
 
     @Override
     protected String getDescription() {
-        return "Basic test for the LoginForm component. The login form should be visible. Entering a username+password and clicking 'login' should replace the login form with a label telling the user name as password. Also a logout button should then be shown and pressing that takes the user back to the original screen with the LoginForm";
+        return "Basic test for the LoginForm component. Three login forms should be visible (undefined height, undefined width, defined height and width). Entering a username+password in a login form and clicking 'login' should replace the login form with a label telling the user name as password. Also a logout button should then be shown and pressing that takes the user back to the original screen with the LoginForm";
     }
 
     @Override