OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <cstddef> | 5 #include <cstddef> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "components/payments/content/payment_app.mojom.h" | 11 #include "components/payments/content/payment_app.mojom.h" |
12 #include "content/browser/payments/payment_app_content_unittest_base.h" | 12 #include "content/browser/payments/payment_app_content_unittest_base.h" |
13 #include "content/browser/payments/payment_app_provider_impl.h" | 13 #include "content/browser/payments/payment_app_provider_impl.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 using payments::mojom::PaymentAppManifestError; | 17 using payments::mojom::PaymentAppManifestError; |
18 using payments::mojom::PaymentAppManifestPtr; | 18 using payments::mojom::PaymentAppManifestPtr; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 class PaymentAppManager; | 22 class PaymentManager; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 void SetManifestCallback(bool* called, | 26 void SetManifestCallback(bool* called, |
27 PaymentAppManifestError* out_error, | 27 PaymentAppManifestError* out_error, |
28 PaymentAppManifestError error) { | 28 PaymentAppManifestError error) { |
29 *called = true; | 29 *called = true; |
30 *out_error = error; | 30 *out_error = error; |
31 } | 31 } |
32 | 32 |
(...skipping 24 matching lines...) Expand all Loading... |
57 | 57 |
58 void InvokePaymentApp(int64_t registration_id, | 58 void InvokePaymentApp(int64_t registration_id, |
59 payments::mojom::PaymentAppRequestPtr app_request, | 59 payments::mojom::PaymentAppRequestPtr app_request, |
60 PaymentAppProvider::InvokePaymentAppCallback callback) { | 60 PaymentAppProvider::InvokePaymentAppCallback callback) { |
61 PaymentAppProviderImpl::GetInstance()->InvokePaymentApp( | 61 PaymentAppProviderImpl::GetInstance()->InvokePaymentApp( |
62 browser_context(), registration_id, std::move(app_request), callback); | 62 browser_context(), registration_id, std::move(app_request), callback); |
63 base::RunLoop().RunUntilIdle(); | 63 base::RunLoop().RunUntilIdle(); |
64 } | 64 } |
65 | 65 |
66 void CreatePaymentApp(const GURL& scope_url, const GURL& sw_script_url) { | 66 void CreatePaymentApp(const GURL& scope_url, const GURL& sw_script_url) { |
67 PaymentAppManager* manager = | 67 PaymentManager* manager = CreatePaymentManager(scope_url, sw_script_url); |
68 CreatePaymentAppManager(scope_url, sw_script_url); | |
69 | 68 |
70 PaymentAppManifestError error = | 69 PaymentAppManifestError error = |
71 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; | 70 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; |
72 bool called = false; | 71 bool called = false; |
73 SetManifest(manager, CreatePaymentAppManifestForTest(scope_url.spec()), | 72 SetManifest(manager, CreatePaymentAppManifestForTest(scope_url.spec()), |
74 base::Bind(&SetManifestCallback, &called, &error)); | 73 base::Bind(&SetManifestCallback, &called, &error)); |
75 ASSERT_TRUE(called); | 74 ASSERT_TRUE(called); |
76 | 75 |
77 ASSERT_EQ(PaymentAppManifestError::NONE, error); | 76 ASSERT_EQ(PaymentAppManifestError::NONE, error); |
78 } | 77 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 called = false; | 142 called = false; |
144 InvokePaymentApp(manifests[1].first, std::move(app_request), | 143 InvokePaymentApp(manifests[1].first, std::move(app_request), |
145 base::Bind(&InvokePaymentAppCallback, &called)); | 144 base::Bind(&InvokePaymentAppCallback, &called)); |
146 ASSERT_TRUE(called); | 145 ASSERT_TRUE(called); |
147 | 146 |
148 EXPECT_EQ(manifests[1].first, last_sw_registration_id()); | 147 EXPECT_EQ(manifests[1].first, last_sw_registration_id()); |
149 EXPECT_EQ(GURL(kPaymentAppInfo[1].scopeUrl), last_sw_scope_url()); | 148 EXPECT_EQ(GURL(kPaymentAppInfo[1].scopeUrl), last_sw_scope_url()); |
150 } | 149 } |
151 | 150 |
152 } // namespace content | 151 } // namespace content |
OLD | NEW |