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 27 matching lines...) Expand all Loading... |
38 EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); | 38 EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); |
39 *called = true; | 39 *called = true; |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 PaymentAppContentUnitTestBase::PaymentAppContentUnitTestBase() | 44 PaymentAppContentUnitTestBase::PaymentAppContentUnitTestBase() |
45 : thread_bundle_( | 45 : thread_bundle_( |
46 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)), | 46 new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)), |
47 embedded_worker_helper_(new EmbeddedWorkerTestHelper(base::FilePath())), | 47 embedded_worker_helper_(new EmbeddedWorkerTestHelper(base::FilePath())), |
48 storage_partition_impl_( | 48 storage_partition_impl_(static_cast<StoragePartitionImpl*>( |
49 new StoragePartitionImpl( | 49 BrowserContext::GetDefaultStoragePartition(browser_context()))), |
50 embedded_worker_helper_->browser_context(), base::FilePath(), | 50 payment_app_context_(storage_partition_impl_->GetPaymentAppContext()) { |
51 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | |
52 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)), | |
53 payment_app_context_(new PaymentAppContextImpl()) { | |
54 embedded_worker_helper_->context_wrapper()->set_storage_partition( | 51 embedded_worker_helper_->context_wrapper()->set_storage_partition( |
55 storage_partition_impl_.get()); | 52 storage_partition_impl_); |
56 payment_app_context_->Init(embedded_worker_helper_->context_wrapper()); | 53 payment_app_context_->Init(embedded_worker_helper_->context_wrapper()); |
57 base::RunLoop().RunUntilIdle(); | 54 base::RunLoop().RunUntilIdle(); |
58 } | 55 } |
59 | 56 |
60 PaymentAppContentUnitTestBase::~PaymentAppContentUnitTestBase() { | 57 PaymentAppContentUnitTestBase::~PaymentAppContentUnitTestBase() {} |
61 payment_app_context_->Shutdown(); | 58 |
62 base::RunLoop().RunUntilIdle(); | 59 BrowserContext* PaymentAppContentUnitTestBase::browser_context() { |
| 60 DCHECK(embedded_worker_helper_); |
| 61 return embedded_worker_helper_->browser_context(); |
63 } | 62 } |
64 | 63 |
65 PaymentAppManager* PaymentAppContentUnitTestBase::CreatePaymentAppManager( | 64 PaymentAppManager* PaymentAppContentUnitTestBase::CreatePaymentAppManager( |
66 const GURL& scope_url, | 65 const GURL& scope_url, |
67 const GURL& sw_script_url) { | 66 const GURL& sw_script_url) { |
68 // Register service worker for payment app manager. | 67 // Register service worker for payment app manager. |
69 bool called = false; | 68 bool called = false; |
70 embedded_worker_helper_->context()->RegisterServiceWorker( | 69 embedded_worker_helper_->context()->RegisterServiceWorker( |
71 scope_url, sw_script_url, nullptr, | 70 scope_url, sw_script_url, nullptr, |
72 base::Bind(&RegisterServiceWorkerCallback, &called)); | 71 base::Bind(&RegisterServiceWorkerCallback, &called)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 const GURL& scope_url) { | 145 const GURL& scope_url) { |
147 // Unregister service worker. | 146 // Unregister service worker. |
148 bool called = false; | 147 bool called = false; |
149 embedded_worker_helper_->context()->UnregisterServiceWorker( | 148 embedded_worker_helper_->context()->UnregisterServiceWorker( |
150 scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called)); | 149 scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called)); |
151 base::RunLoop().RunUntilIdle(); | 150 base::RunLoop().RunUntilIdle(); |
152 EXPECT_TRUE(called); | 151 EXPECT_TRUE(called); |
153 } | 152 } |
154 | 153 |
155 } // namespace content | 154 } // namespace content |
OLD | NEW |