| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/bluetooth/bluetooth_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 111 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| 112 | 112 |
| 113 // TODO(scheib): Test with a device with no name. http://crbug.com/506415 | 113 // TODO(scheib): Test with a device with no name. http://crbug.com/506415 |
| 114 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which | 114 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which |
| 115 // requires string resources to be loaded. For that, something like | 115 // requires string resources to be loaded. For that, something like |
| 116 // InitSharedInstance must be run. See unittest files that call that. It will | 116 // InitSharedInstance must be run. See unittest files that call that. It will |
| 117 // also require build configuration to generate string resources into a .pak | 117 // also require build configuration to generate string resources into a .pak |
| 118 // file. | 118 // file. |
| 119 | 119 |
| 120 #if defined(OS_ANDROID) | 120 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 121 // Basic CreateGattConnection test. | 121 // Basic CreateGattConnection test. |
| 122 TEST_F(BluetoothTest, CreateGattConnection) { | 122 TEST_F(BluetoothTest, CreateGattConnection) { |
| 123 InitWithFakeAdapter(); | 123 InitWithFakeAdapter(); |
| 124 StartLowEnergyDiscoverySession(); | 124 StartLowEnergyDiscoverySession(); |
| 125 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | 125 BluetoothDevice* device = DiscoverLowEnergyDevice(3); |
| 126 | 126 |
| 127 ResetEventCounts(); | 127 ResetEventCounts(); |
| 128 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), | 128 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), |
| 129 GetConnectErrorCallback(Call::NOT_EXPECTED)); | 129 GetConnectErrorCallback(Call::NOT_EXPECTED)); |
| 130 SimulateGattConnection(device); | 130 SimulateGattConnection(device); |
| 131 ASSERT_EQ(1u, gatt_connections_.size()); | 131 ASSERT_EQ(1u, gatt_connections_.size()); |
| 132 EXPECT_TRUE(device->IsGattConnected()); | 132 EXPECT_TRUE(device->IsGattConnected()); |
| 133 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); | 133 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); |
| 134 } | 134 } |
| 135 #endif // defined(OS_ANDROID) | 135 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| 136 | 136 |
| 137 #if defined(OS_ANDROID) | 137 #if defined(OS_ANDROID) |
| 138 // Creates BluetoothGattConnection instances and tests that the interface | 138 // Creates BluetoothGattConnection instances and tests that the interface |
| 139 // functions even when some Disconnect and the BluetoothDevice is destroyed. | 139 // functions even when some Disconnect and the BluetoothDevice is destroyed. |
| 140 TEST_F(BluetoothTest, BluetoothGattConnection) { | 140 TEST_F(BluetoothTest, BluetoothGattConnection) { |
| 141 InitWithFakeAdapter(); | 141 InitWithFakeAdapter(); |
| 142 StartLowEnergyDiscoverySession(); | 142 StartLowEnergyDiscoverySession(); |
| 143 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | 143 BluetoothDevice* device = DiscoverLowEnergyDevice(3); |
| 144 std::string device_address = device->GetAddress(); | 144 std::string device_address = device->GetAddress(); |
| 145 | 145 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 ResetEventCounts(); | 475 ResetEventCounts(); |
| 476 SimulateGattConnection(device); | 476 SimulateGattConnection(device); |
| 477 EXPECT_EQ(1, gatt_discovery_attempts_); | 477 EXPECT_EQ(1, gatt_discovery_attempts_); |
| 478 | 478 |
| 479 SimulateGattServicesDiscoveryError(device); | 479 SimulateGattServicesDiscoveryError(device); |
| 480 EXPECT_EQ(0u, device->GetGattServices().size()); | 480 EXPECT_EQ(0u, device->GetGattServices().size()); |
| 481 } | 481 } |
| 482 #endif // defined(OS_ANDROID) | 482 #endif // defined(OS_ANDROID) |
| 483 | 483 |
| 484 } // namespace device | 484 } // namespace device |
| OLD | NEW |