Commit f397e84f authored by Jan Wilken Doerrie's avatar Jan Wilken Doerrie Committed by Commit Bot

[Bluetooth][WinRT] Skeletons required for Advertisement

This change adds skeletons of classes required for implementing
publishing advertisements for WinRT. Actual functionality will be added
in a follow-up CL.

Bug: 821766
Change-Id: Ib80e8a53810457765ed5e48550d683e1f595ded8
Reviewed-on: https://chromium-review.googlesource.com/1187144Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585536}
parent 3d2ba557
......@@ -290,6 +290,10 @@ test("device_unittests") {
"bluetooth/test/fake_bluetooth_adapter_winrt.h",
"bluetooth/test/fake_bluetooth_le_advertisement_data_section_winrt.cc",
"bluetooth/test/fake_bluetooth_le_advertisement_data_section_winrt.h",
"bluetooth/test/fake_bluetooth_le_advertisement_publisher_status_changed_event_args_winrt.cc",
"bluetooth/test/fake_bluetooth_le_advertisement_publisher_status_changed_event_args_winrt.h",
"bluetooth/test/fake_bluetooth_le_advertisement_publisher_winrt.cc",
"bluetooth/test/fake_bluetooth_le_advertisement_publisher_winrt.h",
"bluetooth/test/fake_bluetooth_le_advertisement_received_event_args_winrt.cc",
"bluetooth/test/fake_bluetooth_le_advertisement_received_event_args_winrt.h",
"bluetooth/test/fake_bluetooth_le_advertisement_watcher_winrt.cc",
......
// 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_publisher_status_changed_event_args_winrt.h"
namespace device {
namespace {
using ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisherStatus;
using ABI::Windows::Devices::Bluetooth::BluetoothError;
} // namespace
FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt::
FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt() =
default;
FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt::
~FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt() =
default;
HRESULT
FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt::get_Status(
BluetoothLEAdvertisementPublisherStatus* value) {
return E_NOTIMPL;
}
HRESULT
FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt::get_Error(
BluetoothError* 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_BLUETOOTH_LE_ADVERTISEMENT_PUBLISHER_STATUS_CHANGED_EVENT_ARGS_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_ADVERTISEMENT_PUBLISHER_STATUS_CHANGED_EVENT_ARGS_WINRT_H_
#include <windows.devices.bluetooth.advertisement.h>
#include <wrl/implements.h>
#include "base/macros.h"
namespace device {
class FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisementPublisherStatusChangedEventArgs> {
public:
FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt();
~FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt() override;
// IBluetoothLEAdvertisementPublisherStatusChangedEventArgs:
IFACEMETHODIMP get_Status(
ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisherStatus* value) override;
IFACEMETHODIMP get_Error(
ABI::Windows::Devices::Bluetooth::BluetoothError* value) override;
private:
DISALLOW_COPY_AND_ASSIGN(
FakeBluetoothLEAdvertisementPublisherStatusChangedEventArgsWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_ADVERTISEMENT_PUBLISHER_STATUS_CHANGED_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_bluetooth_le_advertisement_publisher_winrt.h"
namespace device {
namespace {
using ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisher;
using ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisherStatus;
using ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisherStatusChangedEventArgs;
using ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisement;
using ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisementPublisher;
using ABI::Windows::Foundation::ITypedEventHandler;
} // namespace
FakeBluetoothLEAdvertisementPublisherWinrt::
FakeBluetoothLEAdvertisementPublisherWinrt() = default;
FakeBluetoothLEAdvertisementPublisherWinrt::
~FakeBluetoothLEAdvertisementPublisherWinrt() = default;
HRESULT FakeBluetoothLEAdvertisementPublisherWinrt::get_Status(
BluetoothLEAdvertisementPublisherStatus* value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEAdvertisementPublisherWinrt::get_Advertisement(
IBluetoothLEAdvertisement** value) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEAdvertisementPublisherWinrt::Start() {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEAdvertisementPublisherWinrt::Stop() {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEAdvertisementPublisherWinrt::add_StatusChanged(
ITypedEventHandler<
BluetoothLEAdvertisementPublisher*,
BluetoothLEAdvertisementPublisherStatusChangedEventArgs*>* handler,
EventRegistrationToken* token) {
return E_NOTIMPL;
}
HRESULT FakeBluetoothLEAdvertisementPublisherWinrt::remove_StatusChanged(
EventRegistrationToken token) {
return E_NOTIMPL;
}
FakeBluetoothLEAdvertisementPublisherFactoryWinrt::
FakeBluetoothLEAdvertisementPublisherFactoryWinrt() = default;
FakeBluetoothLEAdvertisementPublisherFactoryWinrt::
~FakeBluetoothLEAdvertisementPublisherFactoryWinrt() = default;
HRESULT FakeBluetoothLEAdvertisementPublisherFactoryWinrt::Create(
IBluetoothLEAdvertisement* advertisement,
IBluetoothLEAdvertisementPublisher** 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_BLUETOOTH_LE_ADVERTISEMENT_PUBLISHER_WINRT_H_
#define DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_ADVERTISEMENT_PUBLISHER_WINRT_H_
#include <windows.devices.bluetooth.advertisement.h>
#include <wrl/implements.h>
#include "base/macros.h"
namespace device {
class FakeBluetoothLEAdvertisementPublisherWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisementPublisher> {
public:
FakeBluetoothLEAdvertisementPublisherWinrt();
~FakeBluetoothLEAdvertisementPublisherWinrt() override;
// IBluetoothLEAdvertisementPublisher:
IFACEMETHODIMP get_Status(
ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisherStatus* value) override;
IFACEMETHODIMP get_Advertisement(
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisement** value) override;
IFACEMETHODIMP Start() override;
IFACEMETHODIMP Stop() override;
IFACEMETHODIMP add_StatusChanged(
ABI::Windows::Foundation::ITypedEventHandler<
ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisher*,
ABI::Windows::Devices::Bluetooth::Advertisement::
BluetoothLEAdvertisementPublisherStatusChangedEventArgs*>*
handler,
EventRegistrationToken* token) override;
IFACEMETHODIMP remove_StatusChanged(EventRegistrationToken token) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEAdvertisementPublisherWinrt);
};
class FakeBluetoothLEAdvertisementPublisherFactoryWinrt
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisementPublisherFactory> {
public:
FakeBluetoothLEAdvertisementPublisherFactoryWinrt();
~FakeBluetoothLEAdvertisementPublisherFactoryWinrt() override;
// IBluetoothLEAdvertisementPublisherFactory:
IFACEMETHODIMP Create(
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisement* advertisement,
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEAdvertisementPublisher** value) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEAdvertisementPublisherFactoryWinrt);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_ADVERTISEMENT_PUBLISHER_WINRT_H_
......@@ -4,8 +4,6 @@
#include "device/bluetooth/test/fake_bluetooth_le_manufacturer_data_winrt.h"
#include <wrl/client.h>
#include <utility>
#include "base/win/winrt_storage_util.h"
......@@ -14,14 +12,25 @@ namespace device {
namespace {
using ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEManufacturerData;
using ABI::Windows::Storage::Streams::IBuffer;
using Microsoft::WRL::ComPtr;
using Microsoft::WRL::Make;
} // namespace
FakeBluetoothLEManufacturerData::FakeBluetoothLEManufacturerData(
uint16_t company_id,
std::vector<uint8_t> data)
: company_id_(company_id) {
base::win::CreateIBufferFromData(data.data(),
static_cast<uint32_t>(data.size()), &data_);
}
FakeBluetoothLEManufacturerData::FakeBluetoothLEManufacturerData(
uint16_t company_id,
ComPtr<IBuffer> data)
: company_id_(company_id), data_(std::move(data)) {}
FakeBluetoothLEManufacturerData::~FakeBluetoothLEManufacturerData() = default;
......@@ -36,14 +45,24 @@ HRESULT FakeBluetoothLEManufacturerData::put_CompanyId(uint16_t value) {
}
HRESULT FakeBluetoothLEManufacturerData::get_Data(IBuffer** value) {
ComPtr<IBuffer> buffer;
HRESULT hr = base::win::CreateIBufferFromData(
data_.data(), static_cast<uint32_t>(data_.size()), &buffer);
return SUCCEEDED(hr) ? buffer.CopyTo(value) : hr;
return data_.CopyTo(value);
}
HRESULT FakeBluetoothLEManufacturerData::put_Data(IBuffer* value) {
return E_NOTIMPL;
}
FakeBluetoothLEManufacturerDataFactory::
FakeBluetoothLEManufacturerDataFactory() = default;
FakeBluetoothLEManufacturerDataFactory::
~FakeBluetoothLEManufacturerDataFactory() = default;
HRESULT FakeBluetoothLEManufacturerDataFactory::Create(
uint16_t company_id,
IBuffer* data,
IBluetoothLEManufacturerData** value) {
return Make<FakeBluetoothLEManufacturerData>(company_id, data).CopyTo(value);
}
} // namespace device
......@@ -6,6 +6,7 @@
#define DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_MANUFACTURER_DATA_WINRT_H_
#include <windows.devices.bluetooth.advertisement.h>
#include <wrl/client.h>
#include <wrl/implements.h>
#include <stdint.h>
......@@ -25,6 +26,9 @@ class FakeBluetoothLEManufacturerData
public:
FakeBluetoothLEManufacturerData(uint16_t company_id,
std::vector<uint8_t> data);
FakeBluetoothLEManufacturerData(
uint16_t company_id,
Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> data);
~FakeBluetoothLEManufacturerData() override;
// IBluetoothLEManufacturerData:
......@@ -37,11 +41,31 @@ class FakeBluetoothLEManufacturerData
private:
uint16_t company_id_;
std::vector<uint8_t> data_;
Microsoft::WRL::ComPtr<ABI::Windows::Storage::Streams::IBuffer> data_;
DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEManufacturerData);
};
class FakeBluetoothLEManufacturerDataFactory
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<
Microsoft::WRL::WinRt | Microsoft::WRL::InhibitRoOriginateError>,
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEManufacturerDataFactory> {
public:
FakeBluetoothLEManufacturerDataFactory();
~FakeBluetoothLEManufacturerDataFactory() override;
// IBluetoothLEManufacturerDataFactory:
IFACEMETHODIMP Create(uint16_t company_id,
ABI::Windows::Storage::Streams::IBuffer* data,
ABI::Windows::Devices::Bluetooth::Advertisement::
IBluetoothLEManufacturerData** value) override;
private:
DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEManufacturerDataFactory);
};
} // namespace device
#endif // DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_LE_MANUFACTURER_DATA_WINRT_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