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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 class PaymentAppManagerTest : public testing::Test { | 55 class PaymentAppManagerTest : public testing::Test { |
56 public: | 56 public: |
57 PaymentAppManagerTest() | 57 PaymentAppManagerTest() |
58 : thread_bundle_( | 58 : thread_bundle_( |
59 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)), | 59 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)), |
60 embedded_worker_helper_(new EmbeddedWorkerTestHelper(base::FilePath())), | 60 embedded_worker_helper_(new EmbeddedWorkerTestHelper(base::FilePath())), |
61 storage_partition_impl_(new StoragePartitionImpl( | 61 storage_partition_impl_(new StoragePartitionImpl( |
62 embedded_worker_helper_->browser_context(), base::FilePath(), | 62 embedded_worker_helper_->browser_context(), base::FilePath(), |
63 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | 63 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, |
64 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)) { | 64 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)) { |
| 65 |
65 embedded_worker_helper_->context_wrapper()->set_storage_partition( | 66 embedded_worker_helper_->context_wrapper()->set_storage_partition( |
66 storage_partition_impl_.get()); | 67 storage_partition_impl_.get()); |
67 | 68 |
68 payment_app_context_ = new PaymentAppContextImpl(); | 69 payment_app_context_ = |
69 payment_app_context_->Init(embedded_worker_helper_->context_wrapper()); | 70 new PaymentAppContext(embedded_worker_helper_->context_wrapper()); |
70 | 71 |
71 bool called = false; | 72 bool called = false; |
72 embedded_worker_helper_->context()->RegisterServiceWorker( | 73 embedded_worker_helper_->context()->RegisterServiceWorker( |
73 GURL(kServiceWorkerPattern), GURL(kServiceWorkerScript), NULL, | 74 GURL(kServiceWorkerPattern), GURL(kServiceWorkerScript), NULL, |
74 base::Bind(&RegisterServiceWorkerCallback, &called, | 75 base::Bind(&RegisterServiceWorkerCallback, &called, |
75 &sw_registration_id_)); | 76 &sw_registration_id_)); |
76 base::RunLoop().RunUntilIdle(); | 77 base::RunLoop().RunUntilIdle(); |
77 EXPECT_TRUE(called); | 78 EXPECT_TRUE(called); |
78 | 79 |
79 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request = | 80 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request = |
(...skipping 21 matching lines...) Expand all Loading... |
101 const PaymentAppManager::GetManifestCallback& callback) { | 102 const PaymentAppManager::GetManifestCallback& callback) { |
102 manager_->GetManifest(scope, callback); | 103 manager_->GetManifest(scope, callback); |
103 base::RunLoop().RunUntilIdle(); | 104 base::RunLoop().RunUntilIdle(); |
104 } | 105 } |
105 | 106 |
106 private: | 107 private: |
107 std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; | 108 std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; |
108 std::unique_ptr<EmbeddedWorkerTestHelper> embedded_worker_helper_; | 109 std::unique_ptr<EmbeddedWorkerTestHelper> embedded_worker_helper_; |
109 std::unique_ptr<StoragePartitionImpl> storage_partition_impl_; | 110 std::unique_ptr<StoragePartitionImpl> storage_partition_impl_; |
110 int64_t sw_registration_id_; | 111 int64_t sw_registration_id_; |
111 scoped_refptr<PaymentAppContextImpl> payment_app_context_; | 112 scoped_refptr<PaymentAppContext> payment_app_context_; |
112 payments::mojom::PaymentAppManagerPtr service_; | 113 payments::mojom::PaymentAppManagerPtr service_; |
113 | 114 |
114 // Owned by payment_app_context_. | 115 // Owned by payment_app_context_. |
115 PaymentAppManager* manager_; | 116 PaymentAppManager* manager_; |
116 | 117 |
117 DISALLOW_COPY_AND_ASSIGN(PaymentAppManagerTest); | 118 DISALLOW_COPY_AND_ASSIGN(PaymentAppManagerTest); |
118 }; | 119 }; |
119 | 120 |
120 TEST_F(PaymentAppManagerTest, SetAndGetManifest) { | 121 TEST_F(PaymentAppManagerTest, SetAndGetManifest) { |
121 payments::mojom::PaymentAppOptionPtr option = | 122 payments::mojom::PaymentAppOptionPtr option = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 payments::mojom::PaymentAppManifestPtr read_manifest; | 158 payments::mojom::PaymentAppManifestPtr read_manifest; |
158 payments::mojom::PaymentAppManifestError read_error; | 159 payments::mojom::PaymentAppManifestError read_error; |
159 GetManifest(kServiceWorkerPattern, | 160 GetManifest(kServiceWorkerPattern, |
160 base::Bind(&GetManifestCallback, &read_manifest, &read_error)); | 161 base::Bind(&GetManifestCallback, &read_manifest, &read_error)); |
161 | 162 |
162 EXPECT_EQ(read_error, payments::mojom::PaymentAppManifestError:: | 163 EXPECT_EQ(read_error, payments::mojom::PaymentAppManifestError:: |
163 MANIFEST_STORAGE_OPERATION_FAILED); | 164 MANIFEST_STORAGE_OPERATION_FAILED); |
164 } | 165 } |
165 | 166 |
166 } // namespace content | 167 } // namespace content |
OLD | NEW |