Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerIntentTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerIntentTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerIntentTest.java |
| index 71be46d0fd99420e99b5431fa45ccf25ebafa093..972fa583890eea6968b0b7bf2d8fd7e2b1c60ec3 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerIntentTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerIntentTest.java |
| @@ -5,6 +5,7 @@ |
| package org.chromium.chrome.browser.notifications; |
| import android.app.Notification; |
| +import android.app.PendingIntent; |
| import android.content.Context; |
| import android.content.Intent; |
| import android.test.suitebuilder.annotation.MediumTest; |
| @@ -18,6 +19,8 @@ import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences |
| import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; |
| import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| import org.chromium.chrome.test.util.ActivityUtils; |
| +import org.chromium.content.browser.test.util.Criteria; |
| +import org.chromium.content.browser.test.util.CriteriaHelper; |
| /** |
| * Instrumentation tests for the Notification UI Manager implementation on Android. |
| @@ -113,4 +116,43 @@ public class NotificationUIManagerIntentTest extends ChromeActivityTestCaseBase< |
| ActivityUtils.waitForFragmentToAttach(activity, SingleWebsitePreferences.class); |
| assertNotNull("Could not find the SingleWebsitePreferences fragment", fragment); |
| } |
| + |
| + /** |
| + * Tests the browser initialization code when a notification has been activated. This will be |
| + * routed through the NotificationService which starts the browser process, which in turn will |
| + * create an instance of the NotificationUIManager. |
| + * |
| + * The created intend does not carry significant data and is expected to fail, but has to be |
|
Michael van Ouwerkerk
2016/03/31 10:00:04
s/intend/intent/
Peter Beverloo
2016/03/31 15:12:17
Done.
|
| + * sufficient for the Java code to trigger start-up of the browser process. |
| + */ |
| + @MediumTest |
| + @Feature({"Browser", "Notifications"}) |
| + public void testLaunchProcessForNotificationActivation() throws Exception { |
| + assertFalse("The native library should not be loaded yet", LibraryLoader.isInitialized()); |
| + assertNull(NotificationUIManager.getInstanceForTests()); |
| + |
| + final Context context = getInstrumentation().getTargetContext().getApplicationContext(); |
|
Michael van Ouwerkerk
2016/03/31 10:00:04
tiny nit: no need for |final| here as it is not us
Peter Beverloo
2016/03/31 15:12:17
Done.
|
| + |
| + Intent intent = new Intent(NotificationConstants.ACTION_CLICK_NOTIFICATION); |
| + intent.setClass(context, NotificationService.Receiver.class); |
| + |
| + intent.putExtra(NotificationConstants.EXTRA_PERSISTENT_NOTIFICATION_ID, 42); |
| + intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN, "example.com"); |
| + intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_TAG, ""); |
| + |
| + PendingIntent pendingIntent = PendingIntent.getBroadcast( |
| + context, 0 /* request code */, intent, PendingIntent.FLAG_UPDATE_CURRENT); |
| + |
| + // Send the pending intent. This will begin starting up the browser process. |
| + pendingIntent.send(); |
| + |
| + CriteriaHelper.pollUiThread(new Criteria("Browser process was never started.") { |
| + @Override |
| + public boolean isSatisfied() { |
| + return NotificationUIManager.getInstanceForTests() != null; |
| + } |
| + }); |
| + |
| + assertNotNull(NotificationUIManager.getInstanceForTests()); |
|
Michael van Ouwerkerk
2016/03/31 10:00:04
Perhaps for symmetry with the start of this test,
Peter Beverloo
2016/03/31 15:12:17
Done.
|
| + } |
| } |