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

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

Issue 15016004: Bluetooth: Parse the bluez.Error.Failed on pairing error. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 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 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 EXPECT_EQ(2, pairing_delegate.call_count_); 1552 EXPECT_EQ(2, pairing_delegate.call_count_);
1553 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 1553 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1554 1554
1555 // Make sure the trusted property has been set to true. 1555 // Make sure the trusted property has been set to true.
1556 FakeBluetoothDeviceClient::Properties* properties = 1556 FakeBluetoothDeviceClient::Properties* properties =
1557 fake_bluetooth_device_client_->GetProperties( 1557 fake_bluetooth_device_client_->GetProperties(
1558 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath)); 1558 dbus::ObjectPath(FakeBluetoothDeviceClient::kWeirdDevicePath));
1559 EXPECT_TRUE(properties->trusted.value()); 1559 EXPECT_TRUE(properties->trusted.value());
1560 } 1560 }
1561 1561
1562 TEST_F(BluetoothExperimentalChromeOSTest, PairUnpairableDeviceFails) {
1563 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
1564 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
1565
1566 GetAdapter();
1567 DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress);
1568
1569 BluetoothDevice* device = adapter_->GetDevice(
1570 FakeBluetoothDeviceClient::kUnpairableDeviceAddress);
1571 ASSERT_TRUE(device != NULL);
1572 ASSERT_FALSE(device->IsPaired());
1573
1574 TestObserver observer(adapter_);
1575 adapter_->AddObserver(&observer);
1576
1577 TestPairingDelegate pairing_delegate;
1578 device->Connect(
1579 &pairing_delegate,
1580 base::Bind(&BluetoothExperimentalChromeOSTest::Callback,
1581 base::Unretained(this)),
1582 base::Bind(&BluetoothExperimentalChromeOSTest::ConnectErrorCallback,
1583 base::Unretained(this)));
1584
1585 EXPECT_EQ(0, pairing_delegate.call_count_);
1586 EXPECT_TRUE(device->IsConnecting());
1587
1588 // Run the loop to get the error..
1589 message_loop.Run();
1590
1591 EXPECT_EQ(0, callback_count_);
1592 EXPECT_EQ(1, error_callback_count_);
1593
1594 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_);
1595
1596 EXPECT_FALSE(device->IsConnected());
1597 EXPECT_FALSE(device->IsConnecting());
1598 EXPECT_FALSE(device->IsPaired());
1599
1600 // Pairing dialog should be dismissed
1601 EXPECT_EQ(1, pairing_delegate.call_count_);
1602 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1603 }
1604
1562 TEST_F(BluetoothExperimentalChromeOSTest, PairingFails) { 1605 TEST_F(BluetoothExperimentalChromeOSTest, PairingFails) {
1563 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT); 1606 base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
1564 fake_bluetooth_device_client_->SetSimulationIntervalMs(10); 1607 fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
1565 1608
1566 GetAdapter(); 1609 GetAdapter();
1567 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); 1610 DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress);
1568 1611
1569 // The vanishing device times out during pairing 1612 // The vanishing device times out during pairing
1570 BluetoothDevice* device = adapter_->GetDevice( 1613 BluetoothDevice* device = adapter_->GetDevice(
1571 FakeBluetoothDeviceClient::kVanishingDeviceAddress); 1614 FakeBluetoothDeviceClient::kVanishingDeviceAddress);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 EXPECT_FALSE(device->IsConnected()); 2025 EXPECT_FALSE(device->IsConnected());
1983 EXPECT_FALSE(device->IsConnecting()); 2026 EXPECT_FALSE(device->IsConnecting());
1984 EXPECT_FALSE(device->IsPaired()); 2027 EXPECT_FALSE(device->IsPaired());
1985 2028
1986 // Pairing dialog should be dismissed 2029 // Pairing dialog should be dismissed
1987 EXPECT_EQ(1, pairing_delegate.call_count_); 2030 EXPECT_EQ(1, pairing_delegate.call_count_);
1988 EXPECT_EQ(1, pairing_delegate.dismiss_count_); 2031 EXPECT_EQ(1, pairing_delegate.dismiss_count_);
1989 } 2032 }
1990 2033
1991 } // namespace chromeos 2034 } // 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