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

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

Issue 2853933002: bluetooth: macOS: Support for extra didConnectPeripheral event from macOS. (Closed)
Patch Set: Adding Android bug Created 3 years, 7 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
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_low_energy_device_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1008
1009 #if defined(OS_ANDROID) || defined(OS_MACOSX) 1009 #if defined(OS_ANDROID) || defined(OS_MACOSX)
1010 // Calls CreateGattConnection then simulates multiple connections from platform. 1010 // Calls CreateGattConnection then simulates multiple connections from platform.
1011 TEST_F(BluetoothTest, 1011 TEST_F(BluetoothTest,
1012 BluetoothGattConnection_ConnectWithMultipleOSConnections) { 1012 BluetoothGattConnection_ConnectWithMultipleOSConnections) {
1013 if (!PlatformSupportsLowEnergy()) { 1013 if (!PlatformSupportsLowEnergy()) {
1014 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1014 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1015 return; 1015 return;
1016 } 1016 }
1017 InitWithFakeAdapter(); 1017 InitWithFakeAdapter();
1018 TestBluetoothAdapterObserver observer(adapter_);
1018 StartLowEnergyDiscoverySession(); 1019 StartLowEnergyDiscoverySession();
1019 BluetoothDevice* device = SimulateLowEnergyDevice(3); 1020 BluetoothDevice* device = SimulateLowEnergyDevice(3);
1020 1021
1021 // CreateGattConnection, & multiple connections from platform only invoke 1022 // CreateGattConnection, & multiple connections from platform only invoke
1022 // callbacks once: 1023 // callbacks once:
1023 ResetEventCounts(); 1024 ResetEventCounts();
1024 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 1025 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
1025 GetConnectErrorCallback(Call::NOT_EXPECTED)); 1026 GetConnectErrorCallback(Call::NOT_EXPECTED));
1026 SimulateGattConnection(device); 1027 SimulateGattConnection(device);
1027 SimulateGattConnection(device); 1028 SimulateGattConnection(device);
1028 base::RunLoop().RunUntilIdle(); 1029 base::RunLoop().RunUntilIdle();
1029 1030
1031 #if !defined(OS_ANDROID)
ortuno 2017/05/04 00:31:03 #if defined(OS_ANDROID) EXPECT_EQ(2, gatt_discov
jlebel 2017/05/04 01:18:38 Done.
1032 // TODO(crbug.com/718168): on Android gatt_discovery_attempts_ is 2.
ortuno 2017/05/04 00:31:03 // Android incorrectly starts second discovery for
jlebel 2017/05/04 01:18:38 Done.
1033 EXPECT_EQ(1, gatt_discovery_attempts_);
1034 #endif // !defined(OS_ANDROID)
1035 EXPECT_EQ(2, observer.device_changed_count());
1030 EXPECT_EQ(1, gatt_connection_attempts_); 1036 EXPECT_EQ(1, gatt_connection_attempts_);
1031 EXPECT_EQ(1, callback_count_); 1037 EXPECT_EQ(1, callback_count_);
1032 EXPECT_EQ(0, error_callback_count_); 1038 EXPECT_EQ(0, error_callback_count_);
1033 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); 1039 EXPECT_TRUE(gatt_connections_[0]->IsConnected());
1034 1040
1035 // Become disconnected: 1041 // Become disconnected:
1036 SimulateGattDisconnection(device); 1042 SimulateGattDisconnection(device);
1037 base::RunLoop().RunUntilIdle(); 1043 base::RunLoop().RunUntilIdle();
1038 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); 1044 EXPECT_FALSE(gatt_connections_[0]->IsConnected());
1039 } 1045 }
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 ->GetPrimaryServicesByUUID(BluetoothUUID( 1604 ->GetPrimaryServicesByUUID(BluetoothUUID(
1599 BluetoothTestBase::kTestUUIDGenericAttribute)) 1605 BluetoothTestBase::kTestUUIDGenericAttribute))
1600 .empty()); 1606 .empty());
1601 1607
1602 EXPECT_NE(services[0]->GetIdentifier(), services[1]->GetIdentifier()); 1608 EXPECT_NE(services[0]->GetIdentifier(), services[1]->GetIdentifier());
1603 } 1609 }
1604 } 1610 }
1605 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1611 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1606 1612
1607 } // namespace device 1613 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_low_energy_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698