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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 OnWalletSigninError(); | 281 OnWalletSigninError(); |
282 } | 282 } |
283 | 283 |
284 // Skips past the 2 second wait between FinishSubmit and DoFinishSubmit. | 284 // Skips past the 2 second wait between FinishSubmit and DoFinishSubmit. |
285 void ForceFinishSubmit() { | 285 void ForceFinishSubmit() { |
286 #if defined(TOOLKIT_VIEWS) | 286 #if defined(TOOLKIT_VIEWS) |
287 DoFinishSubmit(); | 287 DoFinishSubmit(); |
288 #endif | 288 #endif |
289 } | 289 } |
290 | 290 |
291 void SimulateSubmitButtonDelayBegin() { | |
292 // 10 second delay to avoid test flakiness. The test would be flaky if this | |
293 // delay expired before the test finishes. This delay does not affect | |
294 // execution time of the test. | |
295 static const int kSimulatedSubmitButtonDelayMs = 10000; | |
296 AutofillDialogControllerImpl::SubmitButtonDelayBegin( | |
297 kSimulatedSubmitButtonDelayMs); | |
298 } | |
299 | |
300 void SimulateSubmitButtonDelayEnd() { | |
301 AutofillDialogControllerImpl::OnSubmitButtonDelayEnd(); | |
302 } | |
303 | |
291 MOCK_METHOD0(LoadRiskFingerprintData, void()); | 304 MOCK_METHOD0(LoadRiskFingerprintData, void()); |
292 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; | 305 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; |
293 using AutofillDialogControllerImpl::IsEditingExistingData; | 306 using AutofillDialogControllerImpl::IsEditingExistingData; |
294 | 307 |
295 protected: | 308 protected: |
296 virtual PersonalDataManager* GetManager() OVERRIDE { | 309 virtual PersonalDataManager* GetManager() OVERRIDE { |
297 return &test_manager_; | 310 return &test_manager_; |
298 } | 311 } |
299 | 312 |
300 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { | 313 virtual wallet::WalletClient* GetWalletClient() OVERRIDE { |
(...skipping 10 matching lines...) Expand all Loading... | |
311 return true; | 324 return true; |
312 } | 325 } |
313 | 326 |
314 virtual void ShowNewCreditCardBubble( | 327 virtual void ShowNewCreditCardBubble( |
315 scoped_ptr<CreditCard> new_card, | 328 scoped_ptr<CreditCard> new_card, |
316 scoped_ptr<AutofillProfile> billing_profile) OVERRIDE { | 329 scoped_ptr<AutofillProfile> billing_profile) OVERRIDE { |
317 mock_new_card_bubble_controller_->Show(new_card.Pass(), | 330 mock_new_card_bubble_controller_->Show(new_card.Pass(), |
318 billing_profile.Pass()); | 331 billing_profile.Pass()); |
319 } | 332 } |
320 | 333 |
334 virtual void SubmitButtonDelayBegin(int delay_ms) OVERRIDE { | |
Evan Stade
2013/09/04 21:42:52
You don't verify that production code ever calls t
please use gerrit instead
2013/09/05 02:30:58
I've overridden SubmitButtonDelayBegin() to increm
| |
335 // Ignore in testing. | |
336 } | |
337 | |
338 virtual void OnSubmitButtonDelayEnd() OVERRIDE { | |
339 // Ignore in testing. | |
340 } | |
341 | |
321 private: | 342 private: |
322 // To specify our own metric logger. | 343 // To specify our own metric logger. |
323 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { | 344 virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE { |
324 return metric_logger_; | 345 return metric_logger_; |
325 } | 346 } |
326 | 347 |
327 const AutofillMetrics& metric_logger_; | 348 const AutofillMetrics& metric_logger_; |
328 TestPersonalDataManager test_manager_; | 349 TestPersonalDataManager test_manager_; |
329 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; | 350 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; |
330 GURL open_tab_url_; | 351 GURL open_tab_url_; |
(...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2384 TEST_F(AutofillDialogControllerTest, | 2405 TEST_F(AutofillDialogControllerTest, |
2385 SaveInChromePreferenceRememberedOnSuccess) { | 2406 SaveInChromePreferenceRememberedOnSuccess) { |
2386 EXPECT_TRUE(controller()->ShouldSaveInChrome()); | 2407 EXPECT_TRUE(controller()->ShouldSaveInChrome()); |
2387 SwitchToAutofill(); | 2408 SwitchToAutofill(); |
2388 FillCreditCardInputs(); | 2409 FillCreditCardInputs(); |
2389 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(false); | 2410 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(false); |
2390 controller()->OnAccept(); | 2411 controller()->OnAccept(); |
2391 EXPECT_FALSE(controller()->ShouldSaveInChrome()); | 2412 EXPECT_FALSE(controller()->ShouldSaveInChrome()); |
2392 } | 2413 } |
2393 | 2414 |
2415 TEST_F(AutofillDialogControllerTest, SubmitButtonDelayedOnStart) { | |
2416 controller()->SimulateSubmitButtonDelayBegin(); | |
2417 SwitchToAutofill(); | |
Evan Stade
2013/09/04 21:42:52
do you need this?
please use gerrit instead
2013/09/05 02:30:58
SwitchToAutofill() was to get rid of the wallet's
| |
2418 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
2419 controller()->SimulateSubmitButtonDelayEnd(); | |
2420 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
2421 } | |
2422 | |
2394 } // namespace autofill | 2423 } // namespace autofill |
OLD | NEW |