1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "device/bluetooth/bluetooth_low_energy_win.h"
6 #include "testing/gtest/include/gtest/gtest.h"
10 const char kValidDeviceInstanceId
[] =
11 "BTHLE\\DEV_BC6A29AB5FB0\\8&31038925&0&BC6A29AB5FB0";
13 const char kInvalidDeviceInstanceId
[] =
14 "BTHLE\\BC6A29AB5FB0_DEV_\\8&31038925&0&BC6A29AB5FB0";
20 class BluetoothLowEnergyWinTest
: public testing::Test
{};
22 TEST_F(BluetoothLowEnergyWinTest
, ExtractValidBluetoothAddress
) {
23 BLUETOOTH_ADDRESS btha
;
26 device::win::ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
27 kValidDeviceInstanceId
, &btha
, &error
);
30 EXPECT_TRUE(error
.empty());
31 EXPECT_EQ(0xbc, btha
.rgBytes
[5]);
32 EXPECT_EQ(0x6a, btha
.rgBytes
[4]);
33 EXPECT_EQ(0x29, btha
.rgBytes
[3]);
34 EXPECT_EQ(0xab, btha
.rgBytes
[2]);
35 EXPECT_EQ(0x5f, btha
.rgBytes
[1]);
36 EXPECT_EQ(0xb0, btha
.rgBytes
[0]);
39 TEST_F(BluetoothLowEnergyWinTest
, ExtractInvalidBluetoothAddress
) {
40 BLUETOOTH_ADDRESS btha
;
43 device::win::ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
44 kInvalidDeviceInstanceId
, &btha
, &error
);
46 EXPECT_FALSE(success
);
47 EXPECT_FALSE(error
.empty());