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

Unified Diff: chrome/browser/autofill/autofill_manager_unittest.cc

Issue 10828345: Extract PrefServiceBase into chrome/browser/api. Use in api and autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 years, 4 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/autofill/autofill_manager.cc ('k') | chrome/browser/autofill/personal_data_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_manager_unittest.cc
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 408a4ce3171f88af0a65c732d045368b27945d93..abec88c89f6cb3be62a7c930fc449738b35c1970 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -14,6 +14,7 @@
#include "base/time.h"
#include "base/tuple.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/api/prefs/pref_service_base.h"
#include "chrome/browser/autofill/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/autofill/autofill_manager.h"
@@ -22,7 +23,6 @@
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/autofill/test_autofill_external_delegate.h"
-#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -2618,24 +2618,19 @@ TEST_F(AutofillManagerTest, FormSubmittedWithDefaultValues) {
// Checks that resetting the auxiliary profile enabled preference does the right
// thing on all platforms.
TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) {
+ PrefServiceBase* prefs = PrefServiceBase::ForProfile(profile());
#if defined(OS_MACOSX)
// Auxiliary profiles is implemented on Mac only. It enables Mac Address
// Book integration.
- ASSERT_TRUE(profile()->GetPrefs()->GetBoolean(
- prefs::kAutofillAuxiliaryProfilesEnabled));
- profile()->GetPrefs()->SetBoolean(
- prefs::kAutofillAuxiliaryProfilesEnabled, false);
- profile()->GetPrefs()->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled);
- ASSERT_TRUE(profile()->GetPrefs()->GetBoolean(
- prefs::kAutofillAuxiliaryProfilesEnabled));
+ ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled));
+ prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false);
+ prefs->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled);
+ ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled));
#else
- ASSERT_FALSE(profile()->GetPrefs()->GetBoolean(
- prefs::kAutofillAuxiliaryProfilesEnabled));
- profile()->GetPrefs()->SetBoolean(
- prefs::kAutofillAuxiliaryProfilesEnabled, true);
- profile()->GetPrefs()->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled);
- ASSERT_FALSE(profile()->GetPrefs()->GetBoolean(
- prefs::kAutofillAuxiliaryProfilesEnabled));
+ ASSERT_FALSE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled));
+ prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, true);
+ prefs->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled);
+ ASSERT_FALSE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled));
#endif
}
@@ -2919,11 +2914,13 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) {
}
TEST_F(AutofillManagerTest, UpdatePasswordSyncState) {
+ PrefServiceBase* prefs = PrefServiceBase::ForProfile(profile());
+
// Allow this test to control what should get synced.
- profile()->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
+ prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
// Always set password generation enabled check box so we can test the
// behavior of password sync.
- profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, true);
+ prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true);
// Sync some things, but not passwords. Shouldn't send anything since
// password generation is disabled by default.
@@ -2975,9 +2972,11 @@ TEST_F(AutofillManagerTest, UpdatePasswordSyncState) {
}
TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) {
+ PrefServiceBase* prefs = PrefServiceBase::ForProfile(profile());
+
// Always set password sync enabled so we can test the behavior of password
// generation.
- profile()->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
+ prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile(
profile());
sync_service->SetSyncSetupCompleted();
@@ -2986,24 +2985,24 @@ TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) {
sync_service->ChangePreferredDataTypes(preferred_set);
// Enabled state remains false, should not sent.
- profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, false);
+ prefs->SetBoolean(prefs::kPasswordGenerationEnabled, false);
UpdatePasswordGenerationState(false);
EXPECT_EQ(0u, autofill_manager_->GetSentStates().size());
// Enabled state from false to true, should sent true.
- profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, true);
+ prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true);
UpdatePasswordGenerationState(false);
EXPECT_EQ(1u, autofill_manager_->GetSentStates().size());
EXPECT_TRUE(autofill_manager_->GetSentStates()[0]);
autofill_manager_->ClearSentStates();
// Enabled states remains true, should not sent.
- profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, true);
+ prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true);
UpdatePasswordGenerationState(false);
EXPECT_EQ(0u, autofill_manager_->GetSentStates().size());
// Enabled states from true to false, should sent false.
- profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, false);
+ prefs->SetBoolean(prefs::kPasswordGenerationEnabled, false);
UpdatePasswordGenerationState(false);
EXPECT_EQ(1u, autofill_manager_->GetSentStates().size());
EXPECT_FALSE(autofill_manager_->GetSentStates()[0]);
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/autofill/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698