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

Side by Side Diff: webkit/appcache/mock_appcache_storage_unittest.cc

Issue 11595003: webkit: Update the calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "webkit/appcache/appcache.h" 7 #include "webkit/appcache/appcache.h"
8 #include "webkit/appcache/appcache_group.h" 8 #include "webkit/appcache/appcache_group.h"
9 #include "webkit/appcache/appcache_response.h" 9 #include "webkit/appcache/appcache_response.h"
10 #include "webkit/appcache/appcache_storage.h" 10 #include "webkit/appcache/appcache_storage.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }; 77 };
78 78
79 79
80 TEST_F(MockAppCacheStorageTest, LoadCache_Miss) { 80 TEST_F(MockAppCacheStorageTest, LoadCache_Miss) {
81 // Attempt to load a cache that doesn't exist. Should 81 // Attempt to load a cache that doesn't exist. Should
82 // complete asyncly. 82 // complete asyncly.
83 MockAppCacheService service; 83 MockAppCacheService service;
84 MockStorageDelegate delegate; 84 MockStorageDelegate delegate;
85 service.storage()->LoadCache(111, &delegate); 85 service.storage()->LoadCache(111, &delegate);
86 EXPECT_NE(111, delegate.loaded_cache_id_); 86 EXPECT_NE(111, delegate.loaded_cache_id_);
87 MessageLoop::current()->RunAllPending(); // Do async task execution. 87 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
88 EXPECT_EQ(111, delegate.loaded_cache_id_); 88 EXPECT_EQ(111, delegate.loaded_cache_id_);
89 EXPECT_FALSE(delegate.loaded_cache_); 89 EXPECT_FALSE(delegate.loaded_cache_);
90 } 90 }
91 91
92 TEST_F(MockAppCacheStorageTest, LoadCache_NearHit) { 92 TEST_F(MockAppCacheStorageTest, LoadCache_NearHit) {
93 // Attempt to load a cache that is currently in use 93 // Attempt to load a cache that is currently in use
94 // and does not require loading from disk. This 94 // and does not require loading from disk. This
95 // load should complete syncly. 95 // load should complete syncly.
96 MockAppCacheService service; 96 MockAppCacheService service;
97 97
(...skipping 13 matching lines...) Expand all
111 // Attempt to load/create a group that doesn't exist. 111 // Attempt to load/create a group that doesn't exist.
112 // Should complete asyncly. 112 // Should complete asyncly.
113 MockAppCacheService service; 113 MockAppCacheService service;
114 MockAppCacheStorage* storage = 114 MockAppCacheStorage* storage =
115 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 115 reinterpret_cast<MockAppCacheStorage*>(service.storage());
116 MockStorageDelegate delegate; 116 MockStorageDelegate delegate;
117 GURL manifest_url("http://blah/"); 117 GURL manifest_url("http://blah/");
118 service.storage()->LoadOrCreateGroup(manifest_url, &delegate); 118 service.storage()->LoadOrCreateGroup(manifest_url, &delegate);
119 EXPECT_NE(manifest_url, delegate.loaded_manifest_url_); 119 EXPECT_NE(manifest_url, delegate.loaded_manifest_url_);
120 EXPECT_FALSE(delegate.loaded_group_.get()); 120 EXPECT_FALSE(delegate.loaded_group_.get());
121 MessageLoop::current()->RunAllPending(); // Do async task execution. 121 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
122 EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_); 122 EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_);
123 EXPECT_TRUE(delegate.loaded_group_.get()); 123 EXPECT_TRUE(delegate.loaded_group_.get());
124 EXPECT_TRUE(delegate.loaded_group_->HasOneRef()); 124 EXPECT_TRUE(delegate.loaded_group_->HasOneRef());
125 EXPECT_FALSE(delegate.loaded_group_->newest_complete_cache()); 125 EXPECT_FALSE(delegate.loaded_group_->newest_complete_cache());
126 EXPECT_TRUE(storage->stored_groups_.empty()); 126 EXPECT_TRUE(storage->stored_groups_.empty());
127 } 127 }
128 128
129 TEST_F(MockAppCacheStorageTest, LoadGroup_NearHit) { 129 TEST_F(MockAppCacheStorageTest, LoadGroup_NearHit) {
130 // Attempt to load a group that is currently in use 130 // Attempt to load a group that is currently in use
131 // and does not require loading from disk. This 131 // and does not require loading from disk. This
132 // load should complete syncly. 132 // load should complete syncly.
133 MockAppCacheService service; 133 MockAppCacheService service;
134 MockStorageDelegate delegate; 134 MockStorageDelegate delegate;
135 135
136 // Setup some preconditions. Create a group that appears 136 // Setup some preconditions. Create a group that appears
137 // to be "unstored" and "currently in use". 137 // to be "unstored" and "currently in use".
138 GURL manifest_url("http://blah/"); 138 GURL manifest_url("http://blah/");
139 service.storage()->LoadOrCreateGroup(manifest_url, &delegate); 139 service.storage()->LoadOrCreateGroup(manifest_url, &delegate);
140 MessageLoop::current()->RunAllPending(); // Do async task execution. 140 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
141 EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_); 141 EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_);
142 EXPECT_TRUE(delegate.loaded_group_.get()); 142 EXPECT_TRUE(delegate.loaded_group_.get());
143 143
144 // Reset our delegate, and take a reference to the new group. 144 // Reset our delegate, and take a reference to the new group.
145 scoped_refptr<AppCacheGroup> group; 145 scoped_refptr<AppCacheGroup> group;
146 group.swap(delegate.loaded_group_); 146 group.swap(delegate.loaded_group_);
147 delegate.loaded_manifest_url_ = GURL(); 147 delegate.loaded_manifest_url_ = GURL();
148 148
149 // Conduct the test. 149 // Conduct the test.
150 service.storage()->LoadOrCreateGroup(manifest_url, &delegate); 150 service.storage()->LoadOrCreateGroup(manifest_url, &delegate);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 // Setup a delegate to receive completion callbacks. 183 // Setup a delegate to receive completion callbacks.
184 MockStorageDelegate delegate; 184 MockStorageDelegate delegate;
185 185
186 // Conduct the cache load test. 186 // Conduct the cache load test.
187 EXPECT_NE(cache_id, delegate.loaded_cache_id_); 187 EXPECT_NE(cache_id, delegate.loaded_cache_id_);
188 EXPECT_NE(cache_ptr, delegate.loaded_cache_.get()); 188 EXPECT_NE(cache_ptr, delegate.loaded_cache_.get());
189 storage->LoadCache(cache_id, &delegate); 189 storage->LoadCache(cache_id, &delegate);
190 EXPECT_NE(cache_id, delegate.loaded_cache_id_); 190 EXPECT_NE(cache_id, delegate.loaded_cache_id_);
191 EXPECT_NE(cache_ptr, delegate.loaded_cache_.get()); 191 EXPECT_NE(cache_ptr, delegate.loaded_cache_.get());
192 MessageLoop::current()->RunAllPending(); // Do async task execution. 192 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
193 EXPECT_EQ(cache_id, delegate.loaded_cache_id_); 193 EXPECT_EQ(cache_id, delegate.loaded_cache_id_);
194 EXPECT_EQ(cache_ptr, delegate.loaded_cache_.get()); 194 EXPECT_EQ(cache_ptr, delegate.loaded_cache_.get());
195 delegate.loaded_cache_ = NULL; 195 delegate.loaded_cache_ = NULL;
196 196
197 // Conduct the group load test. 197 // Conduct the group load test.
198 EXPECT_NE(manifest_url, delegate.loaded_manifest_url_); 198 EXPECT_NE(manifest_url, delegate.loaded_manifest_url_);
199 EXPECT_FALSE(delegate.loaded_group_.get()); 199 EXPECT_FALSE(delegate.loaded_group_.get());
200 storage->LoadOrCreateGroup(manifest_url, &delegate); 200 storage->LoadOrCreateGroup(manifest_url, &delegate);
201 EXPECT_NE(manifest_url, delegate.loaded_manifest_url_); 201 EXPECT_NE(manifest_url, delegate.loaded_manifest_url_);
202 EXPECT_FALSE(delegate.loaded_group_.get()); 202 EXPECT_FALSE(delegate.loaded_group_.get());
203 MessageLoop::current()->RunAllPending(); // Do async task execution. 203 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
204 EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_); 204 EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_);
205 EXPECT_EQ(group_ptr, delegate.loaded_group_.get()); 205 EXPECT_EQ(group_ptr, delegate.loaded_group_.get());
206 } 206 }
207 207
208 TEST_F(MockAppCacheStorageTest, StoreNewGroup) { 208 TEST_F(MockAppCacheStorageTest, StoreNewGroup) {
209 // Store a group and its newest cache. Should complete asyncly. 209 // Store a group and its newest cache. Should complete asyncly.
210 MockAppCacheService service; 210 MockAppCacheService service;
211 MockAppCacheStorage* storage = 211 MockAppCacheStorage* storage =
212 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 212 reinterpret_cast<MockAppCacheStorage*>(service.storage());
213 213
214 // Setup some preconditions. Create a group and newest cache that 214 // Setup some preconditions. Create a group and newest cache that
215 // appears to be "unstored". 215 // appears to be "unstored".
216 GURL manifest_url("http://blah/"); 216 GURL manifest_url("http://blah/");
217 scoped_refptr<AppCacheGroup> group( 217 scoped_refptr<AppCacheGroup> group(
218 new AppCacheGroup(&service, manifest_url, 111)); 218 new AppCacheGroup(&service, manifest_url, 111));
219 int64 cache_id = storage->NewCacheId(); 219 int64 cache_id = storage->NewCacheId();
220 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id)); 220 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id));
221 // Hold a ref to the cache simulate the UpdateJob holding that ref, 221 // Hold a ref to the cache simulate the UpdateJob holding that ref,
222 // and hold a ref to the group to simulate the CacheHost holding that ref. 222 // and hold a ref to the group to simulate the CacheHost holding that ref.
223 223
224 // Conduct the store test. 224 // Conduct the store test.
225 MockStorageDelegate delegate; 225 MockStorageDelegate delegate;
226 EXPECT_TRUE(storage->stored_caches_.empty()); 226 EXPECT_TRUE(storage->stored_caches_.empty());
227 EXPECT_TRUE(storage->stored_groups_.empty()); 227 EXPECT_TRUE(storage->stored_groups_.empty());
228 storage->StoreGroupAndNewestCache(group, cache, &delegate); 228 storage->StoreGroupAndNewestCache(group, cache, &delegate);
229 EXPECT_FALSE(delegate.stored_group_success_); 229 EXPECT_FALSE(delegate.stored_group_success_);
230 EXPECT_TRUE(storage->stored_caches_.empty()); 230 EXPECT_TRUE(storage->stored_caches_.empty());
231 EXPECT_TRUE(storage->stored_groups_.empty()); 231 EXPECT_TRUE(storage->stored_groups_.empty());
232 MessageLoop::current()->RunAllPending(); // Do async task execution. 232 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
233 EXPECT_TRUE(delegate.stored_group_success_); 233 EXPECT_TRUE(delegate.stored_group_success_);
234 EXPECT_FALSE(storage->stored_caches_.empty()); 234 EXPECT_FALSE(storage->stored_caches_.empty());
235 EXPECT_FALSE(storage->stored_groups_.empty()); 235 EXPECT_FALSE(storage->stored_groups_.empty());
236 EXPECT_EQ(cache, group->newest_complete_cache()); 236 EXPECT_EQ(cache, group->newest_complete_cache());
237 EXPECT_TRUE(cache->is_complete()); 237 EXPECT_TRUE(cache->is_complete());
238 } 238 }
239 239
240 TEST_F(MockAppCacheStorageTest, StoreExistingGroup) { 240 TEST_F(MockAppCacheStorageTest, StoreExistingGroup) {
241 // Store a group and its newest cache. Should complete asyncly. 241 // Store a group and its newest cache. Should complete asyncly.
242 MockAppCacheService service; 242 MockAppCacheService service;
(...skipping 20 matching lines...) Expand all
263 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 263 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
264 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 264 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
265 EXPECT_TRUE(storage->IsCacheStored(old_cache)); 265 EXPECT_TRUE(storage->IsCacheStored(old_cache));
266 EXPECT_FALSE(storage->IsCacheStored(new_cache)); 266 EXPECT_FALSE(storage->IsCacheStored(new_cache));
267 storage->StoreGroupAndNewestCache(group, new_cache, &delegate); 267 storage->StoreGroupAndNewestCache(group, new_cache, &delegate);
268 EXPECT_FALSE(delegate.stored_group_success_); 268 EXPECT_FALSE(delegate.stored_group_success_);
269 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 269 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
270 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 270 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
271 EXPECT_TRUE(storage->IsCacheStored(old_cache)); 271 EXPECT_TRUE(storage->IsCacheStored(old_cache));
272 EXPECT_FALSE(storage->IsCacheStored(new_cache)); 272 EXPECT_FALSE(storage->IsCacheStored(new_cache));
273 MessageLoop::current()->RunAllPending(); // Do async task execution. 273 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
274 EXPECT_TRUE(delegate.stored_group_success_); 274 EXPECT_TRUE(delegate.stored_group_success_);
275 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 275 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
276 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 276 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
277 EXPECT_FALSE(storage->IsCacheStored(old_cache)); 277 EXPECT_FALSE(storage->IsCacheStored(old_cache));
278 EXPECT_TRUE(storage->IsCacheStored(new_cache)); 278 EXPECT_TRUE(storage->IsCacheStored(new_cache));
279 EXPECT_EQ(new_cache.get(), group->newest_complete_cache()); 279 EXPECT_EQ(new_cache.get(), group->newest_complete_cache());
280 EXPECT_TRUE(new_cache->is_complete()); 280 EXPECT_TRUE(new_cache->is_complete());
281 } 281 }
282 282
283 TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) { 283 TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) {
(...skipping 22 matching lines...) Expand all
306 306
307 // Conduct the test. 307 // Conduct the test.
308 MockStorageDelegate delegate; 308 MockStorageDelegate delegate;
309 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 309 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
310 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 310 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
311 EXPECT_TRUE(storage->IsCacheStored(cache)); 311 EXPECT_TRUE(storage->IsCacheStored(cache));
312 storage->StoreGroupAndNewestCache(group, cache, &delegate); 312 storage->StoreGroupAndNewestCache(group, cache, &delegate);
313 EXPECT_FALSE(delegate.stored_group_success_); 313 EXPECT_FALSE(delegate.stored_group_success_);
314 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 314 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
315 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 315 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
316 MessageLoop::current()->RunAllPending(); // Do async task execution. 316 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
317 EXPECT_TRUE(delegate.stored_group_success_); 317 EXPECT_TRUE(delegate.stored_group_success_);
318 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 318 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
319 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 319 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
320 EXPECT_TRUE(storage->IsCacheStored(cache)); 320 EXPECT_TRUE(storage->IsCacheStored(cache));
321 EXPECT_EQ(cache, group->newest_complete_cache()); 321 EXPECT_EQ(cache, group->newest_complete_cache());
322 EXPECT_TRUE(cache->GetEntry(entry_url)); 322 EXPECT_TRUE(cache->GetEntry(entry_url));
323 } 323 }
324 324
325 TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) { 325 TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) {
326 // Make a group obsolete, should complete asyncly. 326 // Make a group obsolete, should complete asyncly.
(...skipping 20 matching lines...) Expand all
347 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 347 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
348 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 348 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
349 EXPECT_FALSE(cache->HasOneRef()); 349 EXPECT_FALSE(cache->HasOneRef());
350 EXPECT_FALSE(group->HasOneRef()); 350 EXPECT_FALSE(group->HasOneRef());
351 storage->MakeGroupObsolete(group, &delegate); 351 storage->MakeGroupObsolete(group, &delegate);
352 EXPECT_FALSE(group->is_obsolete()); 352 EXPECT_FALSE(group->is_obsolete());
353 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 353 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
354 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 354 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
355 EXPECT_FALSE(cache->HasOneRef()); 355 EXPECT_FALSE(cache->HasOneRef());
356 EXPECT_FALSE(group->HasOneRef()); 356 EXPECT_FALSE(group->HasOneRef());
357 MessageLoop::current()->RunAllPending(); // Do async task execution. 357 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
358 EXPECT_TRUE(delegate.obsoleted_success_); 358 EXPECT_TRUE(delegate.obsoleted_success_);
359 EXPECT_EQ(group.get(), delegate.obsoleted_group_.get()); 359 EXPECT_EQ(group.get(), delegate.obsoleted_group_.get());
360 EXPECT_TRUE(group->is_obsolete()); 360 EXPECT_TRUE(group->is_obsolete());
361 EXPECT_TRUE(storage->stored_caches_.empty()); 361 EXPECT_TRUE(storage->stored_caches_.empty());
362 EXPECT_TRUE(storage->stored_groups_.empty()); 362 EXPECT_TRUE(storage->stored_groups_.empty());
363 EXPECT_TRUE(cache->HasOneRef()); 363 EXPECT_TRUE(cache->HasOneRef());
364 EXPECT_FALSE(group->HasOneRef()); 364 EXPECT_FALSE(group->HasOneRef());
365 delegate.obsoleted_group_ = NULL; 365 delegate.obsoleted_group_ = NULL;
366 cache = NULL; 366 cache = NULL;
367 EXPECT_TRUE(group->HasOneRef()); 367 EXPECT_TRUE(group->HasOneRef());
(...skipping 24 matching lines...) Expand all
392 MockAppCacheService service; 392 MockAppCacheService service;
393 MockAppCacheStorage* storage = 393 MockAppCacheStorage* storage =
394 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 394 reinterpret_cast<MockAppCacheStorage*>(service.storage());
395 395
396 // Conduct the test. 396 // Conduct the test.
397 MockStorageDelegate delegate; 397 MockStorageDelegate delegate;
398 GURL url("http://blah/some_url"); 398 GURL url("http://blah/some_url");
399 EXPECT_NE(url, delegate.found_url_); 399 EXPECT_NE(url, delegate.found_url_);
400 storage->FindResponseForMainRequest(url, GURL(), &delegate); 400 storage->FindResponseForMainRequest(url, GURL(), &delegate);
401 EXPECT_NE(url, delegate.found_url_); 401 EXPECT_NE(url, delegate.found_url_);
402 MessageLoop::current()->RunAllPending(); // Do async task execution. 402 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
403 EXPECT_EQ(url, delegate.found_url_); 403 EXPECT_EQ(url, delegate.found_url_);
404 EXPECT_TRUE(delegate.found_manifest_url_.is_empty()); 404 EXPECT_TRUE(delegate.found_manifest_url_.is_empty());
405 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_); 405 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_);
406 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id()); 406 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id());
407 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id()); 407 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id());
408 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); 408 EXPECT_TRUE(delegate.found_fallback_url_.is_empty());
409 EXPECT_EQ(0, delegate.found_entry_.types()); 409 EXPECT_EQ(0, delegate.found_entry_.types());
410 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); 410 EXPECT_EQ(0, delegate.found_fallback_entry_.types());
411 } 411 }
412 412
(...skipping 16 matching lines...) Expand all
429 new AppCacheGroup(&service, kManifestUrl, 111)); 429 new AppCacheGroup(&service, kManifestUrl, 111));
430 group->AddCache(cache); 430 group->AddCache(cache);
431 storage->AddStoredGroup(group); 431 storage->AddStoredGroup(group);
432 storage->AddStoredCache(cache); 432 storage->AddStoredCache(cache);
433 433
434 // Conduct the test. 434 // Conduct the test.
435 MockStorageDelegate delegate; 435 MockStorageDelegate delegate;
436 EXPECT_NE(kEntryUrl, delegate.found_url_); 436 EXPECT_NE(kEntryUrl, delegate.found_url_);
437 storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate); 437 storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate);
438 EXPECT_NE(kEntryUrl, delegate.found_url_); 438 EXPECT_NE(kEntryUrl, delegate.found_url_);
439 MessageLoop::current()->RunAllPending(); // Do async task execution. 439 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
440 EXPECT_EQ(kEntryUrl, delegate.found_url_); 440 EXPECT_EQ(kEntryUrl, delegate.found_url_);
441 EXPECT_EQ(kManifestUrl, delegate.found_manifest_url_); 441 EXPECT_EQ(kManifestUrl, delegate.found_manifest_url_);
442 EXPECT_EQ(kCacheId, delegate.found_cache_id_); 442 EXPECT_EQ(kCacheId, delegate.found_cache_id_);
443 EXPECT_EQ(kResponseId, delegate.found_entry_.response_id()); 443 EXPECT_EQ(kResponseId, delegate.found_entry_.response_id());
444 EXPECT_TRUE(delegate.found_entry_.IsExplicit()); 444 EXPECT_TRUE(delegate.found_entry_.IsExplicit());
445 EXPECT_FALSE(delegate.found_fallback_entry_.has_response_id()); 445 EXPECT_FALSE(delegate.found_fallback_entry_.has_response_id());
446 } 446 }
447 447
448 TEST_F(MockAppCacheStorageTest, BasicFindMainFallbackResponse) { 448 TEST_F(MockAppCacheStorageTest, BasicFindMainFallbackResponse) {
449 // Should complete asyncly. 449 // Should complete asyncly.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 // The test url is in both fallback namespace urls, but should match 487 // The test url is in both fallback namespace urls, but should match
488 // the longer of the two. 488 // the longer of the two.
489 const GURL kTestUrl("http://blah/fallback_namespace/longer/test"); 489 const GURL kTestUrl("http://blah/fallback_namespace/longer/test");
490 490
491 // Conduct the test. 491 // Conduct the test.
492 MockStorageDelegate delegate; 492 MockStorageDelegate delegate;
493 EXPECT_NE(kTestUrl, delegate.found_url_); 493 EXPECT_NE(kTestUrl, delegate.found_url_);
494 storage->FindResponseForMainRequest(kTestUrl, GURL(), &delegate); 494 storage->FindResponseForMainRequest(kTestUrl, GURL(), &delegate);
495 EXPECT_NE(kTestUrl, delegate.found_url_); 495 EXPECT_NE(kTestUrl, delegate.found_url_);
496 MessageLoop::current()->RunAllPending(); // Do async task execution. 496 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
497 EXPECT_EQ(kTestUrl, delegate.found_url_); 497 EXPECT_EQ(kTestUrl, delegate.found_url_);
498 EXPECT_EQ(kManifestUrl, delegate.found_manifest_url_); 498 EXPECT_EQ(kManifestUrl, delegate.found_manifest_url_);
499 EXPECT_EQ(kCacheId, delegate.found_cache_id_); 499 EXPECT_EQ(kCacheId, delegate.found_cache_id_);
500 EXPECT_FALSE(delegate.found_entry_.has_response_id()); 500 EXPECT_FALSE(delegate.found_entry_.has_response_id());
501 EXPECT_EQ(kResponseId2, delegate.found_fallback_entry_.response_id()); 501 EXPECT_EQ(kResponseId2, delegate.found_fallback_entry_.response_id());
502 EXPECT_EQ(kFallbackEntryUrl2, delegate.found_fallback_url_); 502 EXPECT_EQ(kFallbackEntryUrl2, delegate.found_fallback_url_);
503 EXPECT_TRUE(delegate.found_fallback_entry_.IsFallback()); 503 EXPECT_TRUE(delegate.found_fallback_entry_.IsFallback());
504 } 504 }
505 505
506 TEST_F(MockAppCacheStorageTest, FindMainResponseWithMultipleCandidates) { 506 TEST_F(MockAppCacheStorageTest, FindMainResponseWithMultipleCandidates) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 group->AddCache(cache); 543 group->AddCache(cache);
544 storage->AddStoredGroup(group); 544 storage->AddStoredGroup(group);
545 storage->AddStoredCache(cache); 545 storage->AddStoredCache(cache);
546 546
547 // Conduct the test, we should find the response from the second cache 547 // Conduct the test, we should find the response from the second cache
548 // since it's "in use". 548 // since it's "in use".
549 MockStorageDelegate delegate; 549 MockStorageDelegate delegate;
550 EXPECT_NE(kEntryUrl, delegate.found_url_); 550 EXPECT_NE(kEntryUrl, delegate.found_url_);
551 storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate); 551 storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate);
552 EXPECT_NE(kEntryUrl, delegate.found_url_); 552 EXPECT_NE(kEntryUrl, delegate.found_url_);
553 MessageLoop::current()->RunAllPending(); // Do async task execution. 553 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
554 EXPECT_EQ(kEntryUrl, delegate.found_url_); 554 EXPECT_EQ(kEntryUrl, delegate.found_url_);
555 EXPECT_EQ(kManifestUrl2, delegate.found_manifest_url_); 555 EXPECT_EQ(kManifestUrl2, delegate.found_manifest_url_);
556 EXPECT_EQ(kCacheId2, delegate.found_cache_id_); 556 EXPECT_EQ(kCacheId2, delegate.found_cache_id_);
557 EXPECT_EQ(kResponseId2, delegate.found_entry_.response_id()); 557 EXPECT_EQ(kResponseId2, delegate.found_entry_.response_id());
558 EXPECT_TRUE(delegate.found_entry_.IsExplicit()); 558 EXPECT_TRUE(delegate.found_entry_.IsExplicit());
559 EXPECT_FALSE(delegate.found_fallback_entry_.has_response_id()); 559 EXPECT_FALSE(delegate.found_fallback_entry_.has_response_id());
560 } 560 }
561 561
562 TEST_F(MockAppCacheStorageTest, FindMainResponseExclusions) { 562 TEST_F(MockAppCacheStorageTest, FindMainResponseExclusions) {
563 // Should complete asyncly. 563 // Should complete asyncly.
(...skipping 25 matching lines...) Expand all
589 group->AddCache(cache); 589 group->AddCache(cache);
590 storage->AddStoredGroup(group); 590 storage->AddStoredGroup(group);
591 storage->AddStoredCache(cache); 591 storage->AddStoredCache(cache);
592 592
593 MockStorageDelegate delegate; 593 MockStorageDelegate delegate;
594 594
595 // We should not find anything for the foreign entry. 595 // We should not find anything for the foreign entry.
596 EXPECT_NE(kEntryUrl, delegate.found_url_); 596 EXPECT_NE(kEntryUrl, delegate.found_url_);
597 storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate); 597 storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate);
598 EXPECT_NE(kEntryUrl, delegate.found_url_); 598 EXPECT_NE(kEntryUrl, delegate.found_url_);
599 MessageLoop::current()->RunAllPending(); // Do async task execution. 599 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
600 EXPECT_EQ(kEntryUrl, delegate.found_url_); 600 EXPECT_EQ(kEntryUrl, delegate.found_url_);
601 EXPECT_TRUE(delegate.found_manifest_url_.is_empty()); 601 EXPECT_TRUE(delegate.found_manifest_url_.is_empty());
602 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_); 602 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_);
603 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id()); 603 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id());
604 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id()); 604 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id());
605 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); 605 EXPECT_TRUE(delegate.found_fallback_url_.is_empty());
606 EXPECT_EQ(0, delegate.found_entry_.types()); 606 EXPECT_EQ(0, delegate.found_entry_.types());
607 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); 607 EXPECT_EQ(0, delegate.found_fallback_entry_.types());
608 608
609 // We should not find anything for the online namespace. 609 // We should not find anything for the online namespace.
610 EXPECT_NE(kOnlineNamespaceUrl, delegate.found_url_); 610 EXPECT_NE(kOnlineNamespaceUrl, delegate.found_url_);
611 storage->FindResponseForMainRequest(kOnlineNamespaceUrl, GURL(), &delegate); 611 storage->FindResponseForMainRequest(kOnlineNamespaceUrl, GURL(), &delegate);
612 EXPECT_NE(kOnlineNamespaceUrl, delegate.found_url_); 612 EXPECT_NE(kOnlineNamespaceUrl, delegate.found_url_);
613 MessageLoop::current()->RunAllPending(); // Do async task execution. 613 MessageLoop::current()->RunUntilIdle(); // Do async task execution.
614 EXPECT_EQ(kOnlineNamespaceUrl, delegate.found_url_); 614 EXPECT_EQ(kOnlineNamespaceUrl, delegate.found_url_);
615 EXPECT_TRUE(delegate.found_manifest_url_.is_empty()); 615 EXPECT_TRUE(delegate.found_manifest_url_.is_empty());
616 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_); 616 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_);
617 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id()); 617 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id());
618 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id()); 618 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id());
619 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); 619 EXPECT_TRUE(delegate.found_fallback_url_.is_empty());
620 EXPECT_EQ(0, delegate.found_entry_.types()); 620 EXPECT_EQ(0, delegate.found_entry_.types());
621 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); 621 EXPECT_EQ(0, delegate.found_fallback_entry_.types());
622 } 622 }
623 623
624 } // namespace appcache 624 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_service_unittest.cc ('k') | webkit/blob/blob_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698