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

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

Issue 1676073002: Implement BluetoothLowEnergyWrapperFake for Bluetooth test fixture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 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 if (simulated_radios_.get() != nullptr) { 19 if (simulated_radios_.get() != nullptr) {
19 *out_handle = (PVOID)simulated_radios_.get(); 20 *out_handle = (PVOID)simulated_radios_.get();
21 last_error_ = ERROR_SUCCESS;
20 return *out_handle; 22 return *out_handle;
21 } 23 }
24 last_error_ = ERROR_NO_MORE_ITEMS;
22 return NULL; 25 return NULL;
23 } 26 }
24 27
25 DWORD BluetoothClassicWrapperFake::GetRadioInfo( 28 DWORD BluetoothClassicWrapperFake::GetRadioInfo(
26 HANDLE handle, 29 HANDLE handle,
27 PBLUETOOTH_RADIO_INFO out_radio_info) { 30 PBLUETOOTH_RADIO_INFO out_radio_info) {
28 if (simulated_radios_.get() != nullptr) { 31 if (simulated_radios_.get() != nullptr) {
29 *out_radio_info = simulated_radios_->radio_info; 32 *out_radio_info = simulated_radios_->radio_info;
33 last_error_ = ERROR_SUCCESS;
34 return last_error_;
30 } 35 }
31 return ERROR_SUCCESS; 36 last_error_ = ERROR_INVALID_HANDLE;
37 return last_error_;
32 } 38 }
33 39
34 BOOL BluetoothClassicWrapperFake::FindRadioClose(HBLUETOOTH_RADIO_FIND handle) { 40 BOOL BluetoothClassicWrapperFake::FindRadioClose(HBLUETOOTH_RADIO_FIND handle) {
35 return TRUE; 41 return TRUE;
36 } 42 }
37 43
38 BOOL BluetoothClassicWrapperFake::IsConnectable(HANDLE handle) { 44 BOOL BluetoothClassicWrapperFake::IsConnectable(HANDLE handle) {
39 if (simulated_radios_.get() != nullptr) { 45 if (simulated_radios_.get() != nullptr) {
46 last_error_ = ERROR_SUCCESS;
40 return simulated_radios_->is_connectable; 47 return simulated_radios_->is_connectable;
41 } 48 }
42 return TRUE; 49 last_error_ = ERROR_INVALID_HANDLE;
50 return false;
43 } 51 }
44 52
45 HBLUETOOTH_DEVICE_FIND BluetoothClassicWrapperFake::FindFirstDevice( 53 HBLUETOOTH_DEVICE_FIND BluetoothClassicWrapperFake::FindFirstDevice(
46 const BLUETOOTH_DEVICE_SEARCH_PARAMS* params, 54 const BLUETOOTH_DEVICE_SEARCH_PARAMS* params,
47 BLUETOOTH_DEVICE_INFO* out_device_info) { 55 BLUETOOTH_DEVICE_INFO* out_device_info) {
56 last_error_ = ERROR_NO_MORE_ITEMS;
48 return NULL; 57 return NULL;
49 } 58 }
50 59
51 BOOL BluetoothClassicWrapperFake::FindNextDevice( 60 BOOL BluetoothClassicWrapperFake::FindNextDevice(
52 HBLUETOOTH_DEVICE_FIND handle, 61 HBLUETOOTH_DEVICE_FIND handle,
53 BLUETOOTH_DEVICE_INFO* out_device_info) { 62 BLUETOOTH_DEVICE_INFO* out_device_info) {
54 NOTIMPLEMENTED(); 63 NOTIMPLEMENTED();
55 return TRUE; 64 return TRUE;
56 } 65 }
57 66
58 BOOL BluetoothClassicWrapperFake::FindDeviceClose( 67 BOOL BluetoothClassicWrapperFake::FindDeviceClose(
59 HBLUETOOTH_DEVICE_FIND handle) { 68 HBLUETOOTH_DEVICE_FIND handle) {
60 NOTIMPLEMENTED();
61 return TRUE; 69 return TRUE;
62 } 70 }
63 71
64 BOOL BluetoothClassicWrapperFake::EnableDiscovery(HANDLE handle, 72 BOOL BluetoothClassicWrapperFake::EnableDiscovery(HANDLE handle,
65 BOOL is_enable) { 73 BOOL is_enable) {
66 return TRUE; 74 return TRUE;
67 } 75 }
68 76
69 BOOL BluetoothClassicWrapperFake::EnableIncomingConnections(HANDLE handle, 77 BOOL BluetoothClassicWrapperFake::EnableIncomingConnections(HANDLE handle,
70 BOOL is_enable) { 78 BOOL is_enable) {
71 return TRUE; 79 return TRUE;
72 } 80 }
73 81
82 DWORD BluetoothClassicWrapperFake::LastError() {
83 return last_error_;
84 }
85
74 BluetoothRadio* BluetoothClassicWrapperFake::SimulateARadio( 86 BluetoothRadio* BluetoothClassicWrapperFake::SimulateARadio(
75 base::string16 name, 87 base::string16 name,
76 BLUETOOTH_ADDRESS address) { 88 BLUETOOTH_ADDRESS address) {
77 BluetoothRadio* radio = new BluetoothRadio(); 89 BluetoothRadio* radio = new BluetoothRadio();
78 radio->is_connectable = true; // set it connectable by default. 90 radio->is_connectable = true; // set it connectable by default.
79 size_t length = 91 size_t length =
80 ((name.size() > BLUETOOTH_MAX_NAME_SIZE) ? BLUETOOTH_MAX_NAME_SIZE 92 ((name.size() > BLUETOOTH_MAX_NAME_SIZE) ? BLUETOOTH_MAX_NAME_SIZE
81 : name.size()); 93 : name.size());
82 for (size_t i = 0; i < length; i++) { 94 for (size_t i = 0; i < length; i++) {
83 radio->radio_info.szName[i] = name.at(i); 95 radio->radio_info.szName[i] = name.at(i);
84 } 96 }
85 radio->radio_info.address = address; 97 radio->radio_info.address = address;
86 simulated_radios_.reset(radio); 98 simulated_radios_.reset(radio);
87 return radio; 99 return radio;
88 } 100 }
89 } // namespace device 101 } // namespace device
90 } // namespace win 102 } // namespace win
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698