diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2014-08-09 11:26:17 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2014-08-09 11:26:17 +0200 |
| commit | 2130ca02834983e43704ea371cb052b340cce69d (patch) | |
| tree | d2b2d702baf0204944785fb3d14f02d363e273bb /tests | |
| parent | 10a59c187b8b263684902813dfec63a108c842e1 (diff) | |
| download | cgeo-2130ca02834983e43704ea371cb052b340cce69d.zip cgeo-2130ca02834983e43704ea371cb052b340cce69d.tar.gz cgeo-2130ca02834983e43704ea371cb052b340cce69d.tar.bz2 | |
fix #4132: backport GPX test fix
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/cgeo/geocaching/files/GPXImporterTest.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index 02c997c..f72cf4a 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -266,9 +266,9 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { notifyAll(); } - public synchronized void waitForCompletion(final long milliseconds, final int maxMessages) { + public synchronized void waitForCompletion(final long milliseconds) { try { - while (System.currentTimeMillis() - lastMessage <= milliseconds && messages.size() <= maxMessages) { + while (System.currentTimeMillis() - lastMessage <= milliseconds && !hasTerminatingMessage()) { wait(milliseconds); } } catch (InterruptedException e) { @@ -276,9 +276,14 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { } } + private boolean hasTerminatingMessage() { + Message recentMessage = messages.get(messages.size() - 1); + return recentMessage.what == GPXImporter.IMPORT_STEP_CANCELED || recentMessage.what == GPXImporter.IMPORT_STEP_FINISHED || recentMessage.what == GPXImporter.IMPORT_STEP_FINISHED_WITH_ERROR; + } + public void waitForCompletion() { - // Use reasonable defaults - waitForCompletion(1000, 10); + // wait a maximum of 10 seconds + waitForCompletion(10000); } } |
