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

Side by Side Diff: content/browser/background_sync/background_sync_service_impl_unittest.cc

Issue 2851173004: Eliminate bind callback that doesn't take a BindSourceInfo parameter. (Closed)
Patch Set: . Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/background_sync/background_sync_service_impl.h" 5 #include "content/browser/background_sync/background_sync_service_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "content/browser/background_sync/background_sync_context.h" 15 #include "content/browser/background_sync/background_sync_context.h"
16 #include "content/browser/background_sync/background_sync_network_observer.h" 16 #include "content/browser/background_sync/background_sync_network_observer.h"
17 #include "content/browser/service_worker/embedded_worker_test_helper.h" 17 #include "content/browser/service_worker/embedded_worker_test_helper.h"
18 #include "content/browser/service_worker/service_worker_context_wrapper.h" 18 #include "content/browser/service_worker/service_worker_context_wrapper.h"
19 #include "content/browser/storage_partition_impl.h" 19 #include "content/browser/storage_partition_impl.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/permission_type.h" 21 #include "content/public/browser/permission_type.h"
22 #include "content/public/test/background_sync_test_util.h" 22 #include "content/public/test/background_sync_test_util.h"
23 #include "content/public/test/test_browser_context.h" 23 #include "content/public/test/test_browser_context.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
25 #include "content/test/mock_permission_manager.h" 25 #include "content/test/mock_permission_manager.h"
26 #include "content/test/test_background_sync_context.h" 26 #include "content/test/test_background_sync_context.h"
27 #include "mojo/public/cpp/bindings/interface_ptr.h" 27 #include "mojo/public/cpp/bindings/interface_ptr.h"
28 #include "net/base/network_change_notifier.h" 28 #include "net/base/network_change_notifier.h"
29 #include "services/service_manager/public/cpp/bind_source_info.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 31
31 namespace content { 32 namespace content {
32 33
33 namespace { 34 namespace {
34 35
35 using ::testing::_; 36 using ::testing::_;
36 37
37 const char kServiceWorkerPattern[] = "https://example.com/a"; 38 const char kServiceWorkerPattern[] = "https://example.com/a";
38 const char kServiceWorkerScript[] = "https://example.com/a/script.js"; 39 const char kServiceWorkerScript[] = "https://example.com/a/script.js";
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 base::RunLoop().RunUntilIdle(); 175 base::RunLoop().RunUntilIdle();
175 EXPECT_TRUE(sw_registration_); 176 EXPECT_TRUE(sw_registration_);
176 } 177 }
177 178
178 void CreateBackgroundSyncServiceImpl() { 179 void CreateBackgroundSyncServiceImpl() {
179 // Create a dummy mojo channel so that the BackgroundSyncServiceImpl can be 180 // Create a dummy mojo channel so that the BackgroundSyncServiceImpl can be
180 // instantiated. 181 // instantiated.
181 mojo::InterfaceRequest<blink::mojom::BackgroundSyncService> 182 mojo::InterfaceRequest<blink::mojom::BackgroundSyncService>
182 service_request = mojo::MakeRequest(&service_ptr_); 183 service_request = mojo::MakeRequest(&service_ptr_);
183 // Create a new BackgroundSyncServiceImpl bound to the dummy channel. 184 // Create a new BackgroundSyncServiceImpl bound to the dummy channel.
184 background_sync_context_->CreateService(std::move(service_request)); 185 background_sync_context_->CreateService(service_manager::BindSourceInfo(),
186 std::move(service_request));
185 base::RunLoop().RunUntilIdle(); 187 base::RunLoop().RunUntilIdle();
186 188
187 service_impl_ = background_sync_context_->services_.begin()->first; 189 service_impl_ = background_sync_context_->services_.begin()->first;
188 ASSERT_TRUE(service_impl_); 190 ASSERT_TRUE(service_impl_);
189 } 191 }
190 192
191 // Helpers for testing BackgroundSyncServiceImpl methods 193 // Helpers for testing BackgroundSyncServiceImpl methods
192 void Register( 194 void Register(
193 blink::mojom::SyncRegistrationPtr sync, 195 blink::mojom::SyncRegistrationPtr sync,
194 const blink::mojom::BackgroundSyncService::RegisterCallback& callback) { 196 const blink::mojom::BackgroundSyncService::RegisterCallback& callback) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 EXPECT_EQ(blink::mojom::BackgroundSyncError::NONE, register_error); 256 EXPECT_EQ(blink::mojom::BackgroundSyncError::NONE, register_error);
255 GetRegistrations(base::Bind(&ErrorAndRegistrationListCallback, 257 GetRegistrations(base::Bind(&ErrorAndRegistrationListCallback,
256 &getregistrations_called, &getregistrations_error, 258 &getregistrations_called, &getregistrations_error,
257 &array_size)); 259 &array_size));
258 EXPECT_TRUE(getregistrations_called); 260 EXPECT_TRUE(getregistrations_called);
259 EXPECT_EQ(blink::mojom::BackgroundSyncError::NONE, getregistrations_error); 261 EXPECT_EQ(blink::mojom::BackgroundSyncError::NONE, getregistrations_error);
260 EXPECT_EQ(1UL, array_size); 262 EXPECT_EQ(1UL, array_size);
261 } 263 }
262 264
263 } // namespace content 265 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698