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

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

Issue 14199010: Bluetooth: call DeviceChanged observer method on IsConnecting() change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« 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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 device->Connect( 960 device->Connect(
961 NULL, 961 NULL,
962 base::Bind(&BluetoothExperimentalChromeOSTest::Callback, 962 base::Bind(&BluetoothExperimentalChromeOSTest::Callback,
963 base::Unretained(this)), 963 base::Unretained(this)),
964 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback, 964 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback,
965 base::Unretained(this))); 965 base::Unretained(this)));
966 966
967 EXPECT_EQ(1, callback_count_); 967 EXPECT_EQ(1, callback_count_);
968 EXPECT_EQ(0, error_callback_count_); 968 EXPECT_EQ(0, error_callback_count_);
969 969
970 EXPECT_EQ(1, observer.device_changed_count_); 970 EXPECT_EQ(3, observer.device_changed_count_);
971 EXPECT_EQ(device, observer.last_device_); 971 EXPECT_EQ(device, observer.last_device_);
972 972
973 EXPECT_TRUE(device->IsConnected()); 973 EXPECT_TRUE(device->IsConnected());
974 EXPECT_FALSE(device->IsConnecting()); 974 EXPECT_FALSE(device->IsConnecting());
975 } 975 }
976 976
977 TEST_F(BluetoothExperimentalChromeOSTest, ConnectUnpairableDevice) { 977 TEST_F(BluetoothExperimentalChromeOSTest, ConnectUnpairableDevice) {
978 GetAdapter(); 978 GetAdapter();
979 DiscoverDevices(); 979 DiscoverDevices();
980 980
(...skipping 10 matching lines...) Expand all
991 device->Connect( 991 device->Connect(
992 NULL, 992 NULL,
993 base::Bind(&BluetoothExperimentalChromeOSTest::Callback, 993 base::Bind(&BluetoothExperimentalChromeOSTest::Callback,
994 base::Unretained(this)), 994 base::Unretained(this)),
995 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback, 995 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback,
996 base::Unretained(this))); 996 base::Unretained(this)));
997 997
998 EXPECT_EQ(1, callback_count_); 998 EXPECT_EQ(1, callback_count_);
999 EXPECT_EQ(0, error_callback_count_); 999 EXPECT_EQ(0, error_callback_count_);
1000 1000
1001 EXPECT_EQ(1, observer.device_changed_count_); 1001 EXPECT_EQ(3, observer.device_changed_count_);
1002 EXPECT_EQ(device, observer.last_device_); 1002 EXPECT_EQ(device, observer.last_device_);
1003 1003
1004 EXPECT_TRUE(device->IsConnected()); 1004 EXPECT_TRUE(device->IsConnected());
1005 EXPECT_FALSE(device->IsConnecting()); 1005 EXPECT_FALSE(device->IsConnecting());
1006 1006
1007 // Make sure the trusted property has been set to true. 1007 // Make sure the trusted property has been set to true.
1008 FakeBluetoothDeviceClient::Properties* properties = 1008 FakeBluetoothDeviceClient::Properties* properties =
1009 fake_bluetooth_device_client_->GetProperties( 1009 fake_bluetooth_device_client_->GetProperties(
1010 dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath)); 1010 dbus::ObjectPath(FakeBluetoothDeviceClient::kMicrosoftMousePath));
1011 EXPECT_TRUE(properties->trusted.value()); 1011 EXPECT_TRUE(properties->trusted.value());
(...skipping 28 matching lines...) Expand all
1040 device->Connect( 1040 device->Connect(
1041 NULL, 1041 NULL,
1042 base::Bind(&BluetoothExperimentalChromeOSTest::Callback, 1042 base::Bind(&BluetoothExperimentalChromeOSTest::Callback,
1043 base::Unretained(this)), 1043 base::Unretained(this)),
1044 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback, 1044 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback,
1045 base::Unretained(this))); 1045 base::Unretained(this)));
1046 1046
1047 EXPECT_EQ(1, callback_count_); 1047 EXPECT_EQ(1, callback_count_);
1048 EXPECT_EQ(0, error_callback_count_); 1048 EXPECT_EQ(0, error_callback_count_);
1049 1049
1050 EXPECT_EQ(0, observer.device_changed_count_); 1050 // Connecting will trigger true and false.
1051 EXPECT_EQ(2, observer.device_changed_count_);
1051 1052
1052 EXPECT_TRUE(device->IsConnected()); 1053 EXPECT_TRUE(device->IsConnected());
1053 EXPECT_FALSE(device->IsConnecting()); 1054 EXPECT_FALSE(device->IsConnecting());
1054 } 1055 }
1055 1056
1056 TEST_F(BluetoothExperimentalChromeOSTest, ConnectDeviceFails) { 1057 TEST_F(BluetoothExperimentalChromeOSTest, ConnectDeviceFails) {
1057 GetAdapter(); 1058 GetAdapter();
1058 DiscoverDevices(); 1059 DiscoverDevices();
1059 1060
1060 BluetoothDevice* device = adapter_->GetDevice( 1061 BluetoothDevice* device = adapter_->GetDevice(
(...skipping 10 matching lines...) Expand all
1071 NULL, 1072 NULL,
1072 base::Bind(&BluetoothExperimentalChromeOSTest::Callback, 1073 base::Bind(&BluetoothExperimentalChromeOSTest::Callback,
1073 base::Unretained(this)), 1074 base::Unretained(this)),
1074 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback, 1075 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback,
1075 base::Unretained(this))); 1076 base::Unretained(this)));
1076 1077
1077 EXPECT_EQ(0, callback_count_); 1078 EXPECT_EQ(0, callback_count_);
1078 EXPECT_EQ(1, error_callback_count_); 1079 EXPECT_EQ(1, error_callback_count_);
1079 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_); 1080 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_);
1080 1081
1081 EXPECT_EQ(0, observer.device_changed_count_); 1082 EXPECT_EQ(2, observer.device_changed_count_);
1082 1083
1083 EXPECT_FALSE(device->IsConnected()); 1084 EXPECT_FALSE(device->IsConnected());
1084 EXPECT_FALSE(device->IsConnecting()); 1085 EXPECT_FALSE(device->IsConnecting());
1085 } 1086 }
1086 1087
1087 TEST_F(BluetoothExperimentalChromeOSTest, DisconnectDevice) { 1088 TEST_F(BluetoothExperimentalChromeOSTest, DisconnectDevice) {
1088 GetAdapter(); 1089 GetAdapter();
1089 1090
1090 BluetoothDevice* device = adapter_->GetDevice( 1091 BluetoothDevice* device = adapter_->GetDevice(
1091 FakeBluetoothDeviceClient::kPairedDeviceAddress); 1092 FakeBluetoothDeviceClient::kPairedDeviceAddress);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 base::Unretained(this))); 1181 base::Unretained(this)));
1181 1182
1182 EXPECT_EQ(0, pairing_delegate.call_count_); 1183 EXPECT_EQ(0, pairing_delegate.call_count_);
1183 EXPECT_TRUE(device->IsConnecting()); 1184 EXPECT_TRUE(device->IsConnecting());
1184 1185
1185 message_loop.Run(); 1186 message_loop.Run();
1186 1187
1187 EXPECT_EQ(1, callback_count_); 1188 EXPECT_EQ(1, callback_count_);
1188 EXPECT_EQ(0, error_callback_count_); 1189 EXPECT_EQ(0, error_callback_count_);
1189 1190
1190 // One change for connected, and one for paired. 1191 // Two changes for connecting, one change for connected, and one for paired.
1191 EXPECT_EQ(2, observer.device_changed_count_); 1192 EXPECT_EQ(4, observer.device_changed_count_);
1192 EXPECT_EQ(device, observer.last_device_); 1193 EXPECT_EQ(device, observer.last_device_);
1193 1194
1194 EXPECT_TRUE(device->IsConnected()); 1195 EXPECT_TRUE(device->IsConnected());
1195 EXPECT_FALSE(device->IsConnecting()); 1196 EXPECT_FALSE(device->IsConnecting());
1196 1197
1197 EXPECT_TRUE(device->IsPaired()); 1198 EXPECT_TRUE(device->IsPaired());
1198 1199
1199 // Pairing dialog should be dismissed 1200 // Pairing dialog should be dismissed
1200 EXPECT_EQ(1, pairing_delegate.call_count_); 1201 EXPECT_EQ(1, pairing_delegate.call_count_);
1201 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1202 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 EXPECT_EQ(1, pairing_delegate.call_count_); 1236 EXPECT_EQ(1, pairing_delegate.call_count_);
1236 EXPECT_EQ(1, pairing_delegate.display_pincode_count_); 1237 EXPECT_EQ(1, pairing_delegate.display_pincode_count_);
1237 EXPECT_EQ("123456", pairing_delegate.last_pincode_); 1238 EXPECT_EQ("123456", pairing_delegate.last_pincode_);
1238 EXPECT_TRUE(device->IsConnecting()); 1239 EXPECT_TRUE(device->IsConnecting());
1239 1240
1240 message_loop.Run(); 1241 message_loop.Run();
1241 1242
1242 EXPECT_EQ(1, callback_count_); 1243 EXPECT_EQ(1, callback_count_);
1243 EXPECT_EQ(0, error_callback_count_); 1244 EXPECT_EQ(0, error_callback_count_);
1244 1245
1245 // One change for connected, and one for paired. 1246 // Two changes for connecting, one change for connected, and one for paired.
1246 EXPECT_EQ(2, observer.device_changed_count_); 1247 EXPECT_EQ(4, observer.device_changed_count_);
1247 EXPECT_EQ(device, observer.last_device_); 1248 EXPECT_EQ(device, observer.last_device_);
1248 1249
1249 EXPECT_TRUE(device->IsConnected()); 1250 EXPECT_TRUE(device->IsConnected());
1250 EXPECT_FALSE(device->IsConnecting()); 1251 EXPECT_FALSE(device->IsConnecting());
1251 1252
1252 EXPECT_TRUE(device->IsPaired()); 1253 EXPECT_TRUE(device->IsPaired());
1253 1254
1254 // Pairing dialog should be dismissed 1255 // Pairing dialog should be dismissed
1255 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1256 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1256 1257
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 1309
1309 // 8 KeysEntered notifications (0 to 7, inclusive). Two aditional calls for 1310 // 8 KeysEntered notifications (0 to 7, inclusive). Two aditional calls for
1310 // DisplayPasskey() and DismissDisplayOrConfirm(). 1311 // DisplayPasskey() and DismissDisplayOrConfirm().
1311 EXPECT_EQ(10, pairing_delegate.call_count_); 1312 EXPECT_EQ(10, pairing_delegate.call_count_);
1312 EXPECT_EQ(8, pairing_delegate.keys_entered_count_); 1313 EXPECT_EQ(8, pairing_delegate.keys_entered_count_);
1313 EXPECT_EQ(7U, pairing_delegate.last_entered_); 1314 EXPECT_EQ(7U, pairing_delegate.last_entered_);
1314 1315
1315 EXPECT_EQ(1, callback_count_); 1316 EXPECT_EQ(1, callback_count_);
1316 EXPECT_EQ(0, error_callback_count_); 1317 EXPECT_EQ(0, error_callback_count_);
1317 1318
1318 // One change for connected, and one for paired. 1319 // Two changes for connecting, one change for connected, and one for paired.
1319 EXPECT_EQ(2, observer.device_changed_count_); 1320 EXPECT_EQ(4, observer.device_changed_count_);
1320 EXPECT_EQ(device, observer.last_device_); 1321 EXPECT_EQ(device, observer.last_device_);
1321 1322
1322 EXPECT_TRUE(device->IsConnected()); 1323 EXPECT_TRUE(device->IsConnected());
1323 EXPECT_FALSE(device->IsConnecting()); 1324 EXPECT_FALSE(device->IsConnecting());
1324 1325
1325 EXPECT_TRUE(device->IsPaired()); 1326 EXPECT_TRUE(device->IsPaired());
1326 1327
1327 // Pairing dialog should be dismissed 1328 // Pairing dialog should be dismissed
1328 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1329 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1329 1330
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 EXPECT_EQ(1, pairing_delegate.request_pincode_count_); 1363 EXPECT_EQ(1, pairing_delegate.request_pincode_count_);
1363 EXPECT_TRUE(device->IsConnecting()); 1364 EXPECT_TRUE(device->IsConnecting());
1364 1365
1365 // Set the PIN. 1366 // Set the PIN.
1366 device->SetPinCode("1234"); 1367 device->SetPinCode("1234");
1367 message_loop.Run(); 1368 message_loop.Run();
1368 1369
1369 EXPECT_EQ(1, callback_count_); 1370 EXPECT_EQ(1, callback_count_);
1370 EXPECT_EQ(0, error_callback_count_); 1371 EXPECT_EQ(0, error_callback_count_);
1371 1372
1372 // One change for connected, and one for paired. 1373 // Two changes for connecting, one change for connected, and one for paired.
1373 EXPECT_EQ(2, observer.device_changed_count_); 1374 EXPECT_EQ(4, observer.device_changed_count_);
1374 EXPECT_EQ(device, observer.last_device_); 1375 EXPECT_EQ(device, observer.last_device_);
1375 1376
1376 EXPECT_TRUE(device->IsConnected()); 1377 EXPECT_TRUE(device->IsConnected());
1377 EXPECT_FALSE(device->IsConnecting()); 1378 EXPECT_FALSE(device->IsConnecting());
1378 1379
1379 EXPECT_TRUE(device->IsPaired()); 1380 EXPECT_TRUE(device->IsPaired());
1380 1381
1381 // Pairing dialog should be dismissed 1382 // Pairing dialog should be dismissed
1382 EXPECT_EQ(2, pairing_delegate.call_count_); 1383 EXPECT_EQ(2, pairing_delegate.call_count_);
1383 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1384 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 EXPECT_EQ(123456U, pairing_delegate.last_passkey_); 1419 EXPECT_EQ(123456U, pairing_delegate.last_passkey_);
1419 EXPECT_TRUE(device->IsConnecting()); 1420 EXPECT_TRUE(device->IsConnecting());
1420 1421
1421 // Confirm the passkey. 1422 // Confirm the passkey.
1422 device->ConfirmPairing(); 1423 device->ConfirmPairing();
1423 message_loop.Run(); 1424 message_loop.Run();
1424 1425
1425 EXPECT_EQ(1, callback_count_); 1426 EXPECT_EQ(1, callback_count_);
1426 EXPECT_EQ(0, error_callback_count_); 1427 EXPECT_EQ(0, error_callback_count_);
1427 1428
1428 // One change for connected, and one for paired. 1429 // Two changes for connecting, one change for connected, and one for paired.
1429 EXPECT_EQ(2, observer.device_changed_count_); 1430 EXPECT_EQ(4, observer.device_changed_count_);
1430 EXPECT_EQ(device, observer.last_device_); 1431 EXPECT_EQ(device, observer.last_device_);
1431 1432
1432 EXPECT_TRUE(device->IsConnected()); 1433 EXPECT_TRUE(device->IsConnected());
1433 EXPECT_FALSE(device->IsConnecting()); 1434 EXPECT_FALSE(device->IsConnecting());
1434 1435
1435 EXPECT_TRUE(device->IsPaired()); 1436 EXPECT_TRUE(device->IsPaired());
1436 1437
1437 // Pairing dialog should be dismissed 1438 // Pairing dialog should be dismissed
1438 EXPECT_EQ(2, pairing_delegate.call_count_); 1439 EXPECT_EQ(2, pairing_delegate.call_count_);
1439 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1440 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 EXPECT_EQ(1, pairing_delegate.request_passkey_count_); 1476 EXPECT_EQ(1, pairing_delegate.request_passkey_count_);
1476 EXPECT_TRUE(device->IsConnecting()); 1477 EXPECT_TRUE(device->IsConnecting());
1477 1478
1478 // Set the Passkey. 1479 // Set the Passkey.
1479 device->SetPasskey(1234); 1480 device->SetPasskey(1234);
1480 message_loop.Run(); 1481 message_loop.Run();
1481 1482
1482 EXPECT_EQ(1, callback_count_); 1483 EXPECT_EQ(1, callback_count_);
1483 EXPECT_EQ(0, error_callback_count_); 1484 EXPECT_EQ(0, error_callback_count_);
1484 1485
1485 // One change for connected, and one for paired. 1486 // Two changes for connecting, one change for connected, and one for paired.
1486 EXPECT_EQ(2, observer.device_changed_count_); 1487 EXPECT_EQ(4, observer.device_changed_count_);
1487 EXPECT_EQ(device, observer.last_device_); 1488 EXPECT_EQ(device, observer.last_device_);
1488 1489
1489 EXPECT_TRUE(device->IsConnected()); 1490 EXPECT_TRUE(device->IsConnected());
1490 EXPECT_FALSE(device->IsConnecting()); 1491 EXPECT_FALSE(device->IsConnecting());
1491 1492
1492 EXPECT_TRUE(device->IsPaired()); 1493 EXPECT_TRUE(device->IsPaired());
1493 1494
1494 // Pairing dialog should be dismissed 1495 // Pairing dialog should be dismissed
1495 EXPECT_EQ(2, pairing_delegate.call_count_); 1496 EXPECT_EQ(2, pairing_delegate.call_count_);
1496 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1497 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 1574
1574 EXPECT_EQ(0, pairing_delegate.call_count_); 1575 EXPECT_EQ(0, pairing_delegate.call_count_);
1575 EXPECT_TRUE(device->IsConnecting()); 1576 EXPECT_TRUE(device->IsConnecting());
1576 1577
1577 message_loop.Run(); 1578 message_loop.Run();
1578 1579
1579 EXPECT_EQ(0, callback_count_); 1580 EXPECT_EQ(0, callback_count_);
1580 EXPECT_EQ(1, error_callback_count_); 1581 EXPECT_EQ(1, error_callback_count_);
1581 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_); 1582 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_);
1582 1583
1583 // Just one change for paired, the device should not be connected. 1584 // Two changes for connecting, and one for paired; the device should not be
1584 EXPECT_EQ(1, observer.device_changed_count_); 1585 // connected.
1586 EXPECT_EQ(3, observer.device_changed_count_);
1585 EXPECT_EQ(device, observer.last_device_); 1587 EXPECT_EQ(device, observer.last_device_);
1586 1588
1587 EXPECT_FALSE(device->IsConnected()); 1589 EXPECT_FALSE(device->IsConnected());
1588 EXPECT_FALSE(device->IsConnecting()); 1590 EXPECT_FALSE(device->IsConnecting());
1589 1591
1590 EXPECT_TRUE(device->IsPaired()); 1592 EXPECT_TRUE(device->IsPaired());
1591 1593
1592 // Pairing dialog should be dismissed 1594 // Pairing dialog should be dismissed
1593 EXPECT_EQ(1, pairing_delegate.call_count_); 1595 EXPECT_EQ(1, pairing_delegate.call_count_);
1594 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1596 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 EXPECT_TRUE(device->IsConnecting()); 1632 EXPECT_TRUE(device->IsConnecting());
1631 1633
1632 // Reject the pairing. 1634 // Reject the pairing.
1633 device->RejectPairing(); 1635 device->RejectPairing();
1634 message_loop.Run(); 1636 message_loop.Run();
1635 1637
1636 EXPECT_EQ(0, callback_count_); 1638 EXPECT_EQ(0, callback_count_);
1637 EXPECT_EQ(1, error_callback_count_); 1639 EXPECT_EQ(1, error_callback_count_);
1638 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_REJECTED, last_connect_error_); 1640 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_REJECTED, last_connect_error_);
1639 1641
1640 // Should be no changes. 1642 // Should be no changes except connecting going true and false.
1641 EXPECT_EQ(0, observer.device_changed_count_); 1643 EXPECT_EQ(2, observer.device_changed_count_);
1642 EXPECT_FALSE(device->IsConnected()); 1644 EXPECT_FALSE(device->IsConnected());
1643 EXPECT_FALSE(device->IsConnecting()); 1645 EXPECT_FALSE(device->IsConnecting());
1644 EXPECT_FALSE(device->IsPaired()); 1646 EXPECT_FALSE(device->IsPaired());
1645 1647
1646 // Pairing dialog should be dismissed 1648 // Pairing dialog should be dismissed
1647 EXPECT_EQ(2, pairing_delegate.call_count_); 1649 EXPECT_EQ(2, pairing_delegate.call_count_);
1648 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1650 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1649 } 1651 }
1650 1652
1651 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledAtPinCode) { 1653 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledAtPinCode) {
(...skipping 25 matching lines...) Expand all
1677 EXPECT_TRUE(device->IsConnecting()); 1679 EXPECT_TRUE(device->IsConnecting());
1678 1680
1679 // Cancel the pairing. 1681 // Cancel the pairing.
1680 device->CancelPairing(); 1682 device->CancelPairing();
1681 message_loop.Run(); 1683 message_loop.Run();
1682 1684
1683 EXPECT_EQ(0, callback_count_); 1685 EXPECT_EQ(0, callback_count_);
1684 EXPECT_EQ(1, error_callback_count_); 1686 EXPECT_EQ(1, error_callback_count_);
1685 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_); 1687 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_);
1686 1688
1687 // Should be no changes. 1689 // Should be no changes except connecting going true and false.
1688 EXPECT_EQ(0, observer.device_changed_count_); 1690 EXPECT_EQ(2, observer.device_changed_count_);
1689 EXPECT_FALSE(device->IsConnected()); 1691 EXPECT_FALSE(device->IsConnected());
1690 EXPECT_FALSE(device->IsConnecting()); 1692 EXPECT_FALSE(device->IsConnecting());
1691 EXPECT_FALSE(device->IsPaired()); 1693 EXPECT_FALSE(device->IsPaired());
1692 1694
1693 // Pairing dialog should be dismissed 1695 // Pairing dialog should be dismissed
1694 EXPECT_EQ(2, pairing_delegate.call_count_); 1696 EXPECT_EQ(2, pairing_delegate.call_count_);
1695 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1697 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1696 } 1698 }
1697 1699
1698 TEST_F(BluetoothExperimentalChromeOSTest, PairingRejectedAtPasskey) { 1700 TEST_F(BluetoothExperimentalChromeOSTest, PairingRejectedAtPasskey) {
(...skipping 25 matching lines...) Expand all
1724 EXPECT_TRUE(device->IsConnecting()); 1726 EXPECT_TRUE(device->IsConnecting());
1725 1727
1726 // Reject the pairing. 1728 // Reject the pairing.
1727 device->RejectPairing(); 1729 device->RejectPairing();
1728 message_loop.Run(); 1730 message_loop.Run();
1729 1731
1730 EXPECT_EQ(0, callback_count_); 1732 EXPECT_EQ(0, callback_count_);
1731 EXPECT_EQ(1, error_callback_count_); 1733 EXPECT_EQ(1, error_callback_count_);
1732 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_REJECTED, last_connect_error_); 1734 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_REJECTED, last_connect_error_);
1733 1735
1734 // Should be no changes. 1736 // Should be no changes except connecting going true and false.
1735 EXPECT_EQ(0, observer.device_changed_count_); 1737 EXPECT_EQ(2, observer.device_changed_count_);
1736 EXPECT_FALSE(device->IsConnected()); 1738 EXPECT_FALSE(device->IsConnected());
1737 EXPECT_FALSE(device->IsConnecting()); 1739 EXPECT_FALSE(device->IsConnecting());
1738 EXPECT_FALSE(device->IsPaired()); 1740 EXPECT_FALSE(device->IsPaired());
1739 1741
1740 // Pairing dialog should be dismissed 1742 // Pairing dialog should be dismissed
1741 EXPECT_EQ(2, pairing_delegate.call_count_); 1743 EXPECT_EQ(2, pairing_delegate.call_count_);
1742 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1744 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1743 } 1745 }
1744 1746
1745 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledAtPasskey) { 1747 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledAtPasskey) {
(...skipping 25 matching lines...) Expand all
1771 EXPECT_TRUE(device->IsConnecting()); 1773 EXPECT_TRUE(device->IsConnecting());
1772 1774
1773 // Cancel the pairing. 1775 // Cancel the pairing.
1774 device->CancelPairing(); 1776 device->CancelPairing();
1775 message_loop.Run(); 1777 message_loop.Run();
1776 1778
1777 EXPECT_EQ(0, callback_count_); 1779 EXPECT_EQ(0, callback_count_);
1778 EXPECT_EQ(1, error_callback_count_); 1780 EXPECT_EQ(1, error_callback_count_);
1779 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_); 1781 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_);
1780 1782
1781 // Should be no changes. 1783 // Should be no changes except connecting going true and false.
1782 EXPECT_EQ(0, observer.device_changed_count_); 1784 EXPECT_EQ(2, observer.device_changed_count_);
1783 EXPECT_FALSE(device->IsConnected()); 1785 EXPECT_FALSE(device->IsConnected());
1784 EXPECT_FALSE(device->IsConnecting()); 1786 EXPECT_FALSE(device->IsConnecting());
1785 EXPECT_FALSE(device->IsPaired()); 1787 EXPECT_FALSE(device->IsPaired());
1786 1788
1787 // Pairing dialog should be dismissed 1789 // Pairing dialog should be dismissed
1788 EXPECT_EQ(2, pairing_delegate.call_count_); 1790 EXPECT_EQ(2, pairing_delegate.call_count_);
1789 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1791 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1790 } 1792 }
1791 1793
1792 TEST_F(BluetoothExperimentalChromeOSTest, PairingRejectedAtConfirmation) { 1794 TEST_F(BluetoothExperimentalChromeOSTest, PairingRejectedAtConfirmation) {
(...skipping 25 matching lines...) Expand all
1818 EXPECT_TRUE(device->IsConnecting()); 1820 EXPECT_TRUE(device->IsConnecting());
1819 1821
1820 // Reject the pairing. 1822 // Reject the pairing.
1821 device->RejectPairing(); 1823 device->RejectPairing();
1822 message_loop.Run(); 1824 message_loop.Run();
1823 1825
1824 EXPECT_EQ(0, callback_count_); 1826 EXPECT_EQ(0, callback_count_);
1825 EXPECT_EQ(1, error_callback_count_); 1827 EXPECT_EQ(1, error_callback_count_);
1826 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_REJECTED, last_connect_error_); 1828 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_REJECTED, last_connect_error_);
1827 1829
1828 // Should be no changes. 1830 // Should be no changes except connecting going true and false.
1829 EXPECT_EQ(0, observer.device_changed_count_); 1831 EXPECT_EQ(2, observer.device_changed_count_);
1830 EXPECT_FALSE(device->IsConnected()); 1832 EXPECT_FALSE(device->IsConnected());
1831 EXPECT_FALSE(device->IsConnecting()); 1833 EXPECT_FALSE(device->IsConnecting());
1832 EXPECT_FALSE(device->IsPaired()); 1834 EXPECT_FALSE(device->IsPaired());
1833 1835
1834 // Pairing dialog should be dismissed 1836 // Pairing dialog should be dismissed
1835 EXPECT_EQ(2, pairing_delegate.call_count_); 1837 EXPECT_EQ(2, pairing_delegate.call_count_);
1836 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1838 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1837 } 1839 }
1838 1840
1839 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledAtConfirmation) { 1841 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledAtConfirmation) {
(...skipping 25 matching lines...) Expand all
1865 EXPECT_TRUE(device->IsConnecting()); 1867 EXPECT_TRUE(device->IsConnecting());
1866 1868
1867 // Cancel the pairing. 1869 // Cancel the pairing.
1868 device->CancelPairing(); 1870 device->CancelPairing();
1869 message_loop.Run(); 1871 message_loop.Run();
1870 1872
1871 EXPECT_EQ(0, callback_count_); 1873 EXPECT_EQ(0, callback_count_);
1872 EXPECT_EQ(1, error_callback_count_); 1874 EXPECT_EQ(1, error_callback_count_);
1873 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_); 1875 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_);
1874 1876
1875 // Should be no changes. 1877 // Should be no changes except connecting going true and false.
1876 EXPECT_EQ(0, observer.device_changed_count_); 1878 EXPECT_EQ(2, observer.device_changed_count_);
1877 EXPECT_FALSE(device->IsConnected()); 1879 EXPECT_FALSE(device->IsConnected());
1878 EXPECT_FALSE(device->IsConnecting()); 1880 EXPECT_FALSE(device->IsConnecting());
1879 EXPECT_FALSE(device->IsPaired()); 1881 EXPECT_FALSE(device->IsPaired());
1880 1882
1881 // Pairing dialog should be dismissed 1883 // Pairing dialog should be dismissed
1882 EXPECT_EQ(2, pairing_delegate.call_count_); 1884 EXPECT_EQ(2, pairing_delegate.call_count_);
1883 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1885 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1884 } 1886 }
1885 1887
1886 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledInFlight) { 1888 TEST_F(BluetoothExperimentalChromeOSTest, PairingCancelledInFlight) {
(...skipping 24 matching lines...) Expand all
1911 EXPECT_TRUE(device->IsConnecting()); 1913 EXPECT_TRUE(device->IsConnecting());
1912 1914
1913 // Cancel the pairing. 1915 // Cancel the pairing.
1914 device->CancelPairing(); 1916 device->CancelPairing();
1915 message_loop.Run(); 1917 message_loop.Run();
1916 1918
1917 EXPECT_EQ(0, callback_count_); 1919 EXPECT_EQ(0, callback_count_);
1918 EXPECT_EQ(1, error_callback_count_); 1920 EXPECT_EQ(1, error_callback_count_);
1919 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_); 1921 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_CANCELED, last_connect_error_);
1920 1922
1921 // Should be no changes. 1923 // Should be no changes except connecting going true and false.
1922 EXPECT_EQ(0, observer.device_changed_count_); 1924 EXPECT_EQ(2, observer.device_changed_count_);
1923 EXPECT_FALSE(device->IsConnected()); 1925 EXPECT_FALSE(device->IsConnected());
1924 EXPECT_FALSE(device->IsConnecting()); 1926 EXPECT_FALSE(device->IsConnecting());
1925 EXPECT_FALSE(device->IsPaired()); 1927 EXPECT_FALSE(device->IsPaired());
1926 1928
1927 // Pairing dialog should be dismissed 1929 // Pairing dialog should be dismissed
1928 EXPECT_EQ(1, pairing_delegate.call_count_); 1930 EXPECT_EQ(1, pairing_delegate.call_count_);
1929 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1931 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1930 } 1932 }
1931 1933
1932 } // namespace chromeos 1934 } // 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