Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 // break out of those loops. | 136 // break out of those loops. |
| 137 void QuitMessageLoop() { | 137 void QuitMessageLoop() { |
| 138 if (base::MessageLoop::current() && | 138 if (base::MessageLoop::current() && |
| 139 base::MessageLoop::current()->is_running()) | 139 base::MessageLoop::current()->is_running()) |
| 140 base::MessageLoop::current()->Quit(); | 140 base::MessageLoop::current()->Quit(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 scoped_refptr<BluetoothAdapter> adapter_; | 143 scoped_refptr<BluetoothAdapter> adapter_; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 // Callback for BluetoothDevice::GetConnectionInfo() that simply saves the | |
| 147 // connection info to the bound argument. | |
| 148 void SaveConnectionInfo(BluetoothDevice::ConnectionInfo* out, | |
| 149 const BluetoothDevice::ConnectionInfo& conn_info) { | |
| 150 *out = conn_info; | |
| 151 }; | |
| 152 | |
| 146 } // namespace | 153 } // namespace |
| 147 | 154 |
| 148 class TestPairingDelegate : public BluetoothDevice::PairingDelegate { | 155 class TestPairingDelegate : public BluetoothDevice::PairingDelegate { |
| 149 public: | 156 public: |
| 150 TestPairingDelegate() | 157 TestPairingDelegate() |
| 151 : call_count_(0), | 158 : call_count_(0), |
| 152 request_pincode_count_(0), | 159 request_pincode_count_(0), |
| 153 request_passkey_count_(0), | 160 request_passkey_count_(0), |
| 154 display_pincode_count_(0), | 161 display_pincode_count_(0), |
| 155 display_passkey_count_(0), | 162 display_passkey_count_(0), |
| (...skipping 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3265 | 3272 |
| 3266 // Unknown vendor specification identifier. | 3273 // Unknown vendor specification identifier. |
| 3267 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); | 3274 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); |
| 3268 | 3275 |
| 3269 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); | 3276 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); |
| 3270 EXPECT_EQ(0, device->GetVendorID()); | 3277 EXPECT_EQ(0, device->GetVendorID()); |
| 3271 EXPECT_EQ(0, device->GetProductID()); | 3278 EXPECT_EQ(0, device->GetProductID()); |
| 3272 EXPECT_EQ(0, device->GetDeviceID()); | 3279 EXPECT_EQ(0, device->GetDeviceID()); |
| 3273 } | 3280 } |
| 3274 | 3281 |
| 3282 TEST_F(BluetoothChromeOSTest, GetConnectionInfoForDisconnectedDevice) { | |
| 3283 GetAdapter(); | |
| 3284 BluetoothDevice* device = | |
| 3285 adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); | |
| 3286 | |
| 3287 // Calling GetConnectionInfo for an unconnected device should return a result | |
| 3288 // in which all fields are filled with BluetoothDevice::kUnknownPower. | |
| 3289 BluetoothDevice::ConnectionInfo conn_info(0, 0, 0); | |
| 3290 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | |
| 3291 int unknown_power = BluetoothDevice::kUnknownPower; | |
| 3292 EXPECT_NE(0, unknown_power); | |
| 3293 EXPECT_EQ(unknown_power, conn_info.rssi); | |
| 3294 EXPECT_EQ(unknown_power, conn_info.transmit_power); | |
| 3295 EXPECT_EQ(unknown_power, conn_info.max_transmit_power); | |
| 3296 } | |
| 3297 | |
| 3298 TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { | |
| 3299 GetAdapter(); | |
| 3300 BluetoothDevice* device = | |
| 3301 adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); | |
| 3302 | |
| 3303 device->Connect(NULL, base::Bind(&BluetoothChromeOSTest::Callback, | |
|
armansito
2015/01/06 20:36:07
nit: Indentation, break the line after "NULL". I w
Tim Song
2015/01/06 22:30:51
The current formatting is from git cl format, but
| |
| 3304 base::Unretained(this)), | |
| 3305 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | |
| 3306 base::Unretained(this))); | |
| 3307 EXPECT_TRUE(device->IsConnected()); | |
| 3308 | |
| 3309 // Calling GetConnectionInfo for a connected device should return valid | |
| 3310 // results. | |
| 3311 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); | |
| 3312 BluetoothDevice::ConnectionInfo conn_info; | |
| 3313 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | |
| 3314 EXPECT_EQ(-10, conn_info.rssi); | |
| 3315 EXPECT_EQ(3, conn_info.transmit_power); | |
| 3316 EXPECT_EQ(4, conn_info.max_transmit_power); | |
| 3317 } | |
| 3318 | |
| 3275 } // namespace chromeos | 3319 } // namespace chromeos |
| OLD | NEW |