From b15f3930c15356abc607658baf78bc8759578887 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 2 Nov 2009 14:22:47 +0000 Subject: [PATCH] Merged (partly by hand) [9399] svn changeset:9575/svn branch:6.2 --- .../components/loginform/LoginFormTest.html | 142 ++++++++++++++++++ .../components/loginform/LoginFormTest.java | 76 ++++++++-- 2 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 tests/src/com/vaadin/tests/components/loginform/LoginFormTest.html 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 index 0000000000..281e587abf --- /dev/null +++ b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.html @@ -0,0 +1,142 @@ + + + + + + +LoginFormTest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LoginFormTest
open/run/com.vaadin.tests.components.loginform.LoginFormTest?restartApplication
screenCaptureundefinedsize
enterCharacterusernameusername
waitForVaadin
enterCharacterpasswordpassword
waitForVaadin
clickAndWait//form[@id='loginf']/div[5]/div/span/span
waitForVaadin
assertTextvaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]User 'username', password='password' logged in
screenCaptureloggedin
waitForVaadin
clickvaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]
waitForVaadin
screenCaptureundefinedsize
waitForVaadin
clickvaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
screenCapturefixed-height
waitForVaadin
clickvaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
screenCapturefixed-size
clickvaadin=runcomvaadintestscomponentsloginformLoginFormTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
screenCapturefixed-width
+ + diff --git a/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java index f8e8b96f62..38dea89515 100644 --- a/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java +++ b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java @@ -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 -- 2.39.5