Author: dsvyatobatsko
Date: 2008-12-16 13:05:49 -0500 (Tue, 16 Dec 2008)
New Revision: 11832
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5351
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
===================================================================
(Binary files differ)
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-16
17:31:52 UTC (rev 11831)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-16
18:05:49 UTC (rev 11832)
@@ -168,6 +168,8 @@
String firstWeekDayId;
+ String isDisabledId;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
@@ -209,7 +211,8 @@
applyButtonXpath = "//td[@id='" + calendarFooterId +
"']/table/tbody/tr/td[6]";
cleanButtonXPath =
"//td[@id='"+calendarFooterId+"']/table/tbody/tr/td[2]";
calendarMessageId = parentId + FORM_ID + "calendarMsg";
- firstWeekDayId =parentId + FORM_ID + "firstWeekDay";
+ firstWeekDayId = parentId + FORM_ID + "firstWeekDay";
+ isDisabledId = parentId + FORM_ID + "isDisabled";
}
String getStatus() {
@@ -403,7 +406,7 @@
Assert.fail("Calendar displays invalid date. It should contain
["+expected+"]. But was ["+headerDate+"]");
}
}
-
+
@Test
public void testAjaxSingle(Template template) {
AutoTester tester = getAutoTester(this);
@@ -423,8 +426,7 @@
tester.testProcessAttribute();
}
-
-
+
// Erroneous test case.
/* @Test
public void testNULLModel(Template template) {
@@ -440,8 +442,7 @@
}*/
-
-
+
@Test
public void testJSAPI(Template template) {
renderPage(template, RESET_METHOD);
@@ -1176,9 +1177,58 @@
showPopup();
AssertTextEquals(firstWeekDayCellId, weekDayShortName, "It looks as if
'firstWeekDay' attribute doesn't work");
- }
+ }
@Test
+ public void testDisabledAttribute(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+
+ writeStatus("Check 'disabled' attribute");
+ check(isDisabledId, true);
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ writeStatus("Check date input is disabled");
+ //Assert.assertFalse(selenium.isEditable(inputDateId), "Date input is not
disabled");
+ //Assert.assertTrue(Boolean.parseBoolean(selenium.getAttribute(inputDateId +
"@disabled")), "Date input is not disabled");
+ if(selenium.getXpathCount("//*[@id='" + inputDateId + "'
and @disabled='true']").intValue() == 0) {
+ Assert.fail("Date input is not disabled");
+ }
+ writeStatus("button does not trigger popup calendar");
+ showPopup();
+ Assert.assertFalse(isVisible(calendarId), "Calendar popup should not be
shown up");
+ writeStatus("and decorated with disabled icon");
+ testIcon(popupButtonId, "Disabled");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+ writeStatus("All stuff is disabled");
+ Assert.assertFalse(isPresent("//td[@id='" + calendarHeaderId +
"']/table/tbody/tr/td[@class='rich-calendar-tool'][1]/div"),
"Previous year button has NOT to be present");
+ Assert.assertFalse(isPresent("//td[@id='" + calendarHeaderId +
"']/table/tbody/tr/td[@class='rich-calendar-tool'][2]/div"),
"Previous month button has NOT to be present");
+ Assert.assertFalse(isPresent("//td[@id='" + calendarHeaderId +
"']/table/tbody/tr/td[@class='rich-calendar-tool'][3]/div"),
"Next month button has NOT to be present");
+ Assert.assertFalse(isPresent("//td[@id='" + calendarHeaderId +
"']/table/tbody/tr/td[@class='rich-calendar-tool'][4]/div"),
"Next year button has NOT to be present");
+
+ String footerText = selenium.getText("//td[@id='" +
calendarFooterId + "']/table/tbody/tr");
+ Assert.assertFalse(footerText.matches(".*Today.*"), "Today button
should NOT be present");
+ Assert.assertFalse(footerText.matches(".*Clean.*"), "Clean button
should NOT be present");
+
+ String expectedHTML = getHTMLById(calendarId);
+ writeStatus("Convulsively click all over the calendar. The component has not
to be changed it is disabled, remember?!");
+ clickById(calendarId + "DayCell6");
+ String actualHTML = getHTMLById(calendarId);
+ Assert.assertEquals(actualHTML, expectedHTML);
+ clickById(calendarId + "DayCell17");
+ actualHTML = getHTMLById(calendarId);
+ Assert.assertEquals(actualHTML, expectedHTML);
+
+ clickById(calendarId + "DayCell26");
+ actualHTML = getHTMLById(calendarId);
+ Assert.assertEquals(actualHTML, expectedHTML);
+ }
+
+ @Test
public void testTodayControlMode(Template template) {
renderPage(TODAY_CONTROL_MODE_URL, template, null);
initIds(getParentId());