Refactor FakeBluetooth implementation to outside bluetooth/test
As a precursor to introducing FakeBluetooth CDP API support (crrev.com/c/5559106), this CL refactors the core of FakeBluetooth implementation to outside bluetooth/test and into a separate bluetooth/emulation to allow wider usage. * Move essential fake_bluetooth functionality into bluetooth/emulation/ * Rename bluetooth/../mojom/test to bluetooth/../mojom/emulation Bug: 342191615 Change-Id: If5e2340e07dde07bc644e3e496ff584736067b0b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5673025 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Alex N. Jose <alexnj@chromium.org> Reviewed-by: Matt Reynolds <mattreynolds@chromium.org> Cr-Commit-Position: refs/heads/main@{#1324602}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
2fa7287765
commit
cff763aa02
content
device/bluetooth
BUILD.gn
emulation
fake_bluetooth.ccfake_bluetooth.hfake_central.ccfake_central.hfake_peripheral.ccfake_peripheral.hfake_read_response.ccfake_read_response.hfake_remote_gatt_characteristic.ccfake_remote_gatt_characteristic.hfake_remote_gatt_descriptor.ccfake_remote_gatt_descriptor.hfake_remote_gatt_service.ccfake_remote_gatt_service.h
public
test
infra/archive_config
third_party/blink/web_tests
external
wpt
resources
chromium
http
tests
inspector-protocol
device-access
resources
wpt_internal
bluetooth
@ -70,7 +70,7 @@ and the new permissions system. For more details, see the following files in
|
||||
[BluetoothFakeAdapter]:
|
||||
../../shell/browser/web_test/web_test_bluetooth_adapter_provider.h
|
||||
[FakeBluetooth]:
|
||||
../../../device/bluetooth/test/fake_bluetooth.h
|
||||
../../../device/bluetooth/emulation/fake_bluetooth.h
|
||||
[Web Bluetooth Web Tests README]:
|
||||
../../../third_party/blink/web_tests/bluetooth/README.md
|
||||
[Web Bluetooth Web Platform Tests README]:
|
||||
|
@ -63,8 +63,8 @@
|
||||
#include "content/web_test/common/web_test_bluetooth_fake_adapter_setter.mojom.h"
|
||||
#include "content/web_test/common/web_test_string_util.h"
|
||||
#include "content/web_test/common/web_test_switches.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom.h"
|
||||
#include "device/bluetooth/test/fake_bluetooth.h"
|
||||
#include "device/bluetooth/emulation/fake_bluetooth.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.h"
|
||||
#include "gpu/config/gpu_switches.h"
|
||||
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
|
||||
#include "mojo/public/cpp/bindings/binder_map.h"
|
||||
|
@ -82,26 +82,26 @@ source_set("deprecated_experimental_mojo") {
|
||||
|
||||
source_set("fake_bluetooth") {
|
||||
sources = [
|
||||
"test/fake_bluetooth.cc",
|
||||
"test/fake_bluetooth.h",
|
||||
"emulation/fake_bluetooth.cc",
|
||||
"emulation/fake_bluetooth.h",
|
||||
"emulation/fake_central.cc",
|
||||
"emulation/fake_central.h",
|
||||
"emulation/fake_peripheral.cc",
|
||||
"emulation/fake_peripheral.h",
|
||||
"emulation/fake_read_response.cc",
|
||||
"emulation/fake_read_response.h",
|
||||
"emulation/fake_remote_gatt_characteristic.cc",
|
||||
"emulation/fake_remote_gatt_characteristic.h",
|
||||
"emulation/fake_remote_gatt_descriptor.cc",
|
||||
"emulation/fake_remote_gatt_descriptor.h",
|
||||
"emulation/fake_remote_gatt_service.cc",
|
||||
"emulation/fake_remote_gatt_service.h",
|
||||
"test/fake_bluetooth_socket.cc",
|
||||
"test/fake_bluetooth_socket.h",
|
||||
"test/fake_central.cc",
|
||||
"test/fake_central.h",
|
||||
"test/fake_local_gatt_characteristic.cc",
|
||||
"test/fake_local_gatt_characteristic.h",
|
||||
"test/fake_local_gatt_service.cc",
|
||||
"test/fake_local_gatt_service.h",
|
||||
"test/fake_peripheral.cc",
|
||||
"test/fake_peripheral.h",
|
||||
"test/fake_read_response.cc",
|
||||
"test/fake_read_response.h",
|
||||
"test/fake_remote_gatt_characteristic.cc",
|
||||
"test/fake_remote_gatt_characteristic.h",
|
||||
"test/fake_remote_gatt_descriptor.cc",
|
||||
"test/fake_remote_gatt_descriptor.h",
|
||||
"test/fake_remote_gatt_service.cc",
|
||||
"test/fake_remote_gatt_service.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
|
@ -2,13 +2,13 @@
|
||||
// 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.h"
|
||||
#include "device/bluetooth/emulation/fake_bluetooth.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "device/bluetooth/bluetooth_adapter_factory.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
|
@ -1,21 +1,21 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// 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_H_
|
||||
#define DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_H_
|
||||
#ifndef DEVICE_BLUETOOTH_EMULATION_FAKE_BLUETOOTH_H_
|
||||
#define DEVICE_BLUETOOTH_EMULATION_FAKE_BLUETOOTH_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "device/bluetooth/bluetooth_adapter_factory.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom-forward.h"
|
||||
#include "device/bluetooth/test/fake_central.h"
|
||||
#include "device/bluetooth/emulation/fake_central.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom-forward.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
|
||||
namespace bluetooth {
|
||||
|
||||
// Implementation of FakeBluetooth in
|
||||
// src/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.
|
||||
// src/device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.
|
||||
// Implemented on top of the C++ device/bluetooth API, mainly
|
||||
// device/bluetooth/bluetooth_adapter_factory.h.
|
||||
//
|
||||
@ -40,4 +40,4 @@ class FakeBluetooth : public mojom::FakeBluetooth {
|
||||
|
||||
} // namespace bluetooth
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_TEST_FAKE_BLUETOOTH_H_
|
||||
#endif // DEVICE_BLUETOOTH_EMULATION_FAKE_BLUETOOTH_H_
|
@ -2,7 +2,7 @@
|
||||
// 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_central.h"
|
||||
#include "device/bluetooth/emulation/fake_central.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -17,11 +17,11 @@
|
||||
#include "device/bluetooth/bluetooth_device.h"
|
||||
#include "device/bluetooth/bluetooth_discovery_filter.h"
|
||||
#include "device/bluetooth/bluetooth_discovery_session_outcome.h"
|
||||
#include "device/bluetooth/emulation/fake_peripheral.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_service.h"
|
||||
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom.h"
|
||||
#include "device/bluetooth/test/fake_peripheral.h"
|
||||
#include "device/bluetooth/test/fake_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/test/fake_remote_gatt_service.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
#include "device/bluetooth/bluetooth_low_energy_scan_filter.h"
|
||||
@ -152,19 +152,22 @@ void FakeCentral::SetState(mojom::CentralState new_state,
|
||||
switch (old_state) {
|
||||
case mojom::CentralState::ABSENT:
|
||||
notify_present_changed();
|
||||
if (new_state == mojom::CentralState::POWERED_ON)
|
||||
if (new_state == mojom::CentralState::POWERED_ON) {
|
||||
notify_powered_changed();
|
||||
}
|
||||
break;
|
||||
case mojom::CentralState::POWERED_OFF:
|
||||
if (new_state == mojom::CentralState::ABSENT)
|
||||
if (new_state == mojom::CentralState::ABSENT) {
|
||||
notify_present_changed();
|
||||
else
|
||||
} else {
|
||||
notify_powered_changed();
|
||||
}
|
||||
break;
|
||||
case mojom::CentralState::POWERED_ON:
|
||||
notify_powered_changed();
|
||||
if (new_state == mojom::CentralState::ABSENT)
|
||||
if (new_state == mojom::CentralState::ABSENT) {
|
||||
notify_present_changed();
|
||||
}
|
||||
break;
|
||||
}
|
||||
std::move(callback).Run();
|
@ -1,8 +1,8 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// 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_CENTRAL_H_
|
||||
#define DEVICE_BLUETOOTH_TEST_FAKE_CENTRAL_H_
|
||||
#ifndef DEVICE_BLUETOOTH_EMULATION_FAKE_CENTRAL_H_
|
||||
#define DEVICE_BLUETOOTH_EMULATION_FAKE_CENTRAL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -12,7 +12,7 @@
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "device/bluetooth/bluetooth_adapter.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
|
||||
@ -29,7 +29,7 @@ class FakeRemoteGattDescriptor;
|
||||
class FakeRemoteGattService;
|
||||
|
||||
// Implementation of FakeCentral in
|
||||
// src/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.
|
||||
// src/device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.
|
||||
// Implemented on top of the C++ device/bluetooth API, mainly
|
||||
// device/bluetooth/bluetooth_adapter.h.
|
||||
//
|
||||
@ -251,4 +251,4 @@ class FakeCentral final : public mojom::FakeCentral,
|
||||
|
||||
} // namespace bluetooth
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_TEST_FAKE_CENTRAL_H_
|
||||
#endif // DEVICE_BLUETOOTH_EMULATION_FAKE_CENTRAL_H_
|
@ -2,7 +2,7 @@
|
||||
// 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_peripheral.h"
|
||||
#include "device/bluetooth/emulation/fake_peripheral.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
@ -16,8 +16,8 @@
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "build/build_config.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_service.h"
|
||||
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
|
||||
#include "device/bluetooth/test/fake_remote_gatt_service.h"
|
||||
|
||||
namespace bluetooth {
|
||||
|
||||
@ -300,8 +300,9 @@ void FakePeripheral::CreateGattConnection(
|
||||
|
||||
// TODO(crbug.com/41322843): Stop overriding CreateGattConnection once
|
||||
// IsGattConnected() is fixed. See issue for more details.
|
||||
if (gatt_connected_)
|
||||
if (gatt_connected_) {
|
||||
return DidConnectGatt(/*error_code=*/std::nullopt);
|
||||
}
|
||||
|
||||
CreateGattConnectionImpl(std::move(service_uuid));
|
||||
}
|
||||
@ -377,8 +378,7 @@ void FakePeripheral::DispatchDiscoveryResponse() {
|
||||
}
|
||||
}
|
||||
|
||||
void FakePeripheral::DisconnectGatt() {
|
||||
}
|
||||
void FakePeripheral::DisconnectGatt() {}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
void FakePeripheral::ExecuteWrite(base::OnceClosure callback,
|
@ -1,8 +1,8 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// 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_PERIPHERAL_H_
|
||||
#define DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_
|
||||
#ifndef DEVICE_BLUETOOTH_EMULATION_FAKE_PERIPHERAL_H_
|
||||
#define DEVICE_BLUETOOTH_EMULATION_FAKE_PERIPHERAL_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@ -11,8 +11,8 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "build/build_config.h"
|
||||
#include "device/bluetooth/bluetooth_device.h"
|
||||
#include "device/bluetooth/test/fake_central.h"
|
||||
#include "device/bluetooth/test/fake_remote_gatt_service.h"
|
||||
#include "device/bluetooth/emulation/fake_central.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_service.h"
|
||||
|
||||
namespace device {
|
||||
class BluetoothUUID;
|
||||
@ -179,4 +179,4 @@ class FakePeripheral : public device::BluetoothDevice {
|
||||
|
||||
} // namespace bluetooth
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_TEST_FAKE_PERIPHERAL_H_
|
||||
#endif // DEVICE_BLUETOOTH_EMULATION_FAKE_PERIPHERAL_H_
|
@ -2,7 +2,7 @@
|
||||
// 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_read_response.h"
|
||||
#include "device/bluetooth/emulation/fake_read_response.h"
|
||||
|
||||
namespace bluetooth {
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// 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_READ_RESPONSE_H_
|
||||
#define DEVICE_BLUETOOTH_TEST_FAKE_READ_RESPONSE_H_
|
||||
#ifndef DEVICE_BLUETOOTH_EMULATION_FAKE_READ_RESPONSE_H_
|
||||
#define DEVICE_BLUETOOTH_EMULATION_FAKE_READ_RESPONSE_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
@ -33,4 +33,4 @@ class FakeReadResponse {
|
||||
|
||||
} // namespace bluetooth
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_TEST_FAKE_READ_RESPONSE_H_
|
||||
#endif // DEVICE_BLUETOOTH_EMULATION_FAKE_READ_RESPONSE_H_
|
@ -2,7 +2,7 @@
|
||||
// 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_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_characteristic.h"
|
||||
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
@ -12,8 +12,8 @@
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "device/bluetooth/emulation/fake_read_response.h"
|
||||
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
|
||||
#include "device/bluetooth/test/fake_read_response.h"
|
||||
|
||||
namespace bluetooth {
|
||||
|
||||
@ -26,22 +26,30 @@ FakeRemoteGattCharacteristic::FakeRemoteGattCharacteristic(
|
||||
characteristic_uuid_(characteristic_uuid),
|
||||
service_(service) {
|
||||
properties_ = PROPERTY_NONE;
|
||||
if (properties->broadcast)
|
||||
if (properties->broadcast) {
|
||||
properties_ |= PROPERTY_BROADCAST;
|
||||
if (properties->read)
|
||||
}
|
||||
if (properties->read) {
|
||||
properties_ |= PROPERTY_READ;
|
||||
if (properties->write_without_response)
|
||||
}
|
||||
if (properties->write_without_response) {
|
||||
properties_ |= PROPERTY_WRITE_WITHOUT_RESPONSE;
|
||||
if (properties->write)
|
||||
}
|
||||
if (properties->write) {
|
||||
properties_ |= PROPERTY_WRITE;
|
||||
if (properties->notify)
|
||||
}
|
||||
if (properties->notify) {
|
||||
properties_ |= PROPERTY_NOTIFY;
|
||||
if (properties->indicate)
|
||||
}
|
||||
if (properties->indicate) {
|
||||
properties_ |= PROPERTY_INDICATE;
|
||||
if (properties->authenticated_signed_writes)
|
||||
}
|
||||
if (properties->authenticated_signed_writes) {
|
||||
properties_ |= PROPERTY_AUTHENTICATED_SIGNED_WRITES;
|
||||
if (properties->extended_properties)
|
||||
}
|
||||
if (properties->extended_properties) {
|
||||
properties_ |= PROPERTY_EXTENDED_PROPERTIES;
|
||||
}
|
||||
}
|
||||
|
||||
FakeRemoteGattCharacteristic::~FakeRemoteGattCharacteristic() = default;
|
||||
@ -93,11 +101,10 @@ bool FakeRemoteGattCharacteristic::AllResponsesConsumed() {
|
||||
// SetNextUnsubscribeFromNotificationsResponse is implemented.
|
||||
return !next_read_response_ && !next_write_response_ &&
|
||||
!next_subscribe_to_notifications_response_ &&
|
||||
base::ranges::all_of(
|
||||
descriptors_, [](const auto& e) {
|
||||
return static_cast<FakeRemoteGattDescriptor*>(e.second.get())
|
||||
->AllResponsesConsumed();
|
||||
});
|
||||
base::ranges::all_of(descriptors_, [](const auto& e) {
|
||||
return static_cast<FakeRemoteGattDescriptor*>(e.second.get())
|
||||
->AllResponsesConsumed();
|
||||
});
|
||||
}
|
||||
|
||||
std::string FakeRemoteGattCharacteristic::GetIdentifier() const {
|
@ -1,8 +1,8 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// 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_REMOTE_GATT_CHARACTERISTIC_H_
|
||||
#define DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_CHARACTERISTIC_H_
|
||||
#ifndef DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_CHARACTERISTIC_H_
|
||||
#define DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_CHARACTERISTIC_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -12,10 +12,10 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/emulation/fake_read_response.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_descriptor.h"
|
||||
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom.h"
|
||||
#include "device/bluetooth/test/fake_read_response.h"
|
||||
#include "device/bluetooth/test/fake_remote_gatt_descriptor.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.h"
|
||||
|
||||
namespace device {
|
||||
class BluetoothRemoteGattService;
|
||||
@ -170,4 +170,4 @@ class FakeRemoteGattCharacteristic
|
||||
|
||||
} // namespace bluetooth
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_CHARACTERISTIC_H_
|
||||
#endif // DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_CHARACTERISTIC_H_
|
@ -2,13 +2,13 @@
|
||||
// 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_remote_gatt_descriptor.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_descriptor.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.h"
|
||||
|
||||
namespace bluetooth {
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// 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_REMOTE_GATT_DESCRIPTOR_H_
|
||||
#define DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_DESCRIPTOR_H_
|
||||
#ifndef DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_DESCRIPTOR_H_
|
||||
#define DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_DESCRIPTOR_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@ -12,8 +12,8 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
|
||||
#include "device/bluetooth/emulation/fake_read_response.h"
|
||||
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
|
||||
#include "device/bluetooth/test/fake_read_response.h"
|
||||
|
||||
namespace bluetooth {
|
||||
|
||||
@ -91,4 +91,4 @@ class FakeRemoteGattDescriptor : public device::BluetoothRemoteGattDescriptor {
|
||||
|
||||
} // namespace bluetooth
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_DESCRIPTOR_H_
|
||||
#endif // DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_DESCRIPTOR_H_
|
@ -2,7 +2,7 @@
|
||||
// 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_remote_gatt_service.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_service.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -13,9 +13,9 @@
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "device/bluetooth/bluetooth_device.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom.h"
|
||||
#include "device/bluetooth/test/fake_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.h"
|
||||
|
||||
namespace bluetooth {
|
||||
|
||||
@ -32,11 +32,10 @@ FakeRemoteGattService::FakeRemoteGattService(
|
||||
FakeRemoteGattService::~FakeRemoteGattService() = default;
|
||||
|
||||
bool FakeRemoteGattService::AllResponsesConsumed() {
|
||||
return base::ranges::all_of(
|
||||
characteristics_, [](const auto& e) {
|
||||
return static_cast<FakeRemoteGattCharacteristic*>(e.second.get())
|
||||
->AllResponsesConsumed();
|
||||
});
|
||||
return base::ranges::all_of(characteristics_, [](const auto& e) {
|
||||
return static_cast<FakeRemoteGattCharacteristic*>(e.second.get())
|
||||
->AllResponsesConsumed();
|
||||
});
|
||||
}
|
||||
|
||||
std::string FakeRemoteGattService::AddFakeCharacteristic(
|
@ -1,8 +1,8 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// 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_REMOTE_GATT_SERVICE_H_
|
||||
#define DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_SERVICE_H_
|
||||
#ifndef DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_SERVICE_H_
|
||||
#define DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_SERVICE_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -11,9 +11,9 @@
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "device/bluetooth/bluetooth_remote_gatt_service.h"
|
||||
#include "device/bluetooth/emulation/fake_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom-forward.h"
|
||||
#include "device/bluetooth/test/fake_remote_gatt_characteristic.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom-forward.h"
|
||||
|
||||
namespace device {
|
||||
class BluetoothDevice;
|
||||
@ -67,4 +67,4 @@ class FakeRemoteGattService : public device::BluetoothRemoteGattService {
|
||||
|
||||
} // namespace bluetooth
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_TEST_FAKE_REMOTE_GATT_SERVICE_H_
|
||||
#endif // DEVICE_BLUETOOTH_EMULATION_FAKE_REMOTE_GATT_SERVICE_H_
|
@ -53,7 +53,7 @@ mojom("mojom") {
|
||||
}
|
||||
|
||||
mojom("fake_bluetooth_interfaces") {
|
||||
sources = [ "test/fake_bluetooth.mojom" ]
|
||||
sources = [ "emulation/fake_bluetooth.mojom" ]
|
||||
|
||||
public_deps = [ ":mojom" ]
|
||||
|
||||
@ -65,9 +65,7 @@ mojom("fake_bluetooth_interfaces") {
|
||||
cpp = "::device::BluetoothDevice::ServiceDataMap"
|
||||
},
|
||||
]
|
||||
traits_headers = [
|
||||
"//device/bluetooth/public/mojom/test/fake_bluetooth_mojom_traits.h",
|
||||
]
|
||||
traits_headers = [ "//device/bluetooth/public/mojom/emulation/fake_bluetooth_mojom_traits.h" ]
|
||||
traits_public_deps = [ "//device/bluetooth" ]
|
||||
},
|
||||
]
|
||||
|
@ -2,15 +2,15 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef DEVICE_BLUETOOTH_PUBLIC_MOJOM_TEST_FAKE_BLUETOOTH_MOJOM_TRAITS_H_
|
||||
#define DEVICE_BLUETOOTH_PUBLIC_MOJOM_TEST_FAKE_BLUETOOTH_MOJOM_TRAITS_H_
|
||||
#ifndef DEVICE_BLUETOOTH_PUBLIC_MOJOM_EMULATION_FAKE_BLUETOOTH_MOJOM_TRAITS_H_
|
||||
#define DEVICE_BLUETOOTH_PUBLIC_MOJOM_EMULATION_FAKE_BLUETOOTH_MOJOM_TRAITS_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "device/bluetooth/bluetooth_device.h"
|
||||
#include "device/bluetooth/public/mojom/test/fake_bluetooth.mojom-shared.h"
|
||||
#include "device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom-shared.h"
|
||||
#include "mojo/public/cpp/bindings/struct_traits.h"
|
||||
|
||||
namespace mojo {
|
||||
@ -54,4 +54,4 @@ struct StructTraits<bluetooth::mojom::ServiceDataMapDataView,
|
||||
|
||||
} // namespace mojo
|
||||
|
||||
#endif // DEVICE_BLUETOOTH_PUBLIC_MOJOM_TEST_FAKE_BLUETOOTH_MOJOM_TRAITS_H_
|
||||
#endif // DEVICE_BLUETOOTH_PUBLIC_MOJOM_EMULATION_FAKE_BLUETOOTH_MOJOM_TRAITS_H_
|
@ -27,8 +27,8 @@ Web Platform Tests for Web Bluetooth are being refactored to use
|
||||
`third_party/WebKit/LayoutTests/resources/bluetooth/web-bluetooth-test.js`.
|
||||
|
||||
That library is implemented over a mojo interface `fake_bluetooth.mojom` in
|
||||
[bluetooth/public/mojom/test](/device/bluetooth/public/mojom/test)
|
||||
and is implemented in the `bluetooth/test/fake_*` files.
|
||||
[bluetooth/public/mojom/emulation](/device/bluetooth/public/mojom/emulation)
|
||||
and is implemented in the `bluetooth/emulation/fake_*` files.
|
||||
|
||||
The `fake_bluetooth.mojom` interface is not intended to be used directly.
|
||||
`web-bluetooth-test.js` makes the Fake Bluetooth interface easier to work with.
|
||||
@ -40,7 +40,7 @@ If another C++ client intends to use Fake Bluetooth a C++ wrapper similar to
|
||||
`web-bluetooth-test.js` should be created.
|
||||
|
||||
When a Bluetooth service is created the `fake_bluetooth.mojom` and
|
||||
`bluetooth/test/fake_*` files should be removed and the client facing test
|
||||
`bluetooth/emulation/fake_*` files should be removed and the client facing test
|
||||
wrapper `web-bluetooth-test.js` converted to implement the Bluetooth service as
|
||||
needed for tests.
|
||||
|
||||
|
@ -113,7 +113,7 @@
|
||||
"gen/third_party/blink/public/mojom/usb/web_usb_service.mojom.m.js",
|
||||
"gen/device/bluetooth/public/mojom/uuid.mojom.m.js",
|
||||
"gen/url/mojom/origin.mojom.m.js",
|
||||
"gen/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.m.js",
|
||||
"gen/device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.m.js",
|
||||
"gen/content/web_test/common/fake_bluetooth_chooser.mojom.m.js",
|
||||
"gen/services/device/public/mojom/nfc.mojom.m.js",
|
||||
"gen/services/device/public/mojom/serial.mojom.m.js",
|
||||
|
@ -603,7 +603,7 @@ async function initializeChromiumResources() {
|
||||
content.mojom = await import(
|
||||
'/gen/content/web_test/common/fake_bluetooth_chooser.mojom.m.js');
|
||||
bluetooth.mojom = await import(
|
||||
'/gen/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.m.js');
|
||||
'/gen/device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.m.js');
|
||||
|
||||
const map = MOJO_CHOOSER_EVENT_TYPE_MAP;
|
||||
const types = content.mojom.ChooserEventType;
|
||||
|
2
third_party/blink/web_tests/http/tests/inspector-protocol/device-access/resources/bluetooth-test.js
vendored
2
third_party/blink/web_tests/http/tests/inspector-protocol/device-access/resources/bluetooth-test.js
vendored
@ -8,7 +8,7 @@ class BluetoothHelper {
|
||||
|
||||
async setupFakeBluetooth() {
|
||||
const bluetoothMojom = await import(
|
||||
'/gen/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.m.js');
|
||||
'/gen/device/bluetooth/public/mojom/emulation/fake_bluetooth.mojom.m.js');
|
||||
const contentMojom = await import(
|
||||
'/gen/content/web_test/common/fake_bluetooth_chooser.mojom.m.js');
|
||||
|
||||
|
@ -39,7 +39,7 @@ TODO(https://crbug.com/569709) : Update this document when the remaining
|
||||
[BluetoothFakeAdapter]:
|
||||
../../../../content/shell/browser/web_test/web_test_bluetooth_adapter_provider.h
|
||||
[FakeBluetooth]:
|
||||
../../../../device/bluetooth/test/fake_bluetooth.h
|
||||
../../../../device/bluetooth/emulation/fake_bluetooth.h
|
||||
[Web Bluetooth Testing]:
|
||||
https://docs.google.com/document/d/1Nhv_oVDCodd1pEH_jj9k8gF4rPGb_84VYaZ9IG8M_WY
|
||||
[Web Bluetooth Test API Dependencies]:
|
||||
|
Reference in New Issue
Block a user