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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 // Owned by payment_app_context_. | 114 // Owned by payment_app_context_. |
115 PaymentAppManager* manager_; | 115 PaymentAppManager* manager_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(PaymentAppManagerTest); | 117 DISALLOW_COPY_AND_ASSIGN(PaymentAppManagerTest); |
118 }; | 118 }; |
119 | 119 |
120 TEST_F(PaymentAppManagerTest, SetAndGetManifest) { | 120 TEST_F(PaymentAppManagerTest, SetAndGetManifest) { |
121 payments::mojom::PaymentAppOptionPtr option = | 121 payments::mojom::PaymentAppOptionPtr option = |
122 payments::mojom::PaymentAppOption::New(); | 122 payments::mojom::PaymentAppOption::New(); |
123 option->label = "Visa ****"; | 123 option->name = "Visa ****"; |
124 option->id = "payment-app-id"; | 124 option->id = "payment-app-id"; |
125 option->icon = std::string("payment-app-icon"); | 125 option->icon = std::string("payment-app-icon"); |
126 option->enabled_methods.push_back("visa"); | 126 option->enabled_methods.push_back("visa"); |
127 | 127 |
128 payments::mojom::PaymentAppManifestPtr manifest = | 128 payments::mojom::PaymentAppManifestPtr manifest = |
129 payments::mojom::PaymentAppManifest::New(); | 129 payments::mojom::PaymentAppManifest::New(); |
130 manifest->icon = std::string("payment-app-icon"); | 130 manifest->icon = std::string("payment-app-icon"); |
131 manifest->label = "Payment App"; | 131 manifest->name = "Payment App"; |
132 manifest->options.push_back(std::move(option)); | 132 manifest->options.push_back(std::move(option)); |
133 | 133 |
134 payments::mojom::PaymentAppManifestError error; | 134 payments::mojom::PaymentAppManifestError error; |
135 SetManifest(kServiceWorkerPattern, std::move(manifest), | 135 SetManifest(kServiceWorkerPattern, std::move(manifest), |
136 base::Bind(&SetManifestCallback, &error)); | 136 base::Bind(&SetManifestCallback, &error)); |
137 | 137 |
138 ASSERT_EQ(error, payments::mojom::PaymentAppManifestError::NONE); | 138 ASSERT_EQ(error, payments::mojom::PaymentAppManifestError::NONE); |
139 | 139 |
140 payments::mojom::PaymentAppManifestPtr read_manifest; | 140 payments::mojom::PaymentAppManifestPtr read_manifest; |
141 payments::mojom::PaymentAppManifestError read_error; | 141 payments::mojom::PaymentAppManifestError read_error; |
142 GetManifest(kServiceWorkerPattern, | 142 GetManifest(kServiceWorkerPattern, |
143 base::Bind(&GetManifestCallback, &read_manifest, &read_error)); | 143 base::Bind(&GetManifestCallback, &read_manifest, &read_error)); |
144 | 144 |
145 ASSERT_EQ(read_error, payments::mojom::PaymentAppManifestError::NONE); | 145 ASSERT_EQ(read_error, payments::mojom::PaymentAppManifestError::NONE); |
146 EXPECT_EQ(read_manifest->icon, std::string("payment-app-icon")); | 146 EXPECT_EQ(read_manifest->icon, std::string("payment-app-icon")); |
147 EXPECT_EQ(read_manifest->label, "Payment App"); | 147 EXPECT_EQ(read_manifest->name, "Payment App"); |
148 ASSERT_EQ(read_manifest->options.size(), 1U); | 148 ASSERT_EQ(read_manifest->options.size(), 1U); |
149 EXPECT_EQ(read_manifest->options[0]->icon, std::string("payment-app-icon")); | 149 EXPECT_EQ(read_manifest->options[0]->icon, std::string("payment-app-icon")); |
150 EXPECT_EQ(read_manifest->options[0]->label, "Visa ****"); | 150 EXPECT_EQ(read_manifest->options[0]->name, "Visa ****"); |
151 EXPECT_EQ(read_manifest->options[0]->id, "payment-app-id"); | 151 EXPECT_EQ(read_manifest->options[0]->id, "payment-app-id"); |
152 ASSERT_EQ(read_manifest->options[0]->enabled_methods.size(), 1U); | 152 ASSERT_EQ(read_manifest->options[0]->enabled_methods.size(), 1U); |
153 EXPECT_EQ(read_manifest->options[0]->enabled_methods[0], "visa"); | 153 EXPECT_EQ(read_manifest->options[0]->enabled_methods[0], "visa"); |
154 } | 154 } |
155 | 155 |
156 TEST_F(PaymentAppManagerTest, GetManifestWithoutAssociatedServiceWorker) { | 156 TEST_F(PaymentAppManagerTest, GetManifestWithoutAssociatedServiceWorker) { |
157 payments::mojom::PaymentAppManifestPtr read_manifest; | 157 payments::mojom::PaymentAppManifestPtr read_manifest; |
158 payments::mojom::PaymentAppManifestError read_error; | 158 payments::mojom::PaymentAppManifestError read_error; |
159 GetManifest(kServiceWorkerPattern, | 159 GetManifest(kServiceWorkerPattern, |
160 base::Bind(&GetManifestCallback, &read_manifest, &read_error)); | 160 base::Bind(&GetManifestCallback, &read_manifest, &read_error)); |
161 | 161 |
162 EXPECT_EQ(read_error, payments::mojom::PaymentAppManifestError:: | 162 EXPECT_EQ(read_error, payments::mojom::PaymentAppManifestError:: |
163 MANIFEST_STORAGE_OPERATION_FAILED); | 163 MANIFEST_STORAGE_OPERATION_FAILED); |
164 } | 164 } |
165 | 165 |
166 } // namespace content | 166 } // namespace content |
OLD | NEW |