#include "headless/lib/browser/headless_bluetooth_delegate.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/bluetooth/web_bluetooth_device_id.h"
#include "third_party/blink/public/mojom/bluetooth/web_bluetooth.mojom.h"
namespace headless {
using ::blink::WebBluetoothDeviceId;
using ::device::BluetoothUUID;
class HeadlessBluetoothDelegateTest : public testing::Test {
protected:
HeadlessBluetoothDelegate delegate_;
};
TEST_F(HeadlessBluetoothDelegateTest, RunBluetoothChooser) {
auto chooser =
delegate_.RunBluetoothChooser(nullptr, {});
EXPECT_NE(chooser, nullptr);
}
TEST_F(HeadlessBluetoothDelegateTest, ShowBluetoothScanningPrompt) {
auto prompt = delegate_.ShowBluetoothScanningPrompt(nullptr,
{});
EXPECT_EQ(prompt, nullptr);
}
TEST_F(HeadlessBluetoothDelegateTest, GetWebBluetoothDeviceId) {
auto id =
delegate_.GetWebBluetoothDeviceId(nullptr, "12:34:56:78:90:AB");
EXPECT_FALSE(id.IsValid());
}
TEST_F(HeadlessBluetoothDelegateTest, GetDeviceAddress) {
WebBluetoothDeviceId id;
auto address = delegate_.GetDeviceAddress(nullptr, id);
EXPECT_TRUE(address.empty());
}
TEST_F(HeadlessBluetoothDelegateTest, AddScannedDevice) {
auto id = delegate_.AddScannedDevice(nullptr, "12:34:56:78:90:AB");
EXPECT_FALSE(id.IsValid());
}
TEST_F(HeadlessBluetoothDelegateTest, GrantServiceAccessPermission) {
auto id = delegate_.GrantServiceAccessPermission(
nullptr, nullptr, nullptr);
EXPECT_FALSE(id.IsValid());
}
TEST_F(HeadlessBluetoothDelegateTest, HasDevicePermission) {
EXPECT_FALSE(
delegate_.HasDevicePermission(nullptr, WebBluetoothDeviceId()));
}
TEST_F(HeadlessBluetoothDelegateTest, MayUseBluetooth) {
EXPECT_TRUE(delegate_.MayUseBluetooth(nullptr));
}
TEST_F(HeadlessBluetoothDelegateTest, IsAllowedToAccessService) {
EXPECT_FALSE(delegate_.IsAllowedToAccessService(
nullptr, WebBluetoothDeviceId(),
BluetoothUUID("12345678-1234-5678-9abc-def123456789")));
}
TEST_F(HeadlessBluetoothDelegateTest, IsAllowedToAccessAtLeastOneService) {
EXPECT_FALSE(delegate_.IsAllowedToAccessAtLeastOneService(
nullptr, WebBluetoothDeviceId()));
}
TEST_F(HeadlessBluetoothDelegateTest, IsAllowedToAccessManufacturerData) {
EXPECT_FALSE(delegate_.IsAllowedToAccessManufacturerData(
nullptr, WebBluetoothDeviceId(), 0));
}
TEST_F(HeadlessBluetoothDelegateTest, GetPermittedDevices) {
EXPECT_TRUE(delegate_.GetPermittedDevices(nullptr).empty());
}
}