| 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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| 8 |
| 7 import android.content.Intent; | 9 import android.content.Intent; |
| 8 import android.net.Uri; | 10 import android.net.Uri; |
| 9 import android.view.ViewGroup; | 11 import android.view.ViewGroup; |
| 10 | 12 |
| 11 import org.chromium.base.ThreadUtils; | 13 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.chrome.browser.ShortcutHelper; | 14 import org.chromium.chrome.browser.ShortcutHelper; |
| 13 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 15 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 14 import org.chromium.content.browser.test.util.CallbackHelper; | 16 import org.chromium.content.browser.test.util.CallbackHelper; |
| 15 import org.chromium.content.browser.test.util.Criteria; | 17 import org.chromium.content.browser.test.util.Criteria; |
| 16 import org.chromium.content.browser.test.util.CriteriaHelper; | 18 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 17 import org.chromium.content.browser.test.util.TestWebContentsObserver; | 19 import org.chromium.content.browser.test.util.TestWebContentsObserver; |
| 18 import org.chromium.content_public.browser.LoadUrlParams; | 20 import org.chromium.content_public.browser.LoadUrlParams; |
| 19 import org.chromium.ui.base.PageTransition; | 21 import org.chromium.ui.base.PageTransition; |
| 20 | 22 |
| 21 import java.util.concurrent.TimeoutException; | 23 import java.util.concurrent.TimeoutException; |
| 22 | 24 |
| 23 /** | 25 /** |
| 24 * The base class of the WebappActivity tests. It provides the common methods to
access the activity | 26 * The base class of the WebappActivity tests. It provides the common methods to
access the activity |
| 25 * UI. This particular test base only instantiates WebappActivity0. | 27 * UI. This particular test base only instantiates WebappActivity0. |
| 26 */ | 28 */ |
| 27 public abstract class WebappActivityTestBase extends ChromeActivityTestCaseBase<
WebappActivity0> { | 29 public abstract class WebappActivityTestBase extends ChromeActivityTestCaseBase<
WebappActivity0> { |
| 28 static final String WEBAPP_ID = "webapp_id"; | 30 static final String WEBAPP_ID = "webapp_id"; |
| 29 static final String WEBAPP_NAME = "webapp name"; | 31 static final String WEBAPP_NAME = "webapp name"; |
| 30 static final String WEBAPP_SHORT_NAME = "webapp short name"; | 32 static final String WEBAPP_SHORT_NAME = "webapp short name"; |
| 31 | 33 |
| 34 private static final long STARTUP_TIMEOUT = scaleTimeout(10000); |
| 35 |
| 32 // Empty 192x192 image generated with: | 36 // Empty 192x192 image generated with: |
| 33 // ShortcutHelper.encodeBitmapAsString(Bitmap.createBitmap(192, 192, Bitmap.
Config.ARGB_4444)); | 37 // ShortcutHelper.encodeBitmapAsString(Bitmap.createBitmap(192, 192, Bitmap.
Config.ARGB_4444)); |
| 34 protected static final String TEST_ICON = | 38 protected static final String TEST_ICON = |
| 35 "iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAABHNCSVQICAgIfAhkiAA
AAKZJREFU" | 39 "iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAABHNCSVQICAgIfAhkiAA
AAKZJREFU" |
| 36 + "eJztwTEBAAAAwqD1T20JT6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA" | 40 + "eJztwTEBAAAAwqD1T20JT6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA" |
| 37 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA" | 41 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAA" |
| 38 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4GQ
N4AAe3mX6IA" | 42 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4GQ
N4AAe3mX6IA" |
| 39 + "AAAASUVORK5CYII="; | 43 + "AAAASUVORK5CYII="; |
| 40 | 44 |
| 41 // Empty 512x512 image generated with: | 45 // Empty 512x512 image generated with: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 */ | 136 */ |
| 133 protected void waitUntilIdle() { | 137 protected void waitUntilIdle() { |
| 134 getInstrumentation().waitForIdleSync(); | 138 getInstrumentation().waitForIdleSync(); |
| 135 try { | 139 try { |
| 136 CriteriaHelper.pollInstrumentationThread(new Criteria() { | 140 CriteriaHelper.pollInstrumentationThread(new Criteria() { |
| 137 @Override | 141 @Override |
| 138 public boolean isSatisfied() { | 142 public boolean isSatisfied() { |
| 139 return getActivity().getActivityTab() != null | 143 return getActivity().getActivityTab() != null |
| 140 && !getActivity().getActivityTab().isLoading(); | 144 && !getActivity().getActivityTab().isLoading(); |
| 141 } | 145 } |
| 142 }); | 146 }, STARTUP_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
| 143 } catch (InterruptedException exception) { | 147 } catch (InterruptedException exception) { |
| 144 fail(); | 148 fail(); |
| 145 } | 149 } |
| 146 | 150 |
| 147 getInstrumentation().waitForIdleSync(); | 151 getInstrumentation().waitForIdleSync(); |
| 148 } | 152 } |
| 149 | 153 |
| 150 /** | 154 /** |
| 151 * Loads the URL in the WebappActivity and waits until it has been fully loa
ded. | 155 * Loads the URL in the WebappActivity and waits until it has been fully loa
ded. |
| 152 * @param url URL to load. | 156 * @param url URL to load. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 fail(); | 216 fail(); |
| 213 } | 217 } |
| 214 | 218 |
| 215 ViewGroup splashScreen = getActivity().getSplashScreenForTests(); | 219 ViewGroup splashScreen = getActivity().getSplashScreenForTests(); |
| 216 if (splashScreen == null) { | 220 if (splashScreen == null) { |
| 217 fail("No splash screen available."); | 221 fail("No splash screen available."); |
| 218 } | 222 } |
| 219 return splashScreen; | 223 return splashScreen; |
| 220 } | 224 } |
| 221 } | 225 } |
| OLD | NEW |