Author: dsvyatobatsko
Date: 2008-12-10 12:08:13 -0500 (Wed, 10 Dec 2008)
New Revision: 11705
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/images/calendar/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/images/calendar/icon_disabled.gif
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/images/calendar/icon_enabled.gif
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/buttonRelatedAttributesTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5253
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/images/calendar/icon_disabled.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/images/calendar/icon_disabled.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/images/calendar/icon_enabled.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/images/calendar/icon_enabled.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/buttonRelatedAttributesTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/buttonRelatedAttributesTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-10
16:09:05 UTC (rev 11704)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-10
17:08:13 UTC (rev 11705)
@@ -49,6 +49,8 @@
static final String TODAY_CONTROL_MODE_URL =
"pages/calendar/todayControlModeTest.xhtml";
+ static final String BUTTON_RELATED_TEST_URL =
"pages/calendar/buttonRelatedAttributesTest.xhtml";
+
static final String CONTROLS_FORM_ID = "_controls:";
static final String availableDayCellClass = "rich-calendar-cell-size
rich-calendar-cell rich-calendar-btn";
@@ -876,6 +878,29 @@
Assert.assertFalse(isVisible(todayControlXpath), "Control 'Today'
has to be hidden");
}
+ @Test
+ public void buttonRelatedAttributesTest(Template template) {
+ renderPage(BUTTON_RELATED_TEST_URL, template, null);
+ writeStatus("Check button-related attributes");
+
+ String calendar = getParentId() + FORM_ID + "calendar";
+ String enabledIconPopupBtnId = calendar + "EnabledIconPopupButton";
+ String disabledIconPopupBtnId = calendar + "DisabledIconPopupButton";
+ String labeledPopupBtnId = calendar + "LabeledPopupButton";
+
+ writeStatus("Check enabled popup button are rendered with a proper
icon");
+ testIcon(enabledIconPopupBtnId, "icon_enabled");
+ isRenderedAs(enabledIconPopupBtnId, "img");
+
+ writeStatus("Check disabled popup button are rendered with a proper
icon");
+ testIcon(disabledIconPopupBtnId, "icon_disabled");
+ isRenderedAs(disabledIconPopupBtnId, "img");
+
+ writeStatus("Check popup button is rendered as a labeled button
element");
+ isRenderedAs(labeledPopupBtnId, "button");
+ AssertTextEquals(labeledPopupBtnId, "Button");
+ }
+
private void setPopup(boolean isPopup) {
runScript("$('" + isPopupId + "').checked=" +
isPopup);
}
@@ -897,17 +922,36 @@
clickById(popupButtonId);
}
+ /**
+ * 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 + "]");
+ }
+ }
+
+ private void isRenderedAs(String id, String tagName) {
+ if (selenium.getXpathCount("//" + tagName + "[@id='" + id
+ "']").intValue() != 1) {
+ Assert.fail("Dom element with id[" + id + "] is not rendered
as [" + tagName + "]");
+ }
+ }
+
public String getTestUrl() {
return "pages/calendar/calendarTest.xhtml";
}
-
+
@Override
public String getAutoTestUrl() {
- return "pages/calendar/calendarAutoTest.xhtml";
+ return "pages/calendar/calendarAutoTest.xhtml";
}
-
+
@Override
public void changeValue() {
- changeDate();
+ changeDate();
}
}