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

Side by Side Diff: chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm

Issue 3140024: Implement policy for disabling auto fill. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: regenerate XIBs in order to avoid maxID corruption. Created 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/ref_counted.h" 5 #include "base/ref_counted.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h"
7 #import "chrome/browser/autofill/autofill_address_model_mac.h" 8 #import "chrome/browser/autofill/autofill_address_model_mac.h"
8 #import "chrome/browser/autofill/autofill_address_sheet_controller_mac.h" 9 #import "chrome/browser/autofill/autofill_address_sheet_controller_mac.h"
9 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h" 10 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h"
10 #import "chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.h" 11 #import "chrome/browser/autofill/autofill_credit_card_sheet_controller_mac.h"
11 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" 12 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h"
12 #include "chrome/browser/autofill/autofill_profile.h" 13 #include "chrome/browser/autofill/autofill_profile.h"
13 #include "chrome/browser/autofill/personal_data_manager.h" 14 #include "chrome/browser/autofill/personal_data_manager.h"
14 #include "chrome/browser/cocoa/browser_test_helper.h" 15 #include "chrome/browser/cocoa/browser_test_helper.h"
15 #import "chrome/browser/cocoa/cocoa_test_helper.h" 16 #import "chrome/browser/cocoa/cocoa_test_helper.h"
16 #include "chrome/browser/pref_service.h" 17 #include "chrome/browser/pref_service.h"
17 #include "chrome/browser/profile.h" 18 #include "chrome/browser/profile.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/testing_pref_service.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 22
21 namespace { 23 namespace {
22 24
23 // Simulated delay (in milliseconds) for web data loading. 25 // Simulated delay (in milliseconds) for web data loading.
24 const float kWebDataLoadDelayMilliseconds = 10.0; 26 const float kWebDataLoadDelayMilliseconds = 10.0;
25 27
26 // Mock PersonalDataManager that gives back canned profiles and credit cards 28 // Mock PersonalDataManager that gives back canned profiles and credit cards
27 // as well as simulating delayed loading of web data using the 29 // as well as simulating delayed loading of web data using the
28 // |PersonalDataManager::Observer| interface. 30 // |PersonalDataManager::Observer| interface.
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 [controller_ save:nil]; 762 [controller_ save:nil];
761 763
762 // Should hit our observer. 764 // Should hit our observer.
763 ASSERT_TRUE(observer_.hit_); 765 ASSERT_TRUE(observer_.hit_);
764 766
765 // Auxiliary profiles setting should be unchanged. 767 // Auxiliary profiles setting should be unchanged.
766 ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean( 768 ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean(
767 prefs::kAutoFillEnabled)); 769 prefs::kAutoFillEnabled));
768 } 770 }
769 771
772 TEST_F(AutoFillDialogControllerTest, PolicyRefresh) {
773 LoadDialog();
774 ASSERT_FALSE([controller_ autoFillManaged]);
775
776 // Disable AutoFill through configuration policy.
777 helper_.profile()->GetTestingPrefService()->SetManagedPref(
778 prefs::kAutoFillEnabled, Value::CreateBooleanValue(false));
779 ASSERT_TRUE([controller_ autoFillManaged]);
780 ASSERT_FALSE([controller_ autoFillEnabled]);
781
782 // Enabling through policy should switch to enabled but not editable.
783 helper_.profile()->GetTestingPrefService()->SetManagedPref(
784 prefs::kAutoFillEnabled, Value::CreateBooleanValue(true));
785 ASSERT_TRUE([controller_ autoFillManaged]);
786 ASSERT_TRUE([controller_ autoFillEnabled]);
787
788 [controller_ cancel:nil];
789 }
790
791 TEST_F(AutoFillDialogControllerTest, PolicyDisabledAndSave) {
792 // Disable AutoFill through configuration policy.
793 helper_.profile()->GetTestingPrefService()->SetManagedPref(
794 prefs::kAutoFillEnabled, Value::CreateBooleanValue(false));
795 helper_.profile()->GetPrefs()->SetBoolean(
796 prefs::kAutoFillAuxiliaryProfilesEnabled, false);
797 LoadDialog();
798
799 // Save should be disabled.
800 ASSERT_TRUE([controller_ autoFillManagedAndDisabled]);
801
802 [controller_ setAuxiliaryEnabled:YES];
803 [controller_ save:nil];
804
805 // Observer should not have been called.
806 ASSERT_FALSE(observer_.hit_);
807
808 // Auxiliary profiles setting should be unchanged.
809 ASSERT_FALSE(helper_.profile()->GetPrefs()->GetBoolean(
810 prefs::kAutoFillAuxiliaryProfilesEnabled));
811 }
812
813 TEST_F(AutoFillDialogControllerTest, PolicyEnabledAndSave) {
814 // Enable AutoFill through configuration policy.
815 helper_.profile()->GetTestingPrefService()->SetManagedPref(
816 prefs::kAutoFillEnabled, Value::CreateBooleanValue(true));
817 helper_.profile()->GetPrefs()->SetBoolean(
818 prefs::kAutoFillAuxiliaryProfilesEnabled, false);
819 LoadDialog();
820
821 // Save should be enabled.
822 ASSERT_FALSE([controller_ autoFillManagedAndDisabled]);
823
824 [controller_ setAuxiliaryEnabled:YES];
825 [controller_ save:nil];
826
827 // Observer should have been notified.
828 ASSERT_TRUE(observer_.hit_);
829
830 // Auxiliary profiles setting should have been saved.
831 ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean(
832 prefs::kAutoFillAuxiliaryProfilesEnabled));
833 }
834
770 } // namespace 835 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_dialog_controller_mac.mm ('k') | chrome/browser/autofill/autofill_dialog_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698