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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java

Issue 2158783002: Revert of Credit card editor for PaymentRequest UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 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;
9 import android.widget.CheckBox;
10 import android.widget.EditText; 7 import android.widget.EditText;
11 import android.widget.Spinner; 8 import android.widget.Spinner;
12 import android.widget.TextView; 9 import android.widget.TextView;
13 10
14 import org.chromium.base.ThreadUtils; 11 import org.chromium.base.ThreadUtils;
15 import org.chromium.base.test.util.CommandLineFlags; 12 import org.chromium.base.test.util.CommandLineFlags;
16 import org.chromium.base.test.util.UrlUtils; 13 import org.chromium.base.test.util.UrlUtils;
17 import org.chromium.chrome.R; 14 import org.chromium.chrome.R;
18 import org.chromium.chrome.browser.ChromeActivity; 15 import org.chromium.chrome.browser.ChromeActivity;
19 import org.chromium.chrome.browser.ChromeSwitches; 16 import org.chromium.chrome.browser.ChromeSwitches;
(...skipping 30 matching lines...) Expand all
50 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyToClose; 47 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyToClose;
51 protected final PaymentsCallbackHelper<PaymentRequestUI> mResultReady; 48 protected final PaymentsCallbackHelper<PaymentRequestUI> mResultReady;
52 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyForUnmaskInpu t; 49 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyForUnmaskInpu t;
53 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyToUnmask; 50 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyToUnmask;
54 protected final CallbackHelper mReadyToEdit; 51 protected final CallbackHelper mReadyToEdit;
55 protected final CallbackHelper mEditorValidationError; 52 protected final CallbackHelper mEditorValidationError;
56 protected final CallbackHelper mEditorTextUpdate; 53 protected final CallbackHelper mEditorTextUpdate;
57 protected final CallbackHelper mEditorDismissed; 54 protected final CallbackHelper mEditorDismissed;
58 protected final CallbackHelper mDismissed; 55 protected final CallbackHelper mDismissed;
59 protected final CallbackHelper mUnableToAbort; 56 protected final CallbackHelper mUnableToAbort;
60 protected final CallbackHelper mBillingAddressChangeProcessed;
61 private final AtomicReference<ContentViewCore> mViewCoreRef; 57 private final AtomicReference<ContentViewCore> mViewCoreRef;
62 private final AtomicReference<WebContents> mWebContentsRef; 58 private final AtomicReference<WebContents> mWebContentsRef;
63 private final String mTestFilePath; 59 private final String mTestFilePath;
64 private PaymentRequestUI mUI; 60 private PaymentRequestUI mUI;
65 private CardUnmaskPrompt mCardUnmaskPrompt; 61 private CardUnmaskPrompt mCardUnmaskPrompt;
66 62
67 protected PaymentRequestTestBase(String testFileName) { 63 protected PaymentRequestTestBase(String testFileName) {
68 super(ChromeActivity.class); 64 super(ChromeActivity.class);
69 mReadyForInput = new PaymentsCallbackHelper<>(); 65 mReadyForInput = new PaymentsCallbackHelper<>();
70 mReadyToPay = new PaymentsCallbackHelper<>(); 66 mReadyToPay = new PaymentsCallbackHelper<>();
71 mReadyToClose = new PaymentsCallbackHelper<>(); 67 mReadyToClose = new PaymentsCallbackHelper<>();
72 mResultReady = new PaymentsCallbackHelper<>(); 68 mResultReady = new PaymentsCallbackHelper<>();
73 mReadyForUnmaskInput = new PaymentsCallbackHelper<>(); 69 mReadyForUnmaskInput = new PaymentsCallbackHelper<>();
74 mReadyToUnmask = new PaymentsCallbackHelper<>(); 70 mReadyToUnmask = new PaymentsCallbackHelper<>();
75 mReadyToEdit = new CallbackHelper(); 71 mReadyToEdit = new CallbackHelper();
76 mEditorValidationError = new CallbackHelper(); 72 mEditorValidationError = new CallbackHelper();
77 mEditorTextUpdate = new CallbackHelper(); 73 mEditorTextUpdate = new CallbackHelper();
78 mEditorDismissed = new CallbackHelper(); 74 mEditorDismissed = new CallbackHelper();
79 mDismissed = new CallbackHelper(); 75 mDismissed = new CallbackHelper();
80 mUnableToAbort = new CallbackHelper(); 76 mUnableToAbort = new CallbackHelper();
81 mBillingAddressChangeProcessed = new CallbackHelper();
82 mViewCoreRef = new AtomicReference<>(); 77 mViewCoreRef = new AtomicReference<>();
83 mWebContentsRef = new AtomicReference<>(); 78 mWebContentsRef = new AtomicReference<>();
84 mTestFilePath = UrlUtils.getIsolatedTestFilePath( 79 mTestFilePath = UrlUtils.getIsolatedTestFilePath(
85 String.format("chrome/test/data/android/payments/%s", testFileNa me)); 80 String.format("chrome/test/data/android/payments/%s", testFileNa me));
86 } 81 }
87 82
88 @Override 83 @Override
89 public void startMainActivity() throws InterruptedException {} 84 public void startMainActivity() throws InterruptedException {}
90 85
91 protected abstract void onMainActivityStarted() 86 protected abstract void onMainActivityStarted()
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 int callCount = helper.getCallCount(); 149 int callCount = helper.getCallCount();
155 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 150 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
156 @Override 151 @Override
157 public void run() { 152 public void run() {
158 mUI.getShippingAddressSectionForTest().findViewById(resourceId). performClick(); 153 mUI.getShippingAddressSectionForTest().findViewById(resourceId). performClick();
159 } 154 }
160 }); 155 });
161 helper.waitForCallback(callCount); 156 helper.waitForCallback(callCount);
162 } 157 }
163 158
164 /** Clicks on an element in the "Payment" section of the payments UI. */
165 protected void clickInPaymentMethodAndWait(final int resourceId, CallbackHel per helper)
166 throws InterruptedException, TimeoutException {
167 int callCount = helper.getCallCount();
168 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
169 @Override
170 public void run() {
171 mUI.getPaymentMethodSectionForTest().findViewById(resourceId).pe rformClick();
172 }
173 });
174 helper.waitForCallback(callCount);
175 }
176
177 /** Clicks on an element in the "Contact Info" section of the payments UI. * / 159 /** Clicks on an element in the "Contact Info" section of the payments UI. * /
178 protected void clickInContactInfoAndWait(final int resourceId, CallbackHelpe r helper) 160 protected void clickInContactInfoAndWait(final int resourceId, CallbackHelpe r helper)
179 throws InterruptedException, TimeoutException { 161 throws InterruptedException, TimeoutException {
180 int callCount = helper.getCallCount(); 162 int callCount = helper.getCallCount();
181 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 163 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
182 @Override 164 @Override
183 public void run() { 165 public void run() {
184 mUI.getContactDetailsSectionForTest().findViewById(resourceId).p erformClick(); 166 mUI.getContactDetailsSectionForTest().findViewById(resourceId).p erformClick();
185 } 167 }
186 }); 168 });
187 helper.waitForCallback(callCount); 169 helper.waitForCallback(callCount);
188 }
189
190 /** Clicks on an element in the editor UI for credit cards. */
191 protected void clickInCardEditorAndWait(final int resourceId, CallbackHelper helper)
192 throws InterruptedException, TimeoutException {
193 int callCount = helper.getCallCount();
194 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
195 @Override
196 public void run() {
197 mUI.getCardEditorView().findViewById(resourceId).performClick();
198 }
199 });
200 helper.waitForCallback(callCount);
201 } 170 }
202 171
203 /** Clicks on an element in the editor UI. */ 172 /** Clicks on an element in the editor UI. */
204 protected void clickInEditorAndWait(final int resourceId, CallbackHelper hel per) 173 protected void clickInEditorAndWait(final int resourceId, CallbackHelper hel per)
205 throws InterruptedException, TimeoutException { 174 throws InterruptedException, TimeoutException {
206 int callCount = helper.getCallCount(); 175 int callCount = helper.getCallCount();
207 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 176 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
208 @Override 177 @Override
209 public void run() { 178 public void run() {
210 mUI.getEditorView().findViewById(resourceId).performClick(); 179 mUI.getEditorView().findViewById(resourceId).performClick();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 protected int getNumberOfShippingAddressSuggestions() throws ExecutionExcept ion { 259 protected int getNumberOfShippingAddressSuggestions() throws ExecutionExcept ion {
291 return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() { 260 return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
292 @Override 261 @Override
293 public Integer call() { 262 public Integer call() {
294 return ((OptionSection) mUI.getShippingAddressSectionForTest()) 263 return ((OptionSection) mUI.getShippingAddressSectionForTest())
295 .getNumberOfOptionLabelsForTest(); 264 .getNumberOfOptionLabelsForTest();
296 } 265 }
297 }); 266 });
298 } 267 }
299 268
300 /** Selects the spinner value in the editor UI for credit cards. */
301 protected void setSpinnerSelectionsInCardEditorAndWait(final int[] selection s,
302 CallbackHelper helper) throws InterruptedException, TimeoutException {
303 int callCount = helper.getCallCount();
304 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
305 @Override
306 public void run() {
307 List<Spinner> fields = mUI.getCardEditorView().getDropdownFields ForTest();
308 for (int i = 0; i < selections.length && i < fields.size(); i++) {
309 fields.get(i).setSelection(selections[i]);
310 }
311 }
312 });
313 helper.waitForCallback(callCount);
314 }
315
316 /** Selects the spinner value in the editor UI. */ 269 /** Selects the spinner value in the editor UI. */
317 protected void setSpinnerSelectionInEditorAndWait(final int selection, Callb ackHelper helper) 270 protected void setSpinnerSelectionInEditor(final int selection, CallbackHelp er helper)
318 throws InterruptedException, TimeoutException { 271 throws InterruptedException, TimeoutException {
319 int callCount = helper.getCallCount(); 272 int callCount = helper.getCallCount();
320 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 273 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
321 @Override 274 @Override
322 public void run() { 275 public void run() {
323 ((Spinner) mUI.getEditorView().findViewById(R.id.spinner)).setSe lection(selection); 276 ((Spinner) mUI.getEditorView().findViewById(R.id.spinner)).setSe lection(selection);
324 } 277 }
325 }); 278 });
326 helper.waitForCallback(callCount); 279 helper.waitForCallback(callCount);
327 }
328
329 /** Directly sets the text in the editor UI for credit cards. */
330 protected void setTextInCardEditorAndWait(final String[] values, CallbackHel per helper)
331 throws InterruptedException, TimeoutException {
332 int callCount = helper.getCallCount();
333 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
334 @Override
335 public void run() {
336 ViewGroup contents = (ViewGroup)
337 mUI.getCardEditorView().findViewById(R.id.contents);
338 assertNotNull(contents);
339 for (int i = 0, j = 0; i < contents.getChildCount() && j < value s.length; i++) {
340 View view = contents.getChildAt(i);
341 if (view instanceof EditorTextField) {
342 ((EditorTextField) view).getEditText().setText(values[j+ +]);
343 }
344 }
345 }
346 });
347 helper.waitForCallback(callCount);
348 } 280 }
349 281
350 /** Directly sets the text in the editor UI. */ 282 /** Directly sets the text in the editor UI. */
351 protected void setTextInEditorAndWait(final String[] values, CallbackHelper helper) 283 protected void setTextInEditorAndWait(final String[] values, CallbackHelper helper)
352 throws InterruptedException, TimeoutException { 284 throws InterruptedException, TimeoutException {
353 int callCount = helper.getCallCount(); 285 int callCount = helper.getCallCount();
354 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 286 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
355 @Override 287 @Override
356 public void run() { 288 public void run() {
357 List<EditText> fields = mUI.getEditorView().getEditableTextField sForTest(); 289 List<EditorTextField> fields = mUI.getEditorView().getEditorText Fields();
358 for (int i = 0; i < values.length; i++) { 290 for (int i = 0; i < values.length; i++) {
359 fields.get(i).setText(values[i]); 291 fields.get(i).getEditText().setText(values[i]);
360 } 292 }
361 } 293 }
362 }); 294 });
363 helper.waitForCallback(callCount); 295 helper.waitForCallback(callCount);
364 }
365
366 /** Directly sets the checkbox selection in the editor UI for credit cards. */
367 protected void selectCheckboxAndWait(final int resourceId, final boolean isC hecked,
368 CallbackHelper helper) throws InterruptedException, TimeoutException {
369 int callCount = helper.getCallCount();
370 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
371 @Override
372 public void run() {
373 ((CheckBox) mUI.getCardEditorView().findViewById(resourceId)).se tChecked(isChecked);
374 }
375 });
376 helper.waitForCallback(callCount);
377 } 296 }
378 297
379 /** Directly sets the text in the card unmask UI. */ 298 /** Directly sets the text in the card unmask UI. */
380 protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final String input, 299 protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final String input,
381 CallbackHelper helper) throws InterruptedException, TimeoutException { 300 CallbackHelper helper) throws InterruptedException, TimeoutException {
382 int callCount = helper.getCallCount(); 301 int callCount = helper.getCallCount();
383 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 302 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
384 @Override 303 @Override
385 public void run() { 304 public void run() {
386 ((EditText) mCardUnmaskPrompt.getDialogForTest().findViewById(re sourceId)) 305 ((EditText) mCardUnmaskPrompt.getDialogForTest().findViewById(re sourceId))
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 mDismissed.notifyCalled(); 393 mDismissed.notifyCalled();
475 } 394 }
476 395
477 @Override 396 @Override
478 public void onPaymentRequestServiceUnableToAbort() { 397 public void onPaymentRequestServiceUnableToAbort() {
479 ThreadUtils.assertOnUiThread(); 398 ThreadUtils.assertOnUiThread();
480 mUnableToAbort.notifyCalled(); 399 mUnableToAbort.notifyCalled();
481 } 400 }
482 401
483 @Override 402 @Override
484 public void onPaymentRequestServiceBillingAddressChangeProcessed() {
485 ThreadUtils.assertOnUiThread();
486 mBillingAddressChangeProcessed.notifyCalled();
487 }
488
489 @Override
490 public void onCardUnmaskPromptReadyForInput(CardUnmaskPrompt prompt) { 403 public void onCardUnmaskPromptReadyForInput(CardUnmaskPrompt prompt) {
491 ThreadUtils.assertOnUiThread(); 404 ThreadUtils.assertOnUiThread();
492 mReadyForUnmaskInput.notifyCalled(prompt); 405 mReadyForUnmaskInput.notifyCalled(prompt);
493 mCardUnmaskPrompt = prompt; 406 mCardUnmaskPrompt = prompt;
494 } 407 }
495 408
496 @Override 409 @Override
497 public void onCardUnmaskPromptReadyToUnmask(CardUnmaskPrompt prompt) { 410 public void onCardUnmaskPromptReadyToUnmask(CardUnmaskPrompt prompt) {
498 ThreadUtils.assertOnUiThread(); 411 ThreadUtils.assertOnUiThread();
499 mReadyToUnmask.notifyCalled(prompt); 412 mReadyToUnmask.notifyCalled(prompt);
(...skipping 19 matching lines...) Expand all
519 * 432 *
520 * @param ui The UI that is ready for input. 433 * @param ui The UI that is ready for input.
521 */ 434 */
522 public void notifyCalled(T target) { 435 public void notifyCalled(T target) {
523 ThreadUtils.assertOnUiThread(); 436 ThreadUtils.assertOnUiThread();
524 mTarget = target; 437 mTarget = target;
525 notifyCalled(); 438 notifyCalled();
526 } 439 }
527 } 440 }
528 } 441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698