Commit ba7f1536 authored by Mohamad Ahmadi's avatar Mohamad Ahmadi Committed by Commit Bot

[Payment Request] Don't load validation rules in AddressNormalizationManager

Stops proactively loading validation rules in AddressNormalizationManager.
There's no guarantee that the default country code provided to the
AddressNormalizationManager is the same as the country code of the address
to be normalized, nor how much this proactive loading of the rules speeds
up the normalization. Therefore, this call is safe to remove.

Also this async operation can break tests, in which there is a blocking
call to base::Runloop::Run().

This CL also renames the payment instrument finder/launcher unit tests so
that they share the same prefix as other iOS Payment Request unit tests.

Bug: 602666
Change-Id: Ie9792faf33a6b826301519a0ace609cf4a18c9b9
Reviewed-on: https://chromium-review.googlesource.com/651168
Commit-Queue: mahmadi (Moe) <mahmadi@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499990}
parent 6f6900b0
......@@ -22,11 +22,6 @@ AddressNormalizationManager::AddressNormalizationManager(
address_normalizer_(address_normalizer) {
DCHECK(autofill::data_util::IsValidCountryCode(default_country_code));
DCHECK(address_normalizer_);
// Start loading rules for the default country code. This happens
// asynchronously, and will speed up normalization later if the rules for the
// address' region have already been loaded.
address_normalizer_->LoadRulesForRegion(default_country_code);
}
AddressNormalizationManager::~AddressNormalizationManager() {}
......
......@@ -93,7 +93,7 @@ class IOSPaymentInstrumentFinder {
IOSPaymentInstrumentsFoundCallback callback);
private:
friend class IOSPaymentInstrumentFinderTest;
friend class PaymentRequestIOSPaymentInstrumentFinderTest;
// Filters out |queried_url_payment_method_identifiers| for any invalid
// url payment method identifiers queried by the caller. An invalid url
......
......@@ -72,7 +72,7 @@ class IOSPaymentInstrumentLauncher : public KeyedService {
std::string payment_request_id() { return payment_request_id_; }
private:
friend class IOSPaymentInstrumentLauncherTest;
friend class PaymentRequestIOSPaymentInstrumentLauncherTest;
// Returns the JSON-serialized dictionary from each method name the merchant
// requested to the corresponding method data. |stringified_method_data| is
......
......@@ -71,9 +71,9 @@ class FakePaymentInstrumentDelegate : public PaymentInstrument::Delegate {
} // namespace
class IOSPaymentInstrumentLauncherTest : public testing::Test {
class PaymentRequestIOSPaymentInstrumentLauncherTest : public testing::Test {
protected:
IOSPaymentInstrumentLauncherTest()
PaymentRequestIOSPaymentInstrumentLauncherTest()
: chrome_browser_state_(TestChromeBrowserState::Builder().Build()) {}
std::unique_ptr<base::DictionaryValue> SerializeMethodDataWrapper(
......@@ -95,7 +95,8 @@ class IOSPaymentInstrumentLauncherTest : public testing::Test {
// Tests that serializing empty stringified method data yields the expected
// result.
TEST_F(IOSPaymentInstrumentLauncherTest, EmptyStringifiedMethodDataDictionary) {
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
EmptyStringifiedMethodDataDictionary) {
web::PaymentRequest web_payment_request;
autofill::TestPersonalDataManager personal_data_manager;
TestPaymentRequest payment_request(web_payment_request,
......@@ -111,7 +112,7 @@ TEST_F(IOSPaymentInstrumentLauncherTest, EmptyStringifiedMethodDataDictionary) {
// Tests that serializing populated stringified method data yields the expected
// result.
TEST_F(IOSPaymentInstrumentLauncherTest,
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
PopulatedStringifiedMethodDataDictionary) {
web::PaymentRequest web_payment_request;
PaymentMethodData method_datum1;
......@@ -165,7 +166,7 @@ TEST_F(IOSPaymentInstrumentLauncherTest,
// Tests that attempting to open an invalid universal link calls the
// OnInstrumentDetailsError() function of the delegate.
TEST_F(IOSPaymentInstrumentLauncherTest,
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
LaunchIOSPaymentInstrument_MalformedUniversalLink) {
if (base::ios::IsRunningOnIOS10OrLater()) {
std::unique_ptr<web::TestNavigationManager> navigation_manager =
......@@ -198,7 +199,7 @@ TEST_F(IOSPaymentInstrumentLauncherTest,
// Tests that if the response from the payment app is not a valid JSON
// dictionary then the OnInstrumentDetailsError() function of the delegate
// is called.
TEST_F(IOSPaymentInstrumentLauncherTest,
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
ReceiveResponseFromIOSPaymentInstrument_ResponseNotDictionary) {
FakePaymentInstrumentDelegate instrument_delegate;
IOSPaymentInstrumentLauncher launcher;
......@@ -220,7 +221,7 @@ TEST_F(IOSPaymentInstrumentLauncherTest,
// Tests that if a payment app claims to have not been successful in
// fulfilling its side of the transaction then OnInstrumentDetailsError()
// is called.
TEST_F(IOSPaymentInstrumentLauncherTest,
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
ReceiveResponseFromIOSPaymentInstrument_PaymentAppFailed) {
FakePaymentInstrumentDelegate instrument_delegate;
IOSPaymentInstrumentLauncher launcher;
......@@ -247,7 +248,7 @@ TEST_F(IOSPaymentInstrumentLauncherTest,
// Tests that if the response from the payment app does not contain a
// method name then OnInstrumentDetailsError() of the delegate is
// called.
TEST_F(IOSPaymentInstrumentLauncherTest,
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
ReceiveResponseFromIOSPaymentInstrument_NoMethodName) {
FakePaymentInstrumentDelegate instrument_delegate;
IOSPaymentInstrumentLauncher launcher;
......@@ -273,7 +274,7 @@ TEST_F(IOSPaymentInstrumentLauncherTest,
// Tests that if the response from the payment app does not contain any
// stringified details then OnInstrumentDetailsError() of the delegate is
// called.
TEST_F(IOSPaymentInstrumentLauncherTest,
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
ReceiveResponseFromIOSPaymentInstrument_NoDetails) {
FakePaymentInstrumentDelegate instrument_delegate;
IOSPaymentInstrumentLauncher launcher;
......@@ -299,7 +300,7 @@ TEST_F(IOSPaymentInstrumentLauncherTest,
// Tests that if the response from the payment app has all necessary
// parameters with valid values then OnInstrumentDetailsReady() of the
// delegate is called.
TEST_F(IOSPaymentInstrumentLauncherTest,
TEST_F(PaymentRequestIOSPaymentInstrumentLauncherTest,
ReceiveResponseFromIOSPaymentInstrument_WellFormedResponse) {
FakePaymentInstrumentDelegate instrument_delegate;
IOSPaymentInstrumentLauncher launcher;
......
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