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

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

Issue 2863583002: Convert WebappActivityTestBase and direct children to JUnit4. (Closed)
Patch Set: Initial patch Created 3 years, 7 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/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..39d74bca62abf7b43e276327240340046c9fcba9 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
@@ -11,54 +11,72 @@ 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();
+
+ @Before
+ public void setUp() throws Exception {
+ mActivityTestRule.startWebappActivity(createIntent());
}
- @Override
- protected Intent createIntent() {
- Intent intent = super.createIntent();
- intent.putExtra(ShortcutHelper.EXTRA_ICON, TEST_ICON);
+ private Intent createIntent() {
the real yoland 2017/05/04 19:04:43 I would recommend just change the createIntent() m
piotrs 2017/05/05 01:15:53 I got around it just inlining createIntent() with
+ Intent intent = mActivityTestRule.createIntent();
+ intent.putExtra(ShortcutHelper.EXTRA_ICON, WebappActivityTestRule.TEST_ICON);
return intent;
}
+ @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));
}
}

Powered by Google App Engine
This is Rietveld 408576698