| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include <stdint.h> |
| 6 |
| 6 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 7 #include "device/bluetooth/bluetooth_service_record_win.h" | 8 #include "device/bluetooth/bluetooth_service_record_win.h" |
| 8 #include "device/bluetooth/bluetooth_uuid.h" | 9 #include "device/bluetooth/bluetooth_uuid.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 const char kTestNoRfcommSdpBytes[] = | 14 const char kTestNoRfcommSdpBytes[] = |
| 14 "35510900000a00010001090001350319110a09000435103506190100090019350619001909" | 15 "35510900000a00010001090001350319110a09000435103506190100090019350619001909" |
| 15 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75" | 16 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75" |
| 16 "726365090311090001"; | 17 "726365090311090001"; |
| 17 const device::BluetoothUUID kTestNoRfcommSdpUuid("110a"); | 18 const device::BluetoothUUID kTestNoRfcommSdpUuid("110a"); |
| 18 | 19 |
| 19 const char kTestRfcommSdpBytes[] = | 20 const char kTestRfcommSdpBytes[] = |
| 20 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308" | 21 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308" |
| 21 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465" | 22 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465" |
| 22 "776179"; | 23 "776179"; |
| 23 const device::BluetoothUUID kTestRfcommSdpUuid("1112"); | 24 const device::BluetoothUUID kTestRfcommSdpUuid("1112"); |
| 24 const int kTestRfcommChannel = 11; | 25 const int kTestRfcommChannel = 11; |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 28 namespace device { | 29 namespace device { |
| 29 | 30 |
| 30 class BluetoothServiceRecordWinTest : public testing::Test { | 31 class BluetoothServiceRecordWinTest : public testing::Test { |
| 31 protected: | 32 protected: |
| 32 void ConvertSdpBytes(const char* sdp_hex_char, | 33 void ConvertSdpBytes(const char* sdp_hex_char, |
| 33 std::vector<uint8>* sdp_bytes_vector) { | 34 std::vector<uint8_t>* sdp_bytes_vector) { |
| 34 base::HexStringToBytes(sdp_hex_char, sdp_bytes_vector); | 35 base::HexStringToBytes(sdp_hex_char, sdp_bytes_vector); |
| 35 } | 36 } |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) { | 39 TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) { |
| 39 std::vector<uint8> sdp_bytes_array; | 40 std::vector<uint8_t> sdp_bytes_array; |
| 40 ConvertSdpBytes(kTestNoRfcommSdpBytes, &sdp_bytes_array); | 41 ConvertSdpBytes(kTestNoRfcommSdpBytes, &sdp_bytes_array); |
| 41 BluetoothServiceRecordWin service_record( | 42 BluetoothServiceRecordWin service_record( |
| 42 "01:02:03:0A:10:A0", "NoRfcommSdp", sdp_bytes_array, BluetoothUUID()); | 43 "01:02:03:0A:10:A0", "NoRfcommSdp", sdp_bytes_array, BluetoothUUID()); |
| 43 EXPECT_EQ(kTestNoRfcommSdpUuid, service_record.uuid()); | 44 EXPECT_EQ(kTestNoRfcommSdpUuid, service_record.uuid()); |
| 44 EXPECT_FALSE(service_record.SupportsRfcomm()); | 45 EXPECT_FALSE(service_record.SupportsRfcomm()); |
| 45 } | 46 } |
| 46 | 47 |
| 47 | 48 |
| 48 TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) { | 49 TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) { |
| 49 std::vector<uint8> sdp_bytes_array; | 50 std::vector<uint8_t> sdp_bytes_array; |
| 50 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array); | 51 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array); |
| 51 BluetoothServiceRecordWin service_record( | 52 BluetoothServiceRecordWin service_record( |
| 52 "01:02:03:0A:10:A0", "RfcommSdp", sdp_bytes_array, BluetoothUUID()); | 53 "01:02:03:0A:10:A0", "RfcommSdp", sdp_bytes_array, BluetoothUUID()); |
| 53 EXPECT_EQ(kTestRfcommSdpUuid, service_record.uuid()); | 54 EXPECT_EQ(kTestRfcommSdpUuid, service_record.uuid()); |
| 54 EXPECT_TRUE(service_record.SupportsRfcomm()); | 55 EXPECT_TRUE(service_record.SupportsRfcomm()); |
| 55 EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel()); | 56 EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel()); |
| 56 } | 57 } |
| 57 | 58 |
| 58 TEST_F(BluetoothServiceRecordWinTest, BthAddr) { | 59 TEST_F(BluetoothServiceRecordWinTest, BthAddr) { |
| 59 std::vector<uint8> sdp_bytes_array; | 60 std::vector<uint8_t> sdp_bytes_array; |
| 60 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array); | 61 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array); |
| 61 BluetoothServiceRecordWin service_record( | 62 BluetoothServiceRecordWin service_record( |
| 62 "01:02:03:0A:10:A0", "Sdp", sdp_bytes_array, BluetoothUUID()); | 63 "01:02:03:0A:10:A0", "Sdp", sdp_bytes_array, BluetoothUUID()); |
| 63 EXPECT_EQ(1108152553632ull, service_record.device_bth_addr()); | 64 EXPECT_EQ(1108152553632ull, service_record.device_bth_addr()); |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace device | 67 } // namespace device |
| OLD | NEW |