[richfaces-svn-commits] JBoss Rich Faces SVN: r14010 - in trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum: testng and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon May 4 12:31:50 EDT 2009


Author: Alex.Kolonitsky
Date: 2009-05-04 12:31:50 -0400 (Mon, 04 May 2009)
New Revision: 14010

Added:
   trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/ImageResizerTest.java
Modified:
   trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java
Log:
add ImageResizerTest

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-05-04 16:29:31 UTC (rev 14009)
+++ trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/RealWorldHelper.java	2009-05-04 16:31:50 UTC (rev 14010)
@@ -123,6 +123,11 @@
 
 		}
 
+		public static interface ResizeSlider {
+			String TRACK_SLIDER = "//td[./div[@class='dr-insldr-track rich-inslider-track']]";
+			String SLIDER_INPUT = "//*[@class='dr-insldr rich-slider']//input[@type='hidden']";
+		}
+
 		public static interface Search {
 			String SEARCH_INPUT = "//*[@class='search-input']";
 			String SEARCH_BUTTON = "//*[@class='search-find-button']";

Added: trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/ImageResizerTest.java
===================================================================
--- trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/ImageResizerTest.java	                        (rev 0)
+++ trunk/examples/photoalbum/tests/src/test/java/org/richfaces/photoalbum/testng/ImageResizerTest.java	2009-05-04 16:31:50 UTC (rev 14010)
@@ -0,0 +1,60 @@
+package org.richfaces.photoalbum.testng;
+
+import org.richfaces.photoalbum.SeleniumTestBase;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+import static org.richfaces.photoalbum.RealWorldHelper.HtmlConstants.ResizeSlider.*;
+
+/**
+ * @user: akolonitsky
+ * Date: May 4, 2009
+ */
+public class ImageResizerTest extends SeleniumTestBase {
+
+	private static final int LENGTH = 200;
+	
+	private static final int VALUE_START = 80;
+	private static final int VALUE_STEP = 40;
+	private static final int VALUE_END = 200;
+
+	private static final int VALUE_DEFAULT = 120;
+
+	@Test
+	public void testResize() {
+		renderPage();
+
+		selenium.click("//*[@class='album-cover-image'][1]");
+		waitForAjaxCompletion();
+
+		final int count = getImageCount(VALUE_DEFAULT);
+
+		for (int i = 0; i < (VALUE_END-VALUE_START)/VALUE_STEP; i++) {
+			testPosition(count, i);
+		}
+	}
+
+	private void testPosition(final int count, final int position) {
+		final int value = VALUE_START + position * VALUE_STEP;
+
+		clickSlider(position);
+		waitForAjaxCompletion();
+		Assert.assertEquals(value, getSliderValue());
+		Assert.assertEquals(count, getImageCount(value));
+	}
+
+	private int getImageCount(final int value) {
+		return selenium.getXpathCount("//*[@class='preview_box_photo_"+value+"']").intValue();
+	}
+
+	private void clickSlider(int position) {
+		final String track = TRACK_SLIDER;
+		final String coords = (LENGTH * VALUE_STEP / (VALUE_END - VALUE_START) * position + 1) + ",1";
+		selenium.mouseDownAt(track, coords);
+		selenium.mouseUpAt(track, coords);
+	}
+
+	private int getSliderValue() {
+		return Integer.parseInt(selenium.getValue(SLIDER_INPUT));
+	}
+}




More information about the richfaces-svn-commits mailing list