| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "device/bluetooth/test/fake_bluetooth_le_advertisement_watcher_winrt.h" |
| |
| #include "base/strings/string_piece.h" |
| #include "device/bluetooth/test/fake_bluetooth_le_advertisement_received_event_args_winrt.h" |
| #include "device/bluetooth/test/fake_bluetooth_le_advertisement_winrt.h" |
| |
| namespace device { |
| |
| namespace { |
| |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| BluetoothLEAdvertisementReceivedEventArgs; |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| BluetoothLEAdvertisementWatcher; |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| BluetoothLEAdvertisementWatcherStatus; |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| BluetoothLEAdvertisementWatcherStatus_Started; |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| BluetoothLEAdvertisementWatcherStatus_Stopped; |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| BluetoothLEAdvertisementWatcherStoppedEventArgs; |
| using ABI::Windows::Devices::Bluetooth::Advertisement::BluetoothLEScanningMode; |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| IBluetoothLEAdvertisementFilter; |
| using ABI::Windows::Devices::Bluetooth::Advertisement:: |
| IBluetoothLEAdvertisementReceivedEventArgs; |
| using ABI::Windows::Devices::Bluetooth::IBluetoothSignalStrengthFilter; |
| using ABI::Windows::Foundation::TimeSpan; |
| using ABI::Windows::Foundation::ITypedEventHandler; |
| using Microsoft::WRL::ComPtr; |
| using Microsoft::WRL::Make; |
| |
| } // namespace |
| |
| FakeBluetoothLEAdvertisementWatcherWinrt:: |
| FakeBluetoothLEAdvertisementWatcherWinrt() = default; |
| |
| FakeBluetoothLEAdvertisementWatcherWinrt:: |
| ~FakeBluetoothLEAdvertisementWatcherWinrt() = default; |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_MinSamplingInterval( |
| TimeSpan* value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_MaxSamplingInterval( |
| TimeSpan* value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_MinOutOfRangeTimeout( |
| TimeSpan* value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_MaxOutOfRangeTimeout( |
| TimeSpan* value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_Status( |
| BluetoothLEAdvertisementWatcherStatus* value) { |
| *value = status_; |
| return S_OK; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_ScanningMode( |
| BluetoothLEScanningMode* value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::put_ScanningMode( |
| BluetoothLEScanningMode value) { |
| return S_OK; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_SignalStrengthFilter( |
| IBluetoothSignalStrengthFilter** value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::put_SignalStrengthFilter( |
| IBluetoothSignalStrengthFilter* value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::get_AdvertisementFilter( |
| IBluetoothLEAdvertisementFilter** value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::put_AdvertisementFilter( |
| IBluetoothLEAdvertisementFilter* value) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::Start() { |
| status_ = BluetoothLEAdvertisementWatcherStatus_Started; |
| return S_OK; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::Stop() { |
| status_ = BluetoothLEAdvertisementWatcherStatus_Stopped; |
| return S_OK; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::add_Received( |
| ITypedEventHandler<BluetoothLEAdvertisementWatcher*, |
| BluetoothLEAdvertisementReceivedEventArgs*>* handler, |
| EventRegistrationToken* token) { |
| handler_ = handler; |
| return S_OK; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::remove_Received( |
| EventRegistrationToken token) { |
| handler_.Reset(); |
| return S_OK; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::add_Stopped( |
| ITypedEventHandler<BluetoothLEAdvertisementWatcher*, |
| BluetoothLEAdvertisementWatcherStoppedEventArgs*>* |
| handler, |
| EventRegistrationToken* token) { |
| return E_NOTIMPL; |
| } |
| |
| HRESULT FakeBluetoothLEAdvertisementWatcherWinrt::remove_Stopped( |
| EventRegistrationToken token) { |
| return E_NOTIMPL; |
| } |
| |
| void FakeBluetoothLEAdvertisementWatcherWinrt::SimulateLowEnergyDevice( |
| const BluetoothTestBase::LowEnergyDeviceData& device_data) { |
| if (handler_) { |
| handler_->Invoke( |
| this, Make<FakeBluetoothLEAdvertisementReceivedEventArgsWinrt>( |
| device_data.rssi, device_data.address, |
| Make<FakeBluetoothLEAdvertisementWinrt>( |
| device_data.name, device_data.flags, |
| device_data.advertised_uuids, device_data.tx_power, |
| device_data.service_data, device_data.manufacturer_data)) |
| .Get()); |
| } |
| } |
| |
| } // namespace device |