Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1076)

Side by Side Diff: content/browser/payments/payment_app_content_unittest_base.cc

Issue 2586203003: PaymentApp: Remove scope_url parameter from Get/SetManifest methods. (Closed)
Patch Set: rebased Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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());
99 base::RunLoop().RunUntilIdle();
92 return candidate_manager.first; 100 return candidate_manager.first;
101 }
93 } 102 }
94 103
95 NOTREACHED(); 104 NOTREACHED();
96 return nullptr; 105 return nullptr;
97 } 106 }
98 107
99 void PaymentAppContentUnitTestBase::SetManifest( 108 void PaymentAppContentUnitTestBase::SetManifest(
100 PaymentAppManager* manager, 109 PaymentAppManager* manager,
101 const std::string& scope,
102 payments::mojom::PaymentAppManifestPtr manifest, 110 payments::mojom::PaymentAppManifestPtr manifest,
103 const PaymentAppManager::SetManifestCallback& callback) { 111 const PaymentAppManager::SetManifestCallback& callback) {
104 ASSERT_NE(nullptr, manager); 112 ASSERT_NE(nullptr, manager);
105 manager->SetManifest(scope, std::move(manifest), callback); 113 manager->SetManifest(std::move(manifest), callback);
106 base::RunLoop().RunUntilIdle(); 114 base::RunLoop().RunUntilIdle();
107 } 115 }
108 116
109 void PaymentAppContentUnitTestBase::GetManifest( 117 void PaymentAppContentUnitTestBase::GetManifest(
110 PaymentAppManager* manager, 118 PaymentAppManager* manager,
111 const std::string& scope,
112 const PaymentAppManager::GetManifestCallback& callback) { 119 const PaymentAppManager::GetManifestCallback& callback) {
113 ASSERT_NE(nullptr, manager); 120 ASSERT_NE(nullptr, manager);
114 manager->GetManifest(scope, callback); 121 manager->GetManifest(callback);
115 base::RunLoop().RunUntilIdle(); 122 base::RunLoop().RunUntilIdle();
116 } 123 }
117 124
118 payments::mojom::PaymentAppManifestPtr 125 payments::mojom::PaymentAppManifestPtr
119 PaymentAppContentUnitTestBase::CreatePaymentAppManifestForTest( 126 PaymentAppContentUnitTestBase::CreatePaymentAppManifestForTest(
120 const std::string& name) { 127 const std::string& name) {
121 payments::mojom::PaymentAppOptionPtr option = 128 payments::mojom::PaymentAppOptionPtr option =
122 payments::mojom::PaymentAppOption::New(); 129 payments::mojom::PaymentAppOption::New();
123 option->name = "Visa ****"; 130 option->name = "Visa ****";
124 option->id = "payment-app-id"; 131 option->id = "payment-app-id";
125 option->icon = std::string("payment-app-icon"); 132 option->icon = std::string("payment-app-icon");
126 option->enabled_methods.push_back("visa"); 133 option->enabled_methods.push_back("visa");
127 134
128 payments::mojom::PaymentAppManifestPtr manifest = 135 payments::mojom::PaymentAppManifestPtr manifest =
129 payments::mojom::PaymentAppManifest::New(); 136 payments::mojom::PaymentAppManifest::New();
130 manifest->icon = std::string("payment-app-icon"); 137 manifest->icon = std::string("payment-app-icon");
131 manifest->name = name; 138 manifest->name = name;
132 manifest->options.push_back(std::move(option)); 139 manifest->options.push_back(std::move(option));
133 140
134 return manifest; 141 return manifest;
135 } 142 }
136 143
144 void PaymentAppContentUnitTestBase::UnregisterServiceWorker(
145 const GURL& scope_url) {
146 // Unregister service worker.
147 bool called = false;
148 embedded_worker_helper_->context()->UnregisterServiceWorker(
149 scope_url, base::Bind(&UnregisterServiceWorkerCallback, &called));
150 base::RunLoop().RunUntilIdle();
151 EXPECT_TRUE(called);
152 }
153
137 } // namespace content 154 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698