OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 10 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
(...skipping 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2165 | 2165 |
2166 static const std::string new_name("New Device Name"); | 2166 static const std::string new_name("New Device Name"); |
2167 properties->alias.ReplaceValue(new_name); | 2167 properties->alias.ReplaceValue(new_name); |
2168 | 2168 |
2169 EXPECT_EQ(1, observer.device_changed_count()); | 2169 EXPECT_EQ(1, observer.device_changed_count()); |
2170 EXPECT_EQ(devices[0], observer.last_device()); | 2170 EXPECT_EQ(devices[0], observer.last_device()); |
2171 | 2171 |
2172 EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[0]->GetName()); | 2172 EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[0]->GetName()); |
2173 } | 2173 } |
2174 | 2174 |
2175 TEST_F(BluetoothChromeOSTest, DeviceAddressChanged) { | |
2176 // Simulate a change of address of a device. | |
2177 GetAdapter(); | |
2178 | |
2179 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | |
2180 ASSERT_EQ(2U, devices.size()); | |
2181 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | |
2182 devices[0]->GetAddress()); | |
2183 ASSERT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), | |
2184 devices[0]->GetName()); | |
2185 | |
2186 // Install an observer; expect the DeviceAddressChanged method to be called | |
2187 // when we change the alias of the device. | |
2188 TestBluetoothAdapterObserver observer(adapter_); | |
2189 | |
2190 FakeBluetoothDeviceClient::Properties* properties = | |
2191 fake_bluetooth_device_client_->GetProperties( | |
2192 dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); | |
2193 | |
2194 static const char* new_address = "D9:1F:FC:11:22:33"; | |
armansito
2015/09/25 18:42:30
nit: s/new_address/kNewAddress/
jpawlowski1
2015/09/25 19:25:45
Done.
| |
2195 properties->address.ReplaceValue(new_address); | |
2196 | |
2197 EXPECT_EQ(1, observer.device_address_changed_count()); | |
2198 EXPECT_EQ(1, observer.device_changed_count()); | |
2199 EXPECT_EQ(devices[0], observer.last_device()); | |
2200 | |
2201 EXPECT_EQ(std::string(new_address), devices[0]->GetAddress()); | |
2202 } | |
2203 | |
2175 TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { | 2204 TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { |
2176 // Simulate a change of advertised services of a device. | 2205 // Simulate a change of advertised services of a device. |
2177 GetAdapter(); | 2206 GetAdapter(); |
2178 | 2207 |
2179 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 2208 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
2180 ASSERT_EQ(2U, devices.size()); | 2209 ASSERT_EQ(2U, devices.size()); |
2181 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, | 2210 ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, |
2182 devices[0]->GetAddress()); | 2211 devices[0]->GetAddress()); |
2183 | 2212 |
2184 BluetoothDevice::UUIDList uuids = devices[0]->GetUUIDs(); | 2213 BluetoothDevice::UUIDList uuids = devices[0]->GetUUIDs(); |
(...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4145 adapter_->Shutdown(); | 4174 adapter_->Shutdown(); |
4146 adapter_chrome_os->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); | 4175 adapter_chrome_os->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); |
4147 | 4176 |
4148 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, | 4177 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, |
4149 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. | 4178 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. |
4150 EXPECT_EQ(0, callback_count_); | 4179 EXPECT_EQ(0, callback_count_); |
4151 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); | 4180 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); |
4152 } | 4181 } |
4153 | 4182 |
4154 } // namespace chromeos | 4183 } // namespace chromeos |
OLD | NEW |