Author: ppitonak(a)redhat.com
Date: 2011-02-09 10:03:33 -0500 (Wed, 09 Feb 2011)
New Revision: 21568
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestDateEditor.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestTimeEditor.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/AbstractCalendarTest.java
Log:
https://issues.jboss.org/browse/RFPL-931
* added 14 tests for time and date editors in rich:calendar
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/AbstractCalendarTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/AbstractCalendarTest.java 2011-02-09
15:01:21 UTC (rev 21567)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/AbstractCalendarTest.java 2011-02-09
15:03:33 UTC (rev 21568)
@@ -77,15 +77,26 @@
protected JQueryLocator todayButton = pjq("td.rf-cal-tl-ftr:eq(4) >
div");
protected JQueryLocator applyButton = pjq("td.rf-cal-tl-ftr:eq(5) >
div");
// time panel
- protected JQueryLocator timePanel = pjq("table[id$=calendarEditor]");
+ protected JQueryLocator timeEditor =
pjq("table[id$=calendarTimeEditorLayout]");
+ protected JQueryLocator timeEditorOk =
pjq("div[id$=calendarTimeEditorButtonOk]");
+ protected JQueryLocator timeEditorCancel =
pjq("div[id$=calendarTimeEditorButtonCancel]");
protected JQueryLocator hoursInput = pjq("input[id$=calendarTimeHours]");
protected JQueryLocator hoursInputUp =
pjq("div[id$=calendarTimeHoursBtnUp]");
protected JQueryLocator hoursInputDown =
pjq("div[id$=calendarTimeHoursBtnDown]");
protected JQueryLocator minutesInput =
pjq("input[id$=calendarTimeMinutes]");
protected JQueryLocator minutesInputUp =
pjq("div[id$=calendarTimeMinutesBtnUp]");
protected JQueryLocator minutesInputDown =
pjq("div[id$=calendarTimeMinutesBtnDown]");
- protected JQueryLocator okButton = pjq("td.rf-cal-time-layout-ok >
div");
- protected JQueryLocator cancelButton = pjq("td.rf-cal-time-layout-cancel >
div");
-
+ protected JQueryLocator secondsInput =
pjq("input[id$=calendarTimeSeconds]");
+ protected JQueryLocator secondsInputUp =
pjq("div[id$=calendarTimeSecondsBtnUp]");
+ protected JQueryLocator secondsInputDown =
pjq("div[id$=calendarTimeSecondsBtnDown]");
+ // date panel
+ protected JQueryLocator dateEditor =
pjq("table[id$=calendarDateEditorLayout]");
+ protected JQueryLocator dateEditorOk =
pjq("div[id$=calendarDateEditorButtonOk]");
+ protected JQueryLocator dateEditorCancel =
pjq("div[id$=calendarDateEditorButtonCancel]");
+ protected JQueryLocator dateEditorLeftArrow =
pjq("tr[id$=calendarDateEditorLayoutTR] div:eq(2)");
+ protected JQueryLocator dateEditorRightArrow =
pjq("tr[id$=calendarDateEditorLayoutTR] div:eq(3)");
+ protected JQueryLocator dateEditorMonths =
pjq("div[id$=calendarDateEditorLayoutM{0}]");
+ protected JQueryLocator dateEditorYears =
pjq("div[id$=calendarDateEditorLayoutY{0}]");
+ // other
protected JQueryLocator output = pjq("span[id$=output]");
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestDateEditor.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestDateEditor.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestDateEditor.java 2011-02-09
15:03:33 UTC (rev 21568)
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richCalendar;
+
+import static
org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.testng.annotations.Test;
+
+/**
+ * Test case for date editro of a calendar on page
faces/components/richCalendar/simple.xhtml.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestDateEditor extends AbstractCalendarTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richCalendar/simple.xhtml");
+ }
+
+ @Test
+ public void testShowDateEditor() {
+ String currentMonth = new SimpleDateFormat("MMMM, yyyy").format(new
Date()).substring(0, 3);
+ String currentYear = new SimpleDateFormat("yyyy").format(new Date());
+
+ selenium.click(input);
+ guardNoRequest(selenium).click(monthLabel);
+
+ assertTrue(selenium.isElementPresent(dateEditor), "Date editor should be
present on the page.");
+ assertTrue(selenium.isVisible(dateEditor), "Date editor should be
visible.");
+
+ for (int i = 0; i < 12; i++) {
+ assertTrue(selenium.isElementPresent(dateEditorMonths.format(i)), "Date
editor doesn't contain label for month " + Month.values()[i]);
+ assertEquals(selenium.getText(dateEditorMonths.format(i)),
Month.values()[i].toString().substring(0, 3));
+
+ if (currentMonth.equals(selenium.getText(dateEditorMonths.format(i)))) {
+ assertTrue(selenium.belongsClass(dateEditorMonths.format(i),
"rf-cal-edtr-btn-sel"), "");
+ }
+ }
+
+ for (int i = 0; i < 10; i++) {
+ assertTrue(selenium.isElementPresent(dateEditorYears.format(i)), "Date
editor doesn't contain label for year " + (2007 + i));
+ assertEquals(selenium.getText(dateEditorYears.format(i)),
Integer.toString(2007 + i), "Label of year");
+
+ if (currentYear.equals(selenium.getText(dateEditorYears.format(i)))) {
+ assertTrue(selenium.belongsClass(dateEditorYears.format(i),
"rf-cal-edtr-btn-sel"), "Current year should be selected.");
+ }
+ }
+ }
+
+ @Test
+ public void testCancelButton() {
+ selenium.click(input);
+ selenium.click(monthLabel);
+
+ String oldLabel = selenium.getText(monthLabel);
+ assertTrue(selenium.isElementPresent(dateEditor), "Date editor should be
present on the page.");
+ assertTrue(selenium.isVisible(dateEditor), "Date editor should be
visible.");
+
+ selenium.click(dateEditorRightArrow);
+ selenium.click(dateEditorYears.format(0));
+
+ selenium.click(dateEditorCancel);
+ assertFalse(selenium.isVisible(dateEditor), "Date editor should not be
visible.");
+ assertEquals(selenium.getText(monthLabel), oldLabel, "Month and year in
calendar's popup should not change.");
+ }
+
+ @Test
+ public void testLeftButton() {
+ selenium.click(input);
+ selenium.click(monthLabel);
+
+ int minYear = Integer.parseInt(selenium.getText(dateEditorYears.format(0)));
+
+ selenium.click(dateEditorLeftArrow);
+ selenium.click(dateEditorLeftArrow);
+ selenium.click(dateEditorLeftArrow);
+
+ for (int i = 0; i < 10; i++) {
+ assertTrue(selenium.isElementPresent(dateEditorYears.format(i)), "Date
editor doesn't contain label for year " + (minYear - 30 + i));
+ assertEquals(selenium.getText(dateEditorYears.format(i)),
Integer.toString(minYear - 30 + i), "Label of year");
+ assertFalse(selenium.belongsClass(dateEditorYears.format(i),
"rf-cal-edtr-btn-sel"), "No year should be selected.");
+ }
+ }
+
+ @Test
+ public void testRightButton() {
+ selenium.click(input);
+ selenium.click(monthLabel);
+
+ int minYear = Integer.parseInt(selenium.getText(dateEditorYears.format(0)));
+
+ selenium.click(dateEditorRightArrow);
+ selenium.click(dateEditorRightArrow);
+ selenium.click(dateEditorRightArrow);
+
+ for (int i = 0; i < 10; i++) {
+ assertTrue(selenium.isElementPresent(dateEditorYears.format(i)), "Date
editor doesn't contain label for year " + (minYear + 30 + i));
+ assertEquals(selenium.getText(dateEditorYears.format(i)),
Integer.toString(minYear + 30 + i), "Label of year");
+ assertFalse(selenium.belongsClass(dateEditorYears.format(i),
"rf-cal-edtr-btn-sel"), "No year should be selected.");
+ }
+ }
+
+ @Test
+ public void testSelectMonth() {
+ String currentMonth = new SimpleDateFormat("MMMM").format(new Date());
+ String currentYear = new SimpleDateFormat("yyyy").format(new Date());
+
+ selenium.click(input);
+ selenium.click(monthLabel);
+
+ if (currentMonth.equals(Month.January.toString())) {
+ selenium.click(dateEditorMonths.format(Month.December.ordinal()));
+ selenium.click(dateEditorOk);
+ assertEquals(selenium.getText(monthLabel), "December, " +
currentYear, "Month and year in calendar's popup should change.");
+ } else {
+ selenium.click(dateEditorMonths.format(Month.January.ordinal()));
+ selenium.click(dateEditorOk);
+ assertEquals(selenium.getText(monthLabel), "January, " +
currentYear, "Month and year in calendar's popup should change.");
+ }
+
+ assertFalse(selenium.isVisible(dateEditor), "Date editor should not be
visible.");
+ }
+
+ @Test
+ public void testSelectYear() {
+ selenium.click(input);
+ selenium.click(monthLabel);
+
+ String currentMonth = new SimpleDateFormat("MMMM").format(new Date());
+ int minYear = Integer.parseInt(selenium.getText(dateEditorYears.format(0)));
+ selenium.click(dateEditorRightArrow);
+
+ selenium.click(dateEditorYears.format(0));
+ selenium.click(dateEditorOk);
+ assertFalse(selenium.isVisible(dateEditor), "Date editor should not be
visible.");
+ assertEquals(selenium.getText(monthLabel), currentMonth + ", " +
(minYear + 10), "Month and year in calendar's popup should change.");
+
+ }
+}
Property changes on:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestDateEditor.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestTimeEditor.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestTimeEditor.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestTimeEditor.java 2011-02-09
15:03:33 UTC (rev 21568)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richCalendar;
+
+import static
org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.ElementLocator;
+
+import org.testng.annotations.Test;
+
+/**
+ * Test case for time editor of a calendar on page
faces/components/richCalendar/simple.xhtml.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestTimeEditor extends AbstractCalendarTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richCalendar/simple.xhtml");
+ }
+
+ @Test
+ public void testShowTimeEditor() {
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:00", "Button's
text");
+ guardNoRequest(selenium).click(timeButton);
+
+ assertTrue(selenium.isElementPresent(timeEditor), "Date editor should be
present on the page.");
+ assertTrue(selenium.isVisible(timeEditor), "Date editor should be
visible.");
+
+ assertEquals(selenium.getValue(hoursInput), "12", "Value of the
spinner for hours");
+ assertEquals(selenium.getValue(minutesInput), "00", "Value of the
spinner for hours");
+ }
+
+ @Test
+ public void testCancelButton() {
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+ selenium.click(timeButton);
+
+ clickArrow(hoursInputUp, 2);
+ assertEquals(selenium.getValue(hoursInput), "14", "Value of the
spinner for hours");
+ assertEquals(selenium.getValue(minutesInput), "00", "Value of the
spinner for hours");
+
+ selenium.click(timeEditorCancel);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:00", "Button's
text");
+ }
+
+ @Test
+ public void testHoursInputClick() {
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+
+ selenium.click(timeButton);
+ clickArrow(hoursInputUp, 2);
+ assertEquals(selenium.getValue(hoursInput), "14", "Value of the
spinner for hours");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "14:00", "Button's
text");
+
+ selenium.click(timeButton);
+ clickArrow(hoursInputDown, 15);
+ assertEquals(selenium.getValue(hoursInput), "23", "Value of the
spinner for hours");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "23:00", "Button's
text");
+ }
+
+ @Test
+ public void testHoursInputType() {
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+
+ selenium.click(timeButton);
+ selenium.typeKeys(hoursInput, "14");
+ assertEquals(selenium.getValue(hoursInput), "14", "Value of the
spinner for hours");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "14:00", "Button's
text");
+
+ selenium.click(timeButton);
+ selenium.typeKeys(hoursInput, "9");
+ assertEquals(selenium.getValue(hoursInput), "09", "Value of the
spinner for hours");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "09:00", "Button's
text");
+ }
+
+ @Test
+ public void testMinutesInputClick() {
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+
+ selenium.click(timeButton);
+ clickArrow(minutesInputUp, 5);
+ assertEquals(selenium.getValue(minutesInput), "05", "Value of the
spinner for minutes");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:05", "Button's
text");
+
+ selenium.click(timeButton);
+ clickArrow(minutesInputDown, 15);
+ assertEquals(selenium.getValue(minutesInput), "50", "Value of the
spinner for minutes");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:50", "Button's
text");
+ }
+
+ @Test
+ public void testMinutesInputType() {
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+
+ selenium.click(timeButton);
+ selenium.typeKeys(minutesInput, "14");
+ assertEquals(selenium.getValue(minutesInput), "14", "Value of the
spinner for minutes");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:14", "Button's
text");
+
+ selenium.click(timeButton);
+ selenium.typeKeys(minutesInput, "9");
+ assertEquals(selenium.getValue(minutesInput), "09", "Value of the
spinner for minutes");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:09", "Button's
text");
+ }
+
+ @Test
+ public void testSecondsInputClick() {
+ selenium.type(pjq("input[type=text][id$=datePatternInput]"),
"HH:mm:ss MMMM d, yyyy");
+ selenium.waitForPageToLoad();
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+
+ selenium.click(timeButton);
+ clickArrow(secondsInputUp, 5);
+ assertEquals(selenium.getValue(secondsInput), "05", "Value of the
spinner for seconds");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:00:05",
"Button's text");
+
+ selenium.click(timeButton);
+ clickArrow(secondsInputDown, 15);
+ assertEquals(selenium.getValue(secondsInput), "50", "Value of the
spinner for seconds");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:00:50",
"Button's text");
+ }
+
+ @Test
+ public void testSecondsInputType() {
+ selenium.type(pjq("input[type=text][id$=datePatternInput]"),
"HH:mm:ss MMMM d, yyyy");
+ selenium.waitForPageToLoad();
+ selenium.click(input);
+ selenium.click(cellDay.format(18));
+
+ selenium.click(timeButton);
+ selenium.typeKeys(secondsInput, "14");
+ assertEquals(selenium.getValue(secondsInput), "14", "Value of the
spinner for seconds");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:00:14",
"Button's text");
+
+ selenium.click(timeButton);
+ selenium.typeKeys(secondsInput, "9");
+ assertEquals(selenium.getValue(secondsInput), "09", "Value of the
spinner for seconds");
+ selenium.click(timeEditorOk);
+ assertTrue(selenium.isDisplayed(timeButton), "Time button should be
visible.");
+ assertEquals(selenium.getText(timeButton), "12:00:09",
"Button's text");
+ }
+
+ /**
+ * Clicks on spinner's arrow.
+ * @param arrow spinner's up or down arrow locator
+ * @param clicks how many times should it be clicked
+ */
+ private void clickArrow(ElementLocator<?> arrow, int clicks) {
+ for (int i = 0; i < clicks; i++) {
+ selenium.runScript(new JavaScript("jQuery(\"" +
arrow.getRawLocator() + "\").mousedown().mouseup()"));
+ }
+ }
+}
Property changes on:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCalendar/TestTimeEditor.java
___________________________________________________________________
Name: svn:keywords
+ Revision