| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2615 | 2615 |
| 2616 // Simulate form submission. We should not call into the PDM to try to save | 2616 // Simulate form submission. We should not call into the PDM to try to save |
| 2617 // the filled data, since the filled form is effectively missing an address. | 2617 // the filled data, since the filled form is effectively missing an address. |
| 2618 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(0); | 2618 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(0); |
| 2619 FormSubmitted(results); | 2619 FormSubmitted(results); |
| 2620 } | 2620 } |
| 2621 | 2621 |
| 2622 // Checks that resetting the auxiliary profile enabled preference does the right | 2622 // Checks that resetting the auxiliary profile enabled preference does the right |
| 2623 // thing on all platforms. | 2623 // thing on all platforms. |
| 2624 TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { | 2624 TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { |
| 2625 PrefServiceBase* prefs = PrefServiceBase::ForProfile(profile()); | 2625 PrefServiceBase* prefs = PrefServiceBase::ForContext(profile()); |
| 2626 #if defined(OS_MACOSX) | 2626 #if defined(OS_MACOSX) |
| 2627 // Auxiliary profiles is implemented on Mac only. It enables Mac Address | 2627 // Auxiliary profiles is implemented on Mac only. It enables Mac Address |
| 2628 // Book integration. | 2628 // Book integration. |
| 2629 ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); | 2629 ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); |
| 2630 prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false); | 2630 prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false); |
| 2631 prefs->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled); | 2631 prefs->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled); |
| 2632 ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); | 2632 ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); |
| 2633 #else | 2633 #else |
| 2634 ASSERT_FALSE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); | 2634 ASSERT_FALSE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); |
| 2635 prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, true); | 2635 prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, true); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2911 types.clear(); | 2911 types.clear(); |
| 2912 types.insert(UNKNOWN_TYPE); | 2912 types.insert(UNKNOWN_TYPE); |
| 2913 form.fields.push_back(field); | 2913 form.fields.push_back(field); |
| 2914 expected_types.push_back(types); | 2914 expected_types.push_back(types); |
| 2915 | 2915 |
| 2916 autofill_manager_->set_expected_submitted_field_types(expected_types); | 2916 autofill_manager_->set_expected_submitted_field_types(expected_types); |
| 2917 FormSubmitted(form); | 2917 FormSubmitted(form); |
| 2918 } | 2918 } |
| 2919 | 2919 |
| 2920 TEST_F(AutofillManagerTest, UpdatePasswordSyncState) { | 2920 TEST_F(AutofillManagerTest, UpdatePasswordSyncState) { |
| 2921 PrefServiceBase* prefs = PrefServiceBase::ForProfile(profile()); | 2921 PrefServiceBase* prefs = PrefServiceBase::ForContext(profile()); |
| 2922 | 2922 |
| 2923 // Allow this test to control what should get synced. | 2923 // Allow this test to control what should get synced. |
| 2924 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); | 2924 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); |
| 2925 // Always set password generation enabled check box so we can test the | 2925 // Always set password generation enabled check box so we can test the |
| 2926 // behavior of password sync. | 2926 // behavior of password sync. |
| 2927 prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); | 2927 prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); |
| 2928 | 2928 |
| 2929 // Sync some things, but not passwords. Shouldn't send anything since | 2929 // Sync some things, but not passwords. Shouldn't send anything since |
| 2930 // password generation is disabled by default. | 2930 // password generation is disabled by default. |
| 2931 ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile( | 2931 ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 | 2969 |
| 2970 // When a new render_view is created, we send the state even if it's the | 2970 // When a new render_view is created, we send the state even if it's the |
| 2971 // same. | 2971 // same. |
| 2972 UpdatePasswordGenerationState(true); | 2972 UpdatePasswordGenerationState(true); |
| 2973 EXPECT_EQ(1u, autofill_manager_->GetSentStates().size()); | 2973 EXPECT_EQ(1u, autofill_manager_->GetSentStates().size()); |
| 2974 EXPECT_FALSE(autofill_manager_->GetSentStates()[0]); | 2974 EXPECT_FALSE(autofill_manager_->GetSentStates()[0]); |
| 2975 autofill_manager_->ClearSentStates(); | 2975 autofill_manager_->ClearSentStates(); |
| 2976 } | 2976 } |
| 2977 | 2977 |
| 2978 TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) { | 2978 TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) { |
| 2979 PrefServiceBase* prefs = PrefServiceBase::ForProfile(profile()); | 2979 PrefServiceBase* prefs = PrefServiceBase::ForContext(profile()); |
| 2980 | 2980 |
| 2981 // Always set password sync enabled so we can test the behavior of password | 2981 // Always set password sync enabled so we can test the behavior of password |
| 2982 // generation. | 2982 // generation. |
| 2983 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); | 2983 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); |
| 2984 ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile( | 2984 ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile( |
| 2985 profile()); | 2985 profile()); |
| 2986 sync_service->SetSyncSetupCompleted(); | 2986 sync_service->SetSyncSetupCompleted(); |
| 2987 syncer::ModelTypeSet preferred_set; | 2987 syncer::ModelTypeSet preferred_set; |
| 2988 preferred_set.Put(syncer::PASSWORDS); | 2988 preferred_set.Put(syncer::PASSWORDS); |
| 2989 sync_service->ChangePreferredDataTypes(preferred_set); | 2989 sync_service->ChangePreferredDataTypes(preferred_set); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3131 | 3131 |
| 3132 AutofillManager* autofill_manager = tab_contents()->autofill_manager(); | 3132 AutofillManager* autofill_manager = tab_contents()->autofill_manager(); |
| 3133 EXPECT_TRUE(autofill_manager->external_delegate()); | 3133 EXPECT_TRUE(autofill_manager->external_delegate()); |
| 3134 | 3134 |
| 3135 AutocompleteHistoryManager* autocomplete_history_manager = | 3135 AutocompleteHistoryManager* autocomplete_history_manager = |
| 3136 tab_contents()->autocomplete_history_manager(); | 3136 tab_contents()->autocomplete_history_manager(); |
| 3137 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); | 3137 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); |
| 3138 } | 3138 } |
| 3139 | 3139 |
| 3140 #endif // OS_ANDROID | 3140 #endif // OS_ANDROID |
| OLD | NEW |