-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZK-5516: change the current month with a keyboard, ZK-5517: change th…
…e current year with a keyboard (#3091) * ZK-5516: change the current month with a keyboard * ZK-5517: change the current year with a keyboard
- Loading branch information
1 parent
0311461
commit 16a8311
Showing
7 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
F100-ZK-5516.zul | ||
Purpose: | ||
Description: | ||
History: | ||
Sun Dec 10 23:03:30 CST 2023, Created by jamson | ||
Copyright (C) 2023 Potix Corporation. All Rights Reserved. | ||
--> | ||
<zk> | ||
<label multiline="true"> | ||
Click [PageUp], check whether it switched to the same date previous month. | ||
Click [PageDown], check whether it switched to the same date next month. | ||
note : If current date exceed the last date of prev or next month, the date would go to the last day of the month. | ||
</label> | ||
<calendar/> | ||
</zk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
F100-ZK-5517.zul | ||
Purpose: | ||
Description: | ||
History: | ||
Fri Dec 08 18:18:11 CST 2023, Created by jamson | ||
Copyright (C) 2023 Potix Corporation. All Rights Reserved. | ||
--> | ||
<zk> | ||
<label multiline="true"> | ||
Click [Shift + PageUp], check whether it switched to the same month and date previous year. | ||
Click [Shift + PageDown], check whether it switched to the same month and date next year. | ||
note : If current date is 2/29 in a leap year, switching the year would go to the last day of February (2/28). | ||
</label> | ||
<calendar/> | ||
</zk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
zktest/src/test/java/org/zkoss/zktest/zats/test2/F100_ZK_5516Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* F100_ZK_5516Test.java | ||
Purpose: | ||
Description: | ||
History: | ||
Sun Dec 10 23:07:36 CST 2023, Created by jamson | ||
Copyright (C) 2023 Potix Corporation. All Rights Reserved. | ||
*/ | ||
package org.zkoss.zktest.zats.test2; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.Keys; | ||
import org.openqa.selenium.interactions.Actions; | ||
|
||
import org.zkoss.test.webdriver.ztl.Widget; | ||
|
||
public class F100_ZK_5516Test extends F100_ZK_5517Test { | ||
int[] toLastDate = new int[] {31, 28, 31, 30, 31, 30 ,31, 31, 30, 31, 30, 31}; | ||
String[] toMonth = new String[] {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; | ||
int date; | ||
Widget cld; | ||
@Test | ||
public void test() { | ||
connect(); | ||
|
||
click(jq(".z-calendar-selected")); | ||
waitResponse(); | ||
|
||
Actions actions = getActions(); | ||
cld = jq("@calendar").toWidget(); | ||
String month = getMonth(cld); | ||
date = getDate(); | ||
|
||
actions.keyDown(Keys.PAGE_UP).perform(); | ||
waitResponse(); | ||
|
||
assertEquals(toMonth(month, -1), getMonth(cld)); | ||
assertEquals(verifyDate(), getDate()); | ||
|
||
actions.keyDown(Keys.PAGE_DOWN).perform(); | ||
waitResponse(); | ||
|
||
actions.keyDown(Keys.PAGE_DOWN).perform(); | ||
waitResponse(); | ||
|
||
assertEquals(toMonth(month, 1), getMonth(cld)); | ||
assertEquals(verifyDate(), getDate()); | ||
|
||
actions.keyDown(Keys.PAGE_UP).perform(); | ||
waitResponse(); | ||
|
||
assertEquals(month, getMonth(cld)); | ||
assertEquals(verifyDate(), getDate()); | ||
} | ||
|
||
public int toMonthNum(String month) { | ||
if ("Jan".equals(month)) return 0; | ||
else if ("Feb".equals(month)) return 1; | ||
else if ("Mar".equals(month)) return 2; | ||
else if ("Apr".equals(month)) return 3; | ||
else if ("May".equals(month)) return 4; | ||
else if ("Jun".equals(month)) return 5; | ||
else if ("Jul".equals(month)) return 6; | ||
else if ("Aug".equals(month)) return 7; | ||
else if ("Sep".equals(month)) return 8; | ||
else if ("Oct".equals(month)) return 9; | ||
else if ("Nov".equals(month)) return 10; | ||
else return 11; | ||
} | ||
|
||
public String toMonth(String month, int offset) { | ||
return toMonth[(toMonthNum(month) + offset + 12) % 12]; | ||
} | ||
|
||
public int verifyDate() { | ||
String month = getMonth(cld); | ||
int year = getYear(cld), | ||
lastDate = (year % 4 == 0) && ("Feb".equals(month)) ? 29 : toLastDate[toMonthNum(month)]; | ||
date = Math.min(date, lastDate); | ||
return date; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
zktest/src/test/java/org/zkoss/zktest/zats/test2/F100_ZK_5517Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* F100_ZK_5517Test.java | ||
Purpose: | ||
Description: | ||
History: | ||
Fri Dec 08 18:44:37 CST 2023, Created by jamson | ||
Copyright (C) 2023 Potix Corporation. All Rights Reserved. | ||
*/ | ||
package org.zkoss.zktest.zats.test2; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.Keys; | ||
import org.openqa.selenium.interactions.Actions; | ||
|
||
import org.zkoss.test.webdriver.WebDriverTestCase; | ||
import org.zkoss.test.webdriver.ztl.Widget; | ||
|
||
public class F100_ZK_5517Test extends WebDriverTestCase { | ||
@Test | ||
public void test() { | ||
connect(); | ||
|
||
Actions actions = getActions(); | ||
Widget cld = jq("@calendar").toWidget(); | ||
String month = getMonth(cld); | ||
int year = getYear(cld), | ||
date = getDate(); | ||
|
||
click(jq(".z-calendar-selected")); | ||
waitResponse(); | ||
|
||
if ("Feb".equals(month) && date == 29) { | ||
date = 28; | ||
actions.keyDown(Keys.ARROW_LEFT).perform(); | ||
} | ||
|
||
actions.keyDown(Keys.SHIFT).keyDown(Keys.PAGE_UP).perform(); | ||
waitResponse(); | ||
|
||
assertEquals(year, getYear(cld) + 1); | ||
assertEquals(month, getMonth(cld)); | ||
assertEquals(date, getDate()); | ||
|
||
actions.keyDown(Keys.SHIFT).keyDown(Keys.PAGE_DOWN).perform(); | ||
waitResponse(); | ||
|
||
actions.keyDown(Keys.SHIFT).keyDown(Keys.PAGE_DOWN).perform(); | ||
waitResponse(); | ||
|
||
assertEquals(year, getYear(cld) - 1); | ||
assertEquals(month, getMonth(cld)); | ||
assertEquals(date, getDate()); | ||
|
||
actions.keyDown(Keys.SHIFT).keyDown(Keys.PAGE_UP).perform(); | ||
waitResponse(); | ||
|
||
assertEquals(year, getYear(cld)); | ||
assertEquals(month, getMonth(cld)); | ||
assertEquals(date, getDate()); | ||
} | ||
|
||
public int getYear(Widget calendar) { | ||
return Integer.parseInt(calendar.$n("ty").get("innerHTML")); | ||
} | ||
|
||
public String getMonth(Widget calendar) { | ||
return calendar.$n("tm").get("innerHTML"); | ||
} | ||
|
||
public int getDate() { | ||
return Integer.parseInt(jq(".z-calendar-selected").toElement().get("innerHTML")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters