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

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

Issue 1140713005: [PresentationAPI] Implements send API for Blob data from WebPresentationClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unit tests 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
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 677418fd90a10e0ff5fdf3b8415c91b3387119d6..abeace207ad72bec34e203ffe6515aa8e5e62848 100644
--- a/content/browser/presentation/presentation_service_impl_unittest.cc
+++ b/content/browser/presentation/presentation_service_impl_unittest.cc
@@ -306,7 +306,8 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
content::PresentationSessionMessage::CreateBinaryMessage(
presentation_url, presentation_id,
scoped_ptr<std::vector<uint8_t>>(
- new std::vector<uint8_t>(binary_data))));
+ new std::vector<uint8_t>(binary_data)),
+ PresentationMessageType::ARRAY_BUFFER));
message_cb.Run(messages.Pass());
SaveQuitClosureAndRunLoop();
}
@@ -738,6 +739,7 @@ TEST_F(PresentationServiceImplTest, SendArrayBuffer) {
EXPECT_EQ(presentation_url, test_message->presentation_url);
EXPECT_EQ(presentation_id, test_message->presentation_id);
EXPECT_TRUE(test_message->is_binary());
+ EXPECT_EQ(PresentationMessageType::ARRAY_BUFFER, test_message->type);
EXPECT_FALSE(test_message->message);
EXPECT_EQ(data.size(), test_message->data.get()->size());
EXPECT_TRUE(test_message->data.get()->size() <=
@@ -788,6 +790,52 @@ TEST_F(PresentationServiceImplTest, SendArrayBufferWithExceedingLimit) {
SaveQuitClosureAndRunLoop();
}
+TEST_F(PresentationServiceImplTest, SendBlobData) {
+ std::string presentation_url("http://foo.com/index.html");
+ std::string presentation_id("presentationId");
+ const uint8 buffer[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+ std::vector<uint8> data;
+ data.assign(buffer, buffer + sizeof(buffer));
+
+ presentation::SessionMessagePtr message_request(
+ presentation::SessionMessage::New());
+ message_request->presentation_url = presentation_url;
+ message_request->presentation_id = presentation_id;
+ message_request->type = presentation::PresentationMessageType::
+ PRESENTATION_MESSAGE_TYPE_BLOB;
+ message_request->data = mojo::Array<uint8>::From(data);
+ service_ptr_->SendSessionMessage(
+ message_request.Pass(),
+ base::Bind(
+ &PresentationServiceImplTest::ExpectSendMessageMojoCallback,
+ base::Unretained(this)));
+
+ base::RunLoop run_loop;
+ base::Closure send_message_cb;
+ PresentationSessionMessage* test_message = nullptr;
+ EXPECT_CALL(mock_delegate_, SendMessageRawPtr(
+ _, _, _, _))
+ .WillOnce(DoAll(
+ InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
+ SaveArg<2>(&test_message),
+ SaveArg<3>(&send_message_cb)));
+ run_loop.Run();
+
+ EXPECT_TRUE(test_message);
+ EXPECT_EQ(presentation_url, test_message->presentation_url);
+ EXPECT_EQ(presentation_id, test_message->presentation_id);
+ EXPECT_TRUE(test_message->is_binary());
+ EXPECT_EQ(PresentationMessageType::BLOB, test_message->type);
+ EXPECT_FALSE(test_message->message);
+ EXPECT_EQ(data.size(), test_message->data.get()->size());
+ EXPECT_TRUE(test_message->data.get()->size() <=
+ kMaxPresentationSessionMessageSize);
+ EXPECT_EQ(0, memcmp(buffer, &(*test_message->data.get())[0], sizeof(buffer)));
+ delete test_message;
+ send_message_cb.Run();
+ SaveQuitClosureAndRunLoop();
mark a. foltz 2015/06/02 23:51:02 Nice test case :)
+}
+
TEST_F(PresentationServiceImplTest, MaxPendingStartSessionRequests) {
const char* presentation_url = "http://fooUrl%d";
const char* presentation_id = "presentationId%d";

Powered by Google App Engine
This is Rietveld 408576698