Author: dsvyatobatsko
Date: 2009-01-23 12:43:39 -0500 (Fri, 23 Jan 2009)
New Revision: 12411
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenuItem/styleAndClasseStandardHTMLAttributesTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5793
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenuItem/styleAndClasseStandardHTMLAttributesTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java 2009-01-23
16:51:30 UTC (rev 12410)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java 2009-01-23
17:43:39 UTC (rev 12411)
@@ -7,6 +7,7 @@
import org.richfaces.AutoTester;
import org.richfaces.SeleniumEvent;
import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
import org.testng.annotations.Test;
public class PanelMenuItemTest extends SeleniumTestBase {
@@ -73,12 +74,9 @@
writeStatus("Check standard HTML attributes are output to client");
String parentId = getParentId();
- String isDisabledId = parentId + CONTROL_FORM_ID + "isDisabled";
- String disablingControlId = parentId + CONTROL_FORM_ID + "disable";
String menuItemId = "icon" + parentId + FORM_ID + "item";
- check(isDisabledId, false);
- clickCommandAndWait(disablingControlId);
+ disable(false);
writeStatus("Check standart HTML attributes");
assertEvents(menuItemId, SeleniumEvent.STANDARD_HTML_EVENTS);
@@ -91,13 +89,10 @@
writeStatus("Check styles and classes are output to client");
String parentId = getParentId();
- String isDisabledId = parentId + CONTROL_FORM_ID + "isDisabled";
- String disablingControlId = parentId + CONTROL_FORM_ID + "disable";
String itemId = parentId + FORM_ID + "item";
writeStatus("Check enabled component at first");
- check(isDisabledId, false);
- clickCommandAndWait(disablingControlId);
+ disable(false);
String styleElementId = "tablehide" + parentId + FORM_ID +
"item";
assertStyleAttribute(styleElementId, "font-size: 16px", "Style
attribute was not output to client");
@@ -115,14 +110,27 @@
assertClassNames(iconTdXpath, new String[] { "icon-class" },
"iconClass attribute was not output to client", false);
writeStatus("Check disabled component");
- check(isDisabledId, true);
- clickCommandAndWait(disablingControlId);
+ disable(true);
writeStatus("Check disabledClass/disabledStyle attributes");
assertStyleAttribute(styleElementId, "font-size: 13px",
"disabledStyle attribute was not output to client");
assertClassNames(styleElementId, new String[] { "disabled-class" },
"disabledStyle attribute was not output to client", true);
}
+ @Test
+ public void testIconsAttributesApply(Template template) {
+ renderPage(LOOK_AND_FEEL_TEST_URL, template, null);
+
+ writeStatus("Check icons attributes apply: are output to client and images
are accessible");
+
+ disable(false);
+
+ String itemId = getParentId() + FORM_ID + "item";
+ String iconImgXpath = "//*[@id='" + itemId +
"']/table/tbody/tr/td[1]/img";
+ Assert.assertTrue(isPresent(iconImgXpath), "Icon is not rendered");
+ testIcon(iconImgXpath, "Chevron");
+ }
+
@Override
public void sendAjax() {
clickAjaxCommandAndWait("icon" +
getAutoTester(this).getClientId("") + "item");
@@ -138,8 +146,29 @@
return null;
}
- private void check(String id, boolean isChecked) {
- runScript("document.getElementById('" + id +
"').checked=" + isChecked);
+ private boolean disable(boolean isDisabled) {
+ String parentId = getParentId();
+ String isDisabledId = parentId + CONTROL_FORM_ID + "isDisabled";
+ String disablingControlId = parentId + CONTROL_FORM_ID + "disable";
+ boolean prevValue =
Boolean.parseBoolean(runScript("document.getElementById('" + isDisabledId +
"').checked"));
+ if (prevValue != isDisabled) {
+ runScript("document.getElementById('" + isDisabledId +
"').checked=" + isDisabled);
+ clickCommandAndWait(disablingControlId);
+ }
+ return prevValue;
}
+ /**
+ * Test an icon.
+ *
+ * @param location location of image representing icon to be tested
+ * @param iconName substring that icon uri has to contain
+ */
+ private void testIcon(String location, String iconSubstring) {
+ String iconSrc = selenium.getAttribute(location + "/@src");
+ if (null == iconSrc || !iconSrc.matches(".*" + iconSubstring +
".*")) {
+ Assert.fail("It looks as if the icon is not proper. Uri of icon is being
tested must contain ["
+ + iconSubstring + "]");
+ }
+ }
}