| Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenHomescreenIconTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenHomescreenIconTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenHomescreenIconTest.java
|
| index 6829dd82d4ee4adf7b197f415e23cc4ca7b26a0a..0e5e6c1883d63f4758f0622d84a3a9aac4a5cb29 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenHomescreenIconTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenHomescreenIconTest.java
|
| @@ -4,61 +4,73 @@
|
|
|
| package org.chromium.chrome.browser.webapps;
|
|
|
| -import android.content.Intent;
|
| import android.graphics.Bitmap;
|
| import android.graphics.drawable.BitmapDrawable;
|
| import android.support.test.filters.SmallTest;
|
| import android.view.ViewGroup;
|
| import android.widget.ImageView;
|
|
|
| +import org.junit.Assert;
|
| +import org.junit.Before;
|
| +import org.junit.Rule;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +
|
| 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.test.ChromeActivityTestRule;
|
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
|
|
| /**
|
| * Tests for splash screens with EXTRA_ICON specified in the Intent.
|
| */
|
| -public class WebappSplashScreenHomescreenIconTest extends WebappActivityTestBase {
|
| - @Override
|
| - protected void setUp() throws Exception {
|
| - super.setUp();
|
| - startWebappActivity();
|
| - }
|
| +@RunWith(ChromeJUnit4ClassRunner.class)
|
| +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| +public class WebappSplashScreenHomescreenIconTest {
|
| + @Rule
|
| + public final WebappActivityTestRule mActivityTestRule = new WebappActivityTestRule();
|
|
|
| - @Override
|
| - protected Intent createIntent() {
|
| - Intent intent = super.createIntent();
|
| - intent.putExtra(ShortcutHelper.EXTRA_ICON, TEST_ICON);
|
| - return intent;
|
| + @Before
|
| + public void setUp() throws Exception {
|
| + mActivityTestRule.startWebappActivity(mActivityTestRule.createIntent().putExtra(
|
| + ShortcutHelper.EXTRA_ICON, WebappActivityTestRule.TEST_ICON));
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| public void testShowFallbackIcon() {
|
| - ViewGroup splashScreen = waitUntilSplashScreenAppears();
|
| + ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears();
|
| ImageView splashImage = (ImageView) splashScreen.findViewById(
|
| R.id.webapp_splash_screen_icon);
|
| BitmapDrawable drawable = (BitmapDrawable) splashImage.getDrawable();
|
|
|
| - assertEquals(192, drawable.getBitmap().getWidth());
|
| - assertEquals(192, drawable.getBitmap().getHeight());
|
| + Assert.assertEquals(192, drawable.getBitmap().getWidth());
|
| + Assert.assertEquals(192, drawable.getBitmap().getHeight());
|
| }
|
|
|
| + @Test
|
| @SmallTest
|
| @Feature({"Webapps"})
|
| @RetryOnFailure
|
| public void testUmaFallbackIcon() {
|
| - assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
|
| - WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| - WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK));
|
| + Assert.assertEquals(1,
|
| + RecordHistogram.getHistogramValueCountForTesting(
|
| + WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
|
| + WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK));
|
|
|
| - Bitmap icon = ShortcutHelper.decodeBitmapFromString(TEST_ICON);
|
| + Bitmap icon = ShortcutHelper.decodeBitmapFromString(WebappActivityTestRule.TEST_ICON);
|
| int sizeInDp = Math.round((float) icon.getWidth()
|
| - / getActivity().getResources().getDisplayMetrics().density);
|
| - assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
|
| - WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_SIZE, sizeInDp));
|
| + / mActivityTestRule.getActivity().getResources().getDisplayMetrics().density);
|
| + Assert.assertEquals(1,
|
| + RecordHistogram.getHistogramValueCountForTesting(
|
| + WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_SIZE, sizeInDp));
|
| }
|
| }
|
|
|