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 BluetoothDevice::ConnectionInfo conn_info) { | |
Ilya Sherman
2014/11/19 22:18:07
nit: Pass by const-reference?
Tim Song
2014/12/06 00:51:37
Done.
| |
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 3019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3175 | 3182 |
3176 // Unknown vendor specification identifier. | 3183 // Unknown vendor specification identifier. |
3177 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); | 3184 properties->modalias.ReplaceValue("chrome:v00E0p2400d0400"); |
3178 | 3185 |
3179 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); | 3186 EXPECT_EQ(BluetoothDevice::VENDOR_ID_UNKNOWN, device->GetVendorIDSource()); |
3180 EXPECT_EQ(0, device->GetVendorID()); | 3187 EXPECT_EQ(0, device->GetVendorID()); |
3181 EXPECT_EQ(0, device->GetProductID()); | 3188 EXPECT_EQ(0, device->GetProductID()); |
3182 EXPECT_EQ(0, device->GetDeviceID()); | 3189 EXPECT_EQ(0, device->GetDeviceID()); |
3183 } | 3190 } |
3184 | 3191 |
3192 TEST_F(BluetoothChromeOSTest, GetConnectionInfo) { | |
3193 GetAdapter(); | |
3194 BluetoothDevice* device = | |
3195 adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); | |
3196 | |
3197 // Calling GetConnectionInfo for an unconnected device should return a result | |
3198 // in which all fields are filled with BluetoothDevice::kUnknownPower. | |
3199 { | |
3200 BluetoothDevice::ConnectionInfo conn_info(0, 0, 0); | |
3201 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | |
3202 int unkown_power = BluetoothDevice::kUnknownPower; | |
Ilya Sherman
2014/11/19 22:18:07
nit: Please add an explicit check that the unknown
Ilya Sherman
2014/11/19 22:18:07
nit: "unkown" -> "unknown"
Tim Song
2014/12/06 00:51:37
Done.
Tim Song
2014/12/06 00:51:37
Done.
| |
3203 ASSERT_EQ(unkown_power, conn_info.rssi); | |
3204 ASSERT_EQ(unkown_power, conn_info.transmit_power); | |
3205 ASSERT_EQ(unkown_power, conn_info.max_transmit_power); | |
Ilya Sherman
2014/11/19 22:18:07
nit: s/ASSERT/EXPECT.
Tim Song
2014/12/06 00:51:37
Done.
| |
3206 } | |
3207 | |
3208 device->Connect(NULL, base::Bind(&BluetoothChromeOSTest::Callback, | |
3209 base::Unretained(this)), | |
3210 base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, | |
3211 base::Unretained(this))); | |
3212 ASSERT_TRUE(device->IsConnected()); | |
3213 | |
3214 // Calling GetConnectionInfo for an unconnected device should return valid | |
Ilya Sherman
2014/11/19 22:18:07
nit: "an unconnected" -> "a connected"
Tim Song
2014/12/06 00:51:37
Done.
| |
3215 // results. | |
3216 { | |
3217 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); | |
3218 BluetoothDevice::ConnectionInfo conn_info; | |
3219 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | |
3220 ASSERT_EQ(-10, conn_info.rssi); | |
3221 ASSERT_EQ(3, conn_info.transmit_power); | |
3222 ASSERT_EQ(4, conn_info.max_transmit_power); | |
Ilya Sherman
2014/11/19 22:18:07
nit: s/ASSERT/EXPECT.
Tim Song
2014/12/06 00:51:37
Done.
| |
3223 } | |
Ilya Sherman
2014/11/19 22:18:07
Optional nit: I'd write this as two separate tests
Tim Song
2014/12/06 00:51:37
Done.
| |
3224 } | |
3225 | |
3185 } // namespace chromeos | 3226 } // namespace chromeos |
OLD | NEW |