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

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

Issue 1141683002: [Presentation API] Limit the number of pending Start/JoinSession (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rm unused function declaration Created 5 years, 7 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.cc ('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 177da866cadc2c81da76374955eb100277210d4f..677418fd90a10e0ff5fdf3b8415c91b3387119d6 100644
--- a/content/browser/presentation/presentation_service_impl_unittest.cc
+++ b/content/browser/presentation/presentation_service_impl_unittest.cc
@@ -43,6 +43,11 @@ bool ArePresentationSessionMessagesEqual(
expected->data.Equals(actual->data);
}
+void DoNothing(
+ presentation::PresentationSessionInfoPtr info,
+ presentation::PresentationErrorPtr error) {
+}
+
} // namespace
class MockPresentationServiceDelegate : public PresentationServiceDelegate {
@@ -124,8 +129,7 @@ class MockPresentationServiceClient :
class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
public:
- PresentationServiceImplTest()
- : default_session_started_count_(0) {}
+ PresentationServiceImplTest() : default_session_started_count_(0) {}
void SetUp() override {
RenderViewHostImplTestHarness::SetUp();
@@ -784,4 +788,53 @@ TEST_F(PresentationServiceImplTest, SendArrayBufferWithExceedingLimit) {
SaveQuitClosureAndRunLoop();
}
+TEST_F(PresentationServiceImplTest, MaxPendingStartSessionRequests) {
+ const char* presentation_url = "http://fooUrl%d";
+ const char* presentation_id = "presentationId%d";
+ int num_requests = PresentationServiceImpl::kMaxNumQueuedSessionRequests + 1;
+ int i = 0;
+ // First request will be processed. The subsequent
+ // |kMaxNumQueuedSessionRequests| requests will be queued.
+ EXPECT_CALL(mock_delegate_, StartSession(_, _, _, _, _, _)).Times(1);
+ for (; i < num_requests; ++i) {
+ service_ptr_->StartSession(
+ base::StringPrintf(presentation_url, i),
+ base::StringPrintf(presentation_id, i),
+ base::Bind(&DoNothing));
+ }
+
+ // Exceeded maximum queue size, should invoke mojo callback with error.
+ service_ptr_->StartSession(
+ base::StringPrintf(presentation_url, i),
+ base::StringPrintf(presentation_id, i),
+ base::Bind(
+ &PresentationServiceImplTest::ExpectNewSessionMojoCallbackError,
+ base::Unretained(this)));
+ SaveQuitClosureAndRunLoop();
+}
+
+TEST_F(PresentationServiceImplTest, MaxPendingJoinSessionRequests) {
+ const char* presentation_url = "http://fooUrl%d";
+ const char* presentation_id = "presentationId%d";
+ int num_requests = PresentationServiceImpl::kMaxNumQueuedSessionRequests;
+ int i = 0;
+ 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));
+ }
+
+ // 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::ExpectNewSessionMojoCallbackError,
+ base::Unretained(this)));
+ SaveQuitClosureAndRunLoop();
+}
+
} // namespace content
« no previous file with comments | « content/browser/presentation/presentation_service_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698