Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1468)

Unified Diff: device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc

Issue 939753004: device/bluetooth: Implement Unregister() of BlueotoothAudioSinkChromeOS and disconnection-related c… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc
diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc b/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc
index 9aa727f08b4c862a8e40bf8df65961c8bb2c5b6e..7889e6f2e1618d5a4f3442b02dc9ba0c7833aae5 100644
--- a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc
@@ -87,6 +87,7 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test {
void TearDown() override {
callback_count_ = 0;
error_callback_count_ = 0;
+ observer_.reset();
// The adapter should outlive audio sink.
audio_sink_ = nullptr;
@@ -138,8 +139,20 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test {
base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback,
base::Unretained(this)));
+ observer_.reset(new TestAudioSinkObserver(audio_sink_));
EXPECT_EQ(callback_count_, 1);
EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 0);
+ EXPECT_EQ(observer_->volume_changed_count_, 0);
+ }
+
+ void GetFakeMediaEndpoint() {
+ BluetoothAudioSinkChromeOS* audio_sink_chromeos =
+ static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get());
+ ASSERT_NE(audio_sink_chromeos, nullptr);
+
+ media_endpoint_ = static_cast<FakeBluetoothMediaEndpointServiceProvider*>(
+ audio_sink_chromeos->GetEndpointServiceProvider());
}
// Called whenever RegisterAudioSink is completed successfully.
@@ -181,6 +194,8 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test {
base::MessageLoop message_loop_;
+ FakeBluetoothMediaEndpointServiceProvider* media_endpoint_;
+ scoped_ptr<TestAudioSinkObserver> observer_;
scoped_refptr<BluetoothAdapter> adapter_;
scoped_refptr<BluetoothAudioSink> audio_sink_;
@@ -192,11 +207,6 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test {
TEST_F(BluetoothAudioSinkChromeOSTest, RegisterSucceeded) {
GetAudioSink();
-
- // Adds an observer for |audio_sink_|.
- TestAudioSinkObserver observer(audio_sink_);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
}
TEST_F(BluetoothAudioSinkChromeOSTest, RegisterFailedWithInvalidOptions) {
@@ -231,22 +241,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, RegisterFailedWithInvalidOptions) {
TEST_F(BluetoothAudioSinkChromeOSTest, SelectConfiguration) {
GetAudioSink();
-
- // Adds an observer for |audio_sink_|.
- TestAudioSinkObserver observer(audio_sink_);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
// Simulates calling SelectConfiguration on the media endpoint object owned by
// |audio_sink_| with some fake capabilities.
- BluetoothAudioSinkChromeOS* audio_sink_chromeos =
- static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get());
- FakeBluetoothMediaEndpointServiceProvider* media_endpoint =
- static_cast<FakeBluetoothMediaEndpointServiceProvider*>(
- audio_sink_chromeos->GetEndpointServiceProvider());
- ASSERT_NE(media_endpoint, nullptr);
-
- media_endpoint->SelectConfiguration(
+ media_endpoint_->SelectConfiguration(
std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}),
base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback,
base::Unretained(this)));
@@ -254,81 +254,57 @@ TEST_F(BluetoothAudioSinkChromeOSTest, SelectConfiguration) {
EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
EXPECT_EQ(callback_count_, 2);
EXPECT_EQ(error_callback_count_, 0);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 0);
+ EXPECT_EQ(observer_->volume_changed_count_, 0);
}
TEST_F(BluetoothAudioSinkChromeOSTest, SetConfiguration) {
GetAudioSink();
-
- // Adds an observer for |audio_sink_|.
- TestAudioSinkObserver observer(audio_sink_);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
// Simulates calling SetConfiguration on the media endpoint object owned by
// |audio_sink_| with a fake transport path and a
// Delegate::TransportProperties structure.
- BluetoothAudioSinkChromeOS* audio_sink_chromeos =
- static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get());
- FakeBluetoothMediaEndpointServiceProvider* media_endpoint =
- static_cast<FakeBluetoothMediaEndpointServiceProvider*>(
- audio_sink_chromeos->GetEndpointServiceProvider());
- ASSERT_NE(media_endpoint, nullptr);
-
- media_endpoint->SetConfiguration(
+ media_endpoint_->SetConfiguration(
ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
properties_);
EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
EXPECT_EQ(callback_count_, 1);
EXPECT_EQ(error_callback_count_, 0);
- EXPECT_EQ(observer.state_changed_count_, 1);
- EXPECT_EQ(observer.volume_changed_count_, 1);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
}
TEST_F(BluetoothAudioSinkChromeOSTest, SetConfigurationWithUnexpectedState) {
GetAudioSink();
-
- // Adds an observer for |audio_sink_|.
- TestAudioSinkObserver observer(audio_sink_);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
-
- // Simulates calling SetConfiguration on the media endpoint object owned by
- // |audio_sink_| with a fake transport path and a
- // Delegate::TransportProperties structure.
- BluetoothAudioSinkChromeOS* audio_sink_chromeos =
- static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get());
- FakeBluetoothMediaEndpointServiceProvider* media_endpoint =
- static_cast<FakeBluetoothMediaEndpointServiceProvider*>(
- audio_sink_chromeos->GetEndpointServiceProvider());
- ASSERT_NE(media_endpoint, nullptr);
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
// Set state of Delegate::TransportProperties with an unexpected value.
properties_.state = "active";
- media_endpoint->SetConfiguration(
+ media_endpoint_->SetConfiguration(
ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
properties_);
EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
EXPECT_EQ(callback_count_, 1);
EXPECT_EQ(error_callback_count_, 0);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 0);
+ EXPECT_EQ(observer_->volume_changed_count_, 0);
}
-// Checks if the observer is notified while the media object is
-// removed(invisible). Once the media object is removed, the audio sink is no
-// longer valid.
-TEST_F(BluetoothAudioSinkChromeOSTest, ObserverNotifiedWhenMediaRemoved) {
+// TODO(mcchou): Adds test on media-removed events for STATE_PENDING and
+// STATE_ACTIVE.
+// Checks if the observer is notified on media-removed event when the state of
+// |audio_sink_| is STATE_DISCONNECTED. Once the media object is removed, the
+// audio sink is no longer valid.
+TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringDisconnectedState) {
GetAudioSink();
-
- // Adds an observer for |audio_sink_|.
- TestAudioSinkObserver observer(audio_sink_);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
// Gets the media object and makes it invisible to see if the state of the
// audio sink changes accordingly.
@@ -336,46 +312,69 @@ TEST_F(BluetoothAudioSinkChromeOSTest, ObserverNotifiedWhenMediaRemoved) {
DBusThreadManager::Get()->GetBluetoothMediaClient());
media->SetVisible(false);
- BluetoothAudioSinkChromeOS* audio_sink_chromeos =
- static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get());
- FakeBluetoothMediaEndpointServiceProvider* media_endpoint =
- static_cast<FakeBluetoothMediaEndpointServiceProvider*>(
- audio_sink_chromeos->GetEndpointServiceProvider());
+ GetFakeMediaEndpoint();
EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID);
- EXPECT_EQ(media_endpoint, nullptr);
+ EXPECT_EQ(media_endpoint_, nullptr);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 0);
}
-// Checks if the observer is notified while the media transport is
-// removed(invisible). Once the media transport object is removed, the audio
-// sink is disconnected.
-TEST_F(BluetoothAudioSinkChromeOSTest, ObserverNotifiedWhenTransportRemoved) {
+// Checks if the observer is notified on media-removed event when the state of
+// |audio_sink_| is STATE_IDLE. Once the media object is removed, the audio sink
+// is no longer valid.
+TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringIdleState) {
GetAudioSink();
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
- // Adds an observer for |audio_sink_|.
- TestAudioSinkObserver observer(audio_sink_);
- EXPECT_EQ(observer.state_changed_count_, 0);
- EXPECT_EQ(observer.volume_changed_count_, 0);
+ media_endpoint_->SetConfiguration(
+ ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
+ properties_);
- // Simulates calling SetConfiguration on the media endpoint object owned by
- // |audio_sink_| with a fake transport path and a
- // Delegate::TransportProperties structure.
- BluetoothAudioSinkChromeOS* audio_sink_chromeos =
- static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get());
- FakeBluetoothMediaEndpointServiceProvider* media_endpoint =
- static_cast<FakeBluetoothMediaEndpointServiceProvider*>(
- audio_sink_chromeos->GetEndpointServiceProvider());
- ASSERT_NE(media_endpoint, nullptr);
-
- media_endpoint->SetConfiguration(
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
+ EXPECT_EQ(callback_count_, 1);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
+
+ // Gets the media object and makes it invisible to see if the state of the
+ // audio sink changes accordingly.
+ FakeBluetoothMediaClient* media = static_cast<FakeBluetoothMediaClient*>(
+ DBusThreadManager::Get()->GetBluetoothMediaClient());
+ media->SetVisible(false);
+
+ GetFakeMediaEndpoint();
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID);
+ EXPECT_EQ(media_endpoint_, nullptr);
+ // The state becomes disconnted and then invalid, since the removal of
+ // transport object should happend before media becomes invisible.
+ // State: STATE_IDLE -> STATE_DISCONNECTED -> STATE_INVALID
+ EXPECT_EQ(observer_->state_changed_count_, 3);
+ EXPECT_EQ(observer_->volume_changed_count_, 2);
+}
+
+// TODO(mcchou): Add tests on media-removed event for STATE_PENDING and
+// STATE_ACTIVE.
+
+// Checks if the observer is notified on transport-removed event when the state
+// of |audio_sink_| is STATE_IDEL. Once the media transport object is removed,
+// the audio sink is disconnected.
+TEST_F(BluetoothAudioSinkChromeOSTest, TransportRemovedDuringIdleState) {
+ GetAudioSink();
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
+
+ media_endpoint_->SetConfiguration(
ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
properties_);
EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
EXPECT_EQ(callback_count_, 1);
EXPECT_EQ(error_callback_count_, 0);
- EXPECT_EQ(observer.state_changed_count_, 1);
- EXPECT_EQ(observer.volume_changed_count_, 1);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
// Gets the media transport object and makes it invalid to see if the state
// of the audio sink changes accordingly.
@@ -383,9 +382,202 @@ TEST_F(BluetoothAudioSinkChromeOSTest, ObserverNotifiedWhenTransportRemoved) {
static_cast<FakeBluetoothMediaTransportClient*>(
DBusThreadManager::Get()->GetBluetoothMediaTransportClient());
- transport->SetValid(media_endpoint->object_path(), false);
+ transport->SetValid(media_endpoint_->object_path(), false);
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
+ EXPECT_NE(media_endpoint_, nullptr);
+ EXPECT_EQ(observer_->state_changed_count_, 2);
+ EXPECT_EQ(observer_->volume_changed_count_, 2);
+}
+
+// TODO(mcchou): Add tests on transport-removed event for STATE_PENDING and
+// STATE_ACTIVE.
+
+TEST_F(BluetoothAudioSinkChromeOSTest,
+ AdapterPoweredChangedDuringDisconnectedState) {
+ GetAudioSink();
+
+ adapter_->SetPowered(
+ false,
+ base::Bind(&BluetoothAudioSinkChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+
+ EXPECT_TRUE(adapter_->IsPresent());
+ EXPECT_FALSE(adapter_->IsPowered());
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
+ EXPECT_EQ(callback_count_, 2);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 0);
+ EXPECT_EQ(observer_->volume_changed_count_, 0);
+
+ adapter_->SetPowered(
+ true,
+ base::Bind(&BluetoothAudioSinkChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+
+ EXPECT_TRUE(adapter_->IsPresent());
+ EXPECT_TRUE(adapter_->IsPowered());
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
+ EXPECT_EQ(callback_count_, 3);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 0);
+ EXPECT_EQ(observer_->volume_changed_count_, 0);
+}
+
+TEST_F(BluetoothAudioSinkChromeOSTest, AdapterPoweredChangedDuringIdleState) {
+ GetAudioSink();
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
+
+ media_endpoint_->SetConfiguration(
+ ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
+ properties_);
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
+ EXPECT_EQ(callback_count_, 1);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
+
+ adapter_->SetPowered(
+ false,
+ base::Bind(&BluetoothAudioSinkChromeOSTest::Callback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback,
+ base::Unretained(this)));
+ GetFakeMediaEndpoint();
+
+ EXPECT_TRUE(adapter_->IsPresent());
+ EXPECT_FALSE(adapter_->IsPowered());
+ EXPECT_NE(media_endpoint_, nullptr);
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
+ EXPECT_EQ(callback_count_, 2);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 2);
+ EXPECT_EQ(observer_->volume_changed_count_, 2);
+}
+
+// TODO(mcchou): Add tests on AdapterPoweredChanged event for STATE_PENDING and
+// STATE_ACTIVE.
+
+TEST_F(BluetoothAudioSinkChromeOSTest, ClearConfiguration) {
+ GetAudioSink();
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
+
+ media_endpoint_->SetConfiguration(
+ ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
+ properties_);
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
+ EXPECT_EQ(callback_count_, 1);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
+
+ // Simulates calling ClearConfiguration on the media endpoint object with the
+ // transport path.
+ media_endpoint_->ClearConfiguration(
+ ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath));
+
EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
- EXPECT_NE(media_endpoint, nullptr);
+ EXPECT_EQ(observer_->state_changed_count_, 2);
+ EXPECT_EQ(observer_->volume_changed_count_, 2);
+}
+
+TEST_F(BluetoothAudioSinkChromeOSTest, ClearConfigurationWithIrrelevantPath) {
+ GetAudioSink();
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
+
+ media_endpoint_->SetConfiguration(
+ ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
+ properties_);
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
+ EXPECT_EQ(callback_count_, 1);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
+
+ // Simulates calling ClearConfiguration on the media endpoint object with an
+ // irrelevant transport path.
+ media_endpoint_->ClearConfiguration(ObjectPath("IrrelevantPath"));
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
+}
+
+TEST_F(BluetoothAudioSinkChromeOSTest, EndpointReleased) {
Miao 2015/02/23 21:04:25 Removed this test. This can be included in Unregis
+ GetAudioSink();
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
+
+ media_endpoint_->SetConfiguration(
+ ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
+ properties_);
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
+ EXPECT_EQ(callback_count_, 1);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
+
+ // Simulates calling Release on the media endpoint object.
+ media_endpoint_->Released();
+
+ GetFakeMediaEndpoint();
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID);
+ EXPECT_EQ(media_endpoint_, nullptr);
+ EXPECT_EQ(observer_->state_changed_count_, 2);
+ EXPECT_EQ(observer_->volume_changed_count_, 2);
+}
+
+TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringIdleState) {
+ GetAudioSink();
+ GetFakeMediaEndpoint();
+ ASSERT_NE(media_endpoint_, nullptr);
+
+ media_endpoint_->SelectConfiguration(
+ std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}),
+ base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback,
+ base::Unretained(this)));
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED);
+ EXPECT_EQ(callback_count_, 2);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 0);
+ EXPECT_EQ(observer_->volume_changed_count_, 0);
+
+ media_endpoint_->SetConfiguration(
+ ObjectPath(FakeBluetoothMediaTransportClient::kTransportPath),
+ properties_);
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_IDLE);
+ EXPECT_EQ(callback_count_, 2);
+ EXPECT_EQ(error_callback_count_, 0);
+ EXPECT_EQ(observer_->state_changed_count_, 1);
+ EXPECT_EQ(observer_->volume_changed_count_, 1);
+
+ audio_sink_->Unregister(base::Bind(&BluetoothAudioSinkChromeOSTest::Callback,
+ base::Unretained(this)));
+
+ EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID);
+ EXPECT_EQ(callback_count_, 3);
+ EXPECT_EQ(error_callback_count_, 0);
+
+ // The state becomes disconnted and then invalid, since the removal of
+ // transport object should happend before the unregistration of endpoint.
+ // State: STATE_IDLE -> STATE_DISCONNECTED -> STATE_INVALID
+ EXPECT_EQ(observer_->state_changed_count_, 3);
+ EXPECT_EQ(observer_->volume_changed_count_, 2);
}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698