| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/prefs/testing_pref_service.h" |
| 10 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/test/test_simple_task_runner.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "base/values.h" |
| 12 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h" | 16 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h" |
| 17 #include "chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h" |
| 13 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" | 18 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" |
| 14 #include "chrome/browser/profile_resetter/automatic_profile_resetter_mementos.h" | 19 #include "chrome/browser/profile_resetter/automatic_profile_resetter_mementos.h" |
| 15 #include "chrome/browser/profile_resetter/jtl_foundation.h" | 20 #include "chrome/browser/profile_resetter/jtl_foundation.h" |
| 16 #include "chrome/browser/profile_resetter/jtl_instructions.h" | 21 #include "chrome/browser/profile_resetter/jtl_instructions.h" |
| 17 #include "chrome/test/base/scoped_testing_local_state.h" | 22 #include "chrome/test/base/scoped_testing_local_state.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
| 24 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 26 #include "components/user_prefs/pref_registry_syncable.h" |
| 20 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/test/test_browser_thread_bundle.h" | 28 #include "content/public/test/test_browser_thread_bundle.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 31 |
| 32 using testing::_; |
| 33 using testing::Invoke; |
| 34 using testing::Return; |
| 35 |
| 25 namespace { | 36 namespace { |
| 26 | 37 |
| 27 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; | 38 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; |
| 28 const char kStudyDisabledGroupName[] = "Disabled"; | 39 const char kStudyDisabledGroupName[] = "Disabled"; |
| 29 const char kStudyDryRunGroupName[] = "DryRun"; | 40 const char kStudyDryRunGroupName[] = "DryRun"; |
| 30 const char kStudyEnabledGroupName[] = "Enabled"; | 41 const char kStudyEnabledGroupName[] = "Enabled"; |
| 31 | 42 |
| 32 const char kTestHashSeed[] = "testing-hash-seed"; | 43 const char kTestHashSeed[] = "testing-hash-seed"; |
| 33 const char kTestMementoValue[] = "01234567890123456789012345678901"; | 44 const char kTestMementoValue[] = "01234567890123456789012345678901"; |
| 34 const char kTestInvalidMementoValue[] = "12345678901234567890123456789012"; | 45 const char kTestInvalidMementoValue[] = "12345678901234567890123456789012"; |
| 35 | 46 |
| 47 const char kTestPreferencePath[] = "testing.preference"; |
| 48 const char kTestPreferenceValue[] = "testing-preference-value"; |
| 49 |
| 50 const char kSearchURLAttributeKey[] = "search_url"; |
| 51 const char kTestSearchURL[] = "http://example.com/search?q={searchTerms}"; |
| 52 const char kTestSearchURL2[] = "http://google.com/?q={searchTerms}"; |
| 53 |
| 54 const char kTestModuleDigest[] = "01234567890123456789012345678901"; |
| 55 const char kTestModuleDigest2[] = "12345678901234567890123456789012"; |
| 56 |
| 36 // Helpers ------------------------------------------------------------------ | 57 // Helpers ------------------------------------------------------------------ |
| 37 | 58 |
| 59 // A testing version of the AutomaticProfileResetter that differs from the real |
| 60 // one only in that it has its statistics reporting mocked out for verification. |
| 61 class AutomaticProfileResetterUnderTest : public AutomaticProfileResetter { |
| 62 public: |
| 63 explicit AutomaticProfileResetterUnderTest(Profile* profile) |
| 64 : AutomaticProfileResetter(profile) {} |
| 65 virtual ~AutomaticProfileResetterUnderTest() {} |
| 66 |
| 67 MOCK_METHOD2(ReportStatistics, void(uint32, uint32)); |
| 68 |
| 69 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterUnderTest); |
| 71 }; |
| 72 |
| 38 class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate { | 73 class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate { |
| 39 public: | 74 public: |
| 40 MockProfileResetterDelegate() {} | 75 MockProfileResetterDelegate() |
| 76 : emulated_default_search_provider_is_managed_(false) {} |
| 41 virtual ~MockProfileResetterDelegate() {} | 77 virtual ~MockProfileResetterDelegate() {} |
| 42 | 78 |
| 79 MOCK_METHOD0(EnumerateLoadedModulesIfNeeded, void()); |
| 80 MOCK_CONST_METHOD1(RequestCallbackWhenLoadedModulesAreEnumerated, |
| 81 void(const base::Closure&)); |
| 82 |
| 83 MOCK_METHOD0(LoadTemplateURLServiceIfNeeded, void()); |
| 84 MOCK_CONST_METHOD1(RequestCallbackWhenTemplateURLServiceIsLoaded, |
| 85 void(const base::Closure&)); |
| 86 |
| 87 MOCK_CONST_METHOD0(GetLoadedModuleNameDigests, base::ListValue*()); |
| 88 |
| 89 MOCK_CONST_METHOD0(GetDefaultSearchProviderDetails, base::DictionaryValue*()); |
| 90 MOCK_CONST_METHOD0(IsDefaultSearchProviderManaged, bool()); |
| 91 MOCK_CONST_METHOD0(GetPrepopulatedSearchProvidersDetails, base::ListValue*()); |
| 92 |
| 43 MOCK_METHOD0(ShowPrompt, void()); | 93 MOCK_METHOD0(ShowPrompt, void()); |
| 44 MOCK_METHOD2(ReportStatistics, void(uint32, uint32)); | 94 |
| 95 static void ClosureInvoker(const base::Closure& closure) { closure.Run(); } |
| 96 |
| 97 void ExpectCallsToDependenciesSetUpMethods() { |
| 98 EXPECT_CALL(*this, EnumerateLoadedModulesIfNeeded()); |
| 99 EXPECT_CALL(*this, LoadTemplateURLServiceIfNeeded()); |
| 100 EXPECT_CALL(*this, RequestCallbackWhenLoadedModulesAreEnumerated(_)) |
| 101 .WillOnce(Invoke(ClosureInvoker)); |
| 102 EXPECT_CALL(*this, RequestCallbackWhenTemplateURLServiceIsLoaded(_)) |
| 103 .WillOnce(Invoke(ClosureInvoker)); |
| 104 } |
| 105 |
| 106 void ExpectCallsToGetterMethods() { |
| 107 EXPECT_CALL(*this, GetDefaultSearchProviderDetails()) |
| 108 .WillRepeatedly(Invoke(&emulated_default_search_provider_details_, |
| 109 &base::DictionaryValue::DeepCopy)); |
| 110 EXPECT_CALL(*this, IsDefaultSearchProviderManaged()) |
| 111 .WillRepeatedly(Return(emulated_default_search_provider_is_managed_)); |
| 112 EXPECT_CALL(*this, GetPrepopulatedSearchProvidersDetails()) |
| 113 .WillRepeatedly(Invoke(&emulated_search_providers_details_, |
| 114 &base::ListValue::DeepCopy)); |
| 115 EXPECT_CALL(*this, GetLoadedModuleNameDigests()).WillRepeatedly( |
| 116 Invoke(&emulated_loaded_module_digests_, &base::ListValue::DeepCopy)); |
| 117 } |
| 118 |
| 119 base::DictionaryValue& emulated_default_search_provider_details() { |
| 120 return emulated_default_search_provider_details_; |
| 121 } |
| 122 |
| 123 base::ListValue& emulated_search_providers_details() { |
| 124 return emulated_search_providers_details_; |
| 125 } |
| 126 |
| 127 base::ListValue& emulated_loaded_module_digests() { |
| 128 return emulated_loaded_module_digests_; |
| 129 } |
| 130 |
| 131 void set_emulated_default_search_provider_is_managed(bool value) { |
| 132 emulated_default_search_provider_is_managed_ = value; |
| 133 } |
| 45 | 134 |
| 46 private: | 135 private: |
| 136 base::DictionaryValue emulated_default_search_provider_details_; |
| 137 base::ListValue emulated_search_providers_details_; |
| 138 base::ListValue emulated_loaded_module_digests_; |
| 139 bool emulated_default_search_provider_is_managed_; |
| 140 |
| 47 DISALLOW_COPY_AND_ASSIGN(MockProfileResetterDelegate); | 141 DISALLOW_COPY_AND_ASSIGN(MockProfileResetterDelegate); |
| 48 }; | 142 }; |
| 49 | 143 |
| 50 class FileHostedPromptMementoSynchronous : protected FileHostedPromptMemento { | 144 class FileHostedPromptMementoSynchronous : protected FileHostedPromptMemento { |
| 51 public: | 145 public: |
| 52 explicit FileHostedPromptMementoSynchronous(Profile* profile) | 146 explicit FileHostedPromptMementoSynchronous(Profile* profile) |
| 53 : FileHostedPromptMemento(profile) {} | 147 : FileHostedPromptMemento(profile) {} |
| 54 | 148 |
| 55 std::string ReadValue() const { | 149 std::string ReadValue() const { |
| 56 std::string result; | 150 std::string result; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 72 DISALLOW_COPY_AND_ASSIGN(FileHostedPromptMementoSynchronous); | 166 DISALLOW_COPY_AND_ASSIGN(FileHostedPromptMementoSynchronous); |
| 73 }; | 167 }; |
| 74 | 168 |
| 75 std::string GetHash(const std::string& input) { | 169 std::string GetHash(const std::string& input) { |
| 76 return jtl_foundation::Hasher(kTestHashSeed).GetHash(input); | 170 return jtl_foundation::Hasher(kTestHashSeed).GetHash(input); |
| 77 } | 171 } |
| 78 | 172 |
| 79 // Encodes a Boolean argument value into JTL bytecode. | 173 // Encodes a Boolean argument value into JTL bytecode. |
| 80 std::string EncodeBool(bool value) { return value ? VALUE_TRUE : VALUE_FALSE; } | 174 std::string EncodeBool(bool value) { return value ? VALUE_TRUE : VALUE_FALSE; } |
| 81 | 175 |
| 82 // Constructs a simple evaluation program to test that input/output works well. | 176 // Constructs a simple evaluation program to test that basic input/output works |
| 83 // It will emulate a scenario in which the reset criteria are satisfied as | 177 // well. It will emulate a scenario in which the reset criteria are satisfied as |
| 84 // prescribed by |emulate_satisfied_criterion_{1|2}|, and will set bits in the | 178 // prescribed by |emulate_satisfied_criterion_{1|2}|, and will set bits in the |
| 85 // combined status mask according to whether or not the memento values received | 179 // combined status mask according to whether or not the memento values received |
| 86 // in the input were as expected. | 180 // in the input were as expected. |
| 87 // | 181 // |
| 88 // More specifically, the output of the program will be as follows: | 182 // More specifically, the output of the program will be as follows: |
| 89 // { | 183 // { |
| 90 // "satisfied_criteria_mask_bit1": emulate_satisfied_criterion_1, | 184 // "satisfied_criteria_mask_bit1": emulate_satisfied_criterion_1, |
| 91 // "satisfied_criteria_mask_bit2": emulate_satisfied_criterion_2, | 185 // "satisfied_criteria_mask_bit2": emulate_satisfied_criterion_2, |
| 92 // "combined_status_mask_bit1": | 186 // "combined_status_mask_bit1": |
| 93 // (emulate_satisfied_criterion_1 || emulate_satisfied_criterion_2), | 187 // (emulate_satisfied_criterion_1 || emulate_satisfied_criterion_2), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 bytecode += OP_END_OF_SENTENCE; | 229 bytecode += OP_END_OF_SENTENCE; |
| 136 bytecode += OP_STORE_HASH(GetHash("memento_value_in_local_state"), | 230 bytecode += OP_STORE_HASH(GetHash("memento_value_in_local_state"), |
| 137 kTestMementoValue); | 231 kTestMementoValue); |
| 138 bytecode += OP_END_OF_SENTENCE; | 232 bytecode += OP_END_OF_SENTENCE; |
| 139 bytecode += OP_STORE_HASH(GetHash("memento_value_in_file"), | 233 bytecode += OP_STORE_HASH(GetHash("memento_value_in_file"), |
| 140 kTestMementoValue); | 234 kTestMementoValue); |
| 141 bytecode += OP_END_OF_SENTENCE; | 235 bytecode += OP_END_OF_SENTENCE; |
| 142 return bytecode; | 236 return bytecode; |
| 143 } | 237 } |
| 144 | 238 |
| 239 // Constructs another evaluation program to specifically test that local state |
| 240 // and user preference values are included in the input as expected. We will |
| 241 // re-purpose the output bitmasks to channel out information about the outcome |
| 242 // of the checks. |
| 243 // |
| 244 // More specifically, the output of the program will be as follows: |
| 245 // { |
| 246 // "combined_status_mask_bit1": |
| 247 // (input["preferences.testing.preference"] == kTestPreferenceValue) |
| 248 // "combined_status_mask_bit2": |
| 249 // (input["local_state.testing.preference"] == kTestPreferenceValue) |
| 250 // "combined_status_mask_bit3": input["preferences_iuc.testing.preference"] |
| 251 // "combined_status_mask_bit4": input["local_state_iuc.testing.preference"] |
| 252 // } |
| 253 std::string ConstructProgramToCheckPreferences() { |
| 254 std::string bytecode; |
| 255 bytecode += OP_NAVIGATE(GetHash("preferences")); |
| 256 bytecode += OP_NAVIGATE(GetHash("testing")); |
| 257 bytecode += OP_NAVIGATE(GetHash("preference")); |
| 258 bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestPreferenceValue)); |
| 259 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit1"), |
| 260 EncodeBool(true)); |
| 261 bytecode += OP_END_OF_SENTENCE; |
| 262 bytecode += OP_NAVIGATE(GetHash("local_state")); |
| 263 bytecode += OP_NAVIGATE(GetHash("testing")); |
| 264 bytecode += OP_NAVIGATE(GetHash("preference")); |
| 265 bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestPreferenceValue)); |
| 266 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit2"), |
| 267 EncodeBool(true)); |
| 268 bytecode += OP_END_OF_SENTENCE; |
| 269 bytecode += OP_NAVIGATE(GetHash("preferences_iuc")); |
| 270 bytecode += OP_NAVIGATE(GetHash("testing")); |
| 271 bytecode += OP_NAVIGATE(GetHash("preference")); |
| 272 bytecode += OP_COMPARE_NODE_BOOL(EncodeBool(true)); |
| 273 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit3"), |
| 274 EncodeBool(true)); |
| 275 bytecode += OP_END_OF_SENTENCE; |
| 276 bytecode += OP_NAVIGATE(GetHash("local_state_iuc")); |
| 277 bytecode += OP_NAVIGATE(GetHash("testing")); |
| 278 bytecode += OP_NAVIGATE(GetHash("preference")); |
| 279 bytecode += OP_COMPARE_NODE_BOOL(EncodeBool(true)); |
| 280 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit4"), |
| 281 EncodeBool(true)); |
| 282 bytecode += OP_END_OF_SENTENCE; |
| 283 return bytecode; |
| 284 } |
| 285 |
| 286 // Legend for the bitmask returned by the above program. |
| 287 enum CombinedStatusMaskLegendForCheckingPreferences { |
| 288 HAS_EXPECTED_USER_PREFERENCE = 1 << 0, |
| 289 HAS_EXPECTED_LOCAL_STATE_PREFERENCE = 1 << 1, |
| 290 USER_PREFERENCE_IS_USER_CONTROLLED = 1 << 2, |
| 291 LOCAL_STATE_IS_USER_CONTROLLED = 1 << 3, |
| 292 }; |
| 293 |
| 294 // Constructs yet another evaluation program to specifically test that default |
| 295 // and pre-populated search engines are included in the input as expected. We |
| 296 // will re-purpose the output bitmasks to channel out information about the |
| 297 // outcome of the checks. |
| 298 // |
| 299 // More specifically, the output of the program will be as follows: |
| 300 // { |
| 301 // "combined_status_mask_bit1": |
| 302 // (input["default_search_provider.search_url"] == kTestSearchURL) |
| 303 // "combined_status_mask_bit2": input["default_search_provider_iuc"] |
| 304 // "combined_status_mask_bit3": |
| 305 // (input["search_providers.*.search_url"] == kTestSearchURL) |
| 306 // "combined_status_mask_bit4": |
| 307 // (input["search_providers.*.search_url"] == kTestSearchURL2) |
| 308 // } |
| 309 std::string ConstructProgramToCheckSearchEngines() { |
| 310 std::string bytecode; |
| 311 bytecode += OP_NAVIGATE(GetHash("default_search_provider")); |
| 312 bytecode += OP_NAVIGATE(GetHash("search_url")); |
| 313 bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestSearchURL)); |
| 314 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit1"), |
| 315 EncodeBool(true)); |
| 316 bytecode += OP_END_OF_SENTENCE; |
| 317 bytecode += OP_NAVIGATE(GetHash("default_search_provider_iuc")); |
| 318 bytecode += OP_COMPARE_NODE_BOOL(EncodeBool(true)); |
| 319 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit2"), |
| 320 EncodeBool(true)); |
| 321 bytecode += OP_END_OF_SENTENCE; |
| 322 bytecode += OP_NAVIGATE(GetHash("search_providers")); |
| 323 bytecode += OP_NAVIGATE_ANY; |
| 324 bytecode += OP_NAVIGATE(GetHash("search_url")); |
| 325 bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestSearchURL)); |
| 326 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit3"), |
| 327 EncodeBool(true)); |
| 328 bytecode += OP_END_OF_SENTENCE; |
| 329 bytecode += OP_NAVIGATE(GetHash("search_providers")); |
| 330 bytecode += OP_NAVIGATE_ANY; |
| 331 bytecode += OP_NAVIGATE(GetHash("search_url")); |
| 332 bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestSearchURL2)); |
| 333 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit4"), |
| 334 EncodeBool(true)); |
| 335 bytecode += OP_END_OF_SENTENCE; |
| 336 return bytecode; |
| 337 } |
| 338 |
| 339 // Legend for the bitmask returned by the above program. |
| 340 enum CombinedStatusMaskLegendForCheckingSearchEngines { |
| 341 HAS_EXPECTED_DEFAULT_SEARCH_PROVIDER = 1 << 0, |
| 342 DEFAULT_SEARCH_PROVIDER_IS_USER_CONTROLLED = 1 << 1, |
| 343 HAS_EXPECTED_PREPOPULATED_SEARCH_PROVIDER_1 = 1 << 2, |
| 344 HAS_EXPECTED_PREPOPULATED_SEARCH_PROVIDER_2 = 1 << 3, |
| 345 }; |
| 346 |
| 347 // Constructs yet another evaluation program to specifically test that loaded |
| 348 // module digests are included in the input as expected. We will re-purpose the |
| 349 // output bitmasks to channel out information about the outcome of the checks. |
| 350 // |
| 351 // More specifically, the output of the program will be as follows: |
| 352 // { |
| 353 // "combined_status_mask_bit1": |
| 354 // (input["loaded_modules.*"] == kTestModuleDigest) |
| 355 // "combined_status_mask_bit2": |
| 356 // (input["loaded_modules.*"] == kTestModuleDigest2) |
| 357 // } |
| 358 std::string ConstructProgramToCheckLoadedModuleDigests() { |
| 359 std::string bytecode; |
| 360 bytecode += OP_NAVIGATE(GetHash("loaded_modules")); |
| 361 bytecode += OP_NAVIGATE_ANY; |
| 362 bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestModuleDigest)); |
| 363 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit1"), |
| 364 EncodeBool(true)); |
| 365 bytecode += OP_END_OF_SENTENCE; |
| 366 bytecode += OP_NAVIGATE(GetHash("loaded_modules")); |
| 367 bytecode += OP_NAVIGATE_ANY; |
| 368 bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestModuleDigest2)); |
| 369 bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit2"), |
| 370 EncodeBool(true)); |
| 371 bytecode += OP_END_OF_SENTENCE; |
| 372 return bytecode; |
| 373 } |
| 374 |
| 375 // Legend for the bitmask returned by the above program. |
| 376 enum CombinedStatusMaskLegendForCheckingLoadedModules { |
| 377 HAS_EXPECTED_MODULE_DIGEST_1 = 1 << 0, |
| 378 HAS_EXPECTED_MODULE_DIGEST_2 = 1 << 1, |
| 379 }; |
| 380 |
| 145 // Test fixtures ------------------------------------------------------------- | 381 // Test fixtures ------------------------------------------------------------- |
| 146 | 382 |
| 147 class AutomaticProfileResetterTestBase : public testing::Test { | 383 class AutomaticProfileResetterTestBase : public testing::Test { |
| 148 protected: | 384 protected: |
| 149 explicit AutomaticProfileResetterTestBase( | 385 explicit AutomaticProfileResetterTestBase( |
| 150 const std::string& experiment_group_name) | 386 const std::string& experiment_group_name) |
| 151 : local_state_(TestingBrowserProcess::GetGlobal()), | 387 : waiting_task_runner_(new base::TestSimpleTaskRunner), |
| 388 local_state_(TestingBrowserProcess::GetGlobal()), |
| 389 profile_(new TestingProfile()), |
| 152 experiment_group_name_(experiment_group_name), | 390 experiment_group_name_(experiment_group_name), |
| 153 mock_delegate_(NULL) { | 391 mock_delegate_(NULL) { |
| 154 // Make sure the factory is not optimized away, so prefs get registered. | 392 // Make sure the factory is not optimized away, so whatever preferences it |
| 393 // wants to register will actually get registered. |
| 155 AutomaticProfileResetterFactory::GetInstance(); | 394 AutomaticProfileResetterFactory::GetInstance(); |
| 395 |
| 396 // Register some additional local state preferences for testing purposes. |
| 397 PrefRegistrySimple* local_state_registry = local_state_.Get()->registry(); |
| 398 DCHECK(local_state_registry); |
| 399 local_state_registry->RegisterStringPref(kTestPreferencePath, ""); |
| 400 |
| 401 // Register some additional user preferences for testing purposes. |
| 402 user_prefs::PrefRegistrySyncable* user_prefs_registry = |
| 403 profile_->GetTestingPrefService()->registry(); |
| 404 DCHECK(user_prefs_registry); |
| 405 user_prefs_registry->RegisterStringPref( |
| 406 kTestPreferencePath, |
| 407 "", |
| 408 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 156 } | 409 } |
| 157 | 410 |
| 158 virtual void SetUp() OVERRIDE { | 411 virtual void SetUp() OVERRIDE { |
| 159 profile_.reset(new TestingProfile()); | |
| 160 field_trials_.reset(new base::FieldTrialList(NULL)); | 412 field_trials_.reset(new base::FieldTrialList(NULL)); |
| 161 base::FieldTrialList::CreateFieldTrial(kAutomaticProfileResetStudyName, | 413 base::FieldTrialList::CreateFieldTrial(kAutomaticProfileResetStudyName, |
| 162 experiment_group_name_); | 414 experiment_group_name_); |
| 163 mock_delegate_ = new testing::StrictMock<MockProfileResetterDelegate>(); | 415 mock_delegate_ = new testing::StrictMock<MockProfileResetterDelegate>(); |
| 164 resetter_.reset(new AutomaticProfileResetter(profile_.get())); | 416 resetter_.reset(new testing::StrictMock<AutomaticProfileResetterUnderTest>( |
| 417 profile_.get())); |
| 165 } | 418 } |
| 166 | 419 |
| 167 void SetTestingHashSeed(const std::string& hash_seed) { | 420 void SetTestingHashSeed(const std::string& hash_seed) { |
| 168 testing_hash_seed_ = hash_seed; | 421 testing_hash_seed_ = hash_seed; |
| 169 } | 422 } |
| 170 | 423 |
| 171 void SetTestingProgram(const std::string& source_code) { | 424 void SetTestingProgram(const std::string& source_code) { |
| 172 testing_program_ = source_code; | 425 testing_program_ = source_code; |
| 173 } | 426 } |
| 174 | 427 |
| 175 void UnleashResetterAndWait() { | 428 void UnleashResetterAndWait() { |
| 176 resetter_->Initialize(); | |
| 177 resetter_->SetDelegateForTesting(mock_delegate_); // Takes ownership. | 429 resetter_->SetDelegateForTesting(mock_delegate_); // Takes ownership. |
| 178 resetter_->SetHashSeedForTesting(testing_hash_seed_); | 430 resetter_->SetHashSeedForTesting(testing_hash_seed_); |
| 179 resetter_->SetProgramForTesting(testing_program_); | 431 resetter_->SetProgramForTesting(testing_program_); |
| 432 resetter_->SetTaskRunnerForWaitingForTesting(waiting_task_runner_); |
| 433 |
| 434 resetter_->Activate(); |
| 435 |
| 436 if (waiting_task_runner_->HasPendingTask()) { |
| 437 EXPECT_EQ(base::TimeDelta::FromSeconds(55), |
| 438 waiting_task_runner_->NextPendingTaskDelay()); |
| 439 waiting_task_runner_->RunPendingTasks(); |
| 440 } |
| 180 base::RunLoop().RunUntilIdle(); | 441 base::RunLoop().RunUntilIdle(); |
| 181 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 442 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 182 base::RunLoop().RunUntilIdle(); | 443 base::RunLoop().RunUntilIdle(); |
| 183 } | 444 } |
| 184 | 445 |
| 185 TestingProfile* profile() { return profile_.get(); } | 446 TestingProfile* profile() { return profile_.get(); } |
| 447 TestingPrefServiceSimple* local_state() { return local_state_.Get(); } |
| 186 | 448 |
| 187 MockProfileResetterDelegate& mock_delegate() { return *mock_delegate_; } | 449 MockProfileResetterDelegate& mock_delegate() { return *mock_delegate_; } |
| 188 AutomaticProfileResetter* resetter() { return resetter_.get(); } | 450 AutomaticProfileResetterUnderTest& resetter() { return *resetter_; } |
| 189 | 451 |
| 190 private: | 452 private: |
| 191 content::TestBrowserThreadBundle thread_bundle_; | 453 content::TestBrowserThreadBundle thread_bundle_; |
| 454 scoped_refptr<base::TestSimpleTaskRunner> waiting_task_runner_; |
| 192 ScopedTestingLocalState local_state_; | 455 ScopedTestingLocalState local_state_; |
| 193 scoped_ptr<TestingProfile> profile_; | 456 scoped_ptr<TestingProfile> profile_; |
| 194 scoped_ptr<base::FieldTrialList> field_trials_; | 457 scoped_ptr<base::FieldTrialList> field_trials_; |
| 195 std::string experiment_group_name_; | 458 std::string experiment_group_name_; |
| 196 std::string testing_program_; | 459 std::string testing_program_; |
| 197 std::string testing_hash_seed_; | 460 std::string testing_hash_seed_; |
| 198 | 461 |
| 199 scoped_ptr<AutomaticProfileResetter> resetter_; | 462 scoped_ptr<AutomaticProfileResetterUnderTest> resetter_; |
| 200 MockProfileResetterDelegate* mock_delegate_; | 463 MockProfileResetterDelegate* mock_delegate_; |
| 201 | 464 |
| 202 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterTestBase); | 465 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterTestBase); |
| 203 }; | 466 }; |
| 204 | 467 |
| 205 class AutomaticProfileResetterTest : public AutomaticProfileResetterTestBase { | 468 class AutomaticProfileResetterTest : public AutomaticProfileResetterTestBase { |
| 206 protected: | 469 protected: |
| 207 AutomaticProfileResetterTest() | 470 AutomaticProfileResetterTest() |
| 208 : AutomaticProfileResetterTestBase(kStudyEnabledGroupName) {} | 471 : AutomaticProfileResetterTestBase(kStudyEnabledGroupName) {} |
| 209 }; | 472 }; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 513 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 251 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 514 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 252 | 515 |
| 253 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 516 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 254 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 517 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 255 EXPECT_EQ("", memento_in_file.ReadValue()); | 518 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 256 | 519 |
| 257 SetTestingProgram(ConstructProgram(false, false)); | 520 SetTestingProgram(ConstructProgram(false, false)); |
| 258 SetTestingHashSeed(kTestHashSeed); | 521 SetTestingHashSeed(kTestHashSeed); |
| 259 | 522 |
| 260 EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, 0x00u)); | 523 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 524 mock_delegate().ExpectCallsToGetterMethods(); |
| 525 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); |
| 261 | 526 |
| 262 UnleashResetterAndWait(); | 527 UnleashResetterAndWait(); |
| 263 | 528 |
| 264 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 529 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 265 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 530 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 266 EXPECT_EQ("", memento_in_file.ReadValue()); | 531 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 267 } | 532 } |
| 268 | 533 |
| 269 TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) { | 534 TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) { |
| 270 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 535 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 271 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 536 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 272 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 537 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 273 | 538 |
| 274 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 539 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 275 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 540 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 276 EXPECT_EQ("", memento_in_file.ReadValue()); | 541 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 277 | 542 |
| 278 SetTestingProgram(ConstructProgram(true, false)); | 543 SetTestingProgram(ConstructProgram(true, false)); |
| 279 SetTestingHashSeed(kTestHashSeed); | 544 SetTestingHashSeed(kTestHashSeed); |
| 280 | 545 |
| 281 EXPECT_CALL(mock_delegate(), ReportStatistics(0x01u, 0x01u)); | 546 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 547 mock_delegate().ExpectCallsToGetterMethods(); |
| 548 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); |
| 282 | 549 |
| 283 UnleashResetterAndWait(); | 550 UnleashResetterAndWait(); |
| 284 | 551 |
| 285 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 552 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 286 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 553 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 287 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 554 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 288 } | 555 } |
| 289 | 556 |
| 290 TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) { | 557 TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) { |
| 291 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 558 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 292 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 559 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 293 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 560 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 294 | 561 |
| 295 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 562 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 296 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 563 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 297 EXPECT_EQ("", memento_in_file.ReadValue()); | 564 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 298 | 565 |
| 299 SetTestingProgram(ConstructProgram(false, true)); | 566 SetTestingProgram(ConstructProgram(false, true)); |
| 300 SetTestingHashSeed(kTestHashSeed); | 567 SetTestingHashSeed(kTestHashSeed); |
| 301 | 568 |
| 302 EXPECT_CALL(mock_delegate(), ReportStatistics(0x02u, 0x01u)); | 569 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 570 mock_delegate().ExpectCallsToGetterMethods(); |
| 571 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); |
| 303 | 572 |
| 304 UnleashResetterAndWait(); | 573 UnleashResetterAndWait(); |
| 305 | 574 |
| 306 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 575 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 307 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 576 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 308 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 577 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 309 } | 578 } |
| 310 | 579 |
| 311 TEST_F(AutomaticProfileResetterTestDryRun, | 580 TEST_F(AutomaticProfileResetterTestDryRun, |
| 312 ConditionsSatisfiedAndInvalidMementos) { | 581 ConditionsSatisfiedAndInvalidMementos) { |
| 313 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 582 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 314 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 583 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 315 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 584 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 316 | 585 |
| 317 memento_in_prefs.StoreValue(kTestInvalidMementoValue); | 586 memento_in_prefs.StoreValue(kTestInvalidMementoValue); |
| 318 memento_in_local_state.StoreValue(kTestInvalidMementoValue); | 587 memento_in_local_state.StoreValue(kTestInvalidMementoValue); |
| 319 memento_in_file.StoreValue(kTestInvalidMementoValue); | 588 memento_in_file.StoreValue(kTestInvalidMementoValue); |
| 320 | 589 |
| 321 SetTestingProgram(ConstructProgram(true, true)); | 590 SetTestingProgram(ConstructProgram(true, true)); |
| 322 SetTestingHashSeed(kTestHashSeed); | 591 SetTestingHashSeed(kTestHashSeed); |
| 323 | 592 |
| 324 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x01u)); | 593 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 594 mock_delegate().ExpectCallsToGetterMethods(); |
| 595 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 325 | 596 |
| 326 UnleashResetterAndWait(); | 597 UnleashResetterAndWait(); |
| 327 | 598 |
| 328 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 599 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 329 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 600 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 330 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 601 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 331 } | 602 } |
| 332 | 603 |
| 333 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) { | 604 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) { |
| 334 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 605 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 335 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 606 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 336 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 607 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 337 | 608 |
| 338 memento_in_prefs.StoreValue(kTestMementoValue); | 609 memento_in_prefs.StoreValue(kTestMementoValue); |
| 339 | 610 |
| 340 SetTestingProgram(ConstructProgram(true, true)); | 611 SetTestingProgram(ConstructProgram(true, true)); |
| 341 SetTestingHashSeed(kTestHashSeed); | 612 SetTestingHashSeed(kTestHashSeed); |
| 342 | 613 |
| 343 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x03u)); | 614 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 615 mock_delegate().ExpectCallsToGetterMethods(); |
| 616 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); |
| 344 | 617 |
| 345 UnleashResetterAndWait(); | 618 UnleashResetterAndWait(); |
| 346 | 619 |
| 347 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 620 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 348 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 621 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 349 EXPECT_EQ("", memento_in_file.ReadValue()); | 622 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 350 } | 623 } |
| 351 | 624 |
| 352 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) { | 625 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) { |
| 353 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 626 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 354 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 627 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 355 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 628 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 356 | 629 |
| 357 memento_in_local_state.StoreValue(kTestMementoValue); | 630 memento_in_local_state.StoreValue(kTestMementoValue); |
| 358 | 631 |
| 359 SetTestingProgram(ConstructProgram(true, true)); | 632 SetTestingProgram(ConstructProgram(true, true)); |
| 360 SetTestingHashSeed(kTestHashSeed); | 633 SetTestingHashSeed(kTestHashSeed); |
| 361 | 634 |
| 362 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x05u)); | 635 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 636 mock_delegate().ExpectCallsToGetterMethods(); |
| 637 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); |
| 363 | 638 |
| 364 UnleashResetterAndWait(); | 639 UnleashResetterAndWait(); |
| 365 | 640 |
| 366 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 641 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 367 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 642 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 368 EXPECT_EQ("", memento_in_file.ReadValue()); | 643 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 369 } | 644 } |
| 370 | 645 |
| 371 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) { | 646 TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) { |
| 372 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 647 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 373 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 648 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 374 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 649 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 375 | 650 |
| 376 memento_in_file.StoreValue(kTestMementoValue); | 651 memento_in_file.StoreValue(kTestMementoValue); |
| 377 | 652 |
| 378 SetTestingProgram(ConstructProgram(true, true)); | 653 SetTestingProgram(ConstructProgram(true, true)); |
| 379 SetTestingHashSeed(kTestHashSeed); | 654 SetTestingHashSeed(kTestHashSeed); |
| 380 | 655 |
| 381 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x09u)); | 656 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 657 mock_delegate().ExpectCallsToGetterMethods(); |
| 658 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); |
| 382 | 659 |
| 383 UnleashResetterAndWait(); | 660 UnleashResetterAndWait(); |
| 384 | 661 |
| 385 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 662 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 386 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 663 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 387 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 664 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 388 } | 665 } |
| 389 | 666 |
| 390 TEST_F(AutomaticProfileResetterTestDryRun, DoNothingWhenResourcesAreMissing) { | 667 TEST_F(AutomaticProfileResetterTestDryRun, DoNothingWhenResourcesAreMissing) { |
| 391 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 668 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 409 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 686 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 410 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 687 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 411 | 688 |
| 412 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 689 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 413 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 690 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 414 EXPECT_EQ("", memento_in_file.ReadValue()); | 691 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 415 | 692 |
| 416 SetTestingProgram(ConstructProgram(false, false)); | 693 SetTestingProgram(ConstructProgram(false, false)); |
| 417 SetTestingHashSeed(kTestHashSeed); | 694 SetTestingHashSeed(kTestHashSeed); |
| 418 | 695 |
| 419 EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, 0x00u)); | 696 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 697 mock_delegate().ExpectCallsToGetterMethods(); |
| 698 EXPECT_CALL(resetter(), ReportStatistics(0x00u, 0x00u)); |
| 420 | 699 |
| 421 UnleashResetterAndWait(); | 700 UnleashResetterAndWait(); |
| 422 | 701 |
| 423 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 702 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 424 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 703 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 425 EXPECT_EQ("", memento_in_file.ReadValue()); | 704 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 426 } | 705 } |
| 427 | 706 |
| 428 TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) { | 707 TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) { |
| 429 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 708 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 430 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 709 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 431 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 710 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 432 | 711 |
| 433 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 712 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 434 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 713 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 435 EXPECT_EQ("", memento_in_file.ReadValue()); | 714 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 436 | 715 |
| 437 SetTestingProgram(ConstructProgram(true, false)); | 716 SetTestingProgram(ConstructProgram(true, false)); |
| 438 SetTestingHashSeed(kTestHashSeed); | 717 SetTestingHashSeed(kTestHashSeed); |
| 439 | 718 |
| 719 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 720 mock_delegate().ExpectCallsToGetterMethods(); |
| 440 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 721 EXPECT_CALL(mock_delegate(), ShowPrompt()); |
| 441 EXPECT_CALL(mock_delegate(), ReportStatistics(0x01u, 0x01u)); | 722 EXPECT_CALL(resetter(), ReportStatistics(0x01u, 0x01u)); |
| 442 | 723 |
| 443 UnleashResetterAndWait(); | 724 UnleashResetterAndWait(); |
| 444 | 725 |
| 445 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 726 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 446 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 727 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 447 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 728 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 448 } | 729 } |
| 449 | 730 |
| 450 TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) { | 731 TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) { |
| 451 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 732 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 452 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 733 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 453 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 734 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 454 | 735 |
| 455 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 736 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 456 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 737 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 457 EXPECT_EQ("", memento_in_file.ReadValue()); | 738 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 458 | 739 |
| 459 SetTestingProgram(ConstructProgram(false, true)); | 740 SetTestingProgram(ConstructProgram(false, true)); |
| 460 SetTestingHashSeed(kTestHashSeed); | 741 SetTestingHashSeed(kTestHashSeed); |
| 461 | 742 |
| 743 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 744 mock_delegate().ExpectCallsToGetterMethods(); |
| 462 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 745 EXPECT_CALL(mock_delegate(), ShowPrompt()); |
| 463 EXPECT_CALL(mock_delegate(), ReportStatistics(0x02u, 0x01u)); | 746 EXPECT_CALL(resetter(), ReportStatistics(0x02u, 0x01u)); |
| 464 | 747 |
| 465 UnleashResetterAndWait(); | 748 UnleashResetterAndWait(); |
| 466 | 749 |
| 467 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 750 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 468 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 751 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 469 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 752 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 470 } | 753 } |
| 471 | 754 |
| 472 TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) { | 755 TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) { |
| 473 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 756 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 474 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 757 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 475 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 758 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 476 | 759 |
| 477 memento_in_prefs.StoreValue(kTestInvalidMementoValue); | 760 memento_in_prefs.StoreValue(kTestInvalidMementoValue); |
| 478 memento_in_local_state.StoreValue(kTestInvalidMementoValue); | 761 memento_in_local_state.StoreValue(kTestInvalidMementoValue); |
| 479 memento_in_file.StoreValue(kTestInvalidMementoValue); | 762 memento_in_file.StoreValue(kTestInvalidMementoValue); |
| 480 | 763 |
| 481 SetTestingProgram(ConstructProgram(true, true)); | 764 SetTestingProgram(ConstructProgram(true, true)); |
| 482 SetTestingHashSeed(kTestHashSeed); | 765 SetTestingHashSeed(kTestHashSeed); |
| 483 | 766 |
| 767 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 768 mock_delegate().ExpectCallsToGetterMethods(); |
| 484 EXPECT_CALL(mock_delegate(), ShowPrompt()); | 769 EXPECT_CALL(mock_delegate(), ShowPrompt()); |
| 485 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x01u)); | 770 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x01u)); |
| 486 | 771 |
| 487 UnleashResetterAndWait(); | 772 UnleashResetterAndWait(); |
| 488 | 773 |
| 489 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 774 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 490 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 775 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 491 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 776 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 492 } | 777 } |
| 493 | 778 |
| 494 TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) { | 779 TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) { |
| 495 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 780 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 496 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 781 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 497 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 782 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 498 | 783 |
| 499 memento_in_prefs.StoreValue(kTestMementoValue); | 784 memento_in_prefs.StoreValue(kTestMementoValue); |
| 500 | 785 |
| 501 SetTestingProgram(ConstructProgram(true, true)); | 786 SetTestingProgram(ConstructProgram(true, true)); |
| 502 SetTestingHashSeed(kTestHashSeed); | 787 SetTestingHashSeed(kTestHashSeed); |
| 503 | 788 |
| 504 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x03u)); | 789 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 790 mock_delegate().ExpectCallsToGetterMethods(); |
| 791 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x03u)); |
| 505 | 792 |
| 506 UnleashResetterAndWait(); | 793 UnleashResetterAndWait(); |
| 507 | 794 |
| 508 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); | 795 EXPECT_EQ(kTestMementoValue, memento_in_prefs.ReadValue()); |
| 509 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 796 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 510 EXPECT_EQ("", memento_in_file.ReadValue()); | 797 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 511 } | 798 } |
| 512 | 799 |
| 513 TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) { | 800 TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) { |
| 514 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 801 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 515 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 802 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 516 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 803 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 517 | 804 |
| 518 memento_in_local_state.StoreValue(kTestMementoValue); | 805 memento_in_local_state.StoreValue(kTestMementoValue); |
| 519 | 806 |
| 520 SetTestingProgram(ConstructProgram(true, true)); | 807 SetTestingProgram(ConstructProgram(true, true)); |
| 521 SetTestingHashSeed(kTestHashSeed); | 808 SetTestingHashSeed(kTestHashSeed); |
| 522 | 809 |
| 523 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x05u)); | 810 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 811 mock_delegate().ExpectCallsToGetterMethods(); |
| 812 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x05u)); |
| 524 | 813 |
| 525 UnleashResetterAndWait(); | 814 UnleashResetterAndWait(); |
| 526 | 815 |
| 527 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 816 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 528 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); | 817 EXPECT_EQ(kTestMementoValue, memento_in_local_state.ReadValue()); |
| 529 EXPECT_EQ("", memento_in_file.ReadValue()); | 818 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 530 } | 819 } |
| 531 | 820 |
| 532 TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) { | 821 TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) { |
| 533 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 822 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 534 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 823 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 535 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 824 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 536 | 825 |
| 537 memento_in_file.StoreValue(kTestMementoValue); | 826 memento_in_file.StoreValue(kTestMementoValue); |
| 538 | 827 |
| 539 SetTestingProgram(ConstructProgram(true, true)); | 828 SetTestingProgram(ConstructProgram(true, true)); |
| 540 SetTestingHashSeed(kTestHashSeed); | 829 SetTestingHashSeed(kTestHashSeed); |
| 541 | 830 |
| 542 EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x09u)); | 831 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 832 mock_delegate().ExpectCallsToGetterMethods(); |
| 833 EXPECT_CALL(resetter(), ReportStatistics(0x03u, 0x09u)); |
| 543 | 834 |
| 544 UnleashResetterAndWait(); | 835 UnleashResetterAndWait(); |
| 545 | 836 |
| 546 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 837 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 547 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 838 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 548 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); | 839 EXPECT_EQ(kTestMementoValue, memento_in_file.ReadValue()); |
| 549 } | 840 } |
| 550 | 841 |
| 551 TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) { | 842 TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) { |
| 552 PreferenceHostedPromptMemento memento_in_prefs(profile()); | 843 PreferenceHostedPromptMemento memento_in_prefs(profile()); |
| 553 LocalStateHostedPromptMemento memento_in_local_state(profile()); | 844 LocalStateHostedPromptMemento memento_in_local_state(profile()); |
| 554 FileHostedPromptMementoSynchronous memento_in_file(profile()); | 845 FileHostedPromptMementoSynchronous memento_in_file(profile()); |
| 555 | 846 |
| 556 SetTestingProgram(""); | 847 SetTestingProgram(""); |
| 557 SetTestingHashSeed(""); | 848 SetTestingHashSeed(""); |
| 558 | 849 |
| 559 // No calls are expected to the delegate. | 850 // No calls are expected to the delegate. |
| 560 | 851 |
| 561 UnleashResetterAndWait(); | 852 UnleashResetterAndWait(); |
| 562 | 853 |
| 563 EXPECT_EQ("", memento_in_prefs.ReadValue()); | 854 EXPECT_EQ("", memento_in_prefs.ReadValue()); |
| 564 EXPECT_EQ("", memento_in_local_state.ReadValue()); | 855 EXPECT_EQ("", memento_in_local_state.ReadValue()); |
| 565 EXPECT_EQ("", memento_in_file.ReadValue()); | 856 EXPECT_EQ("", memento_in_file.ReadValue()); |
| 566 } | 857 } |
| 567 | 858 |
| 859 // Please see comments above ConstructProgramToCheckPreferences() to understand |
| 860 // how the following tests work. |
| 861 |
| 862 TEST_F(AutomaticProfileResetterTest, InputUserPreferencesCorrect) { |
| 863 SetTestingProgram(ConstructProgramToCheckPreferences()); |
| 864 SetTestingHashSeed(kTestHashSeed); |
| 865 |
| 866 PrefService* prefs = profile()->GetPrefs(); |
| 867 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); |
| 868 |
| 869 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 870 mock_delegate().ExpectCallsToGetterMethods(); |
| 871 uint32 expected_mask = |
| 872 HAS_EXPECTED_USER_PREFERENCE | USER_PREFERENCE_IS_USER_CONTROLLED; |
| 873 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 874 |
| 875 UnleashResetterAndWait(); |
| 876 } |
| 877 |
| 878 TEST_F(AutomaticProfileResetterTest, InputLocalStateCorrect) { |
| 879 SetTestingProgram(ConstructProgramToCheckPreferences()); |
| 880 SetTestingHashSeed(kTestHashSeed); |
| 881 |
| 882 PrefService* prefs = local_state(); |
| 883 prefs->SetString(kTestPreferencePath, kTestPreferenceValue); |
| 884 |
| 885 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 886 mock_delegate().ExpectCallsToGetterMethods(); |
| 887 uint32 expected_mask = |
| 888 HAS_EXPECTED_LOCAL_STATE_PREFERENCE | LOCAL_STATE_IS_USER_CONTROLLED; |
| 889 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 890 |
| 891 UnleashResetterAndWait(); |
| 892 } |
| 893 |
| 894 TEST_F(AutomaticProfileResetterTest, InputManagedUserPreferencesCorrect) { |
| 895 SetTestingProgram(ConstructProgramToCheckPreferences()); |
| 896 SetTestingHashSeed(kTestHashSeed); |
| 897 |
| 898 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); |
| 899 prefs->SetManagedPref(kTestPreferencePath, |
| 900 new base::StringValue(kTestPreferenceValue)); |
| 901 |
| 902 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 903 mock_delegate().ExpectCallsToGetterMethods(); |
| 904 uint32 expected_mask = HAS_EXPECTED_USER_PREFERENCE; |
| 905 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 906 |
| 907 UnleashResetterAndWait(); |
| 908 } |
| 909 |
| 910 TEST_F(AutomaticProfileResetterTest, InputManagedLocalStateCorrect) { |
| 911 SetTestingProgram(ConstructProgramToCheckPreferences()); |
| 912 SetTestingHashSeed(kTestHashSeed); |
| 913 |
| 914 TestingPrefServiceSimple* prefs = local_state(); |
| 915 prefs->SetManagedPref(kTestPreferencePath, |
| 916 new base::StringValue(kTestPreferenceValue)); |
| 917 |
| 918 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 919 mock_delegate().ExpectCallsToGetterMethods(); |
| 920 uint32 expected_mask = HAS_EXPECTED_LOCAL_STATE_PREFERENCE; |
| 921 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 922 |
| 923 UnleashResetterAndWait(); |
| 924 } |
| 925 |
| 926 // Please see comments above ConstructProgramToCheckSearchEngines() to |
| 927 // understand how the following tests work. |
| 928 |
| 929 TEST_F(AutomaticProfileResetterTest, InputDefaultSearchProviderCorrect) { |
| 930 SetTestingProgram(ConstructProgramToCheckSearchEngines()); |
| 931 SetTestingHashSeed(kTestHashSeed); |
| 932 |
| 933 mock_delegate().emulated_default_search_provider_details().SetString( |
| 934 kSearchURLAttributeKey, kTestSearchURL); |
| 935 |
| 936 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 937 mock_delegate().ExpectCallsToGetterMethods(); |
| 938 uint32 expected_mask = HAS_EXPECTED_DEFAULT_SEARCH_PROVIDER | |
| 939 DEFAULT_SEARCH_PROVIDER_IS_USER_CONTROLLED; |
| 940 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 941 |
| 942 UnleashResetterAndWait(); |
| 943 } |
| 944 |
| 945 TEST_F(AutomaticProfileResetterTest, InputSearchProviderManagedCorrect) { |
| 946 SetTestingProgram(ConstructProgramToCheckSearchEngines()); |
| 947 SetTestingHashSeed(kTestHashSeed); |
| 948 |
| 949 mock_delegate().emulated_default_search_provider_details().SetString( |
| 950 kSearchURLAttributeKey, kTestSearchURL); |
| 951 mock_delegate().set_emulated_default_search_provider_is_managed(true); |
| 952 |
| 953 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 954 mock_delegate().ExpectCallsToGetterMethods(); |
| 955 uint32 expected_mask = HAS_EXPECTED_DEFAULT_SEARCH_PROVIDER; |
| 956 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 957 |
| 958 UnleashResetterAndWait(); |
| 959 } |
| 960 |
| 961 TEST_F(AutomaticProfileResetterTest, InputSearchProvidersCorrect) { |
| 962 SetTestingProgram(ConstructProgramToCheckSearchEngines()); |
| 963 SetTestingHashSeed(kTestHashSeed); |
| 964 |
| 965 base::DictionaryValue* search_provider_1 = new base::DictionaryValue; |
| 966 base::DictionaryValue* search_provider_2 = new base::DictionaryValue; |
| 967 search_provider_1->SetString(kSearchURLAttributeKey, kTestSearchURL); |
| 968 search_provider_2->SetString(kSearchURLAttributeKey, kTestSearchURL2); |
| 969 mock_delegate().emulated_search_providers_details().Append(search_provider_1); |
| 970 mock_delegate().emulated_search_providers_details().Append(search_provider_2); |
| 971 |
| 972 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 973 mock_delegate().ExpectCallsToGetterMethods(); |
| 974 uint32 expected_mask = DEFAULT_SEARCH_PROVIDER_IS_USER_CONTROLLED | |
| 975 HAS_EXPECTED_PREPOPULATED_SEARCH_PROVIDER_1 | |
| 976 HAS_EXPECTED_PREPOPULATED_SEARCH_PROVIDER_2; |
| 977 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 978 |
| 979 UnleashResetterAndWait(); |
| 980 } |
| 981 |
| 982 // Please see comments above ConstructProgramToCheckLoadedModuleDigests() to |
| 983 // understand how the following tests work. |
| 984 |
| 985 TEST_F(AutomaticProfileResetterTest, InputModuleDigestsCorrect) { |
| 986 SetTestingProgram(ConstructProgramToCheckLoadedModuleDigests()); |
| 987 SetTestingHashSeed(kTestHashSeed); |
| 988 |
| 989 mock_delegate().emulated_loaded_module_digests().AppendString( |
| 990 kTestModuleDigest); |
| 991 mock_delegate().emulated_loaded_module_digests().AppendString( |
| 992 kTestModuleDigest2); |
| 993 |
| 994 mock_delegate().ExpectCallsToDependenciesSetUpMethods(); |
| 995 mock_delegate().ExpectCallsToGetterMethods(); |
| 996 uint32 expected_mask = |
| 997 HAS_EXPECTED_MODULE_DIGEST_1 | HAS_EXPECTED_MODULE_DIGEST_2; |
| 998 EXPECT_CALL(resetter(), ReportStatistics(0x00u, expected_mask)); |
| 999 |
| 1000 UnleashResetterAndWait(); |
| 1001 } |
| 1002 |
| 568 } // namespace | 1003 } // namespace |
| OLD | NEW |