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

Unified Diff: content/browser/payments/payment_app_provider_impl_unittest.cc

Issue 2873683002: PaymentHandler: Implement GetAllPaymentApps(). (Closed)
Patch Set: installed -> stored in public Created 3 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
« no previous file with comments | « content/browser/payments/payment_app_provider_impl.cc ('k') | content/browser/payments/payment_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/payments/payment_app_provider_impl.cc ('k') | content/browser/payments/payment_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698