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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
10 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" | 10 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 const GURL origin1("http://host1:1/"); | 97 const GURL origin1("http://host1:1/"); |
98 const GURL origin2("http://host2:1/"); | 98 const GURL origin2("http://host2:1/"); |
99 const char origin_str1[] = "http_host1_1"; | 99 const char origin_str1[] = "http_host1_1"; |
100 const char origin_str2[] = "http_host2_1"; | 100 const char origin_str2[] = "http_host2_1"; |
101 const char db1[] = "db1"; | 101 const char db1[] = "db1"; |
102 const char db2[] = "db2"; | 102 const char db2[] = "db2"; |
103 const char db3[] = "db3"; | 103 const char db3[] = "db3"; |
104 | 104 |
105 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( | 105 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( |
106 new CannedBrowsingDataDatabaseHelper(browser()->profile())); | 106 new CannedBrowsingDataDatabaseHelper(browser()->profile())); |
107 helper->AddDatabase(origin1, db1, ""); | 107 helper->AddDatabase(origin1, db1, std::string()); |
108 helper->AddDatabase(origin1, db2, ""); | 108 helper->AddDatabase(origin1, db2, std::string()); |
109 helper->AddDatabase(origin2, db3, ""); | 109 helper->AddDatabase(origin2, db3, std::string()); |
110 | 110 |
111 TestCompletionCallback callback; | 111 TestCompletionCallback callback; |
112 helper->StartFetching( | 112 helper->StartFetching( |
113 base::Bind(&TestCompletionCallback::callback, | 113 base::Bind(&TestCompletionCallback::callback, |
114 base::Unretained(&callback))); | 114 base::Unretained(&callback))); |
115 | 115 |
116 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = | 116 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = |
117 callback.result(); | 117 callback.result(); |
118 | 118 |
119 ASSERT_EQ(3u, result.size()); | 119 ASSERT_EQ(3u, result.size()); |
120 std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator info = | 120 std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator info = |
121 result.begin(); | 121 result.begin(); |
122 EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); | 122 EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); |
123 EXPECT_STREQ(db1, info->database_name.c_str()); | 123 EXPECT_STREQ(db1, info->database_name.c_str()); |
124 info++; | 124 info++; |
125 EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); | 125 EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); |
126 EXPECT_STREQ(db2, info->database_name.c_str()); | 126 EXPECT_STREQ(db2, info->database_name.c_str()); |
127 info++; | 127 info++; |
128 EXPECT_STREQ(origin_str2, info->origin_identifier.c_str()); | 128 EXPECT_STREQ(origin_str2, info->origin_identifier.c_str()); |
129 EXPECT_STREQ(db3, info->database_name.c_str()); | 129 EXPECT_STREQ(db3, info->database_name.c_str()); |
130 } | 130 } |
131 | 131 |
132 IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedUnique) { | 132 IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedUnique) { |
133 const GURL origin("http://host1:1/"); | 133 const GURL origin("http://host1:1/"); |
134 const char origin_str[] = "http_host1_1"; | 134 const char origin_str[] = "http_host1_1"; |
135 const char db[] = "db1"; | 135 const char db[] = "db1"; |
136 | 136 |
137 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( | 137 scoped_refptr<CannedBrowsingDataDatabaseHelper> helper( |
138 new CannedBrowsingDataDatabaseHelper(browser()->profile())); | 138 new CannedBrowsingDataDatabaseHelper(browser()->profile())); |
139 helper->AddDatabase(origin, db, ""); | 139 helper->AddDatabase(origin, db, std::string()); |
140 helper->AddDatabase(origin, db, ""); | 140 helper->AddDatabase(origin, db, std::string()); |
141 | 141 |
142 TestCompletionCallback callback; | 142 TestCompletionCallback callback; |
143 helper->StartFetching( | 143 helper->StartFetching( |
144 base::Bind(&TestCompletionCallback::callback, | 144 base::Bind(&TestCompletionCallback::callback, |
145 base::Unretained(&callback))); | 145 base::Unretained(&callback))); |
146 | 146 |
147 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = | 147 std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = |
148 callback.result(); | 148 callback.result(); |
149 | 149 |
150 ASSERT_EQ(1u, result.size()); | 150 ASSERT_EQ(1u, result.size()); |
151 EXPECT_STREQ(origin_str, result.begin()->origin_identifier.c_str()); | 151 EXPECT_STREQ(origin_str, result.begin()->origin_identifier.c_str()); |
152 EXPECT_STREQ(db, result.begin()->database_name.c_str()); | 152 EXPECT_STREQ(db, result.begin()->database_name.c_str()); |
153 } | 153 } |
154 } // namespace | 154 } // namespace |
OLD | NEW |