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

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

Issue 2853933002: bluetooth: macOS: Support for extra didConnectPeripheral event from macOS. (Closed)
Patch Set: 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 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1020
1021 #if defined(OS_ANDROID) || defined(OS_MACOSX) 1021 #if defined(OS_ANDROID) || defined(OS_MACOSX)
1022 // Calls CreateGattConnection then simulates multiple connections from platform. 1022 // Calls CreateGattConnection then simulates multiple connections from platform.
1023 TEST_F(BluetoothTest, 1023 TEST_F(BluetoothTest,
1024 BluetoothGattConnection_ConnectWithMultipleOSConnections) { 1024 BluetoothGattConnection_ConnectWithMultipleOSConnections) {
1025 if (!PlatformSupportsLowEnergy()) { 1025 if (!PlatformSupportsLowEnergy()) {
1026 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1026 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1027 return; 1027 return;
1028 } 1028 }
1029 InitWithFakeAdapter(); 1029 InitWithFakeAdapter();
1030 TestBluetoothAdapterObserver observer(adapter_);
1030 StartLowEnergyDiscoverySession(); 1031 StartLowEnergyDiscoverySession();
1031 BluetoothDevice* device = SimulateLowEnergyDevice(3); 1032 BluetoothDevice* device = SimulateLowEnergyDevice(3);
1032 1033
1033 // CreateGattConnection, & multiple connections from platform only invoke 1034 // CreateGattConnection, & multiple connections from platform only invoke
1034 // callbacks once: 1035 // callbacks once:
1035 ResetEventCounts(); 1036 ResetEventCounts();
1036 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 1037 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
1037 GetConnectErrorCallback(Call::NOT_EXPECTED)); 1038 GetConnectErrorCallback(Call::NOT_EXPECTED));
1038 SimulateGattConnection(device); 1039 SimulateGattConnection(device);
1039 SimulateGattConnection(device); 1040 SimulateGattConnection(device);
1040 base::RunLoop().RunUntilIdle(); 1041 base::RunLoop().RunUntilIdle();
1041 1042
1043 EXPECT_EQ(1, gatt_discovery_attempts_);
jlebel 2017/05/02 19:54:46 For Android, gatt_discovery_attempts_ is 2. So eac
ortuno 2017/05/02 23:36:45 D: That's definitely a bug in Android. Just open a
jlebel 2017/05/03 21:16:19 Done.
1044 EXPECT_EQ(2, observer.device_changed_count());
1042 EXPECT_EQ(1, gatt_connection_attempts_); 1045 EXPECT_EQ(1, gatt_connection_attempts_);
1043 EXPECT_EQ(1, callback_count_); 1046 EXPECT_EQ(1, callback_count_);
1044 EXPECT_EQ(0, error_callback_count_); 1047 EXPECT_EQ(0, error_callback_count_);
1045 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); 1048 EXPECT_TRUE(gatt_connections_[0]->IsConnected());
1046 1049
1047 // Become disconnected: 1050 // Become disconnected:
1048 SimulateGattDisconnection(device); 1051 SimulateGattDisconnection(device);
1049 base::RunLoop().RunUntilIdle(); 1052 base::RunLoop().RunUntilIdle();
1050 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); 1053 EXPECT_FALSE(gatt_connections_[0]->IsConnected());
1051 } 1054 }
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 ->GetPrimaryServicesByUUID(BluetoothUUID( 1613 ->GetPrimaryServicesByUUID(BluetoothUUID(
1611 BluetoothTestBase::kTestUUIDGenericAttribute)) 1614 BluetoothTestBase::kTestUUIDGenericAttribute))
1612 .empty()); 1615 .empty());
1613 1616
1614 EXPECT_NE(services[0]->GetIdentifier(), services[1]->GetIdentifier()); 1617 EXPECT_NE(services[0]->GetIdentifier(), services[1]->GetIdentifier());
1615 } 1618 }
1616 } 1619 }
1617 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1620 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1618 1621
1619 } // namespace device 1622 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698