Author: konstantin.mishin
Date: 2009-04-29 12:59:40 -0400 (Wed, 29 Apr 2009)
New Revision: 13925
Added:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DeleteUseCasesTest.java
Modified:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.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-29
16:18:09 UTC (rev 13924)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java 2009-04-29
16:59:40 UTC (rev 13925)
@@ -56,19 +56,23 @@
String VIEW_SHELFS_PATH = PATH + "/div[2]";
String VIEW_ALBUMS_PATH = PATH + "/div[3]";
String VIEW_IMAGES_PATH = PATH + "/div[4]";
- String ADD_IMAGE_LINK_PATH = PATH +
"/*[@id='menuform:add_icons_div_id']/a[3]";
+ String ADD_GROUP_PATH = PATH +
"/*[@id='menuform:add_icons_div_id']";
+ String ADD_SHELF_LINK_PATH = ADD_GROUP_PATH + "/a[1]";
+ String ADD_ALBUM_LINK_PATH = ADD_GROUP_PATH + "/a[2]";
+ String ADD_IMAGE_LINK_PATH = ADD_GROUP_PATH + "/a[3]";
}
public static interface ShelfArea {
- String HEADER_PATH = "//*[@class='shelf-header-table']";
- String HEADER_NAME_PATH_SUFIX = "//h1";
- String HEADER_NAME_PATH = HEADER_PATH + HEADER_NAME_PATH_SUFIX;
+ String HEADER_PATH =
"xpath=/descendant::*[@class='shelf-header-table']";
+ String HEADER_NAME_PATH_SUFFIX = "//h1//text()";
+ String HEADER_NAME_PATH = HEADER_PATH + HEADER_NAME_PATH_SUFFIX;
String DELETE_BUTTON_PATH =
"//*[@class='shelf-header-table-col2']/a[2]";
}
public static interface AlbumArea {
String HEADER_PATH = "//*[@class='album-header-table']";
- String HEADER_NAME_PATH = HEADER_PATH + "//h1";
+ String HEADER_NAME_PATH_SUFFIX = "//h1//text()";
+ String HEADER_NAME_PATH = HEADER_PATH + HEADER_NAME_PATH_SUFFIX;
String PREVIEW_PATH = "//*[@class='preview_box_album_120']";
String PREVIEW_LINK_PATH_SUFFIX = "//a";
String PREVIEW_NAME_PATH_SUFFIX = "/*[@class='album_name']";
@@ -78,7 +82,8 @@
public static interface ImageArea {
String HEADER_PATH = "//*[@class='image-header-table']";
- String HEADER_NAME_PATH = HEADER_PATH + "//h1";
+ String HEADER_NAME_PATH_SUFFIX = "//h1//text()";
+ String HEADER_NAME_PATH = HEADER_PATH + HEADER_NAME_PATH_SUFFIX;
String PREVIEW_PATH = "//*[@class='preview_box_photo_120']";
String PREVIEW_LINK_PATH_SUFFIX = "//a";
String PREVIEW_NAME_PATH_SUFFIX = "/*[@class='photo_name']";
@@ -150,7 +155,7 @@
Assert.assertTrue(selenium.isVisible(HtmlConstants.ShelfArea.HEADER_PATH));
if (shelfName != null) {
String text =
selenium.getText(RealWorldHelper.HtmlConstants.ShelfArea.HEADER_NAME_PATH);
- Assert.assertTrue(text.contains(shelfName), "Incorrect data was opened on shelf
area.");
+ Assert.assertTrue(text.equals(shelfName), "Incorrect data was opened on shelf
area.");
}
}
@@ -159,10 +164,10 @@
boolean presented = false;
if (shelfName != null) {
int xpathCount =
selenium.getXpathCount(HtmlConstants.ShelfArea.HEADER_PATH).intValue();
- for (int i = 1; i <= xpathCount && !presented; i++) {
- presented = selenium.getText(HtmlConstants.ShelfArea.HEADER_PATH
- + "[" + i + "]" +
HtmlConstants.ShelfArea.HEADER_NAME_PATH_SUFIX)
- .contains(shelfName);
+ for (int i = 2; i <= xpathCount && !presented; i++) {
+ presented = selenium.getText("(" + HtmlConstants.ShelfArea.HEADER_PATH
+ + ")[" + i + "]" +
HtmlConstants.ShelfArea.HEADER_NAME_PATH_SUFFIX)
+ .equals(shelfName);
}
} else {
@@ -191,7 +196,7 @@
for (int i = 1; i <= xpathCount && !presented; i++) {
presented = selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH
+ "[" + i + "]" +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX)
- .contains(albumName);
+ .equals(albumName);
if (presented) {
selenium.click(HtmlConstants.AlbumArea.PREVIEW_PATH + "[" + i +
"]" + HtmlConstants.AlbumArea.PREVIEW_LINK_PATH_SUFFIX);
waitForAjaxCompletion(selenium);
@@ -213,7 +218,7 @@
Assert.assertTrue(selenium.isVisible(HtmlConstants.AlbumArea.HEADER_PATH));
if (albumName != null) {
String text =
selenium.getText(RealWorldHelper.HtmlConstants.AlbumArea.HEADER_NAME_PATH);
- Assert.assertTrue(text.contains(albumName), "Incorrect data was opened on album
area.");
+ Assert.assertTrue(text.equals(albumName), "Incorrect data was opened on album
area.");
}
}
@@ -225,7 +230,7 @@
for (int i = 1; i <= xpathCount && !presented; i++) {
presented = selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH
+ "[" + i + "]" +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX)
- .contains(albumName);
+ .equals(albumName);
}
} else {
@@ -254,7 +259,7 @@
for (int i = 1; i <= xpathCount && !presented; i++) {
presented = selenium.getText(HtmlConstants.ImageArea.PREVIEW_PATH
+ "[" + i + "]" +
HtmlConstants.ImageArea.PREVIEW_NAME_PATH_SUFFIX)
- .contains(imageName);
+ .equals(imageName);
if (presented) {
selenium.click(HtmlConstants.ImageArea.PREVIEW_PATH + "[" + i +
"]" + HtmlConstants.ImageArea.PREVIEW_LINK_PATH_SUFFIX);
waitForAjaxCompletion(selenium);
@@ -275,7 +280,7 @@
Assert.assertTrue(selenium.isVisible(HtmlConstants.ImageArea.HEADER_PATH));
if (imageName != null) {
String text =
selenium.getText(RealWorldHelper.HtmlConstants.ImageArea.HEADER_NAME_PATH);
- Assert.assertTrue(text.contains(imageName), "Incorrect data was opened on image
area.");
+ Assert.assertTrue(text.equals(imageName), "Incorrect data was opened on image
area.");
}
}
@@ -287,7 +292,7 @@
for (int i = 1; i <= xpathCount && !presented; i++) {
presented = selenium.getText(HtmlConstants.ImageArea.PREVIEW_PATH
+ "[" + i + "]" +
HtmlConstants.ImageArea.PREVIEW_NAME_PATH_SUFFIX)
- .contains(imageName);
+ .equals(imageName);
}
} else {
@@ -322,7 +327,7 @@
public static boolean isLogined(Selenium selenium, String name) {
boolean logined =
!selenium.getXpathCount(HtmlConstants.LogInOutArea.USER_INFO_LINK_PATH).equals(0);
if (logined && name != null) {
- logined =
selenium.getText(HtmlConstants.LogInOutArea.USER_INFO_LINK_PATH).contains(name);
+ logined =
selenium.getText(HtmlConstants.LogInOutArea.USER_INFO_LINK_PATH).equals(name);
}
return logined;
}
Added:
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DeleteUseCasesTest.java
===================================================================
---
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DeleteUseCasesTest.java
(rev 0)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/DeleteUseCasesTest.java 2009-04-29
16:59:40 UTC (rev 13925)
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+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;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class DeleteUseCasesTest extends SeleniumTestBase {
+
+ @Test
+ public void testDeleteImage() {
+ renderPage();
+ RealWorldHelper.login(selenium);
+ selenium.click(HtmlConstants.ToolBarArea.VIEW_IMAGES_PATH);
+ waitForAjaxCompletion();
+ String imageName = selenium.getText(HtmlConstants.ImageArea.PREVIEW_PATH +
HtmlConstants.ImageArea.PREVIEW_NAME_PATH_SUFFIX);
+ RealWorldHelper.openImageFromPreview(selenium);
+ RealWorldHelper.deleteCurrentImage(selenium);
+ selenium.click(HtmlConstants.ToolBarArea.VIEW_IMAGES_PATH);
+ waitForAjaxCompletion();
+ Assert.assertFalse(RealWorldHelper.isImagePresentOnPage(selenium, imageName));
+ }
+
+ @Test
+ public void testDeleteAlbum() {
+ renderPage();
+ RealWorldHelper.login(selenium);
+ selenium.click(HtmlConstants.ToolBarArea.VIEW_ALBUMS_PATH);
+ waitForAjaxCompletion();
+ String albumName = selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX);
+ RealWorldHelper.openAlbumFromPreview(selenium);
+ RealWorldHelper.deleteCurrentAlbum(selenium);
+ selenium.click(HtmlConstants.ToolBarArea.VIEW_ALBUMS_PATH);
+ waitForAjaxCompletion();
+ Assert.assertFalse(RealWorldHelper.isAlbumPresentOnPage(selenium, albumName));
+ }
+
+ @Test
+ public void testDeleteShelf() {
+ renderPage();
+ RealWorldHelper.login(selenium);
+ String shelfName = selenium.getText(HtmlConstants.ShelfArea.HEADER_NAME_PATH);
+ RealWorldHelper.deleteCurrentShelf(selenium);
+ Assert.assertFalse(RealWorldHelper.isShelfPresentOnPage(selenium, shelfName));
+ }
+}
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-29
16:18:09 UTC (rev 13924)
+++
trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/OpenAreasUseCasesTest.java 2009-04-29
16:59:40 UTC (rev 13925)
@@ -3,8 +3,6 @@
*/
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;
@@ -67,46 +65,4 @@
waitForAjaxCompletion();
RealWorldHelper.testImageArea(selenium);
}
-
- @Test
- public void testDeleteImage() {
- renderPage();
- RealWorldHelper.login(selenium);
- selenium.click(HtmlConstants.ToolBarArea.VIEW_IMAGES_PATH);
- waitForAjaxCompletion();
- String imageName = selenium.getText(HtmlConstants.ImageArea.PREVIEW_PATH +
HtmlConstants.ImageArea.PREVIEW_NAME_PATH_SUFFIX);
- RealWorldHelper.openImageFromPreview(selenium);
- RealWorldHelper.deleteCurrentImage(selenium);
- selenium.click(HtmlConstants.ToolBarArea.VIEW_IMAGES_PATH);
- waitForAjaxCompletion();
- Assert.assertFalse(RealWorldHelper.isImagePresentOnPage(selenium, imageName));
- }
-
- @Test
- public void testDeleteAlbum() {
- renderPage();
- RealWorldHelper.login(selenium);
- selenium.click(HtmlConstants.ToolBarArea.VIEW_ALBUMS_PATH);
- waitForAjaxCompletion();
- String albumName = selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX);
- RealWorldHelper.openAlbumFromPreview(selenium);
- RealWorldHelper.deleteCurrentAlbum(selenium);
- selenium.click(HtmlConstants.ToolBarArea.VIEW_ALBUMS_PATH);
- waitForAjaxCompletion();
- Assert.assertFalse(RealWorldHelper.isAlbumPresentOnPage(selenium, albumName));
- }
-
- //TODO @Test
- public void testDeleteShelf() {
- renderPage();
- RealWorldHelper.login(selenium);
- selenium.click(HtmlConstants.ToolBarArea.VIEW_ALBUMS_PATH);
- waitForAjaxCompletion();
- String albumName = selenium.getText(HtmlConstants.AlbumArea.PREVIEW_PATH +
HtmlConstants.AlbumArea.PREVIEW_NAME_PATH_SUFFIX);
- RealWorldHelper.openAlbumFromPreview(selenium);
- RealWorldHelper.deleteCurrentAlbum(selenium);
- selenium.click(HtmlConstants.ToolBarArea.VIEW_ALBUMS_PATH);
- waitForAjaxCompletion();
- Assert.assertFalse(RealWorldHelper.isAlbumPresentOnPage(selenium, albumName));
- }
}
Show replies by date