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

Side by Side Diff: chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.mm

Issue 2040143006: Implement the Sync promo in the password bubble on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h" 5 #include "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/password_manager/password_store_factory.h" 8 #include "chrome/browser/password_manager/password_store_factory.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
10 #include "components/password_manager/core/browser/mock_password_store.h" 10 #include "components/password_manager/core/browser/mock_password_store.h"
(...skipping 20 matching lines...) Expand all
31 // Create the test UIController here so that it's bound to and owned by 31 // Create the test UIController here so that it's bound to and owned by
32 // |test_web_contents_| and therefore accessible to the model. 32 // |test_web_contents_| and therefore accessible to the model.
33 test_web_contents_.reset( 33 test_web_contents_.reset(
34 content::WebContentsTester::CreateTestWebContents(profile(), NULL)); 34 content::WebContentsTester::CreateTestWebContents(profile(), NULL));
35 ui_controller_ = new testing::NiceMock<ManagePasswordsUIControllerMock>( 35 ui_controller_ = new testing::NiceMock<ManagePasswordsUIControllerMock>(
36 test_web_contents_.get()); 36 test_web_contents_.get());
37 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( 37 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
38 profile(), password_manager::BuildPasswordStore< 38 profile(), password_manager::BuildPasswordStore<
39 content::BrowserContext, 39 content::BrowserContext,
40 testing::NiceMock<password_manager::MockPasswordStore>>); 40 testing::NiceMock<password_manager::MockPasswordStore>>);
41 delegate_.reset([[ContentViewDelegateMock alloc] init]);
41 } 42 }
42 43
43 ManagePasswordsBubbleModel* 44 ManagePasswordsBubbleModel*
44 ManagePasswordsControllerTest::GetModelAndCreateIfNull() { 45 ManagePasswordsControllerTest::GetModelAndCreateIfNull() {
45 if (!model_) { 46 if (!model_) {
46 model_.reset(new ManagePasswordsBubbleModel(test_web_contents_.get(), 47 model_.reset(new ManagePasswordsBubbleModel(test_web_contents_.get(),
47 GetDisplayReason())); 48 GetDisplayReason()));
49 [delegate() setModel:model_.get()];
48 } 50 }
49 return model_.get(); 51 return model_.get();
50 } 52 }
51 53
52 void ManagePasswordsControllerTest::SetUpSavePendingState(bool empty_username) { 54 void ManagePasswordsControllerTest::SetUpSavePendingState(bool empty_username) {
53 autofill::PasswordForm form; 55 autofill::PasswordForm form;
54 if (!empty_username) { 56 if (!empty_username) {
55 form.username_value = base::ASCIIToUTF16("username"); 57 form.username_value = base::ASCIIToUTF16("username");
56 } 58 }
57 EXPECT_CALL(*ui_controller_, GetPendingPassword()).WillOnce(ReturnRef(form)); 59 EXPECT_CALL(*ui_controller_, GetPendingPassword()).WillOnce(ReturnRef(form));
(...skipping 27 matching lines...) Expand all
85 87
86 void ManagePasswordsControllerTest::SetUpConfirmationState() { 88 void ManagePasswordsControllerTest::SetUpConfirmationState() {
87 GURL origin(kSiteOrigin); 89 GURL origin(kSiteOrigin);
88 EXPECT_CALL(*ui_controller_, GetOrigin()).WillOnce(ReturnRef(origin)); 90 EXPECT_CALL(*ui_controller_, GetOrigin()).WillOnce(ReturnRef(origin));
89 EXPECT_CALL(*ui_controller_, GetState()) 91 EXPECT_CALL(*ui_controller_, GetState())
90 .WillOnce(Return(password_manager::ui::CONFIRMATION_STATE)); 92 .WillOnce(Return(password_manager::ui::CONFIRMATION_STATE));
91 GetModelAndCreateIfNull(); 93 GetModelAndCreateIfNull();
92 ASSERT_TRUE(testing::Mock::VerifyAndClearExpectations(ui_controller_)); 94 ASSERT_TRUE(testing::Mock::VerifyAndClearExpectations(ui_controller_));
93 } 95 }
94 96
95 void ManagePasswordsControllerTest::SetUpManageState() { 97 void ManagePasswordsControllerTest::SetUpManageState(
96 std::vector<const autofill::PasswordForm*> forms; 98 const VectorConstFormPtr& forms) {
97 EXPECT_CALL(*ui_controller_, GetCurrentForms()).WillOnce(ReturnRef(forms)); 99 EXPECT_CALL(*ui_controller_, GetCurrentForms()).WillOnce(ReturnRef(forms));
98 GURL origin(kSiteOrigin); 100 GURL origin(kSiteOrigin);
99 EXPECT_CALL(*ui_controller_, GetOrigin()).WillOnce(ReturnRef(origin)); 101 EXPECT_CALL(*ui_controller_, GetOrigin()).WillOnce(ReturnRef(origin));
100 EXPECT_CALL(*ui_controller_, GetState()) 102 EXPECT_CALL(*ui_controller_, GetState())
101 .WillOnce(Return(password_manager::ui::MANAGE_STATE)); 103 .WillOnce(Return(password_manager::ui::MANAGE_STATE));
102 GetModelAndCreateIfNull(); 104 GetModelAndCreateIfNull();
103 ASSERT_TRUE(testing::Mock::VerifyAndClearExpectations(ui_controller_)); 105 ASSERT_TRUE(testing::Mock::VerifyAndClearExpectations(ui_controller_));
104 } 106 }
105 107
106 ManagePasswordsBubbleModel::DisplayReason 108 ManagePasswordsBubbleModel::DisplayReason
107 ManagePasswordsControllerTest::GetDisplayReason() const { 109 ManagePasswordsControllerTest::GetDisplayReason() const {
108 return ManagePasswordsBubbleModel::AUTOMATIC; 110 return ManagePasswordsBubbleModel::AUTOMATIC;
109 } 111 }
110 112
111 @implementation ContentViewDelegateMock 113 @implementation ContentViewDelegateMock
112 114
113 @synthesize model = _model; 115 @synthesize model = _model;
114 @synthesize dismissed = _dismissed; 116 @synthesize dismissed = _dismissed;
115 117
116 - (void)viewShouldDismiss { 118 - (void)viewShouldDismiss {
117 _dismissed = YES; 119 _dismissed = YES;
118 } 120 }
119 121
122 - (void)refreshBubble {
123 }
124
120 @end 125 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698