| Index: chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java
|
| index d7af8a3b7e0058e86f60d65467512b9e613b19f2..0131722999b1a8640d5832098657f03f2b2b00d4 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java
|
| @@ -22,11 +22,12 @@ import org.chromium.chrome.browser.preferences.website.ContentSetting;
|
| import org.chromium.chrome.browser.tab.Tab;
|
| import org.chromium.chrome.test.util.browser.TabTitleObserver;
|
| import org.chromium.chrome.test.util.browser.notifications.MockNotificationManagerProxy.NotificationEntry;
|
| -import org.chromium.components.gcm_driver.FakeGoogleCloudMessagingSubscriber;
|
| import org.chromium.components.gcm_driver.GCMDriver;
|
| +import org.chromium.components.gcm_driver.instance_id.InstanceIDWithSubtype;
|
| import org.chromium.content.browser.test.util.CallbackHelper;
|
| import org.chromium.content.browser.test.util.JavaScriptUtils;
|
|
|
| +import java.util.Map;
|
| import java.util.concurrent.TimeoutException;
|
|
|
| /**
|
| @@ -52,6 +53,7 @@ public class PushMessagingTest
|
| @Override
|
| protected void setUp() throws Exception {
|
| super.setUp();
|
| + InstanceIDWithSubtype.clearDataAndSetUseFakeForTesting(true);
|
| final PushMessagingServiceObserver.Listener listener = this;
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| @@ -70,6 +72,7 @@ public class PushMessagingTest
|
| PushMessagingServiceObserver.setListenerForTesting(null);
|
| }
|
| });
|
| + InstanceIDWithSubtype.clearDataAndSetUseFakeForTesting(false);
|
| super.tearDown();
|
| }
|
|
|
| @@ -84,15 +87,11 @@ public class PushMessagingTest
|
| @MediumTest
|
| @Feature({"Browser", "PushMessaging"})
|
| public void testPushAndShowNotification() throws InterruptedException, TimeoutException {
|
| - FakeGoogleCloudMessagingSubscriber subscriber = new FakeGoogleCloudMessagingSubscriber();
|
| - GCMDriver.overrideSubscriberForTesting(subscriber);
|
| -
|
| loadUrl(mPushTestPage);
|
| setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
|
| runScriptAndWaitForTitle("subscribePush()", "subscribe ok");
|
|
|
| - sendPushAndWaitForCallback(
|
| - subscriber.getLastSubscribeSubtype(), subscriber.getLastSubscribeSource());
|
| + sendPushAndWaitForCallback(getSubscribedSubtype(), getSubscribedSenderId());
|
| NotificationEntry notificationEntry = waitForNotification();
|
| assertEquals("push notification 1",
|
| notificationEntry.notification.extras.getString(Notification.EXTRA_TITLE));
|
| @@ -105,9 +104,6 @@ public class PushMessagingTest
|
| @LargeTest
|
| @Feature({"Browser", "PushMessaging"})
|
| public void testDefaultNotification() throws InterruptedException, TimeoutException {
|
| - FakeGoogleCloudMessagingSubscriber subscriber = new FakeGoogleCloudMessagingSubscriber();
|
| - GCMDriver.overrideSubscriberForTesting(subscriber);
|
| -
|
| // Load the push test page into the first tab.
|
| loadUrl(mPushTestPage);
|
| assertEquals(1, getActivity().getCurrentTabModel().getCount());
|
| @@ -118,8 +114,8 @@ public class PushMessagingTest
|
| // Set up the push subscription and capture its details.
|
| setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
|
| runScriptAndWaitForTitle("subscribePush()", "subscribe ok");
|
| - String appId = subscriber.getLastSubscribeSubtype();
|
| - String senderId = subscriber.getLastSubscribeSource();
|
| + String appId = getSubscribedSubtype();
|
| + String senderId = getSubscribedSenderId();
|
|
|
| // Make the tab invisible by opening another one with a different origin.
|
| loadUrlInNewTab(ABOUT_BLANK);
|
| @@ -166,6 +162,26 @@ public class PushMessagingTest
|
| waitForTitle(tab, expectedTitle);
|
| }
|
|
|
| + private String getSubscribedSubtype() {
|
| + Map<String, InstanceIDWithSubtype> instanceIDs =
|
| + InstanceIDWithSubtype.getInstanceIDsForTesting();
|
| + assertEquals(1, instanceIDs.size());
|
| + for (InstanceIDWithSubtype iid : instanceIDs.values()) {
|
| + return iid.getSubtype();
|
| + }
|
| + throw new AssertionError();
|
| + }
|
| +
|
| + private String getSubscribedSenderId() {
|
| + Map<String, InstanceIDWithSubtype> instanceIDs =
|
| + InstanceIDWithSubtype.getInstanceIDsForTesting();
|
| + assertEquals(1, instanceIDs.size());
|
| + for (String senderId : instanceIDs.keySet()) {
|
| + return senderId;
|
| + }
|
| + throw new AssertionError();
|
| + }
|
| +
|
| private void sendPushAndWaitForCallback(final String appId, final String senderId)
|
| throws InterruptedException, TimeoutException {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
|
|