| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import android.view.View; |
| 8 import android.view.ViewGroup; |
| 7 import android.widget.EditText; | 9 import android.widget.EditText; |
| 8 import android.widget.Spinner; | 10 import android.widget.Spinner; |
| 9 import android.widget.TextView; | 11 import android.widget.TextView; |
| 10 | 12 |
| 11 import org.chromium.base.ThreadUtils; | 13 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.base.test.util.CommandLineFlags; | 14 import org.chromium.base.test.util.CommandLineFlags; |
| 13 import org.chromium.base.test.util.UrlUtils; | 15 import org.chromium.base.test.util.UrlUtils; |
| 14 import org.chromium.chrome.R; | 16 import org.chromium.chrome.R; |
| 15 import org.chromium.chrome.browser.ChromeActivity; | 17 import org.chromium.chrome.browser.ChromeActivity; |
| 16 import org.chromium.chrome.browser.ChromeSwitches; | 18 import org.chromium.chrome.browser.ChromeSwitches; |
| 17 import org.chromium.chrome.browser.autofill.CardUnmaskPrompt; | 19 import org.chromium.chrome.browser.autofill.CardUnmaskPrompt; |
| 18 import org.chromium.chrome.browser.autofill.CardUnmaskPrompt.CardUnmaskObserverF
orTest; | 20 import org.chromium.chrome.browser.autofill.CardUnmaskPrompt.CardUnmaskObserverF
orTest; |
| 19 import org.chromium.chrome.browser.payments.PaymentRequestImpl.PaymentRequestSer
viceObserverForTest; | 21 import org.chromium.chrome.browser.payments.PaymentRequestImpl.PaymentRequestSer
viceObserverForTest; |
| 20 import org.chromium.chrome.browser.payments.ui.EditorTextField; | 22 import org.chromium.chrome.browser.payments.ui.EditorTextField; |
| 21 import org.chromium.chrome.browser.payments.ui.PaymentRequestUI; | 23 import org.chromium.chrome.browser.payments.ui.PaymentRequestUI; |
| 22 import org.chromium.chrome.browser.payments.ui.PaymentRequestUI.PaymentRequestOb
serverForTest; | 24 import org.chromium.chrome.browser.payments.ui.PaymentRequestUI.PaymentRequestOb
serverForTest; |
| 23 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 25 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 24 import org.chromium.content.browser.ContentViewCore; | 26 import org.chromium.content.browser.ContentViewCore; |
| 25 import org.chromium.content.browser.test.util.CallbackHelper; | 27 import org.chromium.content.browser.test.util.CallbackHelper; |
| 26 import org.chromium.content.browser.test.util.Criteria; | 28 import org.chromium.content.browser.test.util.Criteria; |
| 27 import org.chromium.content.browser.test.util.CriteriaHelper; | 29 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 28 import org.chromium.content.browser.test.util.DOMUtils; | 30 import org.chromium.content.browser.test.util.DOMUtils; |
| 29 import org.chromium.content_public.browser.WebContents; | 31 import org.chromium.content_public.browser.WebContents; |
| 30 | 32 |
| 31 import java.util.List; | |
| 32 import java.util.concurrent.Callable; | 33 import java.util.concurrent.Callable; |
| 33 import java.util.concurrent.ExecutionException; | 34 import java.util.concurrent.ExecutionException; |
| 34 import java.util.concurrent.TimeoutException; | 35 import java.util.concurrent.TimeoutException; |
| 35 import java.util.concurrent.atomic.AtomicReference; | 36 import java.util.concurrent.atomic.AtomicReference; |
| 36 | 37 |
| 37 /** | 38 /** |
| 38 * A base integration test for payments. | 39 * A base integration test for payments. |
| 39 */ | 40 */ |
| 40 @CommandLineFlags.Add({ChromeSwitches.EXPERIMENTAL_WEB_PLAFTORM_FEATURES}) | 41 @CommandLineFlags.Add({ChromeSwitches.EXPERIMENTAL_WEB_PLAFTORM_FEATURES}) |
| 41 abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
ctivity> | 42 abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
ctivity> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 }); | 206 }); |
| 206 } | 207 } |
| 207 | 208 |
| 208 /** Selects the spinner value in the editor UI. */ | 209 /** Selects the spinner value in the editor UI. */ |
| 209 protected void setSpinnerSelectionInEditor(final int selection, CallbackHelp
er helper) | 210 protected void setSpinnerSelectionInEditor(final int selection, CallbackHelp
er helper) |
| 210 throws InterruptedException, TimeoutException { | 211 throws InterruptedException, TimeoutException { |
| 211 int callCount = helper.getCallCount(); | 212 int callCount = helper.getCallCount(); |
| 212 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 213 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 213 @Override | 214 @Override |
| 214 public void run() { | 215 public void run() { |
| 215 ((Spinner) mUI.getEditorView().findViewById(R.id.spinner)).setSe
lection(selection); | 216 ViewGroup contents = (ViewGroup) mUI.getEditorView().findViewByI
d(R.id.contents); |
| 217 assertNotNull(contents); |
| 218 for (int i = 0; i < contents.getChildCount(); i++) { |
| 219 View view = contents.getChildAt(i); |
| 220 if (view instanceof Spinner) { |
| 221 ((Spinner) view).setSelection(selection); |
| 222 return; |
| 223 } |
| 224 } |
| 216 } | 225 } |
| 217 }); | 226 }); |
| 218 helper.waitForCallback(callCount); | 227 helper.waitForCallback(callCount); |
| 219 } | 228 } |
| 220 | 229 |
| 221 /** Directly sets the text in the editor UI. */ | 230 /** Directly sets the text in the editor UI. */ |
| 222 protected void setTextInEditorAndWait(final String[] values, CallbackHelper
helper) | 231 protected void setTextInEditorAndWait(final String[] values, CallbackHelper
helper) |
| 223 throws InterruptedException, TimeoutException { | 232 throws InterruptedException, TimeoutException { |
| 224 int callCount = helper.getCallCount(); | 233 int callCount = helper.getCallCount(); |
| 225 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 234 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 226 @Override | 235 @Override |
| 227 public void run() { | 236 public void run() { |
| 228 List<EditorTextField> fields = mUI.getEditorView().getEditorText
Fields(); | 237 ViewGroup contents = (ViewGroup) mUI.getEditorView().findViewByI
d(R.id.contents); |
| 229 for (int i = 0; i < values.length; i++) { | 238 assertNotNull(contents); |
| 230 fields.get(i).getEditText().setText(values[i]); | 239 for (int i = 0, j = 0; i < contents.getChildCount() && j < value
s.length; i++) { |
| 240 View view = contents.getChildAt(i); |
| 241 if (view instanceof EditorTextField) { |
| 242 ((EditorTextField) view).getEditText().setText(values[j+
+]); |
| 243 } |
| 231 } | 244 } |
| 232 } | 245 } |
| 233 }); | 246 }); |
| 234 helper.waitForCallback(callCount); | 247 helper.waitForCallback(callCount); |
| 235 } | 248 } |
| 236 | 249 |
| 237 /** Directly sets the text in the card unmask UI. */ | 250 /** Directly sets the text in the card unmask UI. */ |
| 238 protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final
String input, | 251 protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final
String input, |
| 239 CallbackHelper helper) throws InterruptedException, TimeoutException
{ | 252 CallbackHelper helper) throws InterruptedException, TimeoutException
{ |
| 240 int callCount = helper.getCallCount(); | 253 int callCount = helper.getCallCount(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 * | 384 * |
| 372 * @param ui The UI that is ready for input. | 385 * @param ui The UI that is ready for input. |
| 373 */ | 386 */ |
| 374 public void notifyCalled(T target) { | 387 public void notifyCalled(T target) { |
| 375 ThreadUtils.assertOnUiThread(); | 388 ThreadUtils.assertOnUiThread(); |
| 376 mTarget = target; | 389 mTarget = target; |
| 377 notifyCalled(); | 390 notifyCalled(); |
| 378 } | 391 } |
| 379 } | 392 } |
| 380 } | 393 } |
| OLD | NEW |