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" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 return data; | 27 return data; |
28 } | 28 } |
29 | 29 |
30 // Creates a TemplateURL with default values except for the prepopulate ID, | 30 // Creates a TemplateURL with default values except for the prepopulate ID, |
31 // keyword and TemplateURLID. Only use this in tests if your tests do not | 31 // keyword and TemplateURLID. Only use this in tests if your tests do not |
32 // care about other fields. | 32 // care about other fields. |
33 std::unique_ptr<TemplateURL> CreatePrepopulateTemplateURL( | 33 std::unique_ptr<TemplateURL> CreatePrepopulateTemplateURL( |
34 int prepopulate_id, | 34 int prepopulate_id, |
35 const std::string& keyword, | 35 const std::string& keyword, |
36 TemplateURLID id) { | 36 TemplateURLID id) { |
37 return base::WrapUnique(new TemplateURL( | 37 return base::MakeUnique<TemplateURL>( |
38 *CreatePrepopulateTemplateURLData(prepopulate_id, keyword, id))); | 38 *CreatePrepopulateTemplateURLData(prepopulate_id, keyword, id)); |
39 } | 39 } |
40 | 40 |
41 }; // namespace | 41 }; // namespace |
42 | 42 |
43 TEST(TemplateURLServiceUtilTest, RemoveDuplicatePrepopulateIDs) { | 43 TEST(TemplateURLServiceUtilTest, RemoveDuplicatePrepopulateIDs) { |
44 ScopedVector<TemplateURLData> prepopulated_turls; | 44 ScopedVector<TemplateURLData> prepopulated_turls; |
45 TemplateURLService::TemplateURLVector local_turls; | 45 TemplateURLService::TemplateURLVector local_turls; |
46 base::STLElementDeleter<TemplateURLService::TemplateURLVector> | 46 base::STLElementDeleter<TemplateURLService::TemplateURLVector> |
47 local_turls_deleter(&local_turls); | 47 local_turls_deleter(&local_turls); |
48 | 48 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Verify that the expected local TURLs survived the process. | 97 // Verify that the expected local TURLs survived the process. |
98 EXPECT_EQ(local_turls.size(), | 98 EXPECT_EQ(local_turls.size(), |
99 prepopulated_turls.size() + num_non_prepopulated_urls); | 99 prepopulated_turls.size() + num_non_prepopulated_urls); |
100 for (TemplateURLService::TemplateURLVector::const_iterator itr = | 100 for (TemplateURLService::TemplateURLVector::const_iterator itr = |
101 local_turls.begin(); itr != local_turls.end(); ++itr) { | 101 local_turls.begin(); itr != local_turls.end(); ++itr) { |
102 EXPECT_TRUE(base::StartsWith((*itr)->keyword(), | 102 EXPECT_TRUE(base::StartsWith((*itr)->keyword(), |
103 base::ASCIIToUTF16("winner"), | 103 base::ASCIIToUTF16("winner"), |
104 base::CompareCase::SENSITIVE)); | 104 base::CompareCase::SENSITIVE)); |
105 } | 105 } |
106 } | 106 } |
OLD | NEW |