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

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

Issue 11552020: Add search_terms_replacement_key field to TemplateURL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed logic to check search_terms_replacement_key in template_url.cc. This is for a next CL. Created 8 years 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/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
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"); 262 keyword.alternate_urls.push_back("a_url1");
263 keyword.alternate_urls.push_back("a_url2"); 263 keyword.alternate_urls.push_back("a_url2");
264 keyword.search_terms_replacement_key = "espv";
264 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 265 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
265 266
266 keyword.SetKeyword(ASCIIToUTF16("url")); 267 keyword.SetKeyword(ASCIIToUTF16("url"));
267 keyword.instant_url = "http://instant2/"; 268 keyword.instant_url = "http://instant2/";
268 keyword.originating_url = GURL("http://originating.url/"); 269 keyword.originating_url = GURL("http://originating.url/");
269 keyword.input_encodings.push_back("Shift_JIS"); 270 keyword.input_encodings.push_back("Shift_JIS");
270 keyword.id = 2; 271 keyword.id = 2;
271 keyword.prepopulate_id = 5; 272 keyword.prepopulate_id = 5;
272 keyword.sync_guid = "FEDC-BA09-8765-4321"; 273 keyword.sync_guid = "FEDC-BA09-8765-4321";
273 keyword.alternate_urls.clear(); 274 keyword.alternate_urls.clear();
275 keyword.search_terms_replacement_key = "";
274 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 276 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
275 277
276 const char kTestContents[] = "1short_namekeywordhttp://favicon.url/" 278 const char kTestContents[] = "1short_namekeywordhttp://favicon.url/"
277 "http://url/1001url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]" 279 "http://url/1001url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]espv"
278 "2short_nameurlhttp://favicon.url/http://url/1http://originating.url/00" 280 "2short_nameurlhttp://favicon.url/http://url/1http://originating.url/00"
279 "Shift_JIS1url250http://instant2/0FEDC-BA09-8765-4321[]"; 281 "Shift_JIS1url250http://instant2/0FEDC-BA09-8765-4321[]";
280 282
281 std::string contents; 283 std::string contents;
282 EXPECT_TRUE(keyword_table->GetTableContents("keywords", 284 EXPECT_TRUE(keyword_table->GetTableContents("keywords",
283 WebDatabase::kCurrentVersionNumber, &contents)); 285 WebDatabase::kCurrentVersionNumber, &contents));
284 EXPECT_EQ(kTestContents, contents); 286 EXPECT_EQ(kTestContents, contents);
285 287
286 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup", 288 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup",
287 WebDatabase::kCurrentVersionNumber, &contents)); 289 WebDatabase::kCurrentVersionNumber, &contents));
(...skipping 12 matching lines...) Expand all
300 keyword.suggestions_url = "url2"; 302 keyword.suggestions_url = "url2";
301 keyword.favicon_url = GURL("http://favicon.url/"); 303 keyword.favicon_url = GURL("http://favicon.url/");
302 keyword.show_in_default_list = true; 304 keyword.show_in_default_list = true;
303 keyword.safe_for_autoreplace = true; 305 keyword.safe_for_autoreplace = true;
304 keyword.id = 2; 306 keyword.id = 2;
305 keyword.date_created = base::Time::UnixEpoch(); 307 keyword.date_created = base::Time::UnixEpoch();
306 keyword.last_modified = base::Time::UnixEpoch(); 308 keyword.last_modified = base::Time::UnixEpoch();
307 keyword.sync_guid = "1234-5678-90AB-CDEF"; 309 keyword.sync_guid = "1234-5678-90AB-CDEF";
308 keyword.alternate_urls.push_back("a_url1"); 310 keyword.alternate_urls.push_back("a_url1");
309 keyword.alternate_urls.push_back("a_url2"); 311 keyword.alternate_urls.push_back("a_url2");
312 keyword.search_terms_replacement_key = "espv";
310 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 313 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
311 314
312 keyword.SetKeyword(ASCIIToUTF16("url")); 315 keyword.SetKeyword(ASCIIToUTF16("url"));
313 keyword.instant_url = "http://instant2/"; 316 keyword.instant_url = "http://instant2/";
314 keyword.originating_url = GURL("http://originating.url/"); 317 keyword.originating_url = GURL("http://originating.url/");
315 keyword.input_encodings.push_back("Shift_JIS"); 318 keyword.input_encodings.push_back("Shift_JIS");
316 keyword.id = 1; 319 keyword.id = 1;
317 keyword.prepopulate_id = 5; 320 keyword.prepopulate_id = 5;
318 keyword.sync_guid = "FEDC-BA09-8765-4321"; 321 keyword.sync_guid = "FEDC-BA09-8765-4321";
319 keyword.alternate_urls.clear(); 322 keyword.alternate_urls.clear();
323 keyword.search_terms_replacement_key = "";
320 EXPECT_TRUE(keyword_table->AddKeyword(keyword)); 324 EXPECT_TRUE(keyword_table->AddKeyword(keyword));
321 325
322 const char kTestContents[] = "1short_nameurlhttp://favicon.url/http://url/1" 326 const char kTestContents[] = "1short_nameurlhttp://favicon.url/http://url/1"
323 "http://originating.url/00Shift_JIS1url250http://instant2/0" 327 "http://originating.url/00Shift_JIS1url250http://instant2/0"
324 "FEDC-BA09-8765-4321[]" 328 "FEDC-BA09-8765-4321[]"
325 "2short_namekeywordhttp://favicon.url/http://url/1001" 329 "2short_namekeywordhttp://favicon.url/http://url/1001"
326 "url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]"; 330 "url20001234-5678-90AB-CDEF[\"a_url1\",\"a_url2\"]espv";
327 331
328 std::string contents; 332 std::string contents;
329 EXPECT_TRUE(keyword_table->GetTableContents("keywords", 333 EXPECT_TRUE(keyword_table->GetTableContents("keywords",
330 WebDatabase::kCurrentVersionNumber, &contents)); 334 WebDatabase::kCurrentVersionNumber, &contents));
331 EXPECT_EQ(kTestContents, contents); 335 EXPECT_EQ(kTestContents, contents);
332 336
333 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup", 337 EXPECT_TRUE(keyword_table->GetTableContents("keywords_backup",
334 WebDatabase::kCurrentVersionNumber, &contents)); 338 WebDatabase::kCurrentVersionNumber, &contents));
335 EXPECT_EQ(kTestContents, contents); 339 EXPECT_EQ(kTestContents, contents);
336 } 340 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 s.BindString16(0, string16()); 437 s.BindString16(0, string16());
434 s.BindInt64(1, 2000); 438 s.BindInt64(1, 2000);
435 EXPECT_TRUE(s.Run()); 439 EXPECT_TRUE(s.Run());
436 EXPECT_TRUE(keyword_table->UpdateBackupSignature( 440 EXPECT_TRUE(keyword_table->UpdateBackupSignature(
437 WebDatabase::kCurrentVersionNumber)); 441 WebDatabase::kCurrentVersionNumber));
438 442
439 // GetKeywords() should erase the entry with the empty URL field. 443 // GetKeywords() should erase the entry with the empty URL field.
440 EXPECT_TRUE(keyword_table->GetKeywords(&keywords)); 444 EXPECT_TRUE(keyword_table->GetKeywords(&keywords));
441 EXPECT_EQ(1U, keywords.size()); 445 EXPECT_EQ(1U, keywords.size());
442 } 446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698