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 "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba
se.h" | 5 #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba
se.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/string16.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 17 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
17 #include "chrome/browser/ui/views/payments/view_stack.h" | 18 #include "chrome/browser/ui/views/payments/view_stack.h" |
18 #include "chrome/test/base/interactive_test_utils.h" | 19 #include "chrome/test/base/interactive_test_utils.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "components/payments/payment_request.h" | 21 #include "components/payments/payment_request.h" |
21 #include "components/payments/payment_request_web_contents_manager.h" | 22 #include "components/payments/payment_request_web_contents_manager.h" |
22 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 23 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
23 #include "content/public/browser/render_frame_host.h" | 24 #include "content/public/browser/render_frame_host.h" |
24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
25 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
26 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ui_test_utils::MoveMouseToCenterAndPress( | 173 ui_test_utils::MoveMouseToCenterAndPress( |
173 view, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 174 view, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
174 run_loop.QuitClosure()); | 175 run_loop.QuitClosure()); |
175 run_loop.Run(); | 176 run_loop.Run(); |
176 | 177 |
177 WaitForAnimation(); | 178 WaitForAnimation(); |
178 | 179 |
179 WaitForObservedEvent(); | 180 WaitForObservedEvent(); |
180 } | 181 } |
181 | 182 |
| 183 void PaymentRequestInteractiveTestBase::SetEditorTextfieldValue( |
| 184 const base::string16& value, |
| 185 autofill::ServerFieldType type) { |
| 186 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( |
| 187 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 188 DCHECK(textfield); |
| 189 textfield->SetText(value); |
| 190 textfield->OnContentsChanged(); |
| 191 textfield->OnBlur(); |
| 192 } |
| 193 |
| 194 bool PaymentRequestInteractiveTestBase::IsEditorTextfieldInvalid( |
| 195 autofill::ServerFieldType type) { |
| 196 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( |
| 197 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 198 DCHECK(textfield); |
| 199 return textfield->invalid(); |
| 200 } |
| 201 |
182 void PaymentRequestInteractiveTestBase::WaitForAnimation() { | 202 void PaymentRequestInteractiveTestBase::WaitForAnimation() { |
183 ViewStack* view_stack = dialog_view()->view_stack_for_testing(); | 203 ViewStack* view_stack = dialog_view()->view_stack_for_testing(); |
184 if (view_stack->slide_in_animator_->IsAnimating()) { | 204 if (view_stack->slide_in_animator_->IsAnimating()) { |
185 view_stack->slide_in_animator_->SetAnimationDuration(1); | 205 view_stack->slide_in_animator_->SetAnimationDuration(1); |
186 view_stack->slide_in_animator_->SetAnimationDelegate( | 206 view_stack->slide_in_animator_->SetAnimationDelegate( |
187 view_stack->top(), std::unique_ptr<gfx::AnimationDelegate>( | 207 view_stack->top(), std::unique_ptr<gfx::AnimationDelegate>( |
188 new gfx::TestAnimationDelegate())); | 208 new gfx::TestAnimationDelegate())); |
189 base::RunLoop().Run(); | 209 base::RunLoop().Run(); |
190 } else if (view_stack->slide_out_animator_->IsAnimating()) { | 210 } else if (view_stack->slide_out_animator_->IsAnimating()) { |
191 view_stack->slide_out_animator_->SetAnimationDuration(1); | 211 view_stack->slide_out_animator_->SetAnimationDuration(1); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 250 |
231 void PaymentRequestInteractiveTestBase::ResetEventObserver(DialogEvent event) { | 251 void PaymentRequestInteractiveTestBase::ResetEventObserver(DialogEvent event) { |
232 event_observer_ = base::MakeUnique<DialogEventObserver>(event); | 252 event_observer_ = base::MakeUnique<DialogEventObserver>(event); |
233 } | 253 } |
234 | 254 |
235 void PaymentRequestInteractiveTestBase::WaitForObservedEvent() { | 255 void PaymentRequestInteractiveTestBase::WaitForObservedEvent() { |
236 event_observer_->Wait(); | 256 event_observer_->Wait(); |
237 } | 257 } |
238 | 258 |
239 } // namespace payments | 259 } // namespace payments |
OLD | NEW |