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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 audio_state->name = kTestAudioSdpName; | 57 audio_state->name = kTestAudioSdpName; |
58 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes); | 58 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes); |
59 device_state_->service_record_states.push_back(audio_state); | 59 device_state_->service_record_states.push_back(audio_state); |
60 | 60 |
61 BluetoothTaskManagerWin::ServiceRecordState* video_state = | 61 BluetoothTaskManagerWin::ServiceRecordState* video_state = |
62 new BluetoothTaskManagerWin::ServiceRecordState(); | 62 new BluetoothTaskManagerWin::ServiceRecordState(); |
63 video_state->name = kTestVideoSdpName; | 63 video_state->name = kTestVideoSdpName; |
64 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes); | 64 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes); |
65 device_state_->service_record_states.push_back(video_state); | 65 device_state_->service_record_states.push_back(video_state); |
66 | 66 |
67 device_.reset(new BluetoothDeviceWin(*device_state_, | 67 device_.reset(new BluetoothDeviceWin(NULL, *device_state_, ui_task_runner, |
68 ui_task_runner, | 68 socket_thread, NULL, |
69 socket_thread, | |
70 NULL, | |
71 net::NetLog::Source())); | 69 net::NetLog::Source())); |
72 | 70 |
73 // Add empty device. | 71 // Add empty device. |
74 empty_device_state_.reset(new BluetoothTaskManagerWin::DeviceState()); | 72 empty_device_state_.reset(new BluetoothTaskManagerWin::DeviceState()); |
75 empty_device_state_->name = kDeviceName; | 73 empty_device_state_->name = kDeviceName; |
76 empty_device_state_->address = kDeviceAddress; | 74 empty_device_state_->address = kDeviceAddress; |
77 empty_device_.reset(new BluetoothDeviceWin(*empty_device_state_, | 75 empty_device_.reset(new BluetoothDeviceWin(NULL, *empty_device_state_, |
78 ui_task_runner, | 76 ui_task_runner, socket_thread, |
79 socket_thread, | 77 NULL, net::NetLog::Source())); |
80 NULL, | |
81 net::NetLog::Source())); | |
82 } | 78 } |
83 | 79 |
84 protected: | 80 protected: |
85 scoped_ptr<BluetoothDeviceWin> device_; | 81 scoped_ptr<BluetoothDeviceWin> device_; |
86 scoped_ptr<BluetoothTaskManagerWin::DeviceState> device_state_; | 82 scoped_ptr<BluetoothTaskManagerWin::DeviceState> device_state_; |
87 scoped_ptr<BluetoothDeviceWin> empty_device_; | 83 scoped_ptr<BluetoothDeviceWin> empty_device_; |
88 scoped_ptr<BluetoothTaskManagerWin::DeviceState> empty_device_state_; | 84 scoped_ptr<BluetoothTaskManagerWin::DeviceState> empty_device_state_; |
89 }; | 85 }; |
90 | 86 |
91 TEST_F(BluetoothDeviceWinTest, GetUUIDs) { | 87 TEST_F(BluetoothDeviceWinTest, GetUUIDs) { |
92 BluetoothDevice::UUIDList uuids = device_->GetUUIDs(); | 88 BluetoothDevice::UUIDList uuids = device_->GetUUIDs(); |
93 | 89 |
94 EXPECT_EQ(2, uuids.size()); | 90 EXPECT_EQ(2, uuids.size()); |
95 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]); | 91 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]); |
96 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]); | 92 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]); |
97 | 93 |
98 uuids = empty_device_->GetUUIDs(); | 94 uuids = empty_device_->GetUUIDs(); |
99 EXPECT_EQ(0, uuids.size()); | 95 EXPECT_EQ(0, uuids.size()); |
100 } | 96 } |
101 | 97 |
102 TEST_F(BluetoothDeviceWinTest, IsEqual) { | 98 TEST_F(BluetoothDeviceWinTest, IsEqual) { |
103 EXPECT_TRUE(device_->IsEqual(*device_state_)); | 99 EXPECT_TRUE(device_->IsEqual(*device_state_)); |
104 EXPECT_FALSE(device_->IsEqual(*empty_device_state_)); | 100 EXPECT_FALSE(device_->IsEqual(*empty_device_state_)); |
105 EXPECT_FALSE(empty_device_->IsEqual(*device_state_)); | 101 EXPECT_FALSE(empty_device_->IsEqual(*device_state_)); |
106 EXPECT_TRUE(empty_device_->IsEqual(*empty_device_state_)); | 102 EXPECT_TRUE(empty_device_->IsEqual(*empty_device_state_)); |
107 } | 103 } |
108 | 104 |
109 } // namespace device | 105 } // namespace device |
OLD | NEW |