Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / device / bluetooth / bluetooth_service_record_win_unittest.cc
blob8128cb407c74c031f2aa2bdff919793ddd654066
1 // Copyright (c) 2013 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 "base/basictypes.h"
6 #include "base/strings/string_number_conversions.h"
7 #include "device/bluetooth/bluetooth_service_record_win.h"
8 #include "device/bluetooth/bluetooth_uuid.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace {
13 const char kTestNoRfcommSdpBytes[] =
14 "35510900000a00010001090001350319110a09000435103506190100090019350619001909"
15 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75"
16 "726365090311090001";
17 const int kTestNoRfcommSdpBytesSize = sizeof(kTestNoRfcommSdpBytes) / 2;
18 const device::BluetoothUUID kTestNoRfcommSdpUuid("110a");
20 const char kTestRfcommSdpBytes[] =
21 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308"
22 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465"
23 "776179";
24 const int kTestRfcommSdpBytesSize = sizeof(kTestRfcommSdpBytes) / 2;
25 const device::BluetoothUUID kTestRfcommSdpUuid("1112");
26 const int kTestRfcommChannel = 11;
28 } // namespace
30 namespace device {
32 class BluetoothServiceRecordWinTest : public testing::Test {
33 protected:
34 void ConvertSdpBytes(const char* sdp_hex_char,
35 std::vector<uint8>* sdp_bytes_vector) {
36 base::HexStringToBytes(sdp_hex_char, sdp_bytes_vector);
40 TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) {
41 std::vector<uint8> sdp_bytes_array;
42 ConvertSdpBytes(kTestNoRfcommSdpBytes, &sdp_bytes_array);
43 BluetoothServiceRecordWin service_record(
44 "01:02:03:0A:10:A0", "NoRfcommSdp", sdp_bytes_array, BluetoothUUID());
45 EXPECT_EQ(kTestNoRfcommSdpUuid, service_record.uuid());
46 EXPECT_FALSE(service_record.SupportsRfcomm());
50 TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) {
51 std::vector<uint8> sdp_bytes_array;
52 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array);
53 BluetoothServiceRecordWin service_record(
54 "01:02:03:0A:10:A0", "RfcommSdp", sdp_bytes_array, BluetoothUUID());
55 EXPECT_EQ(kTestRfcommSdpUuid, service_record.uuid());
56 EXPECT_TRUE(service_record.SupportsRfcomm());
57 EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel());
60 TEST_F(BluetoothServiceRecordWinTest, BthAddr) {
61 std::vector<uint8> sdp_bytes_array;
62 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array);
63 BluetoothServiceRecordWin service_record(
64 "01:02:03:0A:10:A0", "Sdp", sdp_bytes_array, BluetoothUUID());
65 EXPECT_EQ(1108152553632, service_record.device_bth_addr());
68 } // namespace device