| Index: content/browser/presentation/presentation_service_impl_unittest.cc
|
| diff --git a/content/browser/presentation/presentation_service_impl_unittest.cc b/content/browser/presentation/presentation_service_impl_unittest.cc
|
| index 87c66b364090a273d0731c7031209748b8418a60..1f7f758405395f55c0f519d7aeba2e52f4302d3e 100644
|
| --- a/content/browser/presentation/presentation_service_impl_unittest.cc
|
| +++ b/content/browser/presentation/presentation_service_impl_unittest.cc
|
| @@ -23,23 +23,12 @@
|
|
|
| namespace content {
|
|
|
| -namespace {
|
| -
|
| -bool ArePresentationSessionsEqual(
|
| - const presentation::PresentationSessionInfo& expected,
|
| - const presentation::PresentationSessionInfo& actual) {
|
| - return expected.url == actual.url && expected.id == actual.id;
|
| -}
|
| -} // namespace
|
| -
|
| class MockPresentationServiceDelegate : public PresentationServiceDelegate {
|
| public:
|
| - MOCK_METHOD3(AddObserver,
|
| - void(int render_process_id,
|
| - int render_frame_id,
|
| - PresentationServiceDelegate::Observer* observer));
|
| - MOCK_METHOD2(RemoveObserver,
|
| - void(int render_process_id, int render_frame_id));
|
| + MOCK_METHOD1(AddObserver,
|
| + void(PresentationServiceDelegate::Observer* observer));
|
| + MOCK_METHOD1(RemoveObserver,
|
| + void(PresentationServiceDelegate::Observer* observer));
|
| MOCK_METHOD3(AddScreenAvailabilityListener,
|
| bool(
|
| int render_process_id,
|
| @@ -80,15 +69,13 @@
|
|
|
| class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
|
| public:
|
| - PresentationServiceImplTest()
|
| - : callback_count_(0), default_session_started_count_(0) {}
|
| + PresentationServiceImplTest() : callback_count_(0) {}
|
|
|
| void SetUp() override {
|
| RenderViewHostImplTestHarness::SetUp();
|
|
|
| auto request = mojo::GetProxy(&service_ptr_);
|
| -
|
| - EXPECT_CALL(mock_delegate_, AddObserver(_, _, _)).Times(1);
|
| + EXPECT_CALL(mock_delegate_, AddObserver(_)).Times(1);
|
| service_impl_.reset(new PresentationServiceImpl(
|
| contents()->GetMainFrame(), contents(), &mock_delegate_));
|
| service_impl_->Bind(request.Pass());
|
| @@ -97,9 +84,11 @@
|
| void TearDown() override {
|
| service_ptr_.reset();
|
| if (service_impl_.get()) {
|
| - EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1);
|
| + EXPECT_CALL(mock_delegate_, RemoveObserver(Eq(service_impl_.get())))
|
| + .Times(1);
|
| service_impl_.reset();
|
| }
|
| +
|
| RenderViewHostImplTestHarness::TearDown();
|
| }
|
|
|
| @@ -166,7 +155,8 @@
|
| }
|
|
|
| void ExpectReset() {
|
| - EXPECT_CALL(mock_delegate_, Reset(_, _)).Times(1);
|
| + EXPECT_CALL(mock_delegate_, Reset(_, _))
|
| + .Times(1);
|
| }
|
|
|
| void ExpectCleanState() {
|
| @@ -174,7 +164,6 @@
|
| EXPECT_TRUE(service_impl_->default_presentation_url_.empty());
|
| EXPECT_TRUE(service_impl_->default_presentation_id_.empty());
|
| EXPECT_TRUE(service_impl_->queued_start_session_requests_.empty());
|
| - EXPECT_FALSE(service_impl_->default_session_start_context_.get());
|
| }
|
|
|
| void ExpectNewSessionMojoCallbackSuccess(
|
| @@ -195,31 +184,11 @@
|
| run_loop_quit_closure_.Run();
|
| }
|
|
|
| - void ExpectDefaultSessionStarted(
|
| - const presentation::PresentationSessionInfo& expected_session,
|
| - presentation::PresentationSessionInfoPtr actual_session) {
|
| - ASSERT_TRUE(!actual_session.is_null());
|
| - EXPECT_TRUE(ArePresentationSessionsEqual(
|
| - expected_session, *actual_session));
|
| - ++default_session_started_count_;
|
| - if (!run_loop_quit_closure_.is_null())
|
| - run_loop_quit_closure_.Run();
|
| - }
|
| -
|
| - void ExpectDefaultSessionNull(
|
| - presentation::PresentationSessionInfoPtr actual_session) {
|
| - EXPECT_TRUE(actual_session.is_null());
|
| - ++default_session_started_count_;
|
| - if (!run_loop_quit_closure_.is_null())
|
| - run_loop_quit_closure_.Run();
|
| - }
|
| -
|
| MockPresentationServiceDelegate mock_delegate_;
|
| scoped_ptr<PresentationServiceImpl> service_impl_;
|
| mojo::InterfacePtr<presentation::PresentationService> service_ptr_;
|
| base::Closure run_loop_quit_closure_;
|
| int callback_count_;
|
| - int default_session_started_count_;
|
| };
|
|
|
| TEST_F(PresentationServiceImplTest, ListenForScreenAvailability) {
|
| @@ -325,7 +294,7 @@
|
|
|
| // Since the frame matched the service, |service_impl_| will be deleted.
|
| PresentationServiceImpl* service = service_impl_.release();
|
| - EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1);
|
| + EXPECT_CALL(mock_delegate_, RemoveObserver(Eq(service))).Times(1);
|
| service->RenderFrameDeleted(contents()->GetMainFrame());
|
| }
|
|
|
| @@ -612,59 +581,4 @@
|
| SaveQuitClosureAndRunLoop();
|
| }
|
|
|
| -TEST_F(PresentationServiceImplTest, ListenForDefaultSessionStart) {
|
| - std::string presentation_url1("http://fooUrl1");
|
| - std::string presentation_id1("presentationId1");
|
| - presentation::PresentationSessionInfo expected_session;
|
| - expected_session.url = presentation_url1;
|
| - expected_session.id = presentation_id1;
|
| - service_ptr_->ListenForDefaultSessionStart(
|
| - base::Bind(&PresentationServiceImplTest::ExpectDefaultSessionStarted,
|
| - base::Unretained(this),
|
| - expected_session));
|
| - RunLoopFor(base::TimeDelta::FromMilliseconds(50));
|
| - service_impl_->OnDefaultPresentationStarted(
|
| - content::PresentationSessionInfo(presentation_url1, presentation_id1));
|
| - SaveQuitClosureAndRunLoop();
|
| - EXPECT_EQ(1, default_session_started_count_);
|
| -}
|
| -
|
| -TEST_F(PresentationServiceImplTest, ListenForDefaultSessionStartAfterSet) {
|
| - // Note that the callback will only pick up presentation_url2/id2 since
|
| - // ListenForDefaultSessionStart wasn't called yet when the DPU was still
|
| - // presentation_url1.
|
| - std::string presentation_url1("http://fooUrl1");
|
| - std::string presentation_id1("presentationId1");
|
| - std::string presentation_url2("http://fooUrl2");
|
| - std::string presentation_id2("presentationId2");
|
| - service_impl_->OnDefaultPresentationStarted(
|
| - content::PresentationSessionInfo(presentation_url1, presentation_id1));
|
| -
|
| - presentation::PresentationSessionInfo expected_session;
|
| - expected_session.url = presentation_url2;
|
| - expected_session.id = presentation_id2;
|
| - service_ptr_->ListenForDefaultSessionStart(
|
| - base::Bind(&PresentationServiceImplTest::ExpectDefaultSessionStarted,
|
| - base::Unretained(this),
|
| - expected_session));
|
| - RunLoopFor(base::TimeDelta::FromMilliseconds(50));
|
| - service_impl_->OnDefaultPresentationStarted(
|
| - content::PresentationSessionInfo(presentation_url2, presentation_id2));
|
| - SaveQuitClosureAndRunLoop();
|
| - EXPECT_EQ(1, default_session_started_count_);
|
| -}
|
| -
|
| -TEST_F(PresentationServiceImplTest, DefaultSessionStartReset) {
|
| - service_ptr_->ListenForDefaultSessionStart(
|
| - base::Bind(&PresentationServiceImplTest::ExpectDefaultSessionNull,
|
| - base::Unretained(this)));
|
| - base::RunLoop().RunUntilIdle();
|
| -
|
| - ExpectReset();
|
| - service_impl_->Reset();
|
| - ExpectCleanState();
|
| - SaveQuitClosureAndRunLoop();
|
| - EXPECT_EQ(1, default_session_started_count_);
|
| -}
|
| -
|
| } // namespace content
|
|
|