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

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

Issue 29344967: Issue 4031 - Implement tests for libadblockplus-android (Closed)
Patch Set: With fixed version Created Sept. 8, 2016, 1:53 p.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: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..86296d8085fbe0fbf6398d2de0c1231a95e3c838
--- /dev/null
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/FilterEngineUpdaterTest.java
@@ -0,0 +1,53 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.adblockplus.libadblockplus.tests;
+
+import org.adblockplus.libadblockplus.MockUpdateAvailableCallback;
+import org.adblockplus.libadblockplus.NoOpUpdaterCallback;
+import org.adblockplus.libadblockplus.ServerResponse;
+
+import org.junit.Test;
+
+public class FilterEngineUpdaterTest extends UpdaterTest
+{
+ @Test
+ public void testSetRemoveUpdateAvailableCallback() throws InterruptedException
+ {
+ mockWebRequest.response.setStatus(ServerResponse.NsStatus.OK);
+ mockWebRequest.response.setResponseStatus(200);
+ mockWebRequest.response.setResponse(
+ "{\n" +
+ " \"test\": {\n" +
+ " \"version\": \"1.0.2\",\n" +
+ " \"url\": \"https://downloads.adblockplus.org/test-1.0.2.tar.gz?update\"\n" +
+ " }\n" +
+ "}");
+
+ MockUpdateAvailableCallback mockUpdateAvailableCallback =
+ new MockUpdateAvailableCallback(0);
+ filterEngine.setUpdateAvailableCallback(mockUpdateAvailableCallback);
+ filterEngine.forceUpdateCheck(new NoOpUpdaterCallback());
+ Thread.sleep(1000);
+ assertEquals(1, mockUpdateAvailableCallback.getTimesCalled());
+
+ filterEngine.removeUpdateAvailableCallback();
+ filterEngine.forceUpdateCheck(new NoOpUpdaterCallback());
+ Thread.sleep(1000);
+ assertEquals(1, mockUpdateAvailableCallback.getTimesCalled());
+ }
+}

Powered by Google App Engine
This is Rietveld