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

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

Issue 1391993004: WebApp splashscreen: add UMA to record how a splashscreen is constructed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't assert Created 5 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/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
new file mode 100644
index 0000000000000000000000000000000000000000..2d2959d84be7e568687e578edd3efcf26fdb5c8c
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappSplashScreenIconTest.java
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.webapps;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.base.metrics.RecordHistogram;
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.browser.ShortcutHelper;
+import org.chromium.chrome.browser.metrics.WebappUma;
+
+/**
+ * Tests for splash screens with an icon registered in WebappRegistry.
+ */
+public class WebappSplashScreenIconTest extends WebappActivityTestBase {
+
+ @Override
+ protected Intent createIntent() {
+ Intent intent = super.createIntent();
+ intent.putExtra(ShortcutHelper.EXTRA_ICON, TEST_ICON);
+ return intent;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ WebappDataStorage.open(getInstrumentation().getTargetContext(), WEBAPP_ID)
+ .updateSplashScreenImage(ShortcutHelper.decodeBitmapFromString(TEST_SPLASH_ICON));
+
+ super.setUp();
+ }
+
+ // TODO(mlamouri): test that we actually show the icon.
+
+ @SmallTest
+ @Feature({"Webapps"})
+ public void testUmaCustomIcon() {
+ assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
+ WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_TYPE,
+ WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM));
+
+ Bitmap icon = ShortcutHelper.decodeBitmapFromString(TEST_SPLASH_ICON);
+ int sizeInDp = Math.round((float) icon.getWidth()
+ / getActivity().getResources().getDisplayMetrics().density);
+ assertEquals(1, RecordHistogram.getHistogramValueCountForTesting(
+ WebappUma.HISTOGRAM_SPLASHSCREEN_ICON_SIZE, sizeInDp));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698