Author: dsvyatobatsko
Date: 2008-10-23 13:57:42 -0400 (Thu, 23 Oct 2008)
New Revision: 10889
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelBarItem/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelBarItem/panelBarItemAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelBarItem/panelBarItemTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelBarItemTest.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
Log:
PanelBarItem tests
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelBarItem/panelBarItemAutoTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelBarItem/panelBarItemAutoTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelBarItem/panelBarItemTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelBarItem/panelBarItemTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-10-23
16:51:04 UTC (rev 10888)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-10-23
17:57:42 UTC (rev 10889)
@@ -939,8 +939,46 @@
}
}
+ public void assertStyleAttributeContains(String locator, String expectedExpression,
String message) {
+ assertAttributeContains(locator, "style", expectedExpression,
message);
+ }
+ public void assertClassAttributeContains(String locator, String expectedExpression,
String message) {
+ assertAttributeContains(locator, "class", expectedExpression,
message);
+ }
+
/**
+ * Asserts that element attribute with given name <code>attrName</code>
contains <code>expectedExpression</code>
+ * @param locator id or xpath expression locating element
+ * @param attrName attribute name
+ * @param expectedExpression expected expression
+ * @param message failure message
+ */
+ public void assertAttributeContains(String locator, String attrName, String
expectedExpression, String message) {
+ if (null == locator) {
+ throw new NullPointerException("locator cannot be null");
+ }
+
+ // //div[contains(@style, "font-size: 14px") and contains(@class,
"dr-pnlbar-c rich-panelbar-content")]
+ String xpath = "";
+ if (locator.startsWith("//")) {
+ xpath = locator + String.format("[contains(@%1$s,
\"%2$s\")]", attrName, expectedExpression);
+ } else {
+ xpath = String.format("[contains(@%1$s, \"%2$s\") and
@id=\"%3$s\"]", attrName, expectedExpression, locator);
+ }
+
+ if (selenium.getXpathCount(xpath).intValue() == 0) {
+ String failureMsg = String.format(
+ "Attribute [%1$s] of element [%2$s] doesn't contain expected
expression [%3$s]", attrName, locator,
+ expectedExpression);
+ if (null != message && !"".equals(message.trim())) {
+ failureMsg = message + ": " + failureMsg;
+ }
+ Assert.fail(failureMsg);
+ }
+ }
+
+ /**
* Asserts that expected columns count equals actual one.
* @param i the expected columns count
* @param tableId id of table to be checked
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelBarItemTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelBarItemTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelBarItemTest.java 2008-10-23
17:57:42 UTC (rev 10889)
@@ -0,0 +1,96 @@
+/**
+ * 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.testng;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
+import org.richfaces.SeleniumTestBase;
+import org.testng.annotations.Test;
+
+public class PanelBarItemTest extends SeleniumTestBase {
+
+ private static final String PANEL_BAR_ITEM_ID = "panelBarItemId";
+
+ @Test
+ public void testRenderedAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, null);
+ writeStatus("Test component with rendered = false is not present on the
page");
+ tester.testRendered();
+ }
+
+ @Test
+ public void testJSEventFiring(Template template) {
+ renderPage(template);
+
+ writeStatus("Check onenter/onleave events are fired ");
+
+ String parentId = getParentId() + "_form:";
+
+ List<String> eventsExpected = new ArrayList<String>();
+ assertEvents(eventsExpected);
+
+ writeStatus("Leave panel. Onleave event must be triggered");
+ clickById(parentId + "label2");
+
+ eventsExpected.add("onleave");
+ assertEvents(eventsExpected);
+
+ writeStatus("Enter panel once more. Onenter event must be triggered");
+ clickById(parentId + "label1");
+
+ eventsExpected.add("onenter");
+ assertEvents(eventsExpected);
+ }
+
+ @Test
+ public void testStyleAndClassesAreOutputToClient(Template template) {
+ renderPage(template);
+
+ writeStatus("Check style and classes are output to client");
+
+ String compDivId = getParentId() + "_form:" + PANEL_BAR_ITEM_ID;
+ String contentElemXpath = "//div[@id='" + compDivId +
"']/div[3]/table/tbody/tr/td";
+ assertClassAttributeContains(contentElemXpath, "content-class",
"contentClass attribute was not output to client");
+ assertStyleAttributeContains(contentElemXpath, "font-size: 14px",
"contentStyle attribute was not output to client");
+
+ String headerElementXpath = "//div[@id='" + compDivId +
"']/div[1]";
+ assertClassAttributeContains(headerElementXpath, "header-class",
"headerClass attribute was not output to client");
+ assertStyleAttributeContains(headerElementXpath, "font-size: 13px",
"headerStyle attribute was not output to client");
+
+ String activeHeaderElementXpath = "//div[@id='" + compDivId +
"']/div[2]";
+ assertClassAttributeContains(activeHeaderElementXpath,
"header-class-active", "headerClassActive attribute was not output to
client");
+ assertStyleAttributeContains(activeHeaderElementXpath, "font-size:
12px", "headerStyleActive attribute was not output to client");
+ }
+
+ public String getTestUrl() {
+ return "pages/panelBarItem/panelBarItemTest.xhtml";
+ }
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/panelBarItem/panelBarItemAutoTest.xhtml";
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelBarItemTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native