Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: trunk/src/device/bluetooth/bluetooth_service_record_win_unittest.cc

Issue 224763003: Revert 261566 "device/bluetooth: Rename device::bluetooth_utils:..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
9 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
10 9
11 namespace { 10 namespace {
12 11
13 const char kTestNoRfcommSdpBytes[] = 12 const char kTestNoRfcommSdpBytes[] =
14 "35510900000a00010001090001350319110a09000435103506190100090019350619001909" 13 "35510900000a00010001090001350319110a09000435103506190100090019350619001909"
15 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75" 14 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75"
16 "726365090311090001"; 15 "726365090311090001";
17 const int kTestNoRfcommSdpBytesSize = sizeof(kTestNoRfcommSdpBytes) / 2; 16 const int kTestNoRfcommSdpBytesSize = sizeof(kTestNoRfcommSdpBytes) / 2;
18 const device::BluetoothUUID kTestNoRfcommSdpUuid("110a"); 17 const char kTestNoRfcommSdpUuid[] = "0000110a-0000-1000-8000-00805f9b34fb";
19 18
20 const char kTestRfcommSdpBytes[] = 19 const char kTestRfcommSdpBytes[] =
21 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308" 20 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308"
22 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465" 21 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465"
23 "776179"; 22 "776179";
24 const int kTestRfcommSdpBytesSize = sizeof(kTestRfcommSdpBytes) / 2; 23 const int kTestRfcommSdpBytesSize = sizeof(kTestRfcommSdpBytes) / 2;
25 const device::BluetoothUUID kTestRfcommSdpUuid("1112"); 24 const char kTestRfcommSdpUuid[] = "00001112-0000-1000-8000-00805f9b34fb";
26 const int kTestRfcommChannel = 11; 25 const int kTestRfcommChannel = 11;
27 26
28 } // namespace 27 } // namespace
29 28
30 namespace device { 29 namespace device {
31 30
32 class BluetoothServiceRecordWinTest : public testing::Test { 31 class BluetoothServiceRecordWinTest : public testing::Test {
33 protected: 32 protected:
34 void ConvertSdpBytes(const char* sdp_hex_char, uint8* sdp_bytes_array) { 33 void ConvertSdpBytes(const char* sdp_hex_char, uint8* sdp_bytes_array) {
35 std::vector<uint8> sdp_bytes_vector; 34 std::vector<uint8> sdp_bytes_vector;
36 base::HexStringToBytes(sdp_hex_char, &sdp_bytes_vector); 35 base::HexStringToBytes(sdp_hex_char, &sdp_bytes_vector);
37 std::copy(sdp_bytes_vector.begin(), 36 std::copy(sdp_bytes_vector.begin(),
38 sdp_bytes_vector.end(), 37 sdp_bytes_vector.end(),
39 sdp_bytes_array); 38 sdp_bytes_array);
40 } 39 }
41 }; 40 };
42 41
43 TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) { 42 TEST_F(BluetoothServiceRecordWinTest, NoRfcommSdp) {
44 uint8 sdp_bytes_array[kTestNoRfcommSdpBytesSize]; 43 uint8 sdp_bytes_array[kTestNoRfcommSdpBytesSize];
45 ConvertSdpBytes(kTestNoRfcommSdpBytes, sdp_bytes_array); 44 ConvertSdpBytes(kTestNoRfcommSdpBytes, sdp_bytes_array);
46 BluetoothServiceRecordWin service_record("NoRfcommSdp", 45 BluetoothServiceRecordWin service_record("NoRfcommSdp",
47 "01:02:03:0A:10:A0", 46 "01:02:03:0A:10:A0",
48 kTestNoRfcommSdpBytesSize, 47 kTestNoRfcommSdpBytesSize,
49 sdp_bytes_array); 48 sdp_bytes_array);
50 EXPECT_EQ(kTestNoRfcommSdpUuid, service_record.uuid()); 49 EXPECT_STREQ(kTestNoRfcommSdpUuid, service_record.uuid().c_str());
51 EXPECT_FALSE(service_record.SupportsRfcomm()); 50 EXPECT_FALSE(service_record.SupportsRfcomm());
52 } 51 }
53 52
54 53
55 TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) { 54 TEST_F(BluetoothServiceRecordWinTest, RfcommSdp) {
56 uint8 sdp_bytes_array[kTestRfcommSdpBytesSize]; 55 uint8 sdp_bytes_array[kTestRfcommSdpBytesSize];
57 ConvertSdpBytes(kTestRfcommSdpBytes, sdp_bytes_array); 56 ConvertSdpBytes(kTestRfcommSdpBytes, sdp_bytes_array);
58 BluetoothServiceRecordWin service_record("RfcommSdp", 57 BluetoothServiceRecordWin service_record("RfcommSdp",
59 "01:02:03:0A:10:A0", 58 "01:02:03:0A:10:A0",
60 kTestRfcommSdpBytesSize, 59 kTestRfcommSdpBytesSize,
61 sdp_bytes_array); 60 sdp_bytes_array);
62 EXPECT_EQ(kTestRfcommSdpUuid, service_record.uuid()); 61 EXPECT_STREQ(kTestRfcommSdpUuid, service_record.uuid().c_str());
63 EXPECT_TRUE(service_record.SupportsRfcomm()); 62 EXPECT_TRUE(service_record.SupportsRfcomm());
64 EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel()); 63 EXPECT_EQ(kTestRfcommChannel, service_record.rfcomm_channel());
65 } 64 }
66 65
67 TEST_F(BluetoothServiceRecordWinTest, BthAddr) { 66 TEST_F(BluetoothServiceRecordWinTest, BthAddr) {
68 uint8 sdp_bytes_array[kTestRfcommSdpBytesSize]; 67 uint8 sdp_bytes_array[kTestRfcommSdpBytesSize];
69 ConvertSdpBytes(kTestRfcommSdpBytes, sdp_bytes_array); 68 ConvertSdpBytes(kTestRfcommSdpBytes, sdp_bytes_array);
70 BluetoothServiceRecordWin service_record("Sdp", 69 BluetoothServiceRecordWin service_record("Sdp",
71 "01:02:03:0A:10:A0", 70 "01:02:03:0A:10:A0",
72 kTestRfcommSdpBytesSize, 71 kTestRfcommSdpBytesSize,
73 sdp_bytes_array); 72 sdp_bytes_array);
74 EXPECT_EQ(1108152553632, service_record.bth_addr()); 73 EXPECT_EQ(1108152553632, service_record.bth_addr());
75 } 74 }
76 75
77 } // namespace device 76 } // namespace device
OLDNEW
« no previous file with comments | « trunk/src/device/bluetooth/bluetooth_service_record_win.cc ('k') | trunk/src/device/bluetooth/bluetooth_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698