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

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

Issue 27030002: Added collecting of data to be fed to the JTL interpreter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments by battre@. Created 7 years, 2 months 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
« no previous file with comments | « chrome/browser/profile_resetter/automatic_profile_resetter_factory.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f71af0c8a01b4159561453e3302fb923c225bbf3..af9f22b7f3621862e1b72a4a6055026ae250f9ca 100644
--- a/chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/automatic_profile_resetter_unittest.cc
@@ -4,24 +4,33 @@
#include <string>
-#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/metrics/field_trial.h"
+#include "base/prefs/pref_registry_simple.h"
+#include "base/prefs/testing_pref_service.h"
#include "base/run_loop.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/profile_resetter/automatic_profile_resetter.h"
+#include "chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h"
#include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
#include "chrome/browser/profile_resetter/automatic_profile_resetter_mementos.h"
#include "chrome/browser/profile_resetter/jtl_foundation.h"
#include "chrome/browser/profile_resetter/jtl_instructions.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
+#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using testing::_;
+using testing::Invoke;
+using testing::Return;
+
namespace {
const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset";
@@ -33,17 +42,67 @@ const char kTestHashSeed[] = "testing-hash-seed";
const char kTestMementoValue[] = "01234567890123456789012345678901";
const char kTestInvalidMementoValue[] = "12345678901234567890123456789012";
+const char kTestPreferencePath[] = "testing.preference";
+const char kTestPreferenceValue[] = "testing-preference-value";
+
+const char kSearchURLAttributeKey[] = "search_url";
+const char kTestSearchURL[] = "http://example.com/search?q={searchTerms}";
+const char kTestSearchURL2[] = "http://google.com/?q={searchTerms}";
+
// Helpers ------------------------------------------------------------------
class MockProfileResetterDelegate : public AutomaticProfileResetterDelegate {
public:
- MockProfileResetterDelegate() {}
+ MockProfileResetterDelegate()
+ : emulated_default_search_provider_is_managed_(false) {}
virtual ~MockProfileResetterDelegate() {}
+ MOCK_METHOD0(LoadTemplateURLServiceIfNeeded, void());
+ MOCK_METHOD1(WaitOnTemplateURLService, void(const base::Closure&));
+
+ MOCK_CONST_METHOD0(GetDefaultSearchProviderDetails, base::DictionaryValue*());
+ MOCK_CONST_METHOD0(IsDefaultSearchProviderManaged, bool());
+ MOCK_CONST_METHOD0(GetPrepopulatedSearchProvidersDetails, base::ListValue*());
+
MOCK_METHOD0(ShowPrompt, void());
MOCK_METHOD2(ReportStatistics, void(uint32, uint32));
+ static void ClosureInvoker(const base::Closure& closure) { closure.Run(); }
+
+ void ExpectCallsToWaitingMethods() {
+ EXPECT_CALL(*this, WaitOnTemplateURLService(_))
+ .WillOnce(Invoke(ClosureInvoker));
+ EXPECT_CALL(*this, LoadTemplateURLServiceIfNeeded());
+ }
+
+ void ExpectCallsToGetterMethods() {
+ EXPECT_CALL(*this, GetDefaultSearchProviderDetails())
+ .WillRepeatedly(Invoke(&emulated_default_search_provider_details_,
+ &base::DictionaryValue::DeepCopy));
+ EXPECT_CALL(*this, IsDefaultSearchProviderManaged())
+ .WillRepeatedly(Return(emulated_default_search_provider_is_managed_));
+ EXPECT_CALL(*this, GetPrepopulatedSearchProvidersDetails())
+ .WillRepeatedly(Invoke(&emulated_search_providers_details_,
+ &base::ListValue::DeepCopy));
+ }
+
+ base::DictionaryValue& emulated_default_search_provider_details() {
+ return emulated_default_search_provider_details_;
+ }
+
+ base::ListValue& emulated_search_providers_details() {
+ return emulated_search_providers_details_;
+ }
+
+ void set_emulated_default_search_provider_is_managed(bool value) {
+ emulated_default_search_provider_is_managed_ = value;
+ }
+
private:
+ base::DictionaryValue emulated_default_search_provider_details_;
+ bool emulated_default_search_provider_is_managed_;
+ base::ListValue emulated_search_providers_details_;
+
DISALLOW_COPY_AND_ASSIGN(MockProfileResetterDelegate);
};
@@ -79,8 +138,8 @@ std::string GetHash(const std::string& input) {
// Encodes a Boolean argument value into JTL bytecode.
std::string EncodeBool(bool value) { return value ? VALUE_TRUE : VALUE_FALSE; }
-// Constructs a simple evaluation program to test that input/output works well.
-// It will emulate a scenario in which the reset criteria are satisfied as
+// Constructs a simple evaluation program to test that basic input/output works
+// well. It will emulate a scenario in which the reset criteria are satisfied as
// prescribed by |emulate_satisfied_criterion_{1|2}|, and will set bits in the
// combined status mask according to whether or not the memento values received
// in the input were as expected.
@@ -142,6 +201,114 @@ std::string ConstructProgram(bool emulate_satisfied_criterion_1,
return bytecode;
}
+// Constructs another evaluation program to specifically test that local state
+// and user preference values are included in the input as expected. We will
+// re-purpose the output bitmasks to channel out information about the outcome
+// of the checks.
+//
+// More specifically, the output of the program will be as follows:
+// {
+// "combined_status_mask_bit1":
+// (input["preferences.testing.preference"] == kTestPreferenceValue)
+// "combined_status_mask_bit2":
+// (input["local_state.testing.preference"] == kTestPreferenceValue)
+// "combined_status_mask_bit3": input["preferences_iuc.testing.preference"]
+// "combined_status_mask_bit4": input["local_state_iuc.testing.preference"]
+// }
+std::string ConstructProgramToCheckPreferences() {
+ std::string bytecode;
+ bytecode += OP_NAVIGATE(GetHash("preferences"));
+ bytecode += OP_NAVIGATE(GetHash("testing"));
+ bytecode += OP_NAVIGATE(GetHash("preference"));
+ bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestPreferenceValue));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit1"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ bytecode += OP_NAVIGATE(GetHash("local_state"));
+ bytecode += OP_NAVIGATE(GetHash("testing"));
+ bytecode += OP_NAVIGATE(GetHash("preference"));
+ bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestPreferenceValue));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit2"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ bytecode += OP_NAVIGATE(GetHash("preferences_iuc"));
+ bytecode += OP_NAVIGATE(GetHash("testing"));
+ bytecode += OP_NAVIGATE(GetHash("preference"));
+ bytecode += OP_COMPARE_NODE_BOOL(EncodeBool(true));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit3"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ bytecode += OP_NAVIGATE(GetHash("local_state_iuc"));
+ bytecode += OP_NAVIGATE(GetHash("testing"));
+ bytecode += OP_NAVIGATE(GetHash("preference"));
+ bytecode += OP_COMPARE_NODE_BOOL(EncodeBool(true));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit4"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ return bytecode;
+}
+
+// Legend for the bitmask returned by the above program.
+enum CombinedStatusMaskLegendForCheckingPreferences {
+ HasExpectedUserPreference = 1 << 0,
+ HasExpectedLocalStatePreference = 1 << 1,
+ UserPreferenceIsUserControlled = 1 << 2,
+ LocalStateIsUserControlled = 1 << 3,
+};
+
+// Constructs yet another evaluation program to specifically test that default
+// and pre-populated search engines are included in the input as expected. We
+// will re-purpose the output bitmasks to channel out information about the
+// outcome of the checks.
+//
+// More specifically, the output of the program will be as follows:
+// {
+// "combined_status_mask_bit1":
+// (input["default_search_provider.search_url"] == kTestSearchURL)
+// "combined_status_mask_bit2": input["default_search_provider_iuc"]
+// "combined_status_mask_bit3":
+// (input["search_providers.*.search_url"] == kTestSearchURL)
+// "combined_status_mask_bit4":
+// (input["search_providers.*.search_url"] == kTestSearchURL2)
+// }
+std::string ConstructProgramToCheckSearchEngines() {
+ std::string bytecode;
+ bytecode += OP_NAVIGATE(GetHash("default_search_provider"));
+ bytecode += OP_NAVIGATE(GetHash("search_url"));
+ bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestSearchURL));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit1"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ bytecode += OP_NAVIGATE(GetHash("default_search_provider_iuc"));
+ bytecode += OP_COMPARE_NODE_BOOL(EncodeBool(true));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit2"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ bytecode += OP_NAVIGATE(GetHash("search_providers"));
+ bytecode += OP_NAVIGATE_ANY;
+ bytecode += OP_NAVIGATE(GetHash("search_url"));
+ bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestSearchURL));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit3"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ bytecode += OP_NAVIGATE(GetHash("search_providers"));
+ bytecode += OP_NAVIGATE_ANY;
+ bytecode += OP_NAVIGATE(GetHash("search_url"));
+ bytecode += OP_COMPARE_NODE_HASH(GetHash(kTestSearchURL2));
+ bytecode += OP_STORE_BOOL(GetHash("combined_status_mask_bit4"),
+ EncodeBool(true));
+ bytecode += OP_END_OF_SENTENCE;
+ return bytecode;
+}
+
+// Legend for the bitmask returned by the above program.
+enum CombinedStatusMaskLegendForCheckingSearchEngines {
+ HasExpectedDefaultSearchProvider = 1 << 0,
battre 2013/10/11 16:48:25 Nit: Enums are supposed to be ALL_CAPS_STYLE.
engedy 2013/10/11 16:55:14 Done.
+ DefaultSearchProviderIsUserControlled = 1 << 1,
+ HasExpectedPrepopulatedSearchProvider1 = 1 << 2,
+ HasExpectedPrepopulatedSearchProvider2 = 1 << 3,
+};
+
// Test fixtures -------------------------------------------------------------
class AutomaticProfileResetterTestBase : public testing::Test {
@@ -149,14 +316,29 @@ class AutomaticProfileResetterTestBase : public testing::Test {
explicit AutomaticProfileResetterTestBase(
const std::string& experiment_group_name)
: local_state_(TestingBrowserProcess::GetGlobal()),
+ profile_(new TestingProfile()),
experiment_group_name_(experiment_group_name),
mock_delegate_(NULL) {
- // Make sure the factory is not optimized away, so prefs get registered.
+ // Make sure the factory is not optimized away, so whatever preferences it
+ // wants to register will actually get registered.
AutomaticProfileResetterFactory::GetInstance();
+
+ // Register some additional local state preferences for testing purposes.
+ PrefRegistrySimple* local_state_registry = local_state_.Get()->registry();
+ DCHECK(local_state_registry);
+ local_state_registry->RegisterStringPref(kTestPreferencePath, "");
+
+ // Register some additional user preferences for testing purposes.
+ user_prefs::PrefRegistrySyncable* user_prefs_registry =
+ profile_->GetTestingPrefService()->registry();
+ DCHECK(user_prefs_registry);
+ user_prefs_registry->RegisterStringPref(
+ kTestPreferencePath,
+ "",
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
virtual void SetUp() OVERRIDE {
- profile_.reset(new TestingProfile());
field_trials_.reset(new base::FieldTrialList(NULL));
base::FieldTrialList::CreateFieldTrial(kAutomaticProfileResetStudyName,
experiment_group_name_);
@@ -173,16 +355,18 @@ class AutomaticProfileResetterTestBase : public testing::Test {
}
void UnleashResetterAndWait() {
- resetter_->Initialize();
resetter_->SetDelegateForTesting(mock_delegate_); // Takes ownership.
resetter_->SetHashSeedForTesting(testing_hash_seed_);
resetter_->SetProgramForTesting(testing_program_);
+
+ resetter_->Activate();
base::RunLoop().RunUntilIdle();
content::BrowserThread::GetBlockingPool()->FlushForTesting();
base::RunLoop().RunUntilIdle();
}
TestingProfile* profile() { return profile_.get(); }
+ TestingPrefServiceSimple* local_state() { return local_state_.Get(); }
MockProfileResetterDelegate& mock_delegate() { return *mock_delegate_; }
AutomaticProfileResetter* resetter() { return resetter_.get(); }
@@ -257,6 +441,8 @@ TEST_F(AutomaticProfileResetterTestDryRun, ConditionsNotSatisfied) {
SetTestingProgram(ConstructProgram(false, false));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, 0x00u));
UnleashResetterAndWait();
@@ -278,6 +464,8 @@ TEST_F(AutomaticProfileResetterTestDryRun, OneConditionSatisfied) {
SetTestingProgram(ConstructProgram(true, false));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x01u, 0x01u));
UnleashResetterAndWait();
@@ -299,6 +487,8 @@ TEST_F(AutomaticProfileResetterTestDryRun, OtherConditionSatisfied) {
SetTestingProgram(ConstructProgram(false, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x02u, 0x01u));
UnleashResetterAndWait();
@@ -321,6 +511,8 @@ TEST_F(AutomaticProfileResetterTestDryRun,
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x01u));
UnleashResetterAndWait();
@@ -340,6 +532,8 @@ TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadPrefHostedMemento) {
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x03u));
UnleashResetterAndWait();
@@ -359,6 +553,8 @@ TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadLocalStateHostedMemento) {
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x05u));
UnleashResetterAndWait();
@@ -378,6 +574,8 @@ TEST_F(AutomaticProfileResetterTestDryRun, AlreadyHadFileHostedMemento) {
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x09u));
UnleashResetterAndWait();
@@ -416,6 +614,8 @@ TEST_F(AutomaticProfileResetterTest, ConditionsNotSatisfied) {
SetTestingProgram(ConstructProgram(false, false));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, 0x00u));
UnleashResetterAndWait();
@@ -437,6 +637,8 @@ TEST_F(AutomaticProfileResetterTest, OneConditionSatisfied) {
SetTestingProgram(ConstructProgram(true, false));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ShowPrompt());
EXPECT_CALL(mock_delegate(), ReportStatistics(0x01u, 0x01u));
@@ -459,6 +661,8 @@ TEST_F(AutomaticProfileResetterTest, OtherConditionSatisfied) {
SetTestingProgram(ConstructProgram(false, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ShowPrompt());
EXPECT_CALL(mock_delegate(), ReportStatistics(0x02u, 0x01u));
@@ -481,6 +685,8 @@ TEST_F(AutomaticProfileResetterTest, ConditionsSatisfiedAndInvalidMementos) {
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ShowPrompt());
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x01u));
@@ -501,6 +707,8 @@ TEST_F(AutomaticProfileResetterTest, PrefHostedMementoPreventsPrompt) {
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x03u));
UnleashResetterAndWait();
@@ -520,6 +728,8 @@ TEST_F(AutomaticProfileResetterTest, LocalStateHostedMementoPreventsPrompt) {
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x05u));
UnleashResetterAndWait();
@@ -539,6 +749,8 @@ TEST_F(AutomaticProfileResetterTest, FileHostedMementoPreventsPrompt) {
SetTestingProgram(ConstructProgram(true, true));
SetTestingHashSeed(kTestHashSeed);
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
EXPECT_CALL(mock_delegate(), ReportStatistics(0x03u, 0x09u));
UnleashResetterAndWait();
@@ -565,4 +777,127 @@ TEST_F(AutomaticProfileResetterTest, DoNothingWhenResourcesAreMissing) {
EXPECT_EQ("", memento_in_file.ReadValue());
}
+// Please see comments above ConstructProgramToCheckPreferences() to understand
+// how the following tests work.
+
+TEST_F(AutomaticProfileResetterTest, InputUserPreferencesCorrect) {
+ SetTestingProgram(ConstructProgramToCheckPreferences());
+ SetTestingHashSeed(kTestHashSeed);
+
+ PrefService* prefs = profile()->GetPrefs();
+ prefs->SetString(kTestPreferencePath, kTestPreferenceValue);
+
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ uint32 expected_mask =
+ HasExpectedUserPreference | UserPreferenceIsUserControlled;
+ EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, expected_mask));
+
+ UnleashResetterAndWait();
+}
+
+TEST_F(AutomaticProfileResetterTest, InputLocalStateCorrect) {
+ SetTestingProgram(ConstructProgramToCheckPreferences());
+ SetTestingHashSeed(kTestHashSeed);
+
+ PrefService* prefs = local_state();
+ prefs->SetString(kTestPreferencePath, kTestPreferenceValue);
+
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ uint32 expected_mask =
+ HasExpectedLocalStatePreference | LocalStateIsUserControlled;
+ EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, expected_mask));
+
+ UnleashResetterAndWait();
+}
+
+TEST_F(AutomaticProfileResetterTest, InputManagedUserPreferencesCorrect) {
+ SetTestingProgram(ConstructProgramToCheckPreferences());
+ SetTestingHashSeed(kTestHashSeed);
+
+ TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService();
+ prefs->SetManagedPref(kTestPreferencePath,
+ new base::StringValue(kTestPreferenceValue));
+
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ uint32 expected_mask = HasExpectedUserPreference;
+ EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, expected_mask));
+
+ UnleashResetterAndWait();
+}
+
+TEST_F(AutomaticProfileResetterTest, InputManagedLocalStateCorrect) {
+ SetTestingProgram(ConstructProgramToCheckPreferences());
+ SetTestingHashSeed(kTestHashSeed);
+
+ TestingPrefServiceSimple* prefs = local_state();
+ prefs->SetManagedPref(kTestPreferencePath,
+ new base::StringValue(kTestPreferenceValue));
+
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ uint32 expected_mask = HasExpectedLocalStatePreference;
+ EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, expected_mask));
+
+ UnleashResetterAndWait();
+}
+
+// Please see comments above ConstructProgramToCheckSearchEngines() to
+// understand how the following tests work.
+
+TEST_F(AutomaticProfileResetterTest, InputDefaultSearchProviderCorrect) {
+ SetTestingProgram(ConstructProgramToCheckSearchEngines());
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().emulated_default_search_provider_details().SetString(
+ kSearchURLAttributeKey, kTestSearchURL);
+
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ uint32 expected_mask =
+ HasExpectedDefaultSearchProvider | DefaultSearchProviderIsUserControlled;
+ EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, expected_mask));
+
+ UnleashResetterAndWait();
+}
+
+TEST_F(AutomaticProfileResetterTest, InputSearchProviderManagedCorrect) {
+ SetTestingProgram(ConstructProgramToCheckSearchEngines());
+ SetTestingHashSeed(kTestHashSeed);
+
+ mock_delegate().emulated_default_search_provider_details().SetString(
+ kSearchURLAttributeKey, kTestSearchURL);
+ mock_delegate().set_emulated_default_search_provider_is_managed(true);
+
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ uint32 expected_mask = HasExpectedDefaultSearchProvider;
+ EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, expected_mask));
+
+ UnleashResetterAndWait();
+}
+
+TEST_F(AutomaticProfileResetterTest, InputSearchProvidersCorrect) {
+ SetTestingProgram(ConstructProgramToCheckSearchEngines());
+ SetTestingHashSeed(kTestHashSeed);
+
+ base::DictionaryValue* search_provider_1 = new base::DictionaryValue;
+ base::DictionaryValue* search_provider_2 = new base::DictionaryValue;
+ search_provider_1->SetString(kSearchURLAttributeKey, kTestSearchURL);
+ search_provider_2->SetString(kSearchURLAttributeKey, kTestSearchURL2);
+ mock_delegate().emulated_search_providers_details().Append(search_provider_1);
+ mock_delegate().emulated_search_providers_details().Append(search_provider_2);
+
+ mock_delegate().ExpectCallsToWaitingMethods();
+ mock_delegate().ExpectCallsToGetterMethods();
+ uint32 expected_mask = DefaultSearchProviderIsUserControlled |
+ HasExpectedPrepopulatedSearchProvider1 |
+ HasExpectedPrepopulatedSearchProvider2;
+ EXPECT_CALL(mock_delegate(), ReportStatistics(0x00u, expected_mask));
+
+ UnleashResetterAndWait();
+}
+
} // namespace
« no previous file with comments | « chrome/browser/profile_resetter/automatic_profile_resetter_factory.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698