Index: content/browser/payments/payment_app_provider_impl_unittest.cc |
diff --git a/content/browser/payments/payment_app_provider_impl_unittest.cc b/content/browser/payments/payment_app_provider_impl_unittest.cc |
index 5ced822c8637c82def4bbd58569ce6f279c21d8c..dcf0f53c57aa6939e5cc42ae929f2e6c579f2e7d 100644 |
--- a/content/browser/payments/payment_app_provider_impl_unittest.cc |
+++ b/content/browser/payments/payment_app_provider_impl_unittest.cc |
@@ -23,6 +23,10 @@ class PaymentManager; |
namespace { |
+using ::payments::mojom::PaymentHandlerStatus; |
+using ::payments::mojom::PaymentInstrument; |
+using ::payments::mojom::PaymentInstrumentPtr; |
+ |
void SetManifestCallback(bool* called, |
PaymentAppManifestError* out_error, |
PaymentAppManifestError error) { |
@@ -37,6 +41,16 @@ void GetAllManifestsCallback(bool* called, |
*out_manifests = std::move(manifests); |
} |
+void SetPaymentInstrumentCallback(PaymentHandlerStatus* out_status, |
+ PaymentHandlerStatus status) { |
+ *out_status = status; |
+} |
+ |
+void GetAllPaymentAppsCallback(PaymentAppProvider::PaymentApps* out_apps, |
+ PaymentAppProvider::PaymentApps apps) { |
+ *out_apps = std::move(apps); |
+} |
+ |
void InvokePaymentAppCallback(bool* called, |
payments::mojom::PaymentAppResponsePtr response) { |
*called = true; |
@@ -55,6 +69,24 @@ class PaymentAppProviderTest : public PaymentAppContentUnitTestBase { |
base::RunLoop().RunUntilIdle(); |
} |
+ void SetPaymentInstrument( |
+ PaymentManager* manager, |
+ const std::string& instrument_key, |
+ PaymentInstrumentPtr instrument, |
+ PaymentManager::SetPaymentInstrumentCallback callback) { |
+ ASSERT_NE(nullptr, manager); |
+ manager->SetPaymentInstrument(instrument_key, std::move(instrument), |
+ std::move(callback)); |
+ base::RunLoop().RunUntilIdle(); |
+ } |
+ |
+ void GetAllPaymentApps( |
+ PaymentAppProvider::GetAllPaymentAppsCallback callback) { |
+ PaymentAppProviderImpl::GetInstance()->GetAllPaymentApps( |
+ browser_context(), std::move(callback)); |
+ base::RunLoop().RunUntilIdle(); |
+ } |
+ |
void InvokePaymentApp(int64_t registration_id, |
payments::mojom::PaymentAppRequestPtr app_request, |
PaymentAppProvider::InvokePaymentAppCallback callback) { |
@@ -148,4 +180,26 @@ TEST_F(PaymentAppProviderTest, InvokePaymentAppTest) { |
EXPECT_EQ(GURL(kPaymentAppInfo[1].scopeUrl), last_sw_scope_url()); |
} |
+TEST_F(PaymentAppProviderTest, GetAllPaymentAppsTest) { |
+ PaymentManager* manager1 = CreatePaymentManager( |
+ GURL("https://hellopay.com/a"), GURL("https://hellopay.com/a/script.js")); |
+ PaymentManager* manager2 = CreatePaymentManager( |
+ GURL("https://bobpay.com/b"), GURL("https://bobpay.com/b/script.js")); |
+ |
+ PaymentHandlerStatus status; |
+ SetPaymentInstrument(manager1, "test_key1", PaymentInstrument::New(), |
+ base::Bind(&SetPaymentInstrumentCallback, &status)); |
+ SetPaymentInstrument(manager2, "test_key2", PaymentInstrument::New(), |
+ base::Bind(&SetPaymentInstrumentCallback, &status)); |
+ SetPaymentInstrument(manager2, "test_key3", PaymentInstrument::New(), |
+ base::Bind(&SetPaymentInstrumentCallback, &status)); |
+ |
+ PaymentAppProvider::PaymentApps apps; |
+ GetAllPaymentApps(base::Bind(&GetAllPaymentAppsCallback, &apps)); |
+ |
+ ASSERT_EQ(2U, apps.size()); |
+ ASSERT_EQ(1U, apps[GURL("https://hellopay.com/")].size()); |
+ ASSERT_EQ(2U, apps[GURL("https://bobpay.com/")].size()); |
+} |
+ |
} // namespace content |