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

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

Issue 2174693004: [Presentation API] Add support to content/ for multiple URLs per PresentationRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update service, dispatcher to use Mojo URLs. Created 4 years, 4 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
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 0b560f4fff816edbfc82ef70a59d4769b97bdf39..9ca28d920dcfd602edab8ddc163b5f7048d5a40e 100644
--- a/content/browser/presentation/presentation_service_impl_unittest.cc
+++ b/content/browser/presentation/presentation_service_impl_unittest.cc
@@ -28,6 +28,7 @@
#include "testing/gmock/include/gmock/gmock.h"
using ::testing::_;
+using ::testing::ByRef;
using ::testing::Eq;
using ::testing::InvokeWithoutArgs;
using ::testing::Mock;
@@ -38,13 +39,20 @@ namespace content {
namespace {
-// Matches mojo structs.
+// Matches Mojo structs.
MATCHER_P(Equals, expected, "") {
return expected.Equals(arg);
}
+// Matches PresentationSessionInfo passed by reference.
+MATCHER_P(SessionInfoEquals, expected, "") {
+ blink::mojom::PresentationSessionInfo& expected_value = expected;
+ return expected_value.Equals(arg);
+}
+
const char *const kPresentationId = "presentationId";
-const char *const kPresentationUrl = "http://foo.com/index.html";
+const char* const kPresentationUrl1 = "http://foo.com/index.html";
+const char* const kPresentationUrl2 = "http://example.com/index.html";
void DoNothing(blink::mojom::PresentationSessionInfoPtr info,
blink::mojom::PresentationErrorPtr error) {}
@@ -80,21 +88,21 @@ class MockPresentationServiceDelegate : public PresentationServiceDelegate {
void(
int render_process_id,
int routing_id));
- MOCK_METHOD4(SetDefaultPresentationUrl,
+ MOCK_METHOD4(SetDefaultPresentationUrls,
void(int render_process_id,
int routing_id,
- const std::string& default_presentation_url,
+ const std::vector<std::string>& default_presentation_urls,
const PresentationSessionStartedCallback& callback));
MOCK_METHOD5(StartSession,
void(int render_process_id,
int render_frame_id,
- const std::string& presentation_url,
+ const std::vector<std::string>& presentation_urls,
const PresentationSessionStartedCallback& success_cb,
const PresentationSessionErrorCallback& error_cb));
MOCK_METHOD6(JoinSession,
void(int render_process_id,
int render_frame_id,
- const std::string& presentation_url,
+ const std::vector<std::string>& presentation_urls,
const std::string& presentation_id,
const PresentationSessionStartedCallback& success_cb,
const PresentationSessionErrorCallback& error_cb));
@@ -143,8 +151,11 @@ class MockPresentationServiceDelegate : public PresentationServiceDelegate {
class MockPresentationServiceClient
: public blink::mojom::PresentationServiceClient {
public:
+ void OnScreenAvailabilityUpdated(url::mojom::UrlPtr url, bool available) {
+ OnScreenAvailabilityUpdated(*url, available);
+ }
MOCK_METHOD2(OnScreenAvailabilityUpdated,
- void(const std::string& url, bool available));
+ void(const url::mojom::Url& url, bool available));
void OnConnectionStateChanged(
blink::mojom::PresentationSessionInfoPtr connection,
blink::mojom::PresentationConnectionState new_state) override {
@@ -165,7 +176,11 @@ class MockPresentationServiceClient
blink::mojom::PresentationConnectionCloseReason reason,
const std::string& message));
- MOCK_METHOD1(OnScreenAvailabilityNotSupported, void(const std::string& url));
+ void OnScreenAvailabilityNotSupported(url::mojom::UrlPtr url) {
+ OnScreenAvailabilityNotSupported(*url);
+ }
+ MOCK_METHOD1(OnScreenAvailabilityNotSupported,
+ void(const url::mojom::Url& url));
void OnSessionMessagesReceived(
blink::mojom::PresentationSessionInfoPtr session_info,
@@ -227,7 +242,9 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
.WillOnce(DoAll(
InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
Return(delegate_success)));
- service_ptr_->ListenForScreenAvailability(url);
+ url::mojom::UrlPtr mojo_url = url::mojom::Url::New();
+ mojo_url->url = url;
+ service_ptr_->ListenForScreenAvailability(std::move(mojo_url));
run_loop.Run();
EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_delegate_));
@@ -253,7 +270,10 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
ASSERT_TRUE(listener_it->second);
base::RunLoop run_loop;
- EXPECT_CALL(mock_client_, OnScreenAvailabilityUpdated(url, available))
+ url::mojom::Url mojo_url;
+ mojo_url.url = url;
+ EXPECT_CALL(mock_client_,
+ OnScreenAvailabilityUpdated(Equals(mojo_url), available))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
listener_it->second->OnScreenAvailabilityChanged(available);
run_loop.Run();
@@ -264,9 +284,9 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
}
void ExpectCleanState() {
- EXPECT_TRUE(service_impl_->default_presentation_url_.empty());
+ EXPECT_TRUE(service_impl_->default_presentation_urls_.empty());
EXPECT_EQ(
- service_impl_->screen_availability_listeners_.find(kPresentationUrl),
+ service_impl_->screen_availability_listeners_.find(kPresentationUrl1),
service_impl_->screen_availability_listeners_.end());
EXPECT_FALSE(service_impl_->on_session_messages_callback_.get());
}
@@ -318,7 +338,8 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
blink::mojom::PresentationSessionInfoPtr session(
blink::mojom::PresentationSessionInfo::New());
- session->url = kPresentationUrl;
+ session->url = url::mojom::Url::New();
+ session->url->url = kPresentationUrl1;
session->id = kPresentationId;
PresentationSessionMessageCallback message_cb;
@@ -327,7 +348,7 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
EXPECT_CALL(mock_delegate_, ListenForSessionMessages(_, _, _, _))
.WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
SaveArg<3>(&message_cb)));
- service_ptr_->ListenForSessionMessages(session.Clone());
+ service_ptr_->ListenForSessionMessages(std::move(session));
run_loop.Run();
}
@@ -353,6 +374,18 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
ExpectSessionMessages(expected_msgs, mock_client_.messages_received_);
}
+ std::vector<url::mojom::UrlPtr> ToMojoUrls(
+ const std::vector<std::string>& urls) {
+ std::vector<url::mojom::UrlPtr> mojo_urls(urls.size());
+ std::transform(urls.begin(), urls.end(), mojo_urls.begin(),
+ [](const std::string& url) {
+ url::mojom::UrlPtr mojo_url = url::mojom::Url::New();
+ mojo_url->url = url;
+ return mojo_url;
+ });
+ return mojo_urls;
+ }
+
MockPresentationServiceDelegate mock_delegate_;
std::unique_ptr<PresentationServiceImpl> service_impl_;
@@ -366,15 +399,15 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
};
TEST_F(PresentationServiceImplTest, ListenForScreenAvailability) {
- ListenForScreenAvailabilityAndWait(kPresentationUrl, true);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, true);
- SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true);
- SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, false);
- SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true);
+ SimulateScreenAvailabilityChangeAndWait(kPresentationUrl1, true);
+ SimulateScreenAvailabilityChangeAndWait(kPresentationUrl1, false);
+ SimulateScreenAvailabilityChangeAndWait(kPresentationUrl1, true);
}
TEST_F(PresentationServiceImplTest, Reset) {
- ListenForScreenAvailabilityAndWait(kPresentationUrl, true);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, true);
ExpectReset();
service_impl_->Reset();
@@ -382,7 +415,7 @@ TEST_F(PresentationServiceImplTest, Reset) {
}
TEST_F(PresentationServiceImplTest, DidNavigateThisFrame) {
- ListenForScreenAvailabilityAndWait(kPresentationUrl, true);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, true);
ExpectReset();
service_impl_->DidNavigateAnyFrame(
@@ -393,7 +426,7 @@ TEST_F(PresentationServiceImplTest, DidNavigateThisFrame) {
}
TEST_F(PresentationServiceImplTest, DidNavigateOtherFrame) {
- ListenForScreenAvailabilityAndWait(kPresentationUrl, true);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, true);
// TODO(imcheng): How to get a different RenderFrameHost?
service_impl_->DidNavigateAnyFrame(
@@ -403,11 +436,11 @@ TEST_F(PresentationServiceImplTest, DidNavigateOtherFrame) {
// Availability is reported and callback is invoked since it was not
// removed.
- SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true);
+ SimulateScreenAvailabilityChangeAndWait(kPresentationUrl1, true);
}
TEST_F(PresentationServiceImplTest, ThisRenderFrameDeleted) {
- ListenForScreenAvailabilityAndWait(kPresentationUrl, true);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, true);
ExpectReset();
@@ -418,50 +451,59 @@ TEST_F(PresentationServiceImplTest, ThisRenderFrameDeleted) {
}
TEST_F(PresentationServiceImplTest, OtherRenderFrameDeleted) {
- ListenForScreenAvailabilityAndWait(kPresentationUrl, true);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, true);
// TODO(imcheng): How to get a different RenderFrameHost?
service_impl_->RenderFrameDeleted(nullptr);
// Availability is reported and callback should be invoked since listener
// has not been deleted.
- SimulateScreenAvailabilityChangeAndWait(kPresentationUrl, true);
+ SimulateScreenAvailabilityChangeAndWait(kPresentationUrl1, true);
}
TEST_F(PresentationServiceImplTest, DelegateFails) {
- ListenForScreenAvailabilityAndWait(kPresentationUrl, false);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, false);
ASSERT_EQ(
- service_impl_->screen_availability_listeners_.find(kPresentationUrl),
+ service_impl_->screen_availability_listeners_.find(kPresentationUrl1),
service_impl_->screen_availability_listeners_.end());
}
-TEST_F(PresentationServiceImplTest, SetDefaultPresentationUrl) {
- std::string url1("http://fooUrl");
- EXPECT_CALL(mock_delegate_, SetDefaultPresentationUrl(_, _, Eq(url1), _))
+TEST_F(PresentationServiceImplTest, SetDefaultPresentationUrls) {
+ std::vector<std::string> urls(2);
+ urls[0] = kPresentationUrl1;
+ urls[1] = kPresentationUrl2;
+ EXPECT_CALL(mock_delegate_, SetDefaultPresentationUrls(_, _, urls, _))
.Times(1);
- service_impl_->SetDefaultPresentationURL(url1);
- EXPECT_EQ(url1, service_impl_->default_presentation_url_);
- std::string url2("http://barUrl");
- // Sets different DPU.
+ service_impl_->SetDefaultPresentationUrls(ToMojoUrls(urls));
+
+ std::string url3("http://barUrl");
+ // Sets different DPUs.
+ std::vector<std::string> more_urls(3);
+ more_urls[0] = kPresentationUrl1;
+ more_urls[1] = kPresentationUrl2;
+ more_urls[2] = url3;
+
content::PresentationSessionStartedCallback callback;
- EXPECT_CALL(mock_delegate_, SetDefaultPresentationUrl(_, _, Eq(url2), _))
+ EXPECT_CALL(mock_delegate_, SetDefaultPresentationUrls(_, _, more_urls, _))
.WillOnce(SaveArg<3>(&callback));
- service_impl_->SetDefaultPresentationURL(url2);
- EXPECT_EQ(url2, service_impl_->default_presentation_url_);
+ service_impl_->SetDefaultPresentationUrls(ToMojoUrls(more_urls));
blink::mojom::PresentationSessionInfo session_info;
- session_info.url = url2;
+ session_info.url = url::mojom::Url::New();
+ session_info.url->url = kPresentationUrl2;
session_info.id = kPresentationId;
base::RunLoop run_loop;
- EXPECT_CALL(mock_client_, OnDefaultSessionStarted(Equals(session_info)))
+ EXPECT_CALL(mock_client_,
+ OnDefaultSessionStarted(SessionInfoEquals(ByRef(session_info))))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
- callback.Run(content::PresentationSessionInfo(url2, kPresentationId));
+ callback.Run(
+ content::PresentationSessionInfo(kPresentationUrl2, kPresentationId));
run_loop.Run();
}
TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
- content::PresentationSessionInfo connection(kPresentationUrl,
+ content::PresentationSessionInfo connection(kPresentationUrl1,
kPresentationId);
content::PresentationConnectionStateChangedCallback state_changed_cb;
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
@@ -470,13 +512,14 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
// Trigger state change. It should be propagated back up to |mock_client_|.
blink::mojom::PresentationSessionInfo presentation_connection;
- presentation_connection.url = kPresentationUrl;
+ presentation_connection.url = url::mojom::Url::New();
+ presentation_connection.url->url = kPresentationUrl1;
presentation_connection.id = kPresentationId;
{
base::RunLoop run_loop;
EXPECT_CALL(mock_client_,
OnConnectionStateChanged(
- Equals(presentation_connection),
+ SessionInfoEquals(ByRef(presentation_connection)),
blink::mojom::PresentationConnectionState::TERMINATED))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
state_changed_cb.Run(PresentationConnectionStateChangeInfo(
@@ -486,7 +529,7 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
}
TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
- content::PresentationSessionInfo connection(kPresentationUrl,
+ content::PresentationSessionInfo connection(kPresentationUrl1,
kPresentationId);
content::PresentationConnectionStateChangedCallback state_changed_cb;
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
@@ -496,7 +539,8 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
// Trigger connection close. It should be propagated back up to
// |mock_client_|.
blink::mojom::PresentationSessionInfo presentation_connection;
- presentation_connection.url = kPresentationUrl;
+ presentation_connection.url = url::mojom::Url::New();
+ presentation_connection.url->url = kPresentationUrl1;
presentation_connection.id = kPresentationId;
{
base::RunLoop run_loop;
@@ -508,7 +552,7 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
EXPECT_CALL(
mock_client_,
OnConnectionClosed(
- Equals(presentation_connection),
+ SessionInfoEquals(ByRef(presentation_connection)),
blink::mojom::PresentationConnectionCloseReason::WENT_AWAY, "Foo"))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
state_changed_cb.Run(closed_info);
@@ -516,96 +560,108 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
}
}
-TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrl) {
- EXPECT_CALL(mock_delegate_,
- SetDefaultPresentationUrl(_, _, Eq(kPresentationUrl), _))
+TEST_F(PresentationServiceImplTest, SetSameDefaultPresentationUrls) {
+ std::vector<std::string> urls(2);
+ urls[0] = kPresentationUrl1;
+ urls[1] = kPresentationUrl2;
+
+ EXPECT_CALL(mock_delegate_, SetDefaultPresentationUrls(_, _, urls, _))
.Times(1);
- service_impl_->SetDefaultPresentationURL(kPresentationUrl);
+ service_impl_->SetDefaultPresentationUrls(ToMojoUrls(urls));
EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_delegate_));
- EXPECT_EQ(kPresentationUrl, service_impl_->default_presentation_url_);
- // Same URL as before; no-ops.
- service_impl_->SetDefaultPresentationURL(kPresentationUrl);
+ // Same URLs as before; no-ops.
+ service_impl_->SetDefaultPresentationUrls(ToMojoUrls(urls));
EXPECT_TRUE(Mock::VerifyAndClearExpectations(&mock_delegate_));
- EXPECT_EQ(kPresentationUrl, service_impl_->default_presentation_url_);
}
TEST_F(PresentationServiceImplTest, StartSessionSuccess) {
+ std::vector<std::string> urls(2);
+ urls[0] = kPresentationUrl1;
+ urls[1] = kPresentationUrl2;
+
service_ptr_->StartSession(
- kPresentationUrl,
- base::Bind(
- &PresentationServiceImplTest::ExpectNewSessionCallbackSuccess,
- base::Unretained(this)));
+ ToMojoUrls(urls),
+ base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackSuccess,
+ base::Unretained(this)));
base::RunLoop run_loop;
base::Callback<void(const PresentationSessionInfo&)> success_cb;
- EXPECT_CALL(mock_delegate_, StartSession(_, _, Eq(kPresentationUrl), _, _))
- .WillOnce(DoAll(
- InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<3>(&success_cb)));
+ EXPECT_CALL(mock_delegate_, StartSession(_, _, urls, _, _))
+ .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
+ SaveArg<3>(&success_cb)));
run_loop.Run();
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
.Times(1);
- success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId));
+ success_cb.Run(PresentationSessionInfo(kPresentationUrl1, kPresentationId));
SaveQuitClosureAndRunLoop();
}
TEST_F(PresentationServiceImplTest, StartSessionError) {
+ std::vector<std::string> urls(2);
+ urls[0] = kPresentationUrl1;
+ urls[1] = kPresentationUrl2;
+
service_ptr_->StartSession(
- kPresentationUrl,
- base::Bind(
- &PresentationServiceImplTest::ExpectNewSessionCallbackError,
- base::Unretained(this)));
+ ToMojoUrls(urls),
+ base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackError,
+ base::Unretained(this)));
base::RunLoop run_loop;
base::Callback<void(const PresentationError&)> error_cb;
- EXPECT_CALL(mock_delegate_, StartSession(_, _, Eq(kPresentationUrl), _, _))
- .WillOnce(DoAll(
- InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<4>(&error_cb)));
+ EXPECT_CALL(mock_delegate_, StartSession(_, _, urls, _, _))
+ .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
+ SaveArg<4>(&error_cb)));
run_loop.Run();
error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
SaveQuitClosureAndRunLoop();
}
TEST_F(PresentationServiceImplTest, JoinSessionSuccess) {
+ std::vector<std::string> urls(2);
+ urls[0] = kPresentationUrl1;
+ urls[1] = kPresentationUrl2;
+
service_ptr_->JoinSession(
- kPresentationUrl, base::Optional<std::string>(kPresentationId),
+ ToMojoUrls(urls), base::Optional<std::string>(kPresentationId),
base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackSuccess,
base::Unretained(this)));
base::RunLoop run_loop;
base::Callback<void(const PresentationSessionInfo&)> success_cb;
- EXPECT_CALL(mock_delegate_, JoinSession(
- _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _))
- .WillOnce(DoAll(
- InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<4>(&success_cb)));
+ EXPECT_CALL(mock_delegate_, JoinSession(_, _, urls, kPresentationId, _, _))
+ .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
+ SaveArg<4>(&success_cb)));
run_loop.Run();
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _))
.Times(1);
- success_cb.Run(PresentationSessionInfo(kPresentationUrl, kPresentationId));
+ success_cb.Run(PresentationSessionInfo(kPresentationUrl1, kPresentationId));
SaveQuitClosureAndRunLoop();
}
TEST_F(PresentationServiceImplTest, JoinSessionError) {
+ std::vector<std::string> urls(2);
+ urls[0] = kPresentationUrl1;
+ urls[1] = kPresentationUrl2;
+
service_ptr_->JoinSession(
- kPresentationUrl, base::Optional<std::string>(kPresentationId),
+ ToMojoUrls(urls), base::Optional<std::string>(kPresentationId),
base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackError,
base::Unretained(this)));
base::RunLoop run_loop;
base::Callback<void(const PresentationError&)> error_cb;
- EXPECT_CALL(mock_delegate_, JoinSession(
- _, _, Eq(kPresentationUrl), Eq(kPresentationId), _, _))
- .WillOnce(DoAll(
- InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
- SaveArg<5>(&error_cb)));
+ EXPECT_CALL(mock_delegate_, JoinSession(_, _, urls, kPresentationId, _, _))
+ .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
+ SaveArg<5>(&error_cb)));
run_loop.Run();
error_cb.Run(PresentationError(PRESENTATION_ERROR_UNKNOWN, "Error message"));
SaveQuitClosureAndRunLoop();
}
TEST_F(PresentationServiceImplTest, CloseConnection) {
- service_ptr_->CloseConnection(kPresentationUrl, kPresentationId);
+ url::mojom::UrlPtr url = url::mojom::Url::New();
+ url->url = kPresentationUrl1;
+ service_ptr_->CloseConnection(std::move(url), kPresentationId);
+
base::RunLoop run_loop;
EXPECT_CALL(mock_delegate_, CloseConnection(_, _, Eq(kPresentationId)))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
@@ -613,7 +669,9 @@ TEST_F(PresentationServiceImplTest, CloseConnection) {
}
TEST_F(PresentationServiceImplTest, Terminate) {
- service_ptr_->Terminate(kPresentationUrl, kPresentationId);
+ url::mojom::UrlPtr url = url::mojom::Url::New();
+ url->url = kPresentationUrl1;
+ service_ptr_->Terminate(std::move(url), kPresentationId);
base::RunLoop run_loop;
EXPECT_CALL(mock_delegate_, Terminate(_, _, Eq(kPresentationId)))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
@@ -639,20 +697,21 @@ TEST_F(PresentationServiceImplTest, ListenForSessionMessagesWithEmptyMsg) {
}
TEST_F(PresentationServiceImplTest, StartSessionInProgress) {
+ std::vector<std::string> urls(2);
std::string presentation_url1("http://fooUrl");
std::string presentation_url2("http://barUrl");
- EXPECT_CALL(mock_delegate_, StartSession(_, _, Eq(presentation_url1), _, _))
- .Times(1);
- service_ptr_->StartSession(presentation_url1,
- base::Bind(&DoNothing));
+ urls[0] = presentation_url1;
+ urls[1] = presentation_url2;
+
+ EXPECT_CALL(mock_delegate_, StartSession(_, _, urls, _, _)).Times(1);
+ service_ptr_->StartSession(ToMojoUrls(urls), base::Bind(&DoNothing));
// This request should fail immediately, since there is already a StartSession
// in progress.
service_ptr_->StartSession(
- presentation_url2,
- base::Bind(
- &PresentationServiceImplTest::ExpectNewSessionCallbackError,
- base::Unretained(this)));
+ ToMojoUrls(urls),
+ base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackError,
+ base::Unretained(this)));
SaveQuitClosureAndRunLoop();
}
@@ -661,7 +720,8 @@ TEST_F(PresentationServiceImplTest, SendStringMessage) {
blink::mojom::PresentationSessionInfoPtr session(
blink::mojom::PresentationSessionInfo::New());
- session->url = kPresentationUrl;
+ session->url = url::mojom::Url::New();
+ session->url->url = kPresentationUrl1;
session->id = kPresentationId;
blink::mojom::SessionMessagePtr message_request(
blink::mojom::SessionMessage::New());
@@ -699,7 +759,8 @@ TEST_F(PresentationServiceImplTest, SendArrayBuffer) {
blink::mojom::PresentationSessionInfoPtr session(
blink::mojom::PresentationSessionInfo::New());
- session->url = kPresentationUrl;
+ session->url = url::mojom::Url::New();
+ session->url->url = kPresentationUrl1;
session->id = kPresentationId;
blink::mojom::SessionMessagePtr message_request(
blink::mojom::SessionMessage::New());
@@ -743,7 +804,8 @@ TEST_F(PresentationServiceImplTest, SendArrayBufferWithExceedingLimit) {
blink::mojom::PresentationSessionInfoPtr session(
blink::mojom::PresentationSessionInfo::New());
- session->url = kPresentationUrl;
+ session->url = url::mojom::Url::New();
+ session->url->url = kPresentationUrl1;
session->id = kPresentationId;
blink::mojom::SessionMessagePtr message_request(
blink::mojom::SessionMessage::New());
@@ -774,7 +836,8 @@ TEST_F(PresentationServiceImplTest, SendBlobData) {
blink::mojom::PresentationSessionInfoPtr session(
blink::mojom::PresentationSessionInfo::New());
- session->url = kPresentationUrl;
+ session->url = url::mojom::Url::New();
+ session->url->url = kPresentationUrl1;
session->id = kPresentationId;
blink::mojom::SessionMessagePtr message_request(
blink::mojom::SessionMessage::New());
@@ -815,29 +878,33 @@ TEST_F(PresentationServiceImplTest, MaxPendingJoinSessionRequests) {
EXPECT_CALL(mock_delegate_, JoinSession(_, _, _, _, _, _))
.Times(num_requests);
for (; i < num_requests; ++i) {
- service_ptr_->JoinSession(
- base::StringPrintf(presentation_url, i),
- base::StringPrintf(presentation_id, i),
- base::Bind(&DoNothing));
+ std::vector<url::mojom::UrlPtr> urls(1);
+ urls[0] = url::mojom::Url::New();
+ urls[0]->url = base::StringPrintf(presentation_url, i);
+ service_ptr_->JoinSession(std::move(urls),
+ base::StringPrintf(presentation_id, i),
+ base::Bind(&DoNothing));
}
+ std::vector<url::mojom::UrlPtr> urls(1);
+ urls[0] = url::mojom::Url::New();
+ urls[0]->url = base::StringPrintf(presentation_url, i);
// Exceeded maximum queue size, should invoke mojo callback with error.
service_ptr_->JoinSession(
- base::StringPrintf(presentation_url, i),
- base::StringPrintf(presentation_id, i),
- base::Bind(
- &PresentationServiceImplTest::ExpectNewSessionCallbackError,
- base::Unretained(this)));
+ std::move(urls), base::StringPrintf(presentation_id, i),
+ base::Bind(&PresentationServiceImplTest::ExpectNewSessionCallbackError,
+ base::Unretained(this)));
SaveQuitClosureAndRunLoop();
}
TEST_F(PresentationServiceImplTest, ScreenAvailabilityNotSupported) {
mock_delegate_.set_screen_availability_listening_supported(false);
+ url::mojom::Url url;
+ url.url = kPresentationUrl1;
base::RunLoop run_loop;
- EXPECT_CALL(mock_client_,
- OnScreenAvailabilityNotSupported(Eq(kPresentationUrl)))
+ EXPECT_CALL(mock_client_, OnScreenAvailabilityNotSupported(Equals(url)))
.WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
- ListenForScreenAvailabilityAndWait(kPresentationUrl, false);
+ ListenForScreenAvailabilityAndWait(kPresentationUrl1, false);
run_loop.Run();
}

Powered by Google App Engine
This is Rietveld 408576698