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

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

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChromeOS Full build. Created 6 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" 6 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
7 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" 7 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
8 #include "chromeos/dbus/fake_bluetooth_device_client.h" 8 #include "chromeos/dbus/fake_bluetooth_device_client.h"
9 #include "chromeos/dbus/fake_bluetooth_input_client.h" 9 #include "chromeos/dbus/fake_bluetooth_input_client.h"
10 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" 10 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 void Callback() { 85 void Callback() {
86 ++callback_count_; 86 ++callback_count_;
87 } 87 }
88 88
89 void ErrorCallback() { 89 void ErrorCallback() {
90 ++error_callback_count_; 90 ++error_callback_count_;
91 91
92 message_loop_.Quit(); 92 message_loop_.Quit();
93 } 93 }
94 94
95 void ConnectToProfileErrorCallback(const std::string& error) {
96 ErrorCallback();
97 }
98
95 void ProfileCallback(BluetoothProfile* profile) { 99 void ProfileCallback(BluetoothProfile* profile) {
96 ++profile_callback_count_; 100 ++profile_callback_count_;
97 last_profile_ = profile; 101 last_profile_ = profile;
98 } 102 }
99 103
100 void ConnectionCallback(const BluetoothDevice *device, 104 void ConnectionCallback(const BluetoothDevice *device,
101 scoped_refptr<BluetoothSocket> socket) { 105 scoped_refptr<BluetoothSocket> socket) {
102 ++connection_callback_count_; 106 ++connection_callback_count_;
103 last_device_ = device; 107 last_device_ = device;
104 last_socket_ = socket; 108 last_socket_ = socket;
(...skipping 10 matching lines...) Expand all
115 unsigned int callback_count_; 119 unsigned int callback_count_;
116 unsigned int error_callback_count_; 120 unsigned int error_callback_count_;
117 unsigned int profile_callback_count_; 121 unsigned int profile_callback_count_;
118 unsigned int connection_callback_count_; 122 unsigned int connection_callback_count_;
119 BluetoothProfile* last_profile_; 123 BluetoothProfile* last_profile_;
120 const BluetoothDevice* last_device_; 124 const BluetoothDevice* last_device_;
121 scoped_refptr<BluetoothSocket> last_socket_; 125 scoped_refptr<BluetoothSocket> last_socket_;
122 }; 126 };
123 127
124 TEST_F(BluetoothProfileChromeOSTest, L2capEndToEnd) { 128 TEST_F(BluetoothProfileChromeOSTest, L2capEndToEnd) {
129 // TODO(rpaquay): Implement this test once the ChromeOS implementation of
130 // BluetoothSocket is done.
131 #if 0
125 // Register the profile and expect the profile object to be passed to the 132 // Register the profile and expect the profile object to be passed to the
126 // callback. 133 // callback.
127 BluetoothProfile::Options options; 134 BluetoothProfile::Options options;
128 BluetoothProfile::Register( 135 BluetoothProfile::Register(
129 BluetoothUUID(FakeBluetoothProfileManagerClient::kL2capUuid), 136 BluetoothUUID(FakeBluetoothProfileManagerClient::kL2capUuid),
130 options, 137 options,
131 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback, 138 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback,
132 base::Unretained(this))); 139 base::Unretained(this)));
133 140
134 EXPECT_EQ(1U, profile_callback_count_); 141 EXPECT_EQ(1U, profile_callback_count_);
(...skipping 15 matching lines...) Expand all
150 // connection callback to be called with the device we passed and a new 157 // connection callback to be called with the device we passed and a new
151 // socket instance. 158 // socket instance.
152 BluetoothDevice* device = adapter_->GetDevice( 159 BluetoothDevice* device = adapter_->GetDevice(
153 FakeBluetoothDeviceClient::kPairedDeviceAddress); 160 FakeBluetoothDeviceClient::kPairedDeviceAddress);
154 ASSERT_TRUE(device != NULL); 161 ASSERT_TRUE(device != NULL);
155 162
156 device->ConnectToProfile( 163 device->ConnectToProfile(
157 profile, 164 profile,
158 base::Bind(&BluetoothProfileChromeOSTest::Callback, 165 base::Bind(&BluetoothProfileChromeOSTest::Callback,
159 base::Unretained(this)), 166 base::Unretained(this)),
160 base::Bind(&BluetoothProfileChromeOSTest::ErrorCallback, 167 base::Bind(&BluetoothProfileChromeOSTest::ConnectToProfileErrorCallback,
161 base::Unretained(this))); 168 base::Unretained(this)));
162 169
163 message_loop_.Run(); 170 message_loop_.Run();
164 171
165 EXPECT_EQ(1U, callback_count_); 172 EXPECT_EQ(1U, callback_count_);
166 EXPECT_EQ(0U, error_callback_count_); 173 EXPECT_EQ(0U, error_callback_count_);
167 174
168 EXPECT_EQ(1U, connection_callback_count_); 175 EXPECT_EQ(1U, connection_callback_count_);
169 EXPECT_EQ(device, last_device_); 176 EXPECT_EQ(device, last_device_);
170 EXPECT_TRUE(last_socket_.get() != NULL); 177 EXPECT_TRUE(last_socket_.get() != NULL);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // Close our end of the socket. 245 // Close our end of the socket.
239 socket = NULL; 246 socket = NULL;
240 247
241 // Unregister the profile, make sure it's no longer registered. 248 // Unregister the profile, make sure it's no longer registered.
242 last_profile_->Unregister(); 249 last_profile_->Unregister();
243 250
244 profile_service_provider = 251 profile_service_provider =
245 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( 252 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider(
246 FakeBluetoothProfileManagerClient::kL2capUuid); 253 FakeBluetoothProfileManagerClient::kL2capUuid);
247 EXPECT_TRUE(profile_service_provider == NULL); 254 EXPECT_TRUE(profile_service_provider == NULL);
255 #endif
248 } 256 }
249 257
250 TEST_F(BluetoothProfileChromeOSTest, RfcommEndToEnd) { 258 TEST_F(BluetoothProfileChromeOSTest, RfcommEndToEnd) {
259 // TODO(rpaquay): Implement this test once the ChromeOS implementation of
260 // BluetoothSocket is done.
261 #if 0
251 // Register the profile and expect the profile object to be passed to the 262 // Register the profile and expect the profile object to be passed to the
252 // callback. 263 // callback.
253 BluetoothProfile::Options options; 264 BluetoothProfile::Options options;
254 BluetoothProfile::Register( 265 BluetoothProfile::Register(
255 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), 266 BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid),
256 options, 267 options,
257 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback, 268 base::Bind(&BluetoothProfileChromeOSTest::ProfileCallback,
258 base::Unretained(this))); 269 base::Unretained(this)));
259 270
260 EXPECT_EQ(1U, profile_callback_count_); 271 EXPECT_EQ(1U, profile_callback_count_);
(...skipping 15 matching lines...) Expand all
276 // connection callback to be called with the device we passed and a new 287 // connection callback to be called with the device we passed and a new
277 // socket instance. 288 // socket instance.
278 BluetoothDevice* device = adapter_->GetDevice( 289 BluetoothDevice* device = adapter_->GetDevice(
279 FakeBluetoothDeviceClient::kPairedDeviceAddress); 290 FakeBluetoothDeviceClient::kPairedDeviceAddress);
280 ASSERT_TRUE(device != NULL); 291 ASSERT_TRUE(device != NULL);
281 292
282 device->ConnectToProfile( 293 device->ConnectToProfile(
283 profile, 294 profile,
284 base::Bind(&BluetoothProfileChromeOSTest::Callback, 295 base::Bind(&BluetoothProfileChromeOSTest::Callback,
285 base::Unretained(this)), 296 base::Unretained(this)),
286 base::Bind(&BluetoothProfileChromeOSTest::ErrorCallback, 297 base::Bind(&BluetoothProfileChromeOSTest::ConnectToProfileErrorCallback,
287 base::Unretained(this))); 298 base::Unretained(this)));
288 299
289 message_loop_.Run(); 300 message_loop_.Run();
290 301
291 EXPECT_EQ(1U, callback_count_); 302 EXPECT_EQ(1U, callback_count_);
292 EXPECT_EQ(0U, error_callback_count_); 303 EXPECT_EQ(0U, error_callback_count_);
293 304
294 EXPECT_EQ(1U, connection_callback_count_); 305 EXPECT_EQ(1U, connection_callback_count_);
295 EXPECT_EQ(device, last_device_); 306 EXPECT_EQ(device, last_device_);
296 EXPECT_TRUE(last_socket_.get() != NULL); 307 EXPECT_TRUE(last_socket_.get() != NULL);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // Close our end of the socket. 373 // Close our end of the socket.
363 socket = NULL; 374 socket = NULL;
364 375
365 // Unregister the profile, make sure it's no longer registered. 376 // Unregister the profile, make sure it's no longer registered.
366 last_profile_->Unregister(); 377 last_profile_->Unregister();
367 378
368 profile_service_provider = 379 profile_service_provider =
369 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider( 380 fake_bluetooth_profile_manager_client_->GetProfileServiceProvider(
370 FakeBluetoothProfileManagerClient::kRfcommUuid); 381 FakeBluetoothProfileManagerClient::kRfcommUuid);
371 EXPECT_TRUE(profile_service_provider == NULL); 382 EXPECT_TRUE(profile_service_provider == NULL);
383 #endif
372 } 384 }
373 385
374 } // namespace chromeos 386 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_win_unittest.cc ('k') | device/bluetooth/bluetooth_profile_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698