Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: device/bluetooth/bluetooth_device_unittest.cc

Issue 2727683003: bluetooth: Clean up connection errors (Closed)
Patch Set: format Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 return; 1107 return;
1108 } 1108 }
1109 InitWithFakeAdapter(); 1109 InitWithFakeAdapter();
1110 StartLowEnergyDiscoverySession(); 1110 StartLowEnergyDiscoverySession();
1111 BluetoothDevice* device = SimulateLowEnergyDevice(3); 1111 BluetoothDevice* device = SimulateLowEnergyDevice(3);
1112 1112
1113 ResetEventCounts(); 1113 ResetEventCounts();
1114 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED), 1114 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED),
1115 GetConnectErrorCallback(Call::EXPECTED)); 1115 GetConnectErrorCallback(Call::EXPECTED));
1116 EXPECT_EQ(1, gatt_connection_attempts_); 1116 EXPECT_EQ(1, gatt_connection_attempts_);
1117 SimulateGattConnectionError(device, BluetoothDevice::ERROR_AUTH_FAILED);
1118 SimulateGattConnectionError(device, BluetoothDevice::ERROR_FAILED); 1117 SimulateGattConnectionError(device, BluetoothDevice::ERROR_FAILED);
1119 #if defined(OS_ANDROID) 1118 SimulateGattConnectionError(device, BluetoothDevice::ERROR_UNKNOWN);
1120 // TODO: Change to ERROR_AUTH_FAILED. We should be getting a callback
1121 // only with the first error, but our android framework doesn't yet
1122 // support sending different errors.
1123 // http://crbug.com/578191
1124 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_); 1119 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_);
1125 #else
1126 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_FAILED, last_connect_error_code_);
1127 #endif
1128 for (const auto& connection : gatt_connections_) 1120 for (const auto& connection : gatt_connections_)
1129 EXPECT_FALSE(connection->IsConnected()); 1121 EXPECT_FALSE(connection->IsConnected());
1130 } 1122 }
1131 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) 1123 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
1132 1124
1133 #if defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_MACOSX) 1125 #if defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_MACOSX)
1134 TEST_F(BluetoothTest, GattServices_ObserversCalls) { 1126 TEST_F(BluetoothTest, GattServices_ObserversCalls) {
1135 if (!PlatformSupportsLowEnergy()) { 1127 if (!PlatformSupportsLowEnergy()) {
1136 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1128 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1137 return; 1129 return;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 1324
1333 BluetoothDevice* device2 = SimulateLowEnergyDevice(6); 1325 BluetoothDevice* device2 = SimulateLowEnergyDevice(6);
1334 EXPECT_EQ(BLUETOOTH_TRANSPORT_DUAL, device2->GetType()); 1326 EXPECT_EQ(BLUETOOTH_TRANSPORT_DUAL, device2->GetType());
1335 1327
1336 BluetoothDevice* device3 = SimulateClassicDevice(); 1328 BluetoothDevice* device3 = SimulateClassicDevice();
1337 EXPECT_EQ(BLUETOOTH_TRANSPORT_CLASSIC, device3->GetType()); 1329 EXPECT_EQ(BLUETOOTH_TRANSPORT_CLASSIC, device3->GetType());
1338 } 1330 }
1339 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX) 1331 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
1340 1332
1341 } // namespace device 1333 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698