| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; |
| 8 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 9 import android.graphics.Color; | 10 import android.graphics.Color; |
| 11 import android.os.Bundle; |
| 10 import android.text.TextUtils; | 12 import android.text.TextUtils; |
| 11 | 13 |
| 12 import org.junit.Assert; | 14 import org.junit.Assert; |
| 13 import org.junit.Before; | 15 import org.junit.Before; |
| 14 import org.junit.Test; | 16 import org.junit.Test; |
| 15 import org.junit.runner.RunWith; | 17 import org.junit.runner.RunWith; |
| 16 import org.robolectric.RuntimeEnvironment; | 18 import org.robolectric.RuntimeEnvironment; |
| 17 import org.robolectric.annotation.Config; | 19 import org.robolectric.annotation.Config; |
| 18 import org.robolectric.res.builder.RobolectricPackageManager; | 20 import org.robolectric.res.builder.RobolectricPackageManager; |
| 19 import org.robolectric.shadows.ShadowBitmap; | 21 import org.robolectric.shadows.ShadowBitmap; |
| 20 | 22 |
| 21 import org.chromium.base.ContextUtils; | 23 import org.chromium.base.ContextUtils; |
| 22 import org.chromium.blink_public.platform.WebDisplayMode; | 24 import org.chromium.blink_public.platform.WebDisplayMode; |
| 23 import org.chromium.chrome.browser.ShortcutHelper; | 25 import org.chromium.chrome.browser.ShortcutHelper; |
| 24 import org.chromium.chrome.browser.tab.Tab; | 26 import org.chromium.chrome.browser.tab.Tab; |
| 25 import org.chromium.content_public.common.ScreenOrientationValues; | 27 import org.chromium.content_public.common.ScreenOrientationValues; |
| 26 import org.chromium.testing.local.LocalRobolectricTestRunner; | 28 import org.chromium.testing.local.LocalRobolectricTestRunner; |
| 29 import org.chromium.webapk.lib.common.WebApkMetaDataKeys; |
| 30 import org.chromium.webapk.test.WebApkTestHelper; |
| 27 | 31 |
| 28 import java.util.HashMap; | 32 import java.util.HashMap; |
| 29 import java.util.Map; | 33 import java.util.Map; |
| 30 | 34 |
| 31 /** | 35 /** |
| 32 * Tests the ManifestUpgradeDetector. | 36 * Tests the ManifestUpgradeDetector. |
| 33 */ | 37 */ |
| 34 @RunWith(LocalRobolectricTestRunner.class) | 38 @RunWith(LocalRobolectricTestRunner.class) |
| 35 @Config(manifest = Config.NONE) | 39 @Config(manifest = Config.NONE) |
| 36 public class ManifestUpgradeDetectorTest { | 40 public class ManifestUpgradeDetectorTest { |
| 37 | 41 |
| 38 private static final String WEBAPK_START_URL = "/start_url.html"; | 42 private static final String WEBAPK_START_URL = "/start_url.html"; |
| 39 private static final String WEBAPK_SCOPE_URL = "/"; | 43 private static final String WEBAPK_SCOPE_URL = "/"; |
| 40 private static final String WEBAPK_NAME = "Long Name"; | 44 private static final String WEBAPK_NAME = "Long Name"; |
| 41 private static final String WEBAPK_SHORT_NAME = "Short Name"; | 45 private static final String WEBAPK_SHORT_NAME = "Short Name"; |
| 42 private static final String WEBAPK_BEST_ICON_URL = "/icon.png"; | 46 private static final String WEBAPK_BEST_ICON_URL = "/icon.png"; |
| 43 private static final String WEBAPK_BEST_ICON_MURMUR2_HASH = "3"; | 47 private static final String WEBAPK_BEST_ICON_MURMUR2_HASH = "3"; |
| 44 private static final int WEBAPK_DISPLAY_MODE = WebDisplayMode.Standalone; | 48 private static final int WEBAPK_DISPLAY_MODE = WebDisplayMode.Undefined; |
| 45 private static final int WEBAPK_ORIENTATION = ScreenOrientationValues.LANDSC
APE; | 49 private static final int WEBAPK_ORIENTATION = ScreenOrientationValues.DEFAUL
T; |
| 46 private static final long WEBAPK_THEME_COLOR = 1L; | 50 private static final long WEBAPK_THEME_COLOR = 1L; |
| 47 private static final long WEBAPK_BACKGROUND_COLOR = 2L; | 51 private static final long WEBAPK_BACKGROUND_COLOR = 2L; |
| 48 private static final String WEBAPK_MANIFEST_URL = "manifest.json"; | 52 private static final String WEBAPK_MANIFEST_URL = "manifest.json"; |
| 49 private static final String WEBAPK_PACKAGE_NAME = "package_name"; | 53 private static final String WEBAPK_PACKAGE_NAME = "package_name"; |
| 50 | 54 |
| 51 private RobolectricPackageManager mPackageManager; | 55 private RobolectricPackageManager mPackageManager; |
| 52 | 56 |
| 53 private static class TestCallback implements ManifestUpgradeDetector.Callbac
k { | 57 private static class TestCallback implements ManifestUpgradeDetector.Callbac
k { |
| 54 public boolean mIsUpgraded; | 58 public boolean mIsUpgraded; |
| 55 public boolean mWasCalled; | 59 public boolean mWasCalled; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 172 } |
| 169 | 173 |
| 170 private static WebApkInfo infoFromManifestData(ManifestData manifestData) { | 174 private static WebApkInfo infoFromManifestData(ManifestData manifestData) { |
| 171 return WebApkInfo.create("", "", manifestData.scopeUrl, | 175 return WebApkInfo.create("", "", manifestData.scopeUrl, |
| 172 new WebApkInfo.Icon(manifestData.bestIcon), manifestData.name, | 176 new WebApkInfo.Icon(manifestData.bestIcon), manifestData.name, |
| 173 manifestData.shortName, manifestData.displayMode, manifestData.o
rientation, -1, | 177 manifestData.shortName, manifestData.displayMode, manifestData.o
rientation, -1, |
| 174 manifestData.themeColor, manifestData.backgroundColor, WEBAPK_PA
CKAGE_NAME, -1, | 178 manifestData.themeColor, manifestData.backgroundColor, WEBAPK_PA
CKAGE_NAME, -1, |
| 175 WEBAPK_MANIFEST_URL, manifestData.startUrl, manifestData.iconUrl
ToMurmur2HashMap); | 179 WEBAPK_MANIFEST_URL, manifestData.startUrl, manifestData.iconUrl
ToMurmur2HashMap); |
| 176 } | 180 } |
| 177 | 181 |
| 178 private static TestManifestUpgradeDetector createDetectorWithFetchedData( | 182 /** |
| 179 ManifestData fetchedData, TestCallback callback) { | 183 * Checks whether the WebAPK is updated given data from the WebAPK's Android
Manifest and data |
| 180 return createDetector(defaultManifestData(), fetchedData, callback); | 184 * from the fetched Web Manifest. This function uses the intent version of |
| 185 * {@link WebApkInfo#create()} in order to test default values set by the in
tent version of |
| 186 * {@link WebApkInfo#create()} and how the defaults affect whether the WebAP
K is updated. |
| 187 */ |
| 188 private boolean checkUpdateNeededForFetchedManifest( |
| 189 ManifestData androidManifestData, ManifestData fetchedManifestData)
{ |
| 190 registerWebApk(androidManifestData); |
| 191 |
| 192 Intent intent = new Intent(); |
| 193 intent.putExtra(ShortcutHelper.EXTRA_URL, ""); |
| 194 intent.putExtra( |
| 195 ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, WebApkTestHelper.WEBAP
K_PACKAGE_NAME); |
| 196 WebApkInfo androidManifestInfo = WebApkInfo.create(intent); |
| 197 |
| 198 TestCallback callback = new TestCallback(); |
| 199 TestManifestUpgradeDetector detector = |
| 200 new TestManifestUpgradeDetector(androidManifestInfo, fetchedMani
festData, callback); |
| 201 detector.start(); |
| 202 Assert.assertTrue(callback.mWasCalled); |
| 203 return callback.mIsUpgraded; |
| 181 } | 204 } |
| 182 | 205 |
| 183 /** | 206 /** |
| 184 * Creates ManifestUpgradeDetector. | 207 * Registers WebAPK with default package name. Overwrites previous registrat
ions. |
| 185 * @param oldData Data used to create WebAPK. Potentially different from Web
Manifest data at | 208 * @param manifestData <meta-data> values for WebAPK's Android Manifest. |
| 186 * time that the WebAPK was generated. | |
| 187 * @param fetchedData Data fetched by ManifestUpgradeDetector. | |
| 188 * @param callback Callback to call when the upgrade check is complete. | |
| 189 */ | 209 */ |
| 190 private static TestManifestUpgradeDetector createDetector( | 210 private void registerWebApk(ManifestData manifestData) { |
| 191 ManifestData oldData, ManifestData fetchedData, TestCallback callbac
k) { | 211 Bundle metaData = new Bundle(); |
| 192 return new TestManifestUpgradeDetector( | 212 metaData.putString(WebApkMetaDataKeys.START_URL, manifestData.startUrl); |
| 193 infoFromManifestData(oldData), fetchedData, callback); | 213 metaData.putString(WebApkMetaDataKeys.SCOPE, manifestData.scopeUrl); |
| 214 metaData.putString(WebApkMetaDataKeys.NAME, manifestData.name); |
| 215 metaData.putString(WebApkMetaDataKeys.SHORT_NAME, manifestData.shortName
); |
| 216 metaData.putString(WebApkMetaDataKeys.THEME_COLOR, manifestData.themeCol
or + "L"); |
| 217 metaData.putString(WebApkMetaDataKeys.BACKGROUND_COLOR, manifestData.bac
kgroundColor + "L"); |
| 218 metaData.putString(WebApkMetaDataKeys.WEB_MANIFEST_URL, WEBAPK_MANIFEST_
URL); |
| 219 |
| 220 String iconUrlsAndIconMurmur2Hashes = ""; |
| 221 for (String iconUrl : manifestData.iconUrlToMurmur2HashMap.keySet()) { |
| 222 String murmur2Hash = manifestData.iconUrlToMurmur2HashMap.get(iconUr
l); |
| 223 if (murmur2Hash == null) { |
| 224 murmur2Hash = "0"; |
| 225 } |
| 226 iconUrlsAndIconMurmur2Hashes += " " + iconUrl + " " + murmur2Hash; |
| 227 } |
| 228 iconUrlsAndIconMurmur2Hashes = iconUrlsAndIconMurmur2Hashes.trim(); |
| 229 metaData.putString(WebApkMetaDataKeys.ICON_URLS_AND_ICON_MURMUR2_HASHES, |
| 230 iconUrlsAndIconMurmur2Hashes); |
| 231 WebApkTestHelper.registerWebApkWithMetaData(metaData); |
| 194 } | 232 } |
| 195 | 233 |
| 196 @Test | 234 @Test |
| 197 public void testManifestDoesNotUpgrade() { | 235 public void testManifestDoesNotUpgrade() { |
| 198 TestCallback callback = new TestCallback(); | 236 Assert.assertFalse( |
| 199 TestManifestUpgradeDetector detector = | 237 checkUpdateNeededForFetchedManifest(defaultManifestData(), defau
ltManifestData())); |
| 200 createDetectorWithFetchedData(defaultManifestData(), callback); | |
| 201 detector.start(); | |
| 202 Assert.assertTrue(callback.mWasCalled); | |
| 203 Assert.assertFalse(callback.mIsUpgraded); | |
| 204 } | 238 } |
| 205 | 239 |
| 206 @Test | 240 @Test |
| 207 public void testStartUrlChangeShouldUpgrade() { | 241 public void testStartUrlChangeShouldUpgrade() { |
| 208 ManifestData fetchedData = defaultManifestData(); | 242 ManifestData fetchedData = defaultManifestData(); |
| 209 fetchedData.startUrl = "/changed.html"; | 243 fetchedData.startUrl = "/changed.html"; |
| 210 TestCallback callback = new TestCallback(); | 244 Assert.assertTrue(checkUpdateNeededForFetchedManifest(defaultManifestDat
a(), fetchedData)); |
| 211 TestManifestUpgradeDetector detector = createDetectorWithFetchedData(fet
chedData, callback); | |
| 212 detector.start(); | |
| 213 Assert.assertTrue(callback.mWasCalled); | |
| 214 Assert.assertTrue(callback.mIsUpgraded); | |
| 215 } | 245 } |
| 216 | 246 |
| 217 /** | 247 /** |
| 218 * Test that an upgrade is not requested when the Web Manifest did not chang
e and the Web | 248 * Test that an upgrade is not requested when the Web Manifest did not chang
e and the Web |
| 219 * Manifest scope is empty. | 249 * Manifest scope is empty. |
| 220 */ | 250 */ |
| 221 @Test | 251 @Test |
| 222 public void testManifestEmptyScopeShouldNotUpgrade() { | 252 public void testManifestEmptyScopeShouldNotUpgrade() { |
| 223 ManifestData oldData = defaultManifestData(); | 253 ManifestData oldData = defaultManifestData(); |
| 224 // webapk_installer.cc sets the scope to the default scope if the scope
is empty. | 254 // webapk_installer.cc sets the scope to the default scope if the scope
is empty. |
| 225 oldData.scopeUrl = ShortcutHelper.getScopeFromUrl(oldData.startUrl); | 255 oldData.scopeUrl = ShortcutHelper.getScopeFromUrl(oldData.startUrl); |
| 226 ManifestData fetchedData = defaultManifestData(); | 256 ManifestData fetchedData = defaultManifestData(); |
| 227 fetchedData.scopeUrl = ""; | 257 fetchedData.scopeUrl = ""; |
| 228 Assert.assertTrue(!oldData.scopeUrl.equals(fetchedData.scopeUrl)); | 258 Assert.assertTrue(!oldData.scopeUrl.equals(fetchedData.scopeUrl)); |
| 229 | 259 Assert.assertFalse(checkUpdateNeededForFetchedManifest(oldData, fetchedD
ata)); |
| 230 TestCallback callback = new TestCallback(); | |
| 231 TestManifestUpgradeDetector detector = createDetector(oldData, fetchedDa
ta, callback); | |
| 232 detector.start(); | |
| 233 Assert.assertTrue(callback.mWasCalled); | |
| 234 Assert.assertFalse(callback.mIsUpgraded); | |
| 235 } | 260 } |
| 236 | 261 |
| 237 /** | 262 /** |
| 238 * Test that an upgrade is requested when the Web Manifest is updated from u
sing a non-empty | 263 * Test that an upgrade is requested when the Web Manifest is updated from u
sing a non-empty |
| 239 * scope to an empty scope. | 264 * scope to an empty scope. |
| 240 */ | 265 */ |
| 241 @Test | 266 @Test |
| 242 public void testManifestNonEmptyScopeToEmptyScopeShouldUpgrade() { | 267 public void testManifestNonEmptyScopeToEmptyScopeShouldUpgrade() { |
| 243 ManifestData oldData = defaultManifestData(); | 268 ManifestData oldData = defaultManifestData(); |
| 244 oldData.startUrl = "/fancy/scope/special/snowflake.html"; | 269 oldData.startUrl = "/fancy/scope/special/snowflake.html"; |
| 245 oldData.scopeUrl = "/fancy/scope/"; | 270 oldData.scopeUrl = "/fancy/scope/"; |
| 246 Assert.assertTrue( | 271 Assert.assertTrue( |
| 247 !oldData.scopeUrl.equals(ShortcutHelper.getScopeFromUrl(oldData.
startUrl))); | 272 !oldData.scopeUrl.equals(ShortcutHelper.getScopeFromUrl(oldData.
startUrl))); |
| 248 ManifestData fetchedData = defaultManifestData(); | 273 ManifestData fetchedData = defaultManifestData(); |
| 249 fetchedData.startUrl = "/fancy/scope/special/snowflake.html"; | 274 fetchedData.startUrl = "/fancy/scope/special/snowflake.html"; |
| 250 fetchedData.scopeUrl = ""; | 275 fetchedData.scopeUrl = ""; |
| 251 | 276 |
| 252 TestCallback callback = new TestCallback(); | 277 Assert.assertTrue(checkUpdateNeededForFetchedManifest(oldData, fetchedDa
ta)); |
| 253 TestManifestUpgradeDetector detector = createDetector(oldData, fetchedDa
ta, callback); | |
| 254 detector.start(); | |
| 255 Assert.assertTrue(callback.mWasCalled); | |
| 256 Assert.assertTrue(callback.mIsUpgraded); | |
| 257 } | 278 } |
| 258 | 279 |
| 259 /** | 280 /** |
| 260 * Test that an upgrade is requested when: | 281 * Test that an upgrade is requested when: |
| 261 * - WebAPK was generated using icon at {@link WEBAPK_BEST_ICON_URL} from We
b Manifest. | 282 * - WebAPK was generated using icon at {@link WEBAPK_BEST_ICON_URL} from We
b Manifest. |
| 262 * - Bitmap at {@link WEBAPK_BEST_ICON_URL} has changed. | 283 * - Bitmap at {@link WEBAPK_BEST_ICON_URL} has changed. |
| 263 */ | 284 */ |
| 264 @Test | 285 @Test |
| 265 public void testHomescreenIconChangeShouldUpgrade() { | 286 public void testHomescreenIconChangeShouldUpgrade() { |
| 266 ManifestData fetchedData = defaultManifestData(); | 287 ManifestData fetchedData = defaultManifestData(); |
| 267 fetchedData.iconUrlToMurmur2HashMap.put(fetchedData.bestIconUrl, | 288 fetchedData.iconUrlToMurmur2HashMap.put(fetchedData.bestIconUrl, |
| 268 WEBAPK_BEST_ICON_MURMUR2_HASH + "1"); | 289 WEBAPK_BEST_ICON_MURMUR2_HASH + "1"); |
| 269 fetchedData.bestIcon = createBitmap(Color.BLUE); | 290 fetchedData.bestIcon = createBitmap(Color.BLUE); |
| 270 TestCallback callback = new TestCallback(); | 291 Assert.assertTrue(checkUpdateNeededForFetchedManifest(defaultManifestDat
a(), fetchedData)); |
| 271 TestManifestUpgradeDetector detector = createDetectorWithFetchedData(fet
chedData, callback); | |
| 272 | |
| 273 detector.start(); | |
| 274 Assert.assertTrue(callback.mWasCalled); | |
| 275 Assert.assertTrue(callback.mIsUpgraded); | |
| 276 } | 292 } |
| 277 | 293 |
| 278 /** | 294 /** |
| 279 * Test that an upgrade is requested when: | 295 * Test that an upgrade is requested when: |
| 280 * - WebAPK is generated using icon at {@link WEBAPK_BEST_ICON_URL} from Web
Manifest. | 296 * - WebAPK is generated using icon at {@link WEBAPK_BEST_ICON_URL} from Web
Manifest. |
| 281 * - Web Manifest is updated to refer to different icon. | 297 * - Web Manifest is updated to refer to different icon. |
| 282 */ | 298 */ |
| 283 @Test | 299 @Test |
| 284 public void testHomescreenBestIconUrlChangeShouldUpgrade() { | 300 public void testHomescreenBestIconUrlChangeShouldUpgrade() { |
| 285 ManifestData fetchedData = defaultManifestData(); | 301 ManifestData fetchedData = defaultManifestData(); |
| 286 fetchedData.iconUrlToMurmur2HashMap.clear(); | 302 fetchedData.iconUrlToMurmur2HashMap.clear(); |
| 287 fetchedData.iconUrlToMurmur2HashMap.put("/icon2.png", "22"); | 303 fetchedData.iconUrlToMurmur2HashMap.put("/icon2.png", "22"); |
| 288 fetchedData.bestIconUrl = "/icon2.png"; | 304 fetchedData.bestIconUrl = "/icon2.png"; |
| 289 | 305 Assert.assertTrue(checkUpdateNeededForFetchedManifest(defaultManifestDat
a(), fetchedData)); |
| 290 TestCallback callback = new TestCallback(); | |
| 291 TestManifestUpgradeDetector detector = createDetectorWithFetchedData(fet
chedData, callback); | |
| 292 detector.start(); | |
| 293 Assert.assertTrue(callback.mWasCalled); | |
| 294 Assert.assertTrue(callback.mIsUpgraded); | |
| 295 } | 306 } |
| 296 | 307 |
| 297 /** | 308 /** |
| 298 * Test that an upgrade is not requested if: | 309 * Test that an upgrade is not requested if: |
| 299 * - icon URL is added to the Web Manifest | 310 * - icon URL is added to the Web Manifest |
| 300 * AND | 311 * AND |
| 301 * - "best" icon URL for the launcher icon did not change. | 312 * - "best" icon URL for the launcher icon did not change. |
| 302 */ | 313 */ |
| 303 @Test | 314 @Test |
| 304 public void testIconUrlsChangeShouldNotUpgradeIfTheBestIconUrlDoesNotChange(
) { | 315 public void testIconUrlsChangeShouldNotUpgradeIfTheBestIconUrlDoesNotChange(
) { |
| 305 ManifestData fetchedData = defaultManifestData(); | 316 ManifestData fetchedData = defaultManifestData(); |
| 306 fetchedData.iconUrlToMurmur2HashMap.clear(); | 317 fetchedData.iconUrlToMurmur2HashMap.clear(); |
| 307 fetchedData.iconUrlToMurmur2HashMap.put( | 318 fetchedData.iconUrlToMurmur2HashMap.put( |
| 308 WEBAPK_BEST_ICON_URL, WEBAPK_BEST_ICON_MURMUR2_HASH); | 319 WEBAPK_BEST_ICON_URL, WEBAPK_BEST_ICON_MURMUR2_HASH); |
| 309 fetchedData.iconUrlToMurmur2HashMap.put("/icon2.png", null); | 320 fetchedData.iconUrlToMurmur2HashMap.put("/icon2.png", null); |
| 310 | 321 Assert.assertFalse(checkUpdateNeededForFetchedManifest(defaultManifestDa
ta(), fetchedData)); |
| 311 TestCallback callback = new TestCallback(); | |
| 312 TestManifestUpgradeDetector detector = createDetectorWithFetchedData(fet
chedData, callback); | |
| 313 detector.start(); | |
| 314 Assert.assertTrue(callback.mWasCalled); | |
| 315 Assert.assertFalse(callback.mIsUpgraded); | |
| 316 } | 322 } |
| 317 | 323 |
| 318 /** | 324 /** |
| 319 * Test than upgrade is requested if: | 325 * Test than upgrade is requested if: |
| 320 * - the WebAPK's meta data has murmur2 hashes for all of the icons. | 326 * - the WebAPK's meta data has murmur2 hashes for all of the icons. |
| 321 * AND | 327 * AND |
| 322 * - the Web Manifest has not changed | 328 * - the Web Manifest has not changed |
| 323 * AND | 329 * AND |
| 324 * - the computed best icon URL is different from the one stored in the WebA
PK's meta data. | 330 * - the computed best icon URL is different from the one stored in the WebA
PK's meta data. |
| 325 */ | 331 */ |
| 326 @Test | 332 @Test |
| 327 public void testWebManifestSameButBestIconUrlChangedShouldNotUpgrade() { | 333 public void testWebManifestSameButBestIconUrlChangedShouldNotUpgrade() { |
| 328 String iconUrl1 = "/icon1.png"; | 334 String iconUrl1 = "/icon1.png"; |
| 329 String iconUrl2 = "/icon2.png"; | 335 String iconUrl2 = "/icon2.png"; |
| 330 String hash1 = "11"; | 336 String hash1 = "11"; |
| 331 String hash2 = "22"; | 337 String hash2 = "22"; |
| 332 | 338 |
| 333 ManifestData oldData = defaultManifestData(); | 339 ManifestData oldData = defaultManifestData(); |
| 334 oldData.bestIconUrl = iconUrl1; | 340 oldData.bestIconUrl = iconUrl1; |
| 335 oldData.iconUrlToMurmur2HashMap.clear(); | 341 oldData.iconUrlToMurmur2HashMap.clear(); |
| 336 oldData.iconUrlToMurmur2HashMap.put(iconUrl1, hash1); | 342 oldData.iconUrlToMurmur2HashMap.put(iconUrl1, hash1); |
| 337 oldData.iconUrlToMurmur2HashMap.put(iconUrl2, hash2); | 343 oldData.iconUrlToMurmur2HashMap.put(iconUrl2, hash2); |
| 338 | 344 |
| 339 ManifestData fetchedData = defaultManifestData(); | 345 ManifestData fetchedData = defaultManifestData(); |
| 340 fetchedData.bestIconUrl = iconUrl2; | 346 fetchedData.bestIconUrl = iconUrl2; |
| 341 fetchedData.iconUrlToMurmur2HashMap.clear(); | 347 fetchedData.iconUrlToMurmur2HashMap.clear(); |
| 342 fetchedData.iconUrlToMurmur2HashMap.put(iconUrl1, null); | 348 fetchedData.iconUrlToMurmur2HashMap.put(iconUrl1, null); |
| 343 fetchedData.iconUrlToMurmur2HashMap.put(iconUrl2, hash2); | 349 fetchedData.iconUrlToMurmur2HashMap.put(iconUrl2, hash2); |
| 344 | 350 |
| 345 TestCallback callback = new TestCallback(); | 351 Assert.assertFalse(checkUpdateNeededForFetchedManifest(oldData, fetchedD
ata)); |
| 346 TestManifestUpgradeDetector detector = createDetector(oldData, fetchedDa
ta, callback); | |
| 347 detector.start(); | |
| 348 Assert.assertTrue(callback.mWasCalled); | |
| 349 Assert.assertFalse(callback.mIsUpgraded); | |
| 350 } | 352 } |
| 351 } | 353 } |
| OLD | NEW |