OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "dbus/object_path.h" | 11 #include "dbus/object_path.h" |
12 #include "device/bluetooth/bluetooth_adapter.h" | 12 #include "device/bluetooth/bluetooth_adapter.h" |
13 #include "device/bluetooth/bluetooth_adapter_factory.h" | 13 #include "device/bluetooth/bluetooth_adapter_factory.h" |
14 #include "device/bluetooth/bluetooth_audio_sink.h" | 14 #include "device/bluetooth/bluetooth_audio_sink.h" |
15 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h" | 15 #include "device/bluetooth/bluetooth_audio_sink_bluez.h" |
16 #include "device/bluetooth/dbus/bluetooth_media_client.h" | 16 #include "device/bluetooth/dbus/bluetooth_media_client.h" |
17 #include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" | 17 #include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" |
18 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" | 18 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" |
19 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 19 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
20 #include "device/bluetooth/dbus/fake_bluetooth_media_client.h" | 20 #include "device/bluetooth/dbus/fake_bluetooth_media_client.h" |
21 #include "device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h
" | 21 #include "device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h
" |
22 #include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" | 22 #include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 using bluez::FakeBluetoothMediaTransportClient; | 25 using bluez::FakeBluetoothMediaTransportClient; |
26 using dbus::ObjectPath; | 26 using dbus::ObjectPath; |
27 using device::BluetoothAdapter; | 27 using device::BluetoothAdapter; |
28 using device::BluetoothAdapterFactory; | 28 using device::BluetoothAdapterFactory; |
29 using device::BluetoothAudioSink; | 29 using device::BluetoothAudioSink; |
30 | 30 |
31 namespace chromeos { | 31 namespace bluez { |
32 | 32 |
33 class TestAudioSinkObserver : public BluetoothAudioSink::Observer { | 33 class TestAudioSinkObserver : public BluetoothAudioSink::Observer { |
34 public: | 34 public: |
35 explicit TestAudioSinkObserver(scoped_refptr<BluetoothAudioSink> audio_sink) | 35 explicit TestAudioSinkObserver(scoped_refptr<BluetoothAudioSink> audio_sink) |
36 : state_changed_count_(0), | 36 : state_changed_count_(0), |
37 volume_changed_count_(0), | 37 volume_changed_count_(0), |
38 total_read_(0), | 38 total_read_(0), |
39 state_(audio_sink->GetState()), | 39 state_(audio_sink->GetState()), |
40 audio_sink_(audio_sink) { | 40 audio_sink_(audio_sink) { |
41 audio_sink_->AddObserver(this); | 41 audio_sink_->AddObserver(this); |
(...skipping 30 matching lines...) Expand all Loading... |
72 int data_available_count_; | 72 int data_available_count_; |
73 size_t total_read_; | 73 size_t total_read_; |
74 std::vector<char> data_; | 74 std::vector<char> data_; |
75 uint16_t read_mtu_; | 75 uint16_t read_mtu_; |
76 BluetoothAudioSink::State state_; | 76 BluetoothAudioSink::State state_; |
77 | 77 |
78 private: | 78 private: |
79 scoped_refptr<BluetoothAudioSink> audio_sink_; | 79 scoped_refptr<BluetoothAudioSink> audio_sink_; |
80 }; | 80 }; |
81 | 81 |
82 class BluetoothAudioSinkChromeOSTest : public testing::Test { | 82 class BluetoothAudioSinkBlueZTest : public testing::Test { |
83 public: | 83 public: |
84 void SetUp() override { | 84 void SetUp() override { |
85 bluez::BluezDBusManager::Initialize(NULL, true); | 85 bluez::BluezDBusManager::Initialize(NULL, true); |
86 | 86 |
87 callback_count_ = 0; | 87 callback_count_ = 0; |
88 error_callback_count_ = 0; | 88 error_callback_count_ = 0; |
89 | 89 |
90 fake_media_ = static_cast<bluez::FakeBluetoothMediaClient*>( | 90 fake_media_ = static_cast<bluez::FakeBluetoothMediaClient*>( |
91 bluez::BluezDBusManager::Get()->GetBluetoothMediaClient()); | 91 bluez::BluezDBusManager::Get()->GetBluetoothMediaClient()); |
92 fake_transport_ = static_cast<FakeBluetoothMediaTransportClient*>( | 92 fake_transport_ = static_cast<FakeBluetoothMediaTransportClient*>( |
(...skipping 26 matching lines...) Expand all Loading... |
119 | 119 |
120 // The adapter should outlive audio sink. | 120 // The adapter should outlive audio sink. |
121 audio_sink_ = nullptr; | 121 audio_sink_ = nullptr; |
122 adapter_ = nullptr; | 122 adapter_ = nullptr; |
123 bluez::BluezDBusManager::Shutdown(); | 123 bluez::BluezDBusManager::Shutdown(); |
124 } | 124 } |
125 | 125 |
126 // Gets the existing Bluetooth adapter. | 126 // Gets the existing Bluetooth adapter. |
127 void GetAdapter() { | 127 void GetAdapter() { |
128 BluetoothAdapterFactory::GetAdapter( | 128 BluetoothAdapterFactory::GetAdapter( |
129 base::Bind(&BluetoothAudioSinkChromeOSTest::GetAdapterCallback, | 129 base::Bind(&BluetoothAudioSinkBlueZTest::GetAdapterCallback, |
130 base::Unretained(this))); | 130 base::Unretained(this))); |
131 } | 131 } |
132 | 132 |
133 // Called whenever BluetoothAdapter is retrieved successfully. | 133 // Called whenever BluetoothAdapter is retrieved successfully. |
134 void GetAdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { | 134 void GetAdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { |
135 adapter_ = adapter; | 135 adapter_ = adapter; |
136 | 136 |
137 ASSERT_NE(adapter_.get(), nullptr); | 137 ASSERT_NE(adapter_.get(), nullptr); |
138 ASSERT_TRUE(adapter_->IsInitialized()); | 138 ASSERT_TRUE(adapter_->IsInitialized()); |
139 adapter_->SetPowered( | 139 adapter_->SetPowered(true, |
140 true, | 140 base::Bind(&BluetoothAudioSinkBlueZTest::Callback, |
141 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 141 base::Unretained(this)), |
142 base::Unretained(this)), | 142 base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, |
143 base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, | 143 base::Unretained(this))); |
144 base::Unretained(this))); | |
145 ASSERT_TRUE(adapter_->IsPresent()); | 144 ASSERT_TRUE(adapter_->IsPresent()); |
146 ASSERT_TRUE(adapter_->IsPowered()); | 145 ASSERT_TRUE(adapter_->IsPowered()); |
147 EXPECT_EQ(callback_count_, 1); | 146 EXPECT_EQ(callback_count_, 1); |
148 EXPECT_EQ(error_callback_count_, 0); | 147 EXPECT_EQ(error_callback_count_, 0); |
149 | 148 |
150 // Resets callback_count_. | 149 // Resets callback_count_. |
151 --callback_count_; | 150 --callback_count_; |
152 } | 151 } |
153 | 152 |
154 // Registers BluetoothAudioSinkChromeOS with default codec and capabilities. | 153 // Registers BluetoothAudioSinkBlueZ with default codec and capabilities. |
155 // If the audio sink is retrieved successfully, the state changes to | 154 // If the audio sink is retrieved successfully, the state changes to |
156 // STATE_DISCONNECTED. | 155 // STATE_DISCONNECTED. |
157 void GetAudioSink() { | 156 void GetAudioSink() { |
158 // Sets up valid codec and capabilities. | 157 // Sets up valid codec and capabilities. |
159 BluetoothAudioSink::Options options; | 158 BluetoothAudioSink::Options options; |
160 ASSERT_EQ(options.codec, 0x00); | 159 ASSERT_EQ(options.codec, 0x00); |
161 ASSERT_EQ(options.capabilities, | 160 ASSERT_EQ(options.capabilities, |
162 std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35})); | 161 std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35})); |
163 | 162 |
164 // Registers |audio_sink_| with valid codec and capabilities | 163 // Registers |audio_sink_| with valid codec and capabilities |
165 adapter_->RegisterAudioSink( | 164 adapter_->RegisterAudioSink( |
166 options, | 165 options, base::Bind(&BluetoothAudioSinkBlueZTest::RegisterCallback, |
167 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, | 166 base::Unretained(this)), |
168 base::Unretained(this)), | 167 base::Bind(&BluetoothAudioSinkBlueZTest::RegisterErrorCallback, |
169 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, | |
170 base::Unretained(this))); | 168 base::Unretained(this))); |
171 | 169 |
172 observer_.reset(new TestAudioSinkObserver(audio_sink_)); | 170 observer_.reset(new TestAudioSinkObserver(audio_sink_)); |
173 EXPECT_EQ(callback_count_, 1); | 171 EXPECT_EQ(callback_count_, 1); |
174 EXPECT_EQ(error_callback_count_, 0); | 172 EXPECT_EQ(error_callback_count_, 0); |
175 EXPECT_EQ(observer_->state_changed_count_, 0); | 173 EXPECT_EQ(observer_->state_changed_count_, 0); |
176 EXPECT_EQ(observer_->volume_changed_count_, 0); | 174 EXPECT_EQ(observer_->volume_changed_count_, 0); |
177 } | 175 } |
178 | 176 |
179 void GetFakeMediaEndpoint() { | 177 void GetFakeMediaEndpoint() { |
180 BluetoothAudioSinkChromeOS* audio_sink_chromeos = | 178 BluetoothAudioSinkBlueZ* audio_sink_bluez = |
181 static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); | 179 static_cast<BluetoothAudioSinkBlueZ*>(audio_sink_.get()); |
182 ASSERT_NE(audio_sink_chromeos, nullptr); | 180 ASSERT_NE(audio_sink_bluez, nullptr); |
183 | 181 |
184 media_endpoint_ = | 182 media_endpoint_ = |
185 static_cast<bluez::FakeBluetoothMediaEndpointServiceProvider*>( | 183 static_cast<bluez::FakeBluetoothMediaEndpointServiceProvider*>( |
186 audio_sink_chromeos->GetEndpointServiceProvider()); | 184 audio_sink_bluez->GetEndpointServiceProvider()); |
187 } | 185 } |
188 | 186 |
189 // Called whenever RegisterAudioSink is completed successfully. | 187 // Called whenever RegisterAudioSink is completed successfully. |
190 void RegisterCallback( | 188 void RegisterCallback(scoped_refptr<BluetoothAudioSink> audio_sink) { |
191 scoped_refptr<BluetoothAudioSink> audio_sink) { | |
192 ++callback_count_; | 189 ++callback_count_; |
193 audio_sink_ = audio_sink; | 190 audio_sink_ = audio_sink; |
194 | 191 |
195 GetFakeMediaEndpoint(); | 192 GetFakeMediaEndpoint(); |
196 ASSERT_NE(media_endpoint_, nullptr); | 193 ASSERT_NE(media_endpoint_, nullptr); |
197 fake_media_->SetEndpointRegistered(media_endpoint_, true); | 194 fake_media_->SetEndpointRegistered(media_endpoint_, true); |
198 | 195 |
199 ASSERT_NE(audio_sink_.get(), nullptr); | 196 ASSERT_NE(audio_sink_.get(), nullptr); |
200 ASSERT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 197 ASSERT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
201 } | 198 } |
(...skipping 12 matching lines...) Expand all Loading... |
214 // audio sink in GetAudioSink(). | 211 // audio sink in GetAudioSink(). |
215 EXPECT_EQ(capabilities, std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35})); | 212 EXPECT_EQ(capabilities, std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35})); |
216 } | 213 } |
217 | 214 |
218 void UnregisterErrorCallback(BluetoothAudioSink::ErrorCode error_code) { | 215 void UnregisterErrorCallback(BluetoothAudioSink::ErrorCode error_code) { |
219 ++error_callback_count_; | 216 ++error_callback_count_; |
220 EXPECT_EQ(error_code, BluetoothAudioSink::ERROR_NOT_UNREGISTERED); | 217 EXPECT_EQ(error_code, BluetoothAudioSink::ERROR_NOT_UNREGISTERED); |
221 } | 218 } |
222 | 219 |
223 // Generic callbacks. | 220 // Generic callbacks. |
224 void Callback() { | 221 void Callback() { ++callback_count_; } |
225 ++callback_count_; | |
226 } | |
227 | 222 |
228 void ErrorCallback() { | 223 void ErrorCallback() { ++error_callback_count_; } |
229 ++error_callback_count_; | |
230 } | |
231 | 224 |
232 protected: | 225 protected: |
233 int callback_count_; | 226 int callback_count_; |
234 int error_callback_count_; | 227 int error_callback_count_; |
235 | 228 |
236 base::MessageLoopForIO message_loop_; | 229 base::MessageLoopForIO message_loop_; |
237 | 230 |
238 bluez::FakeBluetoothMediaClient* fake_media_; | 231 bluez::FakeBluetoothMediaClient* fake_media_; |
239 FakeBluetoothMediaTransportClient* fake_transport_; | 232 FakeBluetoothMediaTransportClient* fake_transport_; |
240 bluez::FakeBluetoothMediaEndpointServiceProvider* media_endpoint_; | 233 bluez::FakeBluetoothMediaEndpointServiceProvider* media_endpoint_; |
241 scoped_ptr<TestAudioSinkObserver> observer_; | 234 scoped_ptr<TestAudioSinkObserver> observer_; |
242 scoped_refptr<BluetoothAdapter> adapter_; | 235 scoped_refptr<BluetoothAdapter> adapter_; |
243 scoped_refptr<BluetoothAudioSink> audio_sink_; | 236 scoped_refptr<BluetoothAudioSink> audio_sink_; |
244 | 237 |
245 // The default property set used while calling SetConfiguration on a media | 238 // The default property set used while calling SetConfiguration on a media |
246 // endpoint object. | 239 // endpoint object. |
247 bluez::BluetoothMediaEndpointServiceProvider::Delegate::TransportProperties | 240 bluez::BluetoothMediaEndpointServiceProvider::Delegate::TransportProperties |
248 properties_; | 241 properties_; |
249 }; | 242 }; |
250 | 243 |
251 TEST_F(BluetoothAudioSinkChromeOSTest, RegisterSucceeded) { | 244 TEST_F(BluetoothAudioSinkBlueZTest, RegisterSucceeded) { |
252 GetAudioSink(); | 245 GetAudioSink(); |
253 } | 246 } |
254 | 247 |
255 TEST_F(BluetoothAudioSinkChromeOSTest, RegisterFailedWithInvalidOptions) { | 248 TEST_F(BluetoothAudioSinkBlueZTest, RegisterFailedWithInvalidOptions) { |
256 // Sets options with an invalid codec and valid capabilities. | 249 // Sets options with an invalid codec and valid capabilities. |
257 BluetoothAudioSink::Options options; | 250 BluetoothAudioSink::Options options; |
258 options.codec = 0xff; | 251 options.codec = 0xff; |
259 options.capabilities = std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35}); | 252 options.capabilities = std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35}); |
260 | 253 |
261 adapter_->RegisterAudioSink( | 254 adapter_->RegisterAudioSink( |
262 options, | 255 options, base::Bind(&BluetoothAudioSinkBlueZTest::RegisterCallback, |
263 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, | 256 base::Unretained(this)), |
264 base::Unretained(this)), | 257 base::Bind(&BluetoothAudioSinkBlueZTest::RegisterErrorCallback, |
265 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, | |
266 base::Unretained(this))); | 258 base::Unretained(this))); |
267 | 259 |
268 EXPECT_EQ(callback_count_, 0); | 260 EXPECT_EQ(callback_count_, 0); |
269 EXPECT_EQ(error_callback_count_, 1); | 261 EXPECT_EQ(error_callback_count_, 1); |
270 | 262 |
271 // Sets options with a valid codec and invalid capabilities. | 263 // Sets options with a valid codec and invalid capabilities. |
272 options.codec = 0x00; | 264 options.codec = 0x00; |
273 options.capabilities.clear(); | 265 options.capabilities.clear(); |
274 adapter_->RegisterAudioSink( | 266 adapter_->RegisterAudioSink( |
275 options, | 267 options, base::Bind(&BluetoothAudioSinkBlueZTest::RegisterCallback, |
276 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, | 268 base::Unretained(this)), |
277 base::Unretained(this)), | 269 base::Bind(&BluetoothAudioSinkBlueZTest::RegisterErrorCallback, |
278 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, | |
279 base::Unretained(this))); | 270 base::Unretained(this))); |
280 | 271 |
281 EXPECT_EQ(callback_count_, 0); | 272 EXPECT_EQ(callback_count_, 0); |
282 EXPECT_EQ(error_callback_count_, 2); | 273 EXPECT_EQ(error_callback_count_, 2); |
283 } | 274 } |
284 | 275 |
285 TEST_F(BluetoothAudioSinkChromeOSTest, SelectConfiguration) { | 276 TEST_F(BluetoothAudioSinkBlueZTest, SelectConfiguration) { |
286 GetAudioSink(); | 277 GetAudioSink(); |
287 | 278 |
288 // Simulates calling SelectConfiguration on the media endpoint object owned by | 279 // Simulates calling SelectConfiguration on the media endpoint object owned by |
289 // |audio_sink_| with some fake capabilities. | 280 // |audio_sink_| with some fake capabilities. |
290 media_endpoint_->SelectConfiguration( | 281 media_endpoint_->SelectConfiguration( |
291 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 282 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
292 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 283 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
293 base::Unretained(this))); | 284 base::Unretained(this))); |
294 | 285 |
295 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 286 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
296 EXPECT_EQ(callback_count_, 2); | 287 EXPECT_EQ(callback_count_, 2); |
297 EXPECT_EQ(error_callback_count_, 0); | 288 EXPECT_EQ(error_callback_count_, 0); |
298 EXPECT_EQ(observer_->state_changed_count_, 0); | 289 EXPECT_EQ(observer_->state_changed_count_, 0); |
299 EXPECT_EQ(observer_->volume_changed_count_, 0); | 290 EXPECT_EQ(observer_->volume_changed_count_, 0); |
300 } | 291 } |
301 | 292 |
302 TEST_F(BluetoothAudioSinkChromeOSTest, SetConfiguration) { | 293 TEST_F(BluetoothAudioSinkBlueZTest, SetConfiguration) { |
303 GetAudioSink(); | 294 GetAudioSink(); |
304 | 295 |
305 media_endpoint_->SelectConfiguration( | 296 media_endpoint_->SelectConfiguration( |
306 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 297 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
307 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 298 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
308 base::Unretained(this))); | 299 base::Unretained(this))); |
309 | 300 |
310 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 301 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
311 EXPECT_EQ(callback_count_, 2); | 302 EXPECT_EQ(callback_count_, 2); |
312 EXPECT_EQ(error_callback_count_, 0); | 303 EXPECT_EQ(error_callback_count_, 0); |
313 EXPECT_EQ(observer_->state_changed_count_, 0); | 304 EXPECT_EQ(observer_->state_changed_count_, 0); |
314 EXPECT_EQ(observer_->volume_changed_count_, 0); | 305 EXPECT_EQ(observer_->volume_changed_count_, 0); |
315 | 306 |
316 // Simulates calling SetConfiguration on the media endpoint object owned by | 307 // Simulates calling SetConfiguration on the media endpoint object owned by |
317 // |audio_sink_| with a fake transport path and a | 308 // |audio_sink_| with a fake transport path and a |
318 // Delegate::TransportProperties structure. | 309 // Delegate::TransportProperties structure. |
319 media_endpoint_->SetConfiguration( | 310 media_endpoint_->SetConfiguration( |
320 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 311 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
321 properties_); | 312 properties_); |
322 | 313 |
323 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | 314 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); |
324 EXPECT_EQ(callback_count_, 2); | 315 EXPECT_EQ(callback_count_, 2); |
325 EXPECT_EQ(error_callback_count_, 0); | 316 EXPECT_EQ(error_callback_count_, 0); |
326 EXPECT_EQ(observer_->state_changed_count_, 1); | 317 EXPECT_EQ(observer_->state_changed_count_, 1); |
327 EXPECT_EQ(observer_->volume_changed_count_, 1); | 318 EXPECT_EQ(observer_->volume_changed_count_, 1); |
328 } | 319 } |
329 | 320 |
330 TEST_F(BluetoothAudioSinkChromeOSTest, SetConfigurationWithUnexpectedState) { | 321 TEST_F(BluetoothAudioSinkBlueZTest, SetConfigurationWithUnexpectedState) { |
331 GetAudioSink(); | 322 GetAudioSink(); |
332 | 323 |
333 media_endpoint_->SelectConfiguration( | 324 media_endpoint_->SelectConfiguration( |
334 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 325 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
335 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 326 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
336 base::Unretained(this))); | 327 base::Unretained(this))); |
337 | 328 |
338 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 329 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
339 EXPECT_EQ(callback_count_, 2); | 330 EXPECT_EQ(callback_count_, 2); |
340 EXPECT_EQ(error_callback_count_, 0); | 331 EXPECT_EQ(error_callback_count_, 0); |
341 EXPECT_EQ(observer_->state_changed_count_, 0); | 332 EXPECT_EQ(observer_->state_changed_count_, 0); |
342 EXPECT_EQ(observer_->volume_changed_count_, 0); | 333 EXPECT_EQ(observer_->volume_changed_count_, 0); |
343 | 334 |
344 // Set state of Delegate::TransportProperties with an unexpected value. | 335 // Set state of Delegate::TransportProperties with an unexpected value. |
345 properties_.state = "pending"; | 336 properties_.state = "pending"; |
346 | 337 |
347 media_endpoint_->SetConfiguration( | 338 media_endpoint_->SetConfiguration( |
348 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 339 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
349 properties_); | 340 properties_); |
350 | 341 |
351 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 342 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
352 EXPECT_EQ(callback_count_, 2); | 343 EXPECT_EQ(callback_count_, 2); |
353 EXPECT_EQ(error_callback_count_, 0); | 344 EXPECT_EQ(error_callback_count_, 0); |
354 EXPECT_EQ(observer_->state_changed_count_, 0); | 345 EXPECT_EQ(observer_->state_changed_count_, 0); |
355 EXPECT_EQ(observer_->volume_changed_count_, 0); | 346 EXPECT_EQ(observer_->volume_changed_count_, 0); |
356 } | 347 } |
357 | 348 |
358 // Checks if the observer is notified on media-removed event when the state of | 349 // Checks if the observer is notified on media-removed event when the state of |
359 // |audio_sink_| is STATE_DISCONNECTED. Once the media object is removed, the | 350 // |audio_sink_| is STATE_DISCONNECTED. Once the media object is removed, the |
360 // audio sink is no longer valid. | 351 // audio sink is no longer valid. |
361 TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringDisconnectedState) { | 352 TEST_F(BluetoothAudioSinkBlueZTest, MediaRemovedDuringDisconnectedState) { |
362 GetAudioSink(); | 353 GetAudioSink(); |
363 | 354 |
364 // Gets the media object and makes it invisible to see if the state of the | 355 // Gets the media object and makes it invisible to see if the state of the |
365 // audio sink changes accordingly. | 356 // audio sink changes accordingly. |
366 fake_media_->SetVisible(false); | 357 fake_media_->SetVisible(false); |
367 | 358 |
368 GetFakeMediaEndpoint(); | 359 GetFakeMediaEndpoint(); |
369 | 360 |
370 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); | 361 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); |
371 EXPECT_EQ(media_endpoint_, nullptr); | 362 EXPECT_EQ(media_endpoint_, nullptr); |
372 EXPECT_EQ(observer_->state_changed_count_, 1); | 363 EXPECT_EQ(observer_->state_changed_count_, 1); |
373 EXPECT_EQ(observer_->volume_changed_count_, 0); | 364 EXPECT_EQ(observer_->volume_changed_count_, 0); |
374 } | 365 } |
375 | 366 |
376 // Checks if the observer is notified on media-removed event when the state of | 367 // Checks if the observer is notified on media-removed event when the state of |
377 // |audio_sink_| is STATE_IDLE. Once the media object is removed, the audio sink | 368 // |audio_sink_| is STATE_IDLE. Once the media object is removed, the audio sink |
378 // is no longer valid. | 369 // is no longer valid. |
379 TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringIdleState) { | 370 TEST_F(BluetoothAudioSinkBlueZTest, MediaRemovedDuringIdleState) { |
380 GetAudioSink(); | 371 GetAudioSink(); |
381 | 372 |
382 media_endpoint_->SelectConfiguration( | 373 media_endpoint_->SelectConfiguration( |
383 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 374 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
384 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 375 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
385 base::Unretained(this))); | 376 base::Unretained(this))); |
386 | 377 |
387 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 378 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
388 EXPECT_EQ(callback_count_, 2); | 379 EXPECT_EQ(callback_count_, 2); |
389 EXPECT_EQ(error_callback_count_, 0); | 380 EXPECT_EQ(error_callback_count_, 0); |
390 EXPECT_EQ(observer_->state_changed_count_, 0); | 381 EXPECT_EQ(observer_->state_changed_count_, 0); |
391 EXPECT_EQ(observer_->volume_changed_count_, 0); | 382 EXPECT_EQ(observer_->volume_changed_count_, 0); |
392 | 383 |
393 media_endpoint_->SetConfiguration( | 384 media_endpoint_->SetConfiguration( |
394 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 385 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
(...skipping 14 matching lines...) Expand all Loading... |
409 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); | 400 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); |
410 EXPECT_EQ(media_endpoint_, nullptr); | 401 EXPECT_EQ(media_endpoint_, nullptr); |
411 | 402 |
412 // The state becomes disconnted and then invalid, since the removal of | 403 // The state becomes disconnted and then invalid, since the removal of |
413 // transport object should happend before media becomes invisible. | 404 // transport object should happend before media becomes invisible. |
414 // State: STATE_IDLE -> STATE_DISCONNECTED -> STATE_INVALID | 405 // State: STATE_IDLE -> STATE_DISCONNECTED -> STATE_INVALID |
415 EXPECT_EQ(observer_->state_changed_count_, 3); | 406 EXPECT_EQ(observer_->state_changed_count_, 3); |
416 EXPECT_EQ(observer_->volume_changed_count_, 2); | 407 EXPECT_EQ(observer_->volume_changed_count_, 2); |
417 } | 408 } |
418 | 409 |
419 TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringActiveState) { | 410 TEST_F(BluetoothAudioSinkBlueZTest, MediaRemovedDuringActiveState) { |
420 GetAudioSink(); | 411 GetAudioSink(); |
421 | 412 |
422 media_endpoint_->SelectConfiguration( | 413 media_endpoint_->SelectConfiguration( |
423 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 414 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
424 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 415 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
425 base::Unretained(this))); | 416 base::Unretained(this))); |
426 | 417 |
427 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 418 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
428 EXPECT_EQ(callback_count_, 2); | 419 EXPECT_EQ(callback_count_, 2); |
429 EXPECT_EQ(error_callback_count_, 0); | 420 EXPECT_EQ(error_callback_count_, 0); |
430 EXPECT_EQ(observer_->state_changed_count_, 0); | 421 EXPECT_EQ(observer_->state_changed_count_, 0); |
431 EXPECT_EQ(observer_->volume_changed_count_, 0); | 422 EXPECT_EQ(observer_->volume_changed_count_, 0); |
432 | 423 |
433 media_endpoint_->SetConfiguration( | 424 media_endpoint_->SetConfiguration( |
434 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 425 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
(...skipping 27 matching lines...) Expand all Loading... |
462 // The state becomes disconnted and then invalid, since the removal of | 453 // The state becomes disconnted and then invalid, since the removal of |
463 // transport object should happend before media becomes invisible. | 454 // transport object should happend before media becomes invisible. |
464 // State: STATE_ACTIVE -> STATE_DISCONNECTED -> STATE_INVALID | 455 // State: STATE_ACTIVE -> STATE_DISCONNECTED -> STATE_INVALID |
465 EXPECT_EQ(observer_->state_changed_count_, 5); | 456 EXPECT_EQ(observer_->state_changed_count_, 5); |
466 EXPECT_EQ(observer_->volume_changed_count_, 2); | 457 EXPECT_EQ(observer_->volume_changed_count_, 2); |
467 } | 458 } |
468 | 459 |
469 // Checks if the observer is notified on transport-removed event when the state | 460 // Checks if the observer is notified on transport-removed event when the state |
470 // of |audio_sink_| is STATE_IDEL. Once the media transport object is removed, | 461 // of |audio_sink_| is STATE_IDEL. Once the media transport object is removed, |
471 // the audio sink is disconnected. | 462 // the audio sink is disconnected. |
472 TEST_F(BluetoothAudioSinkChromeOSTest, TransportRemovedDuringIdleState) { | 463 TEST_F(BluetoothAudioSinkBlueZTest, TransportRemovedDuringIdleState) { |
473 GetAudioSink(); | 464 GetAudioSink(); |
474 | 465 |
475 media_endpoint_->SelectConfiguration( | 466 media_endpoint_->SelectConfiguration( |
476 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 467 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
477 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 468 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
478 base::Unretained(this))); | 469 base::Unretained(this))); |
479 | 470 |
480 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 471 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
481 EXPECT_EQ(callback_count_, 2); | 472 EXPECT_EQ(callback_count_, 2); |
482 EXPECT_EQ(error_callback_count_, 0); | 473 EXPECT_EQ(error_callback_count_, 0); |
483 EXPECT_EQ(observer_->state_changed_count_, 0); | 474 EXPECT_EQ(observer_->state_changed_count_, 0); |
484 EXPECT_EQ(observer_->volume_changed_count_, 0); | 475 EXPECT_EQ(observer_->volume_changed_count_, 0); |
485 | 476 |
486 media_endpoint_->SetConfiguration( | 477 media_endpoint_->SetConfiguration( |
487 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 478 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
488 properties_); | 479 properties_); |
489 | 480 |
490 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | 481 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); |
491 EXPECT_EQ(callback_count_, 2); | 482 EXPECT_EQ(callback_count_, 2); |
492 EXPECT_EQ(error_callback_count_, 0); | 483 EXPECT_EQ(error_callback_count_, 0); |
493 EXPECT_EQ(observer_->state_changed_count_, 1); | 484 EXPECT_EQ(observer_->state_changed_count_, 1); |
494 EXPECT_EQ(observer_->volume_changed_count_, 1); | 485 EXPECT_EQ(observer_->volume_changed_count_, 1); |
495 | 486 |
496 // Makes the transport object invalid to see if the state of the audio sink | 487 // Makes the transport object invalid to see if the state of the audio sink |
497 // changes accordingly. | 488 // changes accordingly. |
498 fake_transport_->SetValid(media_endpoint_, false); | 489 fake_transport_->SetValid(media_endpoint_, false); |
499 | 490 |
500 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 491 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
501 EXPECT_NE(media_endpoint_, nullptr); | 492 EXPECT_NE(media_endpoint_, nullptr); |
502 EXPECT_EQ(observer_->state_changed_count_, 2); | 493 EXPECT_EQ(observer_->state_changed_count_, 2); |
503 EXPECT_EQ(observer_->volume_changed_count_, 2); | 494 EXPECT_EQ(observer_->volume_changed_count_, 2); |
504 } | 495 } |
505 | 496 |
506 TEST_F(BluetoothAudioSinkChromeOSTest, TransportRemovedDuringActiveState) { | 497 TEST_F(BluetoothAudioSinkBlueZTest, TransportRemovedDuringActiveState) { |
507 GetAudioSink(); | 498 GetAudioSink(); |
508 | 499 |
509 media_endpoint_->SelectConfiguration( | 500 media_endpoint_->SelectConfiguration( |
510 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 501 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
511 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 502 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
512 base::Unretained(this))); | 503 base::Unretained(this))); |
513 | 504 |
514 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 505 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
515 EXPECT_EQ(callback_count_, 2); | 506 EXPECT_EQ(callback_count_, 2); |
516 EXPECT_EQ(error_callback_count_, 0); | 507 EXPECT_EQ(error_callback_count_, 0); |
517 EXPECT_EQ(observer_->state_changed_count_, 0); | 508 EXPECT_EQ(observer_->state_changed_count_, 0); |
518 EXPECT_EQ(observer_->volume_changed_count_, 0); | 509 EXPECT_EQ(observer_->volume_changed_count_, 0); |
519 | 510 |
520 media_endpoint_->SetConfiguration( | 511 media_endpoint_->SetConfiguration( |
521 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 512 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
(...skipping 18 matching lines...) Expand all Loading... |
540 // Makes the transport object invalid to see if the state of the audio sink | 531 // Makes the transport object invalid to see if the state of the audio sink |
541 // changes accordingly. | 532 // changes accordingly. |
542 fake_transport_->SetValid(media_endpoint_, false); | 533 fake_transport_->SetValid(media_endpoint_, false); |
543 | 534 |
544 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 535 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
545 EXPECT_NE(media_endpoint_, nullptr); | 536 EXPECT_NE(media_endpoint_, nullptr); |
546 EXPECT_EQ(observer_->state_changed_count_, 4); | 537 EXPECT_EQ(observer_->state_changed_count_, 4); |
547 EXPECT_EQ(observer_->volume_changed_count_, 2); | 538 EXPECT_EQ(observer_->volume_changed_count_, 2); |
548 } | 539 } |
549 | 540 |
550 TEST_F(BluetoothAudioSinkChromeOSTest, | 541 TEST_F(BluetoothAudioSinkBlueZTest, |
551 AdapterPoweredChangedDuringDisconnectedState) { | 542 AdapterPoweredChangedDuringDisconnectedState) { |
552 GetAudioSink(); | 543 GetAudioSink(); |
553 | 544 |
554 adapter_->SetPowered( | 545 adapter_->SetPowered(false, base::Bind(&BluetoothAudioSinkBlueZTest::Callback, |
555 false, | 546 base::Unretained(this)), |
556 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 547 base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, |
557 base::Unretained(this)), | 548 base::Unretained(this))); |
558 base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, | |
559 base::Unretained(this))); | |
560 | 549 |
561 EXPECT_TRUE(adapter_->IsPresent()); | 550 EXPECT_TRUE(adapter_->IsPresent()); |
562 EXPECT_FALSE(adapter_->IsPowered()); | 551 EXPECT_FALSE(adapter_->IsPowered()); |
563 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 552 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
564 EXPECT_EQ(callback_count_, 2); | 553 EXPECT_EQ(callback_count_, 2); |
565 EXPECT_EQ(error_callback_count_, 0); | 554 EXPECT_EQ(error_callback_count_, 0); |
566 EXPECT_EQ(observer_->state_changed_count_, 0); | 555 EXPECT_EQ(observer_->state_changed_count_, 0); |
567 EXPECT_EQ(observer_->volume_changed_count_, 0); | 556 EXPECT_EQ(observer_->volume_changed_count_, 0); |
568 | 557 |
569 adapter_->SetPowered( | 558 adapter_->SetPowered(true, base::Bind(&BluetoothAudioSinkBlueZTest::Callback, |
570 true, | 559 base::Unretained(this)), |
571 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 560 base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, |
572 base::Unretained(this)), | 561 base::Unretained(this))); |
573 base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, | |
574 base::Unretained(this))); | |
575 | 562 |
576 EXPECT_TRUE(adapter_->IsPresent()); | 563 EXPECT_TRUE(adapter_->IsPresent()); |
577 EXPECT_TRUE(adapter_->IsPowered()); | 564 EXPECT_TRUE(adapter_->IsPowered()); |
578 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 565 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
579 EXPECT_EQ(callback_count_, 3); | 566 EXPECT_EQ(callback_count_, 3); |
580 EXPECT_EQ(error_callback_count_, 0); | 567 EXPECT_EQ(error_callback_count_, 0); |
581 EXPECT_EQ(observer_->state_changed_count_, 0); | 568 EXPECT_EQ(observer_->state_changed_count_, 0); |
582 EXPECT_EQ(observer_->volume_changed_count_, 0); | 569 EXPECT_EQ(observer_->volume_changed_count_, 0); |
583 } | 570 } |
584 | 571 |
585 TEST_F(BluetoothAudioSinkChromeOSTest, AdapterPoweredChangedDuringIdleState) { | 572 TEST_F(BluetoothAudioSinkBlueZTest, AdapterPoweredChangedDuringIdleState) { |
586 GetAudioSink(); | 573 GetAudioSink(); |
587 | 574 |
588 media_endpoint_->SelectConfiguration( | 575 media_endpoint_->SelectConfiguration( |
589 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 576 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
590 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 577 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
591 base::Unretained(this))); | 578 base::Unretained(this))); |
592 | 579 |
593 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 580 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
594 EXPECT_EQ(callback_count_, 2); | 581 EXPECT_EQ(callback_count_, 2); |
595 EXPECT_EQ(error_callback_count_, 0); | 582 EXPECT_EQ(error_callback_count_, 0); |
596 EXPECT_EQ(observer_->state_changed_count_, 0); | 583 EXPECT_EQ(observer_->state_changed_count_, 0); |
597 EXPECT_EQ(observer_->volume_changed_count_, 0); | 584 EXPECT_EQ(observer_->volume_changed_count_, 0); |
598 | 585 |
599 media_endpoint_->SetConfiguration( | 586 media_endpoint_->SetConfiguration( |
600 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 587 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
601 properties_); | 588 properties_); |
602 | 589 |
603 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | 590 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); |
604 EXPECT_EQ(callback_count_, 2); | 591 EXPECT_EQ(callback_count_, 2); |
605 EXPECT_EQ(error_callback_count_, 0); | 592 EXPECT_EQ(error_callback_count_, 0); |
606 EXPECT_EQ(observer_->state_changed_count_, 1); | 593 EXPECT_EQ(observer_->state_changed_count_, 1); |
607 EXPECT_EQ(observer_->volume_changed_count_, 1); | 594 EXPECT_EQ(observer_->volume_changed_count_, 1); |
608 | 595 |
609 adapter_->SetPowered( | 596 adapter_->SetPowered(false, base::Bind(&BluetoothAudioSinkBlueZTest::Callback, |
610 false, | 597 base::Unretained(this)), |
611 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 598 base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, |
612 base::Unretained(this)), | 599 base::Unretained(this))); |
613 base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, | |
614 base::Unretained(this))); | |
615 GetFakeMediaEndpoint(); | 600 GetFakeMediaEndpoint(); |
616 | 601 |
617 EXPECT_TRUE(adapter_->IsPresent()); | 602 EXPECT_TRUE(adapter_->IsPresent()); |
618 EXPECT_FALSE(adapter_->IsPowered()); | 603 EXPECT_FALSE(adapter_->IsPowered()); |
619 EXPECT_NE(media_endpoint_, nullptr); | 604 EXPECT_NE(media_endpoint_, nullptr); |
620 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 605 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
621 EXPECT_EQ(callback_count_, 3); | 606 EXPECT_EQ(callback_count_, 3); |
622 EXPECT_EQ(error_callback_count_, 0); | 607 EXPECT_EQ(error_callback_count_, 0); |
623 EXPECT_EQ(observer_->state_changed_count_, 2); | 608 EXPECT_EQ(observer_->state_changed_count_, 2); |
624 EXPECT_EQ(observer_->volume_changed_count_, 2); | 609 EXPECT_EQ(observer_->volume_changed_count_, 2); |
625 } | 610 } |
626 | 611 |
627 TEST_F(BluetoothAudioSinkChromeOSTest, | 612 TEST_F(BluetoothAudioSinkBlueZTest, |
628 UnregisterAudioSinkDuringDisconnectedState) { | 613 UnregisterAudioSinkDuringDisconnectedState) { |
629 GetAudioSink(); | 614 GetAudioSink(); |
630 | 615 |
631 audio_sink_->Unregister( | 616 audio_sink_->Unregister( |
632 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 617 base::Bind(&BluetoothAudioSinkBlueZTest::Callback, |
633 base::Unretained(this)), | 618 base::Unretained(this)), |
634 base::Bind(&BluetoothAudioSinkChromeOSTest::UnregisterErrorCallback, | 619 base::Bind(&BluetoothAudioSinkBlueZTest::UnregisterErrorCallback, |
635 base::Unretained(this))); | 620 base::Unretained(this))); |
636 | 621 |
637 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); | 622 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); |
638 EXPECT_EQ(callback_count_, 2); | 623 EXPECT_EQ(callback_count_, 2); |
639 EXPECT_EQ(error_callback_count_, 0); | 624 EXPECT_EQ(error_callback_count_, 0); |
640 EXPECT_EQ(observer_->state_changed_count_, 1); | 625 EXPECT_EQ(observer_->state_changed_count_, 1); |
641 EXPECT_EQ(observer_->volume_changed_count_, 0); | 626 EXPECT_EQ(observer_->volume_changed_count_, 0); |
642 } | 627 } |
643 | 628 |
644 TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringIdleState) { | 629 TEST_F(BluetoothAudioSinkBlueZTest, UnregisterAudioSinkDuringIdleState) { |
645 GetAudioSink(); | 630 GetAudioSink(); |
646 | 631 |
647 media_endpoint_->SelectConfiguration( | 632 media_endpoint_->SelectConfiguration( |
648 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 633 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
649 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 634 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
650 base::Unretained(this))); | 635 base::Unretained(this))); |
651 | 636 |
652 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 637 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
653 EXPECT_EQ(callback_count_, 2); | 638 EXPECT_EQ(callback_count_, 2); |
654 EXPECT_EQ(error_callback_count_, 0); | 639 EXPECT_EQ(error_callback_count_, 0); |
655 EXPECT_EQ(observer_->state_changed_count_, 0); | 640 EXPECT_EQ(observer_->state_changed_count_, 0); |
656 EXPECT_EQ(observer_->volume_changed_count_, 0); | 641 EXPECT_EQ(observer_->volume_changed_count_, 0); |
657 | 642 |
658 media_endpoint_->SetConfiguration( | 643 media_endpoint_->SetConfiguration( |
659 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 644 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
660 properties_); | 645 properties_); |
661 | 646 |
662 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | 647 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); |
663 EXPECT_EQ(callback_count_, 2); | 648 EXPECT_EQ(callback_count_, 2); |
664 EXPECT_EQ(error_callback_count_, 0); | 649 EXPECT_EQ(error_callback_count_, 0); |
665 EXPECT_EQ(observer_->state_changed_count_, 1); | 650 EXPECT_EQ(observer_->state_changed_count_, 1); |
666 EXPECT_EQ(observer_->volume_changed_count_, 1); | 651 EXPECT_EQ(observer_->volume_changed_count_, 1); |
667 | 652 |
668 audio_sink_->Unregister( | 653 audio_sink_->Unregister( |
669 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 654 base::Bind(&BluetoothAudioSinkBlueZTest::Callback, |
670 base::Unretained(this)), | 655 base::Unretained(this)), |
671 base::Bind(&BluetoothAudioSinkChromeOSTest::UnregisterErrorCallback, | 656 base::Bind(&BluetoothAudioSinkBlueZTest::UnregisterErrorCallback, |
672 base::Unretained(this))); | 657 base::Unretained(this))); |
673 | 658 |
674 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); | 659 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); |
675 EXPECT_EQ(callback_count_, 3); | 660 EXPECT_EQ(callback_count_, 3); |
676 EXPECT_EQ(error_callback_count_, 0); | 661 EXPECT_EQ(error_callback_count_, 0); |
677 | 662 |
678 // The state becomes disconnted and then invalid, since the removal of | 663 // The state becomes disconnted and then invalid, since the removal of |
679 // transport object should happend before the unregistration of endpoint. | 664 // transport object should happend before the unregistration of endpoint. |
680 // State: STATE_IDLE -> STATE_DISCONNECTED -> STATE_INVALID | 665 // State: STATE_IDLE -> STATE_DISCONNECTED -> STATE_INVALID |
681 EXPECT_EQ(observer_->state_changed_count_, 3); | 666 EXPECT_EQ(observer_->state_changed_count_, 3); |
682 EXPECT_EQ(observer_->volume_changed_count_, 2); | 667 EXPECT_EQ(observer_->volume_changed_count_, 2); |
683 } | 668 } |
684 | 669 |
685 TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringActiveState) { | 670 TEST_F(BluetoothAudioSinkBlueZTest, UnregisterAudioSinkDuringActiveState) { |
686 GetAudioSink(); | 671 GetAudioSink(); |
687 | 672 |
688 media_endpoint_->SelectConfiguration( | 673 media_endpoint_->SelectConfiguration( |
689 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 674 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
690 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 675 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
691 base::Unretained(this))); | 676 base::Unretained(this))); |
692 | 677 |
693 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 678 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
694 EXPECT_EQ(callback_count_, 2); | 679 EXPECT_EQ(callback_count_, 2); |
695 EXPECT_EQ(error_callback_count_, 0); | 680 EXPECT_EQ(error_callback_count_, 0); |
696 EXPECT_EQ(observer_->state_changed_count_, 0); | 681 EXPECT_EQ(observer_->state_changed_count_, 0); |
697 EXPECT_EQ(observer_->volume_changed_count_, 0); | 682 EXPECT_EQ(observer_->volume_changed_count_, 0); |
698 | 683 |
699 media_endpoint_->SetConfiguration( | 684 media_endpoint_->SetConfiguration( |
700 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 685 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
701 properties_); | 686 properties_); |
702 | 687 |
703 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | 688 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); |
704 EXPECT_EQ(callback_count_, 2); | 689 EXPECT_EQ(callback_count_, 2); |
705 EXPECT_EQ(error_callback_count_, 0); | 690 EXPECT_EQ(error_callback_count_, 0); |
706 EXPECT_EQ(observer_->state_changed_count_, 1); | 691 EXPECT_EQ(observer_->state_changed_count_, 1); |
707 EXPECT_EQ(observer_->volume_changed_count_, 1); | 692 EXPECT_EQ(observer_->volume_changed_count_, 1); |
708 | 693 |
709 fake_transport_->SetState(media_endpoint_->object_path(), "pending"); | 694 fake_transport_->SetState(media_endpoint_->object_path(), "pending"); |
710 | 695 |
711 message_loop_.RunUntilIdle(); | 696 message_loop_.RunUntilIdle(); |
712 | 697 |
713 // Acquire is called when the state of |audio_sink_| becomes STATE_PENDING, | 698 // Acquire is called when the state of |audio_sink_| becomes STATE_PENDING, |
714 // and Acquire will trigger state change. Therefore, the state will be | 699 // and Acquire will trigger state change. Therefore, the state will be |
715 // STATE_ACTIVE right after STATE_PENDING. | 700 // STATE_ACTIVE right after STATE_PENDING. |
716 // State: STATE_IDLE -> STATE_PENDING -> STATE_ACTIVE | 701 // State: STATE_IDLE -> STATE_PENDING -> STATE_ACTIVE |
717 EXPECT_EQ(observer_->state_changed_count_, 3); | 702 EXPECT_EQ(observer_->state_changed_count_, 3); |
718 | 703 |
719 audio_sink_->Unregister( | 704 audio_sink_->Unregister( |
720 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 705 base::Bind(&BluetoothAudioSinkBlueZTest::Callback, |
721 base::Unretained(this)), | 706 base::Unretained(this)), |
722 base::Bind(&BluetoothAudioSinkChromeOSTest::UnregisterErrorCallback, | 707 base::Bind(&BluetoothAudioSinkBlueZTest::UnregisterErrorCallback, |
723 base::Unretained(this))); | 708 base::Unretained(this))); |
724 | 709 |
725 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); | 710 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); |
726 EXPECT_EQ(callback_count_, 3); | 711 EXPECT_EQ(callback_count_, 3); |
727 EXPECT_EQ(error_callback_count_, 0); | 712 EXPECT_EQ(error_callback_count_, 0); |
728 EXPECT_EQ(observer_->state_changed_count_, 5); | 713 EXPECT_EQ(observer_->state_changed_count_, 5); |
729 EXPECT_EQ(observer_->volume_changed_count_, 2); | 714 EXPECT_EQ(observer_->volume_changed_count_, 2); |
730 } | 715 } |
731 | 716 |
732 TEST_F(BluetoothAudioSinkChromeOSTest, StateChanged) { | 717 TEST_F(BluetoothAudioSinkBlueZTest, StateChanged) { |
733 GetAudioSink(); | 718 GetAudioSink(); |
734 | 719 |
735 media_endpoint_->SelectConfiguration( | 720 media_endpoint_->SelectConfiguration( |
736 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 721 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
737 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 722 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
738 base::Unretained(this))); | 723 base::Unretained(this))); |
739 | 724 |
740 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 725 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
741 EXPECT_EQ(callback_count_, 2); | 726 EXPECT_EQ(callback_count_, 2); |
742 EXPECT_EQ(error_callback_count_, 0); | 727 EXPECT_EQ(error_callback_count_, 0); |
743 EXPECT_EQ(observer_->state_changed_count_, 0); | 728 EXPECT_EQ(observer_->state_changed_count_, 0); |
744 EXPECT_EQ(observer_->volume_changed_count_, 0); | 729 EXPECT_EQ(observer_->volume_changed_count_, 0); |
745 | 730 |
746 media_endpoint_->SetConfiguration( | 731 media_endpoint_->SetConfiguration( |
747 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 732 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
748 properties_); | 733 properties_); |
749 | 734 |
750 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | 735 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); |
751 EXPECT_EQ(callback_count_, 2); | 736 EXPECT_EQ(callback_count_, 2); |
752 EXPECT_EQ(error_callback_count_, 0); | 737 EXPECT_EQ(error_callback_count_, 0); |
753 EXPECT_EQ(observer_->state_changed_count_, 1); | 738 EXPECT_EQ(observer_->state_changed_count_, 1); |
754 EXPECT_EQ(observer_->volume_changed_count_, 1); | 739 EXPECT_EQ(observer_->volume_changed_count_, 1); |
755 | 740 |
756 // Changes the current state of transport to pending. | 741 // Changes the current state of transport to pending. |
757 fake_transport_->SetState(media_endpoint_->object_path(), "pending"); | 742 fake_transport_->SetState(media_endpoint_->object_path(), "pending"); |
758 | 743 |
759 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_PENDING); | 744 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_PENDING); |
760 EXPECT_EQ(observer_->state_changed_count_, 3); | 745 EXPECT_EQ(observer_->state_changed_count_, 3); |
761 EXPECT_EQ(observer_->volume_changed_count_, 1); | 746 EXPECT_EQ(observer_->volume_changed_count_, 1); |
762 } | 747 } |
763 | 748 |
764 TEST_F(BluetoothAudioSinkChromeOSTest, VolumeChanged) { | 749 TEST_F(BluetoothAudioSinkBlueZTest, VolumeChanged) { |
765 GetAudioSink(); | 750 GetAudioSink(); |
766 | 751 |
767 media_endpoint_->SelectConfiguration( | 752 media_endpoint_->SelectConfiguration( |
768 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 753 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
769 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 754 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
770 base::Unretained(this))); | 755 base::Unretained(this))); |
771 | 756 |
772 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 757 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
773 EXPECT_EQ(callback_count_, 2); | 758 EXPECT_EQ(callback_count_, 2); |
774 EXPECT_EQ(error_callback_count_, 0); | 759 EXPECT_EQ(error_callback_count_, 0); |
775 EXPECT_EQ(observer_->state_changed_count_, 0); | 760 EXPECT_EQ(observer_->state_changed_count_, 0); |
776 EXPECT_EQ(observer_->volume_changed_count_, 0); | 761 EXPECT_EQ(observer_->volume_changed_count_, 0); |
777 | 762 |
778 media_endpoint_->SetConfiguration( | 763 media_endpoint_->SetConfiguration( |
779 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 764 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
(...skipping 20 matching lines...) Expand all Loading... |
800 | 785 |
801 // Changes volume to an invalid level. | 786 // Changes volume to an invalid level. |
802 fake_transport_->SetVolume(media_endpoint_->object_path(), 200); | 787 fake_transport_->SetVolume(media_endpoint_->object_path(), 200); |
803 | 788 |
804 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | 789 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); |
805 EXPECT_EQ(observer_->state_changed_count_, 1); | 790 EXPECT_EQ(observer_->state_changed_count_, 1); |
806 EXPECT_EQ(observer_->volume_changed_count_, 3); | 791 EXPECT_EQ(observer_->volume_changed_count_, 3); |
807 EXPECT_EQ(audio_sink_->GetVolume(), BluetoothAudioSink::kInvalidVolume); | 792 EXPECT_EQ(audio_sink_->GetVolume(), BluetoothAudioSink::kInvalidVolume); |
808 } | 793 } |
809 | 794 |
810 TEST_F(BluetoothAudioSinkChromeOSTest, AcquireFD) { | 795 TEST_F(BluetoothAudioSinkBlueZTest, AcquireFD) { |
811 GetAudioSink(); | 796 GetAudioSink(); |
812 | 797 |
813 media_endpoint_->SelectConfiguration( | 798 media_endpoint_->SelectConfiguration( |
814 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 799 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
815 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 800 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
816 base::Unretained(this))); | 801 base::Unretained(this))); |
817 | 802 |
818 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 803 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
819 EXPECT_EQ(callback_count_, 2); | 804 EXPECT_EQ(callback_count_, 2); |
820 EXPECT_EQ(error_callback_count_, 0); | 805 EXPECT_EQ(error_callback_count_, 0); |
821 EXPECT_EQ(observer_->state_changed_count_, 0); | 806 EXPECT_EQ(observer_->state_changed_count_, 0); |
822 EXPECT_EQ(observer_->volume_changed_count_, 0); | 807 EXPECT_EQ(observer_->volume_changed_count_, 0); |
823 | 808 |
824 media_endpoint_->SetConfiguration( | 809 media_endpoint_->SetConfiguration( |
825 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 810 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
(...skipping 17 matching lines...) Expand all Loading... |
843 // STATE_ACTIVE right after STATE_PENDING. | 828 // STATE_ACTIVE right after STATE_PENDING. |
844 // State: STATE_IDLE -> STATE_PENDING -> STATE_ACTIVE | 829 // State: STATE_IDLE -> STATE_PENDING -> STATE_ACTIVE |
845 EXPECT_EQ(observer_->state_changed_count_, 3); | 830 EXPECT_EQ(observer_->state_changed_count_, 3); |
846 EXPECT_EQ(observer_->total_read_, data_one.size()); | 831 EXPECT_EQ(observer_->total_read_, data_one.size()); |
847 EXPECT_EQ(observer_->data_, data_one); | 832 EXPECT_EQ(observer_->data_, data_one); |
848 EXPECT_EQ(observer_->read_mtu_, | 833 EXPECT_EQ(observer_->read_mtu_, |
849 FakeBluetoothMediaTransportClient::kDefaultReadMtu); | 834 FakeBluetoothMediaTransportClient::kDefaultReadMtu); |
850 } | 835 } |
851 | 836 |
852 // Tests the case where the remote device pauses and resume audio streaming. | 837 // Tests the case where the remote device pauses and resume audio streaming. |
853 TEST_F(BluetoothAudioSinkChromeOSTest, PauseAndResume) { | 838 TEST_F(BluetoothAudioSinkBlueZTest, PauseAndResume) { |
854 GetAudioSink(); | 839 GetAudioSink(); |
855 | 840 |
856 media_endpoint_->SelectConfiguration( | 841 media_endpoint_->SelectConfiguration( |
857 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 842 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
858 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 843 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
859 base::Unretained(this))); | 844 base::Unretained(this))); |
860 | 845 |
861 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 846 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
862 EXPECT_EQ(callback_count_, 2); | 847 EXPECT_EQ(callback_count_, 2); |
863 EXPECT_EQ(error_callback_count_, 0); | 848 EXPECT_EQ(error_callback_count_, 0); |
864 EXPECT_EQ(observer_->state_changed_count_, 0); | 849 EXPECT_EQ(observer_->state_changed_count_, 0); |
865 EXPECT_EQ(observer_->volume_changed_count_, 0); | 850 EXPECT_EQ(observer_->volume_changed_count_, 0); |
866 | 851 |
867 media_endpoint_->SetConfiguration( | 852 media_endpoint_->SetConfiguration( |
868 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 853 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 | 886 |
902 message_loop_.RunUntilIdle(); | 887 message_loop_.RunUntilIdle(); |
903 | 888 |
904 EXPECT_EQ(observer_->data_, data_two); | 889 EXPECT_EQ(observer_->data_, data_two); |
905 EXPECT_EQ(observer_->read_mtu_, | 890 EXPECT_EQ(observer_->read_mtu_, |
906 FakeBluetoothMediaTransportClient::kDefaultReadMtu); | 891 FakeBluetoothMediaTransportClient::kDefaultReadMtu); |
907 EXPECT_EQ(observer_->state_changed_count_, 6); | 892 EXPECT_EQ(observer_->state_changed_count_, 6); |
908 EXPECT_EQ(observer_->total_read_, data_two.size()); | 893 EXPECT_EQ(observer_->total_read_, data_two.size()); |
909 } | 894 } |
910 | 895 |
911 TEST_F(BluetoothAudioSinkChromeOSTest, ContinuouslyStreaming) { | 896 TEST_F(BluetoothAudioSinkBlueZTest, ContinuouslyStreaming) { |
912 GetAudioSink(); | 897 GetAudioSink(); |
913 | 898 |
914 media_endpoint_->SelectConfiguration( | 899 media_endpoint_->SelectConfiguration( |
915 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | 900 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), |
916 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | 901 base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, |
917 base::Unretained(this))); | 902 base::Unretained(this))); |
918 | 903 |
919 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 904 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
920 EXPECT_EQ(callback_count_, 2); | 905 EXPECT_EQ(callback_count_, 2); |
921 EXPECT_EQ(error_callback_count_, 0); | 906 EXPECT_EQ(error_callback_count_, 0); |
922 EXPECT_EQ(observer_->state_changed_count_, 0); | 907 EXPECT_EQ(observer_->state_changed_count_, 0); |
923 EXPECT_EQ(observer_->volume_changed_count_, 0); | 908 EXPECT_EQ(observer_->volume_changed_count_, 0); |
924 | 909 |
925 media_endpoint_->SetConfiguration( | 910 media_endpoint_->SetConfiguration( |
926 fake_transport_->GetTransportPath(media_endpoint_->object_path()), | 911 fake_transport_->GetTransportPath(media_endpoint_->object_path()), |
(...skipping 23 matching lines...) Expand all Loading... |
950 | 935 |
951 message_loop_.RunUntilIdle(); | 936 message_loop_.RunUntilIdle(); |
952 | 937 |
953 EXPECT_EQ(observer_->data_, data_two); | 938 EXPECT_EQ(observer_->data_, data_two); |
954 EXPECT_EQ(observer_->read_mtu_, | 939 EXPECT_EQ(observer_->read_mtu_, |
955 FakeBluetoothMediaTransportClient::kDefaultReadMtu); | 940 FakeBluetoothMediaTransportClient::kDefaultReadMtu); |
956 EXPECT_EQ(observer_->state_changed_count_, 3); | 941 EXPECT_EQ(observer_->state_changed_count_, 3); |
957 EXPECT_EQ(observer_->total_read_, data_one.size() + data_two.size()); | 942 EXPECT_EQ(observer_->total_read_, data_one.size() + data_two.size()); |
958 } | 943 } |
959 | 944 |
960 } // namespace chromeos | 945 } // namespace bluez |
OLD | NEW |