Commit 7aa2851d authored by Jan Wilken Doerrie's avatar Jan Wilken Doerrie Committed by Commit Bot

[Bluetooth][WinRT] Add Skeletons required for Pairing

This change implements skeletons required for WinRT's pairing logic. No
actual functionality is added, this will be provided in a later CL.
Furthermore, it moves the TestPairingDelegate class from BlueZ's tests
into a standalone file. It also wraps the TestPairingDelegate in
bluetooth_adapter_unittest.cc in an anonymous namespace to avoid ODR
violations.

Bug: 821766
Change-Id: If440153dff46476223a1b24dfab1a630fb2451a3
Reviewed-on: https://chromium-review.googlesource.com/1177715Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583989}
parent 00d099ea
...@@ -64,6 +64,8 @@ test("device_unittests") { ...@@ -64,6 +64,8 @@ test("device_unittests") {
"bluetooth/test/test_bluetooth_adapter_observer.h", "bluetooth/test/test_bluetooth_adapter_observer.h",
"bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc", "bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc",
"bluetooth/test/test_bluetooth_local_gatt_service_delegate.h", "bluetooth/test/test_bluetooth_local_gatt_service_delegate.h",
"bluetooth/test/test_pairing_delegate.cc",
"bluetooth/test/test_pairing_delegate.h",
"bluetooth/uribeacon/uri_encoder_unittest.cc", "bluetooth/uribeacon/uri_encoder_unittest.cc",
"fido/attestation_statement_formats_unittest.cc", "fido/attestation_statement_formats_unittest.cc",
"fido/ble/fido_ble_connection_unittest.cc", "fido/ble/fido_ble_connection_unittest.cc",
...@@ -298,10 +300,16 @@ test("device_unittests") { ...@@ -298,10 +300,16 @@ test("device_unittests") {
"bluetooth/test/fake_bluetooth_le_device_winrt.h", "bluetooth/test/fake_bluetooth_le_device_winrt.h",
"bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.cc", "bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.cc",
"bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.h", "bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.h",
"bluetooth/test/fake_device_information_custom_pairing_winrt.cc",
"bluetooth/test/fake_device_information_custom_pairing_winrt.h",
"bluetooth/test/fake_device_information_pairing_winrt.cc", "bluetooth/test/fake_device_information_pairing_winrt.cc",
"bluetooth/test/fake_device_information_pairing_winrt.h", "bluetooth/test/fake_device_information_pairing_winrt.h",
"bluetooth/test/fake_device_information_winrt.cc", "bluetooth/test/fake_device_information_winrt.cc",
"bluetooth/test/fake_device_information_winrt.h", "bluetooth/test/fake_device_information_winrt.h",
"bluetooth/test/fake_device_pairing_requested_event_args_winrt.cc",
"bluetooth/test/fake_device_pairing_requested_event_args_winrt.h",
"bluetooth/test/fake_device_pairing_result_winrt.cc",
"bluetooth/test/fake_device_pairing_result_winrt.h",
"bluetooth/test/fake_gatt_characteristic_winrt.cc", "bluetooth/test/fake_gatt_characteristic_winrt.cc",
"bluetooth/test/fake_gatt_characteristic_winrt.h", "bluetooth/test/fake_gatt_characteristic_winrt.h",
"bluetooth/test/fake_gatt_characteristics_result_winrt.cc", "bluetooth/test/fake_gatt_characteristics_result_winrt.cc",
......
...@@ -44,6 +44,8 @@ using device::BluetoothDevice; ...@@ -44,6 +44,8 @@ using device::BluetoothDevice;
namespace device { namespace device {
namespace {
class TestBluetoothAdapter : public BluetoothAdapter { class TestBluetoothAdapter : public BluetoothAdapter {
public: public:
TestBluetoothAdapter() = default; TestBluetoothAdapter() = default;
...@@ -176,6 +178,8 @@ class TestPairingDelegate : public BluetoothDevice::PairingDelegate { ...@@ -176,6 +178,8 @@ class TestPairingDelegate : public BluetoothDevice::PairingDelegate {
void AuthorizePairing(BluetoothDevice* device) override {} void AuthorizePairing(BluetoothDevice* device) override {}
}; };
} // namespace
TEST(BluetoothAdapterTest, NoDefaultPairingDelegate) { TEST(BluetoothAdapterTest, NoDefaultPairingDelegate) {
scoped_refptr<BluetoothAdapter> adapter = new TestBluetoothAdapter(); scoped_refptr<BluetoothAdapter> adapter = new TestBluetoothAdapter();
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h"
#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" #include "device/bluetooth/dbus/fake_bluetooth_input_client.h"
#include "device/bluetooth/test/test_bluetooth_adapter_observer.h" #include "device/bluetooth/test/test_bluetooth_adapter_observer.h"
#include "device/bluetooth/test/test_pairing_delegate.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/service_constants.h" #include "third_party/cros_system_api/dbus/service_constants.h"
...@@ -41,6 +42,7 @@ using device::BluetoothDiscoveryFilter; ...@@ -41,6 +42,7 @@ using device::BluetoothDiscoveryFilter;
using device::BluetoothDiscoverySession; using device::BluetoothDiscoverySession;
using device::BluetoothUUID; using device::BluetoothUUID;
using device::TestBluetoothAdapterObserver; using device::TestBluetoothAdapterObserver;
using device::TestPairingDelegate;
namespace bluez { namespace bluez {
...@@ -87,88 +89,6 @@ class FakeBluetoothProfileServiceProviderDelegate ...@@ -87,88 +89,6 @@ class FakeBluetoothProfileServiceProviderDelegate
} // namespace } // namespace
class TestPairingDelegate : public BluetoothDevice::PairingDelegate {
public:
TestPairingDelegate()
: call_count_(0),
request_pincode_count_(0),
request_passkey_count_(0),
display_pincode_count_(0),
display_passkey_count_(0),
keys_entered_count_(0),
confirm_passkey_count_(0),
authorize_pairing_count_(0),
last_passkey_(9999999U),
last_entered_(999U) {}
~TestPairingDelegate() override = default;
void RequestPinCode(BluetoothDevice* device) override {
++call_count_;
++request_pincode_count_;
QuitMessageLoop();
}
void RequestPasskey(BluetoothDevice* device) override {
++call_count_;
++request_passkey_count_;
QuitMessageLoop();
}
void DisplayPinCode(BluetoothDevice* device,
const std::string& pincode) override {
++call_count_;
++display_pincode_count_;
last_pincode_ = pincode;
QuitMessageLoop();
}
void DisplayPasskey(BluetoothDevice* device, uint32_t passkey) override {
++call_count_;
++display_passkey_count_;
last_passkey_ = passkey;
QuitMessageLoop();
}
void KeysEntered(BluetoothDevice* device, uint32_t entered) override {
++call_count_;
++keys_entered_count_;
last_entered_ = entered;
QuitMessageLoop();
}
void ConfirmPasskey(BluetoothDevice* device, uint32_t passkey) override {
++call_count_;
++confirm_passkey_count_;
last_passkey_ = passkey;
QuitMessageLoop();
}
void AuthorizePairing(BluetoothDevice* device) override {
++call_count_;
++authorize_pairing_count_;
QuitMessageLoop();
}
int call_count_;
int request_pincode_count_;
int request_passkey_count_;
int display_pincode_count_;
int display_passkey_count_;
int keys_entered_count_;
int confirm_passkey_count_;
int authorize_pairing_count_;
uint32_t last_passkey_;
uint32_t last_entered_;
std::string last_pincode_;
private:
// Some tests use a message loop since background processing is simulated;
// break out of those loops.
void QuitMessageLoop() {
if (base::RunLoop::IsRunningOnCurrentThread())
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
};
class BluetoothBlueZTest : public testing::Test { class BluetoothBlueZTest : public testing::Test {
public: public:
......
// 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_device_information_custom_pairing_winrt.h"
#include <windows.foundation.h>
namespace device {
namespace {
using ABI::Windows::Devices::Enumeration::DeviceInformationCustomPairing;
using ABI::Windows::Devices::Enumeration::DevicePairingKinds;
using ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel;
using ABI::Windows::Devices::Enumeration::DevicePairingRequestedEventArgs;
using ABI::Windows::Devices::Enumeration::DevicePairingResult;
using ABI::Windows::Devices::Enumeration::IDevicePairingSettings;
using ABI::Windows::Foundation::IAsyncOperation;
using ABI::Windows::Foundation::ITypedEventHandler;
} // namespace
FakeDeviceInformationCustomPairingWinrt::
FakeDeviceInformationCustomPairingWinrt() = default;
FakeDeviceInformationCustomPairingWinrt::
~FakeDeviceInformationCustomPairingWinrt() = default;
HRESULT FakeDeviceInformationCustomPairingWinrt::PairAsync(
DevicePairingKinds pairing_kinds_supported,
IAsyncOperation<DevicePairingResult*>** result) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationCustomPairingWinrt::PairWithProtectionLevelAsync(
DevicePairingKinds pairing_kinds_supported,
DevicePairingProtectionLevel min_protection_level,
IAsyncOperation<DevicePairingResult*>** result) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationCustomPairingWinrt::
PairWithProtectionLevelAndSettingsAsync(
DevicePairingKinds pairing_kinds_supported,
DevicePairingProtectionLevel min_protection_level,
IDevicePairingSettings* device_pairing_settings,
IAsyncOperation<DevicePairingResult*>** result) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationCustomPairingWinrt::add_PairingRequested(
ITypedEventHandler<DeviceInformationCustomPairing*,
DevicePairingRequestedEventArgs*>* handler,
EventRegistrationToken* token) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationCustomPairingWinrt::remove_PairingRequested(
EventRegistrationToken token) {
return E_NOTIMPL;
}
} // namespace device
// 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.
#ifndef DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_INFORMATION_CUSTOM_PAIRING_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_INFORMATION_CUSTOM_PAIRING_WINRT_H_
#include <windows.devices.enumeration.h>
#include <wrl/implements.h>
#include "base/macros.h"
namespace device {
class FakeDeviceInformationCustomPairingWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Enumeration::IDeviceInformationCustomPairing> {
public:
FakeDeviceInformationCustomPairingWinrt();
~FakeDeviceInformationCustomPairingWinrt() override;
// IDeviceInformationCustomPairing:
IFACEMETHODIMP PairAsync(
ABI::Windows::Devices::Enumeration::DevicePairingKinds
pairing_kinds_supported,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DevicePairingResult*>** result)
override;
IFACEMETHODIMP PairWithProtectionLevelAsync(
ABI::Windows::Devices::Enumeration::DevicePairingKinds
pairing_kinds_supported,
ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel
min_protection_level,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DevicePairingResult*>** result)
override;
IFACEMETHODIMP PairWithProtectionLevelAndSettingsAsync(
ABI::Windows::Devices::Enumeration::DevicePairingKinds
pairing_kinds_supported,
ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel
min_protection_level,
ABI::Windows::Devices::Enumeration::IDevicePairingSettings*
device_pairing_settings,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DevicePairingResult*>** result)
override;
IFACEMETHODIMP add_PairingRequested(
ABI::Windows::Foundation::ITypedEventHandler<
ABI::Windows::Devices::Enumeration::DeviceInformationCustomPairing*,
ABI::Windows::Devices::Enumeration::DevicePairingRequestedEventArgs*>*
handler,
EventRegistrationToken* token) override;
IFACEMETHODIMP remove_PairingRequested(EventRegistrationToken token) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeDeviceInformationCustomPairingWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_INFORMATION_CUSTOM_PAIRING_WINRT_H_
...@@ -10,6 +10,9 @@ namespace { ...@@ -10,6 +10,9 @@ namespace {
using ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel; using ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel;
using ABI::Windows::Devices::Enumeration::DevicePairingResult; using ABI::Windows::Devices::Enumeration::DevicePairingResult;
using ABI::Windows::Devices::Enumeration::DeviceUnpairingResult;
using ABI::Windows::Devices::Enumeration::IDeviceInformationCustomPairing;
using ABI::Windows::Devices::Enumeration::IDevicePairingSettings;
using ABI::Windows::Foundation::IAsyncOperation; using ABI::Windows::Foundation::IAsyncOperation;
} // namespace } // namespace
...@@ -41,4 +44,27 @@ HRESULT FakeDeviceInformationPairingWinrt::PairWithProtectionLevelAsync( ...@@ -41,4 +44,27 @@ HRESULT FakeDeviceInformationPairingWinrt::PairWithProtectionLevelAsync(
return E_NOTIMPL; return E_NOTIMPL;
} }
HRESULT FakeDeviceInformationPairingWinrt::get_ProtectionLevel(
DevicePairingProtectionLevel* value) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationPairingWinrt::get_Custom(
IDeviceInformationCustomPairing** value) {
return E_NOTIMPL;
}
HRESULT
FakeDeviceInformationPairingWinrt::PairWithProtectionLevelAndSettingsAsync(
DevicePairingProtectionLevel min_protection_level,
IDevicePairingSettings* device_pairing_settings,
IAsyncOperation<DevicePairingResult*>** result) {
return E_NOTIMPL;
}
HRESULT FakeDeviceInformationPairingWinrt::UnpairAsync(
IAsyncOperation<DeviceUnpairingResult*>** result) {
return E_NOTIMPL;
}
} // namespace device } // namespace device
...@@ -17,7 +17,8 @@ class FakeDeviceInformationPairingWinrt ...@@ -17,7 +17,8 @@ class FakeDeviceInformationPairingWinrt
: public Microsoft::WRL::RuntimeClass< : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>, Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Enumeration::IDeviceInformationPairing> { ABI::Windows::Devices::Enumeration::IDeviceInformationPairing,
ABI::Windows::Devices::Enumeration::IDeviceInformationPairing2> {
public: public:
explicit FakeDeviceInformationPairingWinrt(bool is_paired); explicit FakeDeviceInformationPairingWinrt(bool is_paired);
~FakeDeviceInformationPairingWinrt() override; ~FakeDeviceInformationPairingWinrt() override;
...@@ -36,6 +37,26 @@ class FakeDeviceInformationPairingWinrt ...@@ -36,6 +37,26 @@ class FakeDeviceInformationPairingWinrt
ABI::Windows::Devices::Enumeration::DevicePairingResult*>** result) ABI::Windows::Devices::Enumeration::DevicePairingResult*>** result)
override; override;
// IDeviceInformationPairing2:
IFACEMETHODIMP get_ProtectionLevel(
ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel* value)
override;
IFACEMETHODIMP get_Custom(
ABI::Windows::Devices::Enumeration::IDeviceInformationCustomPairing**
value) override;
IFACEMETHODIMP PairWithProtectionLevelAndSettingsAsync(
ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel
min_protection_level,
ABI::Windows::Devices::Enumeration::IDevicePairingSettings*
device_pairing_settings,
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DevicePairingResult*>** result)
override;
IFACEMETHODIMP UnpairAsync(
ABI::Windows::Foundation::IAsyncOperation<
ABI::Windows::Devices::Enumeration::DeviceUnpairingResult*>** result)
override;
private: private:
bool is_paired_ = false; bool is_paired_ = false;
......
// 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_device_pairing_requested_event_args_winrt.h"
#include <windows.foundation.h>
namespace device {
namespace {
using ABI::Windows::Devices::Enumeration::IDeviceInformation;
using ABI::Windows::Devices::Enumeration::DevicePairingKinds;
using ABI::Windows::Foundation::IDeferral;
class FakeDeferral
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Foundation::IDeferral> {
public:
FakeDeferral() = default;
~FakeDeferral() override = default;
// IDeferral:
IFACEMETHODIMP Complete() override { return E_NOTIMPL; }
private:
DISALLOW_COPY_AND_ASSIGN(FakeDeferral);
};
} // namespace
FakeDevicePairingRequestedEventArgsWinrt::
FakeDevicePairingRequestedEventArgsWinrt() = default;
FakeDevicePairingRequestedEventArgsWinrt::
~FakeDevicePairingRequestedEventArgsWinrt() = default;
HRESULT FakeDevicePairingRequestedEventArgsWinrt::get_DeviceInformation(
IDeviceInformation** value) {
return E_NOTIMPL;
}
HRESULT FakeDevicePairingRequestedEventArgsWinrt::get_PairingKind(
DevicePairingKinds* value) {
return E_NOTIMPL;
}
HRESULT FakeDevicePairingRequestedEventArgsWinrt::get_Pin(HSTRING* value) {
return E_NOTIMPL;
}
HRESULT FakeDevicePairingRequestedEventArgsWinrt::Accept() {
return E_NOTIMPL;
}
HRESULT FakeDevicePairingRequestedEventArgsWinrt::AcceptWithPin(HSTRING pin) {
return E_NOTIMPL;
}
HRESULT FakeDevicePairingRequestedEventArgsWinrt::GetDeferral(
IDeferral** result) {
return E_NOTIMPL;
}
} // namespace device
// 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.
#ifndef DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_PAIRING_REQUESTED_EVENT_ARGS_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_PAIRING_REQUESTED_EVENT_ARGS_WINRT_H_
#include <windows.devices.enumeration.h>
#include <wrl/implements.h>
#include "base/macros.h"
namespace device {
class FakeDevicePairingRequestedEventArgsWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Enumeration::
IDevicePairingRequestedEventArgs> {
public:
FakeDevicePairingRequestedEventArgsWinrt();
~FakeDevicePairingRequestedEventArgsWinrt() override;
// IDevicePairingRequestedEventArgs:
IFACEMETHODIMP get_DeviceInformation(
ABI::Windows::Devices::Enumeration::IDeviceInformation** value) override;
IFACEMETHODIMP get_PairingKind(
ABI::Windows::Devices::Enumeration::DevicePairingKinds* value) override;
IFACEMETHODIMP get_Pin(HSTRING* value) override;
IFACEMETHODIMP Accept() override;
IFACEMETHODIMP AcceptWithPin(HSTRING pin) override;
IFACEMETHODIMP GetDeferral(
ABI::Windows::Foundation::IDeferral** result) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeDevicePairingRequestedEventArgsWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_PAIRING_REQUESTED_EVENT_ARGS_WINRT_H_
// 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_device_pairing_result_winrt.h"
namespace {
using ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel;
using ABI::Windows::Devices::Enumeration::DevicePairingResultStatus;
} // namespace
namespace device {
FakeDevicePairingResultWinrt::FakeDevicePairingResultWinrt() = default;
FakeDevicePairingResultWinrt::~FakeDevicePairingResultWinrt() = default;
HRESULT FakeDevicePairingResultWinrt::get_Status(
DevicePairingResultStatus* status) {
return E_NOTIMPL;
}
HRESULT FakeDevicePairingResultWinrt::get_ProtectionLevelUsed(
DevicePairingProtectionLevel* value) {
return E_NOTIMPL;
}
} // namespace device
// 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.
#ifndef DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_PAIRING_RESULT_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_PAIRING_RESULT_WINRT_H_
#include <windows.devices.enumeration.h>
#include <wrl/implements.h>
#include "base/macros.h"
namespace device {
class FakeDevicePairingResultWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Enumeration::IDevicePairingResult> {
public:
FakeDevicePairingResultWinrt();
~FakeDevicePairingResultWinrt() override;
// IDevicePairingResult:
IFACEMETHODIMP get_Status(
ABI::Windows::Devices::Enumeration::DevicePairingResultStatus* status)
override;
IFACEMETHODIMP get_ProtectionLevelUsed(
ABI::Windows::Devices::Enumeration::DevicePairingProtectionLevel* value)
override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeDevicePairingResultWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_DEVICE_PAIRING_RESULT_WINRT_H_
// 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/test_pairing_delegate.h"
namespace device {
TestPairingDelegate::TestPairingDelegate() = default;
TestPairingDelegate::~TestPairingDelegate() = default;
void TestPairingDelegate::RequestPinCode(BluetoothDevice* device) {
++call_count_;
++request_pincode_count_;
QuitMessageLoop();
}
void TestPairingDelegate::RequestPasskey(BluetoothDevice* device) {
++call_count_;
++request_passkey_count_;
QuitMessageLoop();
}
void TestPairingDelegate::DisplayPinCode(BluetoothDevice* device,
const std::string& pincode) {
++call_count_;
++display_pincode_count_;
last_pincode_ = pincode;
QuitMessageLoop();
}
void TestPairingDelegate::DisplayPasskey(BluetoothDevice* device,
uint32_t passkey) {
++call_count_;
++display_passkey_count_;
last_passkey_ = passkey;
QuitMessageLoop();
}
void TestPairingDelegate::KeysEntered(BluetoothDevice* device,
uint32_t entered) {
++call_count_;
++keys_entered_count_;
last_entered_ = entered;
QuitMessageLoop();
}
void TestPairingDelegate::ConfirmPasskey(BluetoothDevice* device,
uint32_t passkey) {
++call_count_;
++confirm_passkey_count_;
last_passkey_ = passkey;
QuitMessageLoop();
}
void TestPairingDelegate::AuthorizePairing(BluetoothDevice* device) {
++call_count_;
++authorize_pairing_count_;
QuitMessageLoop();
}
void TestPairingDelegate::QuitMessageLoop() {
if (base::RunLoop::IsRunningOnCurrentThread())
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
} // namespace device
// 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.
#ifndef DEVICE_BLUETOOTH_TEST_TEST_PAIRING_DELEGATE_H_
#define DEVICE_BLUETOOTH_TEST_TEST_PAIRING_DELEGATE_H_
#include <stdint.h>
#include <string>
#include "base/run_loop.h"
#include "device/bluetooth/bluetooth_device.h"
namespace device {
class TestPairingDelegate : public BluetoothDevice::PairingDelegate {
public:
TestPairingDelegate();
~TestPairingDelegate() override;
// BluetoothDevice::PairingDelegate:
void RequestPinCode(BluetoothDevice* device) override;
void RequestPasskey(BluetoothDevice* device) override;
void DisplayPinCode(BluetoothDevice* device,
const std::string& pincode) override;
void DisplayPasskey(BluetoothDevice* device, uint32_t passkey) override;
void KeysEntered(BluetoothDevice* device, uint32_t entered) override;
void ConfirmPasskey(BluetoothDevice* device, uint32_t passkey) override;
void AuthorizePairing(BluetoothDevice* device) override;
int call_count_ = 0;
int request_pincode_count_ = 0;
int request_passkey_count_ = 0;
int display_pincode_count_ = 0;
int display_passkey_count_ = 0;
int keys_entered_count_ = 0;
int confirm_passkey_count_ = 0;
int authorize_pairing_count_ = 0;
uint32_t last_passkey_ = 999999u;
uint32_t last_entered_ = 999u;
std::string last_pincode_;
private:
// Some tests use a message loop since background processing is simulated;
// break out of those loops.
void QuitMessageLoop();
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_TEST_PAIRING_DELEGATE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment