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

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

Issue 668171: AutoFill Mac preference for enabling Address Book "me" card usage.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
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 #import "chrome/browser/autofill/autofill_address_model_mac.h" 5 #import "chrome/browser/autofill/autofill_address_model_mac.h"
6 #import "chrome/browser/autofill/autofill_address_view_controller_mac.h" 6 #import "chrome/browser/autofill/autofill_address_view_controller_mac.h"
7 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h" 7 #import "chrome/browser/autofill/autofill_credit_card_model_mac.h"
8 #import "chrome/browser/autofill/autofill_credit_card_view_controller_mac.h" 8 #import "chrome/browser/autofill/autofill_credit_card_view_controller_mac.h"
9 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" 9 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h"
10 #include "chrome/browser/autofill/autofill_profile.h" 10 #include "chrome/browser/autofill/autofill_profile.h"
11 #include "chrome/browser/cocoa/browser_test_helper.h" 11 #include "chrome/browser/cocoa/browser_test_helper.h"
12 #import "chrome/browser/cocoa/cocoa_test_helper.h" 12 #import "chrome/browser/cocoa/cocoa_test_helper.h"
13 #include "chrome/browser/pref_service.h"
13 #include "chrome/browser/profile.h" 14 #include "chrome/browser/profile.h"
15 #include "chrome/common/pref_names.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace { 18 namespace {
17 class AutoFillDialogObserverTester : public AutoFillDialogObserver { 19 class AutoFillDialogObserverTester : public AutoFillDialogObserver {
18 public: 20 public:
19 AutoFillDialogObserverTester() : hit_(false) {} 21 AutoFillDialogObserverTester()
22 : hit_(false) {}
20 virtual ~AutoFillDialogObserverTester() {} 23 virtual ~AutoFillDialogObserverTester() {}
21 24
22 virtual void OnAutoFillDialogApply( 25 virtual void OnAutoFillDialogApply(
23 std::vector<AutoFillProfile>* profiles, 26 std::vector<AutoFillProfile>* profiles,
24 std::vector<CreditCard>* credit_cards) { 27 std::vector<CreditCard>* credit_cards) {
25 hit_ = true; 28 hit_ = true;
26 29
27 std::vector<AutoFillProfile>::iterator i; 30 std::vector<AutoFillProfile>::iterator i;
28 profiles_.clear(); 31 profiles_.clear();
29 for (i = profiles->begin(); i != profiles->end(); ++i) 32 for (i = profiles->begin(); i != profiles->end(); ++i)
(...skipping 14 matching lines...) Expand all
44 }; 47 };
45 48
46 class AutoFillDialogControllerTest : public CocoaTest { 49 class AutoFillDialogControllerTest : public CocoaTest {
47 public: 50 public:
48 AutoFillDialogControllerTest() {} 51 AutoFillDialogControllerTest() {}
49 52
50 void LoadDialog() { 53 void LoadDialog() {
51 controller_ = [AutoFillDialogController 54 controller_ = [AutoFillDialogController
52 controllerWithObserver:&observer_ 55 controllerWithObserver:&observer_
53 autoFillProfiles:profiles_ 56 autoFillProfiles:profiles_
54 creditCards:credit_cards_]; 57 creditCards:credit_cards_
58 profile:helper_.profile()];
55 [controller_ window]; 59 [controller_ window];
56 } 60 }
57 61
58 BrowserTestHelper helper_; 62 BrowserTestHelper helper_;
59 AutoFillDialogObserverTester observer_; 63 AutoFillDialogObserverTester observer_;
60 AutoFillDialogController* controller_; // weak reference 64 AutoFillDialogController* controller_; // weak reference
61 std::vector<AutoFillProfile*> profiles_; // weak references within vector 65 std::vector<AutoFillProfile*> profiles_; // weak references within vector
62 std::vector<CreditCard*> credit_cards_; // weak references within vector 66 std::vector<CreditCard*> credit_cards_; // weak references within vector
63 67
64 private: 68 private:
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 385
382 // Sizes should match be different. New size should be 0. 386 // Sizes should match be different. New size should be 0.
383 ASSERT_NE(observer_.credit_cards_.size(), credit_cards_.size()); 387 ASSERT_NE(observer_.credit_cards_.size(), credit_cards_.size());
384 ASSERT_EQ(observer_.credit_cards_.size(), 1UL); 388 ASSERT_EQ(observer_.credit_cards_.size(), 1UL);
385 389
386 // First credit card should match. 390 // First credit card should match.
387 credit_cards_[0]->set_unique_id(observer_.credit_cards_[0].unique_id()); 391 credit_cards_[0]->set_unique_id(observer_.credit_cards_[0].unique_id());
388 ASSERT_EQ(observer_.credit_cards_[0], credit_card); 392 ASSERT_EQ(observer_.credit_cards_[0], credit_card);
389 } 393 }
390 394
395 TEST_F(AutoFillDialogControllerTest, AuxiliaryProfilesFalse) {
396 LoadDialog();
397 [controller_ save:nil];
398
399 // Should hit our observer.
400 ASSERT_TRUE(observer_.hit_);
401
402 // Auxiliary profiles setting should be unchanged.
403 ASSERT_FALSE(helper_.profile()->GetPrefs()->GetBoolean(
404 prefs::kAutoFillAuxiliaryProfilesEnabled));
405 }
406
407 TEST_F(AutoFillDialogControllerTest, AuxiliaryProfilesTrue) {
408 helper_.profile()->GetPrefs()->SetBoolean(
409 prefs::kAutoFillAuxiliaryProfilesEnabled, true);
410 LoadDialog();
411 [controller_ save:nil];
412
413 // Should hit our observer.
414 ASSERT_TRUE(observer_.hit_);
415
416 // Auxiliary profiles setting should be unchanged.
417 ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean(
418 prefs::kAutoFillAuxiliaryProfilesEnabled));
419 }
420
421 TEST_F(AutoFillDialogControllerTest, AuxiliaryProfilesChanged) {
422 helper_.profile()->GetPrefs()->SetBoolean(
423 prefs::kAutoFillAuxiliaryProfilesEnabled, false);
424 LoadDialog();
425 [controller_ setAuxiliaryEnabled:YES];
426 [controller_ save:nil];
427
428 // Should hit our observer.
429 ASSERT_TRUE(observer_.hit_);
430
431 // Auxiliary profiles setting should be unchanged.
432 ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean(
433 prefs::kAutoFillAuxiliaryProfilesEnabled));
434 }
391 435
392 } 436 }
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