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 "content/browser/payments/payment_app_manager.h" | 5 #include "content/browser/payments/payment_app_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 payments::mojom::PaymentAppManifestPtr manifest, | 52 payments::mojom::PaymentAppManifestPtr manifest, |
53 payments::mojom::PaymentAppManifestError error) { | 53 payments::mojom::PaymentAppManifestError error) { |
54 *called = true; | 54 *called = true; |
55 *out_manifest = std::move(manifest); | 55 *out_manifest = std::move(manifest); |
56 *out_error = error; | 56 *out_error = error; |
57 } | 57 } |
58 | 58 |
59 payments::mojom::PaymentAppManifestPtr CreatePaymentAppManifestForTest() { | 59 payments::mojom::PaymentAppManifestPtr CreatePaymentAppManifestForTest() { |
60 payments::mojom::PaymentAppOptionPtr option = | 60 payments::mojom::PaymentAppOptionPtr option = |
61 payments::mojom::PaymentAppOption::New(); | 61 payments::mojom::PaymentAppOption::New(); |
62 option->label = "Visa ****"; | 62 option->name = "Visa ****"; |
63 option->id = "payment-app-id"; | 63 option->id = "payment-app-id"; |
64 option->icon = std::string("payment-app-icon"); | 64 option->icon = std::string("payment-app-icon"); |
65 option->enabled_methods.push_back("visa"); | 65 option->enabled_methods.push_back("visa"); |
66 | 66 |
67 payments::mojom::PaymentAppManifestPtr manifest = | 67 payments::mojom::PaymentAppManifestPtr manifest = |
68 payments::mojom::PaymentAppManifest::New(); | 68 payments::mojom::PaymentAppManifest::New(); |
69 manifest->icon = std::string("payment-app-icon"); | 69 manifest->icon = std::string("payment-app-icon"); |
70 manifest->label = "Payment App"; | 70 manifest->name = "Payment App"; |
71 manifest->options.push_back(std::move(option)); | 71 manifest->options.push_back(std::move(option)); |
72 | 72 |
73 return manifest; | 73 return manifest; |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 class PaymentAppManagerTest : public testing::Test { | 78 class PaymentAppManagerTest : public testing::Test { |
79 public: | 79 public: |
80 PaymentAppManagerTest() | 80 PaymentAppManagerTest() |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 called = false; | 153 called = false; |
154 payments::mojom::PaymentAppManifestPtr read_manifest; | 154 payments::mojom::PaymentAppManifestPtr read_manifest; |
155 payments::mojom::PaymentAppManifestError read_error = payments::mojom:: | 155 payments::mojom::PaymentAppManifestError read_error = payments::mojom:: |
156 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; | 156 PaymentAppManifestError::MANIFEST_STORAGE_OPERATION_FAILED; |
157 GetManifest(kServiceWorkerPattern, base::Bind(&GetManifestCallback, &called, | 157 GetManifest(kServiceWorkerPattern, base::Bind(&GetManifestCallback, &called, |
158 &read_manifest, &read_error)); | 158 &read_manifest, &read_error)); |
159 | 159 |
160 ASSERT_TRUE(called); | 160 ASSERT_TRUE(called); |
161 ASSERT_EQ(read_error, payments::mojom::PaymentAppManifestError::NONE); | 161 ASSERT_EQ(read_error, payments::mojom::PaymentAppManifestError::NONE); |
162 EXPECT_EQ(read_manifest->icon, std::string("payment-app-icon")); | 162 EXPECT_EQ(read_manifest->icon, std::string("payment-app-icon")); |
163 EXPECT_EQ(read_manifest->label, "Payment App"); | 163 EXPECT_EQ(read_manifest->name, "Payment App"); |
164 ASSERT_EQ(read_manifest->options.size(), 1U); | 164 ASSERT_EQ(read_manifest->options.size(), 1U); |
165 EXPECT_EQ(read_manifest->options[0]->icon, std::string("payment-app-icon")); | 165 EXPECT_EQ(read_manifest->options[0]->icon, std::string("payment-app-icon")); |
166 EXPECT_EQ(read_manifest->options[0]->label, "Visa ****"); | 166 EXPECT_EQ(read_manifest->options[0]->name, "Visa ****"); |
167 EXPECT_EQ(read_manifest->options[0]->id, "payment-app-id"); | 167 EXPECT_EQ(read_manifest->options[0]->id, "payment-app-id"); |
168 ASSERT_EQ(read_manifest->options[0]->enabled_methods.size(), 1U); | 168 ASSERT_EQ(read_manifest->options[0]->enabled_methods.size(), 1U); |
169 EXPECT_EQ(read_manifest->options[0]->enabled_methods[0], "visa"); | 169 EXPECT_EQ(read_manifest->options[0]->enabled_methods[0], "visa"); |
170 } | 170 } |
171 | 171 |
172 TEST_F(PaymentAppManagerTest, SetManifestWithoutAssociatedServiceWorker) { | 172 TEST_F(PaymentAppManagerTest, SetManifestWithoutAssociatedServiceWorker) { |
173 bool called = false; | 173 bool called = false; |
174 payments::mojom::PaymentAppManifestError error = | 174 payments::mojom::PaymentAppManifestError error = |
175 payments::mojom::PaymentAppManifestError::NONE; | 175 payments::mojom::PaymentAppManifestError::NONE; |
176 SetManifest(kUnregisteredServiceWorkerPattern, | 176 SetManifest(kUnregisteredServiceWorkerPattern, |
(...skipping 25 matching lines...) Expand all Loading... |
202 payments::mojom::PaymentAppManifestError::NONE; | 202 payments::mojom::PaymentAppManifestError::NONE; |
203 GetManifest(kServiceWorkerPattern, base::Bind(&GetManifestCallback, &called, | 203 GetManifest(kServiceWorkerPattern, base::Bind(&GetManifestCallback, &called, |
204 &read_manifest, &read_error)); | 204 &read_manifest, &read_error)); |
205 | 205 |
206 ASSERT_TRUE(called); | 206 ASSERT_TRUE(called); |
207 EXPECT_EQ(read_error, payments::mojom::PaymentAppManifestError:: | 207 EXPECT_EQ(read_error, payments::mojom::PaymentAppManifestError:: |
208 MANIFEST_STORAGE_OPERATION_FAILED); | 208 MANIFEST_STORAGE_OPERATION_FAILED); |
209 } | 209 } |
210 | 210 |
211 } // namespace content | 211 } // namespace content |
OLD | NEW |