Skip to content

Commit 3ffb9b2

Browse files
committed
Dispose dialogs while returning to demo host
1 parent afd27bc commit 3ffb9b2

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

docs/demos/common/src/test/java/com/codenameone/developerguide/animations/AnimationDemosScreenshotTest.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.codename1.ui.Button;
99
import com.codename1.ui.Component;
1010
import com.codename1.ui.Container;
11+
import com.codename1.ui.Dialog;
1112
import com.codename1.ui.Display;
1213
import com.codename1.ui.Form;
1314
import com.codename1.ui.Image;
@@ -171,7 +172,7 @@ private void returnToHost(Form demoForm, Form host) {
171172
long deadline = System.currentTimeMillis() + FORM_TIMEOUT_MS;
172173

173174
if (demoForm != null && demoForm != currentForm()) {
174-
demoForm.showBack();
175+
unwindForm(demoForm, host);
175176
}
176177

177178
while (System.currentTimeMillis() <= deadline) {
@@ -183,10 +184,11 @@ private void returnToHost(Form demoForm, Form host) {
183184
if (active == null) {
184185
host.show();
185186
} else {
186-
active.showBack();
187+
unwindForm(active, host);
187188
}
188189

189-
TestUtils.waitFor(150);
190+
Display.getInstance().animate();
191+
TestUtils.waitFor(120);
190192
}
191193

192194
if (currentForm() != host) {
@@ -196,6 +198,23 @@ private void returnToHost(Form demoForm, Form host) {
196198
waitForHost(host);
197199
}
198200

201+
private void unwindForm(Form form, Form host) {
202+
if (form == null) {
203+
return;
204+
}
205+
206+
if (form instanceof Dialog) {
207+
((Dialog) form).dispose();
208+
return;
209+
}
210+
211+
if (form == host) {
212+
return;
213+
}
214+
215+
form.showBack();
216+
}
217+
199218
private Form currentForm() {
200219
Component current = Display.getInstance().getCurrent();
201220
return (current instanceof Form) ? (Form) current : null;

0 commit comments

Comments
 (0)