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

Side by Side Diff: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebappRegistryTest.java

Issue 1749603002: Store URLs in WebappDataStorage, and purge them when history is cleared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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;
(...skipping 25 matching lines...) Expand all
36 // These were copied from WebappRegistry for backward compatibility checking . 36 // These were copied from WebappRegistry for backward compatibility checking .
37 private static final String REGISTRY_FILE_NAME = "webapp_registry"; 37 private static final String REGISTRY_FILE_NAME = "webapp_registry";
38 private static final String KEY_WEBAPP_SET = "webapp_set"; 38 private static final String KEY_WEBAPP_SET = "webapp_set";
39 private static final String KEY_LAST_CLEANUP = "last_cleanup"; 39 private static final String KEY_LAST_CLEANUP = "last_cleanup";
40 40
41 private static final int INITIAL_TIME = 0; 41 private static final int INITIAL_TIME = 0;
42 42
43 private SharedPreferences mSharedPreferences; 43 private SharedPreferences mSharedPreferences;
44 private boolean mCallbackCalled; 44 private boolean mCallbackCalled;
45 45
46 private class FetchCallback implements WebappRegistry.FetchCallback {
47 Set<String> mExpected;
48
49 FetchCallback(Set<String> expected) {
50 mExpected = expected;
51 }
52
53 @Override
54 public void onWebappIdsRetrieved(Set<String> actual) {
55 mCallbackCalled = true;
56 assertEquals(mExpected, actual);
57 }
58 }
59
46 @Before 60 @Before
47 public void setUp() throws Exception { 61 public void setUp() throws Exception {
48 mSharedPreferences = Robolectric.application 62 mSharedPreferences = Robolectric.application
49 .getSharedPreferences(REGISTRY_FILE_NAME, Context.MODE_PRIVATE); 63 .getSharedPreferences(REGISTRY_FILE_NAME, Context.MODE_PRIVATE);
50 mSharedPreferences.edit().putLong(KEY_LAST_CLEANUP, INITIAL_TIME).commit (); 64 mSharedPreferences.edit().putLong(KEY_LAST_CLEANUP, INITIAL_TIME).commit ();
51 65
52 mCallbackCalled = false; 66 mCallbackCalled = false;
53 } 67 }
54 68
55 @Test 69 @Test
56 @Feature({"Webapp"}) 70 @Feature({"Webapp"})
57 public void testBackwardCompatibility() { 71 public void testBackwardCompatibility() {
58 assertEquals(REGISTRY_FILE_NAME, WebappRegistry.REGISTRY_FILE_NAME); 72 assertEquals(REGISTRY_FILE_NAME, WebappRegistry.REGISTRY_FILE_NAME);
59 assertEquals(KEY_WEBAPP_SET, WebappRegistry.KEY_WEBAPP_SET); 73 assertEquals(KEY_WEBAPP_SET, WebappRegistry.KEY_WEBAPP_SET);
60 assertEquals(KEY_LAST_CLEANUP, WebappRegistry.KEY_LAST_CLEANUP); 74 assertEquals(KEY_LAST_CLEANUP, WebappRegistry.KEY_LAST_CLEANUP);
61 } 75 }
62 76
63 @Test 77 @Test
64 @Feature({"Webapp"}) 78 @Feature({"Webapp"})
65 public void testWebappRegistrationAddsToSharedPrefs() throws Exception { 79 public void testWebappRegistrationAddsToSharedPrefs() throws Exception {
66 WebappRegistry.registerWebapp(Robolectric.application, "test"); 80 WebappRegistry.registerWebapp(Robolectric.application, "test", "https:// www.google.com");
67 BackgroundShadowAsyncTask.runBackgroundTasks(); 81 BackgroundShadowAsyncTask.runBackgroundTasks();
68 82
69 Set<String> actual = mSharedPreferences.getStringSet( 83 Set<String> actual = mSharedPreferences.getStringSet(
70 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet()); 84 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet());
71 assertEquals(1, actual.size()); 85 assertEquals(1, actual.size());
72 assertTrue(actual.contains("test")); 86 assertTrue(actual.contains("test"));
73 } 87 }
74 88
75 @Test 89 @Test
76 @Feature({"Webapp"}) 90 @Feature({"Webapp"})
77 public void testWebappRegistrationUpdatesLastUsed() throws Exception { 91 public void testWebappRegistrationUpdatesLastUsedAndSCOPE() throws Exception {
78 long before = System.currentTimeMillis(); 92 long before = System.currentTimeMillis();
79 WebappRegistry.registerWebapp(Robolectric.application, "test"); 93 final String scope = "http://drive.google.com";
94
95 WebappRegistry.registerWebapp(Robolectric.application, "test", scope);
80 BackgroundShadowAsyncTask.runBackgroundTasks(); 96 BackgroundShadowAsyncTask.runBackgroundTasks();
81 long after = System.currentTimeMillis(); 97 long after = System.currentTimeMillis();
82 98
83 SharedPreferences webAppPrefs = Robolectric.application.getSharedPrefere nces( 99 SharedPreferences webAppPrefs = Robolectric.application.getSharedPrefere nces(
84 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "test", Context.MOD E_PRIVATE); 100 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "test", Context.MOD E_PRIVATE);
85 long actual = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USED, 101 long actual = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USED,
86 WebappDataStorage.INVALID_LAST_USED); 102 WebappDataStorage.LAST_USED_INVALID);
103 String webAppScope = webAppPrefs.getString(WebappDataStorage.KEY_SCOPE,
104 WebappDataStorage.SCOPE_INVALID);
87 assertTrue("Timestamp is out of range", before <= actual && actual <= af ter); 105 assertTrue("Timestamp is out of range", before <= actual && actual <= af ter);
106 assertEquals(scope, webAppScope);
88 } 107 }
89 108
90 @Test 109 @Test
91 @Feature({"Webapp"}) 110 @Feature({"Webapp"})
92 public void testWebappIdsRetrieval() throws Exception { 111 public void testWebappIdsRetrieval() throws Exception {
93 final Set<String> expected = addWebappsToRegistry("first", "second"); 112 final Set<String> expected = addWebappsToRegistry("first", "second");
94 113
95 WebappRegistry.getRegisteredWebappIds(Robolectric.application, 114 WebappRegistry.getRegisteredWebappIds(Robolectric.application, new Fetch Callback(expected));
96 new WebappRegistry.FetchCallback() {
97 @Override
98 public void onWebappIdsRetrieved(Set<String> actual) {
99 mCallbackCalled = true;
100 assertEquals(expected, actual);
101 }
102 });
103 BackgroundShadowAsyncTask.runBackgroundTasks(); 115 BackgroundShadowAsyncTask.runBackgroundTasks();
104 Robolectric.runUiThreadTasks(); 116 Robolectric.runUiThreadTasks();
105 117
106 assertTrue(mCallbackCalled); 118 assertTrue(mCallbackCalled);
107 } 119 }
108 120
109 @Test 121 @Test
110 @Feature({"Webapp"}) 122 @Feature({"Webapp"})
111 public void testWebappIdsRetrievalRegisterRetrival() throws Exception { 123 public void testWebappIdsRetrievalRegisterRetrival() throws Exception {
112 final Set<String> expected = addWebappsToRegistry("first"); 124 final Set<String> expected = addWebappsToRegistry("first");
113 125
114 WebappRegistry.getRegisteredWebappIds(Robolectric.application, 126 WebappRegistry.getRegisteredWebappIds(Robolectric.application, new Fetch Callback(expected));
115 new WebappRegistry.FetchCallback() {
116 @Override
117 public void onWebappIdsRetrieved(Set<String> actual) {
118 mCallbackCalled = true;
119 assertEquals(expected, actual);
120 }
121 });
122 BackgroundShadowAsyncTask.runBackgroundTasks(); 127 BackgroundShadowAsyncTask.runBackgroundTasks();
123 Robolectric.runUiThreadTasks(); 128 Robolectric.runUiThreadTasks();
124 129
125 assertTrue(mCallbackCalled); 130 assertTrue(mCallbackCalled);
126 mCallbackCalled = false; 131 mCallbackCalled = false;
127 132
128 WebappRegistry.registerWebapp(Robolectric.application, "second"); 133 WebappRegistry.registerWebapp(Robolectric.application, "second", "https: //www.google.com");
129 BackgroundShadowAsyncTask.runBackgroundTasks(); 134 BackgroundShadowAsyncTask.runBackgroundTasks();
130 135
131 // A copy of the expected set needs to be made as the SharedPreferences is using the copy 136 // A copy of the expected set needs to be made as the SharedPreferences is using the copy
132 // that was paassed to it. 137 // that was paassed to it.
133 final Set<String> secondExpected = new HashSet<String>(expected); 138 final Set<String> secondExpected = new HashSet<String>(expected);
134 secondExpected.add("second"); 139 secondExpected.add("second");
135 140
136 WebappRegistry.getRegisteredWebappIds(Robolectric.application, 141 WebappRegistry.getRegisteredWebappIds(Robolectric.application,
137 new WebappRegistry.FetchCallback() { 142 new FetchCallback(secondExpected));
138 @Override
139 public void onWebappIdsRetrieved(Set<String> actual) {
140 mCallbackCalled = true;
141 assertEquals(secondExpected, actual);
142 }
143 });
144 BackgroundShadowAsyncTask.runBackgroundTasks(); 143 BackgroundShadowAsyncTask.runBackgroundTasks();
145 Robolectric.runUiThreadTasks(); 144 Robolectric.runUiThreadTasks();
146 145
147 assertTrue(mCallbackCalled); 146 assertTrue(mCallbackCalled);
148 } 147 }
149 148
150 @Test 149 @Test
151 @Feature({"Webapp"}) 150 @Feature({"Webapp"})
152 public void testUnregisterRunsCallback() throws Exception { 151 public void testUnregisterRunsCallback() throws Exception {
153 WebappRegistry.unregisterAllWebapps(Robolectric.application, new Runnabl e() { 152 WebappRegistry.unregisterAllWebapps(Robolectric.application, new Runnabl e() {
154 @Override 153 @Override
155 public void run() { 154 public void run() {
156 mCallbackCalled = true; 155 mCallbackCalled = true;
157 } 156 }
158 }); 157 });
159 BackgroundShadowAsyncTask.runBackgroundTasks(); 158 BackgroundShadowAsyncTask.runBackgroundTasks();
160 Robolectric.runUiThreadTasks(); 159 Robolectric.runUiThreadTasks();
161 160
162 assertTrue(mCallbackCalled); 161 assertTrue(mCallbackCalled);
163 } 162 }
164 163
165 @Test 164 @Test
166 @Feature({"Webapp"}) 165 @Feature({"Webapp"})
167 public void testUnregisterClearsRegistry() throws Exception { 166 public void testUnregisterClearsRegistry() throws Exception {
168 addWebappsToRegistry("test"); 167 addWebappsToRegistry("test");
169 168
170 WebappRegistry.unregisterAllWebapps(Robolectric.application, null); 169 WebappRegistry.unregisterAllWebapps(Robolectric.application, new Runnabl e() {
170 @Override
171 public void run() {
172 mCallbackCalled = true;
173 }
174 });
171 BackgroundShadowAsyncTask.runBackgroundTasks(); 175 BackgroundShadowAsyncTask.runBackgroundTasks();
176 Robolectric.runUiThreadTasks();
172 177
178 assertTrue(mCallbackCalled);
173 assertTrue(getRegisteredWebapps().isEmpty()); 179 assertTrue(getRegisteredWebapps().isEmpty());
174 } 180 }
175 181
176 @Test 182 @Test
177 @Feature({"Webapp"}) 183 @Feature({"Webapp"})
178 public void testUnregisterClearsWebappDataStorage() throws Exception { 184 public void testUnregisterClearsWebappDataStorage() throws Exception {
179 addWebappsToRegistry("test"); 185 addWebappsToRegistry("test");
180 SharedPreferences webAppPrefs = Robolectric.application.getSharedPrefere nces( 186 SharedPreferences webAppPrefs = Robolectric.application.getSharedPrefere nces(
181 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "test", Context.MOD E_PRIVATE); 187 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "test", Context.MOD E_PRIVATE);
182 webAppPrefs.edit() 188 webAppPrefs.edit()
(...skipping 21 matching lines...) Expand all
204 .commit(); 210 .commit();
205 211
206 WebappRegistry.unregisterOldWebapps(Robolectric.application, currentTime ); 212 WebappRegistry.unregisterOldWebapps(Robolectric.application, currentTime );
207 BackgroundShadowAsyncTask.runBackgroundTasks(); 213 BackgroundShadowAsyncTask.runBackgroundTasks();
208 214
209 Set<String> actual = mSharedPreferences.getStringSet( 215 Set<String> actual = mSharedPreferences.getStringSet(
210 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet()); 216 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet());
211 assertEquals(new HashSet<String>(Arrays.asList("oldWebapp")), actual); 217 assertEquals(new HashSet<String>(Arrays.asList("oldWebapp")), actual);
212 218
213 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE D, 219 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE D,
214 WebappDataStorage.INVALID_LAST_USED); 220 WebappDataStorage.LAST_USED_INVALID);
215 assertEquals(Long.MIN_VALUE, actualLastUsed); 221 assertEquals(Long.MIN_VALUE, actualLastUsed);
216 222
217 // The last cleanup time was set to 0 in setUp() so check that this hasn 't changed. 223 // The last cleanup time was set to 0 in setUp() so check that this hasn 't changed.
218 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL EANUP, -1); 224 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL EANUP, -1);
219 assertEquals(INITIAL_TIME, lastCleanup); 225 assertEquals(INITIAL_TIME, lastCleanup);
220 } 226 }
221 227
222 @Test 228 @Test
223 @Feature({"Webapp"}) 229 @Feature({"Webapp"})
224 public void testCleanupDoesNotRemoveRecentApps() throws Exception { 230 public void testCleanupDoesNotRemoveRecentApps() throws Exception {
(...skipping 13 matching lines...) Expand all
238 // should not be deleted as it was used recently. The last cleanup time should also be 244 // should not be deleted as it was used recently. The last cleanup time should also be
239 // set to the current time. 245 // set to the current time.
240 WebappRegistry.unregisterOldWebapps(Robolectric.application, currentTime ); 246 WebappRegistry.unregisterOldWebapps(Robolectric.application, currentTime );
241 BackgroundShadowAsyncTask.runBackgroundTasks(); 247 BackgroundShadowAsyncTask.runBackgroundTasks();
242 248
243 Set<String> actual = mSharedPreferences.getStringSet( 249 Set<String> actual = mSharedPreferences.getStringSet(
244 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet()); 250 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet());
245 assertEquals(new HashSet<String>(Arrays.asList("recentWebapp")), actual) ; 251 assertEquals(new HashSet<String>(Arrays.asList("recentWebapp")), actual) ;
246 252
247 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE D, 253 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE D,
248 WebappDataStorage.INVALID_LAST_USED); 254 WebappDataStorage.LAST_USED_INVALID);
249 assertEquals(lastUsed, actualLastUsed); 255 assertEquals(lastUsed, actualLastUsed);
250 256
251 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL EANUP, -1); 257 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL EANUP, -1);
252 assertEquals(currentTime, lastCleanup); 258 assertEquals(currentTime, lastCleanup);
253 } 259 }
254 260
255 @Test 261 @Test
256 @Feature({"Webapp"}) 262 @Feature({"Webapp"})
257 public void testCleanupRemovesOldApps() throws Exception { 263 public void testCleanupRemovesOldApps() throws Exception {
258 // Put the current time such that the task runs. 264 // Put the current time such that the task runs.
(...skipping 11 matching lines...) Expand all
270 // Because the time is just inside the window, there should be a cleanup of old web apps and 276 // Because the time is just inside the window, there should be a cleanup of old web apps and
271 // the last cleaned up time should be set to the current time. 277 // the last cleaned up time should be set to the current time.
272 WebappRegistry.unregisterOldWebapps(Robolectric.application, currentTime ); 278 WebappRegistry.unregisterOldWebapps(Robolectric.application, currentTime );
273 BackgroundShadowAsyncTask.runBackgroundTasks(); 279 BackgroundShadowAsyncTask.runBackgroundTasks();
274 280
275 Set<String> actual = mSharedPreferences.getStringSet( 281 Set<String> actual = mSharedPreferences.getStringSet(
276 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet()); 282 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet());
277 assertTrue(actual.isEmpty()); 283 assertTrue(actual.isEmpty());
278 284
279 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE D, 285 long actualLastUsed = webAppPrefs.getLong(WebappDataStorage.KEY_LAST_USE D,
280 WebappDataStorage.INVALID_LAST_USED); 286 WebappDataStorage.LAST_USED_INVALID);
281 assertEquals(WebappDataStorage.INVALID_LAST_USED, actualLastUsed); 287 assertEquals(WebappDataStorage.LAST_USED_INVALID, actualLastUsed);
282 288
283 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL EANUP, -1); 289 long lastCleanup = mSharedPreferences.getLong(WebappRegistry.KEY_LAST_CL EANUP, -1);
284 assertEquals(currentTime, lastCleanup); 290 assertEquals(currentTime, lastCleanup);
285 } 291 }
286 292
293 @Test
294 @Feature({"Webapp"})
295 public void testClearWebappHistoryRunsCallback() throws Exception {
296 WebappRegistry.clearWebappHistory(Robolectric.application, new Runnable( ) {
297 @Override
298 public void run() {
299 mCallbackCalled = true;
300 }
301 });
302 BackgroundShadowAsyncTask.runBackgroundTasks();
303 Robolectric.runUiThreadTasks();
304
305 assertTrue(mCallbackCalled);
306 }
307
308 @Test
309 @Feature({"Webapp"})
310 public void testClearWebappHistory() throws Exception {
311 final String webappScope1 = "https://www.google.com";
312 final String webappScope2 = "https://drive.google.com";
313 WebappRegistry.registerWebapp(Robolectric.application, "webapp1", webapp Scope1);
314 WebappRegistry.registerWebapp(Robolectric.application, "webapp2", webapp Scope2);
315 BackgroundShadowAsyncTask.runBackgroundTasks();
316
317 SharedPreferences webapp1Prefs = Robolectric.application.getSharedPrefer ences(
318 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp1", Context. MODE_PRIVATE);
319 SharedPreferences webapp2Prefs = Robolectric.application.getSharedPrefer ences(
320 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp2", Context. MODE_PRIVATE);
321
322 WebappRegistry.clearWebappHistory(Robolectric.application, new Runnable( ) {
323 @Override
324 public void run() {
325 mCallbackCalled = true;
326 }
327 });
328 BackgroundShadowAsyncTask.runBackgroundTasks();
329 Robolectric.runUiThreadTasks();
330
331 assertTrue(mCallbackCalled);
332
333 Set<String> actual = mSharedPreferences.getStringSet(
334 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet());
335 assertEquals(2, actual.size());
336 assertTrue(actual.contains("webapp1"));
337 assertTrue(actual.contains("webapp2"));
338
339 // Verify that the last used time for both web apps is WebappDataStorage .LAST_USED_UNSET.
340 long actualLastUsed = webapp1Prefs.getLong(
341 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS ET);
342 assertEquals(WebappDataStorage.LAST_USED_UNSET, actualLastUsed);
343 actualLastUsed = webapp2Prefs.getLong(
344 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_UNS ET);
345 assertEquals(WebappDataStorage.LAST_USED_UNSET, actualLastUsed);
346
347 // Verify that the scope for both web apps is WebappDataStorage.SCOPE_IN VALID.
348 String actualScope = webapp1Prefs.getString(
349 WebappDataStorage.KEY_SCOPE, WebappDataStorage.SCOPE_INVALID);
350 assertEquals(WebappDataStorage.SCOPE_INVALID, actualScope);
351 actualScope = webapp2Prefs.getString(
352 WebappDataStorage.KEY_SCOPE, WebappDataStorage.SCOPE_INVALID);
353 assertEquals(WebappDataStorage.SCOPE_INVALID, actualScope);
354 }
355
356 @Test
357 @Feature({"Webapp"})
358 public void testOpenAfterClearWebappHistory() throws Exception {
359 final String webappScope = "https://www.google.com";
360 WebappRegistry.registerWebapp(Robolectric.application, "webapp", webappS cope);
361 BackgroundShadowAsyncTask.runBackgroundTasks();
362
363 SharedPreferences webappPrefs = Robolectric.application.getSharedPrefere nces(
364 WebappDataStorage.SHARED_PREFS_FILE_PREFIX + "webapp", Context.M ODE_PRIVATE);
365
366 WebappRegistry.clearWebappHistory(Robolectric.application, new Runnable( ) {
367 @Override
368 public void run() {
369 mCallbackCalled = true;
370 }
371 });
372 BackgroundShadowAsyncTask.runBackgroundTasks();
373
374 // Open the webapp up and set the scope.
375 WebappDataStorage.open(Robolectric.application, "webapp");
376 WebappDataStorage.setScope(Robolectric.application, "webapp", webappScop e);
377 BackgroundShadowAsyncTask.runBackgroundTasks();
378 Robolectric.runUiThreadTasks();
379 assertTrue(mCallbackCalled);
380
381 // Verify that the last used time is valid and the scope is updated.
382 long actualLastUsed = webappPrefs.getLong(
383 WebappDataStorage.KEY_LAST_USED, WebappDataStorage.LAST_USED_INV ALID);
384 assertTrue(WebappDataStorage.LAST_USED_INVALID != actualLastUsed);
385 assertTrue(WebappDataStorage.LAST_USED_UNSET != actualLastUsed);
386 String actualScope = webappPrefs.getString(
387 WebappDataStorage.KEY_SCOPE, WebappDataStorage.SCOPE_INVALID);
388 assertEquals(webappScope, actualScope);
389 }
390
391
287 private Set<String> addWebappsToRegistry(String... webapps) { 392 private Set<String> addWebappsToRegistry(String... webapps) {
288 final Set<String> expected = new HashSet<String>(Arrays.asList(webapps)) ; 393 final Set<String> expected = new HashSet<String>(Arrays.asList(webapps)) ;
289 mSharedPreferences.edit() 394 mSharedPreferences.edit()
290 .putStringSet(WebappRegistry.KEY_WEBAPP_SET, expected) 395 .putStringSet(WebappRegistry.KEY_WEBAPP_SET, expected)
291 .commit(); 396 .commit();
292 return expected; 397 return expected;
293 } 398 }
294 399
295 private Set<String> getRegisteredWebapps() { 400 private Set<String> getRegisteredWebapps() {
296 return mSharedPreferences.getStringSet( 401 return mSharedPreferences.getStringSet(
297 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet()); 402 WebappRegistry.KEY_WEBAPP_SET, Collections.<String>emptySet());
298 } 403 }
299 } 404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698