OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/scoped_temp_dir.h" | 4 #include "base/scoped_temp_dir.h" |
5 #include "base/scoped_vector.h" | 5 #include "base/scoped_vector.h" |
6 #include "chrome/browser/search_engines/template_url.h" | 6 #include "chrome/browser/search_engines/template_url.h" |
7 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 7 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
9 #include "chrome/test/testing_profile.h" | 9 #include "chrome/test/testing_profile.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 'T'<<8|'L', 'T'<<8|'M', 'T'<<8|'N', 'T'<<8|'O', 'T'<<8|'R', | 60 'T'<<8|'L', 'T'<<8|'M', 'T'<<8|'N', 'T'<<8|'O', 'T'<<8|'R', |
61 'T'<<8|'T', 'T'<<8|'V', 'T'<<8|'W', 'T'<<8|'Z', 'U'<<8|'A', | 61 'T'<<8|'T', 'T'<<8|'V', 'T'<<8|'W', 'T'<<8|'Z', 'U'<<8|'A', |
62 'U'<<8|'G', 'U'<<8|'M', 'U'<<8|'S', 'U'<<8|'Y', 'U'<<8|'Z', | 62 'U'<<8|'G', 'U'<<8|'M', 'U'<<8|'S', 'U'<<8|'Y', 'U'<<8|'Z', |
63 'V'<<8|'A', 'V'<<8|'C', 'V'<<8|'E', 'V'<<8|'G', 'V'<<8|'I', | 63 'V'<<8|'A', 'V'<<8|'C', 'V'<<8|'E', 'V'<<8|'G', 'V'<<8|'I', |
64 'V'<<8|'N', 'V'<<8|'U', 'W'<<8|'F', 'W'<<8|'S', 'Y'<<8|'E', | 64 'V'<<8|'N', 'V'<<8|'U', 'W'<<8|'F', 'W'<<8|'S', 'Y'<<8|'E', |
65 'Y'<<8|'T', 'Z'<<8|'A', 'Z'<<8|'M', 'Z'<<8|'W', -1 }; | 65 'Y'<<8|'T', 'Z'<<8|'A', 'Z'<<8|'M', 'Z'<<8|'W', -1 }; |
66 TestingProfile profile; | 66 TestingProfile profile; |
67 for (size_t i = 0; i < arraysize(ids); ++i) { | 67 for (size_t i = 0; i < arraysize(ids); ++i) { |
68 profile.GetPrefs()->SetInteger(prefs::kCountryIDAtInstall, ids[i]); | 68 profile.GetPrefs()->SetInteger(prefs::kCountryIDAtInstall, ids[i]); |
69 ScopedVector<TemplateURL> urls; | 69 ScopedVector<TemplateURL> urls; |
70 size_t url_count; | 70 size_t default_index; |
71 TemplateURLPrepopulateData::GetPrepopulatedEngines( | 71 TemplateURLPrepopulateData::GetPrepopulatedEngines( |
72 profile.GetPrefs(), &(urls.get()), &url_count); | 72 profile.GetPrefs(), &(urls.get()), &default_index); |
73 std::set<int> unique_ids; | 73 std::set<int> unique_ids; |
74 for (size_t turl_i = 0; turl_i < urls.size(); ++turl_i) { | 74 for (size_t turl_i = 0; turl_i < urls.size(); ++turl_i) { |
75 ASSERT_TRUE(unique_ids.find(urls[turl_i]->prepopulate_id()) == | 75 ASSERT_TRUE(unique_ids.find(urls[turl_i]->prepopulate_id()) == |
76 unique_ids.end()); | 76 unique_ids.end()); |
77 unique_ids.insert(urls[turl_i]->prepopulate_id()); | 77 unique_ids.insert(urls[turl_i]->prepopulate_id()); |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 // Verifies that default search providers from the preferences file | 82 // Verifies that default search providers from the preferences file |
(...skipping 22 matching lines...) Expand all Loading... |
105 scoped_ptr<PrefService> prefs(new PrefService(new PrefValueStore( | 105 scoped_ptr<PrefService> prefs(new PrefService(new PrefValueStore( |
106 NULL, new JsonPrefStore(preferences_file, | 106 NULL, new JsonPrefStore(preferences_file, |
107 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), | 107 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), |
108 NULL, NULL))); | 108 NULL, NULL))); |
109 | 109 |
110 TemplateURLPrepopulateData::RegisterUserPrefs(prefs.get()); | 110 TemplateURLPrepopulateData::RegisterUserPrefs(prefs.get()); |
111 | 111 |
112 int version = TemplateURLPrepopulateData::GetDataVersion(prefs.get()); | 112 int version = TemplateURLPrepopulateData::GetDataVersion(prefs.get()); |
113 EXPECT_EQ(1, version); | 113 EXPECT_EQ(1, version); |
114 | 114 |
115 std::vector<TemplateURL*> t_urls; | 115 ScopedVector<TemplateURL> t_urls; |
116 size_t default_index; | 116 size_t default_index; |
117 TemplateURLPrepopulateData::GetPrepopulatedEngines( | 117 TemplateURLPrepopulateData::GetPrepopulatedEngines( |
118 prefs.get(), &t_urls, &default_index); | 118 prefs.get(), &(t_urls.get()), &default_index); |
119 | 119 |
120 ASSERT_EQ(1u, t_urls.size()); | 120 ASSERT_EQ(1u, t_urls.size()); |
121 EXPECT_EQ(L"foo", t_urls[0]->short_name()); | 121 EXPECT_EQ(L"foo", t_urls[0]->short_name()); |
122 EXPECT_EQ(L"fook", t_urls[0]->keyword()); | 122 EXPECT_EQ(L"fook", t_urls[0]->keyword()); |
123 EXPECT_EQ("foo.com", t_urls[0]->url()->GetHost()); | 123 EXPECT_EQ("foo.com", t_urls[0]->url()->GetHost()); |
124 EXPECT_EQ("foi.com", t_urls[0]->GetFavIconURL().host()); | 124 EXPECT_EQ("foi.com", t_urls[0]->GetFavIconURL().host()); |
125 EXPECT_EQ(1u, t_urls[0]->input_encodings().size()); | 125 EXPECT_EQ(1u, t_urls[0]->input_encodings().size()); |
126 EXPECT_EQ(1001, t_urls[0]->prepopulate_id()); | 126 EXPECT_EQ(1001, t_urls[0]->prepopulate_id()); |
127 } | 127 } |
OLD | NEW |