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

Unified Diff: chrome/browser/media/router/media_router_mojo_impl_unittest.cc

Issue 1430413003: [Media Router] Connection state change listening redesign part 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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: chrome/browser/media/router/media_router_mojo_impl_unittest.cc
diff --git a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
index e07f88017f53a5ddb8ad826ab66ab0b74296d49f..8ec2b382bf811cd978ade261ed4e730939cc9db7 100644
--- a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
+++ b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
@@ -741,25 +741,49 @@ TEST_F(MediaRouterMojoImplTest, PresentationSessionMessagesError) {
ProcessEventLoop();
}
-TEST_F(MediaRouterMojoImplTest, PresentationConnectionStateObserver) {
+TEST_F(MediaRouterMojoImplTest, PresentationConnectionStateChangedCallback) {
using PresentationConnectionState =
interfaces::MediaRouter::PresentationConnectionState;
MediaRoute::Id route_id("route-id");
- MockPresentationConnectionStateObserver observer(router(), route_id);
+ const std::string kPresentationUrl("http://foo.fakeUrl");
+ const std::string kPresentationId("pid");
+ content::PresentationSessionInfo connection(kPresentationUrl,
+ kPresentationId);
+ MockPresentationConnectionStateChangedCallback callback;
+ scoped_ptr<PresentationConnectionStateSubscription> subscription =
+ router()->AddPresentationConnectionStateChangedCallback(
+ route_id,
+ base::Bind(&MockPresentationConnectionStateChangedCallback::Run,
+ base::Unretained(&callback)));
+
+ EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED))
+ .Times(1);
+ media_router_proxy_->OnPresentationConnectionStateChanged(
+ route_id,
+ PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED);
+ ProcessEventLoop();
- EXPECT_CALL(observer,
- OnStateChanged(content::PRESENTATION_CONNECTION_STATE_CLOSED));
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(&callback));
+
+ // Right now we don't keep track of previous state so the callback will be
+ // invoked with the same state again.
+ EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED))
+ .Times(1);
media_router_proxy_->OnPresentationConnectionStateChanged(
route_id,
PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED);
ProcessEventLoop();
- EXPECT_CALL(observer, OnStateChanged(
- content::PRESENTATION_CONNECTION_STATE_TERMINATED));
+ // Callback has been removed, so we don't expect it to be called anymore.
+ subscription.reset();
+ EXPECT_TRUE(router()->presentation_connection_state_callbacks_.empty());
+
+ EXPECT_CALL(callback, Run(content::PRESENTATION_CONNECTION_STATE_CLOSED))
+ .Times(0);
media_router_proxy_->OnPresentationConnectionStateChanged(
route_id,
- PresentationConnectionState::PRESENTATION_CONNECTION_STATE_TERMINATED);
+ PresentationConnectionState::PRESENTATION_CONNECTION_STATE_CLOSED);
ProcessEventLoop();
}
« no previous file with comments | « chrome/browser/media/router/media_router_mojo_impl.cc ('k') | chrome/browser/media/router/mock_media_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698