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

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

Issue 2108623004: Reland: Refactor contact editor controller into its own class. (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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPhoneTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.widget.EditText; 7 import android.widget.EditText;
8 import android.widget.TextView; 8 import android.widget.TextView;
9 9
10 import org.chromium.base.ThreadUtils; 10 import org.chromium.base.ThreadUtils;
(...skipping 28 matching lines...) Expand all
39 implements PaymentRequestObserverForTest, PaymentRequestServiceObserverF orTest, 39 implements PaymentRequestObserverForTest, PaymentRequestServiceObserverF orTest,
40 CardUnmaskObserverForTest { 40 CardUnmaskObserverForTest {
41 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyForInput; 41 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyForInput;
42 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyToPay; 42 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyToPay;
43 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyToClose; 43 protected final PaymentsCallbackHelper<PaymentRequestUI> mReadyToClose;
44 protected final PaymentsCallbackHelper<PaymentRequestUI> mResultReady; 44 protected final PaymentsCallbackHelper<PaymentRequestUI> mResultReady;
45 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyForUnmaskInpu t; 45 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyForUnmaskInpu t;
46 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyToUnmask; 46 protected final PaymentsCallbackHelper<CardUnmaskPrompt> mReadyToUnmask;
47 protected final CallbackHelper mReadyToEdit; 47 protected final CallbackHelper mReadyToEdit;
48 protected final CallbackHelper mEditorValidationError; 48 protected final CallbackHelper mEditorValidationError;
49 protected final CallbackHelper mEditorTextUpdate;
49 protected final CallbackHelper mEditorDismissed; 50 protected final CallbackHelper mEditorDismissed;
50 protected final CallbackHelper mDismissed; 51 protected final CallbackHelper mDismissed;
51 protected final CallbackHelper mUnableToAbort; 52 protected final CallbackHelper mUnableToAbort;
52 private final AtomicReference<ContentViewCore> mViewCoreRef; 53 private final AtomicReference<ContentViewCore> mViewCoreRef;
53 private final AtomicReference<WebContents> mWebContentsRef; 54 private final AtomicReference<WebContents> mWebContentsRef;
54 private final String mTestFilePath; 55 private final String mTestFilePath;
55 private PaymentRequestUI mUI; 56 private PaymentRequestUI mUI;
56 private CardUnmaskPrompt mCardUnmaskPrompt; 57 private CardUnmaskPrompt mCardUnmaskPrompt;
57 58
58 protected PaymentRequestTestBase(String testFileName) { 59 protected PaymentRequestTestBase(String testFileName) {
59 super(ChromeActivity.class); 60 super(ChromeActivity.class);
60 mReadyForInput = new PaymentsCallbackHelper<>(); 61 mReadyForInput = new PaymentsCallbackHelper<>();
61 mReadyToPay = new PaymentsCallbackHelper<>(); 62 mReadyToPay = new PaymentsCallbackHelper<>();
62 mReadyToClose = new PaymentsCallbackHelper<>(); 63 mReadyToClose = new PaymentsCallbackHelper<>();
63 mResultReady = new PaymentsCallbackHelper<>(); 64 mResultReady = new PaymentsCallbackHelper<>();
64 mReadyForUnmaskInput = new PaymentsCallbackHelper<>(); 65 mReadyForUnmaskInput = new PaymentsCallbackHelper<>();
65 mReadyToUnmask = new PaymentsCallbackHelper<>(); 66 mReadyToUnmask = new PaymentsCallbackHelper<>();
66 mReadyToEdit = new CallbackHelper(); 67 mReadyToEdit = new CallbackHelper();
67 mEditorValidationError = new CallbackHelper(); 68 mEditorValidationError = new CallbackHelper();
69 mEditorTextUpdate = new CallbackHelper();
68 mEditorDismissed = new CallbackHelper(); 70 mEditorDismissed = new CallbackHelper();
69 mDismissed = new CallbackHelper(); 71 mDismissed = new CallbackHelper();
70 mUnableToAbort = new CallbackHelper(); 72 mUnableToAbort = new CallbackHelper();
71 mViewCoreRef = new AtomicReference<>(); 73 mViewCoreRef = new AtomicReference<>();
72 mWebContentsRef = new AtomicReference<>(); 74 mWebContentsRef = new AtomicReference<>();
73 mTestFilePath = UrlUtils.getIsolatedTestFilePath( 75 mTestFilePath = UrlUtils.getIsolatedTestFilePath(
74 String.format("chrome/test/data/android/payments/%s", testFileNa me)); 76 String.format("chrome/test/data/android/payments/%s", testFileNa me));
75 } 77 }
76 78
77 @Override 79 @Override
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 helper.waitForCallback(callCount); 135 helper.waitForCallback(callCount);
134 } 136 }
135 137
136 /** Clicks on an element in the editor UI. */ 138 /** Clicks on an element in the editor UI. */
137 protected void clickInEditorAndWait(final int resourceId, CallbackHelper hel per) 139 protected void clickInEditorAndWait(final int resourceId, CallbackHelper hel per)
138 throws InterruptedException, TimeoutException { 140 throws InterruptedException, TimeoutException {
139 int callCount = helper.getCallCount(); 141 int callCount = helper.getCallCount();
140 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 142 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
141 @Override 143 @Override
142 public void run() { 144 public void run() {
143 mUI.getEditorViewForTest().findViewById(resourceId).performClick (); 145 mUI.getEditorView().findViewById(resourceId).performClick();
144 } 146 }
145 }); 147 });
146 helper.waitForCallback(callCount); 148 helper.waitForCallback(callCount);
147 } 149 }
148 150
149 /** Clicks on a button in the card unmask UI. */ 151 /** Clicks on a button in the card unmask UI. */
150 protected void clickCardUnmaskButtonAndWait(final int dialogButtonId, Callba ckHelper helper) 152 protected void clickCardUnmaskButtonAndWait(final int dialogButtonId, Callba ckHelper helper)
151 throws InterruptedException, TimeoutException { 153 throws InterruptedException, TimeoutException {
152 int callCount = helper.getCallCount(); 154 int callCount = helper.getCallCount();
153 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 155 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
(...skipping 10 matching lines...) Expand all
164 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() { 166 return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
165 @Override 167 @Override
166 public String call() { 168 public String call() {
167 return ((TextView) mUI.getShippingAddressSectionForTest().findVi ewById( 169 return ((TextView) mUI.getShippingAddressSectionForTest().findVi ewById(
168 R.id.payments_left_summary_label)).getText().toString(); 170 R.id.payments_left_summary_label)).getText().toString();
169 } 171 }
170 }); 172 });
171 } 173 }
172 174
173 /** Directly sets the text in the editor UI. */ 175 /** Directly sets the text in the editor UI. */
174 protected void setTextInEditor(final int resourceId, final String input) 176 protected void setTextInEditorAndWait(final int resourceId, final String inp ut,
175 throws InterruptedException, TimeoutException { 177 CallbackHelper helper) throws InterruptedException, TimeoutException {
178 int callCount = helper.getCallCount();
176 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 179 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
177 @Override 180 @Override
178 public void run() { 181 public void run() {
179 ((EditText) mUI.getEditorViewForTest().findViewById(resourceId)) .setText(input); 182 ((EditText) mUI.getEditorView().findViewById(resourceId)).setTex t(input);
180 } 183 }
181 }); 184 });
185 helper.waitForCallback(callCount);
182 } 186 }
183 187
184 /** Directly sets the text in the card unmask UI. */ 188 /** Directly sets the text in the card unmask UI. */
185 protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final String input, 189 protected void setTextInCardUnmaskDialogAndWait(final int resourceId, final String input,
186 CallbackHelper helper) throws InterruptedException, TimeoutException { 190 CallbackHelper helper) throws InterruptedException, TimeoutException {
187 int callCount = helper.getCallCount(); 191 int callCount = helper.getCallCount();
188 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 192 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
189 @Override 193 @Override
190 public void run() { 194 public void run() {
191 ((EditText) mCardUnmaskPrompt.getDialogForTest().findViewById(re sourceId)) 195 ((EditText) mCardUnmaskPrompt.getDialogForTest().findViewById(re sourceId))
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 mReadyToEdit.notifyCalled(); 241 mReadyToEdit.notifyCalled();
238 } 242 }
239 243
240 @Override 244 @Override
241 public void onPaymentRequestEditorValidationError() { 245 public void onPaymentRequestEditorValidationError() {
242 ThreadUtils.assertOnUiThread(); 246 ThreadUtils.assertOnUiThread();
243 mEditorValidationError.notifyCalled(); 247 mEditorValidationError.notifyCalled();
244 } 248 }
245 249
246 @Override 250 @Override
251 public void onPaymentRequestEditorTextUpdate() {
252 ThreadUtils.assertOnUiThread();
253 mEditorTextUpdate.notifyCalled();
254 }
255
256 @Override
247 public void onPaymentRequestEditorDismissed() { 257 public void onPaymentRequestEditorDismissed() {
248 ThreadUtils.assertOnUiThread(); 258 ThreadUtils.assertOnUiThread();
249 mEditorDismissed.notifyCalled(); 259 mEditorDismissed.notifyCalled();
250 } 260 }
251 261
252 @Override 262 @Override
253 public void onPaymentRequestReadyToPay(PaymentRequestUI ui) { 263 public void onPaymentRequestReadyToPay(PaymentRequestUI ui) {
254 ThreadUtils.assertOnUiThread(); 264 ThreadUtils.assertOnUiThread();
255 mReadyToPay.notifyCalled(ui); 265 mReadyToPay.notifyCalled(ui);
256 } 266 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 * 322 *
313 * @param ui The UI that is ready for input. 323 * @param ui The UI that is ready for input.
314 */ 324 */
315 public void notifyCalled(T target) { 325 public void notifyCalled(T target) {
316 ThreadUtils.assertOnUiThread(); 326 ThreadUtils.assertOnUiThread();
317 mTarget = target; 327 mTarget = target;
318 notifyCalled(); 328 notifyCalled();
319 } 329 }
320 } 330 }
321 } 331 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPhoneTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698