| 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 "base/basictypes.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "device/bluetooth/bluetooth_service_record_win.h" | 7 #include "device/bluetooth/bluetooth_service_record_win.h" |
| 8 #include "device/bluetooth/bluetooth_uuid.h" | 8 #include "device/bluetooth/bluetooth_uuid.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 const int kTestRfcommSdpBytesSize = sizeof(kTestRfcommSdpBytes) / 2; | 24 const int kTestRfcommSdpBytesSize = sizeof(kTestRfcommSdpBytes) / 2; |
| 25 const device::BluetoothUUID kTestRfcommSdpUuid("1112"); | 25 const device::BluetoothUUID kTestRfcommSdpUuid("1112"); |
| 26 const int kTestRfcommChannel = 11; | 26 const int kTestRfcommChannel = 11; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 namespace device { | 30 namespace device { |
| 31 | 31 |
| 32 class BluetoothServiceRecordWinTest : public testing::Test { | 32 class BluetoothServiceRecordWinTest : public testing::Test { |
| 33 protected: | 33 protected: |
| 34 void ConvertSdpBytes(const char* sdp_hex_char, uint8* sdp_bytes_array) { | 34 void ConvertSdpBytes(const char* sdp_hex_char, |
| 35 std::vector<uint8> sdp_bytes_vector; | 35 std::vector<uint8>* sdp_bytes_vector) { |
| 36 base::HexStringToBytes(sdp_hex_char, &sdp_bytes_vector); | 36 base::HexStringToBytes(sdp_hex_char, sdp_bytes_vector); |
| 37 std::copy(sdp_bytes_vector.begin(), | |
| 38 sdp_bytes_vector.end(), | |
| 39 sdp_bytes_array); | |
| 40 } | 37 } |
| 41 }; | 38 }; |
| 42 | 39 |
| 43 TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) { | 40 TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) { |
| 44 uint8 sdp_bytes_array[kTestNoRfcommSdpBytesSize]; | 41 std::vector<uint8> sdp_bytes_array; |
| 45 ConvertSdpBytes(kTestNoRfcommSdpBytes, sdp_bytes_array); | 42 ConvertSdpBytes(kTestNoRfcommSdpBytes, &sdp_bytes_array); |
| 46 BluetoothServiceRecordWin service_record("NoRfcommSdp", | 43 BluetoothServiceRecordWin service_record( |
| 47 "01:02:03:0A:10:A0", | 44 "01:02:03:0A:10:A0", "NoRfcommSdp", sdp_bytes_array, BluetoothUUID()); |
| 48 kTestNoRfcommSdpBytesSize, | |
| 49 sdp_bytes_array); | |
| 50 EXPECT_EQ(kTestNoRfcommSdpUuid, service_record.uuid()); | 45 EXPECT_EQ(kTestNoRfcommSdpUuid, service_record.uuid()); |
| 51 EXPECT_FALSE(service_record.SupportsRfcomm()); | 46 EXPECT_FALSE(service_record.SupportsRfcomm()); |
| 52 } | 47 } |
| 53 | 48 |
| 54 | 49 |
| 55 TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) { | 50 TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) { |
| 56 uint8 sdp_bytes_array[kTestRfcommSdpBytesSize]; | 51 std::vector<uint8> sdp_bytes_array; |
| 57 ConvertSdpBytes(kTestRfcommSdpBytes, sdp_bytes_array); | 52 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array); |
| 58 BluetoothServiceRecordWin service_record("RfcommSdp", | 53 BluetoothServiceRecordWin service_record( |
| 59 "01:02:03:0A:10:A0", | 54 "01:02:03:0A:10:A0", "RfcommSdp", sdp_bytes_array, BluetoothUUID()); |
| 60 kTestRfcommSdpBytesSize, | |
| 61 sdp_bytes_array); | |
| 62 EXPECT_EQ(kTestRfcommSdpUuid, service_record.uuid()); | 55 EXPECT_EQ(kTestRfcommSdpUuid, service_record.uuid()); |
| 63 EXPECT_TRUE(service_record.SupportsRfcomm()); | 56 EXPECT_TRUE(service_record.SupportsRfcomm()); |
| 64 EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel()); | 57 EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel()); |
| 65 } | 58 } |
| 66 | 59 |
| 67 TEST_F(BluetoothServiceRecordWinTest, BthAddr) { | 60 TEST_F(BluetoothServiceRecordWinTest, BthAddr) { |
| 68 uint8 sdp_bytes_array[kTestRfcommSdpBytesSize]; | 61 std::vector<uint8> sdp_bytes_array; |
| 69 ConvertSdpBytes(kTestRfcommSdpBytes, sdp_bytes_array); | 62 ConvertSdpBytes(kTestRfcommSdpBytes, &sdp_bytes_array); |
| 70 BluetoothServiceRecordWin service_record("Sdp", | 63 BluetoothServiceRecordWin service_record( |
| 71 "01:02:03:0A:10:A0", | 64 "01:02:03:0A:10:A0", "Sdp", sdp_bytes_array, BluetoothUUID()); |
| 72 kTestRfcommSdpBytesSize, | 65 EXPECT_EQ(1108152553632, service_record.device_bth_addr()); |
| 73 sdp_bytes_array); | |
| 74 EXPECT_EQ(1108152553632, service_record.bth_addr()); | |
| 75 } | 66 } |
| 76 | 67 |
| 77 } // namespace device | 68 } // namespace device |
| OLD | NEW |