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

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: Truncate to top 4 suggestions 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 {
224 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
225 @Override
226 public String call() {
227 if (mUI.getContactDetailsSectionForTest().findViewById(
please use gerrit instead 2016/07/07 13:59:36 Don't call findByView() twice. Save the result and
sebsg 2016/07/08 07:54:52 Done.
228 mOptionLabelIds[suggestionIndex]) == null) {
229 return null;
230 }
231 return ((TextView) mUI.getContactDetailsSectionForTest().findVie wById(
232 mOptionLabelIds[suggestionIndex])).getText().toString();
233 }
234 });
235 }
236
237 /**
238 * Returns the label corresponding to the shipping address suggestion at th e specified
239 * |suggestionIndex|. Returns null if there is no suggestion at |suggestion Index|.
240 */
241 protected String getShippingAddressSuggestionLabel(final int suggestionIndex )
242 throws ExecutionException {
243 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
244 @Override
245 public String call() {
246 if (mUI.getShippingAddressSectionForTest().findViewById(
247 mOptionLabelIds[suggestionIndex]) == null) {
248 return null;
249 }
250 return ((TextView) mUI.getShippingAddressSectionForTest().findVi ewById(
251 mOptionLabelIds[suggestionIndex])).getText().toString();
252 }
253 });
254 }
255
209 /** Selects the spinner value in the editor UI. */ 256 /** Selects the spinner value in the editor UI. */
210 protected void setSpinnerSelectionInEditor(final int selection, CallbackHelp er helper) 257 protected void setSpinnerSelectionInEditor(final int selection, CallbackHelp er helper)
211 throws InterruptedException, TimeoutException { 258 throws InterruptedException, TimeoutException {
212 int callCount = helper.getCallCount(); 259 int callCount = helper.getCallCount();
213 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 260 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
214 @Override 261 @Override
215 public void run() { 262 public void run() {
216 ViewGroup contents = (ViewGroup) mUI.getEditorView().findViewByI d(R.id.contents); 263 ViewGroup contents = (ViewGroup) mUI.getEditorView().findViewByI d(R.id.contents);
217 assertNotNull(contents); 264 assertNotNull(contents);
218 for (int i = 0; i < contents.getChildCount(); i++) { 265 for (int i = 0; i < contents.getChildCount(); i++) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 * 431 *
385 * @param ui The UI that is ready for input. 432 * @param ui The UI that is ready for input.
386 */ 433 */
387 public void notifyCalled(T target) { 434 public void notifyCalled(T target) {
388 ThreadUtils.assertOnUiThread(); 435 ThreadUtils.assertOnUiThread();
389 mTarget = target; 436 mTarget = target;
390 notifyCalled(); 437 notifyCalled();
391 } 438 }
392 } 439 }
393 } 440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698