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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 | 2146 |
2147 int idx = GetDeviceIndexByAddress( | 2147 int idx = GetDeviceIndexByAddress( |
2148 devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); | 2148 devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); |
2149 ASSERT_NE(-1, idx); | 2149 ASSERT_NE(-1, idx); |
2150 ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, | 2150 ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, |
2151 devices[idx]->GetAddress()); | 2151 devices[idx]->GetAddress()); |
2152 | 2152 |
2153 // Verify the other device properties. | 2153 // Verify the other device properties. |
2154 EXPECT_EQ( | 2154 EXPECT_EQ( |
2155 base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), | 2155 base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), |
2156 devices[idx]->GetName()); | 2156 devices[idx]->GetNameForDisplay()); |
2157 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[idx]->GetDeviceType()); | 2157 EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[idx]->GetDeviceType()); |
2158 EXPECT_TRUE(devices[idx]->IsPaired()); | 2158 EXPECT_TRUE(devices[idx]->IsPaired()); |
2159 EXPECT_FALSE(devices[idx]->IsConnected()); | 2159 EXPECT_FALSE(devices[idx]->IsConnected()); |
2160 EXPECT_FALSE(devices[idx]->IsConnecting()); | 2160 EXPECT_FALSE(devices[idx]->IsConnecting()); |
2161 | 2161 |
2162 // Non HID devices are always connectable. | 2162 // Non HID devices are always connectable. |
2163 EXPECT_TRUE(devices[idx]->IsConnectable()); | 2163 EXPECT_TRUE(devices[idx]->IsConnectable()); |
2164 | 2164 |
2165 BluetoothDevice::UUIDList uuids = devices[idx]->GetUUIDs(); | 2165 BluetoothDevice::UUIDList uuids = devices[idx]->GetUUIDs(); |
2166 ASSERT_EQ(2U, uuids.size()); | 2166 ASSERT_EQ(2U, uuids.size()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 2321 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
2322 ASSERT_EQ(2U, devices.size()); | 2322 ASSERT_EQ(2U, devices.size()); |
2323 | 2323 |
2324 int idx = GetDeviceIndexByAddress( | 2324 int idx = GetDeviceIndexByAddress( |
2325 devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); | 2325 devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); |
2326 ASSERT_NE(-1, idx); | 2326 ASSERT_NE(-1, idx); |
2327 ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, | 2327 ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, |
2328 devices[idx]->GetAddress()); | 2328 devices[idx]->GetAddress()); |
2329 ASSERT_EQ( | 2329 ASSERT_EQ( |
2330 base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), | 2330 base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), |
2331 devices[idx]->GetName()); | 2331 devices[idx]->GetNameForDisplay()); |
2332 | 2332 |
2333 // Install an observer; expect the DeviceChanged method to be called when | 2333 // Install an observer; expect the DeviceChanged method to be called when |
2334 // we change the alias of the device. | 2334 // we change the alias of the device. |
2335 TestBluetoothAdapterObserver observer(adapter_); | 2335 TestBluetoothAdapterObserver observer(adapter_); |
2336 | 2336 |
2337 bluez::FakeBluetoothDeviceClient::Properties* properties = | 2337 bluez::FakeBluetoothDeviceClient::Properties* properties = |
2338 fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( | 2338 fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( |
2339 bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); | 2339 bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); |
2340 | 2340 |
2341 static const std::string new_name("New Device Name"); | 2341 static const std::string new_name("New Device Name"); |
2342 properties->alias.ReplaceValue(new_name); | 2342 properties->alias.ReplaceValue(new_name); |
2343 | 2343 |
2344 EXPECT_EQ(1, observer.device_changed_count()); | 2344 EXPECT_EQ(1, observer.device_changed_count()); |
2345 EXPECT_EQ(devices[idx], observer.last_device()); | 2345 EXPECT_EQ(devices[idx], observer.last_device()); |
2346 | 2346 |
2347 EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[idx]->GetName()); | 2347 EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[idx]->GetNameForDisplay()); |
2348 } | 2348 } |
2349 | 2349 |
2350 TEST_F(BluetoothBlueZTest, DeviceAddressChanged) { | 2350 TEST_F(BluetoothBlueZTest, DeviceAddressChanged) { |
2351 // Simulate a change of address of a device. | 2351 // Simulate a change of address of a device. |
2352 GetAdapter(); | 2352 GetAdapter(); |
2353 | 2353 |
2354 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | 2354 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); |
2355 ASSERT_EQ(2U, devices.size()); | 2355 ASSERT_EQ(2U, devices.size()); |
2356 | 2356 |
2357 int idx = GetDeviceIndexByAddress( | 2357 int idx = GetDeviceIndexByAddress( |
2358 devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); | 2358 devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); |
2359 ASSERT_NE(-1, idx); | 2359 ASSERT_NE(-1, idx); |
2360 ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, | 2360 ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, |
2361 devices[idx]->GetAddress()); | 2361 devices[idx]->GetAddress()); |
2362 ASSERT_EQ( | 2362 ASSERT_EQ( |
2363 base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), | 2363 base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), |
2364 devices[idx]->GetName()); | 2364 devices[idx]->GetNameForDisplay()); |
2365 | 2365 |
2366 // Install an observer; expect the DeviceAddressChanged method to be called | 2366 // Install an observer; expect the DeviceAddressChanged method to be called |
2367 // when we change the alias of the device. | 2367 // when we change the alias of the device. |
2368 TestBluetoothAdapterObserver observer(adapter_); | 2368 TestBluetoothAdapterObserver observer(adapter_); |
2369 | 2369 |
2370 bluez::FakeBluetoothDeviceClient::Properties* properties = | 2370 bluez::FakeBluetoothDeviceClient::Properties* properties = |
2371 fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( | 2371 fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( |
2372 bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); | 2372 bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); |
2373 | 2373 |
2374 static const char* kNewAddress = "D9:1F:FC:11:22:33"; | 2374 static const char* kNewAddress = "D9:1F:FC:11:22:33"; |
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4481 adapter_->Shutdown(); | 4481 adapter_->Shutdown(); |
4482 adapter_bluez->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); | 4482 adapter_bluez->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); |
4483 | 4483 |
4484 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, | 4484 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, |
4485 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. | 4485 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. |
4486 EXPECT_EQ(0, callback_count_); | 4486 EXPECT_EQ(0, callback_count_); |
4487 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); | 4487 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); |
4488 } | 4488 } |
4489 | 4489 |
4490 } // namespace bluez | 4490 } // namespace bluez |
OLD | NEW |