aboutsummaryrefslogtreecommitdiff
path: root/WordPress/src/androidTest/java/org/wordpress/android/ui/notifications/GCMIntentServiceTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'WordPress/src/androidTest/java/org/wordpress/android/ui/notifications/GCMIntentServiceTest.java')
-rw-r--r--WordPress/src/androidTest/java/org/wordpress/android/ui/notifications/GCMIntentServiceTest.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/WordPress/src/androidTest/java/org/wordpress/android/ui/notifications/GCMIntentServiceTest.java b/WordPress/src/androidTest/java/org/wordpress/android/ui/notifications/GCMIntentServiceTest.java
new file mode 100644
index 000000000..ae2dd501f
--- /dev/null
+++ b/WordPress/src/androidTest/java/org/wordpress/android/ui/notifications/GCMIntentServiceTest.java
@@ -0,0 +1,66 @@
+package org.wordpress.android.ui.notifications;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.test.RenamingDelegatingContext;
+import android.test.ServiceTestCase;
+
+import org.wordpress.android.FactoryUtils;
+import org.wordpress.android.GCMMessageService;
+import org.wordpress.android.TestUtils;
+import org.wordpress.android.models.AccountHelper;
+
+public class GCMIntentServiceTest extends ServiceTestCase<GCMMessageService> {
+ protected Context mTargetContext;
+
+ public GCMIntentServiceTest() {
+ super(GCMMessageService.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ FactoryUtils.initWithTestFactories();
+
+ mTargetContext = new RenamingDelegatingContext(getContext(), "test_");
+ TestUtils.clearApplicationState(mTargetContext);
+
+ setupService();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ FactoryUtils.clearFactories();
+ super.tearDown();
+ }
+
+ public void testShouldCircularizeNoteIcon() {
+ GCMMessageService intentService = new GCMMessageService();
+
+ String type = "c";
+ assertTrue(intentService.shouldCircularizeNoteIcon(type));
+
+ assertFalse(intentService.shouldCircularizeNoteIcon(null));
+
+ type = "invalidType";
+ assertFalse(intentService.shouldCircularizeNoteIcon(type));
+ }
+
+ public void testOnMessageReceived() throws InterruptedException {
+ org.wordpress.android.models.Account account = AccountHelper.getDefaultAccount();
+ account.setAccessToken("secret token");
+ account.setUserId(1);
+ final Bundle bundle = new Bundle();
+ bundle.putString("user", "1");
+ for (int i = 0; i < 1000; i++) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ getService().onMessageReceived("from", bundle);
+ }
+ }).start();
+ }
+
+ Thread.sleep(10000);
+ }
+}