| 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..17d73b78ec58c6e61665be6dbc88f674151cee78 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,47 @@ 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 intent does not carry significant data and is expected to fail, but has to be
|
| + * 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());
|
| +
|
| + Context context = getInstrumentation().getTargetContext().getApplicationContext();
|
| +
|
| + Intent intent = new Intent(NotificationConstants.ACTION_CLICK_NOTIFICATION);
|
| + intent.setClass(context, NotificationService.Receiver.class);
|
| +
|
| + long persistentId = 42;
|
| +
|
| + intent.putExtra(NotificationConstants.EXTRA_PERSISTENT_NOTIFICATION_ID, persistentId);
|
| + intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_PROFILE_ID, "Default");
|
| + intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN, "example.com");
|
| + intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_TAG, "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;
|
| + }
|
| + });
|
| +
|
| + assertTrue("The native library should be loaded now", LibraryLoader.isInitialized());
|
| + assertNotNull(NotificationUIManager.getInstanceForTests());
|
| + }
|
| }
|
|
|