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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java

Issue 2671853002: Rename best icon to best primary icon in Web app related code. (Closed)
Patch Set: Addressing comments Created 3 years, 10 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/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java
index a580c4726a507879aef469b891f340abd291986c..77e692479f3c297d05dd4649cb1a6b0002edb810 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/ManifestUpgradeDetectorTest.java
@@ -43,8 +43,8 @@ public class ManifestUpgradeDetectorTest {
private static final String WEBAPK_SCOPE_URL = "/";
private static final String WEBAPK_NAME = "Long Name";
private static final String WEBAPK_SHORT_NAME = "Short Name";
- private static final String WEBAPK_BEST_ICON_URL = "/icon.png";
- private static final String WEBAPK_BEST_ICON_MURMUR2_HASH = "3";
+ private static final String WEBAPK_BEST_PRIMARY_ICON_URL = "/icon.png";
+ private static final String WEBAPK_BEST_PRIMARY_ICON_MURMUR2_HASH = "3";
private static final int WEBAPK_DISPLAY_MODE = WebDisplayMode.Undefined;
private static final int WEBAPK_ORIENTATION = ScreenOrientationValues.DEFAULT;
private static final long WEBAPK_THEME_COLOR = 1L;
@@ -57,11 +57,15 @@ public class ManifestUpgradeDetectorTest {
private static class TestCallback implements ManifestUpgradeDetector.Callback {
public boolean mIsUpgraded;
public boolean mWasCalled;
+
@Override
public void onFinishedFetchingWebManifestForInitialUrl(
- boolean needsUpgrade, WebApkInfo info, String bestIconUrl) {}
+ boolean needsUpgrade, WebApkInfo info, String bestPrimaryIconUrl) {
+ }
+
@Override
- public void onGotManifestData(boolean isUpgraded, WebApkInfo info, String bestIconUrl) {
+ public void onGotManifestData(boolean isUpgraded, WebApkInfo info,
+ String bestPrimaryIconUrl) {
mIsUpgraded = isUpgraded;
mWasCalled = true;
}
@@ -73,8 +77,8 @@ public class ManifestUpgradeDetectorTest {
public String name;
public String shortName;
public Map<String, String> iconUrlToMurmur2HashMap;
- public String bestIconUrl;
- public Bitmap bestIcon;
+ public String bestPrimaryIconUrl;
+ public Bitmap bestPrimaryIcon;
public int displayMode;
public int orientation;
public long themeColor;
@@ -82,10 +86,8 @@ public class ManifestUpgradeDetectorTest {
}
/**
- * ManifestUpgradeDetectorFetcher subclass which:
- * - Does not use native.
- * - Which returns the "Downloaded Manifest Data" passed to the constructor when
- * {@link #start()} is called.
+ * ManifestUpgradeDetectorFetcher subclass which: - Does not use native. - Which returns the
+ * "Downloaded Manifest Data" passed to the constructor when {@link #start()} is called.
*/
private static class TestManifestUpgradeDetectorFetcher extends ManifestUpgradeDetectorFetcher {
ManifestData mFetchedManifestData;
@@ -97,7 +99,8 @@ public class ManifestUpgradeDetectorTest {
@Override
public boolean start(Tab tab, WebApkInfo oldInfo, Callback callback) {
callback.onGotManifestData(
- infoFromManifestData(mFetchedManifestData), mFetchedManifestData.bestIconUrl);
+ infoFromManifestData(mFetchedManifestData),
+ mFetchedManifestData.bestPrimaryIconUrl);
return true;
}
@@ -108,11 +111,10 @@ public class ManifestUpgradeDetectorTest {
}
/**
- * ManifestUpgradeDetector subclass which:
- * - Uses mock ManifestUpgradeDetectorFetcher.
- * - Uses {@link fetchedData} passed into the constructor as the "Downloaded Manifest Data".
- * - Tracks whether an upgraded WebAPK was requested.
- * - Tracks whether "upgrade needed checking logic" has terminated.
+ * ManifestUpgradeDetector subclass which: - Uses mock ManifestUpgradeDetectorFetcher. - Uses
pkotwicz 2017/02/03 18:42:15 Please keep the bullet points. There's the same is
F 2017/02/06 12:40:12 Acknowledged. Will pay attention not to let the au
+ * {@link fetchedData} passed into the constructor as the "Downloaded Manifest Data". - Tracks
+ * whether an upgraded WebAPK was requested. - Tracks whether "upgrade needed checking logic"
+ * has terminated.
*/
private static class TestManifestUpgradeDetector extends ManifestUpgradeDetector {
private ManifestData mFetchedData;
@@ -137,10 +139,13 @@ public class ManifestUpgradeDetectorTest {
/**
* Creates 1x1 bitmap.
+ *
* @param color The bitmap color.
*/
private static Bitmap createBitmap(int color) {
- int colors[] = { color };
+ int colors[] = {
+ color
+ };
return ShadowBitmap.createBitmap(colors, 1, 1, Bitmap.Config.ALPHA_8);
}
@@ -160,10 +165,10 @@ public class ManifestUpgradeDetectorTest {
manifestData.iconUrlToMurmur2HashMap = new HashMap<String, String>();
manifestData.iconUrlToMurmur2HashMap.put(
- WEBAPK_BEST_ICON_URL, WEBAPK_BEST_ICON_MURMUR2_HASH);
+ WEBAPK_BEST_PRIMARY_ICON_URL, WEBAPK_BEST_PRIMARY_ICON_MURMUR2_HASH);
- manifestData.bestIconUrl = WEBAPK_BEST_ICON_URL;
- manifestData.bestIcon = createBitmap(Color.GREEN);
+ manifestData.bestPrimaryIconUrl = WEBAPK_BEST_PRIMARY_ICON_URL;
+ manifestData.bestPrimaryIcon = createBitmap(Color.GREEN);
manifestData.displayMode = WEBAPK_DISPLAY_MODE;
manifestData.orientation = WEBAPK_ORIENTATION;
manifestData.themeColor = WEBAPK_THEME_COLOR;
@@ -173,7 +178,7 @@ public class ManifestUpgradeDetectorTest {
private static WebApkInfo infoFromManifestData(ManifestData manifestData) {
return WebApkInfo.create("", "", manifestData.scopeUrl,
- new WebApkInfo.Icon(manifestData.bestIcon), manifestData.name,
+ new WebApkInfo.Icon(manifestData.bestPrimaryIcon), manifestData.name,
manifestData.shortName, manifestData.displayMode, manifestData.orientation, -1,
manifestData.themeColor, manifestData.backgroundColor, WEBAPK_PACKAGE_NAME, -1,
WEBAPK_MANIFEST_URL, manifestData.startUrl, manifestData.iconUrlToMurmur2HashMap);
@@ -196,8 +201,8 @@ public class ManifestUpgradeDetectorTest {
WebApkInfo androidManifestInfo = WebApkInfo.create(intent);
TestCallback callback = new TestCallback();
- TestManifestUpgradeDetector detector =
- new TestManifestUpgradeDetector(androidManifestInfo, fetchedManifestData, callback);
+ TestManifestUpgradeDetector detector = new TestManifestUpgradeDetector(androidManifestInfo,
+ fetchedManifestData, callback);
detector.start();
Assert.assertTrue(callback.mWasCalled);
return callback.mIsUpgraded;
@@ -205,6 +210,7 @@ public class ManifestUpgradeDetectorTest {
/**
* Registers WebAPK with default package name. Overwrites previous registrations.
+ *
* @param manifestData <meta-data> values for WebAPK's Android Manifest.
*/
private void registerWebApk(ManifestData manifestData) {
@@ -278,72 +284,67 @@ public class ManifestUpgradeDetectorTest {
}
/**
- * Test that an upgrade is requested when:
- * - WebAPK was generated using icon at {@link WEBAPK_BEST_ICON_URL} from Web Manifest.
- * - Bitmap at {@link WEBAPK_BEST_ICON_URL} has changed.
+ * Test that an upgrade is requested when: - WebAPK was generated using icon at
+ * {@link WEBAPK_BEST_PRIMARY_ICON_URL} from Web Manifest. - Bitmap at
+ * {@link WEBAPK_BEST_PRIMARY_ICON_URL} has changed.
*/
@Test
public void testHomescreenIconChangeShouldUpgrade() {
ManifestData fetchedData = defaultManifestData();
- fetchedData.iconUrlToMurmur2HashMap.put(fetchedData.bestIconUrl,
- WEBAPK_BEST_ICON_MURMUR2_HASH + "1");
- fetchedData.bestIcon = createBitmap(Color.BLUE);
+ fetchedData.iconUrlToMurmur2HashMap.put(fetchedData.bestPrimaryIconUrl,
+ WEBAPK_BEST_PRIMARY_ICON_MURMUR2_HASH + "1");
+ fetchedData.bestPrimaryIcon = createBitmap(Color.BLUE);
Assert.assertTrue(checkUpdateNeededForFetchedManifest(defaultManifestData(), fetchedData));
}
/**
- * Test that an upgrade is requested when:
- * - WebAPK is generated using icon at {@link WEBAPK_BEST_ICON_URL} from Web Manifest.
- * - Web Manifest is updated to refer to different icon.
+ * Test that an upgrade is requested when: - WebAPK is generated using icon at
+ * {@link WEBAPK_BEST_PRIMARY_ICON_URL} from Web Manifest. - Web Manifest is updated to refer to
+ * different icon.
*/
@Test
- public void testHomescreenBestIconUrlChangeShouldUpgrade() {
+ public void testHomescreenBestPrimaryIconUrlChangeShouldUpgrade() {
ManifestData fetchedData = defaultManifestData();
fetchedData.iconUrlToMurmur2HashMap.clear();
fetchedData.iconUrlToMurmur2HashMap.put("/icon2.png", "22");
- fetchedData.bestIconUrl = "/icon2.png";
+ fetchedData.bestPrimaryIconUrl = "/icon2.png";
Assert.assertTrue(checkUpdateNeededForFetchedManifest(defaultManifestData(), fetchedData));
}
/**
- * Test that an upgrade is not requested if:
- * - icon URL is added to the Web Manifest
- * AND
- * - "best" icon URL for the launcher icon did not change.
+ * Test that an upgrade is not requested if: - icon URL is added to the Web Manifest AND -
+ * "best" icon URL for the launcher icon did not change.
*/
@Test
- public void testIconUrlsChangeShouldNotUpgradeIfTheBestIconUrlDoesNotChange() {
+ public void testIconUrlsChangeShouldNotUpgradeIfTheBestPrimaryIconUrlDoesNotChange() {
ManifestData fetchedData = defaultManifestData();
fetchedData.iconUrlToMurmur2HashMap.clear();
fetchedData.iconUrlToMurmur2HashMap.put(
- WEBAPK_BEST_ICON_URL, WEBAPK_BEST_ICON_MURMUR2_HASH);
+ WEBAPK_BEST_PRIMARY_ICON_URL, WEBAPK_BEST_PRIMARY_ICON_MURMUR2_HASH);
fetchedData.iconUrlToMurmur2HashMap.put("/icon2.png", null);
Assert.assertFalse(checkUpdateNeededForFetchedManifest(defaultManifestData(), fetchedData));
}
/**
- * Test than upgrade is requested if:
- * - the WebAPK's meta data has murmur2 hashes for all of the icons.
- * AND
- * - the Web Manifest has not changed
- * AND
- * - the computed best icon URL is different from the one stored in the WebAPK's meta data.
+ * Test than upgrade is requested if: - the WebAPK's meta data has murmur2 hashes for all of the
+ * icons. AND - the Web Manifest has not changed AND - the computed best icon URL is different
+ * from the one stored in the WebAPK's meta data.
*/
@Test
- public void testWebManifestSameButBestIconUrlChangedShouldNotUpgrade() {
+ public void testWebManifestSameButBestPrimaryIconUrlChangedShouldNotUpgrade() {
String iconUrl1 = "/icon1.png";
String iconUrl2 = "/icon2.png";
String hash1 = "11";
String hash2 = "22";
ManifestData oldData = defaultManifestData();
- oldData.bestIconUrl = iconUrl1;
+ oldData.bestPrimaryIconUrl = iconUrl1;
oldData.iconUrlToMurmur2HashMap.clear();
oldData.iconUrlToMurmur2HashMap.put(iconUrl1, hash1);
oldData.iconUrlToMurmur2HashMap.put(iconUrl2, hash2);
ManifestData fetchedData = defaultManifestData();
- fetchedData.bestIconUrl = iconUrl2;
+ fetchedData.bestPrimaryIconUrl = iconUrl2;
fetchedData.iconUrlToMurmur2HashMap.clear();
fetchedData.iconUrlToMurmur2HashMap.put(iconUrl1, null);
fetchedData.iconUrlToMurmur2HashMap.put(iconUrl2, hash2);

Powered by Google App Engine
This is Rietveld 408576698