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

Unified Diff: ppapi/proxy/file_system_resource_unittest.cc

Issue 127243002: Pepper: Change ResourceMessageTestSink API for getting multiple messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implement GetFirst* methods in terms of GetAll* ones. Created 6 years, 11 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 | « no previous file | ppapi/proxy/resource_message_test_sink.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/file_system_resource_unittest.cc
diff --git a/ppapi/proxy/file_system_resource_unittest.cc b/ppapi/proxy/file_system_resource_unittest.cc
index 6828f7a7f03b1029883e81b3cfbb5381a44b3e88..e60a808f9e24d261c1b843d9b5811756c9b4f415 100644
--- a/ppapi/proxy/file_system_resource_unittest.cc
+++ b/ppapi/proxy/file_system_resource_unittest.cc
@@ -20,6 +20,7 @@
#include "ppapi/thunk/ppb_file_system_api.h"
#include "ppapi/thunk/thunk.h"
+using ppapi::proxy::ResourceMessageTestSink;
using ppapi::thunk::EnterResource;
using ppapi::thunk::PPB_FileSystem_API;
@@ -98,17 +99,15 @@ class FileSystemResourceTest : public PluginProxyTest {
PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb));
ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
- // Should have sent two "open" messages to the browser and renderer.
- ResourceMessageCallParams params1, params2;
- IPC::Message msg1, msg2;
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
- PpapiHostMsg_FileSystem_Open::ID, &params1, &msg1));
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
- PpapiHostMsg_FileSystem_Open::ID, &params2, &msg2));
+ // Should have sent two new "open" messages to the browser and renderer.
+ ResourceMessageTestSink::ResourceCallVector open_messages =
+ sink().GetAllResourceCallsMatching(PpapiHostMsg_FileSystem_Open::ID);
+ ASSERT_EQ(2U, open_messages.size());
+ sink().ClearMessages();
// The resource is expecting two replies.
- SendOpenReply(params1, PP_OK);
- SendOpenReply(params2, PP_OK);
+ SendOpenReply(open_messages[0].first, PP_OK);
+ SendOpenReply(open_messages[1].first, PP_OK);
ASSERT_TRUE(cb.called());
ASSERT_EQ(PP_OK, cb.result());
@@ -130,8 +129,9 @@ class FileSystemResourceTest : public PluginProxyTest {
// Should have sent an "open" message.
ResourceMessageCallParams params;
IPC::Message msg;
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
+ ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_FileIO_Open::ID, &params, &msg));
+ sink().ClearMessages();
// Send a success reply.
ResourceMessageReplyParams reply_params(params.pp_resource(),
@@ -162,15 +162,13 @@ TEST_F(FileSystemResourceTest, OpenFailure) {
PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb));
ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
- ResourceMessageCallParams params1, params2;
- IPC::Message msg1, msg2;
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
- PpapiHostMsg_FileSystem_Open::ID, &params1, &msg1));
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
- PpapiHostMsg_FileSystem_Open::ID, &params2, &msg2));
+ ResourceMessageTestSink::ResourceCallVector open_messages =
+ sink().GetAllResourceCallsMatching(PpapiHostMsg_FileSystem_Open::ID);
+ ASSERT_EQ(2U, open_messages.size());
+ sink().ClearMessages();
- SendOpenReply(params1, PP_ERROR_FAILED);
- SendOpenReply(params2, PP_OK);
+ SendOpenReply(open_messages[0].first, PP_ERROR_FAILED);
+ SendOpenReply(open_messages[1].first, PP_OK);
ASSERT_TRUE(cb.called());
ASSERT_EQ(PP_ERROR_FAILED, cb.result());
@@ -187,15 +185,13 @@ TEST_F(FileSystemResourceTest, OpenFailure) {
PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb));
ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
- ResourceMessageCallParams params1, params2;
- IPC::Message msg1, msg2;
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
- PpapiHostMsg_FileSystem_Open::ID, &params1, &msg1));
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
- PpapiHostMsg_FileSystem_Open::ID, &params2, &msg2));
+ ResourceMessageTestSink::ResourceCallVector open_messages =
+ sink().GetAllResourceCallsMatching(PpapiHostMsg_FileSystem_Open::ID);
+ ASSERT_EQ(2U, open_messages.size());
+ sink().ClearMessages();
- SendOpenReply(params1, PP_OK);
- SendOpenReply(params2, PP_ERROR_FAILED);
+ SendOpenReply(open_messages[0].first, PP_OK);
+ SendOpenReply(open_messages[1].first, PP_ERROR_FAILED);
ASSERT_TRUE(cb.called());
ASSERT_EQ(PP_ERROR_FAILED, cb.result());
@@ -237,8 +233,10 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
// and a map of all currently open files to their max written offsets.
ResourceMessageCallParams params;
IPC::Message msg;
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
+ ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
+ sink().ClearMessages();
+
int64_t amount = 0;
FileOffsetMap max_written_offsets;
ASSERT_TRUE(UnpackMessage<PpapiHostMsg_FileSystem_ReserveQuota>(
@@ -248,16 +246,18 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
ASSERT_EQ(0, max_written_offsets[file_io1.get()]);
ASSERT_EQ(0, max_written_offsets[file_io2.get()]);
- // Make another request.
+ // Make another request while the "reserve quota" message is pending.
MockRequestQuotaCallback cb2;
result = file_system_api->RequestQuota(
kQuotaRequestAmount2,
base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2)));
ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
-
+ // No new "reserve quota" message should be sent while one is pending.
+ ASSERT_FALSE(sink().GetFirstResourceCallMatching(
+ PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
{
ProxyAutoUnlock unlock_to_prevent_deadlock;
- // Reply with quota reservation amount sufficient to cover the two requests.
+ // Reply with quota reservation amount sufficient to cover both requests.
// Both callbacks should be called with the requests granted.
SendReply(params,
PP_OK,
@@ -283,8 +283,9 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2)));
ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
+ ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
+ sink().ClearMessages();
{
ProxyAutoUnlock unlock_to_prevent_deadlock;
// Reply with quota reservation amount insufficient to cover the first
@@ -313,8 +314,9 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2)));
ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
+ ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
+ sink().ClearMessages();
{
ProxyAutoUnlock unlock_to_prevent_deadlock;
// Reply with quota reservation amount sufficient only to cover the first
@@ -330,8 +332,9 @@ TEST_F(FileSystemResourceTest, RequestQuota) {
ASSERT_FALSE(cb2.called());
// Another request message should have been sent.
- ASSERT_TRUE(sink().GetNextResourceCallMatching(
+ ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
+ sink().ClearMessages();
{
ProxyAutoUnlock unlock_to_prevent_deadlock;
// Reply with quota reservation amount sufficient to cover the second
« no previous file with comments | « no previous file | ppapi/proxy/resource_message_test_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698