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

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

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