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 15 matching lines...) Expand all Loading... |
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; | 35 using testing::Invoke; |
| 36 using testing::WithArgs; |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; | 40 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; |
40 const char kStudyDisabledGroupName[] = "Disabled"; | 41 const char kStudyDisabledGroupName[] = "Disabled"; |
41 const char kStudyDryRunGroupName[] = "DryRun"; | 42 const char kStudyDryRunGroupName[] = "DryRun"; |
42 const char kStudyEnabledGroupName[] = "Enabled"; | 43 const char kStudyEnabledGroupName[] = "Enabled"; |
43 | 44 |
44 const char kTestHashSeed[] = "testing-hash-seed"; | 45 const char kTestHashSeed[] = "testing-hash-seed"; |
45 const char kTestMementoValue[] = "01234567890123456789012345678901"; | 46 const char kTestMementoValue[] = "01234567890123456789012345678901"; |
(...skipping 13 matching lines...) Expand all Loading... |
59 | 60 |
60 // A testing version of the AutomaticProfileResetter that differs from the real | 61 // 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. | 62 // one only in that it has its statistics reporting mocked out for verification. |
62 class AutomaticProfileResetterUnderTest : public AutomaticProfileResetter { | 63 class AutomaticProfileResetterUnderTest : public AutomaticProfileResetter { |
63 public: | 64 public: |
64 explicit AutomaticProfileResetterUnderTest(Profile* profile) | 65 explicit AutomaticProfileResetterUnderTest(Profile* profile) |
65 : AutomaticProfileResetter(profile) {} | 66 : AutomaticProfileResetter(profile) {} |
66 virtual ~AutomaticProfileResetterUnderTest() {} | 67 virtual ~AutomaticProfileResetterUnderTest() {} |
67 | 68 |
68 MOCK_METHOD2(ReportStatistics, void(uint32, uint32)); | 69 MOCK_METHOD2(ReportStatistics, void(uint32, uint32)); |
| 70 MOCK_METHOD1(ReportPromptResult, |
| 71 void(AutomaticProfileResetter::PromptResult)); |
69 | 72 |
70 private: | 73 private: |
71 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterUnderTest); | 74 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterUnderTest); |
72 }; | 75 }; |
73 | 76 |
74 class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate { | 77 class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate { |
75 public: | 78 public: |
76 MockProfileResetterDelegate() | 79 MockProfileResetterDelegate() |
77 : emulated_default_search_provider_is_managed_(false) {} | 80 : emulated_default_search_provider_is_managed_(false) {} |
78 virtual ~MockProfileResetterDelegate() {} | 81 virtual ~MockProfileResetterDelegate() {} |
79 | 82 |
80 MOCK_METHOD0(EnumerateLoadedModulesIfNeeded, void()); | 83 MOCK_METHOD0(EnumerateLoadedModulesIfNeeded, void()); |
81 MOCK_CONST_METHOD1(RequestCallbackWhenLoadedModulesAreEnumerated, | 84 MOCK_CONST_METHOD1(RequestCallbackWhenLoadedModulesAreEnumerated, |
82 void(const base::Closure&)); | 85 void(const base::Closure&)); |
83 | 86 |
84 MOCK_METHOD0(LoadTemplateURLServiceIfNeeded, void()); | 87 MOCK_METHOD0(LoadTemplateURLServiceIfNeeded, void()); |
85 MOCK_CONST_METHOD1(RequestCallbackWhenTemplateURLServiceIsLoaded, | 88 MOCK_CONST_METHOD1(RequestCallbackWhenTemplateURLServiceIsLoaded, |
86 void(const base::Closure&)); | 89 void(const base::Closure&)); |
87 | 90 |
| 91 MOCK_METHOD0(FetchBrandcodedDefaultSettingsIfNeeded, void()); |
| 92 MOCK_CONST_METHOD1(RequestCallbackWhenBrandcodedDefaultsAreFetched, |
| 93 void(const base::Closure&)); |
| 94 |
88 MOCK_CONST_METHOD0(OnGetLoadedModuleNameDigestsCalled, void()); | 95 MOCK_CONST_METHOD0(OnGetLoadedModuleNameDigestsCalled, void()); |
89 MOCK_CONST_METHOD0(OnGetDefaultSearchProviderDetailsCalled, void()); | 96 MOCK_CONST_METHOD0(OnGetDefaultSearchProviderDetailsCalled, void()); |
90 MOCK_CONST_METHOD0(OnIsDefaultSearchProviderManagedCalled, void()); | 97 MOCK_CONST_METHOD0(OnIsDefaultSearchProviderManagedCalled, void()); |
91 MOCK_CONST_METHOD0(OnGetPrepopulatedSearchProvidersDetailsCalled, void()); | 98 MOCK_CONST_METHOD0(OnGetPrepopulatedSearchProvidersDetailsCalled, void()); |
92 | 99 |
93 MOCK_METHOD0(ShowPrompt, void()); | 100 MOCK_METHOD0(ShowPrompt, bool()); |
| 101 MOCK_METHOD2(TriggerProfileSettingsReset, void(bool, const base::Closure&)); |
| 102 MOCK_METHOD0(DismissPrompt, void()); |
94 | 103 |
95 virtual scoped_ptr<base::ListValue> | 104 virtual scoped_ptr<base::ListValue> |
96 GetLoadedModuleNameDigests() const OVERRIDE { | 105 GetLoadedModuleNameDigests() const OVERRIDE { |
97 OnGetLoadedModuleNameDigestsCalled(); | 106 OnGetLoadedModuleNameDigestsCalled(); |
98 return scoped_ptr<base::ListValue>( | 107 return scoped_ptr<base::ListValue>( |
99 emulated_loaded_module_digests_.DeepCopy()); | 108 emulated_loaded_module_digests_.DeepCopy()); |
100 } | 109 } |
101 | 110 |
102 virtual scoped_ptr<base::DictionaryValue> | 111 virtual scoped_ptr<base::DictionaryValue> |
103 GetDefaultSearchProviderDetails() const OVERRIDE { | 112 GetDefaultSearchProviderDetails() const OVERRIDE { |
(...skipping 25 matching lines...) Expand all Loading... |
129 .WillOnce(Invoke(ClosureInvoker)); | 138 .WillOnce(Invoke(ClosureInvoker)); |
130 } | 139 } |
131 | 140 |
132 void ExpectCallsToGetterMethods() { | 141 void ExpectCallsToGetterMethods() { |
133 EXPECT_CALL(*this, OnGetLoadedModuleNameDigestsCalled()); | 142 EXPECT_CALL(*this, OnGetLoadedModuleNameDigestsCalled()); |
134 EXPECT_CALL(*this, OnGetDefaultSearchProviderDetailsCalled()); | 143 EXPECT_CALL(*this, OnGetDefaultSearchProviderDetailsCalled()); |
135 EXPECT_CALL(*this, OnIsDefaultSearchProviderManagedCalled()); | 144 EXPECT_CALL(*this, OnIsDefaultSearchProviderManagedCalled()); |
136 EXPECT_CALL(*this, OnGetPrepopulatedSearchProvidersDetailsCalled()); | 145 EXPECT_CALL(*this, OnGetPrepopulatedSearchProvidersDetailsCalled()); |
137 } | 146 } |
138 | 147 |
| 148 void ExpectCallToShowPrompt() { |
| 149 EXPECT_CALL(*this, ShowPrompt()).WillRepeatedly(testing::Return(true)); |
| 150 EXPECT_CALL(*this, FetchBrandcodedDefaultSettingsIfNeeded()); |
| 151 } |
| 152 |
| 153 void ExpectCallToTriggerReset(bool send_feedback) { |
| 154 EXPECT_CALL(*this, TriggerProfileSettingsReset(send_feedback, _)) |
| 155 .WillOnce(WithArgs<1>(Invoke(ClosureInvoker))); |
| 156 } |
| 157 |
139 base::DictionaryValue& emulated_default_search_provider_details() { | 158 base::DictionaryValue& emulated_default_search_provider_details() { |
140 return emulated_default_search_provider_details_; | 159 return emulated_default_search_provider_details_; |
141 } | 160 } |
142 | 161 |
143 base::ListValue& emulated_search_providers_details() { | 162 base::ListValue& emulated_search_providers_details() { |
144 return emulated_search_providers_details_; | 163 return emulated_search_providers_details_; |
145 } | 164 } |
146 | 165 |
147 base::ListValue& emulated_loaded_module_digests() { | 166 base::ListValue& emulated_loaded_module_digests() { |
148 return emulated_loaded_module_digests_; | 167 return emulated_loaded_module_digests_; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 // Register some additional local state preferences for testing purposes. | 436 // Register some additional local state preferences for testing purposes. |
418 PrefRegistrySimple* local_state_registry = local_state_.Get()->registry(); | 437 PrefRegistrySimple* local_state_registry = local_state_.Get()->registry(); |
419 DCHECK(local_state_registry); | 438 DCHECK(local_state_registry); |
420 local_state_registry->RegisterStringPref(kTestPreferencePath, ""); | 439 local_state_registry->RegisterStringPref(kTestPreferencePath, ""); |
421 | 440 |
422 // Register some additional user preferences for testing purposes. | 441 // Register some additional user preferences for testing purposes. |
423 user_prefs::PrefRegistrySyncable* user_prefs_registry = | 442 user_prefs::PrefRegistrySyncable* user_prefs_registry = |
424 profile_->GetTestingPrefService()->registry(); | 443 profile_->GetTestingPrefService()->registry(); |
425 DCHECK(user_prefs_registry); | 444 DCHECK(user_prefs_registry); |
426 user_prefs_registry->RegisterStringPref( | 445 user_prefs_registry->RegisterStringPref( |
427 kTestPreferencePath, | 446 kTestPreferencePath, "", |
428 "", | |
429 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 447 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
430 } | 448 } |
431 | 449 |
432 virtual void SetUp() OVERRIDE { | 450 virtual void SetUp() OVERRIDE { |
433 field_trials_.reset(new base::FieldTrialList(NULL)); | 451 field_trials_.reset(new base::FieldTrialList(NULL)); |
434 chrome_variations::testing::ClearAllVariationParams(); | 452 chrome_variations::testing::ClearAllVariationParams(); |
435 base::FieldTrialList::CreateFieldTrial(kAutomaticProfileResetStudyName, | 453 base::FieldTrialList::CreateFieldTrial(kAutomaticProfileResetStudyName, |
436 experiment_group_name_); | 454 experiment_group_name_); |
437 resetter_.reset( | 455 resetter_.reset( |
438 new testing::StrictMock<AutomaticProfileResetterUnderTest>(profile())); | 456 new testing::StrictMock<AutomaticProfileResetterUnderTest>(profile())); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 if (waiting_task_runner_->HasPendingTask()) { | 494 if (waiting_task_runner_->HasPendingTask()) { |
477 ASSERT_EQ(base::TimeDelta::FromSeconds(55), | 495 ASSERT_EQ(base::TimeDelta::FromSeconds(55), |
478 waiting_task_runner_->NextPendingTaskDelay()); | 496 waiting_task_runner_->NextPendingTaskDelay()); |
479 waiting_task_runner_->RunPendingTasks(); | 497 waiting_task_runner_->RunPendingTasks(); |
480 } | 498 } |
481 base::RunLoop().RunUntilIdle(); | 499 base::RunLoop().RunUntilIdle(); |
482 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 500 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
483 base::RunLoop().RunUntilIdle(); | 501 base::RunLoop().RunUntilIdle(); |
484 } | 502 } |
485 | 503 |
| 504 void ShutdownResetter() { |
| 505 resetter_->Shutdown(); |
| 506 resetter_.reset(); |
| 507 } |
| 508 |
486 TestingProfile* profile() { return profile_.get(); } | 509 TestingProfile* profile() { return profile_.get(); } |
487 TestingPrefServiceSimple* local_state() { return local_state_.Get(); } | 510 TestingPrefServiceSimple* local_state() { return local_state_.Get(); } |
488 | 511 |
489 MockProfileResetterDelegate& mock_delegate() { return *mock_delegate_; } | 512 MockProfileResetterDelegate& mock_delegate() { return *mock_delegate_; } |
490 AutomaticProfileResetterUnderTest& resetter() { return *resetter_; } | 513 AutomaticProfileResetterUnderTest& resetter() { return *resetter_; } |
491 | 514 |
492 private: | 515 private: |
493 content::TestBrowserThreadBundle thread_bundle_; | 516 content::TestBrowserThreadBundle thread_bundle_; |
494 scoped_refptr<base::TestSimpleTaskRunner> waiting_task_runner_; | 517 scoped_refptr<base::TestSimpleTaskRunner> waiting_task_runner_; |
495 ScopedTestingLocalState local_state_; | 518 ScopedTestingLocalState local_state_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 : AutomaticProfileResetterTestBase(kStudyDisabledGroupName) {} | 550 : AutomaticProfileResetterTestBase(kStudyDisabledGroupName) {} |
528 }; | 551 }; |
529 | 552 |
530 // Tests --------------------------------------------------------------------- | 553 // Tests --------------------------------------------------------------------- |
531 | 554 |
532 TEST_F(AutomaticProfileResetterTestDisabled, NothingIsDoneWhenDisabled) { | 555 TEST_F(AutomaticProfileResetterTestDisabled, NothingIsDoneWhenDisabled) { |
533 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 556 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
534 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 557 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
535 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 558 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
536 | 559 |
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)); | 560 SetTestingProgram(ConstructProgram(true, true)); |
542 SetTestingHashSeed(kTestHashSeed); | 561 SetTestingHashSeed(kTestHashSeed); |
543 | 562 |
544 // No calls are expected to the delegate. | 563 // No calls are expected to the delegate. |
545 | 564 |
546 UnleashResetterAndWait(); | 565 UnleashResetterAndWait(); |
| 566 ShutdownResetter(); |
547 | 567 |
548 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 568 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
549 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 569 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
550 EXPECT_EQ("", memento_in_file.ReadValue()); | 570 EXPECT_EQ("", memento_in_file.ReadValue()); |
551 } | 571 } |
552 | 572 |
553 TEST_F(AutomaticProfileResetterTestDryRun, ConditionsNotSatisfied) { | 573 TEST_F(AutomaticProfileResetterTestDryRun, ConditionsNotSatisfied) { |
554 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 574 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
555 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 575 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
556 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 576 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
557 | 577 |
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)); | 578 SetTestingProgram(ConstructProgram(false, false)); |
563 SetTestingHashSeed(kTestHashSeed); | 579 SetTestingHashSeed(kTestHashSeed); |
564 | 580 |
565 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 581 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
566 mock_delegate().ExpectCallsToGetterMethods(); | 582 mock_delegate().ExpectCallsToGetterMethods(); |
567 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); | 583 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); |
568 | 584 |
569 UnleashResetterAndWait(); | 585 UnleashResetterAndWait(); |
| 586 ShutdownResetter(); |
570 | 587 |
571 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 588 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
572 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 589 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
573 EXPECT_EQ("", memento_in_file.ReadValue()); | 590 EXPECT_EQ("", memento_in_file.ReadValue()); |
574 } | 591 } |
575 | 592 |
576 TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) { | 593 TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) { |
577 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 594 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
578 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 595 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
579 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 596 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
580 | 597 |
581 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 598 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
582 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 599 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
583 EXPECT_EQ("", memento_in_file.ReadValue()); | 600 EXPECT_EQ("", memento_in_file.ReadValue()); |
584 | 601 |
585 SetTestingProgram(ConstructProgram(true, false)); | 602 SetTestingProgram(ConstructProgram(true, false)); |
586 SetTestingHashSeed(kTestHashSeed); | 603 SetTestingHashSeed(kTestHashSeed); |
587 | 604 |
588 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 605 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
589 mock_delegate().ExpectCallsToGetterMethods(); | 606 mock_delegate().ExpectCallsToGetterMethods(); |
590 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); | 607 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); |
| 608 EXPECT_CALL(resetter(), ReportPromptResult( |
| 609 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
591 | 610 |
592 UnleashResetterAndWait(); | 611 UnleashResetterAndWait(); |
593 | 612 |
594 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 613 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
595 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 614 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
596 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 615 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 616 |
| 617 ShutdownResetter(); |
597 } | 618 } |
598 | 619 |
599 TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) { | 620 TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) { |
600 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 621 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
601 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 622 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
602 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 623 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
603 | 624 |
604 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 625 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
605 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 626 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
606 EXPECT_EQ("", memento_in_file.ReadValue()); | 627 EXPECT_EQ("", memento_in_file.ReadValue()); |
607 | 628 |
608 SetTestingProgram(ConstructProgram(false, true)); | 629 SetTestingProgram(ConstructProgram(false, true)); |
609 SetTestingHashSeed(kTestHashSeed); | 630 SetTestingHashSeed(kTestHashSeed); |
610 | 631 |
611 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 632 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
612 mock_delegate().ExpectCallsToGetterMethods(); | 633 mock_delegate().ExpectCallsToGetterMethods(); |
613 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); | 634 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); |
| 635 EXPECT_CALL(resetter(), ReportPromptResult( |
| 636 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
614 | 637 |
615 UnleashResetterAndWait(); | 638 UnleashResetterAndWait(); |
616 | 639 |
617 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 640 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
618 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 641 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
619 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 642 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 643 |
| 644 ShutdownResetter(); |
620 } | 645 } |
621 | 646 |
622 #if defined(GOOGLE_CHROME_BUILD) | 647 #if defined(GOOGLE_CHROME_BUILD) |
623 TEST_F(AutomaticProfileResetterTestDryRun, ProgramSetThroughVariationParams) { | 648 TEST_F(AutomaticProfileResetterTestDryRun, ProgramSetThroughVariationParams) { |
624 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 649 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
625 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 650 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
626 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 651 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
627 | 652 |
628 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 653 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
629 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 654 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
630 EXPECT_EQ("", memento_in_file.ReadValue()); | 655 EXPECT_EQ("", memento_in_file.ReadValue()); |
631 | 656 |
632 SetTestingProgram(ConstructProgram(true, true)); | 657 SetTestingProgram(ConstructProgram(true, true)); |
633 SetTestingHashSeed(kTestHashSeed); | 658 SetTestingHashSeed(kTestHashSeed); |
634 AllowInjectingTestDataThroughVariationParams(true); | 659 AllowInjectingTestDataThroughVariationParams(true); |
635 | 660 |
636 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 661 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
637 mock_delegate().ExpectCallsToGetterMethods(); | 662 mock_delegate().ExpectCallsToGetterMethods(); |
638 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 663 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 664 EXPECT_CALL(resetter(), ReportPromptResult( |
| 665 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
639 | 666 |
640 UnleashResetterAndWait(); | 667 UnleashResetterAndWait(); |
641 | 668 |
642 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 669 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
643 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 670 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
644 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 671 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 672 |
| 673 ShutdownResetter(); |
645 } | 674 } |
646 #endif | 675 #endif |
647 | 676 |
648 TEST_F(AutomaticProfileResetterTestDryRun, | 677 TEST_F(AutomaticProfileResetterTestDryRun, |
649 ConditionsSatisfiedAndInvalidMementos) { | 678 ConditionsSatisfiedAndInvalidMementos) { |
650 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 679 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
651 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 680 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
652 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 681 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
653 | 682 |
654 memento_in_prefs.StoreValue(kTestInvalidMementoValue); | 683 memento_in_prefs.StoreValue(kTestInvalidMementoValue); |
655 memento_in_local_state.StoreValue(kTestInvalidMementoValue); | 684 memento_in_local_state.StoreValue(kTestInvalidMementoValue); |
656 memento_in_file.StoreValue(kTestInvalidMementoValue); | 685 memento_in_file.StoreValue(kTestInvalidMementoValue); |
657 | 686 |
658 SetTestingProgram(ConstructProgram(true, true)); | 687 SetTestingProgram(ConstructProgram(true, true)); |
659 SetTestingHashSeed(kTestHashSeed); | 688 SetTestingHashSeed(kTestHashSeed); |
660 | 689 |
661 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 690 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
662 mock_delegate().ExpectCallsToGetterMethods(); | 691 mock_delegate().ExpectCallsToGetterMethods(); |
663 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 692 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 693 EXPECT_CALL(resetter(), ReportPromptResult( |
| 694 AutomaticProfileResetter::PROMPT_NOT_SHOWN)); |
664 | 695 |
665 UnleashResetterAndWait(); | 696 UnleashResetterAndWait(); |
666 | 697 |
667 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 698 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
668 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 699 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
669 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 700 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 701 |
| 702 ShutdownResetter(); |
670 } | 703 } |
671 | 704 |
672 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) { | 705 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) { |
673 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 706 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
674 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 707 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
675 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 708 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
676 | 709 |
677 memento_in_prefs.StoreValue(kTestMementoValue); | 710 memento_in_prefs.StoreValue(kTestMementoValue); |
678 | 711 |
679 SetTestingProgram(ConstructProgram(true, true)); | 712 SetTestingProgram(ConstructProgram(true, true)); |
680 SetTestingHashSeed(kTestHashSeed); | 713 SetTestingHashSeed(kTestHashSeed); |
681 | 714 |
682 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 715 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
683 mock_delegate().ExpectCallsToGetterMethods(); | 716 mock_delegate().ExpectCallsToGetterMethods(); |
684 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); | 717 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); |
685 | 718 |
686 UnleashResetterAndWait(); | 719 UnleashResetterAndWait(); |
| 720 ShutdownResetter(); |
687 | 721 |
688 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 722 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
689 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 723 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
690 EXPECT_EQ("", memento_in_file.ReadValue()); | 724 EXPECT_EQ("", memento_in_file.ReadValue()); |
691 } | 725 } |
692 | 726 |
693 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) { | 727 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) { |
694 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 728 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
695 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 729 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
696 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 730 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
697 | 731 |
698 memento_in_local_state.StoreValue(kTestMementoValue); | 732 memento_in_local_state.StoreValue(kTestMementoValue); |
699 | 733 |
700 SetTestingProgram(ConstructProgram(true, true)); | 734 SetTestingProgram(ConstructProgram(true, true)); |
701 SetTestingHashSeed(kTestHashSeed); | 735 SetTestingHashSeed(kTestHashSeed); |
702 | 736 |
703 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 737 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
704 mock_delegate().ExpectCallsToGetterMethods(); | 738 mock_delegate().ExpectCallsToGetterMethods(); |
705 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); | 739 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); |
706 | 740 |
707 UnleashResetterAndWait(); | 741 UnleashResetterAndWait(); |
| 742 ShutdownResetter(); |
708 | 743 |
709 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 744 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
710 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 745 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
711 EXPECT_EQ("", memento_in_file.ReadValue()); | 746 EXPECT_EQ("", memento_in_file.ReadValue()); |
712 } | 747 } |
713 | 748 |
714 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) { | 749 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) { |
715 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 750 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
716 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 751 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
717 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 752 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
718 | 753 |
719 memento_in_file.StoreValue(kTestMementoValue); | 754 memento_in_file.StoreValue(kTestMementoValue); |
720 | 755 |
721 SetTestingProgram(ConstructProgram(true, true)); | 756 SetTestingProgram(ConstructProgram(true, true)); |
722 SetTestingHashSeed(kTestHashSeed); | 757 SetTestingHashSeed(kTestHashSeed); |
723 | 758 |
724 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 759 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
725 mock_delegate().ExpectCallsToGetterMethods(); | 760 mock_delegate().ExpectCallsToGetterMethods(); |
726 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); | 761 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); |
727 | 762 |
728 UnleashResetterAndWait(); | 763 UnleashResetterAndWait(); |
| 764 ShutdownResetter(); |
729 | 765 |
730 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 766 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
731 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 767 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
732 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 768 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
733 } | 769 } |
734 | 770 |
735 TEST_F(AutomaticProfileResetterTestDryRun, DoNothingWhenResourcesAreMissing) { | 771 TEST_F(AutomaticProfileResetterTestDryRun, DoNothingWhenResourcesAreMissing) { |
736 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 772 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
737 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 773 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
738 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 774 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
739 | 775 |
740 SetTestingProgram(""); | 776 SetTestingProgram(""); |
741 SetTestingHashSeed(""); | 777 SetTestingHashSeed(""); |
742 | 778 |
743 // No calls are expected to the delegate. | 779 // No calls are expected to the delegate. |
744 | 780 |
745 UnleashResetterAndWait(); | 781 UnleashResetterAndWait(); |
| 782 ShutdownResetter(); |
746 | 783 |
747 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 784 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
748 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 785 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
749 EXPECT_EQ("", memento_in_file.ReadValue()); | 786 EXPECT_EQ("", memento_in_file.ReadValue()); |
750 } | 787 } |
751 | 788 |
752 TEST_F(AutomaticProfileResetterTest, ConditionsNotSatisfied) { | 789 TEST_F(AutomaticProfileResetterTest, ConditionsNotSatisfied) { |
753 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 790 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
754 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 791 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
755 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 792 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
756 | 793 |
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)); | 794 SetTestingProgram(ConstructProgram(false, false)); |
762 SetTestingHashSeed(kTestHashSeed); | 795 SetTestingHashSeed(kTestHashSeed); |
763 | 796 |
764 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 797 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
765 mock_delegate().ExpectCallsToGetterMethods(); | 798 mock_delegate().ExpectCallsToGetterMethods(); |
766 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); | 799 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); |
767 | 800 |
768 UnleashResetterAndWait(); | 801 UnleashResetterAndWait(); |
| 802 ShutdownResetter(); |
769 | 803 |
770 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 804 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
771 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 805 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
772 EXPECT_EQ("", memento_in_file.ReadValue()); | 806 EXPECT_EQ("", memento_in_file.ReadValue()); |
773 } | 807 } |
774 | 808 |
775 TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) { | 809 TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) { |
| 810 SetTestingProgram(ConstructProgram(true, false)); |
| 811 SetTestingHashSeed(kTestHashSeed); |
| 812 |
| 813 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 814 mock_delegate().ExpectCallsToGetterMethods(); |
| 815 mock_delegate().ExpectCallToShowPrompt(); |
| 816 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); |
| 817 |
| 818 UnleashResetterAndWait(); |
| 819 } |
| 820 |
| 821 TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) { |
| 822 SetTestingProgram(ConstructProgram(false, true)); |
| 823 SetTestingHashSeed(kTestHashSeed); |
| 824 |
| 825 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 826 mock_delegate().ExpectCallsToGetterMethods(); |
| 827 mock_delegate().ExpectCallToShowPrompt(); |
| 828 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); |
| 829 |
| 830 UnleashResetterAndWait(); |
| 831 } |
| 832 |
| 833 TEST_F(AutomaticProfileResetterTest, PromptSuppressed) { |
776 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 834 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
777 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 835 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
778 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 836 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 837 |
| 838 SetTestingProgram(ConstructProgram(true, true)); |
| 839 SetTestingHashSeed(kTestHashSeed); |
| 840 |
| 841 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 842 mock_delegate().ExpectCallsToGetterMethods(); |
| 843 mock_delegate().ExpectCallToShowPrompt(); |
| 844 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 845 |
| 846 UnleashResetterAndWait(); |
| 847 ShutdownResetter(); |
| 848 |
| 849 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 850 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 851 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 852 } |
| 853 |
| 854 TEST_F(AutomaticProfileResetterTest, PromptIgnored) { |
| 855 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 856 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 857 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
779 | 858 |
780 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 859 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
781 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 860 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
782 EXPECT_EQ("", memento_in_file.ReadValue()); | 861 EXPECT_EQ("", memento_in_file.ReadValue()); |
783 | 862 |
784 SetTestingProgram(ConstructProgram(true, false)); | 863 SetTestingProgram(ConstructProgram(true, true)); |
785 SetTestingHashSeed(kTestHashSeed); | 864 SetTestingHashSeed(kTestHashSeed); |
786 | 865 |
787 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 866 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
788 mock_delegate().ExpectCallsToGetterMethods(); | 867 mock_delegate().ExpectCallsToGetterMethods(); |
789 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 868 mock_delegate().ExpectCallToShowPrompt(); |
790 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); | 869 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 870 EXPECT_CALL(resetter(), ReportPromptResult( |
| 871 AutomaticProfileResetter::PROMPT_IGNORED)); |
791 | 872 |
792 UnleashResetterAndWait(); | 873 UnleashResetterAndWait(); |
| 874 resetter().NotifyDidShowResetBubble(); |
| 875 ShutdownResetter(); |
793 | 876 |
794 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 877 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
795 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 878 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
796 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 879 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
797 } | 880 } |
798 | 881 |
799 TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) { | 882 TEST_F(AutomaticProfileResetterTest, PromptActionReset) { |
800 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 883 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
801 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 884 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
802 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 885 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
803 | 886 |
804 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 887 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
805 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 888 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
806 EXPECT_EQ("", memento_in_file.ReadValue()); | 889 EXPECT_EQ("", memento_in_file.ReadValue()); |
807 | 890 |
808 SetTestingProgram(ConstructProgram(false, true)); | 891 SetTestingProgram(ConstructProgram(true, true)); |
809 SetTestingHashSeed(kTestHashSeed); | 892 SetTestingHashSeed(kTestHashSeed); |
810 | 893 |
811 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 894 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
812 mock_delegate().ExpectCallsToGetterMethods(); | 895 mock_delegate().ExpectCallsToGetterMethods(); |
813 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 896 mock_delegate().ExpectCallToShowPrompt(); |
814 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); | 897 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
815 | 898 |
816 UnleashResetterAndWait(); | 899 UnleashResetterAndWait(); |
817 | 900 |
818 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 901 testing::Mock::VerifyAndClearExpectations(&resetter()); |
819 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 902 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
820 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 903 |
| 904 mock_delegate().ExpectCallToTriggerReset(false); |
| 905 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 906 EXPECT_CALL(resetter(), ReportPromptResult( |
| 907 AutomaticProfileResetter::PROMPT_ACTION_RESET)); |
| 908 |
| 909 resetter().NotifyDidShowResetBubble(); |
| 910 resetter().TriggerProfileReset(false /*send_feedback*/); |
| 911 |
| 912 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 913 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 914 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 915 |
| 916 ShutdownResetter(); |
| 917 } |
| 918 |
| 919 TEST_F(AutomaticProfileResetterTest, PromptActionResetWithFeedback) { |
| 920 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 921 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 922 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 923 |
| 924 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 925 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 926 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 927 |
| 928 SetTestingProgram(ConstructProgram(true, true)); |
| 929 SetTestingHashSeed(kTestHashSeed); |
| 930 |
| 931 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 932 mock_delegate().ExpectCallsToGetterMethods(); |
| 933 mock_delegate().ExpectCallToShowPrompt(); |
| 934 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 935 |
| 936 UnleashResetterAndWait(); |
| 937 |
| 938 testing::Mock::VerifyAndClearExpectations(&resetter()); |
| 939 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
| 940 |
| 941 mock_delegate().ExpectCallToTriggerReset(true); |
| 942 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 943 EXPECT_CALL(resetter(), ReportPromptResult( |
| 944 AutomaticProfileResetter::PROMPT_ACTION_RESET)); |
| 945 |
| 946 resetter().NotifyDidShowResetBubble(); |
| 947 resetter().TriggerProfileReset(true /*send_feedback*/); |
| 948 |
| 949 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 950 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 951 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 952 |
| 953 ShutdownResetter(); |
| 954 } |
| 955 |
| 956 TEST_F(AutomaticProfileResetterTest, PromptActionNoReset) { |
| 957 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 958 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 959 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 960 |
| 961 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 962 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 963 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 964 |
| 965 SetTestingProgram(ConstructProgram(true, true)); |
| 966 SetTestingHashSeed(kTestHashSeed); |
| 967 |
| 968 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 969 mock_delegate().ExpectCallsToGetterMethods(); |
| 970 mock_delegate().ExpectCallToShowPrompt(); |
| 971 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 972 |
| 973 UnleashResetterAndWait(); |
| 974 |
| 975 testing::Mock::VerifyAndClearExpectations(&resetter()); |
| 976 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
| 977 |
| 978 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 979 EXPECT_CALL(resetter(), ReportPromptResult( |
| 980 AutomaticProfileResetter::PROMPT_ACTION_NO_RESET)); |
| 981 |
| 982 resetter().NotifyDidShowResetBubble(); |
| 983 resetter().SkipProfileReset(); |
| 984 |
| 985 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 986 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 987 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 988 |
| 989 ShutdownResetter(); |
| 990 } |
| 991 |
| 992 TEST_F(AutomaticProfileResetterTest, PromptFollowedByWebUIReset) { |
| 993 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 994 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 995 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 996 |
| 997 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 998 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 999 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 1000 |
| 1001 SetTestingProgram(ConstructProgram(true, true)); |
| 1002 SetTestingHashSeed(kTestHashSeed); |
| 1003 |
| 1004 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 1005 mock_delegate().ExpectCallsToGetterMethods(); |
| 1006 mock_delegate().ExpectCallToShowPrompt(); |
| 1007 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 1008 |
| 1009 UnleashResetterAndWait(); |
| 1010 |
| 1011 testing::Mock::VerifyAndClearExpectations(&resetter()); |
| 1012 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
| 1013 |
| 1014 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 1015 EXPECT_CALL(resetter(), ReportPromptResult( |
| 1016 AutomaticProfileResetter::PROMPT_FOLLOWED_BY_WEBUI_RESET)); |
| 1017 |
| 1018 resetter().NotifyDidShowResetBubble(); |
| 1019 resetter().NotifyDidOpenWebUIResetDialog(); |
| 1020 resetter().NotifyDidCloseWebUIResetDialog(true); |
| 1021 |
| 1022 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 1023 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 1024 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 1025 |
| 1026 ShutdownResetter(); |
| 1027 } |
| 1028 |
| 1029 TEST_F(AutomaticProfileResetterTest, PromptFollowedByWebUINoReset) { |
| 1030 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 1031 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 1032 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 1033 |
| 1034 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 1035 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 1036 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 1037 |
| 1038 SetTestingProgram(ConstructProgram(true, true)); |
| 1039 SetTestingHashSeed(kTestHashSeed); |
| 1040 |
| 1041 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 1042 mock_delegate().ExpectCallsToGetterMethods(); |
| 1043 mock_delegate().ExpectCallToShowPrompt(); |
| 1044 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 1045 |
| 1046 UnleashResetterAndWait(); |
| 1047 |
| 1048 testing::Mock::VerifyAndClearExpectations(&resetter()); |
| 1049 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
| 1050 |
| 1051 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 1052 EXPECT_CALL(resetter(), ReportPromptResult( |
| 1053 AutomaticProfileResetter::PROMPT_FOLLOWED_BY_WEBUI_NO_RESET)); |
| 1054 |
| 1055 resetter().NotifyDidShowResetBubble(); |
| 1056 resetter().NotifyDidOpenWebUIResetDialog(); |
| 1057 resetter().NotifyDidCloseWebUIResetDialog(false); |
| 1058 |
| 1059 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 1060 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 1061 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 1062 |
| 1063 ShutdownResetter(); |
| 1064 } |
| 1065 |
| 1066 TEST_F(AutomaticProfileResetterTest, PromptSuppressedButHadWebUIReset) { |
| 1067 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 1068 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 1069 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 1070 |
| 1071 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 1072 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 1073 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 1074 |
| 1075 SetTestingProgram(ConstructProgram(true, true)); |
| 1076 SetTestingHashSeed(kTestHashSeed); |
| 1077 |
| 1078 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 1079 mock_delegate().ExpectCallsToGetterMethods(); |
| 1080 mock_delegate().ExpectCallToShowPrompt(); |
| 1081 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 1082 |
| 1083 UnleashResetterAndWait(); |
| 1084 |
| 1085 testing::Mock::VerifyAndClearExpectations(&resetter()); |
| 1086 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
| 1087 |
| 1088 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 1089 EXPECT_CALL(resetter(), ReportPromptResult( |
| 1090 AutomaticProfileResetter::PROMPT_SUPPRESSED_BUT_HAD_WEBUI_RESET)); |
| 1091 |
| 1092 resetter().NotifyDidOpenWebUIResetDialog(); |
| 1093 resetter().NotifyDidCloseWebUIResetDialog(true); |
| 1094 |
| 1095 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 1096 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 1097 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 1098 |
| 1099 ShutdownResetter(); |
| 1100 } |
| 1101 |
| 1102 TEST_F(AutomaticProfileResetterTest, PromptSuppressedButHadWebUINoReset) { |
| 1103 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 1104 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 1105 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 1106 |
| 1107 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 1108 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 1109 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 1110 |
| 1111 SetTestingProgram(ConstructProgram(true, true)); |
| 1112 SetTestingHashSeed(kTestHashSeed); |
| 1113 |
| 1114 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 1115 mock_delegate().ExpectCallsToGetterMethods(); |
| 1116 mock_delegate().ExpectCallToShowPrompt(); |
| 1117 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 1118 |
| 1119 UnleashResetterAndWait(); |
| 1120 |
| 1121 testing::Mock::VerifyAndClearExpectations(&resetter()); |
| 1122 testing::Mock::VerifyAndClearExpectations(&mock_delegate()); |
| 1123 |
| 1124 EXPECT_CALL(mock_delegate(), DismissPrompt()); |
| 1125 EXPECT_CALL(resetter(), ReportPromptResult( |
| 1126 AutomaticProfileResetter::PROMPT_SUPPRESSED_BUT_HAD_WEBUI_NO_RESET)); |
| 1127 |
| 1128 resetter().NotifyDidOpenWebUIResetDialog(); |
| 1129 resetter().NotifyDidCloseWebUIResetDialog(false); |
| 1130 |
| 1131 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 1132 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 1133 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 1134 |
| 1135 ShutdownResetter(); |
821 } | 1136 } |
822 | 1137 |
823 #if defined(GOOGLE_CHROME_BUILD) | 1138 #if defined(GOOGLE_CHROME_BUILD) |
824 TEST_F(AutomaticProfileResetterTest, ProgramSetThroughVariationParams) { | 1139 TEST_F(AutomaticProfileResetterTest, ProgramSetThroughVariationParams) { |
825 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1140 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
826 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 1141 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
827 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 1142 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
828 | 1143 |
829 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 1144 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
830 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 1145 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
831 EXPECT_EQ("", memento_in_file.ReadValue()); | 1146 EXPECT_EQ("", memento_in_file.ReadValue()); |
832 | 1147 |
833 SetTestingProgram(ConstructProgram(true, true)); | 1148 SetTestingProgram(ConstructProgram(true, true)); |
834 SetTestingHashSeed(kTestHashSeed); | 1149 SetTestingHashSeed(kTestHashSeed); |
835 AllowInjectingTestDataThroughVariationParams(true); | 1150 AllowInjectingTestDataThroughVariationParams(true); |
836 | 1151 |
837 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1152 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
838 mock_delegate().ExpectCallsToGetterMethods(); | 1153 mock_delegate().ExpectCallsToGetterMethods(); |
839 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 1154 mock_delegate().ExpectCallToShowPrompt(); |
840 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 1155 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 1156 EXPECT_CALL(resetter(), ReportPromptResult( |
| 1157 AutomaticProfileResetter::PROMPT_IGNORED)); |
841 | 1158 |
842 UnleashResetterAndWait(); | 1159 UnleashResetterAndWait(); |
| 1160 resetter().NotifyDidShowResetBubble(); |
| 1161 ShutdownResetter(); |
843 | 1162 |
844 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 1163 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
845 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 1164 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
846 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 1165 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
847 } | 1166 } |
848 #endif | 1167 #endif |
849 | 1168 |
850 TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) { | 1169 TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) { |
851 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1170 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
852 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 1171 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
853 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 1172 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
854 | 1173 |
855 memento_in_prefs.StoreValue(kTestInvalidMementoValue); | 1174 memento_in_prefs.StoreValue(kTestInvalidMementoValue); |
856 memento_in_local_state.StoreValue(kTestInvalidMementoValue); | 1175 memento_in_local_state.StoreValue(kTestInvalidMementoValue); |
857 memento_in_file.StoreValue(kTestInvalidMementoValue); | 1176 memento_in_file.StoreValue(kTestInvalidMementoValue); |
858 | 1177 |
859 SetTestingProgram(ConstructProgram(true, true)); | 1178 SetTestingProgram(ConstructProgram(true, true)); |
860 SetTestingHashSeed(kTestHashSeed); | 1179 SetTestingHashSeed(kTestHashSeed); |
861 | 1180 |
862 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1181 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
863 mock_delegate().ExpectCallsToGetterMethods(); | 1182 mock_delegate().ExpectCallsToGetterMethods(); |
864 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 1183 mock_delegate().ExpectCallToShowPrompt(); |
865 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); | 1184 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 1185 EXPECT_CALL(resetter(), ReportPromptResult( |
| 1186 AutomaticProfileResetter::PROMPT_IGNORED)); |
866 | 1187 |
867 UnleashResetterAndWait(); | 1188 UnleashResetterAndWait(); |
| 1189 resetter().NotifyDidShowResetBubble(); |
| 1190 ShutdownResetter(); |
868 | 1191 |
869 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 1192 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
870 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 1193 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
871 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 1194 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
872 } | 1195 } |
873 | 1196 |
874 TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) { | 1197 TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) { |
875 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1198 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
876 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 1199 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
877 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 1200 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
878 | 1201 |
879 memento_in_prefs.StoreValue(kTestMementoValue); | 1202 memento_in_prefs.StoreValue(kTestMementoValue); |
880 | 1203 |
881 SetTestingProgram(ConstructProgram(true, true)); | 1204 SetTestingProgram(ConstructProgram(true, true)); |
882 SetTestingHashSeed(kTestHashSeed); | 1205 SetTestingHashSeed(kTestHashSeed); |
883 | 1206 |
884 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1207 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
885 mock_delegate().ExpectCallsToGetterMethods(); | 1208 mock_delegate().ExpectCallsToGetterMethods(); |
886 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); | 1209 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); |
887 | 1210 |
888 UnleashResetterAndWait(); | 1211 UnleashResetterAndWait(); |
| 1212 ShutdownResetter(); |
889 | 1213 |
890 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 1214 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
891 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 1215 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
892 EXPECT_EQ("", memento_in_file.ReadValue()); | 1216 EXPECT_EQ("", memento_in_file.ReadValue()); |
893 } | 1217 } |
894 | 1218 |
895 TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) { | 1219 TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) { |
896 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1220 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
897 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 1221 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
898 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 1222 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
899 | 1223 |
900 memento_in_local_state.StoreValue(kTestMementoValue); | 1224 memento_in_local_state.StoreValue(kTestMementoValue); |
901 | 1225 |
902 SetTestingProgram(ConstructProgram(true, true)); | 1226 SetTestingProgram(ConstructProgram(true, true)); |
903 SetTestingHashSeed(kTestHashSeed); | 1227 SetTestingHashSeed(kTestHashSeed); |
904 | 1228 |
905 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1229 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
906 mock_delegate().ExpectCallsToGetterMethods(); | 1230 mock_delegate().ExpectCallsToGetterMethods(); |
907 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); | 1231 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); |
908 | 1232 |
909 UnleashResetterAndWait(); | 1233 UnleashResetterAndWait(); |
| 1234 ShutdownResetter(); |
910 | 1235 |
911 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 1236 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
912 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 1237 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
913 EXPECT_EQ("", memento_in_file.ReadValue()); | 1238 EXPECT_EQ("", memento_in_file.ReadValue()); |
914 } | 1239 } |
915 | 1240 |
916 TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) { | 1241 TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) { |
917 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1242 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
918 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 1243 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
919 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 1244 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
920 | 1245 |
921 memento_in_file.StoreValue(kTestMementoValue); | 1246 memento_in_file.StoreValue(kTestMementoValue); |
922 | 1247 |
923 SetTestingProgram(ConstructProgram(true, true)); | 1248 SetTestingProgram(ConstructProgram(true, true)); |
924 SetTestingHashSeed(kTestHashSeed); | 1249 SetTestingHashSeed(kTestHashSeed); |
925 | 1250 |
926 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1251 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
927 mock_delegate().ExpectCallsToGetterMethods(); | 1252 mock_delegate().ExpectCallsToGetterMethods(); |
928 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); | 1253 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); |
929 | 1254 |
930 UnleashResetterAndWait(); | 1255 UnleashResetterAndWait(); |
| 1256 ShutdownResetter(); |
931 | 1257 |
932 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 1258 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
933 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 1259 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
934 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 1260 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
935 } | 1261 } |
936 | 1262 |
937 TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) { | 1263 TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) { |
938 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 1264 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
939 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 1265 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
940 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 1266 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
941 | 1267 |
942 SetTestingProgram(""); | 1268 SetTestingProgram(""); |
943 SetTestingHashSeed(""); | 1269 SetTestingHashSeed(""); |
944 | 1270 |
945 // No calls are expected to the delegate. | 1271 // No calls are expected to the delegate. |
946 | 1272 |
947 UnleashResetterAndWait(); | 1273 UnleashResetterAndWait(); |
| 1274 ShutdownResetter(); |
948 | 1275 |
949 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 1276 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
950 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 1277 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
951 EXPECT_EQ("", memento_in_file.ReadValue()); | 1278 EXPECT_EQ("", memento_in_file.ReadValue()); |
952 } | 1279 } |
953 | 1280 |
954 // Please see comments above ConstructProgramToCheckPreferences() to understand | 1281 // Please see comments above ConstructProgramToCheckPreferences() to understand |
955 // how the following tests work. | 1282 // how the following tests work. |
956 | 1283 |
957 TEST_F(AutomaticProfileResetterTest, InputUserPreferencesCorrect) { | 1284 TEST_F(AutomaticProfileResetterTest, InputUserPreferencesCorrect) { |
958 SetTestingProgram(ConstructProgramToCheckPreferences()); | 1285 SetTestingProgram(ConstructProgramToCheckPreferences()); |
959 SetTestingHashSeed(kTestHashSeed); | 1286 SetTestingHashSeed(kTestHashSeed); |
960 | 1287 |
961 PrefService* prefs = profile()->GetPrefs(); | 1288 PrefService* prefs = profile()->GetPrefs(); |
962 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); | 1289 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); |
963 | 1290 |
964 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1291 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
965 mock_delegate().ExpectCallsToGetterMethods(); | 1292 mock_delegate().ExpectCallsToGetterMethods(); |
966 uint32 expected_mask = | 1293 uint32 expected_mask = HAS_EXPECTED_USER_PREFERENCE | |
967 HAS_EXPECTED_USER_PREFERENCE | USER_PREFERENCE_IS_USER_CONTROLLED; | 1294 USER_PREFERENCE_IS_USER_CONTROLLED; |
968 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); | 1295 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
969 | 1296 |
970 UnleashResetterAndWait(); | 1297 UnleashResetterAndWait(); |
971 } | 1298 } |
972 | 1299 |
973 TEST_F(AutomaticProfileResetterTest, InputLocalStateCorrect) { | 1300 TEST_F(AutomaticProfileResetterTest, InputLocalStateCorrect) { |
974 SetTestingProgram(ConstructProgramToCheckPreferences()); | 1301 SetTestingProgram(ConstructProgramToCheckPreferences()); |
975 SetTestingHashSeed(kTestHashSeed); | 1302 SetTestingHashSeed(kTestHashSeed); |
976 | 1303 |
977 PrefService* prefs = local_state(); | 1304 PrefService* prefs = local_state(); |
978 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); | 1305 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); |
979 | 1306 |
980 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1307 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
981 mock_delegate().ExpectCallsToGetterMethods(); | 1308 mock_delegate().ExpectCallsToGetterMethods(); |
982 uint32 expected_mask = | 1309 uint32 expected_mask = HAS_EXPECTED_LOCAL_STATE_PREFERENCE | |
983 HAS_EXPECTED_LOCAL_STATE_PREFERENCE | LOCAL_STATE_IS_USER_CONTROLLED; | 1310 LOCAL_STATE_IS_USER_CONTROLLED; |
984 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); | 1311 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
985 | 1312 |
986 UnleashResetterAndWait(); | 1313 UnleashResetterAndWait(); |
987 } | 1314 } |
988 | 1315 |
989 TEST_F(AutomaticProfileResetterTest, InputManagedUserPreferencesCorrect) { | 1316 TEST_F(AutomaticProfileResetterTest, InputManagedUserPreferencesCorrect) { |
990 SetTestingProgram(ConstructProgramToCheckPreferences()); | 1317 SetTestingProgram(ConstructProgramToCheckPreferences()); |
991 SetTestingHashSeed(kTestHashSeed); | 1318 SetTestingHashSeed(kTestHashSeed); |
992 | 1319 |
993 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); | 1320 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); | 1416 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
1090 mock_delegate().ExpectCallsToGetterMethods(); | 1417 mock_delegate().ExpectCallsToGetterMethods(); |
1091 uint32 expected_mask = | 1418 uint32 expected_mask = |
1092 HAS_EXPECTED_MODULE_DIGEST_1 | HAS_EXPECTED_MODULE_DIGEST_2; | 1419 HAS_EXPECTED_MODULE_DIGEST_1 | HAS_EXPECTED_MODULE_DIGEST_2; |
1093 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); | 1420 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
1094 | 1421 |
1095 UnleashResetterAndWait(); | 1422 UnleashResetterAndWait(); |
1096 } | 1423 } |
1097 | 1424 |
1098 } // namespace | 1425 } // namespace |
OLD | NEW |