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

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

Issue 2102813002: If location services are turned off, have the BT chooser prompt the user to turn them on. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-fix-testing
Patch Set: Address tedchoc's comments Created 4 years, 5 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_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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 return; 545 return;
546 } 546 }
547 547
548 StartLowEnergyDiscoverySessionExpectedToFail(); 548 StartLowEnergyDiscoverySessionExpectedToFail();
549 549
550 EXPECT_EQ(0, callback_count_); 550 EXPECT_EQ(0, callback_count_);
551 EXPECT_EQ(1, error_callback_count_); 551 EXPECT_EQ(1, error_callback_count_);
552 } 552 }
553 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) 553 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
554 554
555 // Android-only: Only Android requires location services to be turned on to scan
556 // for Bluetooth devices.
557 #if defined(OS_ANDROID)
558 // Checks that discovery fails (instead of hanging) when location services are
559 // turned off.
560 TEST_F(BluetoothTest, NoLocationServices) {
561 if (!PlatformSupportsLowEnergy()) {
562 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
563 return;
564 }
565 InitWithFakeAdapter();
566 TestBluetoothAdapterObserver observer(adapter_);
567
568 SimulateLocationServicesOff();
569
570 StartLowEnergyDiscoverySessionExpectedToFail();
571
572 EXPECT_EQ(0, callback_count_);
573 EXPECT_EQ(1, error_callback_count_);
574 }
575 #endif // defined(OS_ANDROID)
576
555 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 577 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
556 // Discovers a device. 578 // Discovers a device.
557 TEST_F(BluetoothTest, DiscoverLowEnergyDevice) { 579 TEST_F(BluetoothTest, DiscoverLowEnergyDevice) {
558 if (!PlatformSupportsLowEnergy()) { 580 if (!PlatformSupportsLowEnergy()) {
559 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 581 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
560 return; 582 return;
561 } 583 }
562 InitWithFakeAdapter(); 584 InitWithFakeAdapter();
563 TestBluetoothAdapterObserver observer(adapter_); 585 TestBluetoothAdapterObserver observer(adapter_);
564 586
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 GetConnectErrorCallback(Call::NOT_EXPECTED)); 866 GetConnectErrorCallback(Call::NOT_EXPECTED));
845 SimulateGattConnection(device); 867 SimulateGattConnection(device);
846 EXPECT_EQ(1u, adapter_->GetDevices().size()); 868 EXPECT_EQ(1u, adapter_->GetDevices().size());
847 RemoveTimedOutDevices(); 869 RemoveTimedOutDevices();
848 EXPECT_EQ(0, observer.device_removed_count()); 870 EXPECT_EQ(0, observer.device_removed_count());
849 EXPECT_EQ(1u, adapter_->GetDevices().size()); 871 EXPECT_EQ(1u, adapter_->GetDevices().size());
850 } 872 }
851 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) 873 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
852 874
853 } // namespace device 875 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698