| Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenTest.java
|
| index 1b276b739a0791bea87c1dbd36f1694950066c04..f391c0fe17e13cb42dc1f128c2a3adc851a6da52 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenTest.java
|
| @@ -6,7 +6,6 @@ package org.chromium.chrome.browser.webapps;
|
|
|
| import android.annotation.TargetApi;
|
| import android.content.Context;
|
| -import android.content.Intent;
|
| import android.graphics.Bitmap;
|
| import android.graphics.Color;
|
| import android.graphics.drawable.ColorDrawable;
|
| @@ -18,21 +17,35 @@ import android.widget.ImageView;
|
| import android.widget.RelativeLayout;
|
| import android.widget.TextView;
|
|
|
| +import org.junit.Assert;
|
| +import org.junit.Rule;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +
|
| import org.chromium.base.ApiCompatibilityUtils;
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.metrics.RecordHistogram;
|
| +import org.chromium.base.test.util.CommandLineFlags;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.RetryOnFailure;
|
| import org.chromium.chrome.R;
|
| +import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.ShortcutHelper;
|
| import org.chromium.chrome.browser.metrics.WebappUma;
|
| import org.chromium.chrome.browser.tab.Tab;
|
| import org.chromium.chrome.browser.tab.TabTestUtils;
|
| +import org.chromium.chrome.test.ChromeActivityTestRule;
|
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
|
|
| /**
|
| * Tests for splash screens.
|
| */
|
| -public class WebappSplashScreenTest extends WebappActivityTestBase {
|
| +@RunWith(ChromeJUnit4ClassRunner.class)
|
| +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| +public class WebappSplashScreenTest {
|
| + @Rule
|
| + public final WebappActivityTestRule mActivityTestRule = new WebappActivityTestRule();
|
|
|
| private int getHistogramTotalCountFor(String histogram, int buckets) {
|
| int count = 0;
|
| @@ -53,109 +66,121 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
|
| return false;
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testDefaultBackgroundColor() throws Exception {
|
| - startWebappActivity();
|
| - ViewGroup splashScreen = waitUntilSplashScreenAppears();
|
| + mActivityTestRule.startWebappActivity();
|
| + ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears();
|
| ColorDrawable background = (ColorDrawable) splashScreen.getBackground();
|
|
|
| - assertEquals(ApiCompatibilityUtils.getColor(getActivity().getResources(),
|
| - R.color.webapp_default_bg),
|
| + Assert.assertEquals(
|
| + ApiCompatibilityUtils.getColor(
|
| + mActivityTestRule.getActivity().getResources(), R.color.webapp_default_bg),
|
| background.getColor());
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
| @RetryOnFailure
|
| public void testThemeColorWhenNotSpecified() throws Exception {
|
| - startWebappActivity();
|
| + mActivityTestRule.startWebappActivity();
|
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
|
|
|
| - assertEquals(Color.BLACK, getActivity().getWindow().getStatusBarColor());
|
| + Assert.assertEquals(
|
| + Color.BLACK, mActivityTestRule.getActivity().getWindow().getStatusBarColor());
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testHidesAfterFirstPaint() throws Exception {
|
| - startWebappActivity();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| public void run() {
|
| - TabTestUtils.simulateFirstVisuallyNonEmptyPaint(getActivity().getActivityTab());
|
| + TabTestUtils.simulateFirstVisuallyNonEmptyPaint(
|
| + mActivityTestRule.getActivity().getActivityTab());
|
| }
|
| });
|
|
|
| - waitUntilSplashscreenHides();
|
| + mActivityTestRule.waitUntilSplashscreenHides();
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| - public void testHidesAfterCrash() throws Exception {
|
| - startWebappActivity();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + public void testHidesAfterCrash() throws Throwable {
|
| + mActivityTestRule.startWebappActivity();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| public void run() {
|
| - TabTestUtils.simulateCrash(getActivity().getActivityTab(), true);
|
| + TabTestUtils.simulateCrash(mActivityTestRule.getActivity().getActivityTab(), true);
|
| }
|
| });
|
|
|
| - waitUntilSplashscreenHides();
|
| + mActivityTestRule.waitUntilSplashscreenHides();
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testHidesAfterLoadCompletes() throws Exception {
|
| - startWebappActivity();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| public void run() {
|
| - TabTestUtils.simulatePageLoadFinished(getActivity().getActivityTab());
|
| + TabTestUtils.simulatePageLoadFinished(
|
| + mActivityTestRule.getActivity().getActivityTab());
|
| }
|
| });
|
|
|
| - waitUntilSplashscreenHides();
|
| + mActivityTestRule.waitUntilSplashscreenHides();
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testHidesAfterLoadFails() throws Exception {
|
| - startWebappActivity();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| public void run() {
|
| - TabTestUtils.simulatePageLoadFailed(getActivity().getActivityTab(), 0);
|
| + TabTestUtils.simulatePageLoadFailed(
|
| + mActivityTestRule.getActivity().getActivityTab(), 0);
|
| }
|
| });
|
|
|
| - waitUntilSplashscreenHides();
|
| + mActivityTestRule.waitUntilSplashscreenHides();
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testHidesAfterMultipleEvents() throws Exception {
|
| - startWebappActivity();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| public void run() {
|
| - Tab tab = getActivity().getActivityTab();
|
| + Tab tab = mActivityTestRule.getActivity().getActivityTab();
|
|
|
| TabTestUtils.simulatePageLoadFinished(tab);
|
| TabTestUtils.simulatePageLoadFailed(tab, 0);
|
| @@ -163,78 +188,95 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
|
| }
|
| });
|
|
|
| - waitUntilSplashscreenHides();
|
| + mActivityTestRule.waitUntilSplashscreenHides();
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testUmaOnNativeLoad() throws Exception {
|
| - startWebappActivity();
|
| + mActivityTestRule.startWebappActivity();
|
|
|
| // Tests UMA values.
|
| - assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
|
| - WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR,
|
| - WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT));
|
| - assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
|
| - WebappUma.HISTOGRAM_SPLASHSCREEN_THEMECOLOR,
|
| - WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT));
|
| - assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
|
| - WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| - WebappUma.SPLASHSCREEN_ICON_TYPE_NONE));
|
| + Assert.assertEquals(1,
|
| + RecordHistogram.getHistogramValueCountForTesting(
|
| + WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR,
|
| + WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT));
|
| + Assert.assertEquals(1,
|
| + RecordHistogram.getHistogramValueCountForTesting(
|
| + WebappUma.HISTOGRAM_SPLASHSCREEN_THEMECOLOR,
|
| + WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT));
|
| + Assert.assertEquals(1,
|
| + RecordHistogram.getHistogramValueCountForTesting(
|
| + WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| + WebappUma.SPLASHSCREEN_ICON_TYPE_NONE));
|
|
|
| // Tests UMA counts.
|
| - assertEquals(1, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR,
|
| - WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| - assertEquals(1, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_THEMECOLOR,
|
| - WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| - assertEquals(1, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| - WebappUma.SPLASHSCREEN_ICON_TYPE_MAX));
|
| + Assert.assertEquals(1,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR,
|
| + WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| + Assert.assertEquals(1,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_THEMECOLOR,
|
| + WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| + Assert.assertEquals(1,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| + WebappUma.SPLASHSCREEN_ICON_TYPE_MAX));
|
|
|
| // Given that there is no icon, the ICON_SIZE UMA should not be recorded.
|
| - assertEquals(0, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_SIZE, 50));
|
| + Assert.assertEquals(
|
| + 0, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_SIZE, 50));
|
|
|
| // DURATION and HIDES UMA should not have been recorded yet.
|
| - assertFalse(hasHistogramEntry(WebappUma.HISTOGRAM_SPLASHSCREEN_DURATION, 3000));
|
| - assertEquals(0, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_HIDES,
|
| - WebappUma.SPLASHSCREEN_HIDES_REASON_MAX));
|
| + Assert.assertFalse(hasHistogramEntry(WebappUma.HISTOGRAM_SPLASHSCREEN_DURATION, 3000));
|
| + Assert.assertEquals(0,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_HIDES,
|
| + WebappUma.SPLASHSCREEN_HIDES_REASON_MAX));
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testUmaWhenSplashHides() throws Exception {
|
| - startWebappActivity();
|
| + mActivityTestRule.startWebappActivity();
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| public void run() {
|
| - TabTestUtils.simulateFirstVisuallyNonEmptyPaint(getActivity().getActivityTab());
|
| + TabTestUtils.simulateFirstVisuallyNonEmptyPaint(
|
| + mActivityTestRule.getActivity().getActivityTab());
|
| }
|
| });
|
|
|
| - waitUntilSplashscreenHides();
|
| + mActivityTestRule.waitUntilSplashscreenHides();
|
|
|
| // DURATION and HIDES should now have a value.
|
| - assertTrue(hasHistogramEntry(WebappUma.HISTOGRAM_SPLASHSCREEN_DURATION, 5000));
|
| - assertEquals(1, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_HIDES,
|
| - WebappUma.SPLASHSCREEN_HIDES_REASON_MAX));
|
| + Assert.assertTrue(hasHistogramEntry(WebappUma.HISTOGRAM_SPLASHSCREEN_DURATION, 5000));
|
| + Assert.assertEquals(1,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_HIDES,
|
| + WebappUma.SPLASHSCREEN_HIDES_REASON_MAX));
|
|
|
| // The other UMA records should not have changed.
|
| - assertEquals(1, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR,
|
| - WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| - assertEquals(1, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_THEMECOLOR,
|
| - WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| - assertEquals(1, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| - WebappUma.SPLASHSCREEN_ICON_TYPE_MAX));
|
| - assertEquals(0, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_SIZE, 50));
|
| + Assert.assertEquals(1,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_BACKGROUNDCOLOR,
|
| + WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| + Assert.assertEquals(1,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_THEMECOLOR,
|
| + WebappUma.SPLASHSCREEN_COLOR_STATUS_MAX));
|
| + Assert.assertEquals(1,
|
| + getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| + WebappUma.SPLASHSCREEN_ICON_TYPE_MAX));
|
| + Assert.assertEquals(
|
| + 0, getHistogramTotalCountFor(WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_SIZE, 50));
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testRegularSplashScreenAppears() throws Exception {
|
| // Register a properly-sized icon for the splash screen.
|
| - Context context = getInstrumentation().getTargetContext();
|
| + Context context = mActivityTestRule.getInstrumentation().getTargetContext();
|
| int thresholdSize = context.getResources().getDimensionPixelSize(
|
| R.dimen.webapp_splash_image_size_threshold);
|
| int size = thresholdSize + 1;
|
| @@ -242,31 +284,32 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
|
| String bitmapString = ShortcutHelper.encodeBitmapAsString(splashBitmap);
|
|
|
| TestFetchStorageCallback callback = new TestFetchStorageCallback();
|
| - WebappRegistry.getInstance().register(WEBAPP_ID, callback);
|
| + WebappRegistry.getInstance().register(WebappActivityTestRule.WEBAPP_ID, callback);
|
| callback.waitForCallback(0);
|
| callback.getStorage().updateSplashScreenImage(bitmapString);
|
|
|
| - startWebappActivity(createIntent());
|
| - ViewGroup splashScreen = waitUntilSplashScreenAppears();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity();
|
| + ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| ImageView splashImage =
|
| (ImageView) splashScreen.findViewById(R.id.webapp_splash_screen_icon);
|
| - assertEquals(size, splashImage.getMeasuredWidth());
|
| - assertEquals(size, splashImage.getMeasuredHeight());
|
| + Assert.assertEquals(size, splashImage.getMeasuredWidth());
|
| + Assert.assertEquals(size, splashImage.getMeasuredHeight());
|
|
|
| TextView splashText = (TextView) splashScreen.findViewById(R.id.webapp_splash_screen_name);
|
| int[] rules = ((RelativeLayout.LayoutParams) splashText.getLayoutParams()).getRules();
|
| - assertEquals(RelativeLayout.TRUE, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| - assertEquals(0, rules[RelativeLayout.BELOW]);
|
| + Assert.assertEquals(RelativeLayout.TRUE, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| + Assert.assertEquals(0, rules[RelativeLayout.BELOW]);
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testSmallSplashScreenAppears() throws Exception {
|
| // Register a smaller icon for the splash screen.
|
| - Context context = getInstrumentation().getTargetContext();
|
| + Context context = mActivityTestRule.getInstrumentation().getTargetContext();
|
| int thresholdSize = context.getResources().getDimensionPixelSize(
|
| R.dimen.webapp_splash_image_size_threshold);
|
| int size = context.getResources().getDimensionPixelSize(
|
| @@ -275,89 +318,90 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
|
| String bitmapString = ShortcutHelper.encodeBitmapAsString(splashBitmap);
|
|
|
| TestFetchStorageCallback callback = new TestFetchStorageCallback();
|
| - WebappRegistry.getInstance().register(WEBAPP_ID, callback);
|
| + WebappRegistry.getInstance().register(WebappActivityTestRule.WEBAPP_ID, callback);
|
| callback.waitForCallback(0);
|
| callback.getStorage().updateSplashScreenImage(bitmapString);
|
|
|
| - startWebappActivity(createIntent());
|
| - ViewGroup splashScreen = waitUntilSplashScreenAppears();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity();
|
| + ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| // The icon is centered within a fixed-size area on the splash screen.
|
| ImageView splashImage =
|
| (ImageView) splashScreen.findViewById(R.id.webapp_splash_screen_icon);
|
| - assertEquals(thresholdSize, splashImage.getMeasuredWidth());
|
| - assertEquals(thresholdSize, splashImage.getMeasuredHeight());
|
| + Assert.assertEquals(thresholdSize, splashImage.getMeasuredWidth());
|
| + Assert.assertEquals(thresholdSize, splashImage.getMeasuredHeight());
|
|
|
| // The web app name is anchored to the icon.
|
| TextView splashText = (TextView) splashScreen.findViewById(R.id.webapp_splash_screen_name);
|
| int[] rules = ((RelativeLayout.LayoutParams) splashText.getLayoutParams()).getRules();
|
| - assertEquals(0, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| - assertEquals(R.id.webapp_splash_screen_icon, rules[RelativeLayout.BELOW]);
|
| + Assert.assertEquals(0, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| + Assert.assertEquals(R.id.webapp_splash_screen_icon, rules[RelativeLayout.BELOW]);
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testSplashScreenWithoutImageAppears() throws Exception {
|
| // Register an image that's too small for the splash screen.
|
| - Context context = getInstrumentation().getTargetContext();
|
| + Context context = mActivityTestRule.getInstrumentation().getTargetContext();
|
| int size = context.getResources().getDimensionPixelSize(
|
| R.dimen.webapp_splash_image_size_minimum) - 1;
|
| Bitmap splashBitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
| String bitmapString = ShortcutHelper.encodeBitmapAsString(splashBitmap);
|
|
|
| TestFetchStorageCallback callback = new TestFetchStorageCallback();
|
| - WebappRegistry.getInstance().register(WEBAPP_ID, callback);
|
| + WebappRegistry.getInstance().register(WebappActivityTestRule.WEBAPP_ID, callback);
|
| callback.waitForCallback(0);
|
| callback.getStorage().updateSplashScreenImage(bitmapString);
|
|
|
| - Intent intent = createIntent();
|
| - intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, true);
|
| - startWebappActivity(intent);
|
| - ViewGroup splashScreen = waitUntilSplashScreenAppears();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity(mActivityTestRule.createIntent().putExtra(
|
| + ShortcutHelper.EXTRA_IS_ICON_GENERATED, true));
|
| + ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| // There's no icon displayed.
|
| ImageView splashImage =
|
| (ImageView) splashScreen.findViewById(R.id.webapp_splash_screen_icon);
|
| - assertNull(splashImage);
|
| + Assert.assertNull(splashImage);
|
|
|
| View spacer = splashScreen.findViewById(R.id.webapp_splash_space);
|
| - assertNotNull(spacer);
|
| + Assert.assertNotNull(spacer);
|
|
|
| // The web app name is anchored to the top of the spacer.
|
| TextView splashText = (TextView) splashScreen.findViewById(R.id.webapp_splash_screen_name);
|
| int[] rules = ((RelativeLayout.LayoutParams) splashText.getLayoutParams()).getRules();
|
| - assertEquals(0, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| - assertEquals(0, rules[RelativeLayout.BELOW]);
|
| - assertEquals(R.id.webapp_splash_space, rules[RelativeLayout.ABOVE]);
|
| + Assert.assertEquals(0, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| + Assert.assertEquals(0, rules[RelativeLayout.BELOW]);
|
| + Assert.assertEquals(R.id.webapp_splash_space, rules[RelativeLayout.ABOVE]);
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testSplashScreenAppearsWithoutRegisteredSplashImage() throws Exception {
|
| // Don't register anything for the web app, which represents apps that were added to the
|
| // home screen before splash screen images were downloaded.
|
| - startWebappActivity(createIntent());
|
| - ViewGroup splashScreen = waitUntilSplashScreenAppears();
|
| - assertTrue(getActivity().isSplashScreenVisibleForTests());
|
| + mActivityTestRule.startWebappActivity();
|
| + ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears();
|
| + Assert.assertTrue(mActivityTestRule.getActivity().isSplashScreenVisibleForTests());
|
|
|
| // There's no icon displayed.
|
| ImageView splashImage =
|
| (ImageView) splashScreen.findViewById(R.id.webapp_splash_screen_icon);
|
| - assertNull(splashImage);
|
| + Assert.assertNull(splashImage);
|
|
|
| View spacer = splashScreen.findViewById(R.id.webapp_splash_space);
|
| - assertNotNull(spacer);
|
| + Assert.assertNotNull(spacer);
|
|
|
| // The web app name is anchored to the top of the spacer.
|
| TextView splashText = (TextView) splashScreen.findViewById(R.id.webapp_splash_screen_name);
|
| int[] rules = ((RelativeLayout.LayoutParams) splashText.getLayoutParams()).getRules();
|
| - assertEquals(0, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| - assertEquals(0, rules[RelativeLayout.BELOW]);
|
| - assertEquals(0, rules[RelativeLayout.CENTER_IN_PARENT]);
|
| - assertEquals(R.id.webapp_splash_space, rules[RelativeLayout.ABOVE]);
|
| + Assert.assertEquals(0, rules[RelativeLayout.ALIGN_PARENT_BOTTOM]);
|
| + Assert.assertEquals(0, rules[RelativeLayout.BELOW]);
|
| + Assert.assertEquals(0, rules[RelativeLayout.CENTER_IN_PARENT]);
|
| + Assert.assertEquals(R.id.webapp_splash_space, rules[RelativeLayout.ABOVE]);
|
| }
|
| }
|
|
|