| 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_combobox.h" |
| 17 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 18 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
| 18 #include "chrome/browser/ui/views/payments/view_stack.h" | 19 #include "chrome/browser/ui/views/payments/view_stack.h" |
| 19 #include "chrome/test/base/interactive_test_utils.h" | 20 #include "chrome/test/base/interactive_test_utils.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "components/payments/payment_request.h" | 22 #include "components/payments/payment_request.h" |
| 22 #include "components/payments/payment_request_web_contents_manager.h" | 23 #include "components/payments/payment_request_web_contents_manager.h" |
| 23 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 24 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 24 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
| 25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 const base::string16& value, | 185 const base::string16& value, |
| 185 autofill::ServerFieldType type) { | 186 autofill::ServerFieldType type) { |
| 186 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 187 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( |
| 187 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 188 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 188 DCHECK(textfield); | 189 DCHECK(textfield); |
| 189 textfield->SetText(value); | 190 textfield->SetText(value); |
| 190 textfield->OnContentsChanged(); | 191 textfield->OnContentsChanged(); |
| 191 textfield->OnBlur(); | 192 textfield->OnBlur(); |
| 192 } | 193 } |
| 193 | 194 |
| 195 void PaymentRequestInteractiveTestBase::SetComboboxValue( |
| 196 const base::string16& value, |
| 197 autofill::ServerFieldType type) { |
| 198 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( |
| 199 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 200 DCHECK(combobox); |
| 201 combobox->SelectValue(value); |
| 202 combobox->OnContentsChanged(); |
| 203 combobox->OnBlur(); |
| 204 } |
| 205 |
| 194 bool PaymentRequestInteractiveTestBase::IsEditorTextfieldInvalid( | 206 bool PaymentRequestInteractiveTestBase::IsEditorTextfieldInvalid( |
| 195 autofill::ServerFieldType type) { | 207 autofill::ServerFieldType type) { |
| 196 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 208 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( |
| 197 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 209 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 198 DCHECK(textfield); | 210 DCHECK(textfield); |
| 199 return textfield->invalid(); | 211 return textfield->invalid(); |
| 200 } | 212 } |
| 201 | 213 |
| 214 bool PaymentRequestInteractiveTestBase::IsEditorComboboxInvalid( |
| 215 autofill::ServerFieldType type) { |
| 216 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( |
| 217 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 218 DCHECK(combobox); |
| 219 return combobox->invalid(); |
| 220 } |
| 221 |
| 202 void PaymentRequestInteractiveTestBase::WaitForAnimation() { | 222 void PaymentRequestInteractiveTestBase::WaitForAnimation() { |
| 203 ViewStack* view_stack = dialog_view()->view_stack_for_testing(); | 223 ViewStack* view_stack = dialog_view()->view_stack_for_testing(); |
| 204 if (view_stack->slide_in_animator_->IsAnimating()) { | 224 if (view_stack->slide_in_animator_->IsAnimating()) { |
| 205 view_stack->slide_in_animator_->SetAnimationDuration(1); | 225 view_stack->slide_in_animator_->SetAnimationDuration(1); |
| 206 view_stack->slide_in_animator_->SetAnimationDelegate( | 226 view_stack->slide_in_animator_->SetAnimationDelegate( |
| 207 view_stack->top(), std::unique_ptr<gfx::AnimationDelegate>( | 227 view_stack->top(), std::unique_ptr<gfx::AnimationDelegate>( |
| 208 new gfx::TestAnimationDelegate())); | 228 new gfx::TestAnimationDelegate())); |
| 209 base::RunLoop().Run(); | 229 base::RunLoop().Run(); |
| 210 } else if (view_stack->slide_out_animator_->IsAnimating()) { | 230 } else if (view_stack->slide_out_animator_->IsAnimating()) { |
| 211 view_stack->slide_out_animator_->SetAnimationDuration(1); | 231 view_stack->slide_out_animator_->SetAnimationDuration(1); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 270 |
| 251 void PaymentRequestInteractiveTestBase::ResetEventObserver(DialogEvent event) { | 271 void PaymentRequestInteractiveTestBase::ResetEventObserver(DialogEvent event) { |
| 252 event_observer_ = base::MakeUnique<DialogEventObserver>(event); | 272 event_observer_ = base::MakeUnique<DialogEventObserver>(event); |
| 253 } | 273 } |
| 254 | 274 |
| 255 void PaymentRequestInteractiveTestBase::WaitForObservedEvent() { | 275 void PaymentRequestInteractiveTestBase::WaitForObservedEvent() { |
| 256 event_observer_->Wait(); | 276 event_observer_->Wait(); |
| 257 } | 277 } |
| 258 | 278 |
| 259 } // namespace payments | 279 } // namespace payments |
| OLD | NEW |