OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |