Skip to content

Commit

Permalink
Revert "[TTFCC] Show credit cards in the bottom sheet"
Browse files Browse the repository at this point in the history
This reverts commit 116ed39.

Reason for revert: Compile failure.
https://ci.chromium.org/ui/p/chromium/builders/ci/Android%20arm64%20Builder%20All%20Targets%20(dbg)/4480/overview

Original change's description:
> [TTFCC] Show credit cards in the bottom sheet
>
> From the bridge, the cards are passed further to the showSheet
> method of the TouchToFillCreditCardCoordinator which implements
> TouchToFillCreditCardComponent.
>
> The TouchToFillCreditCardCoordinator calls the showSheet method of the
> TouchToFillCreditCardMediator, which stores the credit cards as one of
> the TouchToFillCreditCardProperties.
>
> Changes to bind the views are made to TouchToFillCreditCardView and TouchToFillCreditCardViewBinder.
>
> The name of the card and the expiration date are already shown and the
> favicon will be added in a followup.
>
> HSV link to inspect the layout:
> https://hsv.googleplex.com/4905358175764480
>
> Screenshot with two cards:
> https://screenshot.googleplex.com/8BgSEpFi4Kn5M9k
>
> Bug: 1247698
> Change-Id: I4ffc976cae783183628828ef6b2f5d6fe2e967b2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3963013
> Reviewed-by: Tanmoy Mollik <triploblastic@chromium.org>
> Reviewed-by: Matthias Körber <koerber@google.com>
> Commit-Queue: Ivana Žužić <izuzic@google.com>
> Reviewed-by: Friedrich Horschig <fhorschig@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1076217}

Bug: 1247698
Change-Id: I41b321f99ddf5ec40ffc25a4e5d871929a8b9373
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4062148
Owners-Override: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Francois Pierre Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1076242}
  • Loading branch information
fdoray authored and Chromium LUCI CQ committed Nov 28, 2022
1 parent 7467ebc commit 5fdf5e1
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 395 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

package org.chromium.chrome.browser.autofill;

import static org.chromium.content_public.browser.test.util.TestThreadUtils.runOnUiThreadBlocking;
import static org.chromium.content_public.browser.test.util.TestThreadUtils.runOnUiThreadBlockingNoException;

import org.chromium.base.test.util.CallbackHelper;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.content_public.browser.test.util.TestThreadUtils;

import java.util.Calendar;
import java.util.List;
Expand All @@ -28,25 +26,27 @@ public AutofillTestHelper() {
}

void setRequestTimeoutForTesting() {
runOnUiThreadBlocking(() -> PersonalDataManager.setRequestTimeoutForTesting(0));
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.setRequestTimeoutForTesting(0));
}

void setSyncServiceForTesting() {
runOnUiThreadBlocking(() -> PersonalDataManager.getInstance().setSyncServiceForTesting());
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().setSyncServiceForTesting());
}

AutofillProfile getProfile(final String guid) {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getProfile(guid));
}

List<AutofillProfile> getProfilesToSuggest(final boolean includeNameInLabel) {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getProfilesToSuggest(includeNameInLabel));
}

List<AutofillProfile> getProfilesForSettings() {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getProfilesForSettings());
}

Expand All @@ -60,71 +60,74 @@ int getNumberOfProfilesForSettings() {

public String setProfile(final AutofillProfile profile) throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
String guid = runOnUiThreadBlockingNoException(
String guid = TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().setProfile(profile));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
return guid;
}

public void deleteProfile(final String guid) throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(() -> PersonalDataManager.getInstance().deleteProfile(guid));
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().deleteProfile(guid));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
}

public CreditCard getCreditCard(final String guid) {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getCreditCard(guid));
}

List<CreditCard> getCreditCardsToSuggest() {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
()
-> PersonalDataManager.getInstance().getCreditCardsToSuggest(
/*includeServerCards=*/true));
}

List<CreditCard> getCreditCardsForSettings() {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getCreditCardsForSettings());
}

int getNumberOfCreditCardsToSuggest() {
return getCreditCardsToSuggest().size();
}

public int getNumberOfCreditCardsForSettings() {
int getNumberOfCreditCardsForSettings() {
return getCreditCardsForSettings().size();
}

public String setCreditCard(final CreditCard card) throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
String guid = runOnUiThreadBlockingNoException(
String guid = TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().setCreditCard(card));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
return guid;
}

public void addServerCreditCard(final CreditCard card) throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().addServerCreditCardForTest(card));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
}

public void addServerCreditCard(final CreditCard card, String nickname, int cardIssuer)
throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(()
-> PersonalDataManager.getInstance()
.addServerCreditCardForTestWithAdditionalFields(
card, nickname, cardIssuer));
TestThreadUtils.runOnUiThreadBlocking(
()
-> PersonalDataManager.getInstance()
.addServerCreditCardForTestWithAdditionalFields(
card, nickname, cardIssuer));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
}

void deleteCreditCard(final String guid) throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(() -> PersonalDataManager.getInstance().deleteCreditCard(guid));
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().deleteCreditCard(guid));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
}

Expand All @@ -137,7 +140,8 @@ void deleteCreditCard(final String guid) throws TimeoutException {
*/
void recordAndLogProfileUse(final String guid) throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(() -> PersonalDataManager.getInstance().recordAndLogProfileUse(guid));
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().recordAndLogProfileUse(guid));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
}

Expand All @@ -155,7 +159,7 @@ void recordAndLogProfileUse(final String guid) throws TimeoutException {
public void setProfileUseStatsForTesting(final String guid, final int count, final long date)
throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(
TestThreadUtils.runOnUiThreadBlocking(
()
-> PersonalDataManager.getInstance().setProfileUseStatsForTesting(
guid, count, date));
Expand All @@ -169,7 +173,7 @@ public void setProfileUseStatsForTesting(final String guid, final int count, fin
* @return The non-negative use count of the profile.
*/
public int getProfileUseCountForTesting(final String guid) {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getProfileUseCountForTesting(guid));
}

Expand All @@ -182,7 +186,7 @@ public int getProfileUseCountForTesting(final String guid) {
* the Windows epoch. For more details see the comment header in time.h.
*/
public long getProfileUseDateForTesting(final String guid) {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getProfileUseDateForTesting(guid));
}

Expand All @@ -195,7 +199,7 @@ public long getProfileUseDateForTesting(final String guid) {
*/
public void recordAndLogCreditCardUse(final String guid) throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().recordAndLogCreditCardUse(guid));
mOnPersonalDataChangedHelper.waitForCallback(callCount);
}
Expand All @@ -214,7 +218,7 @@ public void recordAndLogCreditCardUse(final String guid) throws TimeoutException
public void setCreditCardUseStatsForTesting(final String guid, final int count, final long date)
throws TimeoutException {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
runOnUiThreadBlocking(
TestThreadUtils.runOnUiThreadBlocking(
()
-> PersonalDataManager.getInstance().setCreditCardUseStatsForTesting(
guid, count, date));
Expand All @@ -228,7 +232,7 @@ public void setCreditCardUseStatsForTesting(final String guid, final int count,
* @return The non-negative use count of the credit card.
*/
public int getCreditCardUseCountForTesting(final String guid) {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getCreditCardUseCountForTesting(guid));
}

Expand All @@ -241,7 +245,7 @@ public int getCreditCardUseCountForTesting(final String guid) {
* since the Windows epoch. For more details see the comment header in time.h.
*/
public long getCreditCardUseDateForTesting(final String guid) {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getCreditCardUseDateForTesting(guid));
}

Expand All @@ -253,7 +257,7 @@ public long getCreditCardUseDateForTesting(final String guid) {
* For more details see the comment header in time.h.
*/
public long getCurrentDateForTesting() {
return runOnUiThreadBlockingNoException(
return TestThreadUtils.runOnUiThreadBlockingNoException(
() -> PersonalDataManager.getInstance().getCurrentDateForTesting());
}

Expand All @@ -262,17 +266,18 @@ public long getCurrentDateForTesting() {
* #addServerCreditCard(CreditCard)}}.
*/
public void clearAllDataForTesting() throws TimeoutException {
runOnUiThreadBlocking(() -> PersonalDataManager.getInstance().clearServerDataForTesting());
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().clearServerDataForTesting());
// Clear remaining local profiles and cards.
for (AutofillProfile profile : getProfilesForSettings()) {
if (profile.getIsLocal()) {
runOnUiThreadBlocking(
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().deleteProfile(profile.getGUID()));
}
}
for (CreditCard card : getCreditCardsForSettings()) {
if (card.getIsLocal()) {
runOnUiThreadBlocking(
TestThreadUtils.runOnUiThreadBlocking(
() -> PersonalDataManager.getInstance().deleteCreditCard(card.getGUID()));
}
}
Expand All @@ -290,16 +295,10 @@ public static String nextYear() {
return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1);
}

/** Creates a simple {@link CreditCard}. */
public static CreditCard createLocalCreditCard(
String name, String number, String month, String year) {
return new CreditCard("", "", true, false, name, number, "", month, year, "", 0, "", "");
}

private void registerDataObserver() {
try {
int callCount = mOnPersonalDataChangedHelper.getCallCount();
boolean isDataLoaded = runOnUiThreadBlockingNoException(
boolean isDataLoaded = TestThreadUtils.runOnUiThreadBlockingNoException(
()
-> PersonalDataManager.getInstance().registerDataObserver(
() -> mOnPersonalDataChangedHelper.notifyCalled()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import static org.junit.Assert.assertEquals;

import static org.chromium.chrome.browser.autofill.AutofillTestHelper.createLocalCreditCard;

import android.graphics.Bitmap;

import androidx.test.filters.SmallTest;
Expand Down Expand Up @@ -144,6 +142,13 @@ public void testAddAndDeleteProfile() throws TimeoutException {
Assert.assertEquals(0, mHelper.getNumberOfProfilesForSettings());
}

private CreditCard createLocalCreditCard(
String name, String number, String month, String year) {
return new CreditCard("" /*guid*/, "" /*origin*/, true /* isLocal */, false /* isCached */,
name, number, "" /*obfuscatedNumber*/, month, year, "" /* basicCardIssuerNetwork */,
0 /* issuerIconDrawableId */, "" /* billingAddressId */, "" /* serverId */);
}

@Test
@SmallTest
@Feature({"Autofill"})
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/touch_to_fill/payments/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ generate_jni("jni_headers") {
android_library("public_java") {
deps = [
"//base:jni_java",
"//chrome/browser/autofill/android:java",
"//chrome/android:chrome_java",
"//components/browser_ui/bottomsheet/android:java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//ui/android:ui_java",
Expand Down
11 changes: 2 additions & 9 deletions chrome/browser/touch_to_fill/payments/android/internal/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ android_library("java") {
"//base:jni_java",
"//build/android:build_java",
"//chrome/android:chrome_app_java_resources",
"//chrome/browser/autofill/android:java",
"//chrome/android:chrome_java",
"//chrome/browser/autofill/android:java",
"//chrome/browser/touch_to_fill/android/internal:java",
"//chrome/browser/touch_to_fill/payments/android:public_java",
"//components/browser_ui/bottomsheet/android:java",
"//components/payments/content/android:minimal_java_resources",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/androidx:androidx_core_core_java",
"//third_party/androidx:androidx_recyclerview_recyclerview_java",
"//ui/android:ui_java",
"//ui/android:ui_java_resources",
]
Expand Down Expand Up @@ -56,13 +55,9 @@ robolectric_library("junit") {
"//base:base_java",
"//base:base_java_test_support",
"//base:base_junit_test_support",
"//chrome/browser/autofill/android:java",
"//chrome/browser/autofill/test:test_support_java",
"//chrome/browser/touch_to_fill/payments/android:public_java",
"//chrome/test/android:chrome_java_unit_test_support",
"//components/autofill/android:autofill_features_java",
"//components/browser_ui/bottomsheet/android:java",
"//third_party/hamcrest:hamcrest_library_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
"//ui/android:ui_java_test_support",
Expand All @@ -79,16 +74,14 @@ android_library("javatests") {
":java",
"//base:base_java",
"//base:base_java_test_support",
"//chrome/browser/autofill/android:java",
"//chrome/browser/autofill/test:test_support_java",
"//chrome/android:chrome_java",
"//chrome/browser/flags:java",
"//chrome/browser/touch_to_fill/payments/android:public_java",
"//chrome/test/android:chrome_java_integration_test_support",
"//components/browser_ui/bottomsheet/android:java",
"//components/browser_ui/bottomsheet/android/test:java",
"//content/public/test/android:content_java_test_support",
"//third_party/android_deps:espresso_java",
"//third_party/androidx:androidx_recyclerview_recyclerview_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/hamcrest:hamcrest_library_java",
"//third_party/junit:junit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ found in the LICENSE file.
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:layout_marginEnd="4dp"
android:textAppearance="@style/TextAppearance.TextMedium.Primary" />
<TextView
android:id="@+id/card_number"
Expand Down

0 comments on commit 5fdf5e1

Please sign in to comment.