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

Unified Diff: content/browser/presentation/presentation_service_impl_unittest.cc

Issue 2938023002: [PresentationService] Improve PresentationServiceImplTest. (Closed)
Patch Set: Rebase Created 3 years, 6 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
« no previous file with comments | « content/browser/presentation/presentation_service_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f6937ca51d6a4b8d587855f49b074753e734143f..fe47a552ce245027e240b8b9e39973b8f5d8fb9a 100644
--- a/content/browser/presentation/presentation_service_impl_unittest.cc
+++ b/content/browser/presentation/presentation_service_impl_unittest.cc
@@ -13,11 +13,8 @@
#include <utility>
#include <vector>
-#include "base/location.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
-#include "base/test/test_timeouts.h"
-#include "base/threading/thread_task_runner_handle.h"
+#include "base/test/mock_callback.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/presentation_service_delegate.h"
#include "content/public/common/presentation_connection_message.h"
@@ -29,19 +26,25 @@
#include "testing/gmock/include/gmock/gmock.h"
using ::testing::_;
-using ::testing::ByRef;
using ::testing::Eq;
-using ::testing::Invoke;
-using ::testing::InvokeWithoutArgs;
using ::testing::Mock;
using ::testing::Return;
using ::testing::SaveArg;
-using ::testing::WithArgs;
+using NewPresentationCallback =
+ content::PresentationServiceImpl::NewPresentationCallback;
namespace content {
namespace {
+MATCHER(OptionalIsNotNull, "") {
+ return !!arg;
+}
+
+MATCHER(OptionalIsNull, "") {
+ return !arg;
+}
+
// Matches content::PresentationInfo.
MATCHER_P(InfoEquals, expected, "") {
return expected.presentation_url == arg.presentation_url &&
@@ -247,13 +250,11 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
// when AppendChild is called.
NavigateAndCommit(GURL("about:blank"));
- auto request = mojo::MakeRequest(&service_ptr_);
EXPECT_CALL(mock_delegate_, AddObserver(_, _, _)).Times(1);
TestRenderFrameHost* render_frame_host = contents()->GetMainFrame();
render_frame_host->InitializeRenderFrameIfNeeded();
service_impl_.reset(new PresentationServiceImpl(
render_frame_host, contents(), &mock_delegate_, nullptr));
- service_impl_->Bind(std::move(request));
blink::mojom::PresentationServiceClientPtr client_ptr;
client_binding_.reset(
@@ -266,7 +267,6 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
}
void TearDown() override {
- service_ptr_.reset();
if (service_impl_.get()) {
EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1);
service_impl_.reset();
@@ -287,49 +287,25 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
void ListenForScreenAvailabilityAndWait(const GURL& url,
bool delegate_success) {
- base::RunLoop run_loop;
- // This will call to |service_impl_| via mojo. Process the message
- // using RunLoop.
- // The callback shouldn't be invoked since there is no availability
- // result yet.
EXPECT_CALL(mock_delegate_, AddScreenAvailabilityListener())
- .WillOnce(DoAll(
- InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- Return(delegate_success)));
- service_ptr_->ListenForScreenAvailability(url);
- run_loop.Run();
+ .WillOnce(Return(delegate_success));
+ service_impl_->ListenForScreenAvailability(url);
EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_delegate_));
}
- void RunLoopFor(base::TimeDelta duration) {
- base::RunLoop run_loop;
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, run_loop.QuitClosure(), duration);
- run_loop.Run();
- }
-
- void SaveQuitClosureAndRunLoop() {
- base::RunLoop run_loop;
- run_loop_quit_closure_ = run_loop.QuitClosure();
- run_loop.Run();
- run_loop_quit_closure_.Reset();
- }
-
void SimulateScreenAvailabilityChangeAndWait(const GURL& url,
bool available) {
auto listener_it = service_impl_->screen_availability_listeners_.find(url);
ASSERT_TRUE(listener_it->second);
- base::RunLoop run_loop;
blink::mojom::ScreenAvailability expected_availability =
available ? blink::mojom::ScreenAvailability::AVAILABLE
: blink::mojom::ScreenAvailability::UNAVAILABLE;
EXPECT_CALL(mock_client_,
- OnScreenAvailabilityUpdated(url, expected_availability))
- .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
+ OnScreenAvailabilityUpdated(url, expected_availability));
listener_it->second->OnScreenAvailabilityChanged(available);
- run_loop.Run();
+ base::RunLoop().RunUntilIdle();
}
void ExpectReset() {
@@ -343,44 +319,15 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
service_impl_->screen_availability_listeners_.end());
}
- void ExpectNewPresentationCallbackSuccess(
- const base::Optional<PresentationInfo>& info,
- const base::Optional<PresentationError>& error) {
- EXPECT_TRUE(info);
- EXPECT_FALSE(error);
- if (!run_loop_quit_closure_.is_null())
- run_loop_quit_closure_.Run();
- }
-
- void ExpectNewPresentationCallbackError(
- const base::Optional<PresentationInfo>& info,
- const base::Optional<PresentationError>& error) {
- EXPECT_FALSE(info);
- EXPECT_TRUE(error);
- if (!run_loop_quit_closure_.is_null())
- run_loop_quit_closure_.Run();
- }
-
- void ExpectConnectionMessages(
- const std::vector<PresentationConnectionMessage>& expected_msgs,
- const std::vector<PresentationConnectionMessage>& actual_msgs) {
- EXPECT_EQ(expected_msgs.size(), actual_msgs.size());
- for (size_t i = 0; i < actual_msgs.size(); ++i)
- EXPECT_EQ(expected_msgs[i], actual_msgs[i]);
- }
-
MockPresentationServiceDelegate mock_delegate_;
MockReceiverPresentationServiceDelegate mock_receiver_delegate_;
std::unique_ptr<PresentationServiceImpl> service_impl_;
- mojo::InterfacePtr<blink::mojom::PresentationService> service_ptr_;
MockPresentationServiceClient mock_client_;
std::unique_ptr<mojo::Binding<blink::mojom::PresentationServiceClient>>
client_binding_;
- base::Closure run_loop_quit_closure_;
-
GURL presentation_url1_;
GURL presentation_url2_;
GURL presentation_url3_;
@@ -395,6 +342,14 @@ TEST_F(PresentationServiceImplTest, ListenForScreenAvailability) {
SimulateScreenAvailabilityChangeAndWait(presentation_url1_, true);
}
+TEST_F(PresentationServiceImplTest, ScreenAvailabilityNotSupported) {
+ mock_delegate_.set_screen_availability_listening_supported(false);
+ EXPECT_CALL(mock_client_,
+ OnScreenAvailabilityNotSupported(presentation_url1_));
+ ListenForScreenAvailabilityAndWait(presentation_url1_, false);
+ base::RunLoop().RunUntilIdle();
+}
+
TEST_F(PresentationServiceImplTest, Reset) {
ListenForScreenAvailabilityAndWait(presentation_url1_, true);
@@ -429,14 +384,17 @@ TEST_F(PresentationServiceImplTest, ThisRenderFrameDeleted) {
// Since the frame matched the service, |service_impl_| will be deleted.
PresentationServiceImpl* service = service_impl_.release();
EXPECT_CALL(mock_delegate_, RemoveObserver(_, _)).Times(1);
- service->RenderFrameDeleted(contents()->GetMainFrame());
+ service->RenderFrameDeleted(main_rfh());
}
TEST_F(PresentationServiceImplTest, OtherRenderFrameDeleted) {
ListenForScreenAvailabilityAndWait(presentation_url1_, true);
- // TODO(imcheng): How to get a different RenderFrameHost?
- service_impl_->RenderFrameDeleted(nullptr);
+ // Create a new frame and RFH.
+ RenderFrameHost* rfh = main_rfh();
+ RenderFrameHostTester* rfh_tester = RenderFrameHostTester::For(rfh);
+ rfh = rfh_tester->AppendChild("subframe");
+ service_impl_->RenderFrameDeleted(rfh);
// Availability is reported and callback should be invoked since listener
// has not been deleted.
@@ -446,8 +404,8 @@ TEST_F(PresentationServiceImplTest, OtherRenderFrameDeleted) {
TEST_F(PresentationServiceImplTest, DelegateFails) {
ListenForScreenAvailabilityAndWait(presentation_url1_, false);
ASSERT_EQ(
- service_impl_->screen_availability_listeners_.find(presentation_url1_),
- service_impl_->screen_availability_listeners_.end());
+ service_impl_->screen_availability_listeners_.end(),
+ service_impl_->screen_availability_listeners_.find(presentation_url1_));
}
TEST_F(PresentationServiceImplTest, SetDefaultPresentationUrls) {
@@ -468,13 +426,11 @@ TEST_F(PresentationServiceImplTest, SetDefaultPresentationUrls) {
PresentationInfo presentation_info(presentation_url2_, kPresentationId);
- base::RunLoop run_loop;
EXPECT_CALL(mock_client_,
- OnDefaultPresentationStarted(InfoEquals(presentation_info)))
- .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
+ OnDefaultPresentationStarted(InfoEquals(presentation_info)));
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _));
callback.Run(PresentationInfo(presentation_url2_, kPresentationId));
- run_loop.Run();
+ base::RunLoop().RunUntilIdle();
}
TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
@@ -487,16 +443,12 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
.WillOnce(SaveArg<3>(&state_changed_cb));
service_impl_->ListenForConnectionStateChange(connection);
- {
- base::RunLoop run_loop;
- EXPECT_CALL(mock_client_, OnConnectionStateChanged(
- InfoEquals(presentation_connection),
- PRESENTATION_CONNECTION_STATE_TERMINATED))
- .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
- state_changed_cb.Run(PresentationConnectionStateChangeInfo(
- PRESENTATION_CONNECTION_STATE_TERMINATED));
- run_loop.Run();
- }
+ EXPECT_CALL(mock_client_, OnConnectionStateChanged(
+ InfoEquals(presentation_connection),
+ PRESENTATION_CONNECTION_STATE_TERMINATED));
+ state_changed_cb.Run(PresentationConnectionStateChangeInfo(
+ PRESENTATION_CONNECTION_STATE_TERMINATED));
+ base::RunLoop().RunUntilIdle();
}
TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
@@ -509,21 +461,17 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
// Trigger connection close. It should be propagated back up to
// |mock_client_|.
PresentationInfo presentation_connection(presentation_url1_, kPresentationId);
- {
- base::RunLoop run_loop;
- PresentationConnectionStateChangeInfo closed_info(
- PRESENTATION_CONNECTION_STATE_CLOSED);
- closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY;
- closed_info.message = "Foo";
+ PresentationConnectionStateChangeInfo closed_info(
+ PRESENTATION_CONNECTION_STATE_CLOSED);
+ closed_info.close_reason = PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY;
+ closed_info.message = "Foo";
- EXPECT_CALL(mock_client_,
- OnConnectionClosed(
- InfoEquals(presentation_connection),
- PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY, "Foo"))
- .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
- state_changed_cb.Run(closed_info);
- run_loop.Run();
- }
+ EXPECT_CALL(mock_client_,
+ OnConnectionClosed(InfoEquals(presentation_connection),
+ PRESENTATION_CONNECTION_CLOSE_REASON_WENT_AWAY,
+ "Foo"));
+ state_changed_cb.Run(closed_info);
+ base::RunLoop().RunUntilIdle();
}
TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrls) {
@@ -539,92 +487,107 @@ TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrls) {
}
TEST_F(PresentationServiceImplTest, StartPresentationSuccess) {
- service_ptr_->StartPresentation(
- presentation_urls_,
- base::Bind(
- &PresentationServiceImplTest::ExpectNewPresentationCallbackSuccess,
- base::Unretained(this)));
- base::RunLoop run_loop;
+ base::MockCallback<NewPresentationCallback> mock_presentation_cb;
base::Callback<void(const PresentationInfo&)> success_cb;
EXPECT_CALL(mock_delegate_, StartPresentation(_, _, presentation_urls_, _, _))
- .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<3>(&success_cb)));
- run_loop.Run();
-
+ .WillOnce(SaveArg<3>(&success_cb));
+ service_impl_->StartPresentation(presentation_urls_,
+ mock_presentation_cb.Get());
+ EXPECT_FALSE(success_cb.is_null());
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
.Times(1);
+ EXPECT_CALL(mock_presentation_cb, Run(OptionalIsNotNull(), OptionalIsNull()));
success_cb.Run(PresentationInfo(presentation_url1_, kPresentationId));
- SaveQuitClosureAndRunLoop();
}
TEST_F(PresentationServiceImplTest, StartPresentationError) {
- service_ptr_->StartPresentation(
- presentation_urls_,
- base::Bind(
- &PresentationServiceImplTest::ExpectNewPresentationCallbackError,
- base::Unretained(this)));
- base::RunLoop run_loop;
+ base::MockCallback<NewPresentationCallback> mock_presentation_cb;
base::Callback<void(const PresentationError&)> error_cb;
EXPECT_CALL(mock_delegate_, StartPresentation(_, _, presentation_urls_, _, _))
- .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<4>(&error_cb)));
- run_loop.Run();
+ .WillOnce(SaveArg<4>(&error_cb));
+ service_impl_->StartPresentation(presentation_urls_,
+ mock_presentation_cb.Get());
+ EXPECT_FALSE(error_cb.is_null());
+ EXPECT_CALL(mock_presentation_cb, Run(OptionalIsNull(), OptionalIsNotNull()));
error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
- SaveQuitClosureAndRunLoop();
+}
+
+TEST_F(PresentationServiceImplTest, StartPresentationInProgress) {
+ EXPECT_CALL(mock_delegate_, StartPresentation(_, _, presentation_urls_, _, _))
+ .Times(1);
+ // Uninvoked callbacks must outlive |service_impl_| since they get invoked
+ // at |service_impl_|'s destruction.
+ service_impl_->StartPresentation(presentation_urls_, base::Bind(&DoNothing));
+
+ // This request should fail immediately, since there is already a
+ // StartPresentation in progress.
+ base::MockCallback<NewPresentationCallback> mock_presentation_cb;
+ EXPECT_CALL(mock_presentation_cb, Run(OptionalIsNull(), OptionalIsNotNull()));
+ service_impl_->StartPresentation(presentation_urls_,
+ mock_presentation_cb.Get());
}
TEST_F(PresentationServiceImplTest, ReconnectPresentationSuccess) {
- service_ptr_->ReconnectPresentation(
- presentation_urls_, base::Optional<std::string>(kPresentationId),
- base::Bind(
- &PresentationServiceImplTest::ExpectNewPresentationCallbackSuccess,
- base::Unretained(this)));
- base::RunLoop run_loop;
+ base::MockCallback<NewPresentationCallback> mock_presentation_cb;
base::Callback<void(const PresentationInfo&)> success_cb;
EXPECT_CALL(mock_delegate_, ReconnectPresentation(_, _, presentation_urls_,
kPresentationId, _, _))
- .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<4>(&success_cb)));
- run_loop.Run();
-
+ .WillOnce(SaveArg<4>(&success_cb));
+ service_impl_->ReconnectPresentation(
+ presentation_urls_, base::Optional<std::string>(kPresentationId),
+ mock_presentation_cb.Get());
+ EXPECT_FALSE(success_cb.is_null());
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
.Times(1);
+ EXPECT_CALL(mock_presentation_cb, Run(OptionalIsNotNull(), OptionalIsNull()));
success_cb.Run(PresentationInfo(presentation_url1_, kPresentationId));
- SaveQuitClosureAndRunLoop();
}
TEST_F(PresentationServiceImplTest, ReconnectPresentationError) {
- service_ptr_->ReconnectPresentation(
- presentation_urls_, base::Optional<std::string>(kPresentationId),
- base::Bind(
- &PresentationServiceImplTest::ExpectNewPresentationCallbackError,
- base::Unretained(this)));
- base::RunLoop run_loop;
+ base::MockCallback<NewPresentationCallback> mock_presentation_cb;
base::Callback<void(const PresentationError&)> error_cb;
EXPECT_CALL(mock_delegate_, ReconnectPresentation(_, _, presentation_urls_,
kPresentationId, _, _))
- .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<5>(&error_cb)));
- run_loop.Run();
+ .WillOnce(SaveArg<5>(&error_cb));
+ service_impl_->ReconnectPresentation(
+ presentation_urls_, base::Optional<std::string>(kPresentationId),
+ mock_presentation_cb.Get());
+ EXPECT_FALSE(error_cb.is_null());
+ EXPECT_CALL(mock_presentation_cb, Run(OptionalIsNull(), OptionalIsNotNull()));
error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
- SaveQuitClosureAndRunLoop();
}
-TEST_F(PresentationServiceImplTest, CloseConnection) {
- service_ptr_->CloseConnection(presentation_url1_, kPresentationId);
+TEST_F(PresentationServiceImplTest, MaxPendingReconnectPresentationRequests) {
+ const char* presentation_url = "http://fooUrl%d";
+ const char* presentation_id = "presentationId%d";
+ int num_requests = PresentationServiceImpl::kMaxQueuedRequests;
+ int i = 0;
+ EXPECT_CALL(mock_delegate_, ReconnectPresentation(_, _, _, _, _, _))
+ .Times(num_requests);
+ for (; i < num_requests; ++i) {
+ std::vector<GURL> urls = {GURL(base::StringPrintf(presentation_url, i))};
+ // Uninvoked callbacks must outlive |service_impl_| since they get invoked
+ // at |service_impl_|'s destruction.
+ service_impl_->ReconnectPresentation(
+ urls, base::StringPrintf(presentation_id, i), base::Bind(&DoNothing));
+ }
+
+ std::vector<GURL> urls = {GURL(base::StringPrintf(presentation_url, i))};
+ // Exceeded maximum queue size, should invoke mojo callback with error.
+ base::MockCallback<NewPresentationCallback> mock_presentation_cb;
+ EXPECT_CALL(mock_presentation_cb, Run(OptionalIsNull(), OptionalIsNotNull()));
+ service_impl_->ReconnectPresentation(
+ urls, base::StringPrintf(presentation_id, i), mock_presentation_cb.Get());
+}
- base::RunLoop run_loop;
- EXPECT_CALL(mock_delegate_, CloseConnection(_, _, Eq(kPresentationId)))
- .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
- run_loop.Run();
+TEST_F(PresentationServiceImplTest, CloseConnection) {
+ EXPECT_CALL(mock_delegate_, CloseConnection(_, _, Eq(kPresentationId)));
+ service_impl_->CloseConnection(presentation_url1_, kPresentationId);
}
TEST_F(PresentationServiceImplTest, Terminate) {
- service_ptr_->Terminate(presentation_url1_, kPresentationId);
- base::RunLoop run_loop;
- EXPECT_CALL(mock_delegate_, Terminate(_, _, Eq(kPresentationId)))
- .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
- run_loop.Run();
+ EXPECT_CALL(mock_delegate_, Terminate(_, _, Eq(kPresentationId)));
+ service_impl_->Terminate(presentation_url1_, kPresentationId);
}
TEST_F(PresentationServiceImplTest, SetPresentationConnection) {
@@ -647,9 +610,10 @@ TEST_F(PresentationServiceImplTest, SetPresentationConnection) {
TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) {
MockReceiverPresentationServiceDelegate mock_receiver_delegate;
+ EXPECT_CALL(mock_receiver_delegate, AddObserver(_, _, _)).Times(1);
- PresentationServiceImpl service_impl(contents()->GetMainFrame(), contents(),
- nullptr, &mock_receiver_delegate);
+ PresentationServiceImpl service_impl(main_rfh(), contents(), nullptr,
+ &mock_receiver_delegate);
ReceiverConnectionAvailableCallback callback;
EXPECT_CALL(mock_receiver_delegate,
@@ -665,58 +629,23 @@ TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) {
EXPECT_FALSE(callback.is_null());
// NO-OP for ControllerPresentationServiceDelegate API functions
- EXPECT_CALL(mock_delegate_, ListenForConnectionMessages(_, _, _, _)).Times(0);
-
PresentationInfo presentation_info(presentation_url1_, kPresentationId);
+ EXPECT_CALL(mock_delegate_, ListenForConnectionMessages(_, _, _, _)).Times(0);
service_impl.ListenForConnectionMessages(presentation_info);
-}
-
-TEST_F(PresentationServiceImplTest, StartPresentationInProgress) {
- EXPECT_CALL(mock_delegate_, StartPresentation(_, _, presentation_urls_, _, _))
- .Times(1);
- service_ptr_->StartPresentation(presentation_urls_, base::Bind(&DoNothing));
- // This request should fail immediately, since there is already a
- // StartPresentation in progress.
- service_ptr_->StartPresentation(
- presentation_urls_,
- base::Bind(
- &PresentationServiceImplTest::ExpectNewPresentationCallbackError,
- base::Unretained(this)));
- SaveQuitClosureAndRunLoop();
-}
-
-TEST_F(PresentationServiceImplTest, MaxPendingReconnectPresentationRequests) {
- const char* presentation_url = "http://fooUrl%d";
- const char* presentation_id = "presentationId%d";
- int num_requests = PresentationServiceImpl::kMaxQueuedRequests;
- int i = 0;
- EXPECT_CALL(mock_delegate_, ReconnectPresentation(_, _, _, _, _, _))
- .Times(num_requests);
- for (; i < num_requests; ++i) {
- std::vector<GURL> urls = {GURL(base::StringPrintf(presentation_url, i))};
- service_ptr_->ReconnectPresentation(
- urls, base::StringPrintf(presentation_id, i), base::Bind(&DoNothing));
- }
-
- std::vector<GURL> urls = {GURL(base::StringPrintf(presentation_url, i))};
- // Exceeded maximum queue size, should invoke mojo callback with error.
- service_ptr_->ReconnectPresentation(
- urls, base::StringPrintf(presentation_id, i),
- base::Bind(
- &PresentationServiceImplTest::ExpectNewPresentationCallbackError,
- base::Unretained(this)));
- SaveQuitClosureAndRunLoop();
-}
-
-TEST_F(PresentationServiceImplTest, ScreenAvailabilityNotSupported) {
- mock_delegate_.set_screen_availability_listening_supported(false);
- base::RunLoop run_loop;
+ // Client gets notified of receiver connections.
+ blink::mojom::PresentationConnectionPtr controller_connection;
+ MockPresentationConnection mock_presentation_connection;
+ mojo::Binding<blink::mojom::PresentationConnection> connection_binding(
+ &mock_presentation_connection, mojo::MakeRequest(&controller_connection));
+ blink::mojom::PresentationConnectionPtr receiver_connection;
EXPECT_CALL(mock_client_,
- OnScreenAvailabilityNotSupported(presentation_url1_))
- .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
- ListenForScreenAvailabilityAndWait(presentation_url1_, false);
- run_loop.Run();
+ OnReceiverConnectionAvailable(InfoEquals(presentation_info)));
+ callback.Run(presentation_info, std::move(controller_connection),
+ mojo::MakeRequest(&receiver_connection));
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_CALL(mock_receiver_delegate, RemoveObserver(_, _)).Times(1);
}
} // namespace content
« no previous file with comments | « content/browser/presentation/presentation_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698