Commit 40dd55f9 authored by sebsg's avatar sebsg Committed by Commit bot

Suggest complete addresses and contact details first and limit to the top four suggestions.

BUG=625565
TEST=PaymentRequestDynamicShippingMultipleAddressesTest,
     PaymentRequestMultipleContactDetailTest

Review-Url: https://codereview.chromium.org/2120973002
Cr-Commit-Position: refs/heads/master@{#405302}
parent 147aa480
......@@ -32,7 +32,6 @@ public class AutofillAddress extends PaymentOption {
@Nullable private static Pattern sRegionCodePattern;
private AutofillProfile mProfile;
private boolean mIsComplete;
@Nullable private Pattern mLanguageScriptCodePattern;
/**
......@@ -46,11 +45,6 @@ public class AutofillAddress extends PaymentOption {
mIsComplete = isComplete;
}
/** @return Whether the data is complete and can be sent to the merchant as-is. */
public boolean isComplete() {
return mIsComplete;
}
/** @return The autofill profile where this address data lives. */
public AutofillProfile getProfile() {
return mProfile;
......
......@@ -16,7 +16,6 @@ import javax.annotation.Nullable;
*/
public class AutofillContact extends PaymentOption {
private final AutofillProfile mProfile;
private boolean mIsComplete;
@Nullable private String mPayerPhone;
@Nullable private String mPayerEmail;
......@@ -47,11 +46,6 @@ public class AutofillContact extends PaymentOption {
return mPayerPhone;
}
/** @return Whether the data is complete and can be sent to the merchant as-is. */
public boolean isComplete() {
return mIsComplete;
}
/** @return The autofill profile where this contact data lives. */
public AutofillProfile getProfile() {
return mProfile;
......
......@@ -15,6 +15,7 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.favicon.FaviconHelper;
import org.chromium.chrome.browser.payments.ui.Completable;
import org.chromium.chrome.browser.payments.ui.LineItem;
import org.chromium.chrome.browser.payments.ui.PaymentInformation;
import org.chromium.chrome.browser.payments.ui.PaymentOption;
......@@ -45,6 +46,8 @@ import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
......@@ -75,6 +78,8 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
private static final String TAG = "cr_PaymentRequest";
private static final int SUGGESTIONS_LIMIT = 4;
private static PaymentRequestServiceObserverForTest sObserverForTest;
private final Handler mHandler = new Handler();
......@@ -208,6 +213,20 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return;
// Create a comparator to sort the suggestions by completeness.
Comparator<Completable> completenessComparator = new Comparator<Completable>() {
@Override
public int compare(Completable a, Completable b) {
if (a.isComplete() == b.isComplete()) {
return 0;
} else if (a.isComplete()) {
return -1;
} else {
return 1;
}
}
};
// If the merchant requests shipping and does not provide a selected shipping option, then
// the merchant needs the shipping address to calculate the shipping price and availability.
boolean requestShipping = options != null && options.requestShipping;
......@@ -225,7 +244,6 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
if (requestShipping) {
mAddressEditor = new AddressEditor();
List<AutofillAddress> addresses = new ArrayList<>();
int firstCompleteAddressIndex = SectionInformation.NO_SELECTION;
for (int i = 0; i < profiles.size(); i++) {
AutofillProfile profile = profiles.get(i);
......@@ -233,13 +251,22 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
boolean isComplete = mAddressEditor.isProfileComplete(profile);
addresses.add(new AutofillAddress(profile, isComplete));
if (isComplete && firstCompleteAddressIndex == SectionInformation.NO_SELECTION
&& !mMerchantNeedsShippingAddress) {
firstCompleteAddressIndex = i;
}
}
// The shipping address section automatically selects the first complete entry.
// Suggest complete addresses first.
Collections.sort(addresses, completenessComparator);
// Limit the number of suggestions.
addresses = addresses.subList(0, Math.min(addresses.size(), SUGGESTIONS_LIMIT));
// Automatically select the first address if one is complete and if the merchant does
// not require a shipping address to calculate shipping costs.
int firstCompleteAddressIndex = SectionInformation.NO_SELECTION;
if (!mMerchantNeedsShippingAddress && !addresses.isEmpty()
&& addresses.get(0).isComplete()) {
firstCompleteAddressIndex = 0;
}
mShippingAddressesSection =
new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_ADDRESSES,
firstCompleteAddressIndex, addresses);
......@@ -249,7 +276,6 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
Set<String> uniqueContactInfos = new HashSet<>();
mContactEditor = new ContactEditor(requestPayerPhone, requestPayerEmail);
List<AutofillContact> contacts = new ArrayList<>();
int firstCompleteContactIndex = SectionInformation.NO_SELECTION;
for (int i = 0; i < profiles.size(); i++) {
AutofillProfile profile = profiles.get(i);
......@@ -270,15 +296,22 @@ public class PaymentRequestImpl implements PaymentRequest, PaymentRequestUI.Clie
boolean isComplete =
mContactEditor.isContactInformationComplete(phone, email);
contacts.add(new AutofillContact(profile, phone, email, isComplete));
if (isComplete
&& firstCompleteContactIndex == SectionInformation.NO_SELECTION) {
firstCompleteContactIndex = i;
}
}
}
}
// The contact section automatically selects the first complete entry.
// Suggest complete contact infos first.
Collections.sort(contacts, completenessComparator);
// Limit the number of suggestions.
contacts = contacts.subList(0, Math.min(contacts.size(), SUGGESTIONS_LIMIT));
// Automatically select the first address if it is complete.
int firstCompleteContactIndex = SectionInformation.NO_SELECTION;
if (!contacts.isEmpty() && contacts.get(0).isComplete()) {
firstCompleteContactIndex = 0;
}
mContactSection = new SectionInformation(
PaymentRequestUI.TYPE_CONTACT_DETAILS, firstCompleteContactIndex, contacts);
}
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.payments.ui;
/**
* The interface for types that may be complete, i.e., can be sent to the merchant as-is, without
* being edited by the user first.
*/
public interface Completable {
/** @return Whether the data is complete and can be sent to the merchant as-is */
boolean isComplete();
}
\ No newline at end of file
......@@ -10,10 +10,11 @@ import javax.annotation.Nullable;
* An option that the user can select, e.g., a shipping option, a shipping address, or a payment
* method.
*/
public class PaymentOption {
public class PaymentOption implements Completable {
/** The placeholder value that indicates the absence of an icon for this option. */
public static final int NO_ICON = 0;
protected boolean mIsComplete;
private final String mId;
private final int mIcon;
@Nullable private String mLabel;
......@@ -35,6 +36,11 @@ public class PaymentOption {
mIcon = icon;
}
@Override
public boolean isComplete() {
return mIsComplete;
}
/**
* The non-human readable identifier for this option. For example, "standard_shipping" or the
* GUID of an autofill card.
......
......@@ -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();
}
}
/**
......
......@@ -597,6 +597,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/payments/PaymentInstrument.java",
"java/src/org/chromium/chrome/browser/payments/PaymentRequestFactory.java",
"java/src/org/chromium/chrome/browser/payments/PaymentRequestImpl.java",
"java/src/org/chromium/chrome/browser/payments/ui/Completable.java",
"java/src/org/chromium/chrome/browser/payments/ui/EditorDialogToolbar.java",
"java/src/org/chromium/chrome/browser/payments/ui/EditorDropdownField.java",
"java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java",
......@@ -1167,6 +1168,8 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/policy/CombinedPolicyProviderTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestAbortTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestContactDetailsTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestMultipleContactDetailsTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestDynamicShippingMultipleAddressesTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestDynamicShippingSingleAddressTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailTest.java",
"javatests/src/org/chromium/chrome/browser/payments/PaymentRequestFreeShippingTest.java",
......
......@@ -151,7 +151,8 @@ public class AutofillTestHelper {
}
/**
* Sets the use |count| and use |date| of the test profile associated with the |guid|.
* Sets the use |count| and use |date| of the test profile associated with the |guid|. This
* update is not saved to disk.
* @param guid The GUID of the profile to modify.
* @param count The use count to assign to the profile. It should be non-negative.
* @param date The use date to assign to the profile. It represents an absolute point in
......@@ -159,7 +160,7 @@ public class AutofillTestHelper {
* epoch. For more details see the comment header in time.h. It should always be a
* positive number.
*/
void setProfileUseStatsForTesting(final String guid, final int count, final long date)
public void setProfileUseStatsForTesting(final String guid, final int count, final long date)
throws InterruptedException {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
......@@ -167,11 +168,11 @@ public class AutofillTestHelper {
PersonalDataManager.getInstance().setProfileUseStatsForTesting(guid, count, date);
}
});
waitForDataChanged();
}
/**
* Sets the use |count| and use |date| of the test credit card associated with the |guid|.
* Sets the use |count| and use |date| of the test credit card associated with the |guid|. This
* update is not saved to disk.
* @param guid The GUID of the credit card to modify.
* @param count The use count to assign to the credit card. It should be non-negative.
* @param date The use date to assign to the credit card. It represents an absolute point in
......@@ -188,7 +189,6 @@ public class AutofillTestHelper {
guid, count, date);
}
});
waitForDataChanged();
}
private void registerDataObserver() {
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.payments;
import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.autofill.AutofillTestHelper;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* A payment integration test for a merchant that requires shipping address to calculate shipping
* and user that has 5 addresses stored in autofill settings.
*/
public class PaymentRequestDynamicShippingMultipleAddressesTest extends PaymentRequestTestBase {
public PaymentRequestDynamicShippingMultipleAddressesTest() {
// This merchant requests the shipping address first before providing any shipping options.
super("payment_request_dynamic_shipping_test.html");
}
@Override
public void onMainActivityStarted()
throws InterruptedException, ExecutionException, TimeoutException {
AutofillTestHelper helper = new AutofillTestHelper();
// Create an incomplete (no phone) profile with the highest frecency score.
String guid1 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Bart Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "", "bart@simpson.com", ""));
// Create an incomplete (no phone) profile with a the second highest frecency score.
String guid2 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Homer Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "", "homer@simpson.com", ""));
// Create a complete profile with a middle frecency score.
String guid3 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Lisa Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "555 123-4567", "lisa@simpson.com", ""));
// Create a complete profile with the second lowest frecency score.
String guid4 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Maggie Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "555 123-4567", "maggie@simpson.com", ""));
// Create an incomplete profile with the lowest frecency score.
String guid5 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Marge Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "", "marge@simpson.com", ""));
// Create a credit card associated witht the fourth profile.
helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe",
"4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_visa,
guid4));
// Set the use stats so that profile1 has the highest frecency score, profile2 the second
// highest, profile 3 the second lowest and profile4 the lowest.
helper.setProfileUseStatsForTesting(guid1, 20, 5000);
helper.setProfileUseStatsForTesting(guid2, 15, 5000);
helper.setProfileUseStatsForTesting(guid3, 10, 5000);
helper.setProfileUseStatsForTesting(guid4, 5, 5000);
helper.setProfileUseStatsForTesting(guid5, 1, 1);
}
/**
* Make sure the address suggestions are in the correct order and that only the top 4
* suggestions are shown. They should be ordered by frecency and complete addresses should be
* suggested first.
*/
@MediumTest
public void testShippingAddressSuggestionOrdering()
throws InterruptedException, ExecutionException, TimeoutException {
triggerUIAndWait(mReadyForInput);
clickInShippingSummaryAndWait(R.id.payments_section, mReadyForInput);
assertEquals(4, getNumberOfShippingAddressSuggestions());
assertTrue(getShippingAddressSuggestionLabel(0).contains("Lisa Simpson"));
assertTrue(getShippingAddressSuggestionLabel(1).contains("Maggie Simpson"));
assertTrue(getShippingAddressSuggestionLabel(2).contains("Bart Simpson"));
assertTrue(getShippingAddressSuggestionLabel(3).contains("Homer Simpson"));
}
}
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.payments;
import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.autofill.AutofillTestHelper;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* A payment integration test for a merchant that requests contact details and a user that has
* 5 contact detail options.
*/
public class PaymentRequestMultipleContactDetailsTest extends PaymentRequestTestBase {
public PaymentRequestMultipleContactDetailsTest() {
// The merchant requests both a phone number and an email address.
super("payment_request_contact_details_test.html");
}
@Override
public void onMainActivityStarted()
throws InterruptedException, ExecutionException, TimeoutException {
AutofillTestHelper helper = new AutofillTestHelper();
// Create an incomplete (no phone) profile with the highest frecency score.
String guid1 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Bart Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "", "bart@simpson.com", ""));
// Create an incomplete (no phone) profile with a the second highest frecency score.
String guid2 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Homer Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "", "homer@simpson.com", ""));
// Create a complete profile with a middle frecency score.
String guid3 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Lisa Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "555 123-4567", "lisa@simpson.com", ""));
// Create a complete profile with the second lowest frecency score.
String guid4 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Maggie Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "555 123-4567", "maggie@simpson.com", ""));
// Create an incomplete profile with the lowest frecency score.
String guid5 = helper.setProfile(
new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
"Marge Simpson", "Acme Inc.", "123 Main", "California", "Los Angeles", "",
"90210", "", "US", "", "marge@simpson.com", ""));
// Create a credit card associated with the fourth profile.
helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe",
"4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_visa,
guid4));
// Set the use stats so that profile1 has the highest frecency score, profile2 the second
// highest, profile 3 the third lowest, profile4 the second lowest and profile 5 the lowest.
helper.setProfileUseStatsForTesting(guid1, 20, 5000);
helper.setProfileUseStatsForTesting(guid2, 15, 5000);
helper.setProfileUseStatsForTesting(guid3, 10, 5000);
helper.setProfileUseStatsForTesting(guid4, 5, 5000);
helper.setProfileUseStatsForTesting(guid5, 1, 1);
}
/**
* Make sure the contact details suggestions are in the correct order and that only the top 4
* are shown. They should be ordered by frecency and complete contact details should be
* suggested first.
*/
@MediumTest
public void testContactDetailsSuggestionOrdering()
throws InterruptedException, ExecutionException, TimeoutException {
triggerUIAndWait(mReadyToPay);
clickInContactInfoAndWait(R.id.payments_section, mReadyForInput);
assertEquals(4, getNumberOfContactDetailSuggestions());
assertEquals("555 123-4567\nlisa@simpson.com", getContactDetailsSuggestionLabel(0));
assertEquals("555 123-4567\nmaggie@simpson.com", getContactDetailsSuggestionLabel(1));
assertEquals("bart@simpson.com", getContactDetailsSuggestionLabel(2));
assertEquals("homer@simpson.com", getContactDetailsSuggestionLabel(3));
}
}
......@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.autofill.CardUnmaskPrompt;
import org.chromium.chrome.browser.autofill.CardUnmaskPrompt.CardUnmaskObserverForTest;
import org.chromium.chrome.browser.payments.PaymentRequestImpl.PaymentRequestServiceObserverForTest;
import org.chromium.chrome.browser.payments.ui.EditorTextField;
import org.chromium.chrome.browser.payments.ui.PaymentRequestSection.OptionSection;
import org.chromium.chrome.browser.payments.ui.PaymentRequestUI;
import org.chromium.chrome.browser.payments.ui.PaymentRequestUI.PaymentRequestObserverForTest;
import org.chromium.chrome.test.ChromeActivityTestCaseBase;
......@@ -205,6 +206,66 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA
});
}
/**
* Returns the label corresponding to the contact detail suggestion at the specified
* |suggestionIndex|.
*/
protected String getContactDetailsSuggestionLabel(final int suggestionIndex)
throws ExecutionException {
assert (suggestionIndex < getNumberOfContactDetailSuggestions());
return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
@Override
public String call() {
return ((OptionSection) mUI.getContactDetailsSectionForTest())
.getOptionLabelsForTest(suggestionIndex).getText().toString();
}
});
}
/**
* Returns the the number of contact detail suggestions,
*/
protected int getNumberOfContactDetailSuggestions() throws ExecutionException {
return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
@Override
public Integer call() {
return ((OptionSection) mUI.getContactDetailsSectionForTest())
.getNumberOfOptionLabelsForTest();
}
});
}
/**
* Returns the label corresponding to the shipping address suggestion at the specified
* |suggestionIndex|.
*/
protected String getShippingAddressSuggestionLabel(final int suggestionIndex)
throws ExecutionException {
assert (suggestionIndex < getNumberOfShippingAddressSuggestions());
return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() {
@Override
public String call() {
return ((OptionSection) mUI.getShippingAddressSectionForTest())
.getOptionLabelsForTest(suggestionIndex).getText().toString();
}
});
}
/**
* Returns the the number of shipping address suggestions,
*/
protected int getNumberOfShippingAddressSuggestions() throws ExecutionException {
return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
@Override
public Integer call() {
return ((OptionSection) mUI.getShippingAddressSectionForTest())
.getNumberOfOptionLabelsForTest();
}
});
}
/** Selects the spinner value in the editor UI. */
protected void setSpinnerSelectionInEditor(final int selection, CallbackHelper helper)
throws InterruptedException, TimeoutException {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment