Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: chrome/browser/search_engines/template_url_model_unittest.cc

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/search_engines/template_url_model.cc ('k') | chrome/browser/spellcheck_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 #include "base/callback.h" 5 #include "base/callback.h"
6 #include "base/scoped_vector.h" 6 #include "base/scoped_vector.h"
7 #include "base/string_split.h" 7 #include "base/string_split.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/thread.h" 10 #include "base/thread.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 bool safe_for_autoreplace, 126 bool safe_for_autoreplace,
127 Time created_date) { 127 Time created_date) {
128 TemplateURL* template_url = new TemplateURL(); 128 TemplateURL* template_url = new TemplateURL();
129 template_url->SetURL(url, 0, 0); 129 template_url->SetURL(url, 0, 0);
130 template_url->SetSuggestionsURL(suggest_url, 0, 0); 130 template_url->SetSuggestionsURL(suggest_url, 0, 0);
131 template_url->SetFavIconURL(GURL(fav_icon_url)); 131 template_url->SetFavIconURL(GURL(fav_icon_url));
132 template_url->set_keyword(keyword); 132 template_url->set_keyword(keyword);
133 template_url->set_autogenerate_keyword(autogenerate_keyword); 133 template_url->set_autogenerate_keyword(autogenerate_keyword);
134 template_url->set_short_name(short_name); 134 template_url->set_short_name(short_name);
135 std::vector<std::string> encodings_vector; 135 std::vector<std::string> encodings_vector;
136 SplitString(encodings, ';', &encodings_vector); 136 base::SplitString(encodings, ';', &encodings_vector);
137 template_url->set_input_encodings(encodings_vector); 137 template_url->set_input_encodings(encodings_vector);
138 template_url->set_date_created(created_date); 138 template_url->set_date_created(created_date);
139 template_url->set_safe_for_autoreplace(safe_for_autoreplace); 139 template_url->set_safe_for_autoreplace(safe_for_autoreplace);
140 model()->Add(template_url); 140 model()->Add(template_url);
141 EXPECT_NE(0, template_url->id()); 141 EXPECT_NE(0, template_url->id());
142 return template_url; 142 return template_url;
143 } 143 }
144 144
145 // Simulate firing by the prefs service specifying that the managed 145 // Simulate firing by the prefs service specifying that the managed
146 // preferences have changed. 146 // preferences have changed.
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 { "http://blah/foo?x=y&x=z&y=z", true, "x;y", ";z" }, 767 { "http://blah/foo?x=y&x=z&y=z", true, "x;y", ";z" },
768 }; 768 };
769 769
770 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { 770 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
771 TemplateURLModel::QueryTerms terms; 771 TemplateURLModel::QueryTerms terms;
772 ASSERT_EQ(data[i].result, 772 ASSERT_EQ(data[i].result,
773 TemplateURLModel::BuildQueryTerms(GURL(data[i].url), &terms)); 773 TemplateURLModel::BuildQueryTerms(GURL(data[i].url), &terms));
774 if (data[i].result) { 774 if (data[i].result) {
775 std::vector<std::string> keys; 775 std::vector<std::string> keys;
776 std::vector<std::string> values; 776 std::vector<std::string> values;
777 SplitString(data[i].keys, ';', &keys); 777 base::SplitString(data[i].keys, ';', &keys);
778 SplitString(data[i].values, ';', &values); 778 base::SplitString(data[i].values, ';', &values);
779 ASSERT_TRUE(keys.size() == values.size()); 779 ASSERT_TRUE(keys.size() == values.size());
780 ASSERT_EQ(keys.size(), terms.size()); 780 ASSERT_EQ(keys.size(), terms.size());
781 for (size_t j = 0; j < keys.size(); ++j) { 781 for (size_t j = 0; j < keys.size(); ++j) {
782 TemplateURLModel::QueryTerms::iterator term_iterator = 782 TemplateURLModel::QueryTerms::iterator term_iterator =
783 terms.find(keys[j]); 783 terms.find(keys[j]);
784 ASSERT_TRUE(term_iterator != terms.end()); 784 ASSERT_TRUE(term_iterator != terms.end());
785 ASSERT_EQ(values[j], term_iterator->second); 785 ASSERT_EQ(values[j], term_iterator->second);
786 } 786 }
787 } 787 }
788 } 788 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 VerifyObserverCount(1); 1122 VerifyObserverCount(1);
1123 EXPECT_TRUE(model()->is_default_search_managed()); 1123 EXPECT_TRUE(model()->is_default_search_managed());
1124 EXPECT_EQ(2 + initial_count, model()->GetTemplateURLs().size()); 1124 EXPECT_EQ(2 + initial_count, model()->GetTemplateURLs().size());
1125 1125
1126 // Verify that the default manager we are getting is the managed one. 1126 // Verify that the default manager we are getting is the managed one.
1127 scoped_ptr<TemplateURL> expected_managed_default1(new TemplateURL()); 1127 scoped_ptr<TemplateURL> expected_managed_default1(new TemplateURL());
1128 expected_managed_default1->SetURL(kSearchURL, 0, 0); 1128 expected_managed_default1->SetURL(kSearchURL, 0, 0);
1129 expected_managed_default1->SetFavIconURL(GURL(kIconURL)); 1129 expected_managed_default1->SetFavIconURL(GURL(kIconURL));
1130 expected_managed_default1->set_short_name(L"test1"); 1130 expected_managed_default1->set_short_name(L"test1");
1131 std::vector<std::string> encodings_vector; 1131 std::vector<std::string> encodings_vector;
1132 SplitString(kEncodings, ';', &encodings_vector); 1132 base::SplitString(kEncodings, ';', &encodings_vector);
1133 expected_managed_default1->set_input_encodings(encodings_vector); 1133 expected_managed_default1->set_input_encodings(encodings_vector);
1134 expected_managed_default1->set_show_in_default_list(true); 1134 expected_managed_default1->set_show_in_default_list(true);
1135 const TemplateURL* actual_managed_default = 1135 const TemplateURL* actual_managed_default =
1136 model()->GetDefaultSearchProvider(); 1136 model()->GetDefaultSearchProvider();
1137 ExpectSimilar(actual_managed_default, expected_managed_default1.get()); 1137 ExpectSimilar(actual_managed_default, expected_managed_default1.get());
1138 EXPECT_EQ(actual_managed_default->show_in_default_list(), true); 1138 EXPECT_EQ(actual_managed_default->show_in_default_list(), true);
1139 1139
1140 // Update the managed preference and check that the model has changed. 1140 // Update the managed preference and check that the model has changed.
1141 const char kNewName[] = "test2"; 1141 const char kNewName[] = "test2";
1142 const char kNewSearchURL[] = "http://other.com/search?t={searchTerms}"; 1142 const char kNewSearchURL[] = "http://other.com/search?t={searchTerms}";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 kEncodings, ""); 1182 kEncodings, "");
1183 VerifyObserverCount(1); 1183 VerifyObserverCount(1);
1184 EXPECT_TRUE(model()->is_default_search_managed()); 1184 EXPECT_TRUE(model()->is_default_search_managed());
1185 EXPECT_EQ(2 + initial_count, model()->GetTemplateURLs().size()); 1185 EXPECT_EQ(2 + initial_count, model()->GetTemplateURLs().size());
1186 1186
1187 // Verify that the default manager we are getting is the managed one. 1187 // Verify that the default manager we are getting is the managed one.
1188 actual_managed_default = model()->GetDefaultSearchProvider(); 1188 actual_managed_default = model()->GetDefaultSearchProvider();
1189 ExpectSimilar(actual_managed_default, expected_managed_default1.get()); 1189 ExpectSimilar(actual_managed_default, expected_managed_default1.get());
1190 EXPECT_EQ(actual_managed_default->show_in_default_list(), true); 1190 EXPECT_EQ(actual_managed_default->show_in_default_list(), true);
1191 } 1191 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_model.cc ('k') | chrome/browser/spellcheck_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698