OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <list> | 5 #include <list> |
6 #include <map> | 6 #include <map> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 static void SetID(int64 new_id, TemplateURL* url) { | 150 static void SetID(int64 new_id, TemplateURL* url) { |
151 url->set_id(new_id); | 151 url->set_id(new_id); |
152 } | 152 } |
153 | 153 |
154 static void set_prepopulate_id(TemplateURL* url, int id) { | 154 static void set_prepopulate_id(TemplateURL* url, int id) { |
155 url->set_prepopulate_id(id); | 155 url->set_prepopulate_id(id); |
156 } | 156 } |
157 | 157 |
| 158 static void set_logo_id(TemplateURL* url, int id) { |
| 159 url->set_logo_id(id); |
| 160 } |
| 161 |
158 static AutofillEntry MakeAutofillEntry(const char* name, | 162 static AutofillEntry MakeAutofillEntry(const char* name, |
159 const char* value, | 163 const char* value, |
160 time_t timestamp0, | 164 time_t timestamp0, |
161 time_t timestamp1) { | 165 time_t timestamp1) { |
162 std::vector<base::Time> timestamps; | 166 std::vector<base::Time> timestamps; |
163 if (timestamp0 >= 0) | 167 if (timestamp0 >= 0) |
164 timestamps.push_back(Time::FromTimeT(timestamp0)); | 168 timestamps.push_back(Time::FromTimeT(timestamp0)); |
165 if (timestamp1 >= 0) | 169 if (timestamp1 >= 0) |
166 timestamps.push_back(Time::FromTimeT(timestamp1)); | 170 timestamps.push_back(Time::FromTimeT(timestamp1)); |
167 return AutofillEntry( | 171 return AutofillEntry( |
(...skipping 14 matching lines...) Expand all Loading... |
182 GURL favicon_url("http://favicon.url/"); | 186 GURL favicon_url("http://favicon.url/"); |
183 GURL originating_url("http://google.com/"); | 187 GURL originating_url("http://google.com/"); |
184 template_url.SetFavIconURL(favicon_url); | 188 template_url.SetFavIconURL(favicon_url); |
185 template_url.SetURL("http://url/", 0, 0); | 189 template_url.SetURL("http://url/", 0, 0); |
186 template_url.set_safe_for_autoreplace(true); | 190 template_url.set_safe_for_autoreplace(true); |
187 template_url.set_show_in_default_list(true); | 191 template_url.set_show_in_default_list(true); |
188 template_url.set_originating_url(originating_url); | 192 template_url.set_originating_url(originating_url); |
189 template_url.set_usage_count(32); | 193 template_url.set_usage_count(32); |
190 template_url.add_input_encoding("UTF-8"); | 194 template_url.add_input_encoding("UTF-8"); |
191 set_prepopulate_id(&template_url, 10); | 195 set_prepopulate_id(&template_url, 10); |
| 196 set_logo_id(&template_url, 1000); |
192 SetID(1, &template_url); | 197 SetID(1, &template_url); |
193 | 198 |
194 EXPECT_TRUE(db.AddKeyword(template_url)); | 199 EXPECT_TRUE(db.AddKeyword(template_url)); |
195 | 200 |
196 std::vector<TemplateURL*> template_urls; | 201 std::vector<TemplateURL*> template_urls; |
197 EXPECT_TRUE(db.GetKeywords(&template_urls)); | 202 EXPECT_TRUE(db.GetKeywords(&template_urls)); |
198 | 203 |
199 EXPECT_EQ(1U, template_urls.size()); | 204 EXPECT_EQ(1U, template_urls.size()); |
200 const TemplateURL* restored_url = template_urls.front(); | 205 const TemplateURL* restored_url = template_urls.front(); |
201 | 206 |
(...skipping 13 matching lines...) Expand all Loading... |
215 | 220 |
216 EXPECT_TRUE(originating_url == restored_url->originating_url()); | 221 EXPECT_TRUE(originating_url == restored_url->originating_url()); |
217 | 222 |
218 EXPECT_EQ(32, restored_url->usage_count()); | 223 EXPECT_EQ(32, restored_url->usage_count()); |
219 | 224 |
220 ASSERT_EQ(1U, restored_url->input_encodings().size()); | 225 ASSERT_EQ(1U, restored_url->input_encodings().size()); |
221 EXPECT_EQ("UTF-8", restored_url->input_encodings()[0]); | 226 EXPECT_EQ("UTF-8", restored_url->input_encodings()[0]); |
222 | 227 |
223 EXPECT_EQ(10, restored_url->prepopulate_id()); | 228 EXPECT_EQ(10, restored_url->prepopulate_id()); |
224 | 229 |
| 230 EXPECT_EQ(1000, restored_url->logo_id()); |
| 231 |
225 EXPECT_TRUE(db.RemoveKeyword(restored_url->id())); | 232 EXPECT_TRUE(db.RemoveKeyword(restored_url->id())); |
226 | 233 |
227 template_urls.clear(); | 234 template_urls.clear(); |
228 EXPECT_TRUE(db.GetKeywords(&template_urls)); | 235 EXPECT_TRUE(db.GetKeywords(&template_urls)); |
229 | 236 |
230 EXPECT_EQ(0U, template_urls.size()); | 237 EXPECT_EQ(0U, template_urls.size()); |
231 | 238 |
232 delete restored_url; | 239 delete restored_url; |
233 } | 240 } |
234 | 241 |
(...skipping 30 matching lines...) Expand all Loading... |
265 SetID(1, &template_url); | 272 SetID(1, &template_url); |
266 | 273 |
267 EXPECT_TRUE(db.AddKeyword(template_url)); | 274 EXPECT_TRUE(db.AddKeyword(template_url)); |
268 | 275 |
269 GURL originating_url2("http://originating.url/"); | 276 GURL originating_url2("http://originating.url/"); |
270 template_url.set_originating_url(originating_url2); | 277 template_url.set_originating_url(originating_url2); |
271 template_url.set_autogenerate_keyword(true); | 278 template_url.set_autogenerate_keyword(true); |
272 EXPECT_EQ(L"url", template_url.keyword()); | 279 EXPECT_EQ(L"url", template_url.keyword()); |
273 template_url.add_input_encoding("Shift_JIS"); | 280 template_url.add_input_encoding("Shift_JIS"); |
274 set_prepopulate_id(&template_url, 5); | 281 set_prepopulate_id(&template_url, 5); |
| 282 set_logo_id(&template_url, 2000); |
275 EXPECT_TRUE(db.UpdateKeyword(template_url)); | 283 EXPECT_TRUE(db.UpdateKeyword(template_url)); |
276 | 284 |
277 std::vector<TemplateURL*> template_urls; | 285 std::vector<TemplateURL*> template_urls; |
278 EXPECT_TRUE(db.GetKeywords(&template_urls)); | 286 EXPECT_TRUE(db.GetKeywords(&template_urls)); |
279 | 287 |
280 EXPECT_EQ(1U, template_urls.size()); | 288 EXPECT_EQ(1U, template_urls.size()); |
281 const TemplateURL* restored_url = template_urls.front(); | 289 const TemplateURL* restored_url = template_urls.front(); |
282 | 290 |
283 EXPECT_EQ(template_url.short_name(), restored_url->short_name()); | 291 EXPECT_EQ(template_url.short_name(), restored_url->short_name()); |
284 | 292 |
(...skipping 14 matching lines...) Expand all Loading... |
299 ASSERT_EQ(1U, restored_url->input_encodings().size()); | 307 ASSERT_EQ(1U, restored_url->input_encodings().size()); |
300 ASSERT_EQ("Shift_JIS", restored_url->input_encodings()[0]); | 308 ASSERT_EQ("Shift_JIS", restored_url->input_encodings()[0]); |
301 | 309 |
302 EXPECT_EQ(template_url.suggestions_url()->url(), | 310 EXPECT_EQ(template_url.suggestions_url()->url(), |
303 restored_url->suggestions_url()->url()); | 311 restored_url->suggestions_url()->url()); |
304 | 312 |
305 EXPECT_EQ(template_url.id(), restored_url->id()); | 313 EXPECT_EQ(template_url.id(), restored_url->id()); |
306 | 314 |
307 EXPECT_EQ(template_url.prepopulate_id(), restored_url->prepopulate_id()); | 315 EXPECT_EQ(template_url.prepopulate_id(), restored_url->prepopulate_id()); |
308 | 316 |
| 317 EXPECT_EQ(template_url.logo_id(), restored_url->logo_id()); |
| 318 |
309 delete restored_url; | 319 delete restored_url; |
310 } | 320 } |
311 | 321 |
312 TEST_F(WebDatabaseTest, KeywordWithNoFavicon) { | 322 TEST_F(WebDatabaseTest, KeywordWithNoFavicon) { |
313 WebDatabase db; | 323 WebDatabase db; |
314 | 324 |
315 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 325 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
316 | 326 |
317 TemplateURL template_url; | 327 TemplateURL template_url; |
318 template_url.set_short_name(L"short_name"); | 328 template_url.set_short_name(L"short_name"); |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 | 1500 |
1491 // make sure the lists of entries match | 1501 // make sure the lists of entries match |
1492 ASSERT_EQ(expected_entries.size(), entry_set.size()); | 1502 ASSERT_EQ(expected_entries.size(), entry_set.size()); |
1493 AutofillEntrySetIterator it; | 1503 AutofillEntrySetIterator it; |
1494 for (it = entry_set.begin(); it != entry_set.end(); it++) { | 1504 for (it = entry_set.begin(); it != entry_set.end(); it++) { |
1495 expected_entries.erase(*it); | 1505 expected_entries.erase(*it); |
1496 } | 1506 } |
1497 | 1507 |
1498 EXPECT_EQ(0U, expected_entries.size()); | 1508 EXPECT_EQ(0U, expected_entries.size()); |
1499 } | 1509 } |
OLD | NEW |