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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 627043002: replace OVERRIDE and FINAL with override and final in chrome/browser/ui/[a-s]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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) 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 class MockAutofillMetrics : public AutofillMetrics { 90 class MockAutofillMetrics : public AutofillMetrics {
91 public: 91 public:
92 MockAutofillMetrics() 92 MockAutofillMetrics()
93 : dialog_dismissal_action_(static_cast<DialogDismissalAction>(-1)) {} 93 : dialog_dismissal_action_(static_cast<DialogDismissalAction>(-1)) {}
94 virtual ~MockAutofillMetrics() {} 94 virtual ~MockAutofillMetrics() {}
95 95
96 virtual void LogDialogUiDuration( 96 virtual void LogDialogUiDuration(
97 const base::TimeDelta& duration, 97 const base::TimeDelta& duration,
98 DialogDismissalAction dismissal_action) const OVERRIDE { 98 DialogDismissalAction dismissal_action) const override {
99 // Ignore constness for testing. 99 // Ignore constness for testing.
100 MockAutofillMetrics* mutable_this = const_cast<MockAutofillMetrics*>(this); 100 MockAutofillMetrics* mutable_this = const_cast<MockAutofillMetrics*>(this);
101 mutable_this->dialog_dismissal_action_ = dismissal_action; 101 mutable_this->dialog_dismissal_action_ = dismissal_action;
102 } 102 }
103 103
104 AutofillMetrics::DialogDismissalAction dialog_dismissal_action() const { 104 AutofillMetrics::DialogDismissalAction dialog_dismissal_action() const {
105 return dialog_dismissal_action_; 105 return dialog_dismissal_action_;
106 } 106 }
107 107
108 MOCK_CONST_METHOD1(LogDialogDismissalState, 108 MOCK_CONST_METHOD1(LogDialogDismissalState,
(...skipping 25 matching lines...) Expand all
134 sign_in_user_index_(0U), 134 sign_in_user_index_(0U),
135 weak_ptr_factory_(this) { 135 weak_ptr_factory_(this) {
136 test_manager_.Init( 136 test_manager_.Init(
137 NULL, 137 NULL,
138 Profile::FromBrowserContext(contents->GetBrowserContext())->GetPrefs(), 138 Profile::FromBrowserContext(contents->GetBrowserContext())->GetPrefs(),
139 false); 139 false);
140 } 140 }
141 141
142 virtual ~TestAutofillDialogController() {} 142 virtual ~TestAutofillDialogController() {}
143 143
144 virtual GURL SignInUrl() const OVERRIDE { 144 virtual GURL SignInUrl() const override {
145 return GURL(chrome::kChromeUIVersionURL); 145 return GURL(chrome::kChromeUIVersionURL);
146 } 146 }
147 147
148 virtual void ViewClosed() OVERRIDE { 148 virtual void ViewClosed() override {
149 message_loop_runner_->Quit(); 149 message_loop_runner_->Quit();
150 AutofillDialogControllerImpl::ViewClosed(); 150 AutofillDialogControllerImpl::ViewClosed();
151 } 151 }
152 152
153 virtual base::string16 InputValidityMessage( 153 virtual base::string16 InputValidityMessage(
154 DialogSection section, 154 DialogSection section,
155 ServerFieldType type, 155 ServerFieldType type,
156 const base::string16& value) OVERRIDE { 156 const base::string16& value) override {
157 if (!use_validation_) 157 if (!use_validation_)
158 return base::string16(); 158 return base::string16();
159 return AutofillDialogControllerImpl::InputValidityMessage( 159 return AutofillDialogControllerImpl::InputValidityMessage(
160 section, type, value); 160 section, type, value);
161 } 161 }
162 162
163 virtual ValidityMessages InputsAreValid( 163 virtual ValidityMessages InputsAreValid(
164 DialogSection section, 164 DialogSection section,
165 const FieldValueMap& inputs) OVERRIDE { 165 const FieldValueMap& inputs) override {
166 if (!use_validation_) 166 if (!use_validation_)
167 return ValidityMessages(); 167 return ValidityMessages();
168 return AutofillDialogControllerImpl::InputsAreValid(section, inputs); 168 return AutofillDialogControllerImpl::InputsAreValid(section, inputs);
169 } 169 }
170 170
171 // Saving to Chrome is tested in AutofillDialogControllerImpl unit tests. 171 // Saving to Chrome is tested in AutofillDialogControllerImpl unit tests.
172 // TODO(estade): test that the view defaults to saving to Chrome. 172 // TODO(estade): test that the view defaults to saving to Chrome.
173 virtual bool ShouldOfferToSaveInChrome() const OVERRIDE { 173 virtual bool ShouldOfferToSaveInChrome() const override {
174 return true; 174 return true;
175 } 175 }
176 176
177 void ForceFinishSubmit() { 177 void ForceFinishSubmit() {
178 DoFinishSubmit(); 178 DoFinishSubmit();
179 } 179 }
180 180
181 // Increase visibility for testing. 181 // Increase visibility for testing.
182 using AutofillDialogControllerImpl::view; 182 using AutofillDialogControllerImpl::view;
183 using AutofillDialogControllerImpl::popup_input_type; 183 using AutofillDialogControllerImpl::popup_input_type;
184 184
185 MOCK_METHOD0(LoadRiskFingerprintData, void()); 185 MOCK_METHOD0(LoadRiskFingerprintData, void());
186 186
187 virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE { 187 virtual std::vector<DialogNotification> CurrentNotifications() override {
188 return notifications_; 188 return notifications_;
189 } 189 }
190 190
191 void set_notifications(const std::vector<DialogNotification>& notifications) { 191 void set_notifications(const std::vector<DialogNotification>& notifications) {
192 notifications_ = notifications; 192 notifications_ = notifications;
193 } 193 }
194 194
195 TestPersonalDataManager* GetTestingManager() { 195 TestPersonalDataManager* GetTestingManager() {
196 return &test_manager_; 196 return &test_manager_;
197 } 197 }
(...skipping 21 matching lines...) Expand all
219 219
220 wallet::MockWalletClient* GetTestingWalletClient() { 220 wallet::MockWalletClient* GetTestingWalletClient() {
221 return &mock_wallet_client_; 221 return &mock_wallet_client_;
222 } 222 }
223 223
224 void set_sign_in_user_index(size_t sign_in_user_index) { 224 void set_sign_in_user_index(size_t sign_in_user_index) {
225 sign_in_user_index_ = sign_in_user_index; 225 sign_in_user_index_ = sign_in_user_index;
226 } 226 }
227 227
228 protected: 228 protected:
229 virtual PersonalDataManager* GetManager() const OVERRIDE { 229 virtual PersonalDataManager* GetManager() const override {
230 return &const_cast<TestAutofillDialogController*>(this)->test_manager_; 230 return &const_cast<TestAutofillDialogController*>(this)->test_manager_;
231 } 231 }
232 232
233 virtual AddressValidator* GetValidator() OVERRIDE { 233 virtual AddressValidator* GetValidator() override {
234 return &mock_validator_; 234 return &mock_validator_;
235 } 235 }
236 236
237 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { 237 virtual wallet::WalletClient* GetWalletClient() override {
238 return &mock_wallet_client_; 238 return &mock_wallet_client_;
239 } 239 }
240 240
241 virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const 241 virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const
242 OVERRIDE { 242 override {
243 *user_index = sign_in_user_index_; 243 *user_index = sign_in_user_index_;
244 return url == wallet::GetSignInContinueUrl(); 244 return url == wallet::GetSignInContinueUrl();
245 } 245 }
246 246
247 private: 247 private:
248 // To specify our own metric logger. 248 // To specify our own metric logger.
249 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { 249 virtual const AutofillMetrics& GetMetricLogger() const override {
250 return metric_logger_; 250 return metric_logger_;
251 } 251 }
252 252
253 const AutofillMetrics& metric_logger_; 253 const AutofillMetrics& metric_logger_;
254 TestPersonalDataManager test_manager_; 254 TestPersonalDataManager test_manager_;
255 testing::NiceMock<MockAddressValidator> mock_validator_; 255 testing::NiceMock<MockAddressValidator> mock_validator_;
256 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; 256 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_;
257 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 257 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
258 bool use_validation_; 258 bool use_validation_;
259 259
(...skipping 22 matching lines...) Expand all
282 const content::NotificationSource& source) 282 const content::NotificationSource& source)
283 : WindowedNotificationObserver(content::NOTIFICATION_NAV_ENTRY_COMMITTED, 283 : WindowedNotificationObserver(content::NOTIFICATION_NAV_ENTRY_COMMITTED,
284 source), 284 source),
285 url_(url) {} 285 url_(url) {}
286 286
287 virtual ~NavEntryCommittedObserver() {} 287 virtual ~NavEntryCommittedObserver() {}
288 288
289 // content::NotificationObserver: 289 // content::NotificationObserver:
290 virtual void Observe(int type, 290 virtual void Observe(int type,
291 const content::NotificationSource& source, 291 const content::NotificationSource& source,
292 const content::NotificationDetails& details) OVERRIDE { 292 const content::NotificationDetails& details) override {
293 content::LoadCommittedDetails* load_details = 293 content::LoadCommittedDetails* load_details =
294 content::Details<content::LoadCommittedDetails>(details).ptr(); 294 content::Details<content::LoadCommittedDetails>(details).ptr();
295 if (load_details->entry->GetVirtualURL() != url_) 295 if (load_details->entry->GetVirtualURL() != url_)
296 return; 296 return;
297 297
298 WindowedNotificationObserver::Observe(type, source, details); 298 WindowedNotificationObserver::Observe(type, source, details);
299 } 299 }
300 300
301 private: 301 private:
302 GURL url_; 302 GURL url_;
303 303
304 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver); 304 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver);
305 }; 305 };
306 306
307 } // namespace 307 } // namespace
308 308
309 class AutofillDialogControllerTest : public InProcessBrowserTest { 309 class AutofillDialogControllerTest : public InProcessBrowserTest {
310 public: 310 public:
311 AutofillDialogControllerTest() : controller_(NULL) {} 311 AutofillDialogControllerTest() : controller_(NULL) {}
312 virtual ~AutofillDialogControllerTest() {} 312 virtual ~AutofillDialogControllerTest() {}
313 313
314 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 314 virtual void SetUpCommandLine(CommandLine* command_line) override {
315 command_line->AppendSwitch(::switches::kReduceSecurityForTesting); 315 command_line->AppendSwitch(::switches::kReduceSecurityForTesting);
316 } 316 }
317 317
318 virtual void SetUpOnMainThread() OVERRIDE { 318 virtual void SetUpOnMainThread() override {
319 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); 319 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs());
320 InitializeController(); 320 InitializeController();
321 } 321 }
322 322
323 protected: 323 protected:
324 bool SectionHasField(DialogSection section, ServerFieldType type) { 324 bool SectionHasField(DialogSection section, ServerFieldType type) {
325 const DetailInputs& fields = 325 const DetailInputs& fields =
326 controller()->RequestedFieldsForSection(section); 326 controller()->RequestedFieldsForSection(section);
327 for (size_t i = 0; i < fields.size(); ++i) { 327 for (size_t i = 0; i < fields.size(); ++i) {
328 if (type == fields[i].type) 328 if (type == fields[i].type)
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 EXPECT_TRUE(RunTestPage(http_server)); 1494 EXPECT_TRUE(RunTestPage(http_server));
1495 } 1495 }
1496 1496
1497 // Like the parent test, but doesn't add the --reduce-security-for-testing flag. 1497 // Like the parent test, but doesn't add the --reduce-security-for-testing flag.
1498 class AutofillDialogControllerSecurityTest : 1498 class AutofillDialogControllerSecurityTest :
1499 public AutofillDialogControllerTest { 1499 public AutofillDialogControllerTest {
1500 public: 1500 public:
1501 AutofillDialogControllerSecurityTest() {} 1501 AutofillDialogControllerSecurityTest() {}
1502 virtual ~AutofillDialogControllerSecurityTest() {} 1502 virtual ~AutofillDialogControllerSecurityTest() {}
1503 1503
1504 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1504 virtual void SetUpCommandLine(CommandLine* command_line) override {
1505 CHECK(!command_line->HasSwitch(::switches::kReduceSecurityForTesting)); 1505 CHECK(!command_line->HasSwitch(::switches::kReduceSecurityForTesting));
1506 } 1506 }
1507 1507
1508 typedef net::BaseTestServer::SSLOptions SSLOptions; 1508 typedef net::BaseTestServer::SSLOptions SSLOptions;
1509 1509
1510 private: 1510 private:
1511 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerSecurityTest); 1511 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerSecurityTest);
1512 }; 1512 };
1513 1513
1514 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerSecurityTest, 1514 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerSecurityTest,
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 "<input autocomplete='transaction-currency' value='USD'>" 1766 "<input autocomplete='transaction-currency' value='USD'>"
1767 "<input autocomplete='cc-csc'>"); 1767 "<input autocomplete='cc-csc'>");
1768 AutofillDialogControllerImpl* controller = SetUpHtmlAndInvoke(html); 1768 AutofillDialogControllerImpl* controller = SetUpHtmlAndInvoke(html);
1769 ASSERT_TRUE(controller); 1769 ASSERT_TRUE(controller);
1770 1770
1771 EXPECT_EQ(ASCIIToUTF16("24"), controller->transaction_amount_); 1771 EXPECT_EQ(ASCIIToUTF16("24"), controller->transaction_amount_);
1772 EXPECT_EQ(ASCIIToUTF16("USD"), controller->transaction_currency_); 1772 EXPECT_EQ(ASCIIToUTF16("USD"), controller->transaction_currency_);
1773 } 1773 }
1774 1774
1775 } // namespace autofill 1775 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/account_chooser_model.h ('k') | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698