Chromium Code Reviews| Index: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java |
| diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java |
| index 3148d26f855dfda65c034995f8052e0f5cf2a742..1972f66287eccc6468489612041a6457a168929b 100644 |
| --- a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java |
| +++ b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java |
| @@ -50,8 +50,8 @@ public class WebApkUpdateManagerTest { |
| public DisableHistogramsRule mDisableHistogramsRule = new DisableHistogramsRule(); |
| /** WebAPK's id in {@link WebAppDataStorage}. */ |
| - private static final String WEBAPK_ID = |
| - WebApkConstants.WEBAPK_ID_PREFIX + WebApkTestHelper.WEBAPK_PACKAGE_NAME; |
| + private static final String WEBAPK_ID = WebApkConstants.WEBAPK_ID_PREFIX |
| + + WebApkTestHelper.WEBAPK_PACKAGE_NAME; |
| /** Web Manifest URL */ |
| private static final String WEB_MANIFEST_URL = "manifest.json"; |
| @@ -145,14 +145,14 @@ public class WebApkUpdateManagerTest { |
| } |
| @Override |
| - protected void scheduleUpdate(WebApkInfo info, String bestIconUrl, |
| + protected void scheduleUpdate(WebApkInfo info, String bestPrimaryIconUrl, |
| boolean isManifestStale) { |
| mUpdateName = info.name(); |
| - super.scheduleUpdate(info, bestIconUrl, isManifestStale); |
| + super.scheduleUpdate(info, bestPrimaryIconUrl, isManifestStale); |
| } |
| @Override |
| - protected void updateAsyncImpl(WebApkInfo info, String bestIconUrl, |
| + protected void updateAsyncImpl(WebApkInfo info, String bestPrimaryIconUrl, |
| boolean isManifestStale) { |
| mUpdateRequested = true; |
| } |
| @@ -190,8 +190,8 @@ public class WebApkUpdateManagerTest { |
| 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; |
| @@ -206,7 +206,8 @@ public class WebApkUpdateManagerTest { |
| /** |
| * Registers WebAPK with default package name. Overwrites previous registrations. |
| - * @param manifestData <meta-data> values for WebAPK's Android Manifest. |
| + * |
| + * @param manifestData <meta-data> values for WebAPK's Android Manifest. |
| * @param shellApkVersionCode WebAPK's version of the //chrome/android/webapk/shell_apk code. |
| */ |
| private void registerWebApk(ManifestData manifestData, int shellApkVersionCode) { |
| @@ -246,8 +247,8 @@ public class WebApkUpdateManagerTest { |
| manifestData.iconUrlToMurmur2HashMap = new HashMap<String, String>(); |
| manifestData.iconUrlToMurmur2HashMap.put(ICON_URL, ICON_MURMUR2_HASH); |
| - manifestData.bestIconUrl = ICON_URL; |
| - manifestData.bestIcon = createBitmap(Color.GREEN); |
| + manifestData.bestPrimaryIconUrl = ICON_URL; |
| + manifestData.bestPrimaryIcon = createBitmap(Color.GREEN); |
| manifestData.displayMode = DISPLAY_MODE; |
| manifestData.orientation = ORIENTATION; |
| manifestData.themeColor = THEME_COLOR; |
| @@ -259,7 +260,7 @@ public class WebApkUpdateManagerTest { |
| if (manifestData == null) return null; |
| return WebApkInfo.create(WEBAPK_ID, "", 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, |
| WebApkTestHelper.WEBAPK_PACKAGE_NAME, -1, WEB_MANIFEST_URL, |
| @@ -268,10 +269,13 @@ public class WebApkUpdateManagerTest { |
| /** |
| * 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); |
| } |
| @@ -293,8 +297,9 @@ public class WebApkUpdateManagerTest { |
| private static void onGotManifestData(WebApkUpdateManager updateManager, |
| ManifestData fetchedManifestData) { |
| - String bestIconUrl = randomIconUrl(fetchedManifestData); |
| - updateManager.onGotManifestData(infoFromManifestData(fetchedManifestData), bestIconUrl); |
| + String bestPrimaryIconUrl = randomIconUrl(fetchedManifestData); |
| + updateManager.onGotManifestData(infoFromManifestData(fetchedManifestData), |
| + bestPrimaryIconUrl); |
| } |
| private static String randomIconUrl(ManifestData fetchedManifestData) { |
| @@ -305,8 +310,8 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
| - * Runs {@link WebApkUpdateManager#updateIfNeeded()} and returns whether an |
| - * is-update-needed check has been triggered. |
| + * Runs {@link WebApkUpdateManager#updateIfNeeded()} and returns whether an is-update-needed |
| + * check has been triggered. |
| */ |
| private boolean updateIfNeededChecksForUpdatedWebManifest() { |
| TestWebApkUpdateManager updateManager = new TestWebApkUpdateManager(mClock); |
| @@ -327,7 +332,7 @@ public class WebApkUpdateManagerTest { |
| updateIfNeeded(updateManager); |
| assertTrue(updateManager.updateCheckStarted()); |
| updateManager.onGotManifestData( |
| - infoFromManifestData(fetchedManifestData), fetchedManifestData.bestIconUrl); |
| + infoFromManifestData(fetchedManifestData), fetchedManifestData.bestPrimaryIconUrl); |
| return updateManager.updateRequested(); |
| } |
| @@ -347,7 +352,8 @@ public class WebApkUpdateManagerTest { |
| WebappRegistry.getInstance().register( |
| WEBAPK_ID, new WebappRegistry.FetchWebappDataStorageCallback() { |
| @Override |
| - public void onWebappDataStorageRetrieved(WebappDataStorage storage) {} |
| + public void onWebappDataStorageRetrieved(WebappDataStorage storage) { |
| + } |
| }); |
| ShadowApplication.getInstance().runBackgroundTasks(); |
| @@ -360,8 +366,7 @@ public class WebApkUpdateManagerTest { |
| /** |
| * Test that if the WebAPK update failed (e.g. because the WebAPK server is not reachable) that |
| * the is-update-needed check is retried after less time than if the WebAPK update had |
| - * succeeded. |
| - * The is-update-needed check is the first step in retrying to update the WebAPK. |
| + * succeeded. The is-update-needed check is the first step in retrying to update the WebAPK. |
| */ |
| @Test |
| public void testCheckUpdateMoreFrequentlyIfUpdateFails() { |
| @@ -443,10 +448,8 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
|
pkotwicz
2017/02/03 18:42:15
Leave the bullet points one per line with the AND
F
2017/02/06 12:40:12
Acknowledged. Will avoid auto-formatter next time
|
| - * Test that the completion time of the previous WebAPK update is not modified if: |
| - * - The previous WebAPK update succeeded. |
| - * AND |
| - * - A WebAPK update is not required. |
| + * Test that the completion time of the previous WebAPK update is not modified if: - The |
| + * previous WebAPK update succeeded. AND - A WebAPK update is not required. |
| */ |
| @Test |
| public void testUpdateNotNeeded() { |
| @@ -465,10 +468,8 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
| - * Test that the last WebAPK update is marked as having succeeded if: |
| - * - The previous WebAPK update failed. |
| - * AND |
| - * - A WebAPK update is no longer required. |
| + * Test that the last WebAPK update is marked as having succeeded if: - The previous WebAPK |
| + * update failed. AND - A WebAPK update is no longer required. |
| */ |
| @Test |
| public void testMarkUpdateAsSucceededIfUpdateNoLongerNeeded() { |
| @@ -513,13 +514,10 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
| - * Test that an update with data from the WebAPK's Android manifest is done if: |
| - * - WebAPK's code is out of date |
| - * AND |
| - * - WebAPK's start_url does not refer to a Web Manifest. |
| - * |
| - * It is good to minimize the number of users with out of date WebAPKs. We try to keep WebAPKs |
| - * up to date even if the web developer has removed the Web Manifest from their site. |
| + * Test that an update with data from the WebAPK's Android manifest is done if: - WebAPK's code |
| + * is out of date AND - WebAPK's start_url does not refer to a Web Manifest. It is good to |
| + * minimize the number of users with out of date WebAPKs. We try to keep WebAPKs up to date even |
| + * if the web developer has removed the Web Manifest from their site. |
| */ |
| @Test |
| public void testShellApkOutOfDateNoWebManifest() { |
| @@ -561,14 +559,10 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
| - * Test that an update is requested if: |
| - * - start_url does not refer to a Web Manifest. |
| - * AND |
| - * - The user eventually navigates to a page pointing to a Web Manifest with the correct URL. |
| - * AND |
| - * - The Web Manifest has changed. |
| - * |
| - * This scenario can occur if the WebAPK's start_url is a Javascript redirect. |
| + * Test that an update is requested if: - start_url does not refer to a Web Manifest. AND - The |
| + * user eventually navigates to a page pointing to a Web Manifest with the correct URL. AND - |
| + * The Web Manifest has changed. This scenario can occur if the WebAPK's start_url is a |
| + * Javascript redirect. |
| */ |
| @Test |
| public void testStartUrlRedirectsToPageWithUpdatedWebManifest() { |
| @@ -597,11 +591,8 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
| - * Test that an update is not requested if: |
| - * - start_url does not refer to a Web Manifest. |
| - * AND |
| - * - The user eventually navigates to a page pointing to a Web Manifest with the correct URL. |
| - * AND |
| + * Test that an update is not requested if: - start_url does not refer to a Web Manifest. AND - |
| + * The user eventually navigates to a page pointing to a Web Manifest with the correct URL. AND |
| * - The Web Manifest has not changed. |
| */ |
| @Test |
| @@ -659,40 +650,37 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
| - * Test that an upgrade is requested when: |
| - * - WebAPK was generated using icon at {@link ICON_URL} from Web Manifest. |
| - * - Bitmap at {@link ICON_URL} has changed. |
| + * Test that an upgrade is requested when: - WebAPK was generated using icon at {@link ICON_URL} |
| + * from Web Manifest. - Bitmap at {@link ICON_URL} has changed. |
| */ |
| @Test |
| public void testHomescreenIconChangeShouldUpgrade() { |
| ManifestData fetchedData = defaultManifestData(); |
| - fetchedData.iconUrlToMurmur2HashMap.put(fetchedData.bestIconUrl, ICON_MURMUR2_HASH + "1"); |
| - fetchedData.bestIcon = createBitmap(Color.BLUE); |
| + fetchedData.iconUrlToMurmur2HashMap.put(fetchedData.bestPrimaryIconUrl, |
| + ICON_MURMUR2_HASH + "1"); |
| + fetchedData.bestPrimaryIcon = createBitmap(Color.BLUE); |
| assertTrue(checkUpdateNeededForFetchedManifest(defaultManifestData(), fetchedData)); |
| } |
| /** |
| - * Test that an upgrade is requested when: |
| - * - WebAPK is generated using icon at {@link 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 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"; |
| 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(ICON_URL, ICON_MURMUR2_HASH); |
| @@ -701,28 +689,25 @@ public class WebApkUpdateManagerTest { |
| } |
| /** |
| - * 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); |