Author: konstantin.mishin
Date: 2009-04-30 10:49:05 -0400 (Thu, 30 Apr 2009)
New Revision: 13971
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/OpenAreasUseCasesTest.java
Log:
RF-6909
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java 2009-04-30
14:35:30 UTC (rev 13970)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java 2009-04-30
14:49:05 UTC (rev 13971)
@@ -46,8 +46,10 @@
}
public static interface LogInOutArea {
+ String PATH = "xpath=id('logInOutMenu')";
String LOGIN_LINK_ID = "loginPanelShowlink";
- String LOGOUT_LINK_PATH = "//*[@id='logInOutMenu']//div/a";
+ String REGISTER_LINK_PATH = PATH + "/descendant::a[2]";
+ String LOGOUT_LINK_PATH = REGISTER_LINK_PATH;
String USER_INFO_LINK_PATH = "//a[@class='logged-user']";
}
@@ -92,6 +94,13 @@
public static interface UserProfileArea {
String NAME_INPUT_ID = IndexPage.MAIN_FORM_ID + ":loginName";
+ String PASSWORD_INPUT_ID = IndexPage.MAIN_FORM_ID + ":password";
+ String CONFIRM_PASSWORD_INPUT_ID = IndexPage.MAIN_FORM_ID +
":confirmPassword";
+ String FIRST_NAME_INPUT_ID = IndexPage.MAIN_FORM_ID + ":firstname";
+ String SECOND_NAME_INPUT_ID = IndexPage.MAIN_FORM_ID + ":secondname";
+ String BIRTH_DATE_INPUT_ID = IndexPage.MAIN_FORM_ID +
":birthDateInputDate";
+ String EMAIL_INPUT_ID = IndexPage.MAIN_FORM_ID + ":email";
+ String REGISTER_BUTTON_PATH =
"//*[@class='content_box']/descendant::*[@class='photoalbumButton'][1]//input";
}
public static interface FilesUploadArea {
@@ -103,8 +112,11 @@
}
}
+ public static void login(Selenium selenium) {
+ login(selenium, UserInfoConstants.LOGIN_NAME, UserInfoConstants.LOGIN_PASSWORD);
+ }
- public static void login(Selenium selenium) {
+ public static void login(Selenium selenium, String name, String password) {
selenium.click(HtmlConstants.LogInOutArea.LOGIN_LINK_ID);
try {
Thread.sleep(5000);
@@ -120,8 +132,8 @@
Assert.fail("Password input should be of 'password' type");
}
- selenium.type(HtmlConstants.LoginPanel.usernameId, UserInfoConstants.LOGIN_NAME);
- selenium.type(HtmlConstants.LoginPanel.passwordId, UserInfoConstants.LOGIN_PASSWORD);
+ selenium.type(HtmlConstants.LoginPanel.usernameId, name);
+ selenium.type(HtmlConstants.LoginPanel.passwordId, password);
selenium.click(HtmlConstants.LoginPanel.loginButtonPath);
waitForAjaxCompletion(selenium);
@@ -139,10 +151,16 @@
}
public static void testUserProfile(Selenium selenium) {
- String name = selenium.getValue(HtmlConstants.UserProfileArea.NAME_INPUT_ID);
- Assert.assertEquals(name, UserInfoConstants.LOGIN_NAME);
+ testUserProfile(selenium, null);
}
+ public static void testUserProfile(Selenium selenium, String name) {
+ Assert.assertTrue(selenium.isVisible(HtmlConstants.UserProfileArea.NAME_INPUT_ID));
+ if (name != null) {
+ Assert.assertEquals(selenium.getValue(HtmlConstants.UserProfileArea.NAME_INPUT_ID),
name);
+ }
+ }
+
public static void testFilesUpload(Selenium selenium) {
Assert.assertTrue(selenium.isVisible(HtmlConstants.FilesUploadArea.FILE_UPLOAD_ID));
}
@@ -184,13 +202,10 @@
}
public static void openAlbumFromPreview(Selenium selenium) {
- openAlbumFromPreview(selenium, null);
+ openAlbumFromPreview(selenium, selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX));
}
public static void openAlbumFromPreview(Selenium selenium, String albumName) {
- if (albumName == null) {
- albumName = selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX);
- }
boolean presented = false;
int xpathCount =
selenium.getXpathCount(HtmlConstants.AlbumArea.PREVIEW_PATH).intValue();
for (int i = 1; i <= xpathCount && !presented; i++) {
@@ -247,13 +262,10 @@
}
public static void openImageFromPreview(Selenium selenium) {
- openImageFromPreview(selenium, null);
+ openImageFromPreview(selenium, selenium.getText(HtmlConstants.ImageArea.PREVIEW_PATH +
HtmlConstants.ImageArea.PREVIEW_NAME_PATH_SUFFIX));
}
public static void openImageFromPreview(Selenium selenium, String imageName) {
- if (imageName == null) {
- imageName = selenium.getText(HtmlConstants.ImageArea.PREVIEW_PATH +
HtmlConstants.ImageArea.PREVIEW_NAME_PATH_SUFFIX);
- }
boolean presented = false;
int xpathCount =
selenium.getXpathCount(HtmlConstants.ImageArea.PREVIEW_PATH).intValue();
for (int i = 1; i <= xpathCount && !presented; i++) {
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java 2009-04-30
14:35:30 UTC (rev 13970)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/LoginTest.java 2009-04-30
14:49:05 UTC (rev 13971)
@@ -3,8 +3,11 @@
*/
package org.richfaces.photoalbum.testng;
+import junit.framework.Assert;
+
import org.richfaces.photoalbum.RealWorldHelper;
import org.richfaces.photoalbum.SeleniumTestBase;
+import org.richfaces.photoalbum.RealWorldHelper.HtmlConstants;
import org.testng.annotations.Test;
/**
@@ -21,4 +24,24 @@
RealWorldHelper.login(selenium);
RealWorldHelper.logout(selenium);
}
+
+ @Test
+ public void testRegistration() {
+ renderPage();
+ String name = "New user";
+ String password = "pass";
+ selenium.click(HtmlConstants.LogInOutArea.REGISTER_LINK_PATH);
+ waitForAjaxCompletion();
+ RealWorldHelper.testUserProfile(selenium);
+ selenium.type(HtmlConstants.UserProfileArea.NAME_INPUT_ID, name);
+ selenium.type(HtmlConstants.UserProfileArea.PASSWORD_INPUT_ID, password);
+ selenium.type(HtmlConstants.UserProfileArea.CONFIRM_PASSWORD_INPUT_ID, password);
+ selenium.type(HtmlConstants.UserProfileArea.FIRST_NAME_INPUT_ID, "first");
+ selenium.type(HtmlConstants.UserProfileArea.SECOND_NAME_INPUT_ID, "second");
+ selenium.type(HtmlConstants.UserProfileArea.BIRTH_DATE_INPUT_ID, "Jan 1,
1");
+ selenium.type(HtmlConstants.UserProfileArea.EMAIL_INPUT_ID,
"user(a)exadel.com");
+ selenium.click(HtmlConstants.UserProfileArea.REGISTER_BUTTON_PATH);
+ waitForAjaxCompletion();
+ Assert.assertTrue(RealWorldHelper.isLogined(selenium, name));
+ }
}
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/OpenAreasUseCasesTest.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/OpenAreasUseCasesTest.java 2009-04-30
14:35:30 UTC (rev 13970)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/OpenAreasUseCasesTest.java 2009-04-30
14:49:05 UTC (rev 13971)
@@ -6,6 +6,7 @@
import org.richfaces.photoalbum.RealWorldHelper;
import org.richfaces.photoalbum.SeleniumTestBase;
import org.richfaces.photoalbum.RealWorldHelper.HtmlConstants;
+import org.richfaces.photoalbum.RealWorldHelper.UserInfoConstants;
import org.testng.annotations.Test;
/**
@@ -35,7 +36,7 @@
RealWorldHelper.login(selenium);
selenium.click(HtmlConstants.LogInOutArea.USER_INFO_LINK_PATH);
waitForAjaxCompletion();
- RealWorldHelper.testUserProfile(selenium);
+ RealWorldHelper.testUserProfile(selenium, UserInfoConstants.LOGIN_NAME);
}
@Test