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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java

Issue 2701333002: Add integration tests for WebAPKs (Closed)
Patch Set: Merge branch 'remove_load_url' into integration_test 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..825e8a32094721c2c205aca8225aae78fe8a1100
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
@@ -0,0 +1,85 @@
+// Copyright 2017 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.chrome.browser.webapps;
+
+import android.content.Intent;
+import android.support.test.filters.LargeTest;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.base.test.util.ScalableTimeout;
+import org.chromium.chrome.browser.ShortcutHelper;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.chrome.test.util.ChromeTabUtils;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
+import org.chromium.net.test.EmbeddedTestServer;
+
+/** Integration tests for WebAPK feature. */
+public class WebApkIntegrationTest extends ChromeActivityTestCaseBase<TestWebApkActivity> {
+ private static final long STARTUP_TIMEOUT = ScalableTimeout.scaleTimeout(10000);
+
+ private EmbeddedTestServer mTestServer;
+
+ public WebApkIntegrationTest() {
+ super(TestWebApkActivity.class);
+ }
+
+ public void startWebApkActivity(String packageName, final String startUrl)
+ throws InterruptedException {
+ Intent intent =
+ new Intent(getInstrumentation().getTargetContext(), TestWebApkActivity.class);
+ intent.putExtra(ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, packageName);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, startUrl);
+ setActivityIntent(intent);
+
+ CriteriaHelper.pollInstrumentationThread(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return getActivity().getActivityTab() != null;
+ }
+ }, STARTUP_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
+
+ ChromeTabUtils.waitForTabPageLoaded(getActivity().getActivityTab(), startUrl);
+ }
+
+ /** Waits for the splash screen to be hidden. */
+ public void waitUntilSplashscreenHides() {
+ CriteriaHelper.pollInstrumentationThread(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return !getActivity().isSplashScreenVisibleForTests();
+ }
+ });
+ }
+
+ @Override
+ public final void startMainActivity() throws InterruptedException {
+ // Do nothing
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mTestServer.stopAndDestroyServer();
+ super.tearDown();
+ }
+
+ /**
+ * Test launching a WebAPK. Test that loading the start page works and that the splashscreen
+ * eventually hides.
+ */
+ @LargeTest
+ @Feature({"WebApk"})
+ public void testLaunch() throws InterruptedException {
+ startWebApkActivity("org.chromium.webapk.test",
+ mTestServer.getURL("/chrome/test/data/android/test.html"));
+ waitUntilSplashscreenHides();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698