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 "chromeos/dbus/bluetooth_media_client.h" | |
12 #include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h" | |
13 #include "chromeos/dbus/bluetooth_media_transport_client.h" | |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
15 #include "chromeos/dbus/fake_bluetooth_media_client.h" | |
16 #include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" | |
17 #include "chromeos/dbus/fake_bluetooth_media_transport_client.h" | |
12 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
13 #include "device/bluetooth/bluetooth_adapter.h" | 19 #include "device/bluetooth/bluetooth_adapter.h" |
14 #include "device/bluetooth/bluetooth_adapter_factory.h" | 20 #include "device/bluetooth/bluetooth_adapter_factory.h" |
15 #include "device/bluetooth/bluetooth_audio_sink.h" | 21 #include "device/bluetooth/bluetooth_audio_sink.h" |
16 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h" | 22 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
18 | 24 |
25 using dbus::ObjectPath; | |
19 using device::BluetoothAdapter; | 26 using device::BluetoothAdapter; |
20 using device::BluetoothAdapterFactory; | 27 using device::BluetoothAdapterFactory; |
21 using device::BluetoothAudioSink; | 28 using device::BluetoothAudioSink; |
22 | 29 |
23 namespace chromeos { | 30 namespace chromeos { |
24 | 31 |
25 class TestAudioSinkObserver : public BluetoothAudioSink::Observer { | 32 class TestAudioSinkObserver : public BluetoothAudioSink::Observer { |
26 public: | 33 public: |
27 explicit TestAudioSinkObserver(scoped_refptr<BluetoothAudioSink> audio_sink) | 34 explicit TestAudioSinkObserver(scoped_refptr<BluetoothAudioSink> audio_sink) |
28 : state_changed_count_(0), | 35 : state_changed_count_(0), |
(...skipping 20 matching lines...) Expand all Loading... | |
49 int volume_changed_count_; | 56 int volume_changed_count_; |
50 BluetoothAudioSink::State state_; | 57 BluetoothAudioSink::State state_; |
51 | 58 |
52 private: | 59 private: |
53 scoped_refptr<BluetoothAudioSink> audio_sink_; | 60 scoped_refptr<BluetoothAudioSink> audio_sink_; |
54 }; | 61 }; |
55 | 62 |
56 class BluetoothAudioSinkChromeOSTest : public testing::Test { | 63 class BluetoothAudioSinkChromeOSTest : public testing::Test { |
57 public: | 64 public: |
58 void SetUp() override { | 65 void SetUp() override { |
59 chromeos::DBusThreadManager::Initialize(); | 66 DBusThreadManager::Initialize(); |
60 | 67 |
61 callback_count_ = 0; | 68 callback_count_ = 0; |
62 error_callback_count_ = 0; | 69 error_callback_count_ = 0; |
63 audio_sink_ = nullptr; | 70 |
64 adapter_ = nullptr; | 71 // Initiates Delegate::TransportProperties with default values. |
72 properties_.device = | |
73 ObjectPath(FakeBluetoothMediaTransportClient::kTransportDevicePath); | |
74 properties_.uuid = BluetoothMediaClient::kBluetoothAudioSinkUUID; | |
75 properties_.codec = FakeBluetoothMediaTransportClient::kTransportCodec; | |
76 properties_.configuration = | |
77 FakeBluetoothMediaTransportClient::kTransportConfiguration; | |
78 properties_.state = BluetoothMediaTransportClient::kStateIdle; | |
79 properties_.delay.reset( | |
80 new uint16_t(FakeBluetoothMediaTransportClient::kTransportDelay)); | |
81 properties_.volume.reset( | |
82 new uint16_t(FakeBluetoothMediaTransportClient::kTransportVolume)); | |
65 | 83 |
66 GetAdapter(); | 84 GetAdapter(); |
67 } | 85 } |
68 | 86 |
69 void TearDown() override { | 87 void TearDown() override { |
70 callback_count_ = 0; | 88 callback_count_ = 0; |
71 error_callback_count_ = 0; | 89 error_callback_count_ = 0; |
72 | 90 |
73 // The adapter should outlive audio sink. | 91 // The adapter should outlive audio sink. |
74 audio_sink_ = nullptr; | 92 audio_sink_ = nullptr; |
75 adapter_ = nullptr; | 93 adapter_ = nullptr; |
76 DBusThreadManager::Shutdown(); | 94 DBusThreadManager::Shutdown(); |
77 } | 95 } |
78 | 96 |
79 // Get the existing Bluetooth adapter. | 97 // Gets the existing Bluetooth adapter. |
80 void GetAdapter() { | 98 void GetAdapter() { |
81 BluetoothAdapterFactory::GetAdapter( | 99 BluetoothAdapterFactory::GetAdapter( |
82 base::Bind(&BluetoothAudioSinkChromeOSTest::GetAdapterCallback, | 100 base::Bind(&BluetoothAudioSinkChromeOSTest::GetAdapterCallback, |
83 base::Unretained(this))); | 101 base::Unretained(this))); |
84 } | 102 } |
85 | 103 |
104 // Called whenever BluetoothAdapter is retrieved successfully. | |
86 void GetAdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { | 105 void GetAdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { |
87 adapter_ = adapter; | 106 adapter_ = adapter; |
88 | 107 |
89 ASSERT_NE(adapter_.get(), nullptr); | 108 ASSERT_NE(adapter_.get(), nullptr); |
90 ASSERT_TRUE(adapter_->IsInitialized()); | 109 ASSERT_TRUE(adapter_->IsInitialized()); |
91 adapter_->SetPowered( | 110 adapter_->SetPowered( |
92 true, | 111 true, |
93 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, | 112 base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, |
94 base::Unretained(this)), | 113 base::Unretained(this)), |
95 base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, | 114 base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, |
96 base::Unretained(this))); | 115 base::Unretained(this))); |
97 ASSERT_TRUE(adapter_->IsPresent()); | 116 ASSERT_TRUE(adapter_->IsPresent()); |
98 ASSERT_TRUE(adapter_->IsPowered()); | 117 ASSERT_TRUE(adapter_->IsPowered()); |
99 ASSERT_EQ(callback_count_, 1); | 118 EXPECT_EQ(callback_count_, 1); |
100 ASSERT_EQ(error_callback_count_, 0); | 119 EXPECT_EQ(error_callback_count_, 0); |
120 | |
121 // Resets callback_count_. | |
101 --callback_count_; | 122 --callback_count_; |
102 } | 123 } |
103 | 124 |
125 // Registers BluetoothAudioSinkChromeOS with default codec and capabilities. | |
126 void GetAudioSink() { | |
127 // Sets up valid codec and capabilities. | |
128 BluetoothAudioSink::Options options; | |
129 ASSERT_EQ(options.codec, 0x00); | |
130 ASSERT_EQ(options.capabilities, | |
131 std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35})); | |
132 | |
133 // Registers |audio_sink_| with valid codec and capabilities | |
134 adapter_->RegisterAudioSink( | |
135 options, | |
136 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, | |
137 base::Unretained(this)), | |
138 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, | |
139 base::Unretained(this))); | |
140 | |
141 EXPECT_EQ(callback_count_, 1); | |
142 EXPECT_EQ(error_callback_count_, 0); | |
143 } | |
144 | |
104 // Called whenever RegisterAudioSink is completed successfully. | 145 // Called whenever RegisterAudioSink is completed successfully. |
105 void RegisterCallback( | 146 void RegisterCallback( |
106 scoped_refptr<BluetoothAudioSink> audio_sink) { | 147 scoped_refptr<BluetoothAudioSink> audio_sink) { |
107 ++callback_count_; | 148 ++callback_count_; |
108 audio_sink_ = audio_sink; | 149 audio_sink_ = audio_sink; |
109 ASSERT_NE(audio_sink_.get(), nullptr); | 150 ASSERT_NE(audio_sink_.get(), nullptr); |
110 ASSERT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | 151 ASSERT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); |
111 } | 152 } |
112 | 153 |
113 // Called whenever RegisterAudioSink failed. | 154 // Called whenever RegisterAudioSink failed. |
114 void RegisterErrorCallback(BluetoothAudioSink::ErrorCode error_code) { | 155 void RegisterErrorCallback(BluetoothAudioSink::ErrorCode error_code) { |
115 ++error_callback_count_; | 156 ++error_callback_count_; |
116 ASSERT_EQ(error_code, BluetoothAudioSink::ERROR_NOT_REGISTERED); | 157 EXPECT_EQ(error_code, BluetoothAudioSink::ERROR_NOT_REGISTERED); |
158 } | |
159 | |
160 // Called whenever there capabilities are returned from SelectConfiguration. | |
161 void SelectConfigurationCallback(const std::vector<uint8_t>& capabilities) { | |
162 ++callback_count_; | |
163 | |
164 // |capabilities| should be the same as the capabilities for registering an | |
165 // audio sink in GetAudioSink(). | |
166 EXPECT_EQ(capabilities, std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35})); | |
117 } | 167 } |
118 | 168 |
119 // Generic callbacks. | 169 // Generic callbacks. |
120 void Callback() { | 170 void Callback() { |
121 ++callback_count_; | 171 ++callback_count_; |
122 } | 172 } |
123 | 173 |
124 void ErrorCallback() { | 174 void ErrorCallback() { |
125 ++error_callback_count_; | 175 ++error_callback_count_; |
126 } | 176 } |
127 | 177 |
128 protected: | 178 protected: |
129 int callback_count_; | 179 int callback_count_; |
130 int error_callback_count_; | 180 int error_callback_count_; |
181 | |
131 base::MessageLoop message_loop_; | 182 base::MessageLoop message_loop_; |
183 | |
132 scoped_refptr<BluetoothAdapter> adapter_; | 184 scoped_refptr<BluetoothAdapter> adapter_; |
133 scoped_refptr<BluetoothAudioSink> audio_sink_; | 185 scoped_refptr<BluetoothAudioSink> audio_sink_; |
186 | |
187 // The default property set used while calling SetConfiguration on a media | |
188 // endpoint object. | |
189 BluetoothMediaEndpointServiceProvider::Delegate::TransportProperties | |
190 properties_; | |
134 }; | 191 }; |
135 | 192 |
136 TEST_F(BluetoothAudioSinkChromeOSTest, RegisterSucceeded) { | 193 TEST_F(BluetoothAudioSinkChromeOSTest, RegisterSucceeded) { |
137 // Sets up valid codec and capabilities. | 194 GetAudioSink(); |
138 BluetoothAudioSink::Options options; | |
139 ASSERT_EQ(options.codec, 0x00); | |
140 ASSERT_EQ(options.capabilities, | |
141 std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35})); | |
142 adapter_->RegisterAudioSink( | |
143 options, | |
144 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, | |
145 base::Unretained(this)), | |
146 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, | |
147 base::Unretained(this))); | |
148 | 195 |
149 // Adds observer for the audio sink. | 196 // Adds an observer for |audio_sink_|. |
150 TestAudioSinkObserver observer(audio_sink_); | 197 TestAudioSinkObserver observer(audio_sink_); |
151 | 198 EXPECT_EQ(observer.state_changed_count_, 0); |
152 ASSERT_EQ(callback_count_, 1); | 199 EXPECT_EQ(observer.volume_changed_count_, 0); |
153 ASSERT_EQ(error_callback_count_, 0); | |
154 ASSERT_EQ(observer.state_changed_count_, 0); | |
155 ASSERT_EQ(observer.volume_changed_count_, 0); | |
156 } | 200 } |
157 | 201 |
158 TEST_F(BluetoothAudioSinkChromeOSTest, RegisterFailedWithInvalidOptions) { | 202 TEST_F(BluetoothAudioSinkChromeOSTest, RegisterFailedWithInvalidOptions) { |
159 // Sets options with an invalid codec and valid capabilities. | 203 // Sets options with an invalid codec and valid capabilities. |
160 BluetoothAudioSink::Options options; | 204 BluetoothAudioSink::Options options; |
161 options.codec = 0xff; | 205 options.codec = 0xff; |
162 options.capabilities = std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35}); | 206 options.capabilities = std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35}); |
163 | 207 |
164 adapter_->RegisterAudioSink( | 208 adapter_->RegisterAudioSink( |
165 options, | 209 options, |
166 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, | 210 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, |
167 base::Unretained(this)), | 211 base::Unretained(this)), |
168 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, | 212 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, |
169 base::Unretained(this))); | 213 base::Unretained(this))); |
170 | 214 |
171 ASSERT_EQ(callback_count_, 0); | 215 EXPECT_EQ(callback_count_, 0); |
172 ASSERT_EQ(error_callback_count_, 1); | 216 EXPECT_EQ(error_callback_count_, 1); |
173 | 217 |
174 // Sets options with a valid codec and invalid capabilities. | 218 // Sets options with a valid codec and invalid capabilities. |
175 options.codec = 0x00; | 219 options.codec = 0x00; |
176 options.capabilities.clear(); | 220 options.capabilities.clear(); |
177 adapter_->RegisterAudioSink( | 221 adapter_->RegisterAudioSink( |
178 options, | 222 options, |
179 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, | 223 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, |
180 base::Unretained(this)), | 224 base::Unretained(this)), |
181 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, | 225 base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, |
182 base::Unretained(this))); | 226 base::Unretained(this))); |
183 | 227 |
184 ASSERT_EQ(callback_count_, 0); | 228 |
185 ASSERT_EQ(error_callback_count_, 2); | 229 EXPECT_EQ(callback_count_, 0); |
230 EXPECT_EQ(error_callback_count_, 2); | |
231 } | |
232 | |
233 TEST_F(BluetoothAudioSinkChromeOSTest, SelectConfiguration) { | |
234 GetAudioSink(); | |
235 | |
236 // Adds an observer for |audio_sink_|. | |
237 TestAudioSinkObserver observer(audio_sink_); | |
Ben Chan
2015/02/12 21:17:44
perhaps a TODO in a follow-up CL, refactor common
Miao
2015/02/12 22:54:06
Will refactor common tests in the next CL.
| |
238 EXPECT_EQ(observer.state_changed_count_, 0); | |
239 EXPECT_EQ(observer.volume_changed_count_, 0); | |
240 | |
241 // Simulates calling SelectConfiguration on the media endpoint object owned by | |
242 // |audio_sink_| with some fake capabilities. | |
243 BluetoothAudioSinkChromeOS* audio_sink_chromeos = | |
244 static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); | |
245 FakeBluetoothMediaEndpointServiceProvider* media_endpoint = | |
246 static_cast<FakeBluetoothMediaEndpointServiceProvider*>( | |
247 audio_sink_chromeos->GetEndpointServiceProvider()); | |
248 ASSERT_NE(media_endpoint, nullptr); | |
249 | |
250 media_endpoint->SelectConfiguration( | |
251 std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), | |
252 base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, | |
253 base::Unretained(this))); | |
254 | |
255 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | |
256 EXPECT_EQ(callback_count_, 2); | |
257 EXPECT_EQ(error_callback_count_, 0); | |
258 EXPECT_EQ(observer.state_changed_count_, 0); | |
259 EXPECT_EQ(observer.volume_changed_count_, 0); | |
260 } | |
261 | |
262 TEST_F(BluetoothAudioSinkChromeOSTest, SetConfiguration) { | |
263 GetAudioSink(); | |
264 | |
265 // Adds an observer for |audio_sink_|. | |
266 TestAudioSinkObserver observer(audio_sink_); | |
267 EXPECT_EQ(observer.state_changed_count_, 0); | |
268 EXPECT_EQ(observer.volume_changed_count_, 0); | |
269 | |
270 // Simulates calling SetConfiguration on the media endpoint object owned by | |
271 // |audio_sink_| with a fake transport path and a | |
272 // Delegate::TransportProperties structure. | |
273 BluetoothAudioSinkChromeOS* audio_sink_chromeos = | |
274 static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); | |
275 FakeBluetoothMediaEndpointServiceProvider* media_endpoint = | |
276 static_cast<FakeBluetoothMediaEndpointServiceProvider*>( | |
277 audio_sink_chromeos->GetEndpointServiceProvider()); | |
278 ASSERT_NE(media_endpoint, nullptr); | |
279 | |
280 media_endpoint->SetConfiguration( | |
281 ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath), | |
282 properties_); | |
283 | |
284 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | |
285 EXPECT_EQ(callback_count_, 1); | |
286 EXPECT_EQ(error_callback_count_, 0); | |
287 EXPECT_EQ(observer.state_changed_count_, 1); | |
288 EXPECT_EQ(observer.volume_changed_count_, 1); | |
289 } | |
290 | |
291 TEST_F(BluetoothAudioSinkChromeOSTest, SetConfigurationWithUnexpectedState) { | |
292 GetAudioSink(); | |
293 | |
294 // Adds an observer for |audio_sink_|. | |
295 TestAudioSinkObserver observer(audio_sink_); | |
296 EXPECT_EQ(observer.state_changed_count_, 0); | |
297 EXPECT_EQ(observer.volume_changed_count_, 0); | |
298 | |
299 // Simulates calling SetConfiguration on the media endpoint object owned by | |
300 // |audio_sink_| with a fake transport path and a | |
301 // Delegate::TransportProperties structure. | |
302 BluetoothAudioSinkChromeOS* audio_sink_chromeos = | |
303 static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); | |
304 FakeBluetoothMediaEndpointServiceProvider* media_endpoint = | |
305 static_cast<FakeBluetoothMediaEndpointServiceProvider*>( | |
306 audio_sink_chromeos->GetEndpointServiceProvider()); | |
307 ASSERT_NE(media_endpoint, nullptr); | |
308 | |
309 // Set state of Delegate::TransportProperties with an unexpected value. | |
310 properties_.state = "active"; | |
311 | |
312 media_endpoint->SetConfiguration( | |
313 ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath), | |
314 properties_); | |
315 | |
316 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | |
317 EXPECT_EQ(callback_count_, 1); | |
318 EXPECT_EQ(error_callback_count_, 0); | |
319 EXPECT_EQ(observer.state_changed_count_, 0); | |
320 EXPECT_EQ(observer.volume_changed_count_, 0); | |
321 } | |
322 | |
323 // Checks if the observer is notified while the media object is | |
324 // removed(invisible). Once the media object is removed, the audio sink is no | |
325 // longer valid. | |
326 TEST_F(BluetoothAudioSinkChromeOSTest, ObserverNotifiedWhenMediaRemoved) { | |
327 GetAudioSink(); | |
328 | |
329 // Adds an observer for |audio_sink_|. | |
330 TestAudioSinkObserver observer(audio_sink_); | |
331 EXPECT_EQ(observer.state_changed_count_, 0); | |
332 EXPECT_EQ(observer.volume_changed_count_, 0); | |
333 | |
334 // Gets the media object and makes it invisible to see if the state of the | |
335 // audio sink changes accordingly. | |
336 FakeBluetoothMediaClient* media = static_cast<FakeBluetoothMediaClient*>( | |
337 DBusThreadManager::Get()->GetBluetoothMediaClient()); | |
338 media->SetVisible(false); | |
339 | |
340 BluetoothAudioSinkChromeOS* audio_sink_chromeos = | |
341 static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); | |
342 FakeBluetoothMediaEndpointServiceProvider* media_endpoint = | |
343 static_cast<FakeBluetoothMediaEndpointServiceProvider*>( | |
344 audio_sink_chromeos->GetEndpointServiceProvider()); | |
345 | |
346 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); | |
347 EXPECT_EQ(media_endpoint, nullptr); | |
348 } | |
349 | |
350 // Checks if the observer is notified while the media transport is | |
351 // removed(invisible). Once the media transport object is removed, the audio | |
352 // sink is disconnected. | |
353 TEST_F(BluetoothAudioSinkChromeOSTest, ObserverNotifiedWhenTransportRemoved) { | |
354 GetAudioSink(); | |
355 | |
356 // Adds an observer for |audio_sink_|. | |
357 TestAudioSinkObserver observer(audio_sink_); | |
358 EXPECT_EQ(observer.state_changed_count_, 0); | |
359 EXPECT_EQ(observer.volume_changed_count_, 0); | |
360 | |
361 // Simulates calling SetConfiguration on the media endpoint object owned by | |
362 // |audio_sink_| with a fake transport path and a | |
363 // Delegate::TransportProperties structure. | |
364 BluetoothAudioSinkChromeOS* audio_sink_chromeos = | |
365 static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); | |
366 FakeBluetoothMediaEndpointServiceProvider* media_endpoint = | |
367 static_cast<FakeBluetoothMediaEndpointServiceProvider*>( | |
368 audio_sink_chromeos->GetEndpointServiceProvider()); | |
369 ASSERT_NE(media_endpoint, nullptr); | |
370 | |
371 media_endpoint->SetConfiguration( | |
372 ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath), | |
373 properties_); | |
374 | |
375 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE); | |
376 EXPECT_EQ(callback_count_, 1); | |
377 EXPECT_EQ(error_callback_count_, 0); | |
378 EXPECT_EQ(observer.state_changed_count_, 1); | |
379 EXPECT_EQ(observer.volume_changed_count_, 1); | |
380 | |
381 // Gets the media transport object and makes it invalid to see if the state | |
382 // of the audio sink changes accordingly. | |
383 FakeBluetoothMediaTransportClient* transport = | |
384 static_cast<FakeBluetoothMediaTransportClient*>( | |
385 DBusThreadManager::Get()->GetBluetoothMediaTransportClient()); | |
386 | |
387 transport->SetValid(media_endpoint->object_path(), false); | |
388 EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); | |
389 EXPECT_NE(media_endpoint, nullptr); | |
186 } | 390 } |
187 | 391 |
188 } // namespace chromeos | 392 } // namespace chromeos |
OLD | NEW |