| 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 "chromeos/dbus/mock_bluetooth_adapter_client.h" | 5 #include "chromeos/dbus/mock_bluetooth_adapter_client.h" |
| 6 #include "chromeos/dbus/mock_bluetooth_device_client.h" | 6 #include "chromeos/dbus/mock_bluetooth_device_client.h" |
| 7 #include "chromeos/dbus/mock_bluetooth_manager_client.h" | 7 #include "chromeos/dbus/mock_bluetooth_manager_client.h" |
| 8 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 8 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
| 9 #include "dbus/object_path.h" | 9 #include "dbus/object_path.h" |
| 10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // a callback to obtain the adapter path. | 45 // a callback to obtain the adapter path. |
| 46 BluetoothManagerClient::AdapterCallback adapter_callback; | 46 BluetoothManagerClient::AdapterCallback adapter_callback; |
| 47 EXPECT_CALL(*mock_manager_client_, DefaultAdapter(_)) | 47 EXPECT_CALL(*mock_manager_client_, DefaultAdapter(_)) |
| 48 .WillOnce(SaveArg<0>(&adapter_callback)); | 48 .WillOnce(SaveArg<0>(&adapter_callback)); |
| 49 | 49 |
| 50 EXPECT_CALL(*mock_manager_client_, AddObserver(_)) | 50 EXPECT_CALL(*mock_manager_client_, AddObserver(_)) |
| 51 .Times(1); | 51 .Times(1); |
| 52 EXPECT_CALL(*mock_adapter_client_, AddObserver(_)) | 52 EXPECT_CALL(*mock_adapter_client_, AddObserver(_)) |
| 53 .Times(1); | 53 .Times(1); |
| 54 | 54 |
| 55 adapter_ = BluetoothAdapterFactory::DefaultAdapter(); | 55 BluetoothAdapterFactory::RunCallbackOnAdapterReady( |
| 56 ASSERT_TRUE(adapter_.get() != NULL); | 56 base::Bind(&BluetoothAdapterDevicesChromeOsTest::SetAdapter, |
| 57 base::Unretained(this))); |
| 58 ASSERT_TRUE(adapter_ != NULL); |
| 57 | 59 |
| 58 // Call the adapter callback; | 60 // Call the adapter callback; |
| 59 // BluetoothAdapterClient::GetProperties will be called once to obtain | 61 // BluetoothAdapterClient::GetProperties will be called once to obtain |
| 60 // the property set. | 62 // the property set. |
| 61 MockBluetoothAdapterClient::Properties adapter_properties; | 63 MockBluetoothAdapterClient::Properties adapter_properties; |
| 62 adapter_properties.address.ReplaceValue(adapter_address_); | 64 adapter_properties.address.ReplaceValue(adapter_address_); |
| 63 adapter_properties.powered.ReplaceValue(true); | 65 adapter_properties.powered.ReplaceValue(true); |
| 64 | 66 |
| 65 EXPECT_CALL(*mock_adapter_client_, GetProperties(adapter_path_)) | 67 EXPECT_CALL(*mock_adapter_client_, GetProperties(adapter_path_)) |
| 66 .WillRepeatedly(Return(&adapter_properties)); | 68 .WillRepeatedly(Return(&adapter_properties)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 89 .Times(1); | 91 .Times(1); |
| 90 EXPECT_CALL(*mock_adapter_client_, RemoveObserver(adapter_chromeos)) | 92 EXPECT_CALL(*mock_adapter_client_, RemoveObserver(adapter_chromeos)) |
| 91 .Times(1); | 93 .Times(1); |
| 92 EXPECT_CALL(*mock_manager_client_, RemoveObserver(adapter_chromeos)) | 94 EXPECT_CALL(*mock_manager_client_, RemoveObserver(adapter_chromeos)) |
| 93 .Times(1); | 95 .Times(1); |
| 94 | 96 |
| 95 adapter_ = NULL; | 97 adapter_ = NULL; |
| 96 DBusThreadManager::Shutdown(); | 98 DBusThreadManager::Shutdown(); |
| 97 } | 99 } |
| 98 | 100 |
| 101 void SetAdapter(scoped_refptr<device::BluetoothAdapter> adapter) { |
| 102 adapter_ = adapter; |
| 103 } |
| 104 |
| 99 protected: | 105 protected: |
| 100 MockBluetoothManagerClient* mock_manager_client_; | 106 MockBluetoothManagerClient* mock_manager_client_; |
| 101 MockBluetoothAdapterClient* mock_adapter_client_; | 107 MockBluetoothAdapterClient* mock_adapter_client_; |
| 102 MockBluetoothDeviceClient* mock_device_client_; | 108 MockBluetoothDeviceClient* mock_device_client_; |
| 103 | 109 |
| 104 static const dbus::ObjectPath adapter_path_; | 110 static const dbus::ObjectPath adapter_path_; |
| 105 static const std::string adapter_address_; | 111 static const std::string adapter_address_; |
| 106 scoped_refptr<BluetoothAdapter> adapter_; | 112 scoped_refptr<BluetoothAdapter> adapter_; |
| 107 | 113 |
| 108 MockBluetoothAdapter::Observer adapter_observer_; | 114 MockBluetoothAdapter::Observer adapter_observer_; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 165 |
| 160 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) | 166 static_cast<BluetoothAdapterClient::Observer*>(adapter_chromeos) |
| 161 ->DeviceRemoved(adapter_path_, device_path); | 167 ->DeviceRemoved(adapter_path_, device_path); |
| 162 | 168 |
| 163 // Verify that the device is still visible, just no longer paired. | 169 // Verify that the device is still visible, just no longer paired. |
| 164 EXPECT_TRUE(device->IsVisible()); | 170 EXPECT_TRUE(device->IsVisible()); |
| 165 EXPECT_FALSE(device->IsPaired()); | 171 EXPECT_FALSE(device->IsPaired()); |
| 166 } | 172 } |
| 167 | 173 |
| 168 } // namespace chromeos | 174 } // namespace chromeos |
| OLD | NEW |