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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java

Issue 1958793002: Test cancelling card unmasking dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callback-tests
Patch Set: Address comments/ Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
index 4230f6b02c6b7566e00e8227b720790342795830..477ace63216f6f84cce8a3ef117d9f707e22c4d6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java
@@ -34,6 +34,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import java.util.Calendar;
@@ -43,7 +44,10 @@ import java.util.Calendar;
*/
public class CardUnmaskPrompt
implements DialogInterface.OnDismissListener, TextWatcher, OnClickListener {
+ private static CardUnmaskObserverForTest sObserverForTest;
+
private final CardUnmaskPromptDelegate mDelegate;
+ private final CardUnmaskObserverForTest mObserverForTest;
private final AlertDialog mDialog;
private boolean mShouldRequestExpirationDate;
private final int mThisYear;
@@ -98,11 +102,33 @@ public class CardUnmaskPrompt
void onNewCardLinkClicked();
}
- public CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title,
- String instructions, String confirmButtonLabel, int drawableId,
+ /**
+ * A test-only observer for the unmasking prompt.
+ */
+ public interface CardUnmaskObserverForTest {
+ /**
+ * Called when clicks on the prompt are possible.
+ */
+ void onCardUnmaskReadyForInput(CardUnmaskPrompt prompt);
+ }
+
+ public static CardUnmaskPrompt create(Context context, CardUnmaskPromptDelegate delegate,
+ String title, String instructions, String confirmButtonLabel, int drawableId,
boolean shouldRequestExpirationDate, boolean canStoreLocally,
boolean defaultToStoringLocally) {
+ CardUnmaskPrompt prompt = new CardUnmaskPrompt(context, delegate, title, instructions,
+ confirmButtonLabel, drawableId, shouldRequestExpirationDate, canStoreLocally,
+ defaultToStoringLocally, sObserverForTest);
+ sObserverForTest = null;
+ return prompt;
+ }
+
+ private CardUnmaskPrompt(Context context, CardUnmaskPromptDelegate delegate, String title,
+ String instructions, String confirmButtonLabel, int drawableId,
+ boolean shouldRequestExpirationDate, boolean canStoreLocally,
+ boolean defaultToStoringLocally, CardUnmaskObserverForTest observerForTest) {
mDelegate = delegate;
+ mObserverForTest = observerForTest;
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.autofill_card_unmask_prompt, null);
@@ -319,6 +345,9 @@ public class CardUnmaskPrompt
View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
+ if (mObserverForTest != null) {
+ mObserverForTest.onCardUnmaskReadyForInput(CardUnmaskPrompt.this);
+ }
}
private boolean areInputsValid() {
@@ -439,4 +468,14 @@ public class CardUnmaskPrompt
return -1;
}
}
+
+ @VisibleForTesting
+ public static void setObserverForTest(CardUnmaskObserverForTest observerForTest) {
+ sObserverForTest = observerForTest;
+ }
+
+ @VisibleForTesting
+ public AlertDialog getDialogForTest() {
+ return mDialog;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698