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

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

Issue 29347202: Issue 4180 - Fix NotificationTest.testMarkAsShown test (Closed)
Patch Set: Created July 1, 2016, 2:16 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java
===================================================================
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/NotificationTest.java
@@ -12,30 +12,23 @@
* 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 android.util.Log;
import org.adblockplus.libadblockplus.FilterEngine;
-import org.adblockplus.libadblockplus.HeaderEntry;
-import org.adblockplus.libadblockplus.LazyLogSystem;
import org.adblockplus.libadblockplus.LazyWebRequest;
import org.adblockplus.libadblockplus.Notification;
-import org.adblockplus.libadblockplus.ServerResponse;
import org.adblockplus.libadblockplus.ShowNotificationCallback;
-import org.adblockplus.libadblockplus.WebRequest;
import org.junit.Test;
-import java.util.List;
-
public class NotificationTest extends BaseJsTest {
protected FilterEngine filterEngine;
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -61,57 +54,29 @@
public Notification getRetValue()
{
return retValue;
}
@Override
public void showNotificationCallback(Notification notification)
{
- Log.d(TAG, this + " received [" + notification + "]");
retValue = notification;
}
}
protected Notification peekNotification(String url) throws InterruptedException
{
- Log.d(TAG, "Start peek");
-
LocalShowNotificationCallback callback = new LocalShowNotificationCallback();
- Log.d(TAG, "set callback " + callback);
filterEngine.setShowNotificationCallback(callback);
filterEngine.showNextNotification(url);
filterEngine.removeShowNotificationCallback();
- Log.d(TAG, "removed callback");
return callback.getRetValue();
}
- private class MockWebRequest extends WebRequest
- {
- private String responseText;
-
- public MockWebRequest(String responseText)
- {
- this.responseText = responseText;
- }
-
- @Override
- public ServerResponse httpGET(String url, List<HeaderEntry> headers)
- {
- if (url.indexOf("/notification.json") < 0)
- return new ServerResponse();
-
- ServerResponse response = new ServerResponse();
- response.setStatus(ServerResponse.NsStatus.OK);
- response.setResponseStatus(200);
- response.setResponse(responseText);
- return response;
- }
- }
-
@Test
public void testNoNotifications() throws InterruptedException
{
assertNull(peekNotification(""));
}
@Test
public void testAddNotification() throws InterruptedException
@@ -147,17 +112,17 @@
notification = peekNotification("http://www.com");
assertNotNull(notification);
assertEquals(Notification.Type.INFORMATION, notification.getType());
}
@Test
public void testMarkAsShown() throws InterruptedException
{
- addNotification("{ type: 'question' }");
+ addNotification("{ id: 'id', type: 'information' }");
assertNotNull(peekNotification(""));
Notification notification = peekNotification("");
assertNotNull(notification);
Thread.sleep(1000);
notification.markAsShown();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld