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

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

Issue 29678581: Issue 6000 - Rename "libadblockplus-android" (Closed)
Patch Set: addressed comments Created Jan. 29, 2018, 11:04 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: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java
deleted file mode 100644
index 4d551eca0f9174a149ed4c8c4ed2718e65d06561..0000000000000000000000000000000000000000
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * This file is part of Adblock Plus <https://adblockplus.org/>,
- * Copyright (C) 2006-present 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.LazyWebRequest;
-import org.adblockplus.libadblockplus.Notification;
-import org.adblockplus.libadblockplus.ShowNotificationCallback;
-import org.adblockplus.libadblockplus.WebRequest;
-
-import org.junit.Test;
-
-public class NotificationTest extends BaseFilterEngineTest
-{
- @Override
- protected WebRequest createWebRequest()
- {
- return new LazyWebRequest();
- }
-
- protected void addNotification(String notification)
- {
- platform.getJsEngine().evaluate(
- "(function()\n" +
- "{\n" +
- "require('notification').Notification.addNotification(" + notification + ");\n" +
- "})();");
- }
-
- private class LocalShowNotificationCallback extends ShowNotificationCallback
- {
- private Notification retValue;
-
- public Notification getRetValue()
- {
- return retValue;
- }
-
- @Override
- public void showNotificationCallback(Notification notification)
- {
- retValue = notification;
- }
- }
-
- protected Notification peekNotification(String url) throws InterruptedException
- {
- LocalShowNotificationCallback callback = new LocalShowNotificationCallback();
- filterEngine.setShowNotificationCallback(callback);
- filterEngine.showNextNotification(url);
- filterEngine.removeShowNotificationCallback();
- return callback.getRetValue();
- }
-
- @Test
- public void testNoNotifications() throws InterruptedException
- {
- assertNull(peekNotification(""));
- }
-
- @Test
- public void testAddNotification() throws InterruptedException
- {
- addNotification(
- "{\n" +
- " type: 'critical',\n" +
- " title: 'testTitle',\n" +
- " message: 'testMessage',\n" +
- "}");
- Notification notification = peekNotification("");
- assertNotNull(notification);
- assertEquals(Notification.Type.CRITICAL, notification.getType());
- assertEquals("testTitle", notification.getTitle());
- assertEquals("testMessage", notification.getMessageString());
- }
-
- @Test
- public void testFilterByUrl() throws InterruptedException
- {
- addNotification("{ id:'no-filter', type:'critical' }");
- addNotification("{ id:'www.com', type:'information', urlFilters:['||www.com$document'] }");
- addNotification("{ id:'www.de', type:'question', urlFilters:['||www.de$document'] }");
-
- Notification notification = peekNotification("");
- assertNotNull(notification);
- assertEquals(Notification.Type.CRITICAL, notification.getType());
-
- notification = peekNotification("http://www.de");
- assertNotNull(notification);
- assertEquals(Notification.Type.QUESTION, notification.getType());
-
- notification = peekNotification("http://www.com");
- assertNotNull(notification);
- assertEquals(Notification.Type.INFORMATION, notification.getType());
- }
-
- @Test
- public void testMarkAsShown() throws InterruptedException
- {
- addNotification("{ id: 'id', type: 'information' }");
- assertNotNull(peekNotification(""));
-
- Notification notification = peekNotification("");
- assertNotNull(notification);
-
- Thread.sleep(1000);
- notification.markAsShown();
-
- assertNull(peekNotification(""));
- }
-}

Powered by Google App Engine
This is Rietveld