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/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/search_engines/search_terms_data.h" | 10 #include "components/search_engines/search_terms_data.h" |
11 #include "components/search_engines/template_url.h" | 11 #include "components/search_engines/template_url.h" |
12 #include "components/search_engines/template_url_service.h" | 12 #include "components/search_engines/template_url_service.h" |
13 #include "components/search_engines/util.h" | 13 #include "components/search_engines/util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 scoped_ptr<TemplateURLData> CreatePrepopulateTemplateURLData( | 18 scoped_ptr<TemplateURLData> CreatePrepopulateTemplateURLData( |
19 int prepopulate_id, | 19 int prepopulate_id, |
20 const std::string& keyword, | 20 const std::string& keyword, |
21 TemplateURLID id) { | 21 TemplateURLID id) { |
22 scoped_ptr<TemplateURLData> data(new TemplateURLData); | 22 scoped_ptr<TemplateURLData> data(new TemplateURLData); |
23 data->prepopulate_id = prepopulate_id; | 23 data->prepopulate_id = prepopulate_id; |
24 data->SetKeyword(base::ASCIIToUTF16(keyword)); | 24 data->SetKeyword(base::ASCIIToUTF16(keyword)); |
25 data->id = id; | 25 data->id = id; |
26 return data.Pass(); | 26 return data; |
27 } | 27 } |
28 | 28 |
29 // Creates a TemplateURL with default values except for the prepopulate ID, | 29 // Creates a TemplateURL with default values except for the prepopulate ID, |
30 // keyword and TemplateURLID. Only use this in tests if your tests do not | 30 // keyword and TemplateURLID. Only use this in tests if your tests do not |
31 // care about other fields. | 31 // care about other fields. |
32 scoped_ptr<TemplateURL> CreatePrepopulateTemplateURL(int prepopulate_id, | 32 scoped_ptr<TemplateURL> CreatePrepopulateTemplateURL(int prepopulate_id, |
33 const std::string& keyword, | 33 const std::string& keyword, |
34 TemplateURLID id) { | 34 TemplateURLID id) { |
35 return make_scoped_ptr(new TemplateURL( | 35 return make_scoped_ptr(new TemplateURL( |
36 *CreatePrepopulateTemplateURLData(prepopulate_id, keyword, id))); | 36 *CreatePrepopulateTemplateURLData(prepopulate_id, keyword, id))); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Verify that the expected local TURLs survived the process. | 95 // Verify that the expected local TURLs survived the process. |
96 EXPECT_EQ(local_turls.size(), | 96 EXPECT_EQ(local_turls.size(), |
97 prepopulated_turls.size() + num_non_prepopulated_urls); | 97 prepopulated_turls.size() + num_non_prepopulated_urls); |
98 for (TemplateURLService::TemplateURLVector::const_iterator itr = | 98 for (TemplateURLService::TemplateURLVector::const_iterator itr = |
99 local_turls.begin(); itr != local_turls.end(); ++itr) { | 99 local_turls.begin(); itr != local_turls.end(); ++itr) { |
100 EXPECT_TRUE(base::StartsWith((*itr)->keyword(), | 100 EXPECT_TRUE(base::StartsWith((*itr)->keyword(), |
101 base::ASCIIToUTF16("winner"), | 101 base::ASCIIToUTF16("winner"), |
102 base::CompareCase::SENSITIVE)); | 102 base::CompareCase::SENSITIVE)); |
103 } | 103 } |
104 } | 104 } |
OLD | NEW |