OLD | NEW |
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 "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 have_result_ = true; | 24 have_result_ = true; |
25 } | 25 } |
26 | 26 |
27 private: | 27 private: |
28 bool have_result_; | 28 bool have_result_; |
29 }; | 29 }; |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 class CannedBrowsingDataAppCacheHelperTest : public testing::Test { | 33 class CannedBrowsingDataAppCacheHelperTest : public testing::Test { |
| 34 public: |
| 35 CannedBrowsingDataAppCacheHelperTest() |
| 36 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD) {} |
| 37 |
34 content::TestBrowserThreadBundle thread_bundle_; | 38 content::TestBrowserThreadBundle thread_bundle_; |
35 }; | 39 }; |
36 | 40 |
37 TEST_F(CannedBrowsingDataAppCacheHelperTest, SetInfo) { | 41 TEST_F(CannedBrowsingDataAppCacheHelperTest, SetInfo) { |
38 TestingProfile profile; | 42 TestingProfile profile; |
39 | 43 |
40 GURL manifest1("http://example1.com/manifest.xml"); | 44 GURL manifest1("http://example1.com/manifest.xml"); |
41 GURL manifest2("http://example2.com/path1/manifest.xml"); | 45 GURL manifest2("http://example2.com/path1/manifest.xml"); |
42 GURL manifest3("http://example2.com/path2/manifest.xml"); | 46 GURL manifest3("http://example2.com/path2/manifest.xml"); |
43 | 47 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( | 105 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( |
102 new CannedBrowsingDataAppCacheHelper(&profile)); | 106 new CannedBrowsingDataAppCacheHelper(&profile)); |
103 | 107 |
104 ASSERT_TRUE(helper->empty()); | 108 ASSERT_TRUE(helper->empty()); |
105 helper->AddAppCache(manifest); | 109 helper->AddAppCache(manifest); |
106 ASSERT_FALSE(helper->empty()); | 110 ASSERT_FALSE(helper->empty()); |
107 helper->Reset(); | 111 helper->Reset(); |
108 ASSERT_TRUE(helper->empty()); | 112 ASSERT_TRUE(helper->empty()); |
109 } | 113 } |
110 | 114 |
| 115 TEST_F(CannedBrowsingDataAppCacheHelperTest, Delete) { |
| 116 TestingProfile profile; |
| 117 |
| 118 GURL manifest1("http://example.com/manifest1.xml"); |
| 119 GURL manifest2("http://foo.example.com/manifest2.xml"); |
| 120 GURL manifest3("http://bar.example.com/manifest3.xml"); |
| 121 |
| 122 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( |
| 123 new CannedBrowsingDataAppCacheHelper(&profile)); |
| 124 |
| 125 EXPECT_TRUE(helper->empty()); |
| 126 helper->AddAppCache(manifest1); |
| 127 helper->AddAppCache(manifest2); |
| 128 helper->AddAppCache(manifest3); |
| 129 EXPECT_FALSE(helper->empty()); |
| 130 EXPECT_EQ(3u, helper->GetAppCacheCount()); |
| 131 helper->DeleteAppCacheGroup(manifest2); |
| 132 EXPECT_EQ(2u, helper->GetAppCacheCount()); |
| 133 EXPECT_TRUE(helper->GetOriginAppCacheInfoMap().find(manifest2) == |
| 134 helper->GetOriginAppCacheInfoMap().end()); |
| 135 } |
| 136 |
111 TEST_F(CannedBrowsingDataAppCacheHelperTest, IgnoreExtensionsAndDevTools) { | 137 TEST_F(CannedBrowsingDataAppCacheHelperTest, IgnoreExtensionsAndDevTools) { |
112 TestingProfile profile; | 138 TestingProfile profile; |
113 | 139 |
114 GURL manifest1("chrome-extension://abcdefghijklmnopqrstuvwxyz/manifest.xml"); | 140 GURL manifest1("chrome-extension://abcdefghijklmnopqrstuvwxyz/manifest.xml"); |
115 GURL manifest2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/manifest.xml"); | 141 GURL manifest2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/manifest.xml"); |
116 | 142 |
117 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( | 143 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( |
118 new CannedBrowsingDataAppCacheHelper(&profile)); | 144 new CannedBrowsingDataAppCacheHelper(&profile)); |
119 | 145 |
120 ASSERT_TRUE(helper->empty()); | 146 ASSERT_TRUE(helper->empty()); |
121 helper->AddAppCache(manifest1); | 147 helper->AddAppCache(manifest1); |
122 ASSERT_TRUE(helper->empty()); | 148 ASSERT_TRUE(helper->empty()); |
123 helper->AddAppCache(manifest2); | 149 helper->AddAppCache(manifest2); |
124 ASSERT_TRUE(helper->empty()); | 150 ASSERT_TRUE(helper->empty()); |
125 } | 151 } |
OLD | NEW |