| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 new CannedBrowsingDataAppCacheHelper(&profile)); | 49 new CannedBrowsingDataAppCacheHelper(&profile)); |
| 50 helper->AddAppCache(manifest1); | 50 helper->AddAppCache(manifest1); |
| 51 helper->AddAppCache(manifest2); | 51 helper->AddAppCache(manifest2); |
| 52 helper->AddAppCache(manifest3); | 52 helper->AddAppCache(manifest3); |
| 53 | 53 |
| 54 TestCompletionCallback callback; | 54 TestCompletionCallback callback; |
| 55 helper->StartFetching(base::Bind(&TestCompletionCallback::callback, | 55 helper->StartFetching(base::Bind(&TestCompletionCallback::callback, |
| 56 base::Unretained(&callback))); | 56 base::Unretained(&callback))); |
| 57 ASSERT_TRUE(callback.have_result()); | 57 ASSERT_TRUE(callback.have_result()); |
| 58 | 58 |
| 59 std::map<GURL, appcache::AppCacheInfoVector>& collection = | 59 std::map<GURL, content::AppCacheInfoVector>& collection = |
| 60 helper->info_collection()->infos_by_origin; | 60 helper->info_collection()->infos_by_origin; |
| 61 | 61 |
| 62 ASSERT_EQ(2u, collection.size()); | 62 ASSERT_EQ(2u, collection.size()); |
| 63 EXPECT_TRUE(ContainsKey(collection, manifest1.GetOrigin())); | 63 EXPECT_TRUE(ContainsKey(collection, manifest1.GetOrigin())); |
| 64 ASSERT_EQ(1u, collection[manifest1.GetOrigin()].size()); | 64 ASSERT_EQ(1u, collection[manifest1.GetOrigin()].size()); |
| 65 EXPECT_EQ(manifest1, collection[manifest1.GetOrigin()].at(0).manifest_url); | 65 EXPECT_EQ(manifest1, collection[manifest1.GetOrigin()].at(0).manifest_url); |
| 66 | 66 |
| 67 EXPECT_TRUE(ContainsKey(collection, manifest2.GetOrigin())); | 67 EXPECT_TRUE(ContainsKey(collection, manifest2.GetOrigin())); |
| 68 EXPECT_EQ(2u, collection[manifest2.GetOrigin()].size()); | 68 EXPECT_EQ(2u, collection[manifest2.GetOrigin()].size()); |
| 69 std::set<GURL> manifest_results; | 69 std::set<GURL> manifest_results; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 81 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( | 81 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( |
| 82 new CannedBrowsingDataAppCacheHelper(&profile)); | 82 new CannedBrowsingDataAppCacheHelper(&profile)); |
| 83 helper->AddAppCache(manifest); | 83 helper->AddAppCache(manifest); |
| 84 helper->AddAppCache(manifest); | 84 helper->AddAppCache(manifest); |
| 85 | 85 |
| 86 TestCompletionCallback callback; | 86 TestCompletionCallback callback; |
| 87 helper->StartFetching(base::Bind(&TestCompletionCallback::callback, | 87 helper->StartFetching(base::Bind(&TestCompletionCallback::callback, |
| 88 base::Unretained(&callback))); | 88 base::Unretained(&callback))); |
| 89 ASSERT_TRUE(callback.have_result()); | 89 ASSERT_TRUE(callback.have_result()); |
| 90 | 90 |
| 91 std::map<GURL, appcache::AppCacheInfoVector>& collection = | 91 std::map<GURL, content::AppCacheInfoVector>& collection = |
| 92 helper->info_collection()->infos_by_origin; | 92 helper->info_collection()->infos_by_origin; |
| 93 | 93 |
| 94 ASSERT_EQ(1u, collection.size()); | 94 ASSERT_EQ(1u, collection.size()); |
| 95 EXPECT_TRUE(ContainsKey(collection, manifest.GetOrigin())); | 95 EXPECT_TRUE(ContainsKey(collection, manifest.GetOrigin())); |
| 96 ASSERT_EQ(1u, collection[manifest.GetOrigin()].size()); | 96 ASSERT_EQ(1u, collection[manifest.GetOrigin()].size()); |
| 97 EXPECT_EQ(manifest, collection[manifest.GetOrigin()].at(0).manifest_url); | 97 EXPECT_EQ(manifest, collection[manifest.GetOrigin()].at(0).manifest_url); |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_F(CannedBrowsingDataAppCacheHelperTest, Empty) { | 100 TEST_F(CannedBrowsingDataAppCacheHelperTest, Empty) { |
| 101 TestingProfile profile; | 101 TestingProfile profile; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( | 143 scoped_refptr<CannedBrowsingDataAppCacheHelper> helper( |
| 144 new CannedBrowsingDataAppCacheHelper(&profile)); | 144 new CannedBrowsingDataAppCacheHelper(&profile)); |
| 145 | 145 |
| 146 ASSERT_TRUE(helper->empty()); | 146 ASSERT_TRUE(helper->empty()); |
| 147 helper->AddAppCache(manifest1); | 147 helper->AddAppCache(manifest1); |
| 148 ASSERT_TRUE(helper->empty()); | 148 ASSERT_TRUE(helper->empty()); |
| 149 helper->AddAppCache(manifest2); | 149 helper->AddAppCache(manifest2); |
| 150 ASSERT_TRUE(helper->empty()); | 150 ASSERT_TRUE(helper->empty()); |
| 151 } | 151 } |
| OLD | NEW |