-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZK-3729: getDesktop() sometimes returns NULL causing NPE
- Loading branch information
1 parent
1d27a30
commit cb75290
Showing
8 changed files
with
167 additions
and
4 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
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
58 changes: 58 additions & 0 deletions
58
zktest/src/main/java/org/zkoss/zktest/test2/B101_ZK_3729Composer.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,58 @@ | ||
/* B101_ZK_3729Composer.java | ||
Purpose: | ||
Description: | ||
History: | ||
3:36 PM 2024/9/18, Created by jumperchen | ||
Copyright (C) 2024 Potix Corporation. All Rights Reserved. | ||
*/ | ||
package org.zkoss.zktest.test2; | ||
|
||
import org.zkoss.zk.ui.Component; | ||
import org.zkoss.zk.ui.Sessions; | ||
import org.zkoss.zk.ui.event.Events; | ||
import org.zkoss.zk.ui.select.SelectorComposer; | ||
import org.zkoss.zk.ui.select.annotation.Listen; | ||
import org.zkoss.zk.ui.select.annotation.Wire; | ||
import org.zkoss.zul.Div; | ||
import org.zkoss.zul.Grid; | ||
import org.zkoss.zul.ListModelList; | ||
|
||
/** | ||
* @author jumperchen | ||
*/ | ||
public class B101_ZK_3729Composer extends SelectorComposer { | ||
|
||
@Wire private Grid grid; | ||
private Div rootDiv; | ||
private ListModelList model = new ListModelList(); | ||
|
||
@Override | ||
public void doAfterCompose(Component comp) throws Exception { | ||
super.doAfterCompose(comp); | ||
rootDiv = (Div) comp; | ||
grid.setModel(model); | ||
} | ||
|
||
@Listen(Events.ON_CLICK + "=#logout") | ||
public void logout() { | ||
Sessions.getCurrent().invalidate(); | ||
// ((SimpleSession)Sessions.getCurrent()).invalidateNow(); | ||
} | ||
|
||
@Listen(Events.ON_CLICK + "=#op2") | ||
public void longOp() { | ||
fakeOperation(3); | ||
model.add("success"); | ||
} | ||
|
||
static public void fakeOperation(int seconds) { | ||
long endTime = System.currentTimeMillis() + seconds * 1000; | ||
while (System.currentTimeMillis() < endTime) { | ||
// Just a busy-wait. In real scenarios, this could be some meaningful computation. | ||
} | ||
} | ||
} |
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
B101-ZK-3729.zul | ||
Purpose: | ||
Description: | ||
History: | ||
2024/9/18, Created by jumperchen | ||
Copyright (C) 2024 Potix Corporation. All Rights Reserved. | ||
--> | ||
<zk> | ||
<div apply="org.zkoss.zktest.test2.B101_ZK_3729Composer"> | ||
<button id="op2" label="sync long op"/> | ||
<button id="logout" label="logout" /> | ||
<grid id="grid"></grid> | ||
</div> | ||
</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
39 changes: 39 additions & 0 deletions
39
zktest/src/test/java/org/zkoss/zktest/zats/test2/B101_ZK_3729Test.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,39 @@ | ||
/* B101_ZK_3729Test.java | ||
Purpose: | ||
Description: | ||
History: | ||
11:25 AM 2024/9/19, Created by jumperchen | ||
Copyright (C) 2024 Potix Corporation. All Rights Reserved. | ||
*/ | ||
package org.zkoss.zktest.zats.test2; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.WindowType; | ||
|
||
import org.zkoss.test.webdriver.WebDriverTestCase; | ||
|
||
/** | ||
* @author jumperchen | ||
*/ | ||
public class B101_ZK_3729Test extends WebDriverTestCase { | ||
|
||
@Test | ||
public void test() { | ||
connect(); | ||
driver.switchTo().newWindow(WindowType.TAB); | ||
driver.get(getAddress() + "/test2/B101-ZK-3729.zul"); | ||
waitResponse(); | ||
Object[] windowHandles = driver.getWindowHandles().toArray(); | ||
driver.switchTo().window((String) windowHandles[0]); | ||
click(jq("$op2")); | ||
driver.switchTo().window((String) windowHandles[1]); | ||
click(jq("$logout")); | ||
driver.switchTo().window((String) windowHandles[0]); | ||
waitResponse(); | ||
assertNoZKError(); | ||
} | ||
} |