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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_browsertest_base.cc

Issue 2733953003: [Payments] Return a basic card response (Closed)
Patch Set: addressed comments from anthony Created 3 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
OLDNEW
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 "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" 5 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/autofill/personal_data_manager_factory.h" 14 #include "chrome/browser/autofill/personal_data_manager_factory.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 18 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
19 #include "chrome/browser/ui/views/payments/validating_combobox.h" 19 #include "chrome/browser/ui/views/payments/validating_combobox.h"
20 #include "chrome/browser/ui/views/payments/validating_textfield.h" 20 #include "chrome/browser/ui/views/payments/validating_textfield.h"
21 #include "chrome/browser/ui/views/payments/view_stack.h" 21 #include "chrome/browser/ui/views/payments/view_stack.h"
22 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/autofill/core/browser/autofill_profile.h" 23 #include "components/autofill/core/browser/autofill_profile.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js)); 126 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js));
127 127
128 WaitForObservedEvent(); 128 WaitForObservedEvent();
129 129
130 // The web-modal dialog should be open. 130 // The web-modal dialog should be open.
131 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = 131 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager =
132 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); 132 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
133 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); 133 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive());
134 } 134 }
135 135
136 void PaymentRequestBrowserTestBase::ExpectBodyContains(
137 const std::vector<base::string16>& expected_strings) {
138 content::WebContents* web_contents = GetActiveWebContents();
139 const std::string extract_contents_js =
140 "(function() { "
141 "window.domAutomationController.send(window.document.body.textContent); "
142 "})()";
143 std::string contents;
144 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
145 web_contents, extract_contents_js, &contents));
146 for (const auto expected_string : expected_strings) {
147 EXPECT_NE(std::string::npos,
148 contents.find(base::UTF16ToUTF8(expected_string)))
149 << "String not present: " << expected_string;
150 }
151 }
152
136 void PaymentRequestBrowserTestBase::OpenOrderSummaryScreen() { 153 void PaymentRequestBrowserTestBase::OpenOrderSummaryScreen() {
137 ResetEventObserver(DialogEvent::ORDER_SUMMARY_OPENED); 154 ResetEventObserver(DialogEvent::ORDER_SUMMARY_OPENED);
138 155
139 ClickOnDialogViewAndWait(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION); 156 ClickOnDialogViewAndWait(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION);
140 } 157 }
141 158
142 void PaymentRequestBrowserTestBase::OpenPaymentMethodScreen() { 159 void PaymentRequestBrowserTestBase::OpenPaymentMethodScreen() {
143 ResetEventObserver(DialogEvent::PAYMENT_METHOD_OPENED); 160 ResetEventObserver(DialogEvent::PAYMENT_METHOD_OPENED);
144 161
145 ClickOnDialogViewAndWait(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION); 162 ClickOnDialogViewAndWait(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 367
351 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) { 368 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) {
352 event_observer_ = base::MakeUnique<DialogEventObserver>(event); 369 event_observer_ = base::MakeUnique<DialogEventObserver>(event);
353 } 370 }
354 371
355 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { 372 void PaymentRequestBrowserTestBase::WaitForObservedEvent() {
356 event_observer_->Wait(); 373 event_observer_->Wait();
357 } 374 }
358 375
359 } // namespace payments 376 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_browsertest_base.h ('k') | components/payments/content/payment_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698