Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/push_messaging/PushMessagingTest.java

Issue 2690163008: Route through a JobService when receiving a message for the GCM Driver (Closed)
Patch Set: Route through a JobService when receiving a message for the GCM Driver Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java_sources.gni ('k') | components/gcm_driver/android/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.push_messaging; 5 package org.chromium.chrome.browser.push_messaging;
6 6
7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
8 8
9 import android.annotation.SuppressLint; 9 import android.annotation.SuppressLint;
10 import android.app.Notification; 10 import android.app.Notification;
(...skipping 12 matching lines...) Expand all
23 import org.chromium.base.test.util.RetryOnFailure; 23 import org.chromium.base.test.util.RetryOnFailure;
24 import org.chromium.chrome.browser.infobar.InfoBar; 24 import org.chromium.chrome.browser.infobar.InfoBar;
25 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; 25 import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
26 import org.chromium.chrome.browser.notifications.NotificationTestBase; 26 import org.chromium.chrome.browser.notifications.NotificationTestBase;
27 import org.chromium.chrome.browser.preferences.website.ContentSetting; 27 import org.chromium.chrome.browser.preferences.website.ContentSetting;
28 import org.chromium.chrome.browser.tab.Tab; 28 import org.chromium.chrome.browser.tab.Tab;
29 import org.chromium.chrome.test.util.InfoBarUtil; 29 import org.chromium.chrome.test.util.InfoBarUtil;
30 import org.chromium.chrome.test.util.browser.TabTitleObserver; 30 import org.chromium.chrome.test.util.browser.TabTitleObserver;
31 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy.NotificationEntry; 31 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy.NotificationEntry;
32 import org.chromium.components.gcm_driver.GCMDriver; 32 import org.chromium.components.gcm_driver.GCMDriver;
33 import org.chromium.components.gcm_driver.GCMMessage;
33 import org.chromium.components.gcm_driver.instance_id.FakeInstanceIDWithSubtype; 34 import org.chromium.components.gcm_driver.instance_id.FakeInstanceIDWithSubtype;
34 import org.chromium.content.browser.test.util.Criteria; 35 import org.chromium.content.browser.test.util.Criteria;
35 import org.chromium.content.browser.test.util.CriteriaHelper; 36 import org.chromium.content.browser.test.util.CriteriaHelper;
36 import org.chromium.content.browser.test.util.JavaScriptUtils; 37 import org.chromium.content.browser.test.util.JavaScriptUtils;
37 38
38 import java.util.List; 39 import java.util.List;
39 import java.util.concurrent.TimeoutException; 40 import java.util.concurrent.TimeoutException;
40 41
41 /** 42 /**
42 * Instrumentation tests for the Push API and the integration with the Notificat ions API on Android. 43 * Instrumentation tests for the Push API and the integration with the Notificat ions API on Android.
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 287 }
287 288
288 private void sendPushAndWaitForCallback(Pair<String, String> appIdAndSenderI d) 289 private void sendPushAndWaitForCallback(Pair<String, String> appIdAndSenderI d)
289 throws InterruptedException, TimeoutException { 290 throws InterruptedException, TimeoutException {
290 final String appId = appIdAndSenderId.first; 291 final String appId = appIdAndSenderId.first;
291 final String senderId = appIdAndSenderId.second; 292 final String senderId = appIdAndSenderId.second;
292 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 293 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
293 @Override 294 @Override
294 public void run() { 295 public void run() {
295 Context context = getInstrumentation().getTargetContext().getApp licationContext(); 296 Context context = getInstrumentation().getTargetContext().getApp licationContext();
297
296 Bundle extras = new Bundle(); 298 Bundle extras = new Bundle();
299 extras.putString("subtype", appId);
300
301 GCMMessage message = new GCMMessage(senderId, extras);
297 try { 302 try {
298 ChromeBrowserInitializer.getInstance(context).handleSynchron ousStartup(); 303 ChromeBrowserInitializer.getInstance(context).handleSynchron ousStartup();
299 GCMDriver.onMessageReceived(appId, senderId, extras); 304 GCMDriver.dispatchMessage(message);
300 } catch (ProcessInitException e) { 305 } catch (ProcessInitException e) {
301 fail("Chrome browser failed to initialize."); 306 fail("Chrome browser failed to initialize.");
302 } 307 }
303 } 308 }
304 }); 309 });
305 mMessageHandledHelper.waitForCallback(mMessageHandledHelper.getCallCount ()); 310 mMessageHandledHelper.waitForCallback(mMessageHandledHelper.getCallCount ());
306 } 311 }
307 312
308 private void waitForTitle(Tab tab, String expectedTitle) throws InterruptedE xception { 313 private void waitForTitle(Tab tab, String expectedTitle) throws InterruptedE xception {
309 TabTitleObserver titleObserver = new TabTitleObserver(tab, expectedTitle ); 314 TabTitleObserver titleObserver = new TabTitleObserver(tab, expectedTitle );
(...skipping 20 matching lines...) Expand all
330 private void waitForInfobarToClose() { 335 private void waitForInfobarToClose() {
331 CriteriaHelper.pollUiThread(new Criteria() { 336 CriteriaHelper.pollUiThread(new Criteria() {
332 @Override 337 @Override
333 public boolean isSatisfied() { 338 public boolean isSatisfied() {
334 return getInfoBars().isEmpty(); 339 return getInfoBars().isEmpty();
335 } 340 }
336 }); 341 });
337 assertEquals(0, getInfoBars().size()); 342 assertEquals(0, getInfoBars().size());
338 } 343 }
339 } 344 }
OLDNEW
« no previous file with comments | « chrome/android/java_sources.gni ('k') | components/gcm_driver/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698