| 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 25 matching lines...) Expand all Loading... |
| 36 TemplateURLID id) { | 36 TemplateURLID id) { |
| 37 return base::WrapUnique(new TemplateURL( | 37 return base::WrapUnique(new 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 STLElementDeleter<TemplateURLService::TemplateURLVector> local_turls_deleter( | 46 base::STLElementDeleter<TemplateURLService::TemplateURLVector> |
| 47 &local_turls); | 47 local_turls_deleter(&local_turls); |
| 48 | 48 |
| 49 prepopulated_turls.push_back( | 49 prepopulated_turls.push_back( |
| 50 CreatePrepopulateTemplateURLData(1, "winner4", 1).release()); | 50 CreatePrepopulateTemplateURLData(1, "winner4", 1).release()); |
| 51 prepopulated_turls.push_back( | 51 prepopulated_turls.push_back( |
| 52 CreatePrepopulateTemplateURLData(2, "xxx", 2).release()); | 52 CreatePrepopulateTemplateURLData(2, "xxx", 2).release()); |
| 53 prepopulated_turls.push_back( | 53 prepopulated_turls.push_back( |
| 54 CreatePrepopulateTemplateURLData(3, "yyy", 3).release()); | 54 CreatePrepopulateTemplateURLData(3, "yyy", 3).release()); |
| 55 | 55 |
| 56 // Create a sets of different TURLs grouped by prepopulate ID. Each group | 56 // Create a sets of different TURLs grouped by prepopulate ID. Each group |
| 57 // will test a different heuristic of RemoveDuplicatePrepopulateIDs. | 57 // will test a different heuristic of RemoveDuplicatePrepopulateIDs. |
| (...skipping 39 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 |