naiveproxy/content/shell/common/layout_test/fake_bluetooth_chooser.mojom
2018-08-11 05:35:24 +00:00

69 lines
2.2 KiB
Plaintext

// 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.
module content.mojom;
// This interface is being developed to support Web Platform Tests for Web
// Bluetooth.
// https://docs.google.com/document/d/1Nhv_oVDCodd1pEH_jj9k8gF4rPGb_84VYaZ9IG8M_WY
//
// These interfaces are not intended to be used directly.
// `web-bluetooth-test.js` makes the Fake Bluetooth interface easier to work
// with.
// * Calls are synchronous.
// * IDs are cached.
//
// If another C++ client intends to use FakeBluetooth a C++ wrapper similar to
// `web-bluetooth-test.js` should be created.
//
// The implementation details of FakeBluetoothChooser can be found in the Web
// Bluetooth Test Scanning design document.
// https://docs.google.com/document/d/1XFl_4ZAgO8ddM6U53A9AfUuZeWgJnlYD5wtbXqEpzeg
// Indicates the types of Bluetooth chooser events.
enum ChooserEventType {
CHOOSER_OPENED,
SCAN_STARTED,
DEVICE_UPDATE,
ADAPTER_REMOVED,
ADAPTER_DISABLED,
ADAPTER_ENABLED,
DISCOVERY_FAILED_TO_START,
DISCOVERING,
DISCOVERY_IDLE,
ADD_DEVICE,
};
// FakeBluetoothChooser allows clients to control the global state of the
// Bluetooth chooser during a layout test.
interface FakeBluetoothChooser {
// Waits until at least |num_of_events| have been recorded before returning
// |num_of_events| FakeBluetoothChooserEvents.
WaitForEvents(
uint32 num_of_events) => (array<FakeBluetoothChooserEvent> events);
// Simulates a user selecting the given |peripheral_address| in the Bluetooth
// chooser.
SelectPeripheral(string peripheral_address) => ();
// Calls the event handler function with the CANCELLED event.
Cancel() => ();
// Calls the event handler function with the RESCAN event.
Rescan() => ();
};
// FakeBluetoothChooserEvent describes the type of chooser event that has been
// produced by the FakeBluetoothChooser.
struct FakeBluetoothChooserEvent {
ChooserEventType type;
// Describes the origin the chooser is currently displaying.
// This field will be used by the |CHOOSER_OPENED| event type.
string? origin;
// Describes the MAC address of the Bluetooth device.
string? peripheral_address;
};