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

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

Issue 192043: AppCacheHost cache selection algorithm (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "webkit/appcache/appcache.h" 6 #include "webkit/appcache/appcache.h"
7 #include "webkit/appcache/appcache_frontend_impl.h"
7 #include "webkit/appcache/appcache_host.h" 8 #include "webkit/appcache/appcache_host.h"
8 #include "webkit/appcache/appcache_service.h" 9 #include "webkit/appcache/appcache_service.h"
9 10
10 using appcache::AppCache; 11 namespace appcache {
11 using appcache::AppCacheEntry;
12 using appcache::AppCacheHost;
13 using appcache::AppCacheService;
14
15 namespace {
16 12
17 class AppCacheTest : public testing::Test { 13 class AppCacheTest : public testing::Test {
18 }; 14 };
19 15
20 } // namespace
21
22 TEST(AppCacheTest, CleanupUnusedCache) { 16 TEST(AppCacheTest, CleanupUnusedCache) {
23 AppCacheService service; 17 AppCacheService service;
18 AppCacheFrontendImpl frontend;
24 AppCache* cache = new AppCache(&service, 111); 19 AppCache* cache = new AppCache(&service, 111);
20 cache->set_complete(true);
25 21
26 AppCacheHost host1(1, NULL); 22 AppCacheHost host1(1, &frontend, &service);
27 AppCacheHost host2(2, NULL); 23 AppCacheHost host2(2, &frontend, &service);
28 24
29 host1.set_selected_cache(cache); 25 host1.AssociateCache(cache);
30 host2.set_selected_cache(cache); 26 host2.AssociateCache(cache);
31 27
32 host1.set_selected_cache(NULL); 28 host1.AssociateCache(NULL);
33 host2.set_selected_cache(NULL); 29 host2.AssociateCache(NULL);
34 } 30 }
35 31
36 TEST(AppCacheTest, AddModifyEntry) { 32 TEST(AppCacheTest, AddModifyEntry) {
37 AppCacheService service; 33 AppCacheService service;
38 scoped_refptr<AppCache> cache = new AppCache(&service, 111); 34 scoped_refptr<AppCache> cache = new AppCache(&service, 111);
39 35
40 const GURL kUrl1("http://foo.com"); 36 const GURL kUrl1("http://foo.com");
41 AppCacheEntry entry1(AppCacheEntry::MASTER); 37 AppCacheEntry entry1(AppCacheEntry::MASTER);
42 cache->AddEntry(kUrl1, entry1); 38 cache->AddEntry(kUrl1, entry1);
43 EXPECT_EQ(entry1.types(), cache->GetEntry(kUrl1)->types()); 39 EXPECT_EQ(entry1.types(), cache->GetEntry(kUrl1)->types());
44 40
45 const GURL kUrl2("http://bar.com"); 41 const GURL kUrl2("http://bar.com");
46 AppCacheEntry entry2(AppCacheEntry::FALLBACK); 42 AppCacheEntry entry2(AppCacheEntry::FALLBACK);
47 cache->AddOrModifyEntry(kUrl2, entry2); 43 cache->AddOrModifyEntry(kUrl2, entry2);
48 EXPECT_EQ(entry2.types(), cache->GetEntry(kUrl2)->types()); 44 EXPECT_EQ(entry2.types(), cache->GetEntry(kUrl2)->types());
49 45
50 AppCacheEntry entry3(AppCacheEntry::EXPLICIT); 46 AppCacheEntry entry3(AppCacheEntry::EXPLICIT);
51 cache->AddOrModifyEntry(kUrl1, entry3); 47 cache->AddOrModifyEntry(kUrl1, entry3);
52 EXPECT_EQ((AppCacheEntry::MASTER | AppCacheEntry::EXPLICIT), 48 EXPECT_EQ((AppCacheEntry::MASTER | AppCacheEntry::EXPLICIT),
53 cache->GetEntry(kUrl1)->types()); 49 cache->GetEntry(kUrl1)->types());
54 EXPECT_EQ(entry2.types(), cache->GetEntry(kUrl2)->types()); // unchanged 50 EXPECT_EQ(entry2.types(), cache->GetEntry(kUrl2)->types()); // unchanged
55 } 51 }
52
53 } // namespace appacache
54
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_service_unittest.cc ('k') | webkit/appcache/manifest_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698