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

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

Issue 2120973002: [Payments] Show complete profiles first and limit to 4 suggestions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 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; 7 import android.view.View;
8 import android.view.ViewGroup; 8 import android.view.ViewGroup;
9 import android.widget.EditText; 9 import android.widget.EditText;
10 import android.widget.Spinner; 10 import android.widget.Spinner;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 protected final CallbackHelper mEditorTextUpdate; 53 protected final CallbackHelper mEditorTextUpdate;
54 protected final CallbackHelper mEditorDismissed; 54 protected final CallbackHelper mEditorDismissed;
55 protected final CallbackHelper mDismissed; 55 protected final CallbackHelper mDismissed;
56 protected final CallbackHelper mUnableToAbort; 56 protected final CallbackHelper mUnableToAbort;
57 private final AtomicReference<ContentViewCore> mViewCoreRef; 57 private final AtomicReference<ContentViewCore> mViewCoreRef;
58 private final AtomicReference<WebContents> mWebContentsRef; 58 private final AtomicReference<WebContents> mWebContentsRef;
59 private final String mTestFilePath; 59 private final String mTestFilePath;
60 private PaymentRequestUI mUI; 60 private PaymentRequestUI mUI;
61 private CardUnmaskPrompt mCardUnmaskPrompt; 61 private CardUnmaskPrompt mCardUnmaskPrompt;
62 62
63 /** An array mapping the index of a option label to its id. */
64 private final int[] mOptionLabelIds = {
65 R.id.payments_first_option_label,
66 R.id.payments_second_option_label,
67 R.id.payments_third_option_label,
68 R.id.payments_fourth_option_label,
69 R.id.payments_fifth_option_label
70 };
71
63 protected PaymentRequestTestBase(String testFileName) { 72 protected PaymentRequestTestBase(String testFileName) {
64 super(ChromeActivity.class); 73 super(ChromeActivity.class);
65 mReadyForInput = new PaymentsCallbackHelper<>(); 74 mReadyForInput = new PaymentsCallbackHelper<>();
66 mReadyToPay = new PaymentsCallbackHelper<>(); 75 mReadyToPay = new PaymentsCallbackHelper<>();
67 mReadyToClose = new PaymentsCallbackHelper<>(); 76 mReadyToClose = new PaymentsCallbackHelper<>();
68 mResultReady = new PaymentsCallbackHelper<>(); 77 mResultReady = new PaymentsCallbackHelper<>();
69 mReadyForUnmaskInput = new PaymentsCallbackHelper<>(); 78 mReadyForUnmaskInput = new PaymentsCallbackHelper<>();
70 mReadyToUnmask = new PaymentsCallbackHelper<>(); 79 mReadyToUnmask = new PaymentsCallbackHelper<>();
71 mReadyToEdit = new CallbackHelper(); 80 mReadyToEdit = new CallbackHelper();
72 mEditorValidationError = new CallbackHelper(); 81 mEditorValidationError = new CallbackHelper();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 protected String getAddressSectionLabel() throws ExecutionException { 208 protected String getAddressSectionLabel() throws ExecutionException {
200 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() { 209 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
201 @Override 210 @Override
202 public String call() { 211 public String call() {
203 return ((TextView) mUI.getShippingSummarySectionForTest().findVi ewById( 212 return ((TextView) mUI.getShippingSummarySectionForTest().findVi ewById(
204 R.id.payments_left_summary_label)).getText().toString(); 213 R.id.payments_left_summary_label)).getText().toString();
205 } 214 }
206 }); 215 });
207 } 216 }
208 217
218 /**
219 * Returns the label corresponding to the contact detail suggestion at the specified
220 * |suggestionIndex|. Returns null if there is no suggestion at |suggestion Index|.
221 */
222 protected String getContactDetailsSuggestionLabel(final int suggestionIndex)
223 throws ExecutionException {
please use gerrit instead 2016/07/08 08:36:31 assert suggestionIndex < mOoptionLabelIds.length;
sebsg 2016/07/08 09:20:25 Done.
224 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
225 @Override
226 public String call() {
227 View view = mUI.getContactDetailsSectionForTest().findViewById(
228 mOptionLabelIds[suggestionIndex]);
229
230 if (view == null) {
please use gerrit instead 2016/07/08 08:36:31 return view == null ? null : ((TextView) view).get
sebsg 2016/07/08 09:20:25 Done.
231 return null;
232 }
233 return ((TextView) view).getText().toString();
234 }
235 });
236 }
237
238 /**
239 * Returns the label corresponding to the shipping address suggestion at th e specified
240 * |suggestionIndex|. Returns null if there is no suggestion at |suggestion Index|.
241 */
242 protected String getShippingAddressSuggestionLabel(final int suggestionIndex )
243 throws ExecutionException {
please use gerrit instead 2016/07/08 08:36:31 assert suggestionIndex < mOoptionLabelIds.length;
sebsg 2016/07/08 09:20:25 Done.
244 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
245 @Override
246 public String call() {
247 View view = mUI.getShippingAddressSectionForTest().findViewById(
248 mOptionLabelIds[suggestionIndex]);
249
250 if (view == null) {
please use gerrit instead 2016/07/08 08:36:31 Ditto.
sebsg 2016/07/08 09:20:25 Done.
251 return null;
252 }
253 return ((TextView) view).getText().toString();
254 }
255 });
256 }
257
209 /** Selects the spinner value in the editor UI. */ 258 /** Selects the spinner value in the editor UI. */
210 protected void setSpinnerSelectionInEditor(final int selection, CallbackHelp er helper) 259 protected void setSpinnerSelectionInEditor(final int selection, CallbackHelp er helper)
211 throws InterruptedException, TimeoutException { 260 throws InterruptedException, TimeoutException {
212 int callCount = helper.getCallCount(); 261 int callCount = helper.getCallCount();
213 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 262 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
214 @Override 263 @Override
215 public void run() { 264 public void run() {
216 ViewGroup contents = (ViewGroup) mUI.getEditorView().findViewByI d(R.id.contents); 265 ViewGroup contents = (ViewGroup) mUI.getEditorView().findViewByI d(R.id.contents);
217 assertNotNull(contents); 266 assertNotNull(contents);
218 for (int i = 0; i < contents.getChildCount(); i++) { 267 for (int i = 0; i < contents.getChildCount(); i++) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 * 433 *
385 * @param ui The UI that is ready for input. 434 * @param ui The UI that is ready for input.
386 */ 435 */
387 public void notifyCalled(T target) { 436 public void notifyCalled(T target) {
388 ThreadUtils.assertOnUiThread(); 437 ThreadUtils.assertOnUiThread();
389 mTarget = target; 438 mTarget = target;
390 notifyCalled(); 439 notifyCalled();
391 } 440 }
392 } 441 }
393 } 442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698