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

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

Issue 2863643003: bluetooth: Adding #if and #endif around each tests (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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_service_unittest.cc » ('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_adapter.h" 5 #include "device/bluetooth/bluetooth_adapter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 EXPECT_EQ(2u, result.size()); 888 EXPECT_EQ(2u, result.size());
889 for (const auto& pair : result) { 889 for (const auto& pair : result) {
890 EXPECT_TRUE(adapter_->GetDevice(pair.first->GetAddress())); 890 EXPECT_TRUE(adapter_->GetDevice(pair.first->GetAddress()));
891 EXPECT_TRUE(pair.second.empty()); 891 EXPECT_TRUE(pair.second.empty());
892 } 892 }
893 EXPECT_EQ(BluetoothDevice::UUIDSet({BluetoothUUID(kTestUUIDGenericAccess)}), 893 EXPECT_EQ(BluetoothDevice::UUIDSet({BluetoothUUID(kTestUUIDGenericAccess)}),
894 RetrieveConnectedPeripheralServiceUUIDs()); 894 RetrieveConnectedPeripheralServiceUUIDs());
895 EXPECT_EQ(2, observer.device_added_count()); 895 EXPECT_EQ(2, observer.device_added_count());
896 EXPECT_EQ(2u, adapter_->GetDevices().size()); 896 EXPECT_EQ(2u, adapter_->GetDevices().size());
897 } 897 }
898 #endif // defined(OS_MACOSX)
898 899
900 #if defined(OS_MACOSX)
899 // Simulate two devices being connected before calling 901 // Simulate two devices being connected before calling
900 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with one service filter. 902 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with one service filter.
901 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceWithFilter) { 903 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceWithFilter) {
902 if (!PlatformSupportsLowEnergy()) { 904 if (!PlatformSupportsLowEnergy()) {
903 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 905 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
904 return; 906 return;
905 } 907 }
906 InitWithFakeAdapter(); 908 InitWithFakeAdapter();
907 TestBluetoothAdapterObserver observer(adapter_); 909 TestBluetoothAdapterObserver observer(adapter_);
908 910
(...skipping 11 matching lines...) Expand all
920 for (const auto& pair : result) { 922 for (const auto& pair : result) {
921 EXPECT_EQ(kTestDeviceAddress2, pair.first->GetAddress()); 923 EXPECT_EQ(kTestDeviceAddress2, pair.first->GetAddress());
922 EXPECT_TRUE(adapter_->GetDevice(pair.first->GetAddress())); 924 EXPECT_TRUE(adapter_->GetDevice(pair.first->GetAddress()));
923 EXPECT_EQ(BluetoothDevice::UUIDSet({heart_service_uuid}), pair.second); 925 EXPECT_EQ(BluetoothDevice::UUIDSet({heart_service_uuid}), pair.second);
924 } 926 }
925 EXPECT_EQ(BluetoothDevice::UUIDSet({heart_service_uuid}), 927 EXPECT_EQ(BluetoothDevice::UUIDSet({heart_service_uuid}),
926 RetrieveConnectedPeripheralServiceUUIDs()); 928 RetrieveConnectedPeripheralServiceUUIDs());
927 EXPECT_EQ(1, observer.device_added_count()); 929 EXPECT_EQ(1, observer.device_added_count());
928 EXPECT_EQ(1u, adapter_->GetDevices().size()); 930 EXPECT_EQ(1u, adapter_->GetDevices().size());
929 } 931 }
932 #endif // defined(OS_MACOSX)
930 933
934 #if defined(OS_MACOSX)
931 // Simulate two devices being connected before calling 935 // Simulate two devices being connected before calling
932 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with one service filter 936 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with one service filter
933 // that doesn't match. 937 // that doesn't match.
934 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceWithWrongFilter) { 938 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceWithWrongFilter) {
935 if (!PlatformSupportsLowEnergy()) { 939 if (!PlatformSupportsLowEnergy()) {
936 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 940 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
937 return; 941 return;
938 } 942 }
939 InitWithFakeAdapter(); 943 InitWithFakeAdapter();
940 TestBluetoothAdapterObserver observer(adapter_); 944 TestBluetoothAdapterObserver observer(adapter_);
941 945
942 SimulateConnectedLowEnergyDevice(ConnectedDeviceType::GENERIC_DEVICE); 946 SimulateConnectedLowEnergyDevice(ConnectedDeviceType::GENERIC_DEVICE);
943 SimulateConnectedLowEnergyDevice(ConnectedDeviceType::HEART_RATE_DEVICE); 947 SimulateConnectedLowEnergyDevice(ConnectedDeviceType::HEART_RATE_DEVICE);
944 BluetoothDiscoveryFilter discovery_filter(BLUETOOTH_TRANSPORT_LE); 948 BluetoothDiscoveryFilter discovery_filter(BLUETOOTH_TRANSPORT_LE);
945 discovery_filter.AddUUID(device::BluetoothUUID(kTestUUIDLinkLoss)); 949 discovery_filter.AddUUID(device::BluetoothUUID(kTestUUIDLinkLoss));
946 std::unordered_map<BluetoothDevice*, BluetoothDevice::UUIDSet> result = 950 std::unordered_map<BluetoothDevice*, BluetoothDevice::UUIDSet> result =
947 adapter_->RetrieveGattConnectedDevicesWithDiscoveryFilter( 951 adapter_->RetrieveGattConnectedDevicesWithDiscoveryFilter(
948 discovery_filter); 952 discovery_filter);
949 953
950 EXPECT_TRUE(result.empty()); 954 EXPECT_TRUE(result.empty());
951 EXPECT_EQ( 955 EXPECT_EQ(
952 BluetoothDevice::UUIDSet({device::BluetoothUUID(kTestUUIDLinkLoss)}), 956 BluetoothDevice::UUIDSet({device::BluetoothUUID(kTestUUIDLinkLoss)}),
953 RetrieveConnectedPeripheralServiceUUIDs()); 957 RetrieveConnectedPeripheralServiceUUIDs());
954 EXPECT_EQ(0, observer.device_added_count()); 958 EXPECT_EQ(0, observer.device_added_count());
955 EXPECT_EQ(0u, adapter_->GetDevices().size()); 959 EXPECT_EQ(0u, adapter_->GetDevices().size());
956 } 960 }
961 #endif // defined(OS_MACOSX)
957 962
963 #if defined(OS_MACOSX)
958 // Simulate two devices being connected before calling 964 // Simulate two devices being connected before calling
959 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with two service filters 965 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with two service filters
960 // that both match. 966 // that both match.
961 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceWithTwoFilters) { 967 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceWithTwoFilters) {
962 if (!PlatformSupportsLowEnergy()) { 968 if (!PlatformSupportsLowEnergy()) {
963 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 969 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
964 return; 970 return;
965 } 971 }
966 InitWithFakeAdapter(); 972 InitWithFakeAdapter();
967 TestBluetoothAdapterObserver observer(adapter_); 973 TestBluetoothAdapterObserver observer(adapter_);
(...skipping 24 matching lines...) Expand all
992 // Unknown device. 998 // Unknown device.
993 EXPECT_TRUE(false); 999 EXPECT_TRUE(false);
994 } 1000 }
995 } 1001 }
996 EXPECT_EQ( 1002 EXPECT_EQ(
997 BluetoothDevice::UUIDSet({generic_service_uuid, heart_service_uuid}), 1003 BluetoothDevice::UUIDSet({generic_service_uuid, heart_service_uuid}),
998 RetrieveConnectedPeripheralServiceUUIDs()); 1004 RetrieveConnectedPeripheralServiceUUIDs());
999 EXPECT_EQ(2, observer.device_added_count()); 1005 EXPECT_EQ(2, observer.device_added_count());
1000 EXPECT_EQ(2u, adapter_->GetDevices().size()); 1006 EXPECT_EQ(2u, adapter_->GetDevices().size());
1001 } 1007 }
1008 #endif // defined(OS_MACOSX)
1002 1009
1010 #if defined(OS_MACOSX)
1003 // Simulate two devices being connected before calling 1011 // Simulate two devices being connected before calling
1004 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with one service filter 1012 // RetrieveGattConnectedDevicesWithDiscoveryFilter() with one service filter
1005 // that one match device, and then 1013 // that one match device, and then
1006 // RetrieveGattConnectedDevicesWithDiscoveryFilter() again. 1014 // RetrieveGattConnectedDevicesWithDiscoveryFilter() again.
1007 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceTwice) { 1015 TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceTwice) {
1008 if (!PlatformSupportsLowEnergy()) { 1016 if (!PlatformSupportsLowEnergy()) {
1009 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1017 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1010 return; 1018 return;
1011 } 1019 }
1012 InitWithFakeAdapter(); 1020 InitWithFakeAdapter();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 } 1054 }
1047 EXPECT_EQ(BluetoothDevice::UUIDSet({heart_service_uuid}), 1055 EXPECT_EQ(BluetoothDevice::UUIDSet({heart_service_uuid}),
1048 RetrieveConnectedPeripheralServiceUUIDs()); 1056 RetrieveConnectedPeripheralServiceUUIDs());
1049 1057
1050 EXPECT_EQ(0, observer.device_added_count()); 1058 EXPECT_EQ(0, observer.device_added_count());
1051 EXPECT_EQ(1u, adapter_->GetDevices().size()); 1059 EXPECT_EQ(1u, adapter_->GetDevices().size());
1052 } 1060 }
1053 #endif // defined(OS_MACOSX) 1061 #endif // defined(OS_MACOSX)
1054 1062
1055 } // namespace device 1063 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698