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_content_unittest_base.h" | 5 #include "content/browser/payments/payment_app_content_unittest_base.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 15 matching lines...) Expand all Loading... | |
26 namespace { | 26 namespace { |
27 | 27 |
28 void RegisterServiceWorkerCallback(bool* called, | 28 void RegisterServiceWorkerCallback(bool* called, |
29 ServiceWorkerStatusCode status, | 29 ServiceWorkerStatusCode status, |
30 const std::string& status_message, | 30 const std::string& status_message, |
31 int64_t registration_id) { | 31 int64_t registration_id) { |
32 EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); | 32 EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); |
33 *called = true; | 33 *called = true; |
34 } | 34 } |
35 | 35 |
36 void UnregisterServiceWorkerCallback(bool* called, | |
37 ServiceWorkerStatusCode status) { | |
38 EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); | |
39 *called = true; | |
40 } | |
41 | |
36 } // namespace | 42 } // namespace |
37 | 43 |
38 PaymentAppContentUnitTestBase::PaymentAppContentUnitTestBase() | 44 PaymentAppContentUnitTestBase::PaymentAppContentUnitTestBase() |
39 : thread_bundle_( | 45 : thread_bundle_( |
40 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)), | 46 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)), |
41 embedded_worker_helper_(new EmbeddedWorkerTestHelper(base::FilePath())), | 47 embedded_worker_helper_(new EmbeddedWorkerTestHelper(base::FilePath())), |
42 storage_partition_impl_( | 48 storage_partition_impl_( |
43 new StoragePartitionImpl(embedded_worker_helper_->browser_context(), | 49 new StoragePartitionImpl(embedded_worker_helper_->browser_context(), |
44 base::FilePath(), | 50 base::FilePath(), |
45 nullptr)), | 51 nullptr)), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 payments::mojom::PaymentAppManagerPtr manager; | 87 payments::mojom::PaymentAppManagerPtr manager; |
82 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request = | 88 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request = |
83 mojo::GetProxy(&manager); | 89 mojo::GetProxy(&manager); |
84 payment_app_managers_.push_back(std::move(manager)); | 90 payment_app_managers_.push_back(std::move(manager)); |
85 payment_app_context_->CreatePaymentAppManager(std::move(request)); | 91 payment_app_context_->CreatePaymentAppManager(std::move(request)); |
86 base::RunLoop().RunUntilIdle(); | 92 base::RunLoop().RunUntilIdle(); |
87 | 93 |
88 // Find a last registered payment app manager. | 94 // Find a last registered payment app manager. |
89 for (const auto& candidate_manager : | 95 for (const auto& candidate_manager : |
90 payment_app_context_->payment_app_managers_) { | 96 payment_app_context_->payment_app_managers_) { |
91 if (!base::ContainsKey(existing_managers, candidate_manager.first)) | 97 if (!base::ContainsKey(existing_managers, candidate_manager.first)) { |
98 candidate_manager.first->Init(scope_url.spec()); | |
please use gerrit instead
2016/12/20 16:57:54
Run the loop here as well, because Init() posts a
zino
2016/12/20 17:18:37
Done.
| |
92 return candidate_manager.first; | 99 return candidate_manager.first; |
100 } | |
93 } | 101 } |
94 | 102 |
95 NOTREACHED(); | 103 NOTREACHED(); |
96 return nullptr; | 104 return nullptr; |
97 } | 105 } |
98 | 106 |
99 void PaymentAppContentUnitTestBase::SetManifest( | 107 void PaymentAppContentUnitTestBase::SetManifest( |
100 PaymentAppManager* manager, | 108 PaymentAppManager* manager, |
101 const std::string& scope, | |
102 payments::mojom::PaymentAppManifestPtr manifest, | 109 payments::mojom::PaymentAppManifestPtr manifest, |
103 const PaymentAppManager::SetManifestCallback& callback) { | 110 const PaymentAppManager::SetManifestCallback& callback) { |
104 ASSERT_NE(nullptr, manager); | 111 ASSERT_NE(nullptr, manager); |
105 manager->SetManifest(scope, std::move(manifest), callback); | 112 manager->SetManifest(std::move(manifest), callback); |
106 base::RunLoop().RunUntilIdle(); | 113 base::RunLoop().RunUntilIdle(); |
107 } | 114 } |
108 | 115 |
109 void PaymentAppContentUnitTestBase::GetManifest( | 116 void PaymentAppContentUnitTestBase::GetManifest( |
110 PaymentAppManager* manager, | 117 PaymentAppManager* manager, |
111 const std::string& scope, | |
112 const PaymentAppManager::GetManifestCallback& callback) { | 118 const PaymentAppManager::GetManifestCallback& callback) { |
113 ASSERT_NE(nullptr, manager); | 119 ASSERT_NE(nullptr, manager); |
114 manager->GetManifest(scope, callback); | 120 manager->GetManifest(callback); |
115 base::RunLoop().RunUntilIdle(); | 121 base::RunLoop().RunUntilIdle(); |
116 } | 122 } |
117 | 123 |
124 void PaymentAppContentUnitTestBase::UnregisterServiceWorker( | |
125 const GURL& scope_url) { | |
126 // Unregister service worker. | |
127 bool called = false; | |
128 embedded_worker_helper_->context()->UnregisterServiceWorker( | |
129 scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called)); | |
130 base::RunLoop().RunUntilIdle(); | |
131 EXPECT_TRUE(called); | |
132 } | |
133 | |
118 } // namespace content | 134 } // namespace content |
OLD | NEW |