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

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

Issue 14048007: Bluetooth: D-Bus client interface for org.bluez.Input1 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fake device simulates the input Created 7 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chromeos/chromeos_switches.h" 8 #include "chromeos/chromeos_switches.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_device_client.h" 10 #include "chromeos/dbus/fake_bluetooth_device_client.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 ASSERT_EQ(1U, devices.size()); 735 ASSERT_EQ(1U, devices.size());
736 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, 736 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress,
737 devices[0]->GetAddress()); 737 devices[0]->GetAddress());
738 738
739 // Verify the other device properties. 739 // Verify the other device properties.
740 EXPECT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), 740 EXPECT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName),
741 devices[0]->GetName()); 741 devices[0]->GetName());
742 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType()); 742 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType());
743 EXPECT_TRUE(devices[0]->IsPaired()); 743 EXPECT_TRUE(devices[0]->IsPaired());
744 EXPECT_FALSE(devices[0]->IsConnected()); 744 EXPECT_FALSE(devices[0]->IsConnected());
745 EXPECT_FALSE(devices[0]->IsConnectable());
746 EXPECT_FALSE(devices[0]->IsConnecting()); 745 EXPECT_FALSE(devices[0]->IsConnecting());
747 746
747 // Non HID devices are always connectable.
748 EXPECT_TRUE(devices[0]->IsConnectable());
749
748 BluetoothDevice::ServiceList uuids = devices[0]->GetServices(); 750 BluetoothDevice::ServiceList uuids = devices[0]->GetServices();
749 ASSERT_EQ(2U, uuids.size()); 751 ASSERT_EQ(2U, uuids.size());
750 EXPECT_EQ(uuids[0], "00001800-0000-1000-8000-00805f9b34fb"); 752 EXPECT_EQ(uuids[0], "00001800-0000-1000-8000-00805f9b34fb");
751 EXPECT_EQ(uuids[1], "00001801-0000-1000-8000-00805f9b34fb"); 753 EXPECT_EQ(uuids[1], "00001801-0000-1000-8000-00805f9b34fb");
752 } 754 }
753 755
754 TEST_F(BluetoothExperimentalChromeOSTest, DeviceClassChanged) { 756 TEST_F(BluetoothExperimentalChromeOSTest, DeviceClassChanged) {
755 // Simulate a change of class of a device, as sometimes occurs 757 // Simulate a change of class of a device, as sometimes occurs
756 // during discovery. 758 // during discovery.
757 GetAdapter(); 759 GetAdapter();
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 1122
1121 // One change for connected, and one for paired. 1123 // One change for connected, and one for paired.
1122 EXPECT_EQ(2, observer.device_changed_count_); 1124 EXPECT_EQ(2, observer.device_changed_count_);
1123 EXPECT_EQ(device, observer.last_device_); 1125 EXPECT_EQ(device, observer.last_device_);
1124 1126
1125 EXPECT_TRUE(device->IsConnected()); 1127 EXPECT_TRUE(device->IsConnected());
1126 EXPECT_FALSE(device->IsConnecting()); 1128 EXPECT_FALSE(device->IsConnecting());
1127 1129
1128 EXPECT_TRUE(device->IsPaired()); 1130 EXPECT_TRUE(device->IsPaired());
1129 1131
1132 // Verify is a HID device and is connectable.
1133 BluetoothDevice::ServiceList uuids = device->GetServices();
1134 ASSERT_EQ(1U, uuids.size());
1135 ASSERT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb");
1136 EXPECT_TRUE(device->IsConnectable());
1137
1130 // Pairing dialog should be dismissed 1138 // Pairing dialog should be dismissed
1131 EXPECT_EQ(1, pairing_delegate.call_count_); 1139 EXPECT_EQ(1, pairing_delegate.call_count_);
1132 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1140 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1133 1141
1134 // Make sure the trusted property has been set to true. 1142 // Make sure the trusted property has been set to true.
1135 FakeBluetoothDeviceClient::Properties* properties = 1143 FakeBluetoothDeviceClient::Properties* properties =
1136 fake_bluetooth_device_client_->GetProperties( 1144 fake_bluetooth_device_client_->GetProperties(
1137 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleMousePath)); 1145 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleMousePath));
1138 EXPECT_TRUE(properties->trusted.value()); 1146 EXPECT_TRUE(properties->trusted.value());
1139 } 1147 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 1183
1176 // One change for connected, and one for paired. 1184 // One change for connected, and one for paired.
1177 EXPECT_EQ(2, observer.device_changed_count_); 1185 EXPECT_EQ(2, observer.device_changed_count_);
1178 EXPECT_EQ(device, observer.last_device_); 1186 EXPECT_EQ(device, observer.last_device_);
1179 1187
1180 EXPECT_TRUE(device->IsConnected()); 1188 EXPECT_TRUE(device->IsConnected());
1181 EXPECT_FALSE(device->IsConnecting()); 1189 EXPECT_FALSE(device->IsConnecting());
1182 1190
1183 EXPECT_TRUE(device->IsPaired()); 1191 EXPECT_TRUE(device->IsPaired());
1184 1192
1193 // Verify is a HID device and is connectable.
1194 BluetoothDevice::ServiceList uuids = device->GetServices();
1195 ASSERT_EQ(1U, uuids.size());
1196 ASSERT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb");
1197 EXPECT_TRUE(device->IsConnectable());
1198
1185 // Pairing dialog should be dismissed 1199 // Pairing dialog should be dismissed
1186 EXPECT_EQ(2, pairing_delegate.call_count_); 1200 EXPECT_EQ(2, pairing_delegate.call_count_);
1187 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1201 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1188 1202
1189 // Make sure the trusted property has been set to true. 1203 // Make sure the trusted property has been set to true.
1190 FakeBluetoothDeviceClient::Properties* properties = 1204 FakeBluetoothDeviceClient::Properties* properties =
1191 fake_bluetooth_device_client_->GetProperties( 1205 fake_bluetooth_device_client_->GetProperties(
1192 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleKeyboardPath)); 1206 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleKeyboardPath));
1193 EXPECT_TRUE(properties->trusted.value()); 1207 EXPECT_TRUE(properties->trusted.value());
1194 } 1208 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1246
1233 // One change for connected, and one for paired. 1247 // One change for connected, and one for paired.
1234 EXPECT_EQ(2, observer.device_changed_count_); 1248 EXPECT_EQ(2, observer.device_changed_count_);
1235 EXPECT_EQ(device, observer.last_device_); 1249 EXPECT_EQ(device, observer.last_device_);
1236 1250
1237 EXPECT_TRUE(device->IsConnected()); 1251 EXPECT_TRUE(device->IsConnected());
1238 EXPECT_FALSE(device->IsConnecting()); 1252 EXPECT_FALSE(device->IsConnecting());
1239 1253
1240 EXPECT_TRUE(device->IsPaired()); 1254 EXPECT_TRUE(device->IsPaired());
1241 1255
1256 // Verify is a HID device.
1257 BluetoothDevice::ServiceList uuids = device->GetServices();
1258 ASSERT_EQ(1U, uuids.size());
1259 ASSERT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb");
1260
1261 // Fake MotorolaKeyboard is not connectable.
1262 EXPECT_FALSE(device->IsConnectable());
1263
1242 // Pairing dialog should be dismissed 1264 // Pairing dialog should be dismissed
1243 EXPECT_EQ(2, pairing_delegate.call_count_); 1265 EXPECT_EQ(2, pairing_delegate.call_count_);
1244 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1266 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1245 1267
1246 // Make sure the trusted property has been set to true. 1268 // Make sure the trusted property has been set to true.
1247 FakeBluetoothDeviceClient::Properties* properties = 1269 FakeBluetoothDeviceClient::Properties* properties =
1248 fake_bluetooth_device_client_->GetProperties( 1270 fake_bluetooth_device_client_->GetProperties(
1249 dbus::ObjectPath(FakeBluetoothDeviceClient::kMotorolaKeyboardPath)); 1271 dbus::ObjectPath(FakeBluetoothDeviceClient::kMotorolaKeyboardPath));
1250 EXPECT_TRUE(properties->trusted.value()); 1272 EXPECT_TRUE(properties->trusted.value());
1251 } 1273 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 1309
1288 // One change for connected, and one for paired. 1310 // One change for connected, and one for paired.
1289 EXPECT_EQ(2, observer.device_changed_count_); 1311 EXPECT_EQ(2, observer.device_changed_count_);
1290 EXPECT_EQ(device, observer.last_device_); 1312 EXPECT_EQ(device, observer.last_device_);
1291 1313
1292 EXPECT_TRUE(device->IsConnected()); 1314 EXPECT_TRUE(device->IsConnected());
1293 EXPECT_FALSE(device->IsConnecting()); 1315 EXPECT_FALSE(device->IsConnecting());
1294 1316
1295 EXPECT_TRUE(device->IsPaired()); 1317 EXPECT_TRUE(device->IsPaired());
1296 1318
1319 // Verify is not a HID device.
1320 BluetoothDevice::ServiceList uuids = device->GetServices();
1321 ASSERT_EQ(0U, uuids.size());
1322
1323 // Non HID devices are always connectable.
1324 EXPECT_TRUE(device->IsConnectable());
1325
1297 // Pairing dialog should be dismissed 1326 // Pairing dialog should be dismissed
1298 EXPECT_EQ(2, pairing_delegate.call_count_); 1327 EXPECT_EQ(2, pairing_delegate.call_count_);
1299 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1328 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1300 1329
1301 // Make sure the trusted property has been set to true. 1330 // Make sure the trusted property has been set to true.
1302 FakeBluetoothDeviceClient::Properties* properties = 1331 FakeBluetoothDeviceClient::Properties* properties =
1303 fake_bluetooth_device_client_->GetProperties( 1332 fake_bluetooth_device_client_->GetProperties(
1304 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath)); 1333 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath));
1305 EXPECT_TRUE(properties->trusted.value()); 1334 EXPECT_TRUE(properties->trusted.value());
1306 } 1335 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 1372
1344 // One change for connected, and one for paired. 1373 // One change for connected, and one for paired.
1345 EXPECT_EQ(2, observer.device_changed_count_); 1374 EXPECT_EQ(2, observer.device_changed_count_);
1346 EXPECT_EQ(device, observer.last_device_); 1375 EXPECT_EQ(device, observer.last_device_);
1347 1376
1348 EXPECT_TRUE(device->IsConnected()); 1377 EXPECT_TRUE(device->IsConnected());
1349 EXPECT_FALSE(device->IsConnecting()); 1378 EXPECT_FALSE(device->IsConnecting());
1350 1379
1351 EXPECT_TRUE(device->IsPaired()); 1380 EXPECT_TRUE(device->IsPaired());
1352 1381
1382 // Non HID devices are always connectable.
1383 EXPECT_TRUE(device->IsConnectable());
1384
1353 // Pairing dialog should be dismissed 1385 // Pairing dialog should be dismissed
1354 EXPECT_EQ(2, pairing_delegate.call_count_); 1386 EXPECT_EQ(2, pairing_delegate.call_count_);
1355 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1387 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1356 1388
1357 // Make sure the trusted property has been set to true. 1389 // Make sure the trusted property has been set to true.
1358 FakeBluetoothDeviceClient::Properties* properties = 1390 FakeBluetoothDeviceClient::Properties* properties =
1359 fake_bluetooth_device_client_->GetProperties( 1391 fake_bluetooth_device_client_->GetProperties(
1360 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath)); 1392 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath));
1361 EXPECT_TRUE(properties->trusted.value()); 1393 EXPECT_TRUE(properties->trusted.value());
1362 } 1394 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 1432
1401 // One change for connected, and one for paired. 1433 // One change for connected, and one for paired.
1402 EXPECT_EQ(2, observer.device_changed_count_); 1434 EXPECT_EQ(2, observer.device_changed_count_);
1403 EXPECT_EQ(device, observer.last_device_); 1435 EXPECT_EQ(device, observer.last_device_);
1404 1436
1405 EXPECT_TRUE(device->IsConnected()); 1437 EXPECT_TRUE(device->IsConnected());
1406 EXPECT_FALSE(device->IsConnecting()); 1438 EXPECT_FALSE(device->IsConnecting());
1407 1439
1408 EXPECT_TRUE(device->IsPaired()); 1440 EXPECT_TRUE(device->IsPaired());
1409 1441
1442 // Non HID devices are always connectable.
1443 EXPECT_TRUE(device->IsConnectable());
1444
1410 // Pairing dialog should be dismissed 1445 // Pairing dialog should be dismissed
1411 EXPECT_EQ(2, pairing_delegate.call_count_); 1446 EXPECT_EQ(2, pairing_delegate.call_count_);
1412 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1447 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1413 1448
1414 // Make sure the trusted property has been set to true. 1449 // Make sure the trusted property has been set to true.
1415 FakeBluetoothDeviceClient::Properties* properties = 1450 FakeBluetoothDeviceClient::Properties* properties =
1416 fake_bluetooth_device_client_->GetProperties( 1451 fake_bluetooth_device_client_->GetProperties(
1417 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); 1452 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath));
1418 EXPECT_TRUE(properties->trusted.value()); 1453 EXPECT_TRUE(properties->trusted.value());
1419 } 1454 }
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 EXPECT_FALSE(device->IsConnected()); 1874 EXPECT_FALSE(device->IsConnected());
1840 EXPECT_FALSE(device->IsConnecting()); 1875 EXPECT_FALSE(device->IsConnecting());
1841 EXPECT_FALSE(device->IsPaired()); 1876 EXPECT_FALSE(device->IsPaired());
1842 1877
1843 // Pairing dialog should be dismissed 1878 // Pairing dialog should be dismissed
1844 EXPECT_EQ(1, pairing_delegate.call_count_); 1879 EXPECT_EQ(1, pairing_delegate.call_count_);
1845 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1880 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1846 } 1881 }
1847 1882
1848 } // namespace chromeos 1883 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698