Author: konstantin.mishin
Date: 2008-05-23 11:10:59 -0400 (Fri, 23 May 2008)
New Revision: 8733
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/spacer/
trunk/test-applications/seleniumTest/src/main/webapp/pages/spacer/spacerTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SpacerTest.java
Log:
add spacer test
Added: trunk/test-applications/seleniumTest/src/main/webapp/pages/spacer/spacerTest.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/src/main/webapp/pages/spacer/spacerTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/spacer/spacerTest.xhtml 2008-05-23
15:10:59 UTC (rev 8733)
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.template}">
+ <ui:define name="component">
+ <style>
+ .sp {
+ color: red;
+ }
+ </style>
+ <rich:spacer id="sp" styleClass="sp" style="border: solid
1px green;" width="1" height="5" title="Here is a
spacer..."/>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SpacerTest.java
===================================================================
--- trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SpacerTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/SpacerTest.java 2008-05-23
15:10:59 UTC (rev 8733)
@@ -0,0 +1,123 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces;
+
+import org.ajax4jsf.test.base.RichSeleniumTest;
+import org.ajax4jsf.test.base.SeleniumTestBase;
+import org.ajax4jsf.test.base.Templates;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+public class SpacerTest extends SeleniumTestBase implements RichSeleniumTest {
+
+ public SpacerTest() {
+ super("http", "localhost", "8080");
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeTest
+ @Parameters( { "browser" })
+ public void startSelenium(String browser) {
+ super.startSelenium(browser);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterTest
+ public void stopSelenium() {
+ super.stopSelenium();
+ }
+
+ @Test
+ public void testSimpleTogglePanelComponent() throws Exception {
+ _testSimpleTogglePanelComponent(Templates.SIMPLE);
+ _testSimpleTogglePanelComponent(Templates.DATATABLE);
+ _testSimpleTogglePanelComponent(Templates.MODALPANEL);
+ }
+
+ private void _testSimpleTogglePanelComponent(Templates template) {
+ renderPage(getTestUrl(), template);
+ String parentId = getParentId();
+ String spacerId = parentId + "sp";
+
+ writeStatus("Check width ");
+ assertWidth(1 + 2, spacerId);
+
+ writeStatus("Check height ");
+ assertHeight(5 + 2, spacerId);
+
+ writeStatus("Check styleClass ");
+ assertStyleClass("sp", spacerId);
+
+ writeStatus("Check style ");
+ assertStyleClass("border: solid 1px green;", spacerId);
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/spacer/spacerTest.xhtml";
+ }
+
+ private void assertWidth(int width, String spacerId) {
+ StringBuffer script = new StringBuffer(" document.getElementById('");
+ script.append(spacerId);
+ script.append("').offsetWidth");
+
+ String w = runScript(script.toString());
+ Assert.assertEquals(w, String.valueOf(width));
+ }
+
+ private void assertHeight(int height, String spacerId) {
+ StringBuffer script = new StringBuffer(" document.getElementById('");
+ script.append(spacerId);
+ script.append("').offsetHeight");
+
+ String h = runScript(script.toString());
+ Assert.assertEquals(h, String.valueOf(height));
+ }
+
+ private void assertStyleClass(String styleClass, String spacerId) {
+ StringBuffer script = new StringBuffer(" document.getElementById('");
+ script.append(spacerId);
+ script.append("').className");
+
+ String sc = runScript(script.toString());
+ if (sc != null) {
+ Assert.assertTrue(sc.endsWith("sp"));
+ } else {
+ Assert.fail("ClassName is null");
+ }
+ }
+ private void assertStyle(String style, String spacerId) {
+ StringBuffer script = new StringBuffer(" document.getElementById('");
+ script.append(spacerId);
+ script.append("').style");
+
+ String s = runScript(script.toString());
+ Assert.assertEquals(s, style);
+ }
+}