OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
| 10 #include "chrome/browser/ui/test/test_browser_dialog.h" |
10 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" | 11 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" |
11 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 12 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
13 #include "components/autofill/core/browser/autofill_profile.h" | 14 #include "components/autofill/core/browser/autofill_profile.h" |
14 #include "components/autofill/core/browser/autofill_test_utils.h" | 15 #include "components/autofill/core/browser/autofill_test_utils.h" |
15 #include "components/autofill/core/browser/credit_card.h" | 16 #include "components/autofill/core/browser/credit_card.h" |
16 #include "components/payments/content/payment_request.h" | 17 #include "components/payments/content/payment_request.h" |
17 #include "components/payments/content/payment_request_web_contents_manager.h" | 18 #include "components/payments/content/payment_request_web_contents_manager.h" |
18 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 19 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
19 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 GetPaymentRequests(GetActiveWebContents()); | 337 GetPaymentRequests(GetActiveWebContents()); |
337 EXPECT_EQ(1u, requests.size()); | 338 EXPECT_EQ(1u, requests.size()); |
338 std::vector<std::string> supported_card_networks = | 339 std::vector<std::string> supported_card_networks = |
339 requests[0]->spec()->supported_card_networks(); | 340 requests[0]->spec()->supported_card_networks(); |
340 EXPECT_EQ(3u, supported_card_networks.size()); | 341 EXPECT_EQ(3u, supported_card_networks.size()); |
341 EXPECT_EQ("mastercard", supported_card_networks[0]); | 342 EXPECT_EQ("mastercard", supported_card_networks[0]); |
342 EXPECT_EQ("visa", supported_card_networks[1]); | 343 EXPECT_EQ("visa", supported_card_networks[1]); |
343 EXPECT_EQ("jcb", supported_card_networks[2]); | 344 EXPECT_EQ("jcb", supported_card_networks[2]); |
344 } | 345 } |
345 | 346 |
| 347 // Test harness integrating with DialogBrowserTest to present the dialog in an |
| 348 // interactive manner for visual testing. |
| 349 class PaymentsRequestVisualTest |
| 350 : public SupportsTestDialog<PaymentRequestNoShippingTest> { |
| 351 protected: |
| 352 PaymentsRequestVisualTest() {} |
| 353 |
| 354 // TestBrowserDialog: |
| 355 void ShowDialog(const std::string& name) override { |
| 356 InvokePaymentRequestUI(); |
| 357 } |
| 358 |
| 359 bool AlwaysCloseAsynchronously() override { |
| 360 // Bypassing Widget::CanClose() causes payments::JourneyLogger to see the |
| 361 // show, but not the close, resulting in a DCHECK in its destructor. |
| 362 return true; |
| 363 } |
| 364 |
| 365 private: |
| 366 DISALLOW_COPY_AND_ASSIGN(PaymentsRequestVisualTest); |
| 367 }; |
| 368 |
| 369 IN_PROC_BROWSER_TEST_F(PaymentsRequestVisualTest, InvokeDialog_NoShipping) { |
| 370 RunDialog(); |
| 371 } |
| 372 |
346 } // namespace payments | 373 } // namespace payments |
OLD | NEW |