-
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: unable to change the current month with a keyboard
- Loading branch information
1 parent
751975a
commit 3f3ba31
Showing
5 changed files
with
116 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"?> | ||
<!-- | ||
B100-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
87 changes: 87 additions & 0 deletions
87
zktest/src/test/java/org/zkoss/zktest/zats/test2/B100_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 @@ | ||
/* B100_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 B100_ZK_5516Test extends B100_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; | ||
} | ||
} |
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