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

Side by Side Diff: device/bluetooth/bluetooth_adapter_mac_unittest.mm

Issue 1228863002: Runtime checks so that CoreBluetooth only used on >= 10.10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timeinfo
Patch Set: CHECK->DCHECK Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/test/test_simple_task_runner.h" 6 #include "base/test/test_simple_task_runner.h"
7 #include "device/bluetooth/bluetooth_adapter.h" 7 #include "device/bluetooth/bluetooth_adapter.h"
8 #include "device/bluetooth/bluetooth_adapter_mac.h" 8 #include "device/bluetooth/bluetooth_adapter_mac.h"
9 #include "device/bluetooth/bluetooth_discovery_session.h" 9 #include "device/bluetooth/bluetooth_discovery_session.h"
10 #include "device/bluetooth/test/mock_bluetooth_central_manager_mac.h" 10 #include "device/bluetooth/test/mock_bluetooth_central_manager_mac.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace device { 13 namespace device {
14 14
15 class BluetoothAdapterMacTest : public testing::Test { 15 class BluetoothAdapterMacTest : public testing::Test {
16 public: 16 public:
17 BluetoothAdapterMacTest() 17 BluetoothAdapterMacTest()
18 : ui_task_runner_(new base::TestSimpleTaskRunner()), 18 : ui_task_runner_(new base::TestSimpleTaskRunner()),
19 adapter_(new BluetoothAdapterMac()), 19 adapter_(new BluetoothAdapterMac()),
20 adapter_mac_(static_cast<BluetoothAdapterMac*>(adapter_.get())), 20 adapter_mac_(static_cast<BluetoothAdapterMac*>(adapter_.get())),
21 callback_count_(0), 21 callback_count_(0),
22 error_callback_count_(0) { 22 error_callback_count_(0) {
23 adapter_mac_->InitForTest(ui_task_runner_); 23 adapter_mac_->InitForTest(ui_task_runner_);
24 } 24 }
25 25
26 // Helper methods for setup and access to BluetoothAdapterMacTest's members. 26 // Helper methods for setup and access to BluetoothAdapterMacTest's members.
27 bool SetMockCentralManager() { 27 bool SetMockCentralManager() {
28 Class aClass = NSClassFromString(@"CBCentralManager"); 28 if (!BluetoothAdapterMac::IsLowEnergyAvailable()) {
29 if (aClass == nil) { 29 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
30 LOG(WARNING) << "CoreBluetooth not available, skipping unit test.";
31 return false; 30 return false;
32 } 31 }
33 mock_central_manager_ = [[MockCentralManager alloc] init]; 32 mock_central_manager_ = [[MockCentralManager alloc] init];
34 adapter_mac_->low_energy_discovery_manager_->SetManagerForTesting( 33 adapter_mac_->low_energy_discovery_manager_->SetManagerForTesting(
35 mock_central_manager_); 34 mock_central_manager_);
36 return true; 35 return true;
37 } 36 }
38 37
39 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter) { 38 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter) {
40 adapter_mac_->AddDiscoverySession( 39 adapter_mac_->AddDiscoverySession(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 RemoveDiscoverySession(discovery_filter.get()); 153 RemoveDiscoverySession(discovery_filter.get());
155 EXPECT_EQ(0, callback_count_); 154 EXPECT_EQ(0, callback_count_);
156 EXPECT_EQ(1, error_callback_count_); 155 EXPECT_EQ(1, error_callback_count_);
157 EXPECT_EQ(0, NumDiscoverySessions()); 156 EXPECT_EQ(0, NumDiscoverySessions());
158 157
159 // Check that stopScan was not called. 158 // Check that stopScan was not called.
160 EXPECT_EQ(0, [mock_central_manager_ stopScanCallCount]); 159 EXPECT_EQ(0, [mock_central_manager_ stopScanCallCount]);
161 } 160 }
162 161
163 } // namespace device 162 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac.mm ('k') | device/bluetooth/bluetooth_low_energy_device_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698