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