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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.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: Removed the null return value 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
index 4c506bac1d64759d2c38d305739674e543d43411..11a091775d1221aa3dfd0bf982af096fdd73c485 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java
@@ -25,10 +25,12 @@ import android.widget.RadioButton;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.widget.TintedDrawable;
import java.util.ArrayList;
+import java.util.List;
import javax.annotation.Nullable;
@@ -524,6 +526,8 @@ public abstract class PaymentRequestSection extends LinearLayout {
private static final int INVALID_OPTION_INDEX = -1;
+ private final List<TextView> mLabelsForTest = new ArrayList<>();
+
/**
* Displays a row representing either a selectable option or some flavor text.
*
@@ -577,7 +581,7 @@ public abstract class PaymentRequestSection extends LinearLayout {
}
/** Set the button identifier for the option. */
- public void setId(int id) {
+ public void setButtonId(int id) {
mButton.setId(id);
}
@@ -864,6 +868,7 @@ public abstract class PaymentRequestSection extends LinearLayout {
private void updateOptionList(SectionInformation information, PaymentOption selectedItem) {
mOptionLayout.removeAllViews();
mOptionRows.clear();
+ mLabelsForTest.clear();
// Show any additional text requested by the layout.
if (!TextUtils.isEmpty(mDelegate.getAdditionalText(this))) {
@@ -884,13 +889,18 @@ public abstract class PaymentRequestSection extends LinearLayout {
if (firstOptionIndex == INVALID_OPTION_INDEX) firstOptionIndex = currentRow;
PaymentOption item = information.getItem(i);
- mOptionRows.add(new OptionRow(mOptionLayout, currentRow,
- OptionRow.OPTION_ROW_TYPE_OPTION, item, item == selectedItem));
+ OptionRow currentOptionRow = new OptionRow(mOptionLayout, currentRow,
+ OptionRow.OPTION_ROW_TYPE_OPTION, item, item == selectedItem);
+ mOptionRows.add(currentOptionRow);
+
+ // For testing, keep the labels in a list for easy access.
+ mLabelsForTest.add(currentOptionRow.mLabel);
}
+ // TODO(crbug.com/627186): Find another way to give access to this resource in tests.
// For testing.
if (firstOptionIndex != INVALID_OPTION_INDEX) {
- mOptionRows.get(firstOptionIndex).setId(R.id.payments_first_radio_button);
+ mOptionRows.get(firstOptionIndex).setButtonId(R.id.payments_first_radio_button);
}
// If the user is allowed to add new options, show the button for it.
@@ -898,7 +908,7 @@ public abstract class PaymentRequestSection extends LinearLayout {
OptionRow addRow = new OptionRow(mOptionLayout, mOptionLayout.getChildCount(),
OptionRow.OPTION_ROW_TYPE_ADD, null, false);
addRow.setLabel(information.getAddStringId());
- addRow.setId(R.id.payments_add_option_button);
+ addRow.setButtonId(R.id.payments_add_option_button);
mOptionRows.add(addRow);
}
}
@@ -907,6 +917,21 @@ public abstract class PaymentRequestSection extends LinearLayout {
if (TextUtils.isEmpty(item.getSublabel())) return item.getLabel();
return new StringBuilder(item.getLabel()).append("\n").append(item.getSublabel());
}
+
+ /**
+ * Returns the label at the specified |labelIndex|. Returns null if there is no label at
+ * that index.
+ */
+ @VisibleForTesting
+ public TextView getOptionLabelsForTest(int labelIndex) {
+ return mLabelsForTest.get(labelIndex);
+ }
+
+ /** Returns the number of option labels. */
+ @VisibleForTesting
+ public int getNumberOfOptionLabelsForTest() {
+ return mLabelsForTest.size();
+ }
}
/**
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentOption.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698