OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "device/bluetooth/test/bluetooth_test_win.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "device/bluetooth/bluetooth_adapter_win.h" |
| 9 #include "device/bluetooth/bluetooth_low_energy_win.h" |
| 10 |
| 11 namespace device { |
| 12 BluetoothTestWin::BluetoothTestWin() |
| 13 : ui_task_runner_(new base::TestSimpleTaskRunner()), |
| 14 bluetooth_task_runner_(new base::TestSimpleTaskRunner()) {} |
| 15 BluetoothTestWin::~BluetoothTestWin() {} |
| 16 |
| 17 bool BluetoothTestWin::PlatformSupportsLowEnergy() { |
| 18 return win::IsBluetoothLowEnergySupported(); |
| 19 } |
| 20 |
| 21 void BluetoothTestWin::AdapterInitCallback() {} |
| 22 |
| 23 void BluetoothTestWin::InitWithDefaultAdapter() { |
| 24 adapter_ = new BluetoothAdapterWin(base::Bind( |
| 25 &BluetoothTestWin::AdapterInitCallback, base::Unretained(this))); |
| 26 adapter_win_ = static_cast<BluetoothAdapterWin*>(adapter_.get()); |
| 27 adapter_win_->Init(); |
| 28 } |
| 29 |
| 30 void BluetoothTestWin::InitWithoutDefaultAdapter() { |
| 31 adapter_ = new BluetoothAdapterWin(base::Bind( |
| 32 &BluetoothTestWin::AdapterInitCallback, base::Unretained(this))); |
| 33 adapter_win_ = static_cast<BluetoothAdapterWin*>(adapter_.get()); |
| 34 adapter_win_->InitForTest(ui_task_runner_, bluetooth_task_runner_); |
| 35 } |
| 36 |
| 37 void BluetoothTestWin::InitWithFakeAdapter() { |
| 38 adapter_ = new BluetoothAdapterWin(base::Bind( |
| 39 &BluetoothTestWin::AdapterInitCallback, base::Unretained(this))); |
| 40 adapter_win_ = static_cast<BluetoothAdapterWin*>(adapter_.get()); |
| 41 adapter_win_->InitForTest(ui_task_runner_, bluetooth_task_runner_); |
| 42 BluetoothTaskManagerWin::AdapterState* adapter_state = |
| 43 new BluetoothTaskManagerWin::AdapterState(); |
| 44 adapter_state->name = kTestAdapterName; |
| 45 adapter_state->address = kTestAdapterAddress; |
| 46 adapter_state->powered = true; |
| 47 adapter_win_->AdapterStateChanged(*adapter_state); |
| 48 } |
| 49 |
| 50 bool BluetoothTestWin::DenyPermission() { |
| 51 return false; |
| 52 } |
| 53 } |
OLD | NEW |