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

Side by Side Diff: device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc

Issue 935383003: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: further fix ownership, address comments Created 5 years, 10 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "chromeos/dbus/bluetooth_profile_service_provider.h" 7 #include "chromeos/dbus/bluetooth_profile_service_provider.h"
8 #include "chromeos/dbus/dbus_thread_manager.h" 8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" 10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 unsigned int error_callback_count_; 144 unsigned int error_callback_count_;
145 }; 145 };
146 146
147 TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { 147 TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) {
148 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); 148 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid);
149 BluetoothProfileManagerClient::Options options; 149 BluetoothProfileManagerClient::Options options;
150 150
151 options.require_authentication.reset(new bool(false)); 151 options.require_authentication.reset(new bool(false));
152 152
153 profile_ = BluetoothAdapterProfileChromeOS::Register( 153 profile_ = BluetoothAdapterProfileChromeOS::Register(
154 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, 154 uuid, options, base::Bind(&base::DoNothing),
155 base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback)); 155 base::Bind(&DoNothingDBusErrorCallback));
156 156
157 message_loop_.RunUntilIdle(); 157 message_loop_.RunUntilIdle();
158 158
159 EXPECT_TRUE(profile_); 159 EXPECT_TRUE(profile_);
160 160
161 EXPECT_EQ(0U, profile_->DelegateCount()); 161 EXPECT_EQ(0U, profile_->DelegateCount());
162 162
163 profile_->SetDelegate(fake_delegate_paired_.device_path_, 163 profile_->SetDelegate(fake_delegate_paired_.device_path_,
164 &fake_delegate_paired_); 164 &fake_delegate_paired_);
165 165
(...skipping 12 matching lines...) Expand all
178 delete profile_; 178 delete profile_;
179 }; 179 };
180 180
181 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { 181 TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) {
182 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); 182 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid);
183 BluetoothProfileManagerClient::Options options; 183 BluetoothProfileManagerClient::Options options;
184 184
185 options.require_authentication.reset(new bool(false)); 185 options.require_authentication.reset(new bool(false));
186 186
187 profile_ = BluetoothAdapterProfileChromeOS::Register( 187 profile_ = BluetoothAdapterProfileChromeOS::Register(
188 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, 188 uuid, options,
189 base::Bind( 189 base::Bind(
190 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, 190 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback,
191 base::Unretained(this)), 191 base::Unretained(this)),
192 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, 192 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback,
193 base::Unretained(this))); 193 base::Unretained(this)));
194 194
195 message_loop_.RunUntilIdle(); 195 message_loop_.RunUntilIdle();
196 196
197 EXPECT_TRUE(profile_); 197 EXPECT_TRUE(profile_);
198 EXPECT_EQ(1U, success_callback_count_); 198 EXPECT_EQ(1U, success_callback_count_);
(...skipping 18 matching lines...) Expand all
217 delete profile_; 217 delete profile_;
218 }; 218 };
219 219
220 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { 220 TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) {
221 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); 221 BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid);
222 BluetoothProfileManagerClient::Options options; 222 BluetoothProfileManagerClient::Options options;
223 223
224 options.require_authentication.reset(new bool(false)); 224 options.require_authentication.reset(new bool(false));
225 225
226 profile_ = BluetoothAdapterProfileChromeOS::Register( 226 profile_ = BluetoothAdapterProfileChromeOS::Register(
227 static_cast<BluetoothAdapterChromeOS*>(adapter_.get()), uuid, options, 227 uuid, options,
228 base::Bind( 228 base::Bind(
229 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, 229 &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback,
230 base::Unretained(this)), 230 base::Unretained(this)),
231 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, 231 base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback,
232 base::Unretained(this))); 232 base::Unretained(this)));
233 233
234 message_loop_.RunUntilIdle(); 234 message_loop_.RunUntilIdle();
235 235
236 ASSERT_TRUE(profile_); 236 ASSERT_TRUE(profile_);
237 237
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 EXPECT_EQ(4U, success_callback_count_); 289 EXPECT_EQ(4U, success_callback_count_);
290 EXPECT_EQ(0U, error_callback_count_); 290 EXPECT_EQ(0U, error_callback_count_);
291 291
292 EXPECT_EQ(1U, fake_delegate_listen_.connections_); 292 EXPECT_EQ(1U, fake_delegate_listen_.connections_);
293 293
294 delete profile_; 294 delete profile_;
295 }; 295 };
296 296
297 } // namespace chromeos 297 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698