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

Side by Side Diff: chrome/browser/search_engines/template_url_service_unittest.cc

Issue 10676012: De-dupe input encodings in TemplateURLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 VerifyObserverCount(1); 1459 VerifyObserverCount(1);
1460 test_util_.BlockTillServiceProcessesRequests(); 1460 test_util_.BlockTillServiceProcessesRequests();
1461 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1461 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1462 1462
1463 // Reload the model to verify it was actually saved to the database and 1463 // Reload the model to verify it was actually saved to the database and
1464 // assigned a new GUID when brought back. 1464 // assigned a new GUID when brought back.
1465 test_util_.ResetModel(true); 1465 test_util_.ResetModel(true);
1466 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); 1466 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1467 const TemplateURL* loaded_url = 1467 const TemplateURL* loaded_url =
1468 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); 1468 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1469 ASSERT_FALSE(loaded_url == NULL);
1470 ASSERT_FALSE(loaded_url->sync_guid().empty());
1471 }
1472
1473 // Test that if we load a TemplateURL with duplicate input encodings, the load
1474 // process de-dupes them.
1475 TEST_F(TemplateURLServiceTest, DuplicateInputEncodings) {
1476 // Add a new TemplateURL.
1477 test_util_.VerifyLoad();
1478 const size_t initial_count = model()->GetTemplateURLs().size();
1479
1480 TemplateURLData data;
1481 data.short_name = ASCIIToUTF16("google");
1482 data.SetKeyword(ASCIIToUTF16("keyword"));
1483 data.SetURL("http://www.google.com/foo/bar");
1484 std::vector<std::string> encodings;
1485 data.input_encodings.push_back("UTF-8");
1486 data.input_encodings.push_back("UTF-8");
1487 data.input_encodings.push_back("UTF-16");
1488 data.input_encodings.push_back("UTF-8");
1489 data.input_encodings.push_back("Big5");
1490 data.input_encodings.push_back("UTF-16");
1491 data.input_encodings.push_back("Big5");
1492 data.input_encodings.push_back("Windows-1252");
1493 TemplateURL* t_url = new TemplateURL(test_util_.profile(), data);
1494 model()->Add(t_url);
1495
1496 VerifyObserverCount(1);
1497 test_util_.BlockTillServiceProcessesRequests();
1498 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1499 const TemplateURL* loaded_url =
1500 model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1469 ASSERT_TRUE(loaded_url != NULL); 1501 ASSERT_TRUE(loaded_url != NULL);
1470 ASSERT_FALSE(loaded_url->sync_guid().empty()); 1502 EXPECT_EQ(8U, loaded_url->input_encodings().size());
1503
1504 // Reload the model to verify it was actually saved to the database and the
1505 // duplicate encodings were removed.
1506 test_util_.ResetModel(true);
1507 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size());
1508 loaded_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword"));
1509 ASSERT_FALSE(loaded_url == NULL);
1510 EXPECT_EQ(4U, loaded_url->input_encodings().size());
1471 } 1511 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service_sync_unittest.cc ('k') | chrome/browser/search_engines/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698