| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h" | 5 #include "chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 TemplateURLService* template_url_service = | 364 TemplateURLService* template_url_service = |
| 365 TemplateURLServiceFactory::GetForProfile(profile()); | 365 TemplateURLServiceFactory::GetForProfile(profile()); |
| 366 TemplateURLServiceTestUtilBase::VerifyLoad(); | 366 TemplateURLServiceTestUtilBase::VerifyLoad(); |
| 367 | 367 |
| 368 // Check that the "managed state" and the details returned by the delegate are | 368 // Check that the "managed state" and the details returned by the delegate are |
| 369 // correct. We verify the details against the data stored by | 369 // correct. We verify the details against the data stored by |
| 370 // TemplateURLService into Prefs. | 370 // TemplateURLService into Prefs. |
| 371 scoped_ptr<TemplateURL> owned_custom_dsp(CreateTestTemplateURL()); | 371 scoped_ptr<TemplateURL> owned_custom_dsp(CreateTestTemplateURL()); |
| 372 TemplateURL* custom_dsp = owned_custom_dsp.get(); | 372 TemplateURL* custom_dsp = owned_custom_dsp.get(); |
| 373 template_url_service->Add(owned_custom_dsp.release()); | 373 template_url_service->Add(owned_custom_dsp.release()); |
| 374 template_url_service->SetDefaultSearchProvider(custom_dsp); | 374 template_url_service->SetUserSelectedDefaultSearchProvider(custom_dsp); |
| 375 | 375 |
| 376 PrefService* prefs = profile()->GetPrefs(); | 376 PrefService* prefs = profile()->GetPrefs(); |
| 377 ASSERT_TRUE(prefs); | 377 ASSERT_TRUE(prefs); |
| 378 scoped_ptr<base::DictionaryValue> dsp_details( | 378 scoped_ptr<base::DictionaryValue> dsp_details( |
| 379 resetter_delegate()->GetDefaultSearchProviderDetails()); | 379 resetter_delegate()->GetDefaultSearchProviderDetails()); |
| 380 scoped_ptr<base::DictionaryValue> expected_dsp_details( | 380 scoped_ptr<base::DictionaryValue> expected_dsp_details( |
| 381 GetDefaultSearchProviderDetailsFromPrefs(prefs)); | 381 GetDefaultSearchProviderDetailsFromPrefs(prefs)); |
| 382 | 382 |
| 383 ExpectDetailsMatch(*expected_dsp_details, *dsp_details); | 383 ExpectDetailsMatch(*expected_dsp_details, *dsp_details); |
| 384 EXPECT_FALSE(resetter_delegate()->IsDefaultSearchProviderManaged()); | 384 EXPECT_FALSE(resetter_delegate()->IsDefaultSearchProviderManaged()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 for (size_t i = 0; i < search_engines_details->GetSize(); ++i) { | 439 for (size_t i = 0; i < search_engines_details->GetSize(); ++i) { |
| 440 const base::DictionaryValue* details = NULL; | 440 const base::DictionaryValue* details = NULL; |
| 441 ASSERT_TRUE(search_engines_details->GetDictionary(i, &details)); | 441 ASSERT_TRUE(search_engines_details->GetDictionary(i, &details)); |
| 442 | 442 |
| 443 std::string keyword; | 443 std::string keyword; |
| 444 ASSERT_TRUE(details->GetString("keyword", &keyword)); | 444 ASSERT_TRUE(details->GetString("keyword", &keyword)); |
| 445 TemplateURL* search_engine = | 445 TemplateURL* search_engine = |
| 446 template_url_service->GetTemplateURLForKeyword( | 446 template_url_service->GetTemplateURLForKeyword( |
| 447 base::ASCIIToUTF16(keyword)); | 447 base::ASCIIToUTF16(keyword)); |
| 448 ASSERT_TRUE(search_engine); | 448 ASSERT_TRUE(search_engine); |
| 449 template_url_service->SetDefaultSearchProvider(prepopulated_engines[i]); | 449 template_url_service->SetUserSelectedDefaultSearchProvider( |
| 450 prepopulated_engines[i]); |
| 450 | 451 |
| 451 PrefService* prefs = profile()->GetPrefs(); | 452 PrefService* prefs = profile()->GetPrefs(); |
| 452 ASSERT_TRUE(prefs); | 453 ASSERT_TRUE(prefs); |
| 453 scoped_ptr<base::DictionaryValue> expected_dsp_details( | 454 scoped_ptr<base::DictionaryValue> expected_dsp_details( |
| 454 GetDefaultSearchProviderDetailsFromPrefs(prefs)); | 455 GetDefaultSearchProviderDetailsFromPrefs(prefs)); |
| 455 ExpectDetailsMatch(*expected_dsp_details, *details); | 456 ExpectDetailsMatch(*expected_dsp_details, *details); |
| 456 } | 457 } |
| 457 } | 458 } |
| 458 | 459 |
| 459 TEST_F(AutomaticProfileResetterDelegateTest, | 460 TEST_F(AutomaticProfileResetterDelegateTest, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 if (ProfileResetGlobalError::IsSupportedOnPlatform()) | 613 if (ProfileResetGlobalError::IsSupportedOnPlatform()) |
| 613 ExpectResetPromptState(true /*active*/); | 614 ExpectResetPromptState(true /*active*/); |
| 614 else | 615 else |
| 615 ExpectResetPromptState(false /*active*/); | 616 ExpectResetPromptState(false /*active*/); |
| 616 resetter_delegate()->DismissPrompt(); | 617 resetter_delegate()->DismissPrompt(); |
| 617 ExpectResetPromptState(false /*active*/); | 618 ExpectResetPromptState(false /*active*/); |
| 618 resetter_delegate()->DismissPrompt(); | 619 resetter_delegate()->DismissPrompt(); |
| 619 } | 620 } |
| 620 | 621 |
| 621 } // namespace | 622 } // namespace |
| OLD | NEW |