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

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: interface deletion order fixed. 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
« no previous file with comments | « device/bluetooth/bluetooth_device_experimental_chromeos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 ASSERT_EQ(1U, devices.size()); 748 ASSERT_EQ(1U, devices.size());
749 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, 749 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress,
750 devices[0]->GetAddress()); 750 devices[0]->GetAddress());
751 751
752 // Verify the other device properties. 752 // Verify the other device properties.
753 EXPECT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), 753 EXPECT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName),
754 devices[0]->GetName()); 754 devices[0]->GetName());
755 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType()); 755 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType());
756 EXPECT_TRUE(devices[0]->IsPaired()); 756 EXPECT_TRUE(devices[0]->IsPaired());
757 EXPECT_FALSE(devices[0]->IsConnected()); 757 EXPECT_FALSE(devices[0]->IsConnected());
758 EXPECT_FALSE(devices[0]->IsConnectable());
759 EXPECT_FALSE(devices[0]->IsConnecting()); 758 EXPECT_FALSE(devices[0]->IsConnecting());
760 759
760 // Non HID devices are always connectable.
761 EXPECT_TRUE(devices[0]->IsConnectable());
762
761 BluetoothDevice::ServiceList uuids = devices[0]->GetServices(); 763 BluetoothDevice::ServiceList uuids = devices[0]->GetServices();
762 ASSERT_EQ(2U, uuids.size()); 764 ASSERT_EQ(2U, uuids.size());
763 EXPECT_EQ(uuids[0], "00001800-0000-1000-8000-00805f9b34fb"); 765 EXPECT_EQ(uuids[0], "00001800-0000-1000-8000-00805f9b34fb");
764 EXPECT_EQ(uuids[1], "00001801-0000-1000-8000-00805f9b34fb"); 766 EXPECT_EQ(uuids[1], "00001801-0000-1000-8000-00805f9b34fb");
765 } 767 }
766 768
767 TEST_F(BluetoothExperimentalChromeOSTest, DeviceClassChanged) { 769 TEST_F(BluetoothExperimentalChromeOSTest, DeviceClassChanged) {
768 // Simulate a change of class of a device, as sometimes occurs 770 // Simulate a change of class of a device, as sometimes occurs
769 // during discovery. 771 // during discovery.
770 GetAdapter(); 772 GetAdapter();
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 EXPECT_EQ(device, observer.last_device_); 1004 EXPECT_EQ(device, observer.last_device_);
1003 1005
1004 EXPECT_TRUE(device->IsConnected()); 1006 EXPECT_TRUE(device->IsConnected());
1005 EXPECT_FALSE(device->IsConnecting()); 1007 EXPECT_FALSE(device->IsConnecting());
1006 1008
1007 // Make sure the trusted property has been set to true. 1009 // Make sure the trusted property has been set to true.
1008 FakeBluetoothDeviceClient::Properties* properties = 1010 FakeBluetoothDeviceClient::Properties* properties =
1009 fake_bluetooth_device_client_->GetProperties( 1011 fake_bluetooth_device_client_->GetProperties(
1010 dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath)); 1012 dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath));
1011 EXPECT_TRUE(properties->trusted.value()); 1013 EXPECT_TRUE(properties->trusted.value());
1014
1015 // Verify is a HID device and is not connectable.
1016 BluetoothDevice::ServiceList uuids = device->GetServices();
1017 ASSERT_EQ(1U, uuids.size());
1018 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb");
1019 EXPECT_FALSE(device->IsConnectable());
1012 } 1020 }
1013 1021
1014 TEST_F(BluetoothExperimentalChromeOSTest, ConnectConnectedDevice) { 1022 TEST_F(BluetoothExperimentalChromeOSTest, ConnectConnectedDevice) {
1015 GetAdapter(); 1023 GetAdapter();
1016 1024
1017 BluetoothDevice* device = adapter_->GetDevice( 1025 BluetoothDevice* device = adapter_->GetDevice(
1018 FakeBluetoothDeviceClient::kPairedDeviceAddress); 1026 FakeBluetoothDeviceClient::kPairedDeviceAddress);
1019 ASSERT_TRUE(device != NULL); 1027 ASSERT_TRUE(device != NULL);
1020 ASSERT_TRUE(device->IsPaired()); 1028 ASSERT_TRUE(device->IsPaired());
1021 1029
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 1197
1190 // One change for connected, and one for paired. 1198 // One change for connected, and one for paired.
1191 EXPECT_EQ(2, observer.device_changed_count_); 1199 EXPECT_EQ(2, observer.device_changed_count_);
1192 EXPECT_EQ(device, observer.last_device_); 1200 EXPECT_EQ(device, observer.last_device_);
1193 1201
1194 EXPECT_TRUE(device->IsConnected()); 1202 EXPECT_TRUE(device->IsConnected());
1195 EXPECT_FALSE(device->IsConnecting()); 1203 EXPECT_FALSE(device->IsConnecting());
1196 1204
1197 EXPECT_TRUE(device->IsPaired()); 1205 EXPECT_TRUE(device->IsPaired());
1198 1206
1207 // Verify is a HID device and is connectable.
1208 BluetoothDevice::ServiceList uuids = device->GetServices();
1209 ASSERT_EQ(1U, uuids.size());
1210 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb");
1211 EXPECT_TRUE(device->IsConnectable());
1212
1199 // Pairing dialog should be dismissed 1213 // Pairing dialog should be dismissed
1200 EXPECT_EQ(1, pairing_delegate.call_count_); 1214 EXPECT_EQ(1, pairing_delegate.call_count_);
1201 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1215 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1202 1216
1203 // Make sure the trusted property has been set to true. 1217 // Make sure the trusted property has been set to true.
1204 FakeBluetoothDeviceClient::Properties* properties = 1218 FakeBluetoothDeviceClient::Properties* properties =
1205 fake_bluetooth_device_client_->GetProperties( 1219 fake_bluetooth_device_client_->GetProperties(
1206 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleMousePath)); 1220 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleMousePath));
1207 EXPECT_TRUE(properties->trusted.value()); 1221 EXPECT_TRUE(properties->trusted.value());
1208 } 1222 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1258
1245 // One change for connected, and one for paired. 1259 // One change for connected, and one for paired.
1246 EXPECT_EQ(2, observer.device_changed_count_); 1260 EXPECT_EQ(2, observer.device_changed_count_);
1247 EXPECT_EQ(device, observer.last_device_); 1261 EXPECT_EQ(device, observer.last_device_);
1248 1262
1249 EXPECT_TRUE(device->IsConnected()); 1263 EXPECT_TRUE(device->IsConnected());
1250 EXPECT_FALSE(device->IsConnecting()); 1264 EXPECT_FALSE(device->IsConnecting());
1251 1265
1252 EXPECT_TRUE(device->IsPaired()); 1266 EXPECT_TRUE(device->IsPaired());
1253 1267
1268 // Verify is a HID device and is connectable.
1269 BluetoothDevice::ServiceList uuids = device->GetServices();
1270 ASSERT_EQ(1U, uuids.size());
1271 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb");
1272 EXPECT_TRUE(device->IsConnectable());
1273
1254 // Pairing dialog should be dismissed 1274 // Pairing dialog should be dismissed
1255 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1275 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1256 1276
1257 // Make sure the trusted property has been set to true. 1277 // Make sure the trusted property has been set to true.
1258 FakeBluetoothDeviceClient::Properties* properties = 1278 FakeBluetoothDeviceClient::Properties* properties =
1259 fake_bluetooth_device_client_->GetProperties( 1279 fake_bluetooth_device_client_->GetProperties(
1260 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleKeyboardPath)); 1280 dbus::ObjectPath(FakeBluetoothDeviceClient::kAppleKeyboardPath));
1261 EXPECT_TRUE(properties->trusted.value()); 1281 EXPECT_TRUE(properties->trusted.value());
1262 } 1282 }
1263 1283
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1337
1318 // One change for connected, and one for paired. 1338 // One change for connected, and one for paired.
1319 EXPECT_EQ(2, observer.device_changed_count_); 1339 EXPECT_EQ(2, observer.device_changed_count_);
1320 EXPECT_EQ(device, observer.last_device_); 1340 EXPECT_EQ(device, observer.last_device_);
1321 1341
1322 EXPECT_TRUE(device->IsConnected()); 1342 EXPECT_TRUE(device->IsConnected());
1323 EXPECT_FALSE(device->IsConnecting()); 1343 EXPECT_FALSE(device->IsConnecting());
1324 1344
1325 EXPECT_TRUE(device->IsPaired()); 1345 EXPECT_TRUE(device->IsPaired());
1326 1346
1347 // Verify is a HID device.
1348 BluetoothDevice::ServiceList uuids = device->GetServices();
1349 ASSERT_EQ(1U, uuids.size());
1350 EXPECT_EQ(uuids[0], "00001124-0000-1000-8000-00805f9b34fb");
1351
1352 // Fake MotorolaKeyboard is not connectable.
1353 EXPECT_FALSE(device->IsConnectable());
1354
1327 // Pairing dialog should be dismissed 1355 // Pairing dialog should be dismissed
1328 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1356 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1329 1357
1330 // Make sure the trusted property has been set to true. 1358 // Make sure the trusted property has been set to true.
1331 FakeBluetoothDeviceClient::Properties* properties = 1359 FakeBluetoothDeviceClient::Properties* properties =
1332 fake_bluetooth_device_client_->GetProperties( 1360 fake_bluetooth_device_client_->GetProperties(
1333 dbus::ObjectPath(FakeBluetoothDeviceClient::kMotorolaKeyboardPath)); 1361 dbus::ObjectPath(FakeBluetoothDeviceClient::kMotorolaKeyboardPath));
1334 EXPECT_TRUE(properties->trusted.value()); 1362 EXPECT_TRUE(properties->trusted.value());
1335 } 1363 }
1336 1364
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 1399
1372 // One change for connected, and one for paired. 1400 // One change for connected, and one for paired.
1373 EXPECT_EQ(2, observer.device_changed_count_); 1401 EXPECT_EQ(2, observer.device_changed_count_);
1374 EXPECT_EQ(device, observer.last_device_); 1402 EXPECT_EQ(device, observer.last_device_);
1375 1403
1376 EXPECT_TRUE(device->IsConnected()); 1404 EXPECT_TRUE(device->IsConnected());
1377 EXPECT_FALSE(device->IsConnecting()); 1405 EXPECT_FALSE(device->IsConnecting());
1378 1406
1379 EXPECT_TRUE(device->IsPaired()); 1407 EXPECT_TRUE(device->IsPaired());
1380 1408
1409 // Verify is not a HID device.
1410 BluetoothDevice::ServiceList uuids = device->GetServices();
1411 ASSERT_EQ(0U, uuids.size());
1412
1413 // Non HID devices are always connectable.
1414 EXPECT_TRUE(device->IsConnectable());
1415
1381 // Pairing dialog should be dismissed 1416 // Pairing dialog should be dismissed
1382 EXPECT_EQ(2, pairing_delegate.call_count_); 1417 EXPECT_EQ(2, pairing_delegate.call_count_);
1383 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1418 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1384 1419
1385 // Make sure the trusted property has been set to true. 1420 // Make sure the trusted property has been set to true.
1386 FakeBluetoothDeviceClient::Properties* properties = 1421 FakeBluetoothDeviceClient::Properties* properties =
1387 fake_bluetooth_device_client_->GetProperties( 1422 fake_bluetooth_device_client_->GetProperties(
1388 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath)); 1423 dbus::ObjectPath(FakeBluetoothDeviceClient::kSonyHeadphonesPath));
1389 EXPECT_TRUE(properties->trusted.value()); 1424 EXPECT_TRUE(properties->trusted.value());
1390 } 1425 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 1462
1428 // One change for connected, and one for paired. 1463 // One change for connected, and one for paired.
1429 EXPECT_EQ(2, observer.device_changed_count_); 1464 EXPECT_EQ(2, observer.device_changed_count_);
1430 EXPECT_EQ(device, observer.last_device_); 1465 EXPECT_EQ(device, observer.last_device_);
1431 1466
1432 EXPECT_TRUE(device->IsConnected()); 1467 EXPECT_TRUE(device->IsConnected());
1433 EXPECT_FALSE(device->IsConnecting()); 1468 EXPECT_FALSE(device->IsConnecting());
1434 1469
1435 EXPECT_TRUE(device->IsPaired()); 1470 EXPECT_TRUE(device->IsPaired());
1436 1471
1472 // Non HID devices are always connectable.
1473 EXPECT_TRUE(device->IsConnectable());
1474
1437 // Pairing dialog should be dismissed 1475 // Pairing dialog should be dismissed
1438 EXPECT_EQ(2, pairing_delegate.call_count_); 1476 EXPECT_EQ(2, pairing_delegate.call_count_);
1439 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1477 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1440 1478
1441 // Make sure the trusted property has been set to true. 1479 // Make sure the trusted property has been set to true.
1442 FakeBluetoothDeviceClient::Properties* properties = 1480 FakeBluetoothDeviceClient::Properties* properties =
1443 fake_bluetooth_device_client_->GetProperties( 1481 fake_bluetooth_device_client_->GetProperties(
1444 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath)); 1482 dbus::ObjectPath(FakeBluetoothDeviceClient::kPhonePath));
1445 EXPECT_TRUE(properties->trusted.value()); 1483 EXPECT_TRUE(properties->trusted.value());
1446 } 1484 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 1522
1485 // One change for connected, and one for paired. 1523 // One change for connected, and one for paired.
1486 EXPECT_EQ(2, observer.device_changed_count_); 1524 EXPECT_EQ(2, observer.device_changed_count_);
1487 EXPECT_EQ(device, observer.last_device_); 1525 EXPECT_EQ(device, observer.last_device_);
1488 1526
1489 EXPECT_TRUE(device->IsConnected()); 1527 EXPECT_TRUE(device->IsConnected());
1490 EXPECT_FALSE(device->IsConnecting()); 1528 EXPECT_FALSE(device->IsConnecting());
1491 1529
1492 EXPECT_TRUE(device->IsPaired()); 1530 EXPECT_TRUE(device->IsPaired());
1493 1531
1532 // Non HID devices are always connectable.
1533 EXPECT_TRUE(device->IsConnectable());
1534
1494 // Pairing dialog should be dismissed 1535 // Pairing dialog should be dismissed
1495 EXPECT_EQ(2, pairing_delegate.call_count_); 1536 EXPECT_EQ(2, pairing_delegate.call_count_);
1496 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1537 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1497 1538
1498 // Make sure the trusted property has been set to true. 1539 // Make sure the trusted property has been set to true.
1499 FakeBluetoothDeviceClient::Properties* properties = 1540 FakeBluetoothDeviceClient::Properties* properties =
1500 fake_bluetooth_device_client_->GetProperties( 1541 fake_bluetooth_device_client_->GetProperties(
1501 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); 1542 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath));
1502 EXPECT_TRUE(properties->trusted.value()); 1543 EXPECT_TRUE(properties->trusted.value());
1503 } 1544 }
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 EXPECT_FALSE(device->IsConnected()); 1964 EXPECT_FALSE(device->IsConnected());
1924 EXPECT_FALSE(device->IsConnecting()); 1965 EXPECT_FALSE(device->IsConnecting());
1925 EXPECT_FALSE(device->IsPaired()); 1966 EXPECT_FALSE(device->IsPaired());
1926 1967
1927 // Pairing dialog should be dismissed 1968 // Pairing dialog should be dismissed
1928 EXPECT_EQ(1, pairing_delegate.call_count_); 1969 EXPECT_EQ(1, pairing_delegate.call_count_);
1929 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1970 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1930 } 1971 }
1931 1972
1932 } // namespace chromeos 1973 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_experimental_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698