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

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

Issue 2351113005: [Reland] Refactor WebappRegistry into a singleton instance. (Closed)
Patch Set: Comments Created 4 years, 2 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/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 dc7f8945e06e1b3cfd280f5106f607cfceda778e..cf5bbcc4760faf7aa0aabd6546ed9642e1e3f8d3 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
@@ -33,6 +33,7 @@ import org.chromium.chrome.browser.tab.TabTestUtils;
* Tests for splash screens.
*/
public class WebappSplashScreenTest extends WebappActivityTestBase {
+
private int getHistogramTotalCountFor(String histogram, int buckets) {
int count = 0;
@@ -236,9 +237,14 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
Context context = getInstrumentation().getTargetContext();
int thresholdSize = context.getResources().getDimensionPixelSize(
R.dimen.webapp_splash_image_size_threshold);
- int bitmapSize = thresholdSize + 1;
- Bitmap splashBitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
- WebappDataStorage.open(WEBAPP_ID).updateSplashScreenImage(splashBitmap);
+ int size = thresholdSize + 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);
+ callback.waitForCallback(0);
+ callback.getStorage().updateSplashScreenImage(bitmapString);
startWebappActivity(createIntent());
ViewGroup splashScreen = waitUntilSplashScreenAppears();
@@ -246,8 +252,8 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
ImageView splashImage =
(ImageView) splashScreen.findViewById(R.id.webapp_splash_screen_icon);
- assertEquals(bitmapSize, splashImage.getMeasuredWidth());
- assertEquals(bitmapSize, splashImage.getMeasuredHeight());
+ assertEquals(size, splashImage.getMeasuredWidth());
+ assertEquals(size, splashImage.getMeasuredHeight());
TextView splashText = (TextView) splashScreen.findViewById(R.id.webapp_splash_screen_name);
int[] rules = ((RelativeLayout.LayoutParams) splashText.getLayoutParams()).getRules();
@@ -263,10 +269,15 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
Context context = getInstrumentation().getTargetContext();
int thresholdSize = context.getResources().getDimensionPixelSize(
R.dimen.webapp_splash_image_size_threshold);
- int bitmapSize = context.getResources().getDimensionPixelSize(
+ int size = context.getResources().getDimensionPixelSize(
R.dimen.webapp_splash_image_size_minimum);
- Bitmap splashBitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
- WebappDataStorage.open(WEBAPP_ID).updateSplashScreenImage(splashBitmap);
+ 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);
+ callback.waitForCallback(0);
+ callback.getStorage().updateSplashScreenImage(bitmapString);
startWebappActivity(createIntent());
ViewGroup splashScreen = waitUntilSplashScreenAppears();
@@ -291,10 +302,15 @@ public class WebappSplashScreenTest extends WebappActivityTestBase {
public void testSplashScreenWithoutImageAppears() throws Exception {
// Register an image that's too small for the splash screen.
Context context = getInstrumentation().getTargetContext();
- int bitmapSize = context.getResources().getDimensionPixelSize(
+ int size = context.getResources().getDimensionPixelSize(
R.dimen.webapp_splash_image_size_minimum) - 1;
- Bitmap splashBitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
- WebappDataStorage.open(WEBAPP_ID).updateSplashScreenImage(splashBitmap);
+ 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);
+ callback.waitForCallback(0);
+ callback.getStorage().updateSplashScreenImage(bitmapString);
Intent intent = createIntent();
intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, true);

Powered by Google App Engine
This is Rietveld 408576698