| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" | |
| 6 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_chromeos.h" | |
| 7 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.h" | |
| 8 #include "chrome/browser/chromeos/bluetooth/test/mock_bluetooth_adapter.h" | |
| 9 #include "chromeos/dbus/mock_bluetooth_adapter_client.h" | 5 #include "chromeos/dbus/mock_bluetooth_adapter_client.h" |
| 10 #include "chromeos/dbus/mock_bluetooth_manager_client.h" | 6 #include "chromeos/dbus/mock_bluetooth_manager_client.h" |
| 11 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 7 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
| 12 #include "dbus/object_path.h" | 8 #include "dbus/object_path.h" |
| 9 #include "device/bluetooth/bluetooth_adapter.h" |
| 10 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
| 11 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 12 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using device::BluetoothAdapter; |
| 16 using device::BluetoothAdapterFactory; |
| 17 using device::MockBluetoothAdapter; |
| 15 using ::testing::_; | 18 using ::testing::_; |
| 16 using ::testing::InSequence; | 19 using ::testing::InSequence; |
| 17 using ::testing::Return; | 20 using ::testing::Return; |
| 18 using ::testing::SaveArg; | 21 using ::testing::SaveArg; |
| 19 | 22 |
| 20 namespace chromeos { | 23 namespace chromeos { |
| 21 | 24 |
| 22 class BluetoothAdapterChromeOsTest : public testing::Test { | 25 class BluetoothAdapterChromeOsTest : public testing::Test { |
| 23 public: | 26 public: |
| 24 virtual void SetUp() { | 27 virtual void SetUp() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 TEST_F(BluetoothAdapterChromeOsTest, DefaultAdapterNotPresent) { | 63 TEST_F(BluetoothAdapterChromeOsTest, DefaultAdapterNotPresent) { |
| 61 // Create the default adapter instance; | 64 // Create the default adapter instance; |
| 62 // BluetoothManagerClient::DefaultAdapter will be called once, passing | 65 // BluetoothManagerClient::DefaultAdapter will be called once, passing |
| 63 // a callback to obtain the adapter path. | 66 // a callback to obtain the adapter path. |
| 64 BluetoothManagerClient::AdapterCallback adapter_callback; | 67 BluetoothManagerClient::AdapterCallback adapter_callback; |
| 65 EXPECT_CALL(*mock_manager_client_, DefaultAdapter(_)) | 68 EXPECT_CALL(*mock_manager_client_, DefaultAdapter(_)) |
| 66 .WillOnce(SaveArg<0>(&adapter_callback)); | 69 .WillOnce(SaveArg<0>(&adapter_callback)); |
| 67 | 70 |
| 68 scoped_refptr<BluetoothAdapter> adapter = | 71 scoped_refptr<BluetoothAdapter> adapter = |
| 69 BluetoothAdapterFactory::DefaultAdapter(); | 72 BluetoothAdapterFactory::DefaultAdapter(); |
| 73 ASSERT_TRUE(adapter.get() != NULL); |
| 70 | 74 |
| 71 // Call the adapter callback; make out it failed. | 75 // Call the adapter callback; make out it failed. |
| 72 // BluetoothAdapter::Observer::AdapterPresentChanged must not be called. | 76 // BluetoothAdapter::Observer::AdapterPresentChanged must not be called. |
| 73 MockBluetoothAdapter::Observer adapter_observer; | 77 MockBluetoothAdapter::Observer adapter_observer; |
| 74 adapter->AddObserver(&adapter_observer); | 78 adapter->AddObserver(&adapter_observer); |
| 75 | 79 |
| 76 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter.get(), _)) | 80 EXPECT_CALL(adapter_observer, AdapterPresentChanged(adapter.get(), _)) |
| 77 .Times(0); | 81 .Times(0); |
| 78 | 82 |
| 79 adapter_callback.Run(dbus::ObjectPath(""), false); | 83 adapter_callback.Run(dbus::ObjectPath(""), false); |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 static_cast<BluetoothAdapterChromeOs*>(adapter.get()); | 1548 static_cast<BluetoothAdapterChromeOs*>(adapter.get()); |
| 1545 | 1549 |
| 1546 static_cast<BluetoothManagerClient::Observer*>(adapter_chromeos) | 1550 static_cast<BluetoothManagerClient::Observer*>(adapter_chromeos) |
| 1547 ->AdapterRemoved(adapter_path); | 1551 ->AdapterRemoved(adapter_path); |
| 1548 | 1552 |
| 1549 // Adapter should have the new property value. | 1553 // Adapter should have the new property value. |
| 1550 EXPECT_FALSE(adapter->IsDiscovering()); | 1554 EXPECT_FALSE(adapter->IsDiscovering()); |
| 1551 } | 1555 } |
| 1552 | 1556 |
| 1553 } // namespace chromeos | 1557 } // namespace chromeos |
| OLD | NEW |