Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: adblock-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java

Issue 29857561: Fix libadblockplus-android tests, Part 2
Patch Set: Created Aug. 16, 2018, 11:48 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: adblock-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java
diff --git a/adblock-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java b/adblock-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java
index fe7657a7e32bdc66ec810f3f787dfdc3de7610b6..1f4d6a95fcd092599e2e19ff36ce8ede4e692a4c 100644
--- a/adblock-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java
+++ b/adblock-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java
@@ -17,16 +17,19 @@
package org.adblockplus.libadblockplus.tests;
+import android.os.SystemClock;
+
import org.adblockplus.libadblockplus.MockUpdateAvailableCallback;
import org.adblockplus.libadblockplus.NoOpUpdaterCallback;
import org.adblockplus.libadblockplus.ServerResponse;
+import org.adblockplus.libadblockplus.UpdaterTest;
import org.junit.Test;
public class FilterEngineUpdaterTest extends UpdaterTest
{
@Test
- public void testSetRemoveUpdateAvailableCallback() throws InterruptedException
+ public void testSetRemoveUpdateAvailableCallback()
{
mockWebRequest.response.setStatus(ServerResponse.NsStatus.OK);
mockWebRequest.response.setResponseStatus(200);
@@ -40,14 +43,23 @@ public class FilterEngineUpdaterTest extends UpdaterTest
MockUpdateAvailableCallback mockUpdateAvailableCallback =
new MockUpdateAvailableCallback(0);
+ NoOpUpdaterCallback noOpUpdater = new NoOpUpdaterCallback();
filterEngine.setUpdateAvailableCallback(mockUpdateAvailableCallback);
- filterEngine.forceUpdateCheck(new NoOpUpdaterCallback());
- Thread.sleep(1000);
+ filterEngine.forceUpdateCheck(noOpUpdater);
+ while (noOpUpdater.getUpdateCount() < 1)
+ {
+ SystemClock.sleep(100);
+ }
+ assertEquals(1, noOpUpdater.getUpdateCount());
assertEquals(1, mockUpdateAvailableCallback.getTimesCalled());
filterEngine.removeUpdateAvailableCallback();
- filterEngine.forceUpdateCheck(new NoOpUpdaterCallback());
- Thread.sleep(1000);
+ filterEngine.forceUpdateCheck(noOpUpdater);
+ while (noOpUpdater.getUpdateCount() < 2)
+ {
+ SystemClock.sleep(100);
+ }
+ assertEquals(2, noOpUpdater.getUpdateCount());
assertEquals(1, mockUpdateAvailableCallback.getTimesCalled());
}
}

Powered by Google App Engine
This is Rietveld