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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTestHelper.java

Issue 2126213002: [Payments] Record use of profiles and credit cards in Payment Request. (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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.autofill; 5 package org.chromium.chrome.browser.autofill;
6 6
7 import org.chromium.base.ThreadUtils; 7 import org.chromium.base.ThreadUtils;
8 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; 8 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
9 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; 9 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
10 import org.chromium.chrome.browser.autofill.PersonalDataManager.PersonalDataMana gerObserver; 10 import org.chromium.chrome.browser.autofill.PersonalDataManager.PersonalDataMana gerObserver;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 144 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
145 @Override 145 @Override
146 public void run() { 146 public void run() {
147 PersonalDataManager.getInstance().deleteCreditCard(guid); 147 PersonalDataManager.getInstance().deleteCreditCard(guid);
148 } 148 }
149 }); 149 });
150 waitForDataChanged(); 150 waitForDataChanged();
151 } 151 }
152 152
153 /** 153 /**
154 * Records the use of the profile associated with the specified |guid|. Effe ctively increments
155 * the use count of the profile and set its use date to the current time. Al so logs usage
156 * metrics.
157 * @param guid The GUID of the profile.
please use gerrit instead 2016/07/12 15:41:58 newline before @param
sebsg 2016/07/13 18:49:19 Done.
158 */
159 void recordAndLogProfileUse(final String guid) throws InterruptedException {
160 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
161 @Override
162 public void run() {
163 PersonalDataManager.getInstance().recordAndLogProfileUse(guid);
164 }
165 });
166 waitForDataChanged();
167 }
168
169 /**
154 * Sets the use |count| and use |date| of the test profile associated with t he |guid|. 170 * Sets the use |count| and use |date| of the test profile associated with t he |guid|.
155 * @param guid The GUID of the profile to modify. 171 * @param guid The GUID of the profile to modify.
156 * @param count The use count to assign to the profile. It should be non-neg ative. 172 * @param count The use count to assign to the profile. It should be non-neg ative.
157 * @param date The use date to assign to the profile. It represents an absol ute point in 173 * @param date The use date to assign to the profile. It represents an absol ute point in
158 * coordinated universal time (UTC) represented as microseconds since the Windows 174 * coordinated universal time (UTC) represented as microseconds since the Windows
159 * epoch. For more details see the comment header in time.h. It should always be a 175 * epoch. For more details see the comment header in time.h. It should always be a
160 * positive number. 176 * positive number.
161 */ 177 */
162 void setProfileUseStatsForTesting(final String guid, final int count, final long date) 178 public void setProfileUseStatsForTesting(final String guid, final int count, final long date)
163 throws InterruptedException { 179 throws InterruptedException {
164 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 180 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
165 @Override 181 @Override
166 public void run() { 182 public void run() {
167 PersonalDataManager.getInstance().setProfileUseStatsForTesting(g uid, count, date); 183 PersonalDataManager.getInstance().setProfileUseStatsForTesting(g uid, count, date);
168 } 184 }
169 }); 185 });
170 waitForDataChanged(); 186 waitForDataChanged();
171 } 187 }
172 188
173 /** 189 /**
190 * Get the use count of the test profile associated with the |guid|.
191 * @param guid The GUID of the profile to modify.
please use gerrit instead 2016/07/12 15:41:58 1) newline before @param 2) s/to modify/to query/
sebsg 2016/07/13 18:49:19 Done.
192 * @return count The use count to assign to the profile. It should be non-ne gative.
please use gerrit instead 2016/07/12 15:41:58 1) Remove "count". @return The use count to ass
sebsg 2016/07/13 18:49:20 Done.
193 */
194 public int getProfileUseCountForTesting(final String guid) throws Interrupte dException,
195 ExecutionException {
196 return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
197 @Override
198 public Integer call() {
199 return PersonalDataManager.getInstance().getProfileUseCountForTe sting(guid);
200 }
201 });
202 }
203
204 /**
205 * Get the use date of the test profile associated with the |guid|.
206 * @param guid The GUID of the profile to modify.
please use gerrit instead 2016/07/12 15:41:58 1) newline before @param 2) s/to modify/to query/
sebsg 2016/07/13 18:49:19 Done.
207 * @return date The use date to assign to the profile. It represents an abso lute point in
please use gerrit instead 2016/07/12 15:41:58 Remove "date" after "@return".
sebsg 2016/07/13 18:49:19 Done.
208 * coordinated universal time (UTC) represented as microseconds since the Windows
209 * epoch. For more details see the comment header in time.h. It should always be a
210 * positive number.
211 */
212 public long getProfileUseDateForTesting(final String guid) throws Interrupte dException,
213 ExecutionException {
214 return ThreadUtils.runOnUiThreadBlocking(new Callable<Long>() {
215 @Override
216 public Long call() {
217 return PersonalDataManager.getInstance().getProfileUseDateForTes ting(guid);
218 }
219 });
220 }
221
222 /**
223 * Records the use of the credit card associated with the specified |guid|. Effectively
224 * increments the use count of the credit card and set its use date to the c urrent time. Also
please use gerrit instead 2016/07/12 15:41:58 s/set/sets/
sebsg 2016/07/13 18:49:20 Done.
225 * logs usage metrics.
226 * @param guid The GUID of the credit card.
please use gerrit instead 2016/07/12 15:41:58 newline before @param
sebsg 2016/07/13 18:49:20 Done.
227 */
228 public void recordAndLogCreditCardUse(final String guid) throws InterruptedE xception {
229 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
230 @Override
231 public void run() {
232 PersonalDataManager.getInstance().recordAndLogCreditCardUse(guid );
233 }
234 });
235 waitForDataChanged();
236 }
237
238 /**
174 * Sets the use |count| and use |date| of the test credit card associated wi th the |guid|. 239 * Sets the use |count| and use |date| of the test credit card associated wi th the |guid|.
175 * @param guid The GUID of the credit card to modify. 240 * @param guid The GUID of the credit card to modify.
176 * @param count The use count to assign to the credit card. It should be non -negative. 241 * @param count The use count to assign to the credit card. It should be non -negative.
177 * @param date The use date to assign to the credit card. It represents an a bsolute point in 242 * @return date The use date to assign to the credit card. It represents an absolute point in
please use gerrit instead 2016/07/12 15:41:58 Remove "date" after "@return".
sebsg 2016/07/13 18:49:19 Actually it should still be a param, my bad...
178 * coordinated universal time (UTC) represented as microseconds since the Windows 243 * coordinated universal time (UTC) represented as microseconds since the Windows
179 * epoch. For more details see the comment header in time.h. It should always be a 244 * epoch. For more details see the comment header in time.h. It should always be a
180 * positive number. 245 * positive number.
181 */ 246 */
182 void setCreditCardUseStatsForTesting(final String guid, final int count, fin al long date) 247 public void setCreditCardUseStatsForTesting(final String guid, final int cou nt, final long date)
183 throws InterruptedException { 248 throws InterruptedException {
184 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 249 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
185 @Override 250 @Override
186 public void run() { 251 public void run() {
187 PersonalDataManager.getInstance().setCreditCardUseStatsForTestin g( 252 PersonalDataManager.getInstance().setCreditCardUseStatsForTestin g(
188 guid, count, date); 253 guid, count, date);
189 } 254 }
190 }); 255 });
191 waitForDataChanged(); 256 waitForDataChanged();
192 } 257 }
193 258
259 /**
260 * Get the use count of the test credit card associated with the |guid|.
261 * @param guid The GUID of the credit card to modify.
please use gerrit instead 2016/07/12 15:41:58 1) newline before @param 2) s/modify/query/
sebsg 2016/07/13 18:49:19 Done.
262 * @return count The use count to assign to the credit card. It should be no n-negative.
please use gerrit instead 2016/07/12 15:41:58 1) Remove "count". 2) Remove "It should be".
sebsg 2016/07/13 18:49:19 Done.
263 */
264 public int getCreditCardUseCountForTesting(final String guid) throws Interru ptedException,
265 ExecutionException {
266 return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
267 @Override
268 public Integer call() {
269 return PersonalDataManager.getInstance().getCreditCardUseCountFo rTesting(guid);
270 }
271 });
272 }
273
274 /**
275 * Get the use date of the test credit card associated with the |guid|.
276 * @param guid The GUID of the credit card to modify.
please use gerrit instead 2016/07/12 15:41:58 Ditto
sebsg 2016/07/13 18:49:19 Done.
277 * @return date The use date to assign to the credit card. It represents an absolute point in
278 * coordinated universal time (UTC) represented as microseconds since the Windows
279 * epoch. For more details see the comment header in time.h. It should always be a
280 * positive number.
281 */
282 public long getCreditCardUseDateForTesting(final String guid) throws Interru ptedException,
283 ExecutionException {
284 return ThreadUtils.runOnUiThreadBlocking(new Callable<Long>() {
285 @Override
286 public Long call() {
287 return PersonalDataManager.getInstance().getCreditCardUseDateFor Testing(guid);
288 }
289 });
290 }
291
292 /**
293 * Get the current use date to be used in test to compare with credit card o r profile use dates.
294 * @return date The current use date. It represents an absolute point in coo rdinated universal
please use gerrit instead 2016/07/12 15:41:58 Ditto
sebsg 2016/07/13 18:49:19 Done.
295 * time (UTC) represented as microseconds since the Windows epo ch. For more details
296 * see the comment header in time.h. It should always be a posi tive number.
297 */
298 public long getCurrentDateForTesting() throws InterruptedException, Executio nException {
299 return ThreadUtils.runOnUiThreadBlocking(new Callable<Long>() {
300 @Override
301 public Long call() {
302 return PersonalDataManager.getInstance().getCurrentDateForTestin g();
303 }
304 });
305 }
306
194 private void registerDataObserver() { 307 private void registerDataObserver() {
195 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 308 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
196 @Override 309 @Override
197 public void run() { 310 public void run() {
198 PersonalDataManager.getInstance().registerDataObserver( 311 PersonalDataManager.getInstance().registerDataObserver(
199 new PersonalDataManagerObserver() { 312 new PersonalDataManagerObserver() {
200 @Override 313 @Override
201 public void onPersonalDataChanged() { 314 public void onPersonalDataChanged() {
202 synchronized (mObserverNotified) { 315 synchronized (mObserverNotified) {
203 mObserverNotified.notifyAll(); 316 mObserverNotified.notifyAll();
204 } 317 }
205 } 318 }
206 } 319 }
207 ); 320 );
208 } 321 }
209 }); 322 });
210 } 323 }
211 324
212 @SuppressWarnings("WaitNotInLoop") 325 @SuppressWarnings("WaitNotInLoop")
213 public void waitForDataChanged() throws InterruptedException { 326 public void waitForDataChanged() throws InterruptedException {
214 synchronized (mObserverNotified) { 327 synchronized (mObserverNotified) {
215 mObserverNotified.wait(3000); 328 mObserverNotified.wait(3000);
216 } 329 }
217 } 330 }
218 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698