Chromium Code Reviews| 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..3e07c0c9b730943876412a631d1a920e68f1fd30 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,47 @@ 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_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(); |
|
mark a. foltz
2015/11/18 00:39:38
Is there test coverage for the removal callback?
imcheng
2015/11/19 23:39:53
Added assertion that the CallbackList entry is rem
|
| } |