| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_classic_win_fake.h" | 5 #include "device/bluetooth/bluetooth_classic_win_fake.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace device { | 9 namespace device { |
| 10 namespace win { | 10 namespace win { |
| 11 | 11 |
| 12 BluetoothClassicWrapperFake::BluetoothClassicWrapperFake() {} | 12 BluetoothClassicWrapperFake::BluetoothClassicWrapperFake() |
| 13 : last_error_(ERROR_SUCCESS) {} |
| 13 BluetoothClassicWrapperFake::~BluetoothClassicWrapperFake() {} | 14 BluetoothClassicWrapperFake::~BluetoothClassicWrapperFake() {} |
| 14 | 15 |
| 15 HBLUETOOTH_RADIO_FIND BluetoothClassicWrapperFake::FindFirstRadio( | 16 HBLUETOOTH_RADIO_FIND BluetoothClassicWrapperFake::FindFirstRadio( |
| 16 const BLUETOOTH_FIND_RADIO_PARAMS* params, | 17 const BLUETOOTH_FIND_RADIO_PARAMS* params, |
| 17 HANDLE* out_handle) { | 18 HANDLE* out_handle) { |
| 18 NOTIMPLEMENTED(); | 19 if (simulated_radios_) { |
| 20 *out_handle = (PVOID)simulated_radios_.get(); |
| 21 last_error_ = ERROR_SUCCESS; |
| 22 return *out_handle; |
| 23 } |
| 24 last_error_ = ERROR_NO_MORE_ITEMS; |
| 19 return NULL; | 25 return NULL; |
| 20 } | 26 } |
| 21 | 27 |
| 22 DWORD BluetoothClassicWrapperFake::GetRadioInfo( | 28 DWORD BluetoothClassicWrapperFake::GetRadioInfo( |
| 23 HANDLE handle, | 29 HANDLE handle, |
| 24 PBLUETOOTH_RADIO_INFO out_radio_info) { | 30 PBLUETOOTH_RADIO_INFO out_radio_info) { |
| 25 NOTIMPLEMENTED(); | 31 if (simulated_radios_) { |
| 26 return ERROR_SUCCESS; | 32 *out_radio_info = simulated_radios_->radio_info; |
| 33 last_error_ = ERROR_SUCCESS; |
| 34 return last_error_; |
| 35 } |
| 36 last_error_ = ERROR_INVALID_HANDLE; |
| 37 return last_error_; |
| 27 } | 38 } |
| 28 | 39 |
| 29 BOOL BluetoothClassicWrapperFake::FindRadioClose(HBLUETOOTH_RADIO_FIND handle) { | 40 BOOL BluetoothClassicWrapperFake::FindRadioClose(HBLUETOOTH_RADIO_FIND handle) { |
| 30 NOTIMPLEMENTED(); | |
| 31 return TRUE; | 41 return TRUE; |
| 32 } | 42 } |
| 33 | 43 |
| 34 BOOL BluetoothClassicWrapperFake::IsConnectable(HANDLE handle) { | 44 BOOL BluetoothClassicWrapperFake::IsConnectable(HANDLE handle) { |
| 35 NOTIMPLEMENTED(); | 45 if (simulated_radios_) { |
| 36 return TRUE; | 46 last_error_ = ERROR_SUCCESS; |
| 47 return simulated_radios_->is_connectable; |
| 48 } |
| 49 last_error_ = ERROR_INVALID_HANDLE; |
| 50 return FALSE; |
| 37 } | 51 } |
| 38 | 52 |
| 39 HBLUETOOTH_DEVICE_FIND BluetoothClassicWrapperFake::FindFirstDevice( | 53 HBLUETOOTH_DEVICE_FIND BluetoothClassicWrapperFake::FindFirstDevice( |
| 40 const BLUETOOTH_DEVICE_SEARCH_PARAMS* params, | 54 const BLUETOOTH_DEVICE_SEARCH_PARAMS* params, |
| 41 BLUETOOTH_DEVICE_INFO* out_device_info) { | 55 BLUETOOTH_DEVICE_INFO* out_device_info) { |
| 42 NOTIMPLEMENTED(); | 56 last_error_ = ERROR_NO_MORE_ITEMS; |
| 43 return NULL; | 57 return NULL; |
| 44 } | 58 } |
| 45 | 59 |
| 46 BOOL BluetoothClassicWrapperFake::FindNextDevice( | 60 BOOL BluetoothClassicWrapperFake::FindNextDevice( |
| 47 HBLUETOOTH_DEVICE_FIND handle, | 61 HBLUETOOTH_DEVICE_FIND handle, |
| 48 BLUETOOTH_DEVICE_INFO* out_device_info) { | 62 BLUETOOTH_DEVICE_INFO* out_device_info) { |
| 49 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
| 50 return TRUE; | 64 return TRUE; |
| 51 } | 65 } |
| 52 | 66 |
| 53 BOOL BluetoothClassicWrapperFake::FindDeviceClose( | 67 BOOL BluetoothClassicWrapperFake::FindDeviceClose( |
| 54 HBLUETOOTH_DEVICE_FIND handle) { | 68 HBLUETOOTH_DEVICE_FIND handle) { |
| 55 NOTIMPLEMENTED(); | |
| 56 return TRUE; | 69 return TRUE; |
| 57 } | 70 } |
| 58 | 71 |
| 59 BOOL BluetoothClassicWrapperFake::EnableDiscovery(HANDLE handle, | 72 BOOL BluetoothClassicWrapperFake::EnableDiscovery(HANDLE handle, |
| 60 BOOL is_enable) { | 73 BOOL is_enable) { |
| 61 NOTIMPLEMENTED(); | |
| 62 return TRUE; | 74 return TRUE; |
| 63 } | 75 } |
| 64 | 76 |
| 65 BOOL BluetoothClassicWrapperFake::EnableIncomingConnections(HANDLE handle, | 77 BOOL BluetoothClassicWrapperFake::EnableIncomingConnections(HANDLE handle, |
| 66 BOOL is_enable) { | 78 BOOL is_enable) { |
| 67 NOTIMPLEMENTED(); | |
| 68 return TRUE; | 79 return TRUE; |
| 69 } | 80 } |
| 81 |
| 82 DWORD BluetoothClassicWrapperFake::LastError() { |
| 83 return last_error_; |
| 84 } |
| 85 |
| 86 BluetoothRadio* BluetoothClassicWrapperFake::SimulateARadio( |
| 87 base::string16 name, |
| 88 BLUETOOTH_ADDRESS address) { |
| 89 BluetoothRadio* radio = new BluetoothRadio(); |
| 90 radio->is_connectable = true; // set it connectable by default. |
| 91 size_t length = |
| 92 ((name.size() > BLUETOOTH_MAX_NAME_SIZE) ? BLUETOOTH_MAX_NAME_SIZE |
| 93 : name.size()); |
| 94 wcsncpy(radio->radio_info.szName, name.c_str(), length); |
| 95 radio->radio_info.address = address; |
| 96 simulated_radios_.reset(radio); |
| 97 return radio; |
| 98 } |
| 70 } // namespace device | 99 } // namespace device |
| 71 } // namespace win | 100 } // namespace win |
| OLD | NEW |