Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenIconTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenIconTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenIconTest.java |
index f53ac888a37872cb87fdf32a5b77a10e37b07f59..71c936058d7395b30e4101739bf234d4cb8061de 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenIconTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenIconTest.java |
@@ -11,57 +11,76 @@ 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 an icon registered in WebappRegistry. |
*/ |
+@RunWith(ChromeJUnit4ClassRunner.class) |
+@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
@RetryOnFailure |
-public class WebappSplashScreenIconTest extends WebappActivityTestBase { |
+public class WebappSplashScreenIconTest { |
+ @Rule |
+ public final WebappActivityTestRule mActivityTestRule = new WebappActivityTestRule(); |
- @Override |
- protected Intent createIntent() { |
- Intent intent = super.createIntent(); |
- intent.putExtra(ShortcutHelper.EXTRA_ICON, TEST_ICON); |
+ private Intent createIntent() { |
+ Intent intent = mActivityTestRule.createIntent(); |
+ intent.putExtra(ShortcutHelper.EXTRA_ICON, WebappActivityTestRule.TEST_ICON); |
return intent; |
} |
- @Override |
- protected void setUp() throws Exception { |
- super.setUp(); |
- WebappRegistry.getInstance().getWebappDataStorage(WEBAPP_ID).updateSplashScreenImage( |
- TEST_SPLASH_ICON); |
- startWebappActivity(); |
+ @Before |
+ public void setUp() throws Exception { |
+ WebappRegistry.getInstance() |
+ .getWebappDataStorage(WebappActivityTestRule.WEBAPP_ID) |
+ .updateSplashScreenImage(WebappActivityTestRule.TEST_SPLASH_ICON); |
+ mActivityTestRule.startWebappActivity(createIntent()); |
} |
+ @Test |
@SmallTest |
@Feature({"Webapps"}) |
public void testShowSplashIcon() { |
- ViewGroup splashScreen = waitUntilSplashScreenAppears(); |
+ ViewGroup splashScreen = mActivityTestRule.waitUntilSplashScreenAppears(); |
ImageView splashImage = (ImageView) splashScreen.findViewById( |
R.id.webapp_splash_screen_icon); |
BitmapDrawable drawable = (BitmapDrawable) splashImage.getDrawable(); |
- assertEquals(512, drawable.getBitmap().getWidth()); |
- assertEquals(512, drawable.getBitmap().getHeight()); |
+ Assert.assertEquals(512, drawable.getBitmap().getWidth()); |
+ Assert.assertEquals(512, drawable.getBitmap().getHeight()); |
} |
+ @Test |
@SmallTest |
@Feature({"Webapps"}) |
public void testUmaCustomIcon() { |
- assertEquals(1, RecordHistogram.getHistogramValueCountForTesting( |
- WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE, |
- WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM)); |
+ Assert.assertEquals(1, |
+ RecordHistogram.getHistogramValueCountForTesting( |
+ WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE, |
+ WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM)); |
- Bitmap icon = ShortcutHelper.decodeBitmapFromString(TEST_SPLASH_ICON); |
+ Bitmap icon = |
+ ShortcutHelper.decodeBitmapFromString(WebappActivityTestRule.TEST_SPLASH_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)); |
} |
} |