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/bind.h" | 6 #include "base/bind.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/test/test_simple_task_runner.h" | 11 #include "base/test/test_simple_task_runner.h" |
12 #include "device/bluetooth/bluetooth_device_win.h" | 12 #include "device/bluetooth/bluetooth_device_win.h" |
13 #include "device/bluetooth/bluetooth_service_record_win.h" | 13 #include "device/bluetooth/bluetooth_service_record_win.h" |
14 #include "device/bluetooth/bluetooth_socket_thread.h" | 14 #include "device/bluetooth/bluetooth_socket_thread.h" |
15 #include "device/bluetooth/bluetooth_task_manager_win.h" | 15 #include "device/bluetooth/bluetooth_task_manager_win.h" |
16 #include "device/bluetooth/bluetooth_uuid.h" | 16 #include "device/bluetooth/bluetooth_uuid.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char kDeviceName[] = "Device"; | 21 const char kDeviceName[] = "Device"; |
22 const char kDeviceAddress[] = "device address"; | 22 const char kDeviceAddress[] = "01:02:03:0A:10:A0"; |
23 | 23 |
24 const char kTestAudioSdpName[] = "Audio"; | 24 const char kTestAudioSdpName[] = "Audio"; |
25 const char kTestAudioSdpAddress[] = "01:02:03:0A:10:A0"; | |
26 const char kTestAudioSdpBytes[] = | 25 const char kTestAudioSdpBytes[] = |
27 "35510900000a00010001090001350319110a09000435103506190100090019350619001909" | 26 "35510900000a00010001090001350319110a09000435103506190100090019350619001909" |
28 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75" | 27 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75" |
29 "726365090311090001"; | 28 "726365090311090001"; |
30 const device::BluetoothUUID kTestAudioSdpUuid("110a"); | 29 const device::BluetoothUUID kTestAudioSdpUuid("110a"); |
31 | 30 |
32 const char kTestVideoSdpName[] = "Video"; | 31 const char kTestVideoSdpName[] = "Video"; |
33 const char kTestVideoSdpAddress[] = "A0:10:0A:03:02:01"; | |
34 const char kTestVideoSdpBytes[] = | 32 const char kTestVideoSdpBytes[] = |
35 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308" | 33 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308" |
36 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465" | 34 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465" |
37 "776179"; | 35 "776179"; |
38 const device::BluetoothUUID kTestVideoSdpUuid("1112"); | 36 const device::BluetoothUUID kTestVideoSdpUuid("1112"); |
39 | 37 |
40 } // namespace | 38 } // namespace |
41 | 39 |
42 namespace device { | 40 namespace device { |
43 | 41 |
44 class BluetoothDeviceWinTest : public testing::Test { | 42 class BluetoothDeviceWinTest : public testing::Test { |
45 public: | 43 public: |
46 BluetoothDeviceWinTest() { | 44 BluetoothDeviceWinTest() { |
47 BluetoothTaskManagerWin::DeviceState device_state; | 45 BluetoothTaskManagerWin::DeviceState device_state; |
48 device_state.name = kDeviceName; | 46 device_state.name = kDeviceName; |
49 device_state.address = kDeviceAddress; | 47 device_state.address = kDeviceAddress; |
50 | 48 |
51 // Add device with audio/video services. | 49 // Add device with audio/video services. |
52 BluetoothTaskManagerWin::ServiceRecordState* audio_state = | 50 BluetoothTaskManagerWin::ServiceRecordState* audio_state = |
53 new BluetoothTaskManagerWin::ServiceRecordState(); | 51 new BluetoothTaskManagerWin::ServiceRecordState(); |
54 audio_state->name = kTestAudioSdpName; | 52 audio_state->name = kTestAudioSdpName; |
55 audio_state->address = kTestAudioSdpAddress; | |
56 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes); | 53 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes); |
57 device_state.service_record_states.push_back(audio_state); | 54 device_state.service_record_states.push_back(audio_state); |
58 | 55 |
59 BluetoothTaskManagerWin::ServiceRecordState* video_state = | 56 BluetoothTaskManagerWin::ServiceRecordState* video_state = |
60 new BluetoothTaskManagerWin::ServiceRecordState(); | 57 new BluetoothTaskManagerWin::ServiceRecordState(); |
61 video_state->name = kTestVideoSdpName; | 58 video_state->name = kTestVideoSdpName; |
62 video_state->address = kTestVideoSdpAddress; | |
63 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes); | 59 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes); |
64 device_state.service_record_states.push_back(video_state); | 60 device_state.service_record_states.push_back(video_state); |
65 | 61 |
66 scoped_refptr<base::SequencedTaskRunner> ui_task_runner( | 62 scoped_refptr<base::SequencedTaskRunner> ui_task_runner( |
67 new base::TestSimpleTaskRunner()); | 63 new base::TestSimpleTaskRunner()); |
68 scoped_refptr<BluetoothSocketThread> socket_thread( | 64 scoped_refptr<BluetoothSocketThread> socket_thread( |
69 BluetoothSocketThread::Get()); | 65 BluetoothSocketThread::Get()); |
70 device_.reset(new BluetoothDeviceWin(device_state, | 66 device_.reset(new BluetoothDeviceWin(device_state, |
71 ui_task_runner, | 67 ui_task_runner, |
72 socket_thread, | 68 socket_thread, |
(...skipping 19 matching lines...) Expand all Loading... |
92 | 88 |
93 EXPECT_EQ(2, uuids.size()); | 89 EXPECT_EQ(2, uuids.size()); |
94 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]); | 90 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]); |
95 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]); | 91 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]); |
96 | 92 |
97 uuids = empty_device_->GetUUIDs(); | 93 uuids = empty_device_->GetUUIDs(); |
98 EXPECT_EQ(0, uuids.size()); | 94 EXPECT_EQ(0, uuids.size()); |
99 } | 95 } |
100 | 96 |
101 } // namespace device | 97 } // namespace device |
OLD | NEW |