Index: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java |
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java |
index a1baa2b4e239755c1a85c78277611fedd2fe4cda..92e6bf64422c4dd5d4f5eae29f6360bf84cea420 100644 |
--- a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java |
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappDataStorageTest.java |
@@ -188,24 +188,24 @@ public class WebappDataStorageTest { |
final TestClock clock = new TestClock(System.currentTimeMillis()); |
WebappDataStorage.setClockForTests(clock); |
+ // Opening a data storage doesn't count as a launch. |
WebappDataStorage storage = WebappDataStorage.open(Robolectric.application, "test"); |
- storage.updateLastUsedTime(); |
BackgroundShadowAsyncTask.runBackgroundTasks(); |
Robolectric.runUiThreadTasks(); |
assertTrue(!storage.wasLaunchedRecently()); |
+ // When the last used time is updated, then it is a launch. |
+ storage.updateLastUsedTime(); |
+ BackgroundShadowAsyncTask.runBackgroundTasks(); |
+ Robolectric.runUiThreadTasks(); |
+ assertTrue(storage.wasLaunchedRecently()); |
+ |
long lastUsedTime = mSharedPreferences.getLong(WebappDataStorage.KEY_LAST_USED, |
WebappDataStorage.LAST_USED_INVALID); |
assertTrue(lastUsedTime != WebappDataStorage.LAST_USED_UNSET); |
assertTrue(lastUsedTime != WebappDataStorage.LAST_USED_INVALID); |
- // Mark as launched, check launched recently. |
- mSharedPreferences.edit() |
- .putBoolean(WebappDataStorage.KEY_LAUNCHED, true) |
- .commit(); |
- assertTrue(storage.wasLaunchedRecently()); |
- |
// Move the last used time one day in the past. |
mSharedPreferences.edit() |
.putLong(WebappDataStorage.KEY_LAST_USED, lastUsedTime - TimeUnit.DAYS.toMillis(1L)) |
@@ -229,18 +229,6 @@ public class WebappDataStorageTest { |
lastUsedTime - TimeUnit.DAYS.toMillis(10L) + 1).commit(); |
assertTrue(storage.wasLaunchedRecently()); |
- // Mark as not launched. |
- mSharedPreferences.edit() |
- .putBoolean(WebappDataStorage.KEY_LAUNCHED, false) |
- .commit(); |
- assertTrue(!storage.wasLaunchedRecently()); |
- |
- // Mark as launched. |
- mSharedPreferences.edit() |
- .putBoolean(WebappDataStorage.KEY_LAUNCHED, true) |
- .commit(); |
- assertTrue(storage.wasLaunchedRecently()); |
- |
// Move the last used time to exactly ten days in the past. |
mSharedPreferences.edit().putLong(WebappDataStorage.KEY_LAST_USED, |
lastUsedTime - TimeUnit.DAYS.toMillis(10L)).commit(); |