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

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 BluetoothLowEnergyDeviceMac::DidConnectPeripheral() 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
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)
1032 // Android incorrectly starts second discovery for devices that are already
1033 // connected.
1034 // TODO(crbug.com/718168): Remove once Android is fixed.
1035 EXPECT_EQ(2, gatt_discovery_attempts_);
1036 #else // !defined(OS_ANDROID)
1037 EXPECT_EQ(1, gatt_discovery_attempts_);
1038 #endif // defined(OS_ANDROID)
1039 EXPECT_EQ(2, observer.device_changed_count());
1030 EXPECT_EQ(1, gatt_connection_attempts_); 1040 EXPECT_EQ(1, gatt_connection_attempts_);
1031 EXPECT_EQ(1, callback_count_); 1041 EXPECT_EQ(1, callback_count_);
1032 EXPECT_EQ(0, error_callback_count_); 1042 EXPECT_EQ(0, error_callback_count_);
1033 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); 1043 EXPECT_TRUE(gatt_connections_[0]->IsConnected());
1034 1044
1035 // Become disconnected: 1045 // Become disconnected:
1036 SimulateGattDisconnection(device); 1046 SimulateGattDisconnection(device);
1037 base::RunLoop().RunUntilIdle(); 1047 base::RunLoop().RunUntilIdle();
1038 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); 1048 EXPECT_FALSE(gatt_connections_[0]->IsConnected());
1039 } 1049 }
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 ->GetPrimaryServicesByUUID(BluetoothUUID( 1608 ->GetPrimaryServicesByUUID(BluetoothUUID(
1599 BluetoothTestBase::kTestUUIDGenericAttribute)) 1609 BluetoothTestBase::kTestUUIDGenericAttribute))
1600 .empty()); 1610 .empty());
1601 1611
1602 EXPECT_NE(services[0]->GetIdentifier(), services[1]->GetIdentifier()); 1612 EXPECT_NE(services[0]->GetIdentifier(), services[1]->GetIdentifier());
1603 } 1613 }
1604 } 1614 }
1605 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1615 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1606 1616
1607 } // namespace device 1617 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698