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

Unified Diff: chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java

Issue 2858563004: Add support for webapk without runtimeHost (Closed)
Patch Set: Delete private data before switching host browser. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java
diff --git a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java b/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java
deleted file mode 100644
index c7ec5752f7a9cae9827865f8fa9ac6c45808c40c..0000000000000000000000000000000000000000
--- a/chrome/android/webapk/shell_apk/junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.webapk.shell_apk;
-
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ResolveInfo;
-import android.os.Bundle;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.annotation.Config;
-import org.robolectric.res.builder.RobolectricPackageManager;
-import org.robolectric.shadows.ShadowApplication;
-
-import org.chromium.testing.local.LocalRobolectricTestRunner;
-import org.chromium.webapk.lib.common.WebApkMetaDataKeys;
-import org.chromium.webapk.test.WebApkTestHelper;
-
-/**
- * Tests MainActivity.
- */
-@RunWith(LocalRobolectricTestRunner.class)
-@Config(manifest = Config.NONE, packageName = MainActivityTest.WEBAPK_PACKAGE_NAME)
-public class MainActivityTest {
- private static final String HOST_BROWSER_PACKAGE_NAME = "truly.random";
-
- protected static final String WEBAPK_PACKAGE_NAME = "org.chromium.webapk.test_package";
- private ShadowApplication mShadowApplication;
- private RobolectricPackageManager mPackageManager;
-
- @Before
- public void setUp() {
- mShadowApplication = Shadows.shadowOf(RuntimeEnvironment.application);
- mPackageManager =
- (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
- }
-
- /**
- * Tests that when the user launches the WebAPK and the user does not have any browser installed
- * that the WebAPK launches Google Play to install the host browser.
- */
- @Test
- public void testBrowserNotInstalled() {
- // Throw ActivityNotFoundException if Intent cannot be resolved.
- mShadowApplication.checkActivities(true);
-
- // Set WebAPK's meta-data.
- Bundle metaData = new Bundle();
- metaData.putString(WebApkMetaDataKeys.RUNTIME_HOST, HOST_BROWSER_PACKAGE_NAME);
- metaData.putString(WebApkMetaDataKeys.START_URL, "http://random.org");
- WebApkTestHelper.registerWebApkWithMetaData(WEBAPK_PACKAGE_NAME, metaData);
-
- // Make intents to Google Play not throw ActivityNotFoundException.
- mPackageManager.addResolveInfoForIntent(
- MainActivity.createInstallIntent(HOST_BROWSER_PACKAGE_NAME),
- newResolveInfo("google.play"));
-
- Robolectric.buildActivity(MainActivity.class).create();
-
- Intent startActivityIntent = mShadowApplication.getNextStartedActivity();
- Assert.assertNotNull(startActivityIntent);
- Assert.assertTrue(startActivityIntent.getDataString().startsWith("market://"));
- }
-
- /**
- * Test that when the user launches the WebAPK and the user has neither a browser nor Google
- * Play installed that launching the WebAPK silently fails and does not crash.
- */
- @Test
- public void testBrowserNotInstalledAndGooglePlayNotInstalled() {
- // Throw ActivityNotFoundException if Intent cannot be resolved.
- mShadowApplication.checkActivities(true);
-
- // Set WebAPK's meta-data.
- Bundle metaData = new Bundle();
- metaData.putString(WebApkMetaDataKeys.RUNTIME_HOST, HOST_BROWSER_PACKAGE_NAME);
- metaData.putString(WebApkMetaDataKeys.START_URL, "http://random.org");
- WebApkTestHelper.registerWebApkWithMetaData(WEBAPK_PACKAGE_NAME, metaData);
-
- Robolectric.buildActivity(MainActivity.class).create();
-
- Intent startActivityIntent = mShadowApplication.getNextStartedActivity();
- Assert.assertNull(startActivityIntent);
- }
-
- private static ResolveInfo newResolveInfo(String packageName) {
- ActivityInfo activityInfo = new ActivityInfo();
- activityInfo.packageName = packageName;
- ResolveInfo resolveInfo = new ResolveInfo();
- resolveInfo.activityInfo = activityInfo;
- return resolveInfo;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698