Author: alevkovsky
Date: 2008-06-30 12:01:11 -0400 (Mon, 30 Jun 2008)
New Revision: 9306
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxMediaOutput/
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxMediaOutput/ajaxMediaOutputTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxMediaOutputTest.java
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/Media.java
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaBean.java
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaData.java
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
Log:
Add a4j:mediaOutput selenium test
Modified: trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/Media.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/Media.java 2008-06-30
14:26:16 UTC (rev 9305)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/Media.java 2008-06-30
16:01:11 UTC (rev 9306)
@@ -3,15 +3,12 @@
import java.io.IOException;
import java.io.OutputStream;
-
public interface Media {
- public void paint(OutputStream out, Object data) throws IOException;
+ public void paint(OutputStream out, Object data) throws IOException;
- public void initData();
+ public void setData(MediaData data);
- public void setData(MediaData data);
+ public MediaData getData();
- public MediaData getData();
-
}
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaBean.java 2008-06-30
14:26:16 UTC (rev 9305)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaBean.java 2008-06-30
16:01:11 UTC (rev 9306)
@@ -8,48 +8,65 @@
import javax.imageio.ImageIO;
-
public class MediaBean implements Media {
-
- private MediaData data;
- /**
- * @return the data
- */
- public MediaData getData() {
- return data;
- }
+ private MediaData data = new MediaData();
+ private MediaData data2 = new MediaData(50, 10, Color.BLACK, Color.WHITE);
- /**
- * @param data the data to set
- */
- public void setData(MediaData data) {
- this.data = data;
- }
-
- public void initData(){
- data= new MediaData();
- data.setWidth(100);
- data.setHeight(100);
- data.setBackground(Color.BLUE);
- data.setDrawColor(Color.RED);
- }
+
+ /**
+ * @return the data2
+ */
+ public MediaData getData2() {
+ return data2;
+ }
- public void paint(OutputStream out, Object data) throws IOException{
- if (data instanceof MediaData) {
-
- MediaData paintData = (MediaData) data;
- BufferedImage img = new
BufferedImage(paintData.getWidth(),paintData.getHeight(),BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics2D = img.createGraphics();
- graphics2D.setBackground(paintData.getBackground());
- graphics2D.setColor(paintData.getDrawColor());
- graphics2D.clearRect(0,0,paintData.getWidth(),paintData.getHeight());
- graphics2D.drawLine(5,5,paintData.getWidth()-5,paintData.getHeight()-5);
- graphics2D.drawChars(new String("RichFaces").toCharArray(),0,9,40,15);
- graphics2D.drawChars(new String("mediaOutput").toCharArray(),0,11,5,45);
-
- ImageIO.write(img,"jpeg",out);
-
- }
+ /**
+ * @param data2 the data2 to set
+ */
+ public void setData2(MediaData data2) {
+ this.data2 = data2;
+ }
+
+ /**
+ * @return the data
+ */
+ public MediaData getData() {
+ return data;
+ }
+
+ /**
+ * @param data
+ * the data to set
+ */
+ public void setData(MediaData data) {
+ this.data = data;
+ }
+
+ public String reInitData() {
+ data = new MediaData(200, 200, Color.WHITE, Color.BLACK);
+ return null;
+ }
+
+ public String resetData() {
+ data = new MediaData();
+ return null;
+ }
+
+ public void paint(OutputStream out, Object data) throws IOException {
+ if (data instanceof MediaData) {
+
+ MediaData paintData = (MediaData) data;
+ BufferedImage img = new BufferedImage(paintData.getWidth(), paintData.getHeight(),
BufferedImage.TYPE_INT_RGB);
+ Graphics2D graphics2D = img.createGraphics();
+ graphics2D.setBackground(paintData.getBackground());
+ graphics2D.setColor(paintData.getDrawColor());
+ graphics2D.clearRect(0, 0, paintData.getWidth(), paintData.getHeight());
+ graphics2D.drawChars(new String("mediaOutput").toCharArray(), 0, 11, 5,
35);
+ graphics2D.drawChars(new String("selenium test").toCharArray(), 0, 13, 5,
55);
+
+ ImageIO.write(img, "jpeg", out);
+
}
+ }
}
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaData.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaData.java 2008-06-30
14:26:16 UTC (rev 9305)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/MediaData.java 2008-06-30
16:01:11 UTC (rev 9306)
@@ -3,37 +3,86 @@
import java.awt.Color;
import java.io.Serializable;
-public class MediaData implements Serializable{
+public class MediaData implements Serializable {
- private static final long serialVersionUID = 1L;
- Integer Width=110;
- Integer Height=50;
- Color Background=new Color(0,0,0);
- Color DrawColor=new Color(255,255,255);
- public MediaData() {
- }
- public Color getBackground() {
- return Background;
- }
- public void setBackground(Color background) {
- Background = background;
- }
- public Color getDrawColor() {
- return DrawColor;
- }
- public void setDrawColor(Color drawColor) {
- DrawColor = drawColor;
- }
- public Integer getHeight() {
- return Height;
- }
- public void setHeight(Integer height) {
- Height = height;
- }
- public Integer getWidth() {
- return Width;
- }
- public void setWidth(Integer width) {
- Width = width;
- }
+ private static final long serialVersionUID = 1L;
+
+ Integer width;
+
+ Integer height;
+
+ Color background;
+
+ Color drawColor;
+
+ public MediaData() {
+ this.width = 100;
+ this.height = 100;
+ background = Color.BLACK;
+ drawColor = Color.WHITE;
+ }
+
+ public MediaData(Integer width, Integer height, Color background, Color drawColor) {
+ this.width = width;
+ this.height = height;
+ this.background = background;
+ this.drawColor = drawColor;
+ }
+
+ /**
+ * @return the width
+ */
+ public Integer getWidth() {
+ return width;
+ }
+
+ /**
+ * @param width the width to set
+ */
+ public void setWidth(Integer width) {
+ this.width = width;
+ }
+
+ /**
+ * @return the height
+ */
+ public Integer getHeight() {
+ return height;
+ }
+
+ /**
+ * @param height the height to set
+ */
+ public void setHeight(Integer height) {
+ this.height = height;
+ }
+
+ /**
+ * @return the background
+ */
+ public Color getBackground() {
+ return background;
+ }
+
+ /**
+ * @param background the background to set
+ */
+ public void setBackground(Color background) {
+ this.background = background;
+ }
+
+ /**
+ * @return the drawColor
+ */
+ public Color getDrawColor() {
+ return drawColor;
+ }
+
+ /**
+ * @param drawColor the drawColor to set
+ */
+ public void setDrawColor(Color drawColor) {
+ this.drawColor = drawColor;
+ }
+
}
\ No newline at end of file
Modified: trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-06-30
14:26:16 UTC (rev 9305)
+++
trunk/test-applications/seleniumTest/src/main/webapp/WEB-INF/faces-config.xml 2008-06-30
16:01:11 UTC (rev 9306)
@@ -141,6 +141,11 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>a4jMediaBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.MediaBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>calendarBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.CalendarTestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxMediaOutput/ajaxMediaOutputTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxMediaOutput/ajaxMediaOutputTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-06-30
14:26:16 UTC (rev 9305)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SeleniumTestBase.java 2008-06-30
16:01:11 UTC (rev 9306)
@@ -699,9 +699,87 @@
}
}
+
+ public void testOnclickEvent(String testElementId, String testElementResultId, String
beforeResult, String afterResult) {
+ writeStatus("Testing onclick event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.click(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+ public void testOnDblclickEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing ondblclick event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.doubleClick(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnfocusEvent(String testElementId, String testElementResultId, String
beforeResult, String afterResult) {
+ writeStatus("Testing onfocus event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.focus(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnkeydownEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing onkeydown event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.keyDown(testElementId, "1");
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnkeypressEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing onkeypress event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.keyPress(testElementId, "1");
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnkeyupEvent(String testElementId, String testElementResultId, String
beforeResult, String afterResult) {
+ writeStatus("Testing onkeyup event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.keyUp(testElementId, "1");
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnmousedownEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing onmousedown event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.mouseDown(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnmousemoveEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing onmousemove event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.mouseMove(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnmouseoutEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing onmouseout event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.mouseOut(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnmouseoverEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing onmouseover event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.mouseOver(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
+ public void testOnmouseupEvent(String testElementId, String testElementResultId,
String beforeResult, String afterResult) {
+ writeStatus("Testing onmouseup event");
+ AssertTextEquals(testElementResultId, beforeResult);
+ selenium.mouseUp(testElementId);
+ AssertTextEquals(testElementResultId, afterResult);
+ }
+
/**
* Checks whether client is FireFox
+ *
* @return true if client is FireFox
*/
public boolean isFF() {
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxMediaOutputTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxMediaOutputTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxMediaOutputTest.java 2008-06-30
16:01:11 UTC (rev 9306)
@@ -0,0 +1,108 @@
+/*
+ * AjaxMediaOutputTest.java Date created: 26.06.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces.testng;
+
+import junit.framework.Assert;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.annotations.Test;
+
+/**
+ * ajaxMediaOutput component selenium test
+ * @author Alexandr Levkovsky
+ *
+ */
+public class AjaxMediaOutputTest extends SeleniumTestBase {
+
+ private final static String FORM_ID = "form:";
+ private final static String IMAGE_ID = FORM_ID + "media_data";
+ private final static String IMAGE_EVENT_ID = FORM_ID +
"media_data_event_";
+ private final static String EVENT_RESULT_ID = "_result";
+ private final static String EVENT_TEST_RESULT_FAILED_TEXT = "No";
+ private final static String EVENT_TEST_RESULT_PASSED_TEXT = "Passed";
+ /**
+ * @see org.richfaces.SeleniumTestBase#getTestUrl()
+ */
+ @Override
+ public String getTestUrl() {
+ return "pages/ajaxMediaOutput/ajaxMediaOutputTest.xhtml";
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAjaxMediaOutput(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing media output");
+
+ String imageId = getParentId() + IMAGE_ID;
+
+ AssertPresent(imageId);
+
+ String tagName = runScript("getElementType('" + imageId
+"');");
+ Assert.assertEquals(tagName.toLowerCase(), "img");
+
+
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnclickEvent(Template template) throws Exception {
+ renderPage(template);
+ String imageId = getParentId() + IMAGE_EVENT_ID + 1;
+ super.testOnclickEvent(imageId, imageId + EVENT_RESULT_ID,
EVENT_TEST_RESULT_FAILED_TEXT, EVENT_TEST_RESULT_PASSED_TEXT);
+ runScript("resetEventTestResult('" + imageId + EVENT_RESULT_ID +
"');");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnDblclickEvent(Template template) throws Exception {
+ renderPage(template);
+ String imageId = getParentId() + IMAGE_EVENT_ID + 2;
+ super.testOnDblclickEvent(imageId, imageId + EVENT_RESULT_ID,
EVENT_TEST_RESULT_FAILED_TEXT, EVENT_TEST_RESULT_PASSED_TEXT);
+ runScript("resetEventTestResult('" + imageId + EVENT_RESULT_ID +
"');");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousedownEvent(Template template) throws Exception {
+ renderPage(template);
+ String imageId = getParentId() + IMAGE_EVENT_ID + 7;
+ super.testOnmousedownEvent(imageId, imageId + EVENT_RESULT_ID,
EVENT_TEST_RESULT_FAILED_TEXT, EVENT_TEST_RESULT_PASSED_TEXT);
+ runScript("resetEventTestResult('" + imageId + EVENT_RESULT_ID +
"');");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousemoveEvent(Template template) throws Exception {
+ renderPage(template);
+ String imageId = getParentId() + IMAGE_EVENT_ID + 8;
+ super.testOnmousemoveEvent(imageId, imageId + EVENT_RESULT_ID,
EVENT_TEST_RESULT_FAILED_TEXT, EVENT_TEST_RESULT_PASSED_TEXT);
+ runScript("resetEventTestResult('" + imageId + EVENT_RESULT_ID +
"');");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseoutEvent(Template template) throws Exception {
+ renderPage(template);
+ String imageId = getParentId() + IMAGE_EVENT_ID + 9;
+ super.testOnmouseoutEvent(imageId, imageId + EVENT_RESULT_ID,
EVENT_TEST_RESULT_FAILED_TEXT, EVENT_TEST_RESULT_PASSED_TEXT);
+ runScript("resetEventTestResult('" + imageId + EVENT_RESULT_ID +
"');");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseoverEvent(Template template) throws Exception {
+ renderPage(template);
+ String imageId = getParentId() + IMAGE_EVENT_ID + 10;
+ super.testOnmouseoverEvent(imageId, imageId + EVENT_RESULT_ID,
EVENT_TEST_RESULT_FAILED_TEXT, EVENT_TEST_RESULT_PASSED_TEXT);
+ runScript("resetEventTestResult('" + imageId + EVENT_RESULT_ID +
"');");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseupEvent(Template template) throws Exception {
+ renderPage(template);
+ String imageId = getParentId() + IMAGE_EVENT_ID + 11;
+ super.testOnmouseupEvent(imageId, imageId + EVENT_RESULT_ID,
EVENT_TEST_RESULT_FAILED_TEXT, EVENT_TEST_RESULT_PASSED_TEXT);
+ runScript("resetEventTestResult('" + imageId + EVENT_RESULT_ID +
"');");
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxMediaOutputTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native