| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 Time last_modified); | 180 Time last_modified); |
| 181 | 181 |
| 182 // Verifies the two TemplateURLs are equal. | 182 // Verifies the two TemplateURLs are equal. |
| 183 void AssertEquals(const TemplateURL& expected, const TemplateURL& actual); | 183 void AssertEquals(const TemplateURL& expected, const TemplateURL& actual); |
| 184 | 184 |
| 185 // Create an URL that appears to have been prepopulated, but won't be in the | 185 // Create an URL that appears to have been prepopulated, but won't be in the |
| 186 // current data. The caller owns the returned TemplateURL*. | 186 // current data. The caller owns the returned TemplateURL*. |
| 187 TemplateURL* CreatePreloadedTemplateURL(bool safe_for_autoreplace, | 187 TemplateURL* CreatePreloadedTemplateURL(bool safe_for_autoreplace, |
| 188 int prepopulate_id); | 188 int prepopulate_id); |
| 189 | 189 |
| 190 // Creates a TemplateURL with the same prepopulated id as a real prepopulated | |
| 191 // item. The input number determines which prepopulated item. The caller is | |
| 192 // responsible for owning the returned TemplateURL*. | |
| 193 TemplateURL* CreateReplaceablePreloadedTemplateURL( | |
| 194 bool safe_for_autoreplace, | |
| 195 size_t index_offset_from_default, | |
| 196 base::string16* prepopulated_display_url); | |
| 197 | |
| 198 // Verifies the behavior of when a preloaded url later gets changed. | |
| 199 // Since the input is the offset from the default, when one passes in | |
| 200 // 0, it tests the default. Passing in a number > 0 will verify what | |
| 201 // happens when a preloaded url that is not the default gets updated. | |
| 202 void TestLoadUpdatingPreloadedURL(size_t index_offset_from_default); | |
| 203 | |
| 204 // Helper methods to make calling TemplateURLServiceTestUtil methods less | 190 // Helper methods to make calling TemplateURLServiceTestUtil methods less |
| 205 // visually noisy in the test code. | 191 // visually noisy in the test code. |
| 206 void VerifyObserverCount(int expected_changed_count); | 192 void VerifyObserverCount(int expected_changed_count); |
| 207 void VerifyObserverFired(); | 193 void VerifyObserverFired(); |
| 208 TemplateURLService* model() { return test_util_.model(); } | 194 TemplateURLService* model() { return test_util_.model(); } |
| 209 | 195 |
| 210 protected: | 196 protected: |
| 211 TemplateURLServiceTestUtil test_util_; | 197 TemplateURLServiceTestUtil test_util_; |
| 212 | 198 |
| 213 void TestGenerateSearchURL(SearchTermsData* search_terms_data) { | 199 void TestGenerateSearchURL(SearchTermsData* search_terms_data) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 236 EXPECT_EQ(result, generate_url_cases[i].expected) | 222 EXPECT_EQ(result, generate_url_cases[i].expected) |
| 237 << generate_url_cases[i].test_name << " failed. Expected " | 223 << generate_url_cases[i].test_name << " failed. Expected " |
| 238 << generate_url_cases[i].expected << " Actual " << result; | 224 << generate_url_cases[i].expected << " Actual " << result; |
| 239 } | 225 } |
| 240 } | 226 } |
| 241 | 227 |
| 242 | 228 |
| 243 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTest); | 229 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTest); |
| 244 }; | 230 }; |
| 245 | 231 |
| 232 class TemplateURLServiceWithoutFallbackTest : public TemplateURLServiceTest { |
| 233 public: |
| 234 TemplateURLServiceWithoutFallbackTest() : TemplateURLServiceTest() {} |
| 235 |
| 236 virtual void SetUp() OVERRIDE { |
| 237 TemplateURLService::set_fallback_search_engines_disabled(true); |
| 238 TemplateURLServiceTest::SetUp(); |
| 239 } |
| 240 |
| 241 virtual void TearDown() OVERRIDE { |
| 242 TemplateURLServiceTest::TearDown(); |
| 243 TemplateURLService::set_fallback_search_engines_disabled(false); |
| 244 } |
| 245 }; |
| 246 |
| 246 TemplateURLServiceTest::TemplateURLServiceTest() { | 247 TemplateURLServiceTest::TemplateURLServiceTest() { |
| 247 } | 248 } |
| 248 | 249 |
| 249 void TemplateURLServiceTest::SetUp() { | 250 void TemplateURLServiceTest::SetUp() { |
| 250 test_util_.SetUp(); | 251 test_util_.SetUp(); |
| 251 } | 252 } |
| 252 | 253 |
| 253 void TemplateURLServiceTest::TearDown() { | 254 void TemplateURLServiceTest::TearDown() { |
| 254 test_util_.TearDown(); | 255 test_util_.TearDown(); |
| 255 } | 256 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 data.favicon_url = GURL("http://favicon.url"); | 300 data.favicon_url = GURL("http://favicon.url"); |
| 300 data.show_in_default_list = true; | 301 data.show_in_default_list = true; |
| 301 data.safe_for_autoreplace = safe_for_autoreplace; | 302 data.safe_for_autoreplace = safe_for_autoreplace; |
| 302 data.input_encodings.push_back("UTF-8"); | 303 data.input_encodings.push_back("UTF-8"); |
| 303 data.date_created = Time::FromTimeT(100); | 304 data.date_created = Time::FromTimeT(100); |
| 304 data.last_modified = Time::FromTimeT(100); | 305 data.last_modified = Time::FromTimeT(100); |
| 305 data.prepopulate_id = prepopulate_id; | 306 data.prepopulate_id = prepopulate_id; |
| 306 return new TemplateURL(test_util_.profile(), data); | 307 return new TemplateURL(test_util_.profile(), data); |
| 307 } | 308 } |
| 308 | 309 |
| 309 TemplateURL* TemplateURLServiceTest::CreateReplaceablePreloadedTemplateURL( | |
| 310 bool safe_for_autoreplace, | |
| 311 size_t index_offset_from_default, | |
| 312 base::string16* prepopulated_display_url) { | |
| 313 size_t default_search_provider_index = 0; | |
| 314 ScopedVector<TemplateURLData> prepopulated_urls = | |
| 315 TemplateURLPrepopulateData::GetPrepopulatedEngines( | |
| 316 test_util_.profile()->GetPrefs(), &default_search_provider_index); | |
| 317 EXPECT_LT(index_offset_from_default, prepopulated_urls.size()); | |
| 318 size_t prepopulated_index = (default_search_provider_index + | |
| 319 index_offset_from_default) % prepopulated_urls.size(); | |
| 320 TemplateURL* t_url = CreatePreloadedTemplateURL(safe_for_autoreplace, | |
| 321 prepopulated_urls[prepopulated_index]->prepopulate_id); | |
| 322 *prepopulated_display_url = | |
| 323 TemplateURL(NULL, *prepopulated_urls[prepopulated_index]).url_ref(). | |
| 324 DisplayURL(); | |
| 325 return t_url; | |
| 326 } | |
| 327 | |
| 328 void TemplateURLServiceTest::TestLoadUpdatingPreloadedURL( | |
| 329 size_t index_offset_from_default) { | |
| 330 base::string16 prepopulated_url; | |
| 331 TemplateURL* t_url = CreateReplaceablePreloadedTemplateURL(false, | |
| 332 index_offset_from_default, &prepopulated_url); | |
| 333 | |
| 334 base::string16 original_url = t_url->url_ref().DisplayURL(); | |
| 335 std::string original_guid = t_url->sync_guid(); | |
| 336 EXPECT_NE(prepopulated_url, original_url); | |
| 337 | |
| 338 // Then add it to the model and save it all. | |
| 339 test_util_.ChangeModelToLoadState(); | |
| 340 model()->Add(t_url); | |
| 341 const TemplateURL* keyword_url = | |
| 342 model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")); | |
| 343 ASSERT_TRUE(keyword_url != NULL); | |
| 344 EXPECT_EQ(t_url, keyword_url); | |
| 345 EXPECT_EQ(original_url, keyword_url->url_ref().DisplayURL()); | |
| 346 base::RunLoop().RunUntilIdle(); | |
| 347 | |
| 348 // Now reload the model and verify that the merge updates the url, and | |
| 349 // preserves the sync GUID. | |
| 350 test_util_.ResetModel(true); | |
| 351 keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")); | |
| 352 ASSERT_TRUE(keyword_url != NULL); | |
| 353 EXPECT_EQ(prepopulated_url, keyword_url->url_ref().DisplayURL()); | |
| 354 EXPECT_EQ(original_guid, keyword_url->sync_guid()); | |
| 355 | |
| 356 // Wait for any saves to finish. | |
| 357 base::RunLoop().RunUntilIdle(); | |
| 358 | |
| 359 // Reload the model to verify that change was saved correctly. | |
| 360 test_util_.ResetModel(true); | |
| 361 keyword_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")); | |
| 362 ASSERT_TRUE(keyword_url != NULL); | |
| 363 EXPECT_EQ(prepopulated_url, keyword_url->url_ref().DisplayURL()); | |
| 364 EXPECT_EQ(original_guid, keyword_url->sync_guid()); | |
| 365 } | |
| 366 | |
| 367 void TemplateURLServiceTest::VerifyObserverCount(int expected_changed_count) { | 310 void TemplateURLServiceTest::VerifyObserverCount(int expected_changed_count) { |
| 368 EXPECT_EQ(expected_changed_count, test_util_.GetObserverCount()); | 311 EXPECT_EQ(expected_changed_count, test_util_.GetObserverCount()); |
| 369 test_util_.ResetObserverCount(); | 312 test_util_.ResetObserverCount(); |
| 370 } | 313 } |
| 371 | 314 |
| 372 void TemplateURLServiceTest::VerifyObserverFired() { | 315 void TemplateURLServiceTest::VerifyObserverFired() { |
| 373 EXPECT_LE(1, test_util_.GetObserverCount()); | 316 EXPECT_LE(1, test_util_.GetObserverCount()); |
| 374 test_util_.ResetObserverCount(); | 317 test_util_.ResetObserverCount(); |
| 375 } | 318 } |
| 376 | 319 |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 | 985 |
| 1043 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 986 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
| 1044 history::URLVisitedDetails details; | 987 history::URLVisitedDetails details; |
| 1045 details.row = history::URLRow(GURL(data[i].url)); | 988 details.row = history::URLRow(GURL(data[i].url)); |
| 1046 details.transition = content::PageTransitionFromInt(0); | 989 details.transition = content::PageTransitionFromInt(0); |
| 1047 model()->UpdateKeywordSearchTermsForURL(details); | 990 model()->UpdateKeywordSearchTermsForURL(details); |
| 1048 ASSERT_EQ(base::string16(), test_util_.GetAndClearSearchTerm()); | 991 ASSERT_EQ(base::string16(), test_util_.GetAndClearSearchTerm()); |
| 1049 } | 992 } |
| 1050 } | 993 } |
| 1051 | 994 |
| 1052 TEST_F(TemplateURLServiceTest, ChangeGoogleBaseValue) { | 995 TEST_F(TemplateURLServiceWithoutFallbackTest, ChangeGoogleBaseValue) { |
| 1053 // NOTE: Do not do a VerifyLoad() here as it will load the prepopulate data, | 996 // NOTE: Do not load the prepopulate data, which also has a {google:baseURL} |
| 1054 // which also has a {google:baseURL} keyword in it, which will confuse this | 997 // keyword in it and would confuse this test. |
| 1055 // test. | |
| 1056 test_util_.ChangeModelToLoadState(); | 998 test_util_.ChangeModelToLoadState(); |
| 999 |
| 1057 test_util_.SetGoogleBaseURL(GURL("http://google.com/")); | 1000 test_util_.SetGoogleBaseURL(GURL("http://google.com/")); |
| 1058 const TemplateURL* t_url = AddKeywordWithDate( | 1001 const TemplateURL* t_url = AddKeywordWithDate( |
| 1059 "name", "google.com", "{google:baseURL}?q={searchTerms}", "http://sugg1", | 1002 "name", "google.com", "{google:baseURL}?q={searchTerms}", "http://sugg1", |
| 1060 std::string(), "http://icon1", false, "UTF-8;UTF-16", Time(), Time()); | 1003 std::string(), "http://icon1", false, "UTF-8;UTF-16", Time(), Time()); |
| 1061 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.com")); | 1004 ASSERT_EQ(t_url, model()->GetTemplateURLForHost("google.com")); |
| 1062 EXPECT_EQ("google.com", t_url->url_ref().GetHost()); | 1005 EXPECT_EQ("google.com", t_url->url_ref().GetHost()); |
| 1063 EXPECT_EQ(ASCIIToUTF16("google.com"), t_url->keyword()); | 1006 EXPECT_EQ(ASCIIToUTF16("google.com"), t_url->keyword()); |
| 1064 | 1007 |
| 1065 // Change the Google base url. | 1008 // Change the Google base url. |
| 1066 test_util_.ResetObserverCount(); | 1009 test_util_.ResetObserverCount(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 base::RunLoop().RunUntilIdle(); | 1166 base::RunLoop().RunUntilIdle(); |
| 1224 | 1167 |
| 1225 // Reload the model and check that the default search provider | 1168 // Reload the model and check that the default search provider |
| 1226 // was properly saved. | 1169 // was properly saved. |
| 1227 test_util_.ResetModel(true); | 1170 test_util_.ResetModel(true); |
| 1228 default_search = model()->GetDefaultSearchProvider(); | 1171 default_search = model()->GetDefaultSearchProvider(); |
| 1229 ASSERT_TRUE(default_search != NULL); | 1172 ASSERT_TRUE(default_search != NULL); |
| 1230 AssertEquals(*cloned_url, *default_search); | 1173 AssertEquals(*cloned_url, *default_search); |
| 1231 } | 1174 } |
| 1232 | 1175 |
| 1233 TEST_F(TemplateURLServiceTest, FindNewDefaultSearchProvider) { | |
| 1234 // Ensure that if our service is initially empty, we don't initial have a | |
| 1235 // valid new DSP. | |
| 1236 EXPECT_FALSE(model()->FindNewDefaultSearchProvider()); | |
| 1237 | |
| 1238 // Add a few entries with searchTerms, but ensure only the last one is in the | |
| 1239 // default list. | |
| 1240 AddKeywordWithDate("name1", "key1", "http://foo1/{searchTerms}", | |
| 1241 "http://sugg1", std::string(), "http://icon1", true, | |
| 1242 "UTF-8;UTF-16", Time(), Time()); | |
| 1243 AddKeywordWithDate("name2", "key2", "http://foo2/{searchTerms}", | |
| 1244 "http://sugg2", std::string(), "http://icon1", true, | |
| 1245 "UTF-8;UTF-16", Time(), Time()); | |
| 1246 AddKeywordWithDate("name3", "key3", "http://foo1/{searchTerms}", | |
| 1247 "http://sugg3", std::string(), "http://icon3", true, | |
| 1248 "UTF-8;UTF-16", Time(), Time()); | |
| 1249 TemplateURLData data; | |
| 1250 data.short_name = ASCIIToUTF16("valid"); | |
| 1251 data.SetKeyword(ASCIIToUTF16("validkeyword")); | |
| 1252 data.SetURL("http://valid/{searchTerms}"); | |
| 1253 data.favicon_url = GURL("http://validicon"); | |
| 1254 data.show_in_default_list = true; | |
| 1255 TemplateURL* valid_turl(new TemplateURL(test_util_.profile(), data)); | |
| 1256 model()->Add(valid_turl); | |
| 1257 EXPECT_EQ(4U, model()->GetTemplateURLs().size()); | |
| 1258 | |
| 1259 // Request a new DSP from the service and only expect the valid one. | |
| 1260 TemplateURL* new_default = model()->FindNewDefaultSearchProvider(); | |
| 1261 ASSERT_TRUE(new_default); | |
| 1262 EXPECT_EQ(valid_turl, new_default); | |
| 1263 | |
| 1264 // Remove the default we received and ensure that the service returns NULL. | |
| 1265 model()->Remove(new_default); | |
| 1266 EXPECT_FALSE(model()->FindNewDefaultSearchProvider()); | |
| 1267 } | |
| 1268 | |
| 1269 // Make sure that the load routine doesn't delete | 1176 // Make sure that the load routine doesn't delete |
| 1270 // prepopulated engines that no longer exist in the prepopulate data if | 1177 // prepopulated engines that no longer exist in the prepopulate data if |
| 1271 // it is the default search provider. | 1178 // it is the default search provider. |
| 1272 TEST_F(TemplateURLServiceTest, LoadRetainsDefaultProvider) { | 1179 TEST_F(TemplateURLServiceTest, LoadRetainsDefaultProvider) { |
| 1273 // Set the default search provider to a preloaded template url which | 1180 // Set the default search provider to a preloaded template url which |
| 1274 // is not in the current set of preloaded template urls and save | 1181 // is not in the current set of preloaded template urls and save |
| 1275 // the result. | 1182 // the result. |
| 1276 TemplateURL* t_url = CreatePreloadedTemplateURL(true, 999999); | 1183 TemplateURL* t_url = CreatePreloadedTemplateURL(true, 999999); |
| 1277 test_util_.ChangeModelToLoadState(); | 1184 test_util_.ChangeModelToLoadState(); |
| 1278 model()->Add(t_url); | 1185 model()->Add(t_url); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1304 test_util_.ResetModel(true); | 1211 test_util_.ResetModel(true); |
| 1305 { | 1212 { |
| 1306 const TemplateURL* keyword_url = | 1213 const TemplateURL* keyword_url = |
| 1307 model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")); | 1214 model()->GetTemplateURLForKeyword(ASCIIToUTF16("unittest")); |
| 1308 ASSERT_TRUE(keyword_url != NULL); | 1215 ASSERT_TRUE(keyword_url != NULL); |
| 1309 AssertEquals(*cloned_url, *keyword_url); | 1216 AssertEquals(*cloned_url, *keyword_url); |
| 1310 ASSERT_EQ(keyword_url, model()->GetDefaultSearchProvider()); | 1217 ASSERT_EQ(keyword_url, model()->GetDefaultSearchProvider()); |
| 1311 } | 1218 } |
| 1312 } | 1219 } |
| 1313 | 1220 |
| 1314 // Make sure that the load routine updates the url of a preexisting | |
| 1315 // default search engine provider and that the result is saved correctly. | |
| 1316 TEST_F(TemplateURLServiceTest, LoadUpdatesDefaultSearchURL) { | |
| 1317 TestLoadUpdatingPreloadedURL(0); | |
| 1318 } | |
| 1319 | |
| 1320 // Make sure that the load routine updates the url of a preexisting | |
| 1321 // non-default search engine provider and that the result is saved correctly. | |
| 1322 TEST_F(TemplateURLServiceTest, LoadUpdatesSearchURL) { | |
| 1323 TestLoadUpdatingPreloadedURL(1); | |
| 1324 } | |
| 1325 | |
| 1326 // Make sure that the load routine sets a default search provider if it was | 1221 // Make sure that the load routine sets a default search provider if it was |
| 1327 // missing and not managed. | 1222 // missing and not managed. |
| 1328 TEST_F(TemplateURLServiceTest, LoadEnsuresDefaultSearchProviderExists) { | 1223 TEST_F(TemplateURLServiceTest, LoadEnsuresDefaultSearchProviderExists) { |
| 1329 // Force the model to load and make sure we have a default search provider. | 1224 // Force the model to load and make sure we have a default search provider. |
| 1330 test_util_.VerifyLoad(); | 1225 test_util_.VerifyLoad(); |
| 1331 TemplateURL* old_default = model()->GetDefaultSearchProvider(); | 1226 EXPECT_TRUE(model()->GetDefaultSearchProvider()); |
| 1332 EXPECT_TRUE(old_default); | |
| 1333 | 1227 |
| 1334 // Now remove it. | |
| 1335 model()->SetUserSelectedDefaultSearchProvider(NULL); | |
| 1336 model()->Remove(old_default); | |
| 1337 base::RunLoop().RunUntilIdle(); | |
| 1338 | |
| 1339 EXPECT_FALSE(model()->GetDefaultSearchProvider()); | |
| 1340 | |
| 1341 // Reset the model and load it. There should be a default search provider. | |
| 1342 test_util_.ResetModel(true); | |
| 1343 | |
| 1344 ASSERT_TRUE(model()->GetDefaultSearchProvider()); | |
| 1345 EXPECT_TRUE(model()->GetDefaultSearchProvider()->SupportsReplacement()); | 1228 EXPECT_TRUE(model()->GetDefaultSearchProvider()->SupportsReplacement()); |
| 1346 | 1229 |
| 1347 // Make default search provider unusable (no search terms). | 1230 // Make default search provider unusable (no search terms). |
| 1348 model()->ResetTemplateURL(model()->GetDefaultSearchProvider(), | 1231 model()->ResetTemplateURL(model()->GetDefaultSearchProvider(), |
| 1349 ASCIIToUTF16("test"), ASCIIToUTF16("test"), | 1232 ASCIIToUTF16("test"), ASCIIToUTF16("test"), |
| 1350 "http://example.com/"); | 1233 "http://example.com/"); |
| 1351 base::RunLoop().RunUntilIdle(); | 1234 base::RunLoop().RunUntilIdle(); |
| 1352 | 1235 |
| 1353 // Reset the model and load it. There should be a usable default search | 1236 // Reset the model and load it. There should be a usable default search |
| 1354 // provider. | 1237 // provider. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 actual_managed_default = model()->GetDefaultSearchProvider(); | 1335 actual_managed_default = model()->GetDefaultSearchProvider(); |
| 1453 ExpectSimilar(expected_managed_default2.get(), actual_managed_default); | 1336 ExpectSimilar(expected_managed_default2.get(), actual_managed_default); |
| 1454 EXPECT_EQ(actual_managed_default->show_in_default_list(), true); | 1337 EXPECT_EQ(actual_managed_default->show_in_default_list(), true); |
| 1455 | 1338 |
| 1456 // Remove all the managed prefs and check that we are no longer managed. | 1339 // Remove all the managed prefs and check that we are no longer managed. |
| 1457 test_util_.RemoveManagedDefaultSearchPreferences(); | 1340 test_util_.RemoveManagedDefaultSearchPreferences(); |
| 1458 VerifyObserverFired(); | 1341 VerifyObserverFired(); |
| 1459 EXPECT_FALSE(model()->is_default_search_managed()); | 1342 EXPECT_FALSE(model()->is_default_search_managed()); |
| 1460 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); | 1343 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); |
| 1461 | 1344 |
| 1462 // The default should now be the first URL added | 1345 // The default should now be the user preference. |
| 1463 const TemplateURL* actual_final_managed_default = | 1346 const TemplateURL* actual_final_managed_default = |
| 1464 model()->GetDefaultSearchProvider(); | 1347 model()->GetDefaultSearchProvider(); |
| 1465 ExpectSimilar(model()->GetTemplateURLs()[0], actual_final_managed_default); | 1348 ExpectSimilar(regular_default, actual_final_managed_default); |
| 1466 EXPECT_EQ(actual_final_managed_default->show_in_default_list(), true); | 1349 EXPECT_EQ(actual_final_managed_default->show_in_default_list(), true); |
| 1467 | 1350 |
| 1468 // Disable the default search provider through policy. | 1351 // Disable the default search provider through policy. |
| 1469 test_util_.SetManagedDefaultSearchPreferences(false, std::string(), | 1352 test_util_.SetManagedDefaultSearchPreferences(false, std::string(), |
| 1470 std::string(), std::string(), std::string(), std::string(), | 1353 std::string(), std::string(), std::string(), std::string(), |
| 1471 std::string(), std::string(), std::string()); | 1354 std::string(), std::string(), std::string()); |
| 1472 VerifyObserverFired(); | 1355 VerifyObserverFired(); |
| 1473 EXPECT_TRUE(model()->is_default_search_managed()); | 1356 EXPECT_TRUE(model()->is_default_search_managed()); |
| 1474 EXPECT_TRUE(NULL == model()->GetDefaultSearchProvider()); | 1357 EXPECT_TRUE(NULL == model()->GetDefaultSearchProvider()); |
| 1475 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); | 1358 EXPECT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 scoped_ptr<AssociatedExtensionInfo> extension_info( | 1562 scoped_ptr<AssociatedExtensionInfo> extension_info( |
| 1680 new AssociatedExtensionInfo); | 1563 new AssociatedExtensionInfo); |
| 1681 extension_info->wants_to_be_default_engine = true; | 1564 extension_info->wants_to_be_default_engine = true; |
| 1682 extension_info->extension_id = "ext1"; | 1565 extension_info->extension_id = "ext1"; |
| 1683 model()->AddExtensionControlledTURL(ext_dse, extension_info.Pass()); | 1566 model()->AddExtensionControlledTURL(ext_dse, extension_info.Pass()); |
| 1684 EXPECT_EQ(ext_dse, model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); | 1567 EXPECT_EQ(ext_dse, model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); |
| 1685 EXPECT_TRUE(model()->is_default_search_managed()); | 1568 EXPECT_TRUE(model()->is_default_search_managed()); |
| 1686 actual_managed_default = model()->GetDefaultSearchProvider(); | 1569 actual_managed_default = model()->GetDefaultSearchProvider(); |
| 1687 ExpectSimilar(expected_managed_default.get(), actual_managed_default); | 1570 ExpectSimilar(expected_managed_default.get(), actual_managed_default); |
| 1688 } | 1571 } |
| OLD | NEW |