OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 static org.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
8 import static org.junit.Assert.assertTrue; | 8 import static org.junit.Assert.assertTrue; |
9 | 9 |
10 import android.content.Context; | 10 import android.content.Context; |
11 import android.content.Intent; | 11 import android.content.Intent; |
12 import android.content.SharedPreferences; | 12 import android.content.SharedPreferences; |
13 import android.os.AsyncTask; | 13 import android.os.AsyncTask; |
14 import android.text.TextUtils; | 14 import android.text.TextUtils; |
15 | 15 |
16 import org.junit.After; | 16 import org.junit.After; |
17 import org.junit.Before; | 17 import org.junit.Before; |
18 import org.junit.Test; | 18 import org.junit.Test; |
19 import org.junit.runner.RunWith; | 19 import org.junit.runner.RunWith; |
| 20 |
20 import org.robolectric.RuntimeEnvironment; | 21 import org.robolectric.RuntimeEnvironment; |
21 import org.robolectric.annotation.Config; | 22 import org.robolectric.annotation.Config; |
22 import org.robolectric.shadows.ShadowLooper; | 23 import org.robolectric.shadows.ShadowLooper; |
23 | 24 |
24 import org.chromium.base.ContextUtils; | 25 import org.chromium.base.ContextUtils; |
25 import org.chromium.base.test.util.Feature; | 26 import org.chromium.base.test.util.Feature; |
26 import org.chromium.chrome.browser.ShortcutHelper; | 27 import org.chromium.chrome.browser.ShortcutHelper; |
27 import org.chromium.chrome.browser.browsing_data.UrlFilters; | 28 import org.chromium.chrome.browser.browsing_data.UrlFilters; |
28 import org.chromium.testing.local.BackgroundShadowAsyncTask; | 29 import org.chromium.testing.local.BackgroundShadowAsyncTask; |
29 import org.chromium.testing.local.LocalRobolectricTestRunner; | 30 import org.chromium.testing.local.LocalRobolectricTestRunner; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 120 } |
120 | 121 |
121 @Test | 122 @Test |
122 @Feature({"Webapp"}) | 123 @Feature({"Webapp"}) |
123 public void testWebappRegistrationUpdatesLastUsed() throws Exception { | 124 public void testWebappRegistrationUpdatesLastUsed() throws Exception { |
124 registerWebapp("test", null); | 125 registerWebapp("test", null); |
125 | 126 |
126 long after = System.currentTimeMillis(); | 127 long after = System.currentTimeMillis(); |
127 SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().get
SharedPreferences( | 128 SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().get
SharedPreferences( |
128 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "test", Context.MOD
E_PRIVATE); | 129 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "test", Context.MOD
E_PRIVATE); |
129 long actual = webAppPrefs.getLong( | 130 long actual = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USED, |
130 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 131 WebappDataStorage.LAST_USED_INVALID); |
131 assertTrue("Timestamp is out of range", actual <= after); | 132 assertTrue("Timestamp is out of range", actual <= after); |
132 } | 133 } |
133 | 134 |
134 @Test | 135 @Test |
135 @Feature({"Webapp"}) | 136 @Feature({"Webapp"}) |
136 public void testWebappIdsRetrieval() throws Exception { | 137 public void testWebappIdsRetrieval() throws Exception { |
137 final Set<String> expected = addWebappsToRegistry("first", "second"); | 138 final Set<String> expected = addWebappsToRegistry("first", "second"); |
138 assertEquals(expected, WebappRegistry.getRegisteredWebappIdsForTesting()
); | 139 assertEquals(expected, WebappRegistry.getRegisteredWebappIdsForTesting()
); |
139 } | 140 } |
140 | 141 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "oldWebapp", Contex
t.MODE_PRIVATE); | 240 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "oldWebapp", Contex
t.MODE_PRIVATE); |
240 webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, Long.MIN_VAL
UE).apply(); | 241 webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, Long.MIN_VAL
UE).apply(); |
241 | 242 |
242 // Force a re-read of the preferences from disk. | 243 // Force a re-read of the preferences from disk. |
243 WebappRegistry.refreshSharedPrefsForTesting(); | 244 WebappRegistry.refreshSharedPrefsForTesting(); |
244 WebappRegistry.getInstance().unregisterOldWebapps(currentTime); | 245 WebappRegistry.getInstance().unregisterOldWebapps(currentTime); |
245 | 246 |
246 Set<String> actual = getRegisteredWebapps(); | 247 Set<String> actual = getRegisteredWebapps(); |
247 assertEquals(new HashSet<>(Arrays.asList("oldWebapp")), actual); | 248 assertEquals(new HashSet<>(Arrays.asList("oldWebapp")), actual); |
248 | 249 |
249 long actualLastUsed = webAppPrefs.getLong( | 250 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE
D, |
250 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 251 WebappDataStorage.LAST_USED_INVALID); |
251 assertEquals(Long.MIN_VALUE, actualLastUsed); | 252 assertEquals(Long.MIN_VALUE, actualLastUsed); |
252 | 253 |
253 // The last cleanup time was set to 0 in setUp() so check that this hasn
't changed. | 254 // The last cleanup time was set to 0 in setUp() so check that this hasn
't changed. |
254 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL
EANUP, -1); | 255 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL
EANUP, -1); |
255 assertEquals(INITIAL_TIME, lastCleanup); | 256 assertEquals(INITIAL_TIME, lastCleanup); |
256 } | 257 } |
257 | 258 |
258 @Test | 259 @Test |
259 @Feature({"Webapp"}) | 260 @Feature({"Webapp"}) |
260 public void testCleanupDoesNotRemoveRecentApps() throws Exception { | 261 public void testCleanupDoesNotRemoveRecentApps() throws Exception { |
(...skipping 11 matching lines...) Expand all Loading... |
272 WebappRegistry.refreshSharedPrefsForTesting(); | 273 WebappRegistry.refreshSharedPrefsForTesting(); |
273 | 274 |
274 // Because the time is just inside the window, there should be a cleanup
but the web app | 275 // Because the time is just inside the window, there should be a cleanup
but the web app |
275 // should not be deleted as it was used recently. The last cleanup time
should also be | 276 // should not be deleted as it was used recently. The last cleanup time
should also be |
276 // set to the current time. | 277 // set to the current time. |
277 WebappRegistry.getInstance().unregisterOldWebapps(currentTime); | 278 WebappRegistry.getInstance().unregisterOldWebapps(currentTime); |
278 | 279 |
279 Set<String> actual = getRegisteredWebapps(); | 280 Set<String> actual = getRegisteredWebapps(); |
280 assertEquals(new HashSet<>(Arrays.asList("recentWebapp")), actual); | 281 assertEquals(new HashSet<>(Arrays.asList("recentWebapp")), actual); |
281 | 282 |
282 long actualLastUsed = webAppPrefs.getLong( | 283 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE
D, |
283 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 284 WebappDataStorage.LAST_USED_INVALID); |
284 assertEquals(lastUsed, actualLastUsed); | 285 assertEquals(lastUsed, actualLastUsed); |
285 | 286 |
286 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL
EANUP, -1); | 287 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL
EANUP, -1); |
287 assertEquals(currentTime, lastCleanup); | 288 assertEquals(currentTime, lastCleanup); |
288 } | 289 } |
289 | 290 |
290 @Test | 291 @Test |
291 @Feature({"Webapp"}) | 292 @Feature({"Webapp"}) |
292 public void testCleanupRemovesOldApps() throws Exception { | 293 public void testCleanupRemovesOldApps() throws Exception { |
293 // Put the current time such that the task runs. | 294 // Put the current time such that the task runs. |
294 long currentTime = INITIAL_TIME + WebappRegistry.FULL_CLEANUP_DURATION; | 295 long currentTime = INITIAL_TIME + WebappRegistry.FULL_CLEANUP_DURATION; |
295 | 296 |
296 // Put the last used time just outside the no-cleanup window. | 297 // Put the last used time just outside the no-cleanup window. |
297 addWebappsToRegistry("oldWebapp"); | 298 addWebappsToRegistry("oldWebapp"); |
298 SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().get
SharedPreferences( | 299 SharedPreferences webAppPrefs = ContextUtils.getApplicationContext().get
SharedPreferences( |
299 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "oldWebapp", Contex
t.MODE_PRIVATE); | 300 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "oldWebapp", Contex
t.MODE_PRIVATE); |
300 long lastUsed = currentTime - WebappRegistry.WEBAPP_UNOPENED_CLEANUP_DUR
ATION; | 301 long lastUsed = currentTime - WebappRegistry.WEBAPP_UNOPENED_CLEANUP_DUR
ATION; |
301 webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, lastUsed).ap
ply(); | 302 webAppPrefs.edit().putLong(WebappDataStorage.KEY_LAST_USED, lastUsed).ap
ply(); |
302 | 303 |
303 // Force a re-read of the preferences from disk. | 304 // Force a re-read of the preferences from disk. |
304 WebappRegistry.refreshSharedPrefsForTesting(); | 305 WebappRegistry.refreshSharedPrefsForTesting(); |
305 | 306 |
306 // Because the time is just inside the window, there should be a cleanup
of old web apps and | 307 // Because the time is just inside the window, there should be a cleanup
of old web apps and |
307 // the last cleaned up time should be set to the current time. | 308 // the last cleaned up time should be set to the current time. |
308 WebappRegistry.getInstance().unregisterOldWebapps(currentTime); | 309 WebappRegistry.getInstance().unregisterOldWebapps(currentTime); |
309 | 310 |
310 Set<String> actual = getRegisteredWebapps(); | 311 Set<String> actual = getRegisteredWebapps(); |
311 assertTrue(actual.isEmpty()); | 312 assertTrue(actual.isEmpty()); |
312 | 313 |
313 long actualLastUsed = webAppPrefs.getLong( | 314 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE
D, |
314 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 315 WebappDataStorage.LAST_USED_INVALID); |
315 assertEquals(WebappDataStorage.TIMESTAMP_INVALID, actualLastUsed); | 316 assertEquals(WebappDataStorage.LAST_USED_INVALID, actualLastUsed); |
316 | 317 |
317 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL
EANUP, -1); | 318 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL
EANUP, -1); |
318 assertEquals(currentTime, lastCleanup); | 319 assertEquals(currentTime, lastCleanup); |
319 } | 320 } |
320 | 321 |
321 @Test | 322 @Test |
322 @Feature({"WebApk"}) | 323 @Feature({"WebApk"}) |
323 public void testCleanupRemovesUninstalledWebApks() throws Exception { | 324 public void testCleanupRemovesUninstalledWebApks() throws Exception { |
324 String webappId1 = "webapk:uninstalledWebApk1"; | 325 String webappId1 = "webapk:uninstalledWebApk1"; |
325 String webApkPackage1 = "uninstalledWebApk1"; | 326 String webApkPackage1 = "uninstalledWebApk1"; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 FetchStorageCallback storageCallback2 = new FetchStorageCallback(shortcu
tIntent2); | 414 FetchStorageCallback storageCallback2 = new FetchStorageCallback(shortcu
tIntent2); |
414 registerWebapp("webapp2", storageCallback2); | 415 registerWebapp("webapp2", storageCallback2); |
415 assertTrue(storageCallback2.getCallbackCalled()); | 416 assertTrue(storageCallback2.getCallbackCalled()); |
416 | 417 |
417 SharedPreferences webapp1Prefs = ContextUtils.getApplicationContext().ge
tSharedPreferences( | 418 SharedPreferences webapp1Prefs = ContextUtils.getApplicationContext().ge
tSharedPreferences( |
418 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp1", Context.
MODE_PRIVATE); | 419 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp1", Context.
MODE_PRIVATE); |
419 SharedPreferences webapp2Prefs = ContextUtils.getApplicationContext().ge
tSharedPreferences( | 420 SharedPreferences webapp2Prefs = ContextUtils.getApplicationContext().ge
tSharedPreferences( |
420 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp2", Context.
MODE_PRIVATE); | 421 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp2", Context.
MODE_PRIVATE); |
421 | 422 |
422 long webapp1OriginalLastUsed = webapp2Prefs.getLong( | 423 long webapp1OriginalLastUsed = webapp2Prefs.getLong( |
423 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 424 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS
ET); |
424 long webapp2OriginalLastUsed = webapp2Prefs.getLong( | 425 long webapp2OriginalLastUsed = webapp2Prefs.getLong( |
425 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 426 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS
ET); |
426 assertTrue(webapp1OriginalLastUsed != WebappDataStorage.TIMESTAMP_INVALI
D); | 427 assertTrue(webapp1OriginalLastUsed != WebappDataStorage.LAST_USED_UNSET)
; |
427 assertTrue(webapp2OriginalLastUsed != WebappDataStorage.TIMESTAMP_INVALI
D); | 428 assertTrue(webapp2OriginalLastUsed != WebappDataStorage.LAST_USED_UNSET)
; |
428 | 429 |
429 // Clear data for |webapp1Url|. | 430 // Clear data for |webapp1Url|. |
430 WebappRegistry.getInstance().clearWebappHistoryForUrlsImpl( | 431 WebappRegistry.getInstance().clearWebappHistoryForUrlsImpl( |
431 new UrlFilters.OneUrl(webapp1Url)); | 432 new UrlFilters.OneUrl(webapp1Url)); |
432 | 433 |
433 Set<String> actual = getRegisteredWebapps(); | 434 Set<String> actual = getRegisteredWebapps(); |
434 assertEquals(2, actual.size()); | 435 assertEquals(2, actual.size()); |
435 assertTrue(actual.contains("webapp1")); | 436 assertTrue(actual.contains("webapp1")); |
436 assertTrue(actual.contains("webapp2")); | 437 assertTrue(actual.contains("webapp2")); |
437 | 438 |
438 // Verify that the last used time for the first web app is | 439 // Verify that the last used time for the first web app is |
439 // WebappDataStorage.TIMESTAMP_INVALID, while for the second one it's un
changed. | 440 // WebappDataStorage.LAST_USED_UNSET, while for the second one it's unch
anged. |
440 long actualLastUsed = webapp1Prefs.getLong( | 441 long actualLastUsed = webapp1Prefs.getLong( |
441 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 442 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS
ET); |
442 assertEquals(WebappDataStorage.TIMESTAMP_INVALID, actualLastUsed); | 443 assertEquals(WebappDataStorage.LAST_USED_UNSET, actualLastUsed); |
443 actualLastUsed = webapp2Prefs.getLong( | 444 actualLastUsed = webapp2Prefs.getLong( |
444 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 445 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS
ET); |
445 assertEquals(webapp2OriginalLastUsed, actualLastUsed); | 446 assertEquals(webapp2OriginalLastUsed, actualLastUsed); |
446 | 447 |
447 // Verify that the URL and scope for the first web app is WebappDataStor
age.URL_INVALID, | 448 // Verify that the URL and scope for the first web app is WebappDataStor
age.URL_INVALID, |
448 // while for the second one it's unchanged. | 449 // while for the second one it's unchanged. |
449 String actualScope = webapp1Prefs.getString( | 450 String actualScope = webapp1Prefs.getString( |
450 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); | 451 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); |
451 assertEquals(WebappDataStorage.URL_INVALID, actualScope); | 452 assertEquals(WebappDataStorage.URL_INVALID, actualScope); |
452 String actualUrl = webapp1Prefs.getString( | 453 String actualUrl = webapp1Prefs.getString( |
453 WebappDataStorage.KEY_URL, WebappDataStorage.URL_INVALID); | 454 WebappDataStorage.KEY_URL, WebappDataStorage.URL_INVALID); |
454 assertEquals(WebappDataStorage.URL_INVALID, actualUrl); | 455 assertEquals(WebappDataStorage.URL_INVALID, actualUrl); |
455 actualScope = webapp2Prefs.getString( | 456 actualScope = webapp2Prefs.getString( |
456 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); | 457 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); |
457 assertEquals(webapp2Url + "/", actualScope); | 458 assertEquals(webapp2Url + "/", actualScope); |
458 actualUrl = webapp2Prefs.getString( | 459 actualUrl = webapp2Prefs.getString( |
459 WebappDataStorage.KEY_URL, WebappDataStorage.URL_INVALID); | 460 WebappDataStorage.KEY_URL, WebappDataStorage.URL_INVALID); |
460 assertEquals(webapp2Url, actualUrl); | 461 assertEquals(webapp2Url, actualUrl); |
461 | 462 |
462 // Clear data for all urls. | 463 // Clear data for all urls. |
463 WebappRegistry.getInstance().clearWebappHistoryForUrlsImpl(new UrlFilter
s.AllUrls()); | 464 WebappRegistry.getInstance().clearWebappHistoryForUrlsImpl(new UrlFilter
s.AllUrls()); |
464 | 465 |
465 // Verify that the last used time for both web apps is WebappDataStorage
.TIMESTAMP_INVALID. | 466 // Verify that the last used time for both web apps is WebappDataStorage
.LAST_USED_UNSET. |
466 actualLastUsed = webapp1Prefs.getLong( | 467 actualLastUsed = webapp1Prefs.getLong( |
467 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 468 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS
ET); |
468 assertEquals(WebappDataStorage.TIMESTAMP_INVALID, actualLastUsed); | 469 assertEquals(WebappDataStorage.LAST_USED_UNSET, actualLastUsed); |
469 actualLastUsed = webapp2Prefs.getLong( | 470 actualLastUsed = webapp2Prefs.getLong( |
470 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 471 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS
ET); |
471 assertEquals(WebappDataStorage.TIMESTAMP_INVALID, actualLastUsed); | 472 assertEquals(WebappDataStorage.LAST_USED_UNSET, actualLastUsed); |
472 | 473 |
473 // Verify that the URL and scope for both web apps is WebappDataStorage.
URL_INVALID. | 474 // Verify that the URL and scope for both web apps is WebappDataStorage.
URL_INVALID. |
474 actualScope = webapp1Prefs.getString( | 475 actualScope = webapp1Prefs.getString( |
475 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); | 476 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); |
476 assertEquals(WebappDataStorage.URL_INVALID, actualScope); | 477 assertEquals(WebappDataStorage.URL_INVALID, actualScope); |
477 actualUrl = webapp1Prefs.getString( | 478 actualUrl = webapp1Prefs.getString( |
478 WebappDataStorage.KEY_URL, WebappDataStorage.URL_INVALID); | 479 WebappDataStorage.KEY_URL, WebappDataStorage.URL_INVALID); |
479 assertEquals(WebappDataStorage.URL_INVALID, actualUrl); | 480 assertEquals(WebappDataStorage.URL_INVALID, actualUrl); |
480 actualScope = webapp2Prefs.getString( | 481 actualScope = webapp2Prefs.getString( |
481 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); | 482 WebappDataStorage.KEY_SCOPE, WebappDataStorage.URL_INVALID); |
(...skipping 10 matching lines...) Expand all Loading... |
492 | 493 |
493 SharedPreferences webappPrefs = ContextUtils.getApplicationContext().get
SharedPreferences( | 494 SharedPreferences webappPrefs = ContextUtils.getApplicationContext().get
SharedPreferences( |
494 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp", Context.M
ODE_PRIVATE); | 495 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp", Context.M
ODE_PRIVATE); |
495 WebappRegistry.getInstance().clearWebappHistoryForUrlsImpl(new UrlFilter
s.AllUrls()); | 496 WebappRegistry.getInstance().clearWebappHistoryForUrlsImpl(new UrlFilter
s.AllUrls()); |
496 | 497 |
497 // Open the webapp up and set the last used time. | 498 // Open the webapp up and set the last used time. |
498 WebappRegistry.getInstance().getWebappDataStorage("webapp").updateLastUs
edTime(); | 499 WebappRegistry.getInstance().getWebappDataStorage("webapp").updateLastUs
edTime(); |
499 | 500 |
500 // Verify that the last used time is valid. | 501 // Verify that the last used time is valid. |
501 long actualLastUsed = webappPrefs.getLong( | 502 long actualLastUsed = webappPrefs.getLong( |
502 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.TIMESTAMP_INV
ALID); | 503 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_INV
ALID); |
503 assertTrue(WebappDataStorage.TIMESTAMP_INVALID != actualLastUsed); | 504 assertTrue(WebappDataStorage.LAST_USED_INVALID != actualLastUsed); |
| 505 assertTrue(WebappDataStorage.LAST_USED_UNSET != actualLastUsed); |
504 } | 506 } |
505 | 507 |
506 @Test | 508 @Test |
507 @Feature({"Webapp"}) | 509 @Feature({"Webapp"}) |
508 public void testUpdateAfterClearWebappHistory() throws Exception { | 510 public void testUpdateAfterClearWebappHistory() throws Exception { |
509 final String webappUrl = "http://www.google.com"; | 511 final String webappUrl = "http://www.google.com"; |
510 final String webappScope = "http://www.google.com/"; | 512 final String webappScope = "http://www.google.com/"; |
511 final Intent shortcutIntent = createShortcutIntent(webappUrl); | 513 final Intent shortcutIntent = createShortcutIntent(webappUrl); |
512 registerWebapp("webapp", new FetchStorageCallback(shortcutIntent)); | 514 registerWebapp("webapp", new FetchStorageCallback(shortcutIntent)); |
513 | 515 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 } | 627 } |
626 | 628 |
627 private Intent createWebApkIntent(String webappId, String webApkPackage) { | 629 private Intent createWebApkIntent(String webappId, String webApkPackage) { |
628 Intent intent = new Intent(); | 630 Intent intent = new Intent(); |
629 intent.putExtra(ShortcutHelper.EXTRA_ID, webappId) | 631 intent.putExtra(ShortcutHelper.EXTRA_ID, webappId) |
630 .putExtra(ShortcutHelper.EXTRA_URL, "https://foo.com") | 632 .putExtra(ShortcutHelper.EXTRA_URL, "https://foo.com") |
631 .putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkPacka
ge); | 633 .putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkPacka
ge); |
632 return intent; | 634 return intent; |
633 } | 635 } |
634 } | 636 } |
OLD | NEW |