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

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

Issue 2610163002: PaymentApp: Implement InvokePaymentApp() in browser side. (Closed)
Patch Set: nhiroki's comments Created 3 years, 11 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: 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 8fde6670496bc23830b328de26bdf07a586cb990..e6e6edf27707e5c89f1a23d680c74aba9c00617a 100644
--- a/content/browser/payments/payment_app_provider_impl_unittest.cc
+++ b/content/browser/payments/payment_app_provider_impl_unittest.cc
@@ -50,6 +50,13 @@ class PaymentAppProviderTest : public PaymentAppContentUnitTestBase {
base::RunLoop().RunUntilIdle();
}
+ void InvokePaymentApp(int64_t registration_id,
+ payments::mojom::PaymentAppRequestDataPtr data) {
+ PaymentAppProviderImpl::GetInstance()->InvokePaymentApp(
+ browser_context(), registration_id, std::move(data));
+ base::RunLoop().RunUntilIdle();
+ }
+
void CreatePaymentApp(const GURL& scope_url, const GURL& sw_script_url) {
PaymentAppManager* manager =
CreatePaymentAppManager(scope_url, sw_script_url);
@@ -68,7 +75,7 @@ class PaymentAppProviderTest : public PaymentAppContentUnitTestBase {
DISALLOW_COPY_AND_ASSIGN(PaymentAppProviderTest);
};
-TEST_F(PaymentAppProviderTest, Test) {
+TEST_F(PaymentAppProviderTest, GetAllManifestsTest) {
static const struct {
const char* scopeUrl;
const char* scriptUrl;
@@ -101,4 +108,38 @@ TEST_F(PaymentAppProviderTest, Test) {
}
}
+TEST_F(PaymentAppProviderTest, InvokePaymentAppTest) {
+ static const struct {
+ const char* scopeUrl;
+ const char* scriptUrl;
+ } kPaymentAppInfo[] = {
+ {"https://example.com/a", "https://example.com/a/script.js"},
+ {"https://example.com/b", "https://example.com/b/script.js"},
+ {"https://example.com/c", "https://example.com/c/script.js"}};
+
+ for (size_t i = 0; i < arraysize(kPaymentAppInfo); i++) {
+ CreatePaymentApp(GURL(kPaymentAppInfo[i].scopeUrl),
+ GURL(kPaymentAppInfo[i].scriptUrl));
+ }
+
+ PaymentAppProvider::Manifests manifests;
+ bool called = false;
+ GetAllManifests(base::Bind(&GetAllManifestsCallback, &called, &manifests));
+ ASSERT_TRUE(called);
+ ASSERT_EQ(3U, manifests.size());
+
+ payments::mojom::PaymentAppRequestDataPtr data =
+ payments::mojom::PaymentAppRequestData::New();
+ data->methodData.push_back(payments::mojom::PaymentMethodData::New());
+ data->total = payments::mojom::PaymentItem::New();
+ data->total->amount = payments::mojom::PaymentCurrencyAmount::New();
+
+ EXPECT_FALSE(payment_app_invoked());
+ InvokePaymentApp(manifests[1].first, std::move(data));
+
+ ASSERT_TRUE(payment_app_invoked());
+ EXPECT_EQ(manifests[1].first, last_sw_registration_id());
+ EXPECT_EQ(GURL(kPaymentAppInfo[1].scopeUrl), last_sw_scope_url());
+}
+
} // namespace content
« no previous file with comments | « content/browser/payments/payment_app_provider_impl.cc ('k') | content/browser/service_worker/embedded_worker_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698