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