OLD | NEW |
---|---|
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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "device/bluetooth/bluetooth_adapter.h" | 9 #include "device/bluetooth/bluetooth_adapter.h" |
10 #include "device/bluetooth/bluetooth_adapter_mac.h" | 10 #include "device/bluetooth/bluetooth_adapter_mac.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 void RemoveTimedOutDevices() { adapter_mac_->RemoveTimedOutDevices(); } | 112 void RemoveTimedOutDevices() { adapter_mac_->RemoveTimedOutDevices(); } |
113 | 113 |
114 bool SetMockCentralManager(CBCentralManagerState desired_state) { | 114 bool SetMockCentralManager(CBCentralManagerState desired_state) { |
115 if (!BluetoothAdapterMac::IsLowEnergyAvailable()) { | 115 if (!BluetoothAdapterMac::IsLowEnergyAvailable()) { |
116 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 116 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
117 return false; | 117 return false; |
118 } | 118 } |
119 mock_central_manager_ = [[MockCentralManager alloc] init]; | 119 mock_central_manager_ = [[MockCentralManager alloc] init]; |
120 [mock_central_manager_ setState:desired_state]; | 120 [mock_central_manager_ setState:desired_state]; |
121 adapter_mac_->SetCentralManagerForTesting(mock_central_manager_); | 121 adapter_mac_->SetCentralManagerForTesting(mock_central_manager_); |
122 [mock_central_manager_ release]; | |
msarda
2016/02/11 10:55:38
In Chromium, you should not call release on an obj
jlebel
2016/02/19 11:02:35
Done.
| |
122 return true; | 123 return true; |
123 } | 124 } |
124 | 125 |
125 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter) { | 126 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter) { |
126 adapter_mac_->AddDiscoverySession( | 127 adapter_mac_->AddDiscoverySession( |
127 discovery_filter, | 128 discovery_filter, |
128 base::Bind(&BluetoothAdapterMacTest::Callback, base::Unretained(this)), | 129 base::Bind(&BluetoothAdapterMacTest::Callback, base::Unretained(this)), |
129 base::Bind(&BluetoothAdapterMacTest::DiscoveryErrorCallback, | 130 base::Bind(&BluetoothAdapterMacTest::DiscoveryErrorCallback, |
130 base::Unretained(this))); | 131 base::Unretained(this))); |
131 } | 132 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 EXPECT_EQ(1, NumDevices()); | 326 EXPECT_EQ(1, NumDevices()); |
326 EXPECT_TRUE(DevicePresent(mock_peripheral)); | 327 EXPECT_TRUE(DevicePresent(mock_peripheral)); |
327 | 328 |
328 // Check that object pointed to by |device| is deleted by the adapter. | 329 // Check that object pointed to by |device| is deleted by the adapter. |
329 RemoveTimedOutDevices(); | 330 RemoveTimedOutDevices(); |
330 EXPECT_EQ(0, NumDevices()); | 331 EXPECT_EQ(0, NumDevices()); |
331 EXPECT_FALSE(DevicePresent(mock_peripheral)); | 332 EXPECT_FALSE(DevicePresent(mock_peripheral)); |
332 } | 333 } |
333 | 334 |
334 } // namespace device | 335 } // namespace device |
OLD | NEW |