File: bluetooth_service_record_win_unittest.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (67 lines) | stat: -rw-r--r-- 2,449 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stdint.h>

#include "base/strings/string_number_conversions.h"
#include "device/bluetooth/bluetooth_service_record_win.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

const char kTestNoRfcommSdpBytes[] =
    "35510900000a00010001090001350319110a09000435103506190100090019350619001909"
    "010209000535031910020900093508350619110d090102090100250c417564696f20536f75"
    "726365090311090001";
const device::BluetoothUUID kTestNoRfcommSdpUuid("110a");

const char kTestRfcommSdpBytes[] =
    "354b0900000a000100030900013506191112191203090004350c3503190100350519000308"
    "0b090005350319100209000935083506191108090100090100250d566f6963652047617465"
    "776179";
const device::BluetoothUUID kTestRfcommSdpUuid("1112");
const int kTestRfcommChannel = 11;

}  // namespace

namespace device {

class BluetoothServiceRecordWinTest : public testing::Test {
 protected:
  void ConvertSdpBytes(const char* sdp_hex_char,
                       std::vector<uint8_t>* sdp_bytes_vector) {
    base::HexStringToBytes(sdp_hex_char, sdp_bytes_vector);
  }
};

TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) {
  std::vector<uint8_t> sdp_bytes_array;
  ConvertSdpBytes(kTestNoRfcommSdpBytes, &sdp_bytes_array);
  BluetoothServiceRecordWin service_record(
      "01:02:03:0A:10:A0", "NoRfcommSdp", sdp_bytes_array, BluetoothUUID());
  EXPECT_EQ(kTestNoRfcommSdpUuid, service_record.uuid());
  EXPECT_FALSE(service_record.SupportsRfcomm());
}


TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) {
  std::vector<uint8_t> sdp_bytes_array;
  ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array);
  BluetoothServiceRecordWin service_record(
      "01:02:03:0A:10:A0", "RfcommSdp", sdp_bytes_array, BluetoothUUID());
  EXPECT_EQ(kTestRfcommSdpUuid, service_record.uuid());
  EXPECT_TRUE(service_record.SupportsRfcomm());
  EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel());
}

TEST_F(BluetoothServiceRecordWinTest, BthAddr) {
  std::vector<uint8_t> sdp_bytes_array;
  ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array);
  BluetoothServiceRecordWin service_record(
      "01:02:03:0A:10:A0", "Sdp", sdp_bytes_array, BluetoothUUID());
  EXPECT_EQ(1108152553632ull, service_record.device_bth_addr());
}

}  // namespace device