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

Unified Diff: chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc

Issue 62193002: Integrate UI and reset logic into AutomaticProfileResetter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests, some other smaller changes. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc
diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc b/chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc
index ed7b67ab398c1c5f04b611c1a130a01934c1b533..bf003d0880a0c75af0c7c0c9c6ad079cb35338c3 100644
--- a/chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc
@@ -33,6 +33,7 @@
using testing::_;
using testing::Invoke;
+using testing::WithArgs;
namespace {
@@ -66,6 +67,8 @@ class AutomaticProfileResetterUnderTest : public AutomaticProfileResetter {
virtual ~AutomaticProfileResetterUnderTest() {}
MOCK_METHOD2(ReportStatistics, void(uint32, uint32));
+ MOCK_METHOD1(ReportPromptResult,
+ void(AutomaticProfileResetter::PromptResult));
private:
DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterUnderTest);
@@ -85,12 +88,18 @@ class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate {
MOCK_CONST_METHOD1(RequestCallbackWhenTemplateURLServiceIsLoaded,
void(const base::Closure&));
+ MOCK_METHOD0(FetchBrandcodedDefaultSettingsIfNeeded, void());
+ MOCK_CONST_METHOD1(RequestCallbackWhenBrandcodedDefaultsAreFetched,
+ void(const base::Closure&));
+
MOCK_CONST_METHOD0(OnGetLoadedModuleNameDigestsCalled, void());
MOCK_CONST_METHOD0(OnGetDefaultSearchProviderDetailsCalled, void());
MOCK_CONST_METHOD0(OnIsDefaultSearchProviderManagedCalled, void());
MOCK_CONST_METHOD0(OnGetPrepopulatedSearchProvidersDetailsCalled, void());
MOCK_METHOD0(ShowPrompt, void());
+ MOCK_METHOD2(TriggerProfileSettingsReset, void(bool, const base::Closure&));
+ MOCK_METHOD0(DismissPrompt, void());
virtual scoped_ptr<base::ListValue>
GetLoadedModuleNameDigests() const OVERRIDE {
@@ -136,6 +145,16 @@ class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate {
EXPECT_CALL(*this, OnGetPrepopulatedSearchProvidersDetailsCalled());
}
+ void ExpectCallToShowPrompt() {
+ EXPECT_CALL(*this, ShowPrompt());
+ EXPECT_CALL(*this, FetchBrandcodedDefaultSettingsIfNeeded());
+ }
+
+ void ExpectCallToTriggerReset(bool send_feedback) {
+ EXPECT_CALL(*this, TriggerProfileSettingsReset(send_feedback, _))
+ .WillOnce(WithArgs<1>(Invoke(ClosureInvoker)));
+ }
+
base::DictionaryValue& emulated_default_search_provider_details() {
return emulated_default_search_provider_details_;
}
@@ -424,8 +443,7 @@ class AutomaticProfileResetterTestBase : public testing::Test {
profile_->GetTestingPrefService()->registry();
DCHECK(user_prefs_registry);
user_prefs_registry->RegisterStringPref(
- kTestPreferencePath,
- "",
+ kTestPreferencePath, "",
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
@@ -483,6 +501,11 @@ class AutomaticProfileResetterTestBase : public testing::Test {
base::RunLoop().RunUntilIdle();
}
+ void ShutdownResetter() {
+ resetter_->Shutdown();
+ resetter_.reset();
+ }
+
TestingProfile* profile() { return profile_.get(); }
TestingPrefServiceSimple* local_state() { return local_state_.Get(); }
@@ -534,16 +557,13 @@ TEST_F(AutomaticProfileResetterTestDisabled, NothingIsDoneWhenDisabled) {
LocalStateHostedPromptMemento memento_in_local_state(profile());
FileHostedPromptMementoSynchronous memento_in_file(profile());
- EXPECT_EQ("", memento_in_prefs.ReadValue());
- EXPECT_EQ("", memento_in_local_state.ReadValue());
- EXPECT_EQ("", memento_in_file.ReadValue());
-
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
// No calls are expected to the delegate.
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -555,10 +575,6 @@ TEST_F(AutomaticProfileResetterTestDryRun, ConditionsNotSatisfied) {
LocalStateHostedPromptMemento memento_in_local_state(profile());
FileHostedPromptMementoSynchronous memento_in_file(profile());
- EXPECT_EQ("", memento_in_prefs.ReadValue());
- EXPECT_EQ("", memento_in_local_state.ReadValue());
- EXPECT_EQ("", memento_in_file.ReadValue());
-
SetTestingProgram(ConstructProgram(false, false));
SetTestingHashSeed(kTestHashSeed);
@@ -567,6 +583,7 @@ TEST_F(AutomaticProfileResetterTestDryRun, ConditionsNotSatisfied) {
EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u));
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -588,12 +605,16 @@ TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u));
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_NOT_SHOWN));
UnleashResetterAndWait();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
}
TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) {
@@ -611,12 +632,16 @@ TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u));
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_NOT_SHOWN));
UnleashResetterAndWait();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
}
#if defined(GOOGLE_CHROME_BUILD)
@@ -636,12 +661,16 @@ TEST_F(AutomaticProfileResetterTestDryRun, ProgramSetThroughVariationParams) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_NOT_SHOWN));
UnleashResetterAndWait();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
}
#endif
@@ -661,12 +690,16 @@ TEST_F(AutomaticProfileResetterTestDryRun,
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_NOT_SHOWN));
UnleashResetterAndWait();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
}
TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) {
@@ -684,6 +717,7 @@ TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) {
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u));
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -705,6 +739,7 @@ TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) {
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u));
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
@@ -726,6 +761,7 @@ TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) {
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u));
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -743,6 +779,7 @@ TEST_F(AutomaticProfileResetterTestDryRun, DoNothingWhenResourcesAreMissing) {
// No calls are expected to the delegate.
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -754,25 +791,67 @@ TEST_F(AutomaticProfileResetterTest, ConditionsNotSatisfied) {
LocalStateHostedPromptMemento memento_in_local_state(profile());
FileHostedPromptMementoSynchronous memento_in_file(profile());
+ SetTestingProgram(ConstructProgram(false, false));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u));
+
+ UnleashResetterAndWait();
+ ShutdownResetter();
+
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
EXPECT_EQ("", memento_in_file.ReadValue());
+}
- SetTestingProgram(ConstructProgram(false, false));
+TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) {
+ SetTestingProgram(ConstructProgram(true, false));
SetTestingHashSeed(kTestHashSeed);
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u));
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u));
UnleashResetterAndWait();
+}
+
+TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) {
+ SetTestingProgram(ConstructProgram(false, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u));
+
+ UnleashResetterAndWait();
+}
+
+TEST_F(AutomaticProfileResetterTest, PromptSuppressed) {
+ PreferenceHostedPromptMemento memento_in_prefs(profile());
+ LocalStateHostedPromptMemento memento_in_local_state(profile());
+ FileHostedPromptMementoSynchronous memento_in_file(profile());
+
+ SetTestingProgram(ConstructProgram(true, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+
+ UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
EXPECT_EQ("", memento_in_file.ReadValue());
}
-TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) {
+TEST_F(AutomaticProfileResetterTest, PromptIgnored) {
PreferenceHostedPromptMemento memento_in_prefs(profile());
LocalStateHostedPromptMemento memento_in_local_state(profile());
FileHostedPromptMementoSynchronous memento_in_file(profile());
@@ -781,22 +860,26 @@ TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) {
EXPECT_EQ("", memento_in_local_state.ReadValue());
EXPECT_EQ("", memento_in_file.ReadValue());
- SetTestingProgram(ConstructProgram(true, false));
+ SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- EXPECT_CALL(mock_delegate(), ShowPrompt());
- EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u));
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_IGNORED));
UnleashResetterAndWait();
+ resetter().NotifyDidShowResetBubble();
+ ShutdownResetter();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
}
-TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) {
+TEST_F(AutomaticProfileResetterTest, PromptActionReset) {
PreferenceHostedPromptMemento memento_in_prefs(profile());
LocalStateHostedPromptMemento memento_in_local_state(profile());
FileHostedPromptMementoSynchronous memento_in_file(profile());
@@ -805,19 +888,251 @@ TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) {
EXPECT_EQ("", memento_in_local_state.ReadValue());
EXPECT_EQ("", memento_in_file.ReadValue());
- SetTestingProgram(ConstructProgram(false, true));
+ SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- EXPECT_CALL(mock_delegate(), ShowPrompt());
- EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u));
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+
+ UnleashResetterAndWait();
+
+ testing::Mock::VerifyAndClearExpectations(&resetter());
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate());
+
+ mock_delegate().ExpectCallToTriggerReset(false);
+ EXPECT_CALL(mock_delegate(), DismissPrompt());
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_ACTION_RESET));
+
+ resetter().NotifyDidShowResetBubble();
+ resetter().TriggerProfileReset(false /*send_feedback*/);
+
+ EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
+}
+
+TEST_F(AutomaticProfileResetterTest, PromptActionResetWithFeedback) {
+ PreferenceHostedPromptMemento memento_in_prefs(profile());
+ LocalStateHostedPromptMemento memento_in_local_state(profile());
+ FileHostedPromptMementoSynchronous memento_in_file(profile());
+
+ EXPECT_EQ("", memento_in_prefs.ReadValue());
+ EXPECT_EQ("", memento_in_local_state.ReadValue());
+ EXPECT_EQ("", memento_in_file.ReadValue());
+
+ SetTestingProgram(ConstructProgram(true, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+
+ UnleashResetterAndWait();
+
+ testing::Mock::VerifyAndClearExpectations(&resetter());
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate());
+
+ mock_delegate().ExpectCallToTriggerReset(true);
+ EXPECT_CALL(mock_delegate(), DismissPrompt());
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_ACTION_RESET));
+
+ resetter().NotifyDidShowResetBubble();
+ resetter().TriggerProfileReset(true /*send_feedback*/);
+
+ EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
+}
+
+TEST_F(AutomaticProfileResetterTest, PromptActionNoReset) {
+ PreferenceHostedPromptMemento memento_in_prefs(profile());
+ LocalStateHostedPromptMemento memento_in_local_state(profile());
+ FileHostedPromptMementoSynchronous memento_in_file(profile());
+
+ EXPECT_EQ("", memento_in_prefs.ReadValue());
+ EXPECT_EQ("", memento_in_local_state.ReadValue());
+ EXPECT_EQ("", memento_in_file.ReadValue());
+
+ SetTestingProgram(ConstructProgram(true, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+
+ UnleashResetterAndWait();
+
+ testing::Mock::VerifyAndClearExpectations(&resetter());
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate());
+
+ EXPECT_CALL(mock_delegate(), DismissPrompt());
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_ACTION_NO_RESET));
+
+ resetter().NotifyDidShowResetBubble();
+ resetter().SkipProfileReset();
+
+ EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
+}
+
+TEST_F(AutomaticProfileResetterTest, PromptFollowedByWebUIReset) {
+ PreferenceHostedPromptMemento memento_in_prefs(profile());
+ LocalStateHostedPromptMemento memento_in_local_state(profile());
+ FileHostedPromptMementoSynchronous memento_in_file(profile());
+
+ EXPECT_EQ("", memento_in_prefs.ReadValue());
+ EXPECT_EQ("", memento_in_local_state.ReadValue());
+ EXPECT_EQ("", memento_in_file.ReadValue());
+
+ SetTestingProgram(ConstructProgram(true, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
UnleashResetterAndWait();
+ testing::Mock::VerifyAndClearExpectations(&resetter());
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate());
+
+ EXPECT_CALL(mock_delegate(), DismissPrompt());
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_FOLLOWED_BY_WEBUI_RESET));
+
+ resetter().NotifyDidShowResetBubble();
+ resetter().NotifyDidOpenWebUIResetDialog();
+ resetter().NotifyDidCloseWebUIResetDialog(true);
+
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
+}
+
+TEST_F(AutomaticProfileResetterTest, PromptFollowedByWebUINoReset) {
+ PreferenceHostedPromptMemento memento_in_prefs(profile());
+ LocalStateHostedPromptMemento memento_in_local_state(profile());
+ FileHostedPromptMementoSynchronous memento_in_file(profile());
+
+ EXPECT_EQ("", memento_in_prefs.ReadValue());
+ EXPECT_EQ("", memento_in_local_state.ReadValue());
+ EXPECT_EQ("", memento_in_file.ReadValue());
+
+ SetTestingProgram(ConstructProgram(true, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+
+ UnleashResetterAndWait();
+
+ testing::Mock::VerifyAndClearExpectations(&resetter());
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate());
+
+ EXPECT_CALL(mock_delegate(), DismissPrompt());
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_FOLLOWED_BY_WEBUI_NO_RESET));
+
+ resetter().NotifyDidShowResetBubble();
+ resetter().NotifyDidOpenWebUIResetDialog();
+ resetter().NotifyDidCloseWebUIResetDialog(false);
+
+ EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
+}
+
+TEST_F(AutomaticProfileResetterTest, PromptSuppressedButHadWebUIReset) {
+ PreferenceHostedPromptMemento memento_in_prefs(profile());
+ LocalStateHostedPromptMemento memento_in_local_state(profile());
+ FileHostedPromptMementoSynchronous memento_in_file(profile());
+
+ EXPECT_EQ("", memento_in_prefs.ReadValue());
+ EXPECT_EQ("", memento_in_local_state.ReadValue());
+ EXPECT_EQ("", memento_in_file.ReadValue());
+
+ SetTestingProgram(ConstructProgram(true, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+
+ UnleashResetterAndWait();
+
+ testing::Mock::VerifyAndClearExpectations(&resetter());
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate());
+
+ EXPECT_CALL(mock_delegate(), DismissPrompt());
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_SUPPRESSED_BUT_HAD_WEBUI_RESET));
+
+ resetter().NotifyDidOpenWebUIResetDialog();
+ resetter().NotifyDidCloseWebUIResetDialog(true);
+
+ EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
+}
+
+TEST_F(AutomaticProfileResetterTest, PromptSuppressedButHadWebUINoReset) {
+ PreferenceHostedPromptMemento memento_in_prefs(profile());
+ LocalStateHostedPromptMemento memento_in_local_state(profile());
+ FileHostedPromptMementoSynchronous memento_in_file(profile());
+
+ EXPECT_EQ("", memento_in_prefs.ReadValue());
+ EXPECT_EQ("", memento_in_local_state.ReadValue());
+ EXPECT_EQ("", memento_in_file.ReadValue());
+
+ SetTestingProgram(ConstructProgram(true, true));
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().ExpectCallsToDependenciesSetUpMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ mock_delegate().ExpectCallToShowPrompt();
+ EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+
+ UnleashResetterAndWait();
+
+ testing::Mock::VerifyAndClearExpectations(&resetter());
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate());
+
+ EXPECT_CALL(mock_delegate(), DismissPrompt());
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_SUPPRESSED_BUT_HAD_WEBUI_NO_RESET));
+
+ resetter().NotifyDidOpenWebUIResetDialog();
+ resetter().NotifyDidCloseWebUIResetDialog(false);
+
+ EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
+ EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue());
+
+ ShutdownResetter();
}
#if defined(GOOGLE_CHROME_BUILD)
@@ -836,10 +1151,14 @@ TEST_F(AutomaticProfileResetterTest, ProgramSetThroughVariationParams) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- EXPECT_CALL(mock_delegate(), ShowPrompt());
+ mock_delegate().ExpectCallToShowPrompt();
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_IGNORED));
UnleashResetterAndWait();
+ resetter().NotifyDidShowResetBubble();
+ ShutdownResetter();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
@@ -861,10 +1180,14 @@ TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- EXPECT_CALL(mock_delegate(), ShowPrompt());
+ mock_delegate().ExpectCallToShowPrompt();
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u));
+ EXPECT_CALL(resetter(), ReportPromptResult(
+ AutomaticProfileResetter::PROMPT_IGNORED));
UnleashResetterAndWait();
+ resetter().NotifyDidShowResetBubble();
+ ShutdownResetter();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
@@ -886,6 +1209,7 @@ TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) {
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u));
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -907,6 +1231,7 @@ TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) {
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u));
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue());
@@ -928,6 +1253,7 @@ TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) {
EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u));
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -945,6 +1271,7 @@ TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) {
// No calls are expected to the delegate.
UnleashResetterAndWait();
+ ShutdownResetter();
EXPECT_EQ("", memento_in_prefs.ReadValue());
EXPECT_EQ("", memento_in_local_state.ReadValue());
@@ -963,8 +1290,8 @@ TEST_F(AutomaticProfileResetterTest, InputUserPreferencesCorrect) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- uint32 expected_mask =
- HAS_EXPECTED_USER_PREFERENCE | USER_PREFERENCE_IS_USER_CONTROLLED;
+ uint32 expected_mask = HAS_EXPECTED_USER_PREFERENCE |
+ USER_PREFERENCE_IS_USER_CONTROLLED;
EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask));
UnleashResetterAndWait();
@@ -979,8 +1306,8 @@ TEST_F(AutomaticProfileResetterTest, InputLocalStateCorrect) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- uint32 expected_mask =
- HAS_EXPECTED_LOCAL_STATE_PREFERENCE | LOCAL_STATE_IS_USER_CONTROLLED;
+ uint32 expected_mask = HAS_EXPECTED_LOCAL_STATE_PREFERENCE |
+ LOCAL_STATE_IS_USER_CONTROLLED;
EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask));
UnleashResetterAndWait();
@@ -1088,7 +1415,7 @@ TEST_F(AutomaticProfileResetterTest, InputModuleDigestsCorrect) {
mock_delegate().ExpectCallsToDependenciesSetUpMethods();
mock_delegate().ExpectCallsToGetterMethods();
- uint32 expected_mask =
+ uint32 expected_mask =
HAS_EXPECTED_MODULE_DIGEST_1 | HAS_EXPECTED_MODULE_DIGEST_2;
EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask));

Powered by Google App Engine
This is Rietveld 408576698