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 bb7b38f4478cfdd1990109a363f3df60f7ff05b3..7ec9af1c37b6287d96e51430114dc2fb87a16c10 100644 |
| --- a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc |
| +++ b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc |
| @@ -123,6 +123,13 @@ class ListenForMessagesCallbackHandler { |
| bool pass_ownership_; |
| }; |
| +class PresentationConnectionStateChangeHandler { |
|
mark a. foltz
2015/11/12 04:19:38
How about PresentatonConnectionStateChangeCallback
imcheng
2015/11/16 23:52:01
Done.
|
| + public: |
| + MOCK_METHOD2(Invoke, |
| + void(const content::PresentationSessionInfo&, |
| + content::PresentationConnectionState)); |
| +}; |
| + |
| template <typename T> |
| void StoreAndRun(T* result, const base::Closure& closure, const T& result_val) { |
| *result = result_val; |
| @@ -738,17 +745,26 @@ TEST_F(MediaRouterMojoImplTest, PresentationConnectionStateObserver) { |
| interfaces::MediaRouter::PresentationConnectionState; |
| MediaRoute::Id route_id("route-id"); |
| - MockPresentationConnectionStateObserver observer(router(), route_id); |
| - |
| - EXPECT_CALL(observer, |
| - OnStateChanged(content::PRESENTATION_CONNECTION_STATE_CLOSED)); |
| + const std::string kPresentationUrl("http://foo.fakeUrl"); |
| + const std::string kPresentationId("pid"); |
| + content::PresentationSessionInfo connection(kPresentationUrl, |
| + kPresentationId); |
| + PresentationConnectionStateChangeHandler handler; |
| + PresentationConnectionStateObserver observer( |
| + base::Bind(&PresentationConnectionStateChangeHandler::Invoke, |
| + base::Unretained(&handler)), |
| + connection, route_id, router()); |
| + |
| + EXPECT_CALL(handler, Invoke(_, 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)); |
| + EXPECT_CALL(handler, |
| + Invoke(_, content::PRESENTATION_CONNECTION_STATE_TERMINATED)) |
| + .Times(1); |
| media_router_proxy_->OnPresentationConnectionStateChanged( |
| route_id, |
| PresentationConnectionState::PRESENTATION_CONNECTION_STATE_TERMINATED); |