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/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 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_TRUE(loaded_url != NULL); | 1469 ASSERT_TRUE(loaded_url != NULL); |
1470 ASSERT_FALSE(loaded_url->sync_guid().empty()); | 1470 ASSERT_FALSE(loaded_url->sync_guid().empty()); |
1471 } | 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")); | |
1501 ASSERT_TRUE(loaded_url != NULL); | |
SteveT
2012/06/27 01:11:14
nit: I find it a bit odd that in the other file, y
Peter Kasting
2012/06/27 03:35:40
I think this partly comes from different people wr
| |
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_TRUE(loaded_url != NULL); | |
1510 EXPECT_EQ(4U, loaded_url->input_encodings().size()); | |
1511 } | |
OLD | NEW |