| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/memory/scoped_vector.h" | |
| 9 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 11 #include "components/search_engines/search_terms_data.h" | 10 #include "components/search_engines/search_terms_data.h" |
| 12 #include "components/search_engines/template_url.h" | 11 #include "components/search_engines/template_url.h" |
| 13 #include "components/search_engines/template_url_service.h" | 12 #include "components/search_engines/template_url_service.h" |
| 14 #include "components/search_engines/util.h" | 13 #include "components/search_engines/util.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 int prepopulate_id, | 33 int prepopulate_id, |
| 35 const std::string& keyword, | 34 const std::string& keyword, |
| 36 TemplateURLID id) { | 35 TemplateURLID id) { |
| 37 return base::MakeUnique<TemplateURL>( | 36 return base::MakeUnique<TemplateURL>( |
| 38 *CreatePrepopulateTemplateURLData(prepopulate_id, keyword, id)); | 37 *CreatePrepopulateTemplateURLData(prepopulate_id, keyword, id)); |
| 39 } | 38 } |
| 40 | 39 |
| 41 }; // namespace | 40 }; // namespace |
| 42 | 41 |
| 43 TEST(TemplateURLServiceUtilTest, RemoveDuplicatePrepopulateIDs) { | 42 TEST(TemplateURLServiceUtilTest, RemoveDuplicatePrepopulateIDs) { |
| 44 ScopedVector<TemplateURLData> prepopulated_turls; | 43 std::vector<std::unique_ptr<TemplateURLData>> prepopulated_turls; |
| 45 TemplateURLService::OwnedTemplateURLVector local_turls; | 44 TemplateURLService::OwnedTemplateURLVector local_turls; |
| 46 | 45 |
| 47 prepopulated_turls.push_back( | 46 prepopulated_turls.push_back( |
| 48 CreatePrepopulateTemplateURLData(1, "winner4", 1)); | 47 CreatePrepopulateTemplateURLData(1, "winner4", 1)); |
| 49 prepopulated_turls.push_back(CreatePrepopulateTemplateURLData(2, "xxx", 2)); | 48 prepopulated_turls.push_back(CreatePrepopulateTemplateURLData(2, "xxx", 2)); |
| 50 prepopulated_turls.push_back(CreatePrepopulateTemplateURLData(3, "yyy", 3)); | 49 prepopulated_turls.push_back(CreatePrepopulateTemplateURLData(3, "yyy", 3)); |
| 51 | 50 |
| 52 // Create a sets of different TURLs grouped by prepopulate ID. Each group | 51 // Create a sets of different TURLs grouped by prepopulate ID. Each group |
| 53 // will test a different heuristic of RemoveDuplicatePrepopulateIDs. | 52 // will test a different heuristic of RemoveDuplicatePrepopulateIDs. |
| 54 // Ignored set - These should be left alone as they do not have valid | 53 // Ignored set - These should be left alone as they do not have valid |
| (...skipping 27 matching lines...) Expand all Loading... |
| 82 &local_turls, SearchTermsData(), nullptr); | 81 &local_turls, SearchTermsData(), nullptr); |
| 83 | 82 |
| 84 // Verify that the expected local TURLs survived the process. | 83 // Verify that the expected local TURLs survived the process. |
| 85 EXPECT_EQ(local_turls.size(), | 84 EXPECT_EQ(local_turls.size(), |
| 86 prepopulated_turls.size() + num_non_prepopulated_urls); | 85 prepopulated_turls.size() + num_non_prepopulated_urls); |
| 87 for (const auto& turl : local_turls) { | 86 for (const auto& turl : local_turls) { |
| 88 EXPECT_TRUE(base::StartsWith(turl->keyword(), base::ASCIIToUTF16("winner"), | 87 EXPECT_TRUE(base::StartsWith(turl->keyword(), base::ASCIIToUTF16("winner"), |
| 89 base::CompareCase::SENSITIVE)); | 88 base::CompareCase::SENSITIVE)); |
| 90 } | 89 } |
| 91 } | 90 } |
| OLD | NEW |