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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "device/bluetooth/bluetooth_device_win.h" | 10 #include "device/bluetooth/bluetooth_device_win.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 TEST_F(BluetoothDeviceWinTest, GetServiceRecords) { | 95 TEST_F(BluetoothDeviceWinTest, GetServiceRecords) { |
96 device_->GetServiceRecords( | 96 device_->GetServiceRecords( |
97 base::Bind(&BluetoothDeviceWinTest::GetServiceRecords, | 97 base::Bind(&BluetoothDeviceWinTest::GetServiceRecords, |
98 base::Unretained(this)), | 98 base::Unretained(this)), |
99 BluetoothDevice::ErrorCallback()); | 99 BluetoothDevice::ErrorCallback()); |
100 ASSERT_TRUE(service_records_ != NULL); | 100 ASSERT_TRUE(service_records_ != NULL); |
101 EXPECT_EQ(2, service_records_->size()); | 101 EXPECT_EQ(2, service_records_->size()); |
102 EXPECT_STREQ(kTestAudioSdpUuid, (*service_records_)[0]->uuid().c_str()); | 102 EXPECT_STREQ(kTestAudioSdpUuid, (*service_records_)[0]->uuid().c_str()); |
103 EXPECT_STREQ(kTestVideoSdpUuid, (*service_records_)[1]->uuid().c_str()); | 103 EXPECT_STREQ(kTestVideoSdpUuid, (*service_records_)[1]->uuid().c_str()); |
| 104 |
| 105 BluetoothDeviceWin* device_win = |
| 106 reinterpret_cast<BluetoothDeviceWin*>(device_.get()); |
| 107 |
| 108 const BluetoothServiceRecord* audio_device = |
| 109 device_win->GetServiceRecord(kTestAudioSdpUuid); |
| 110 ASSERT_TRUE(audio_device != NULL); |
| 111 EXPECT_EQ((*service_records_)[0], audio_device); |
| 112 |
| 113 const BluetoothServiceRecord* video_device = |
| 114 device_win->GetServiceRecord(kTestVideoSdpUuid); |
| 115 ASSERT_TRUE(video_device != NULL); |
| 116 EXPECT_EQ((*service_records_)[1], video_device); |
| 117 |
| 118 const BluetoothServiceRecord* invalid_device = |
| 119 device_win->GetServiceRecord(kTestVideoSdpAddress); |
| 120 EXPECT_TRUE(invalid_device == NULL); |
104 } | 121 } |
105 | 122 |
106 TEST_F(BluetoothDeviceWinTest, ProvidesServiceWithName) { | 123 TEST_F(BluetoothDeviceWinTest, ProvidesServiceWithName) { |
107 device_->ProvidesServiceWithName( | 124 device_->ProvidesServiceWithName( |
108 kTestAudioSdpName, | 125 kTestAudioSdpName, |
109 base::Bind(&BluetoothDeviceWinTest::SetProvidesServiceWithName, | 126 base::Bind(&BluetoothDeviceWinTest::SetProvidesServiceWithName, |
110 base::Unretained(this))); | 127 base::Unretained(this))); |
111 EXPECT_TRUE(provides_service_with_name_); | 128 EXPECT_TRUE(provides_service_with_name_); |
112 | 129 |
113 device_->ProvidesServiceWithName( | 130 device_->ProvidesServiceWithName( |
114 kTestVideoSdpName, | 131 kTestVideoSdpName, |
115 base::Bind(&BluetoothDeviceWinTest::SetProvidesServiceWithName, | 132 base::Bind(&BluetoothDeviceWinTest::SetProvidesServiceWithName, |
116 base::Unretained(this))); | 133 base::Unretained(this))); |
117 EXPECT_TRUE(provides_service_with_name_); | 134 EXPECT_TRUE(provides_service_with_name_); |
118 | 135 |
119 device_->ProvidesServiceWithName( | 136 device_->ProvidesServiceWithName( |
120 "name that does not exist", | 137 "name that does not exist", |
121 base::Bind(&BluetoothDeviceWinTest::SetProvidesServiceWithName, | 138 base::Bind(&BluetoothDeviceWinTest::SetProvidesServiceWithName, |
122 base::Unretained(this))); | 139 base::Unretained(this))); |
123 EXPECT_FALSE(provides_service_with_name_); | 140 EXPECT_FALSE(provides_service_with_name_); |
124 } | 141 } |
125 | 142 |
126 } // namespace device | 143 } // namespace device |
OLD | NEW |