-
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-5517: change the current year with a keyboard
- Loading branch information
1 parent
e964513
commit e25bc21
Showing
5 changed files
with
109 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-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
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