| 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.h" | 5 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 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 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/test/base/testing_pref_service_syncable.h" | 25 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 26 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
| 27 #include "components/user_prefs/pref_registry_syncable.h" | 27 #include "components/user_prefs/pref_registry_syncable.h" |
| 28 #include "components/variations/variations_associated_data.h" | 28 #include "components/variations/variations_associated_data.h" |
| 29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
| 31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 | 33 |
| 34 using testing::_; | 34 using testing::_; |
| 35 using testing::Invoke; | |
| 36 | 35 |
| 37 namespace { | 36 namespace { |
| 38 | 37 |
| 39 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; | 38 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; |
| 40 const char kStudyDisabledGroupName[] = "Disabled"; | 39 const char kStudyDisabledGroupName[] = "Disabled"; |
| 41 const char kStudyDryRunGroupName[] = "DryRun"; | 40 const char kStudyDryRunGroupName[] = "DryRun"; |
| 42 const char kStudyEnabledGroupName[] = "Enabled"; | 41 const char kStudyEnabledGroupName[] = "Enabled"; |
| 43 | 42 |
| 44 const char kTestHashSeed[] = "testing-hash-seed"; | 43 const char kTestHashSeed[] = "testing-hash-seed"; |
| 45 const char kTestMementoValue[] = "01234567890123456789012345678901"; | 44 const char kTestMementoValue[] = "01234567890123456789012345678901"; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 | 58 |
| 60 // A testing version of the AutomaticProfileResetter that differs from the real | 59 // A testing version of the AutomaticProfileResetter that differs from the real |
| 61 // one only in that it has its statistics reporting mocked out for verification. | 60 // one only in that it has its statistics reporting mocked out for verification. |
| 62 class AutomaticProfileResetterUnderTest : public AutomaticProfileResetter { | 61 class AutomaticProfileResetterUnderTest : public AutomaticProfileResetter { |
| 63 public: | 62 public: |
| 64 explicit AutomaticProfileResetterUnderTest(Profile* profile) | 63 explicit AutomaticProfileResetterUnderTest(Profile* profile) |
| 65 : AutomaticProfileResetter(profile) {} | 64 : AutomaticProfileResetter(profile) {} |
| 66 virtual ~AutomaticProfileResetterUnderTest() {} | 65 virtual ~AutomaticProfileResetterUnderTest() {} |
| 67 | 66 |
| 68 MOCK_METHOD2(ReportStatistics, void(uint32, uint32)); | 67 MOCK_METHOD2(ReportStatistics, void(uint32, uint32)); |
| 68 MOCK_METHOD1(ReportPromptResult, |
| 69 void(AutomaticProfileResetter::PromptResult)); |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterUnderTest); | 72 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterUnderTest); |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate { | 75 class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate { |
| 75 public: | 76 public: |
| 76 MockProfileResetterDelegate() | 77 MockProfileResetterDelegate() |
| 77 : emulated_default_search_provider_is_managed_(false) {} | 78 : emulated_default_search_provider_is_managed_(false) {} |
| 78 virtual ~MockProfileResetterDelegate() {} | 79 virtual ~MockProfileResetterDelegate() {} |
| 79 | 80 |
| 80 MOCK_METHOD0(EnumerateLoadedModulesIfNeeded, void()); | 81 MOCK_METHOD0(EnumerateLoadedModulesIfNeeded, void()); |
| 81 MOCK_CONST_METHOD1(RequestCallbackWhenLoadedModulesAreEnumerated, | 82 MOCK_CONST_METHOD1(RequestCallbackWhenLoadedModulesAreEnumerated, |
| 82 void(const base::Closure&)); | 83 void(const base::Closure&)); |
| 83 | 84 |
| 84 MOCK_METHOD0(LoadTemplateURLServiceIfNeeded, void()); | 85 MOCK_METHOD0(LoadTemplateURLServiceIfNeeded, void()); |
| 85 MOCK_CONST_METHOD1(RequestCallbackWhenTemplateURLServiceIsLoaded, | 86 MOCK_CONST_METHOD1(RequestCallbackWhenTemplateURLServiceIsLoaded, |
| 86 void(const base::Closure&)); | 87 void(const base::Closure&)); |
| 87 | 88 |
| 89 MOCK_METHOD0(FetchBrandcodedDefaultSettingsIfNeeded, void()); |
| 90 MOCK_CONST_METHOD1(RequestCallbackWhenBrandcodedDefaultsAreFetched, |
| 91 void(const base::Closure&)); |
| 92 |
| 88 MOCK_CONST_METHOD0(OnGetLoadedModuleNameDigestsCalled, void()); | 93 MOCK_CONST_METHOD0(OnGetLoadedModuleNameDigestsCalled, void()); |
| 89 MOCK_CONST_METHOD0(OnGetDefaultSearchProviderDetailsCalled, void()); | 94 MOCK_CONST_METHOD0(OnGetDefaultSearchProviderDetailsCalled, void()); |
| 90 MOCK_CONST_METHOD0(OnIsDefaultSearchProviderManagedCalled, void()); | 95 MOCK_CONST_METHOD0(OnIsDefaultSearchProviderManagedCalled, void()); |
| 91 MOCK_CONST_METHOD0(OnGetPrepopulatedSearchProvidersDetailsCalled, void()); | 96 MOCK_CONST_METHOD0(OnGetPrepopulatedSearchProvidersDetailsCalled, void()); |
| 92 | 97 |
| 93 MOCK_METHOD0(ShowPrompt, void()); | 98 MOCK_METHOD0(ShowPrompt, bool()); |
| 99 MOCK_METHOD2(TriggerProfileSettingsReset, void(bool, const base::Closure&)); |
| 100 MOCK_METHOD0(DismissPrompt, void()); |
| 94 | 101 |
| 95 virtual scoped_ptr<base::ListValue> | 102 virtual scoped_ptr<base::ListValue> |
| 96 GetLoadedModuleNameDigests() const OVERRIDE { | 103 GetLoadedModuleNameDigests() const OVERRIDE { |
| 97 OnGetLoadedModuleNameDigestsCalled(); | 104 OnGetLoadedModuleNameDigestsCalled(); |
| 98 return scoped_ptr<base::ListValue>( | 105 return scoped_ptr<base::ListValue>( |
| 99 emulated_loaded_module_digests_.DeepCopy()); | 106 emulated_loaded_module_digests_.DeepCopy()); |
| 100 } | 107 } |
| 101 | 108 |
| 102 virtual scoped_ptr<base::DictionaryValue> | 109 virtual scoped_ptr<base::DictionaryValue> |
| 103 GetDefaultSearchProviderDetails() const OVERRIDE { | 110 GetDefaultSearchProviderDetails() const OVERRIDE { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 117 return scoped_ptr<base::ListValue>( | 124 return scoped_ptr<base::ListValue>( |
| 118 emulated_search_providers_details_.DeepCopy()); | 125 emulated_search_providers_details_.DeepCopy()); |
| 119 } | 126 } |
| 120 | 127 |
| 121 static void ClosureInvoker(const base::Closure& closure) { closure.Run(); } | 128 static void ClosureInvoker(const base::Closure& closure) { closure.Run(); } |
| 122 | 129 |
| 123 void ExpectCallsToDependenciesSetUpMethods() { | 130 void ExpectCallsToDependenciesSetUpMethods() { |
| 124 EXPECT_CALL(*this, EnumerateLoadedModulesIfNeeded()); | 131 EXPECT_CALL(*this, EnumerateLoadedModulesIfNeeded()); |
| 125 EXPECT_CALL(*this, LoadTemplateURLServiceIfNeeded()); | 132 EXPECT_CALL(*this, LoadTemplateURLServiceIfNeeded()); |
| 126 EXPECT_CALL(*this, RequestCallbackWhenLoadedModulesAreEnumerated(_)) | 133 EXPECT_CALL(*this, RequestCallbackWhenLoadedModulesAreEnumerated(_)) |
| 127 .WillOnce(Invoke(ClosureInvoker)); | 134 .WillOnce(testing::Invoke(ClosureInvoker)); |
| 128 EXPECT_CALL(*this, RequestCallbackWhenTemplateURLServiceIsLoaded(_)) | 135 EXPECT_CALL(*this, RequestCallbackWhenTemplateURLServiceIsLoaded(_)) |
| 129 .WillOnce(Invoke(ClosureInvoker)); | 136 .WillOnce(testing::Invoke(ClosureInvoker)); |
| 130 } | 137 } |
| 131 | 138 |
| 132 void ExpectCallsToGetterMethods() { | 139 void ExpectCallsToGetterMethods() { |
| 133 EXPECT_CALL(*this, OnGetLoadedModuleNameDigestsCalled()); | 140 EXPECT_CALL(*this, OnGetLoadedModuleNameDigestsCalled()); |
| 134 EXPECT_CALL(*this, OnGetDefaultSearchProviderDetailsCalled()); | 141 EXPECT_CALL(*this, OnGetDefaultSearchProviderDetailsCalled()); |
| 135 EXPECT_CALL(*this, OnIsDefaultSearchProviderManagedCalled()); | 142 EXPECT_CALL(*this, OnIsDefaultSearchProviderManagedCalled()); |
| 136 EXPECT_CALL(*this, OnGetPrepopulatedSearchProvidersDetailsCalled()); | 143 EXPECT_CALL(*this, OnGetPrepopulatedSearchProvidersDetailsCalled()); |
| 137 } | 144 } |
| 138 | 145 |
| 146 void ExpectCallToShowPrompt() { |
| 147 EXPECT_CALL(*this, ShowPrompt()).WillRepeatedly(testing::Return(true)); |
| 148 EXPECT_CALL(*this, FetchBrandcodedDefaultSettingsIfNeeded()); |
| 149 } |
| 150 |
| 151 void ExpectCallToTriggerReset(bool send_feedback) { |
| 152 EXPECT_CALL(*this, TriggerProfileSettingsReset(send_feedback, _)) |
| 153 .WillOnce(testing::WithArgs<1>(testing::Invoke(ClosureInvoker))); |
| 154 } |
| 155 |
| 139 base::DictionaryValue& emulated_default_search_provider_details() { | 156 base::DictionaryValue& emulated_default_search_provider_details() { |
| 140 return emulated_default_search_provider_details_; | 157 return emulated_default_search_provider_details_; |
| 141 } | 158 } |
| 142 | 159 |
| 143 base::ListValue& emulated_search_providers_details() { | 160 base::ListValue& emulated_search_providers_details() { |
| 144 return emulated_search_providers_details_; | 161 return emulated_search_providers_details_; |
| 145 } | 162 } |
| 146 | 163 |
| 147 base::ListValue& emulated_loaded_module_digests() { | 164 base::ListValue& emulated_loaded_module_digests() { |
| 148 return emulated_loaded_module_digests_; | 165 return emulated_loaded_module_digests_; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 | 417 |
| 401 // Test fixtures ------------------------------------------------------------- | 418 // Test fixtures ------------------------------------------------------------- |
| 402 | 419 |
| 403 class AutomaticProfileResetterTestBase : public testing::Test { | 420 class AutomaticProfileResetterTestBase : public testing::Test { |
| 404 protected: | 421 protected: |
| 405 explicit AutomaticProfileResetterTestBase( | 422 explicit AutomaticProfileResetterTestBase( |
| 406 const std::string& experiment_group_name) | 423 const std::string& experiment_group_name) |
| 407 : waiting_task_runner_(new base::TestSimpleTaskRunner), | 424 : waiting_task_runner_(new base::TestSimpleTaskRunner), |
| 408 local_state_(TestingBrowserProcess::GetGlobal()), | 425 local_state_(TestingBrowserProcess::GetGlobal()), |
| 409 profile_(new TestingProfile()), | 426 profile_(new TestingProfile()), |
| 427 field_trials_(new base::FieldTrialList(NULL)), |
| 428 memento_in_prefs_(new PreferenceHostedPromptMemento(profile())), |
| 429 memento_in_local_state_(new LocalStateHostedPromptMemento(profile())), |
| 430 memento_in_file_(new FileHostedPromptMementoSynchronous(profile())), |
| 410 experiment_group_name_(experiment_group_name), | 431 experiment_group_name_(experiment_group_name), |
| 411 inject_data_through_variation_params_(false), | 432 inject_data_through_variation_params_(false), |
| 412 mock_delegate_(NULL) { | 433 mock_delegate_(NULL) { |
| 413 // Make sure the factory is not optimized away, so whatever preferences it | 434 // Make sure the factory is not optimized away, so whatever preferences it |
| 414 // wants to register will actually get registered. | 435 // wants to register will actually get registered. |
| 415 AutomaticProfileResetterFactory::GetInstance(); | 436 AutomaticProfileResetterFactory::GetInstance(); |
| 416 | 437 |
| 417 // Register some additional local state preferences for testing purposes. | 438 // Register some additional local state preferences for testing purposes. |
| 418 PrefRegistrySimple* local_state_registry = local_state_.Get()->registry(); | 439 PrefRegistrySimple* local_state_registry = local_state_.Get()->registry(); |
| 419 DCHECK(local_state_registry); | 440 DCHECK(local_state_registry); |
| 420 local_state_registry->RegisterStringPref(kTestPreferencePath, ""); | 441 local_state_registry->RegisterStringPref(kTestPreferencePath, ""); |
| 421 | 442 |
| 422 // Register some additional user preferences for testing purposes. | 443 // Register some additional user preferences for testing purposes. |
| 423 user_prefs::PrefRegistrySyncable* user_prefs_registry = | 444 user_prefs::PrefRegistrySyncable* user_prefs_registry = |
| 424 profile_->GetTestingPrefService()->registry(); | 445 profile_->GetTestingPrefService()->registry(); |
| 425 DCHECK(user_prefs_registry); | 446 DCHECK(user_prefs_registry); |
| 426 user_prefs_registry->RegisterStringPref( | 447 user_prefs_registry->RegisterStringPref( |
| 427 kTestPreferencePath, | 448 kTestPreferencePath, std::string(), |
| 428 "", | |
| 429 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 449 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 430 } | 450 } |
| 431 | 451 |
| 432 virtual void SetUp() OVERRIDE { | 452 virtual void SetUp() OVERRIDE { |
| 433 field_trials_.reset(new base::FieldTrialList(NULL)); | |
| 434 chrome_variations::testing::ClearAllVariationParams(); | 453 chrome_variations::testing::ClearAllVariationParams(); |
| 435 base::FieldTrialList::CreateFieldTrial(kAutomaticProfileResetStudyName, | 454 base::FieldTrialList::CreateFieldTrial(kAutomaticProfileResetStudyName, |
| 436 experiment_group_name_); | 455 experiment_group_name_); |
| 437 resetter_.reset( | 456 resetter_.reset( |
| 438 new testing::StrictMock<AutomaticProfileResetterUnderTest>(profile())); | 457 new testing::StrictMock<AutomaticProfileResetterUnderTest>(profile())); |
| 439 mock_delegate_owned_.reset( | 458 mock_delegate_owned_.reset( |
| 440 new testing::StrictMock<MockProfileResetterDelegate>()); | 459 new testing::StrictMock<MockProfileResetterDelegate>()); |
| 441 mock_delegate_ = mock_delegate_owned_.get(); | 460 mock_delegate_ = mock_delegate_owned_.get(); |
| 461 |
| 462 ExpectAllMementoValuesEqualTo(std::string()); |
| 442 } | 463 } |
| 443 | 464 |
| 444 void SetTestingHashSeed(const std::string& hash_seed) { | 465 void SetTestingHashSeed(const std::string& hash_seed) { |
| 445 testing_hash_seed_ = hash_seed; | 466 testing_hash_seed_ = hash_seed; |
| 446 } | 467 } |
| 447 | 468 |
| 448 void SetTestingProgram(const std::string& source_code) { | 469 void SetTestingProgram(const std::string& source_code) { |
| 449 testing_program_ = source_code; | 470 testing_program_ = source_code; |
| 450 } | 471 } |
| 451 | 472 |
| 452 void AllowInjectingTestDataThroughVariationParams(bool value) { | 473 void AllowInjectingTestDataThroughVariationParams(bool value) { |
| 453 inject_data_through_variation_params_ = value; | 474 inject_data_through_variation_params_ = value; |
| 454 } | 475 } |
| 455 | 476 |
| 477 // Goes through an evaluation flow such that the reset criteria are satisfied. |
| 478 // Used to reduce boilerplate for tests that need to verify behavior during |
| 479 // the reset prompt flow. |
| 480 void OrchestrateThroughEvaluationFlow() { |
| 481 SetTestingProgram(ConstructProgram(true, true)); |
| 482 SetTestingHashSeed(kTestHashSeed); |
| 483 |
| 484 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 485 mock_delegate().ExpectCallsToGetterMethods(); |
| 486 mock_delegate().ExpectCallToShowPrompt(); |
| 487 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 488 |
| 489 UnleashResetterAndWait(); |
| 490 |
| 491 testing::Mock::VerifyAndClearExpectations(&resetter()); |
| 492 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
| 493 } |
| 494 |
| 495 void ExpectAllMementoValuesEqualTo(const std::string& value) { |
| 496 EXPECT_EQ(value, memento_in_prefs_->ReadValue()); |
| 497 EXPECT_EQ(value, memento_in_local_state_->ReadValue()); |
| 498 EXPECT_EQ(value, memento_in_file_->ReadValue()); |
| 499 } |
| 500 |
| 456 void UnleashResetterAndWait() { | 501 void UnleashResetterAndWait() { |
| 457 if (inject_data_through_variation_params_) { | 502 if (inject_data_through_variation_params_) { |
| 458 std::map<std::string, std::string> variation_params; | 503 std::map<std::string, std::string> variation_params; |
| 459 variation_params["program"] = testing_program_; | 504 variation_params["program"] = testing_program_; |
| 460 variation_params["hash_seed"] = testing_hash_seed_; | 505 variation_params["hash_seed"] = testing_hash_seed_; |
| 461 ASSERT_TRUE(chrome_variations::AssociateVariationParams( | 506 ASSERT_TRUE(chrome_variations::AssociateVariationParams( |
| 462 kAutomaticProfileResetStudyName, | 507 kAutomaticProfileResetStudyName, |
| 463 experiment_group_name_, | 508 experiment_group_name_, |
| 464 variation_params)); | 509 variation_params)); |
| 465 } | 510 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 476 if (waiting_task_runner_->HasPendingTask()) { | 521 if (waiting_task_runner_->HasPendingTask()) { |
| 477 ASSERT_EQ(base::TimeDelta::FromSeconds(55), | 522 ASSERT_EQ(base::TimeDelta::FromSeconds(55), |
| 478 waiting_task_runner_->NextPendingTaskDelay()); | 523 waiting_task_runner_->NextPendingTaskDelay()); |
| 479 waiting_task_runner_->RunPendingTasks(); | 524 waiting_task_runner_->RunPendingTasks(); |
| 480 } | 525 } |
| 481 base::RunLoop().RunUntilIdle(); | 526 base::RunLoop().RunUntilIdle(); |
| 482 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 527 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 483 base::RunLoop().RunUntilIdle(); | 528 base::RunLoop().RunUntilIdle(); |
| 484 } | 529 } |
| 485 | 530 |
| 531 void ShutdownResetter() { |
| 532 resetter_->Shutdown(); |
| 533 resetter_.reset(); |
| 534 } |
| 535 |
| 486 TestingProfile* profile() { return profile_.get(); } | 536 TestingProfile* profile() { return profile_.get(); } |
| 487 TestingPrefServiceSimple* local_state() { return local_state_.Get(); } | 537 TestingPrefServiceSimple* local_state() { return local_state_.Get(); } |
| 488 | 538 |
| 539 PreferenceHostedPromptMemento& memento_in_prefs() { |
| 540 return *memento_in_prefs_; |
| 541 } |
| 542 |
| 543 LocalStateHostedPromptMemento& memento_in_local_state() { |
| 544 return *memento_in_local_state_; |
| 545 } |
| 546 |
| 547 FileHostedPromptMementoSynchronous& memento_in_file() { |
| 548 return *memento_in_file_; |
| 549 } |
| 550 |
| 489 MockProfileResetterDelegate& mock_delegate() { return *mock_delegate_; } | 551 MockProfileResetterDelegate& mock_delegate() { return *mock_delegate_; } |
| 490 AutomaticProfileResetterUnderTest& resetter() { return *resetter_; } | 552 AutomaticProfileResetterUnderTest& resetter() { return *resetter_; } |
| 491 | 553 |
| 492 private: | 554 private: |
| 493 content::TestBrowserThreadBundle thread_bundle_; | 555 content::TestBrowserThreadBundle thread_bundle_; |
| 494 scoped_refptr<base::TestSimpleTaskRunner> waiting_task_runner_; | 556 scoped_refptr<base::TestSimpleTaskRunner> waiting_task_runner_; |
| 495 ScopedTestingLocalState local_state_; | 557 ScopedTestingLocalState local_state_; |
| 496 scoped_ptr<TestingProfile> profile_; | 558 scoped_ptr<TestingProfile> profile_; |
| 497 scoped_ptr<base::FieldTrialList> field_trials_; | 559 scoped_ptr<base::FieldTrialList> field_trials_; |
| 560 scoped_ptr<PreferenceHostedPromptMemento> memento_in_prefs_; |
| 561 scoped_ptr<LocalStateHostedPromptMemento> memento_in_local_state_; |
| 562 scoped_ptr<FileHostedPromptMementoSynchronous> memento_in_file_; |
| 563 |
| 498 std::string experiment_group_name_; | 564 std::string experiment_group_name_; |
| 499 std::string testing_program_; | 565 std::string testing_program_; |
| 500 std::string testing_hash_seed_; | 566 std::string testing_hash_seed_; |
| 501 bool inject_data_through_variation_params_; | 567 bool inject_data_through_variation_params_; |
| 502 | 568 |
| 503 scoped_ptr<AutomaticProfileResetterUnderTest> resetter_; | 569 scoped_ptr<AutomaticProfileResetterUnderTest> resetter_; |
| 504 scoped_ptr<MockProfileResetterDelegate> mock_delegate_owned_; | 570 scoped_ptr<MockProfileResetterDelegate> mock_delegate_owned_; |
| 505 MockProfileResetterDelegate* mock_delegate_; | 571 MockProfileResetterDelegate* mock_delegate_; |
| 506 | 572 |
| 507 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterTestBase); | 573 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterTestBase); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 523 class AutomaticProfileResetterTestDisabled | 589 class AutomaticProfileResetterTestDisabled |
| 524 : public AutomaticProfileResetterTestBase { | 590 : public AutomaticProfileResetterTestBase { |
| 525 protected: | 591 protected: |
| 526 AutomaticProfileResetterTestDisabled() | 592 AutomaticProfileResetterTestDisabled() |
| 527 : AutomaticProfileResetterTestBase(kStudyDisabledGroupName) {} | 593 : AutomaticProfileResetterTestBase(kStudyDisabledGroupName) {} |
| 528 }; | 594 }; |
| 529 | 595 |
| 530 // Tests --------------------------------------------------------------------- | 596 // Tests --------------------------------------------------------------------- |
| 531 | 597 |
| 532 TEST_F(AutomaticProfileResetterTestDisabled, NothingIsDoneWhenDisabled) { | 598 TEST_F(AutomaticProfileResetterTestDisabled, NothingIsDoneWhenDisabled) { |
| 533 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 534 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 535 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 536 | |
| 537 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 538 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 539 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 540 | |
| 541 SetTestingProgram(ConstructProgram(true, true)); | 599 SetTestingProgram(ConstructProgram(true, true)); |
| 542 SetTestingHashSeed(kTestHashSeed); | 600 SetTestingHashSeed(kTestHashSeed); |
| 543 | 601 |
| 544 // No calls are expected to the delegate. | 602 // No calls are expected to the delegate. |
| 545 | 603 |
| 546 UnleashResetterAndWait(); | 604 UnleashResetterAndWait(); |
| 605 ShutdownResetter(); |
| 547 | 606 |
| 548 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 607 ExpectAllMementoValuesEqualTo(std::string()); |
| 549 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 550 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 551 } | 608 } |
| 552 | 609 |
| 553 TEST_F(AutomaticProfileResetterTestDryRun, ConditionsNotSatisfied) { | 610 TEST_F(AutomaticProfileResetterTestDryRun, ConditionsNotSatisfied) { |
| 554 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 555 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 556 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 557 | |
| 558 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 559 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 560 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 561 | |
| 562 SetTestingProgram(ConstructProgram(false, false)); | 611 SetTestingProgram(ConstructProgram(false, false)); |
| 563 SetTestingHashSeed(kTestHashSeed); | 612 SetTestingHashSeed(kTestHashSeed); |
| 564 | 613 |
| 565 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 614 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 566 mock_delegate().ExpectCallsToGetterMethods(); | 615 mock_delegate().ExpectCallsToGetterMethods(); |
| 567 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); | 616 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); |
| 568 | 617 |
| 569 UnleashResetterAndWait(); | 618 UnleashResetterAndWait(); |
| 619 ShutdownResetter(); |
| 570 | 620 |
| 571 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 621 ExpectAllMementoValuesEqualTo(std::string()); |
| 572 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 573 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 574 } | 622 } |
| 575 | 623 |
| 576 TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) { | 624 TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) { |
| 577 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 578 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 579 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 580 | |
| 581 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 582 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 583 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 584 | |
| 585 SetTestingProgram(ConstructProgram(true, false)); | 625 SetTestingProgram(ConstructProgram(true, false)); |
| 586 SetTestingHashSeed(kTestHashSeed); | 626 SetTestingHashSeed(kTestHashSeed); |
| 587 | 627 |
| 588 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 628 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 589 mock_delegate().ExpectCallsToGetterMethods(); | 629 mock_delegate().ExpectCallsToGetterMethods(); |
| 590 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); | 630 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); |
| 631 EXPECT_CALL(resetter(), ReportPromptResult( |
| 632 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
| 591 | 633 |
| 592 UnleashResetterAndWait(); | 634 UnleashResetterAndWait(); |
| 593 | 635 |
| 594 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 636 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 595 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 637 |
| 596 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 638 ShutdownResetter(); |
| 597 } | 639 } |
| 598 | 640 |
| 599 TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) { | 641 TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) { |
| 600 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 601 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 602 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 603 | |
| 604 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 605 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 606 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 607 | |
| 608 SetTestingProgram(ConstructProgram(false, true)); | 642 SetTestingProgram(ConstructProgram(false, true)); |
| 609 SetTestingHashSeed(kTestHashSeed); | 643 SetTestingHashSeed(kTestHashSeed); |
| 610 | 644 |
| 611 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 645 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 612 mock_delegate().ExpectCallsToGetterMethods(); | 646 mock_delegate().ExpectCallsToGetterMethods(); |
| 613 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); | 647 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); |
| 648 EXPECT_CALL(resetter(), ReportPromptResult( |
| 649 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
| 614 | 650 |
| 615 UnleashResetterAndWait(); | 651 UnleashResetterAndWait(); |
| 616 | 652 |
| 617 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 653 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 618 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 654 |
| 619 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 655 ShutdownResetter(); |
| 620 } | 656 } |
| 621 | 657 |
| 622 #if defined(GOOGLE_CHROME_BUILD) | 658 #if defined(GOOGLE_CHROME_BUILD) |
| 623 TEST_F(AutomaticProfileResetterTestDryRun, ProgramSetThroughVariationParams) { | 659 TEST_F(AutomaticProfileResetterTestDryRun, ProgramSetThroughVariationParams) { |
| 624 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 625 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 626 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 627 | |
| 628 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 629 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 630 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 631 | |
| 632 SetTestingProgram(ConstructProgram(true, true)); | 660 SetTestingProgram(ConstructProgram(true, true)); |
| 633 SetTestingHashSeed(kTestHashSeed); | 661 SetTestingHashSeed(kTestHashSeed); |
| 634 AllowInjectingTestDataThroughVariationParams(true); | 662 AllowInjectingTestDataThroughVariationParams(true); |
| 635 | 663 |
| 636 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 664 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 637 mock_delegate().ExpectCallsToGetterMethods(); | 665 mock_delegate().ExpectCallsToGetterMethods(); |
| 638 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 666 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 667 EXPECT_CALL(resetter(), ReportPromptResult( |
| 668 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
| 639 | 669 |
| 640 UnleashResetterAndWait(); | 670 UnleashResetterAndWait(); |
| 641 | 671 |
| 642 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 672 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 643 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 673 |
| 644 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 674 ShutdownResetter(); |
| 645 } | 675 } |
| 646 #endif | 676 #endif |
| 647 | 677 |
| 648 TEST_F(AutomaticProfileResetterTestDryRun, | 678 TEST_F(AutomaticProfileResetterTestDryRun, |
| 649 ConditionsSatisfiedAndInvalidMementos) { | 679 ConditionsSatisfiedAndInvalidMementos) { |
| 650 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 680 memento_in_prefs().StoreValue(kTestInvalidMementoValue); |
| 651 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 681 memento_in_local_state().StoreValue(kTestInvalidMementoValue); |
| 652 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 682 memento_in_file().StoreValue(kTestInvalidMementoValue); |
| 653 | |
| 654 memento_in_prefs.StoreValue(kTestInvalidMementoValue); | |
| 655 memento_in_local_state.StoreValue(kTestInvalidMementoValue); | |
| 656 memento_in_file.StoreValue(kTestInvalidMementoValue); | |
| 657 | 683 |
| 658 SetTestingProgram(ConstructProgram(true, true)); | 684 SetTestingProgram(ConstructProgram(true, true)); |
| 659 SetTestingHashSeed(kTestHashSeed); | 685 SetTestingHashSeed(kTestHashSeed); |
| 660 | 686 |
| 661 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 687 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 662 mock_delegate().ExpectCallsToGetterMethods(); | 688 mock_delegate().ExpectCallsToGetterMethods(); |
| 663 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 689 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 690 EXPECT_CALL(resetter(), ReportPromptResult( |
| 691 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
| 664 | 692 |
| 665 UnleashResetterAndWait(); | 693 UnleashResetterAndWait(); |
| 666 | 694 |
| 667 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 695 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 668 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 696 |
| 669 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 697 ShutdownResetter(); |
| 670 } | 698 } |
| 671 | 699 |
| 672 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) { | 700 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) { |
| 673 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 701 memento_in_prefs().StoreValue(kTestMementoValue); |
| 674 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 675 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 676 | |
| 677 memento_in_prefs.StoreValue(kTestMementoValue); | |
| 678 | 702 |
| 679 SetTestingProgram(ConstructProgram(true, true)); | 703 SetTestingProgram(ConstructProgram(true, true)); |
| 680 SetTestingHashSeed(kTestHashSeed); | 704 SetTestingHashSeed(kTestHashSeed); |
| 681 | 705 |
| 682 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 706 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 683 mock_delegate().ExpectCallsToGetterMethods(); | 707 mock_delegate().ExpectCallsToGetterMethods(); |
| 684 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); | 708 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); |
| 685 | 709 |
| 686 UnleashResetterAndWait(); | 710 UnleashResetterAndWait(); |
| 711 ShutdownResetter(); |
| 687 | 712 |
| 688 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 713 EXPECT_EQ(kTestMementoValue, memento_in_prefs().ReadValue()); |
| 689 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 714 EXPECT_EQ(std::string(), memento_in_local_state().ReadValue()); |
| 690 EXPECT_EQ("", memento_in_file.ReadValue()); | 715 EXPECT_EQ(std::string(), memento_in_file().ReadValue()); |
| 691 } | 716 } |
| 692 | 717 |
| 693 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) { | 718 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) { |
| 694 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 719 memento_in_local_state().StoreValue(kTestMementoValue); |
| 695 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 696 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 697 | |
| 698 memento_in_local_state.StoreValue(kTestMementoValue); | |
| 699 | 720 |
| 700 SetTestingProgram(ConstructProgram(true, true)); | 721 SetTestingProgram(ConstructProgram(true, true)); |
| 701 SetTestingHashSeed(kTestHashSeed); | 722 SetTestingHashSeed(kTestHashSeed); |
| 702 | 723 |
| 703 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 724 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 704 mock_delegate().ExpectCallsToGetterMethods(); | 725 mock_delegate().ExpectCallsToGetterMethods(); |
| 705 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); | 726 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); |
| 706 | 727 |
| 707 UnleashResetterAndWait(); | 728 UnleashResetterAndWait(); |
| 729 ShutdownResetter(); |
| 708 | 730 |
| 709 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 731 EXPECT_EQ(std::string(), memento_in_prefs().ReadValue()); |
| 710 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 732 EXPECT_EQ(kTestMementoValue, memento_in_local_state().ReadValue()); |
| 711 EXPECT_EQ("", memento_in_file.ReadValue()); | 733 EXPECT_EQ(std::string(), memento_in_file().ReadValue()); |
| 712 } | 734 } |
| 713 | 735 |
| 714 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) { | 736 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) { |
| 715 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 737 memento_in_file().StoreValue(kTestMementoValue); |
| 716 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 717 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 718 | |
| 719 memento_in_file.StoreValue(kTestMementoValue); | |
| 720 | 738 |
| 721 SetTestingProgram(ConstructProgram(true, true)); | 739 SetTestingProgram(ConstructProgram(true, true)); |
| 722 SetTestingHashSeed(kTestHashSeed); | 740 SetTestingHashSeed(kTestHashSeed); |
| 723 | 741 |
| 724 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 742 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 725 mock_delegate().ExpectCallsToGetterMethods(); | 743 mock_delegate().ExpectCallsToGetterMethods(); |
| 726 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); | 744 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); |
| 727 | 745 |
| 728 UnleashResetterAndWait(); | 746 UnleashResetterAndWait(); |
| 747 ShutdownResetter(); |
| 729 | 748 |
| 730 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 749 EXPECT_EQ(std::string(), memento_in_prefs().ReadValue()); |
| 731 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 750 EXPECT_EQ(std::string(), memento_in_local_state().ReadValue()); |
| 732 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 751 EXPECT_EQ(kTestMementoValue, memento_in_file().ReadValue()); |
| 733 } | 752 } |
| 734 | 753 |
| 735 TEST_F(AutomaticProfileResetterTestDryRun, DoNothingWhenResourcesAreMissing) { | 754 TEST_F(AutomaticProfileResetterTestDryRun, DoNothingWhenResourcesAreMissing) { |
| 736 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 755 SetTestingProgram(std::string()); |
| 737 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 756 SetTestingHashSeed(std::string()); |
| 738 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 739 | |
| 740 SetTestingProgram(""); | |
| 741 SetTestingHashSeed(""); | |
| 742 | 757 |
| 743 // No calls are expected to the delegate. | 758 // No calls are expected to the delegate. |
| 744 | 759 |
| 745 UnleashResetterAndWait(); | 760 UnleashResetterAndWait(); |
| 761 ShutdownResetter(); |
| 746 | 762 |
| 747 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 763 ExpectAllMementoValuesEqualTo(std::string()); |
| 748 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 749 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 750 } | 764 } |
| 751 | 765 |
| 752 TEST_F(AutomaticProfileResetterTest, ConditionsNotSatisfied) { | 766 TEST_F(AutomaticProfileResetterTest, ConditionsNotSatisfied) { |
| 753 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 754 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 755 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 756 | |
| 757 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 758 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 759 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 760 | |
| 761 SetTestingProgram(ConstructProgram(false, false)); | 767 SetTestingProgram(ConstructProgram(false, false)); |
| 762 SetTestingHashSeed(kTestHashSeed); | 768 SetTestingHashSeed(kTestHashSeed); |
| 763 | 769 |
| 764 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 770 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 765 mock_delegate().ExpectCallsToGetterMethods(); | 771 mock_delegate().ExpectCallsToGetterMethods(); |
| 766 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); | 772 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); |
| 767 | 773 |
| 768 UnleashResetterAndWait(); | 774 UnleashResetterAndWait(); |
| 769 | 775 ShutdownResetter(); |
| 770 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 776 |
| 771 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 777 ExpectAllMementoValuesEqualTo(std::string()); |
| 772 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 773 } | 778 } |
| 774 | 779 |
| 775 TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) { | 780 TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) { |
| 776 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 777 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 778 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 779 | |
| 780 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 781 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 782 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 783 | |
| 784 SetTestingProgram(ConstructProgram(true, false)); | 781 SetTestingProgram(ConstructProgram(true, false)); |
| 785 SetTestingHashSeed(kTestHashSeed); | 782 SetTestingHashSeed(kTestHashSeed); |
| 786 | 783 |
| 787 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 784 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 788 mock_delegate().ExpectCallsToGetterMethods(); | 785 mock_delegate().ExpectCallsToGetterMethods(); |
| 789 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 786 mock_delegate().ExpectCallToShowPrompt(); |
| 790 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); | 787 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); |
| 791 | 788 |
| 792 UnleashResetterAndWait(); | 789 UnleashResetterAndWait(); |
| 793 | |
| 794 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | |
| 795 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | |
| 796 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | |
| 797 } | 790 } |
| 798 | 791 |
| 799 TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) { | 792 TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) { |
| 800 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 801 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 802 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 803 | |
| 804 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 805 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 806 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 807 | |
| 808 SetTestingProgram(ConstructProgram(false, true)); | 793 SetTestingProgram(ConstructProgram(false, true)); |
| 809 SetTestingHashSeed(kTestHashSeed); | 794 SetTestingHashSeed(kTestHashSeed); |
| 810 | 795 |
| 811 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 796 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 812 mock_delegate().ExpectCallsToGetterMethods(); | 797 mock_delegate().ExpectCallsToGetterMethods(); |
| 813 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 798 mock_delegate().ExpectCallToShowPrompt(); |
| 814 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); | 799 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); |
| 815 | 800 |
| 816 UnleashResetterAndWait(); | 801 UnleashResetterAndWait(); |
| 817 | 802 } |
| 818 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 803 |
| 819 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 804 TEST_F(AutomaticProfileResetterTest, PromptSuppressed) { |
| 820 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 805 OrchestrateThroughEvaluationFlow(); |
| 806 |
| 807 ShutdownResetter(); |
| 808 |
| 809 ExpectAllMementoValuesEqualTo(std::string()); |
| 810 } |
| 811 |
| 812 TEST_F(AutomaticProfileResetterTest, PromptIgnored) { |
| 813 OrchestrateThroughEvaluationFlow(); |
| 814 |
| 815 resetter().NotifyDidShowResetBubble(); |
| 816 ShutdownResetter(); |
| 817 |
| 818 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 819 } |
| 820 |
| 821 TEST_F(AutomaticProfileResetterTest, PromptActionReset) { |
| 822 OrchestrateThroughEvaluationFlow(); |
| 823 |
| 824 mock_delegate().ExpectCallToTriggerReset(false); |
| 825 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 826 EXPECT_CALL(resetter(), ReportPromptResult( |
| 827 AutomaticProfileResetter::PROMPT_ACTION_RESET)); |
| 828 |
| 829 resetter().NotifyDidShowResetBubble(); |
| 830 resetter().TriggerProfileReset(false /*send_feedback*/); |
| 831 |
| 832 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 833 |
| 834 ShutdownResetter(); |
| 835 } |
| 836 |
| 837 TEST_F(AutomaticProfileResetterTest, PromptActionResetWithFeedback) { |
| 838 OrchestrateThroughEvaluationFlow(); |
| 839 |
| 840 mock_delegate().ExpectCallToTriggerReset(true); |
| 841 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 842 EXPECT_CALL(resetter(), ReportPromptResult( |
| 843 AutomaticProfileResetter::PROMPT_ACTION_RESET)); |
| 844 |
| 845 resetter().NotifyDidShowResetBubble(); |
| 846 resetter().TriggerProfileReset(true /*send_feedback*/); |
| 847 |
| 848 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 849 |
| 850 ShutdownResetter(); |
| 851 } |
| 852 |
| 853 TEST_F(AutomaticProfileResetterTest, PromptActionNoReset) { |
| 854 OrchestrateThroughEvaluationFlow(); |
| 855 |
| 856 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 857 EXPECT_CALL(resetter(), ReportPromptResult( |
| 858 AutomaticProfileResetter::PROMPT_ACTION_NO_RESET)); |
| 859 |
| 860 resetter().NotifyDidShowResetBubble(); |
| 861 resetter().SkipProfileReset(); |
| 862 |
| 863 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 864 |
| 865 ShutdownResetter(); |
| 866 } |
| 867 |
| 868 TEST_F(AutomaticProfileResetterTest, PromptFollowedByWebUIReset) { |
| 869 OrchestrateThroughEvaluationFlow(); |
| 870 |
| 871 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 872 EXPECT_CALL(resetter(), ReportPromptResult( |
| 873 AutomaticProfileResetter::PROMPT_FOLLOWED_BY_WEBUI_RESET)); |
| 874 |
| 875 resetter().NotifyDidShowResetBubble(); |
| 876 resetter().NotifyDidOpenWebUIResetDialog(); |
| 877 resetter().NotifyDidCloseWebUIResetDialog(true); |
| 878 |
| 879 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 880 |
| 881 ShutdownResetter(); |
| 882 } |
| 883 |
| 884 TEST_F(AutomaticProfileResetterTest, PromptFollowedByWebUINoReset) { |
| 885 OrchestrateThroughEvaluationFlow(); |
| 886 |
| 887 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 888 EXPECT_CALL(resetter(), ReportPromptResult( |
| 889 AutomaticProfileResetter::PROMPT_FOLLOWED_BY_WEBUI_NO_RESET)); |
| 890 |
| 891 resetter().NotifyDidShowResetBubble(); |
| 892 resetter().NotifyDidOpenWebUIResetDialog(); |
| 893 resetter().NotifyDidCloseWebUIResetDialog(false); |
| 894 |
| 895 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 896 |
| 897 ShutdownResetter(); |
| 898 } |
| 899 |
| 900 TEST_F(AutomaticProfileResetterTest, PromptSuppressedButHadWebUIReset) { |
| 901 OrchestrateThroughEvaluationFlow(); |
| 902 |
| 903 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 904 EXPECT_CALL(resetter(), ReportPromptResult( |
| 905 AutomaticProfileResetter::PROMPT_SUPPRESSED_BUT_HAD_WEBUI_RESET)); |
| 906 |
| 907 resetter().NotifyDidOpenWebUIResetDialog(); |
| 908 resetter().NotifyDidCloseWebUIResetDialog(true); |
| 909 |
| 910 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 911 |
| 912 ShutdownResetter(); |
| 913 } |
| 914 |
| 915 TEST_F(AutomaticProfileResetterTest, PromptSuppressedButHadWebUINoReset) { |
| 916 OrchestrateThroughEvaluationFlow(); |
| 917 |
| 918 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 919 EXPECT_CALL(resetter(), ReportPromptResult( |
| 920 AutomaticProfileResetter::PROMPT_SUPPRESSED_BUT_HAD_WEBUI_NO_RESET)); |
| 921 |
| 922 resetter().NotifyDidOpenWebUIResetDialog(); |
| 923 resetter().NotifyDidCloseWebUIResetDialog(false); |
| 924 |
| 925 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 926 |
| 927 ShutdownResetter(); |
| 821 } | 928 } |
| 822 | 929 |
| 823 #if defined(GOOGLE_CHROME_BUILD) | 930 #if defined(GOOGLE_CHROME_BUILD) |
| 824 TEST_F(AutomaticProfileResetterTest, ProgramSetThroughVariationParams) { | 931 TEST_F(AutomaticProfileResetterTest, ProgramSetThroughVariationParams) { |
| 825 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 826 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 827 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 828 | |
| 829 EXPECT_EQ("", memento_in_prefs.ReadValue()); | |
| 830 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 831 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 832 | |
| 833 SetTestingProgram(ConstructProgram(true, true)); | 932 SetTestingProgram(ConstructProgram(true, true)); |
| 834 SetTestingHashSeed(kTestHashSeed); | 933 SetTestingHashSeed(kTestHashSeed); |
| 835 AllowInjectingTestDataThroughVariationParams(true); | 934 AllowInjectingTestDataThroughVariationParams(true); |
| 836 | 935 |
| 837 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 936 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 838 mock_delegate().ExpectCallsToGetterMethods(); | 937 mock_delegate().ExpectCallsToGetterMethods(); |
| 839 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 938 mock_delegate().ExpectCallToShowPrompt(); |
| 840 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 939 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 841 | 940 EXPECT_CALL(resetter(), ReportPromptResult( |
| 842 UnleashResetterAndWait(); | 941 AutomaticProfileResetter::PROMPT_IGNORED)); |
| 843 | 942 |
| 844 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 943 UnleashResetterAndWait(); |
| 845 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 944 resetter().NotifyDidShowResetBubble(); |
| 846 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 945 ShutdownResetter(); |
| 946 |
| 947 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 847 } | 948 } |
| 848 #endif | 949 #endif |
| 849 | 950 |
| 850 TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) { | 951 TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) { |
| 851 PreferenceHostedPromptMemento memento_in_prefs(profile()); | |
| 852 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 853 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 854 | |
| 855 memento_in_prefs.StoreValue(kTestInvalidMementoValue); | |
| 856 memento_in_local_state.StoreValue(kTestInvalidMementoValue); | |
| 857 memento_in_file.StoreValue(kTestInvalidMementoValue); | |
| 858 | |
| 859 SetTestingProgram(ConstructProgram(true, true)); | 952 SetTestingProgram(ConstructProgram(true, true)); |
| 860 SetTestingHashSeed(kTestHashSeed); | 953 SetTestingHashSeed(kTestHashSeed); |
| 861 | 954 |
| 862 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 955 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 863 mock_delegate().ExpectCallsToGetterMethods(); | 956 mock_delegate().ExpectCallsToGetterMethods(); |
| 864 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 957 mock_delegate().ExpectCallToShowPrompt(); |
| 865 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 958 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 866 | 959 EXPECT_CALL(resetter(), ReportPromptResult( |
| 867 UnleashResetterAndWait(); | 960 AutomaticProfileResetter::PROMPT_IGNORED)); |
| 868 | 961 |
| 869 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 962 UnleashResetterAndWait(); |
| 870 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 963 resetter().NotifyDidShowResetBubble(); |
| 871 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 964 ShutdownResetter(); |
| 965 |
| 966 ExpectAllMementoValuesEqualTo(kTestMementoValue); |
| 872 } | 967 } |
| 873 | 968 |
| 874 TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) { | 969 TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) { |
| 875 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 970 memento_in_prefs().StoreValue(kTestMementoValue); |
| 876 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 877 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 878 | |
| 879 memento_in_prefs.StoreValue(kTestMementoValue); | |
| 880 | 971 |
| 881 SetTestingProgram(ConstructProgram(true, true)); | 972 SetTestingProgram(ConstructProgram(true, true)); |
| 882 SetTestingHashSeed(kTestHashSeed); | 973 SetTestingHashSeed(kTestHashSeed); |
| 883 | 974 |
| 884 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 975 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 885 mock_delegate().ExpectCallsToGetterMethods(); | 976 mock_delegate().ExpectCallsToGetterMethods(); |
| 886 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); | 977 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); |
| 887 | 978 |
| 888 UnleashResetterAndWait(); | 979 UnleashResetterAndWait(); |
| 980 ShutdownResetter(); |
| 889 | 981 |
| 890 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 982 EXPECT_EQ(kTestMementoValue, memento_in_prefs().ReadValue()); |
| 891 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 983 EXPECT_EQ(std::string(), memento_in_local_state().ReadValue()); |
| 892 EXPECT_EQ("", memento_in_file.ReadValue()); | 984 EXPECT_EQ(std::string(), memento_in_file().ReadValue()); |
| 893 } | 985 } |
| 894 | 986 |
| 895 TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) { | 987 TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) { |
| 896 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 988 memento_in_local_state().StoreValue(kTestMementoValue); |
| 897 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 898 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 899 | |
| 900 memento_in_local_state.StoreValue(kTestMementoValue); | |
| 901 | 989 |
| 902 SetTestingProgram(ConstructProgram(true, true)); | 990 SetTestingProgram(ConstructProgram(true, true)); |
| 903 SetTestingHashSeed(kTestHashSeed); | 991 SetTestingHashSeed(kTestHashSeed); |
| 904 | 992 |
| 905 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 993 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 906 mock_delegate().ExpectCallsToGetterMethods(); | 994 mock_delegate().ExpectCallsToGetterMethods(); |
| 907 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); | 995 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); |
| 908 | 996 |
| 909 UnleashResetterAndWait(); | 997 UnleashResetterAndWait(); |
| 998 ShutdownResetter(); |
| 910 | 999 |
| 911 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 1000 EXPECT_EQ(std::string(), memento_in_prefs().ReadValue()); |
| 912 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 1001 EXPECT_EQ(kTestMementoValue, memento_in_local_state().ReadValue()); |
| 913 EXPECT_EQ("", memento_in_file.ReadValue()); | 1002 EXPECT_EQ(std::string(), memento_in_file().ReadValue()); |
| 914 } | 1003 } |
| 915 | 1004 |
| 916 TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) { | 1005 TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) { |
| 917 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1006 memento_in_file().StoreValue(kTestMementoValue); |
| 918 LocalStateHostedPromptMemento memento_in_local_state(profile()); | |
| 919 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 920 | |
| 921 memento_in_file.StoreValue(kTestMementoValue); | |
| 922 | 1007 |
| 923 SetTestingProgram(ConstructProgram(true, true)); | 1008 SetTestingProgram(ConstructProgram(true, true)); |
| 924 SetTestingHashSeed(kTestHashSeed); | 1009 SetTestingHashSeed(kTestHashSeed); |
| 925 | 1010 |
| 926 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1011 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 927 mock_delegate().ExpectCallsToGetterMethods(); | 1012 mock_delegate().ExpectCallsToGetterMethods(); |
| 928 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); | 1013 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); |
| 929 | 1014 |
| 930 UnleashResetterAndWait(); | 1015 UnleashResetterAndWait(); |
| 1016 ShutdownResetter(); |
| 931 | 1017 |
| 932 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 1018 EXPECT_EQ(std::string(), memento_in_prefs().ReadValue()); |
| 933 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 1019 EXPECT_EQ(std::string(), memento_in_local_state().ReadValue()); |
| 934 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 1020 EXPECT_EQ(kTestMementoValue, memento_in_file().ReadValue()); |
| 935 } | 1021 } |
| 936 | 1022 |
| 937 TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) { | 1023 TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) { |
| 938 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1024 SetTestingProgram(std::string()); |
| 939 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 1025 SetTestingHashSeed(std::string()); |
| 940 FileHostedPromptMementoSynchronous memento_in_file(profile()); | |
| 941 | |
| 942 SetTestingProgram(""); | |
| 943 SetTestingHashSeed(""); | |
| 944 | 1026 |
| 945 // No calls are expected to the delegate. | 1027 // No calls are expected to the delegate. |
| 946 | 1028 |
| 947 UnleashResetterAndWait(); | 1029 UnleashResetterAndWait(); |
| 1030 ShutdownResetter(); |
| 948 | 1031 |
| 949 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 1032 ExpectAllMementoValuesEqualTo(std::string()); |
| 950 EXPECT_EQ("", memento_in_local_state.ReadValue()); | |
| 951 EXPECT_EQ("", memento_in_file.ReadValue()); | |
| 952 } | 1033 } |
| 953 | 1034 |
| 954 // Please see comments above ConstructProgramToCheckPreferences() to understand | 1035 // Please see comments above ConstructProgramToCheckPreferences() to understand |
| 955 // how the following tests work. | 1036 // how the following tests work. |
| 956 | 1037 |
| 957 TEST_F(AutomaticProfileResetterTest, InputUserPreferencesCorrect) { | 1038 TEST_F(AutomaticProfileResetterTest, InputUserPreferencesCorrect) { |
| 958 SetTestingProgram(ConstructProgramToCheckPreferences()); | 1039 SetTestingProgram(ConstructProgramToCheckPreferences()); |
| 959 SetTestingHashSeed(kTestHashSeed); | 1040 SetTestingHashSeed(kTestHashSeed); |
| 960 | 1041 |
| 961 PrefService* prefs = profile()->GetPrefs(); | 1042 PrefService* prefs = profile()->GetPrefs(); |
| 962 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); | 1043 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); |
| 963 | 1044 |
| 964 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1045 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 965 mock_delegate().ExpectCallsToGetterMethods(); | 1046 mock_delegate().ExpectCallsToGetterMethods(); |
| 966 uint32 expected_mask = | 1047 uint32 expected_mask = HAS_EXPECTED_USER_PREFERENCE | |
| 967 HAS_EXPECTED_USER_PREFERENCE | USER_PREFERENCE_IS_USER_CONTROLLED; | 1048 USER_PREFERENCE_IS_USER_CONTROLLED; |
| 968 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); | 1049 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 969 | 1050 |
| 970 UnleashResetterAndWait(); | 1051 UnleashResetterAndWait(); |
| 971 } | 1052 } |
| 972 | 1053 |
| 973 TEST_F(AutomaticProfileResetterTest, InputLocalStateCorrect) { | 1054 TEST_F(AutomaticProfileResetterTest, InputLocalStateCorrect) { |
| 974 SetTestingProgram(ConstructProgramToCheckPreferences()); | 1055 SetTestingProgram(ConstructProgramToCheckPreferences()); |
| 975 SetTestingHashSeed(kTestHashSeed); | 1056 SetTestingHashSeed(kTestHashSeed); |
| 976 | 1057 |
| 977 PrefService* prefs = local_state(); | 1058 PrefService* prefs = local_state(); |
| 978 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); | 1059 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); |
| 979 | 1060 |
| 980 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1061 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 981 mock_delegate().ExpectCallsToGetterMethods(); | 1062 mock_delegate().ExpectCallsToGetterMethods(); |
| 982 uint32 expected_mask = | 1063 uint32 expected_mask = HAS_EXPECTED_LOCAL_STATE_PREFERENCE | |
| 983 HAS_EXPECTED_LOCAL_STATE_PREFERENCE | LOCAL_STATE_IS_USER_CONTROLLED; | 1064 LOCAL_STATE_IS_USER_CONTROLLED; |
| 984 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); | 1065 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 985 | 1066 |
| 986 UnleashResetterAndWait(); | 1067 UnleashResetterAndWait(); |
| 987 } | 1068 } |
| 988 | 1069 |
| 989 TEST_F(AutomaticProfileResetterTest, InputManagedUserPreferencesCorrect) { | 1070 TEST_F(AutomaticProfileResetterTest, InputManagedUserPreferencesCorrect) { |
| 990 SetTestingProgram(ConstructProgramToCheckPreferences()); | 1071 SetTestingProgram(ConstructProgramToCheckPreferences()); |
| 991 SetTestingHashSeed(kTestHashSeed); | 1072 SetTestingHashSeed(kTestHashSeed); |
| 992 | 1073 |
| 993 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); | 1074 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1170 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 1090 mock_delegate().ExpectCallsToGetterMethods(); | 1171 mock_delegate().ExpectCallsToGetterMethods(); |
| 1091 uint32 expected_mask = | 1172 uint32 expected_mask = |
| 1092 HAS_EXPECTED_MODULE_DIGEST_1 | HAS_EXPECTED_MODULE_DIGEST_2; | 1173 HAS_EXPECTED_MODULE_DIGEST_1 | HAS_EXPECTED_MODULE_DIGEST_2; |
| 1093 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); | 1174 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 1094 | 1175 |
| 1095 UnleashResetterAndWait(); | 1176 UnleashResetterAndWait(); |
| 1096 } | 1177 } |
| 1097 | 1178 |
| 1098 } // namespace | 1179 } // namespace |
| OLD | NEW |