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

Side by Side Diff: chrome/browser/webdata/keyword_table_unittest.cc

Issue 10908226: Introduces a search term extraction mechanism working for arbitrary search providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed need for espv=1 for search term extraction. Created 8 years, 2 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) 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 keyword.SetKeyword(ASCIIToUTF16("keyword")); 252 keyword.SetKeyword(ASCIIToUTF16("keyword"));
253 keyword.SetURL("http://url/"); 253 keyword.SetURL("http://url/");
254 keyword.suggestions_url = "url2"; 254 keyword.suggestions_url = "url2";
255 keyword.favicon_url = GURL("http://favicon.url/"); 255 keyword.favicon_url = GURL("http://favicon.url/");
256 keyword.show_in_default_list = true; 256 keyword.show_in_default_list = true;
257 keyword.safe_for_autoreplace = true; 257 keyword.safe_for_autoreplace = true;
258 keyword.id = 1; 258 keyword.id = 1;
259 keyword.date_created = base::Time::UnixEpoch(); 259 keyword.date_created = base::Time::UnixEpoch();
260 keyword.last_modified = base::Time::UnixEpoch(); 260 keyword.last_modified = base::Time::UnixEpoch();
261 keyword.sync_guid = "1234-5678-90AB-CDEF"; 261 keyword.sync_guid = "1234-5678-90AB-CDEF";
262 keyword.alternate_urls.push_back("a_url1");
263 keyword.alternate_urls.push_back("a_url2");
262 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 264 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
263 265
264 keyword.SetKeyword(ASCIIToUTF16("url")); 266 keyword.SetKeyword(ASCIIToUTF16("url"));
265 keyword.instant_url = "http://instant2/"; 267 keyword.instant_url = "http://instant2/";
266 keyword.originating_url = GURL("http://originating.url/"); 268 keyword.originating_url = GURL("http://originating.url/");
267 keyword.input_encodings.push_back("Shift_JIS"); 269 keyword.input_encodings.push_back("Shift_JIS");
268 keyword.id = 2; 270 keyword.id = 2;
269 keyword.prepopulate_id = 5; 271 keyword.prepopulate_id = 5;
270 keyword.sync_guid = "FEDC-BA09-8765-4321"; 272 keyword.sync_guid = "FEDC-BA09-8765-4321";
273 keyword.alternate_urls.clear();
271 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 274 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
272 275
273 const char kTestContents[] = "1short_namekeywordhttp://favicon.url/" 276 const char kTestContents[] = "1short_namekeywordhttp://favicon.url/"
274 "http://url/1001url20001234-5678-90AB-CDEF2short_nameurl" 277 "http://url/1001url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]"
275 "http://favicon.url/http://url/1http://originating.url/00Shift_JIS1url250" 278 "2short_nameurlhttp://favicon.url/http://url/1http://originating.url/00"
276 "http://instant2/0FEDC-BA09-8765-4321"; 279 "Shift_JIS1url250http://instant2/0FEDC-BA09-8765-4321[]";
277 280
278 std::string contents; 281 std::string contents;
279 EXPECT_TRUE(keyword_table->GetTableContents("keywords", 282 EXPECT_TRUE(keyword_table->GetTableContents("keywords",
280 WebDatabase::kCurrentVersionNumber, &contents)); 283 WebDatabase::kCurrentVersionNumber, &contents));
281 EXPECT_EQ(kTestContents, contents); 284 EXPECT_EQ(kTestContents, contents);
282 285
283 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup", 286 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup",
284 WebDatabase::kCurrentVersionNumber, &contents)); 287 WebDatabase::kCurrentVersionNumber, &contents));
285 EXPECT_EQ(kTestContents, contents); 288 EXPECT_EQ(kTestContents, contents);
286 } 289 }
287 290
288 TEST_F(KeywordTableTest, GetTableContentsOrdering) { 291 TEST_F(KeywordTableTest, GetTableContentsOrdering) {
289 WebDatabase db; 292 WebDatabase db;
290 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); 293 ASSERT_EQ(sql::INIT_OK, db.Init(file_));
291 KeywordTable* keyword_table = db.GetKeywordTable(); 294 KeywordTable* keyword_table = db.GetKeywordTable();
292 295
293 TemplateURLData keyword; 296 TemplateURLData keyword;
294 keyword.short_name = ASCIIToUTF16("short_name"); 297 keyword.short_name = ASCIIToUTF16("short_name");
295 keyword.SetKeyword(ASCIIToUTF16("keyword")); 298 keyword.SetKeyword(ASCIIToUTF16("keyword"));
296 keyword.SetURL("http://url/"); 299 keyword.SetURL("http://url/");
297 keyword.suggestions_url = "url2"; 300 keyword.suggestions_url = "url2";
298 keyword.favicon_url = GURL("http://favicon.url/"); 301 keyword.favicon_url = GURL("http://favicon.url/");
299 keyword.show_in_default_list = true; 302 keyword.show_in_default_list = true;
300 keyword.safe_for_autoreplace = true; 303 keyword.safe_for_autoreplace = true;
301 keyword.id = 2; 304 keyword.id = 2;
302 keyword.date_created = base::Time::UnixEpoch(); 305 keyword.date_created = base::Time::UnixEpoch();
303 keyword.last_modified = base::Time::UnixEpoch(); 306 keyword.last_modified = base::Time::UnixEpoch();
304 keyword.sync_guid = "1234-5678-90AB-CDEF"; 307 keyword.sync_guid = "1234-5678-90AB-CDEF";
308 keyword.alternate_urls.push_back("a_url1");
309 keyword.alternate_urls.push_back("a_url2");
305 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 310 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
306 311
307 keyword.SetKeyword(ASCIIToUTF16("url")); 312 keyword.SetKeyword(ASCIIToUTF16("url"));
308 keyword.instant_url = "http://instant2/"; 313 keyword.instant_url = "http://instant2/";
309 keyword.originating_url = GURL("http://originating.url/"); 314 keyword.originating_url = GURL("http://originating.url/");
310 keyword.input_encodings.push_back("Shift_JIS"); 315 keyword.input_encodings.push_back("Shift_JIS");
311 keyword.id = 1; 316 keyword.id = 1;
312 keyword.prepopulate_id = 5; 317 keyword.prepopulate_id = 5;
313 keyword.sync_guid = "FEDC-BA09-8765-4321"; 318 keyword.sync_guid = "FEDC-BA09-8765-4321";
319 keyword.alternate_urls.clear();
314 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 320 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
315 321
316 const char kTestContents[] = "1short_nameurlhttp://favicon.url/http://url/1" 322 const char kTestContents[] = "1short_nameurlhttp://favicon.url/http://url/1"
317 "http://originating.url/00Shift_JIS1url250http://instant2/0" 323 "http://originating.url/00Shift_JIS1url250http://instant2/0"
318 "FEDC-BA09-8765-43212short_namekeywordhttp://favicon.url/http://url/1001" 324 "FEDC-BA09-8765-4321[]"
319 "url20001234-5678-90AB-CDEF"; 325 "2short_namekeywordhttp://favicon.url/http://url/1001"
326 "url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]";
320 327
321 std::string contents; 328 std::string contents;
322 EXPECT_TRUE(keyword_table->GetTableContents("keywords", 329 EXPECT_TRUE(keyword_table->GetTableContents("keywords",
323 WebDatabase::kCurrentVersionNumber, &contents)); 330 WebDatabase::kCurrentVersionNumber, &contents));
324 EXPECT_EQ(kTestContents, contents); 331 EXPECT_EQ(kTestContents, contents);
325 332
326 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup", 333 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup",
327 WebDatabase::kCurrentVersionNumber, &contents)); 334 WebDatabase::kCurrentVersionNumber, &contents));
328 EXPECT_EQ(kTestContents, contents); 335 EXPECT_EQ(kTestContents, contents);
329 } 336 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 s.BindString16(0, string16()); 433 s.BindString16(0, string16());
427 s.BindInt64(1, 2000); 434 s.BindInt64(1, 2000);
428 EXPECT_TRUE(s.Run()); 435 EXPECT_TRUE(s.Run());
429 EXPECT_TRUE(keyword_table->UpdateBackupSignature( 436 EXPECT_TRUE(keyword_table->UpdateBackupSignature(
430 WebDatabase::kCurrentVersionNumber)); 437 WebDatabase::kCurrentVersionNumber));
431 438
432 // GetKeywords() should erase the entry with the empty URL field. 439 // GetKeywords() should erase the entry with the empty URL field.
433 EXPECT_TRUE(keyword_table->GetKeywords(&keywords)); 440 EXPECT_TRUE(keyword_table->GetKeywords(&keywords));
434 EXPECT_EQ(1U, keywords.size()); 441 EXPECT_EQ(1U, keywords.size());
435 } 442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698