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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/proxy/resource_message_test_sink.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "ppapi/c/pp_errors.h" 6 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/c/ppb_file_io.h" 7 #include "ppapi/c/ppb_file_io.h"
8 #include "ppapi/c/ppb_file_ref.h" 8 #include "ppapi/c/ppb_file_ref.h"
9 #include "ppapi/c/ppb_file_system.h" 9 #include "ppapi/c/ppb_file_system.h"
10 #include "ppapi/proxy/file_system_resource.h" 10 #include "ppapi/proxy/file_system_resource.h"
11 #include "ppapi/proxy/locking_resource_releaser.h" 11 #include "ppapi/proxy/locking_resource_releaser.h"
12 #include "ppapi/proxy/plugin_message_filter.h" 12 #include "ppapi/proxy/plugin_message_filter.h"
13 #include "ppapi/proxy/ppapi_message_utils.h" 13 #include "ppapi/proxy/ppapi_message_utils.h"
14 #include "ppapi/proxy/ppapi_messages.h" 14 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/proxy/ppapi_proxy_test.h" 15 #include "ppapi/proxy/ppapi_proxy_test.h"
16 #include "ppapi/shared_impl/proxy_lock.h" 16 #include "ppapi/shared_impl/proxy_lock.h"
17 #include "ppapi/shared_impl/scoped_pp_var.h" 17 #include "ppapi/shared_impl/scoped_pp_var.h"
18 #include "ppapi/shared_impl/var.h" 18 #include "ppapi/shared_impl/var.h"
19 #include "ppapi/thunk/enter.h" 19 #include "ppapi/thunk/enter.h"
20 #include "ppapi/thunk/ppb_file_system_api.h" 20 #include "ppapi/thunk/ppb_file_system_api.h"
21 #include "ppapi/thunk/thunk.h" 21 #include "ppapi/thunk/thunk.h"
22 22
23 using ppapi::proxy::ResourceMessageTestSink;
23 using ppapi::thunk::EnterResource; 24 using ppapi::thunk::EnterResource;
24 using ppapi::thunk::PPB_FileSystem_API; 25 using ppapi::thunk::PPB_FileSystem_API;
25 26
26 namespace ppapi { 27 namespace ppapi {
27 namespace proxy { 28 namespace proxy {
28 29
29 namespace { 30 namespace {
30 31
31 const int64_t kExpectedFileSystemSize = 100; 32 const int64_t kExpectedFileSystemSize = 100;
32 const int64_t kQuotaRequestAmount1 = 10; 33 const int64_t kQuotaRequestAmount1 = 10;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 92
92 // Opens the given file system. 93 // Opens the given file system.
93 void OpenFileSystem(PP_Resource file_system) { 94 void OpenFileSystem(PP_Resource file_system) {
94 MockCompletionCallback cb; 95 MockCompletionCallback cb;
95 int32_t result = thunk::GetPPB_FileSystem_1_0_Thunk()->Open( 96 int32_t result = thunk::GetPPB_FileSystem_1_0_Thunk()->Open(
96 file_system, 97 file_system,
97 kExpectedFileSystemSize, 98 kExpectedFileSystemSize,
98 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb)); 99 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb));
99 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 100 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
100 101
101 // Should have sent two "open" messages to the browser and renderer. 102 // Should have sent two new "open" messages to the browser and renderer.
102 ResourceMessageCallParams params1, params2; 103 ResourceMessageTestSink::ResourceCallVector open_messages =
103 IPC::Message msg1, msg2; 104 sink().GetAllResourceCallsMatching(PpapiHostMsg_FileSystem_Open::ID);
104 ASSERT_TRUE(sink().GetNextResourceCallMatching( 105 ASSERT_EQ(2U, open_messages.size());
105 PpapiHostMsg_FileSystem_Open::ID, &params1, &msg1)); 106 sink().ClearMessages();
106 ASSERT_TRUE(sink().GetNextResourceCallMatching(
107 PpapiHostMsg_FileSystem_Open::ID, &params2, &msg2));
108 107
109 // The resource is expecting two replies. 108 // The resource is expecting two replies.
110 SendOpenReply(params1, PP_OK); 109 SendOpenReply(open_messages[0].first, PP_OK);
111 SendOpenReply(params2, PP_OK); 110 SendOpenReply(open_messages[1].first, PP_OK);
112 111
113 ASSERT_TRUE(cb.called()); 112 ASSERT_TRUE(cb.called());
114 ASSERT_EQ(PP_OK, cb.result()); 113 ASSERT_EQ(PP_OK, cb.result());
115 } 114 }
116 115
117 // Opens the given file in the given file system. Since there is no host, 116 // Opens the given file in the given file system. Since there is no host,
118 // the file handle will be invalid. 117 // the file handle will be invalid.
119 void OpenFile(PP_Resource file_io, 118 void OpenFile(PP_Resource file_io,
120 PP_Resource file_ref, 119 PP_Resource file_ref,
121 PP_Resource file_system) { 120 PP_Resource file_system) {
122 MockCompletionCallback cb; 121 MockCompletionCallback cb;
123 int32_t result = thunk::GetPPB_FileIO_1_1_Thunk()->Open( 122 int32_t result = thunk::GetPPB_FileIO_1_1_Thunk()->Open(
124 file_io, 123 file_io,
125 file_ref, 124 file_ref,
126 PP_FILEOPENFLAG_WRITE, 125 PP_FILEOPENFLAG_WRITE,
127 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb)); 126 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb));
128 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 127 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
129 128
130 // Should have sent an "open" message. 129 // Should have sent an "open" message.
131 ResourceMessageCallParams params; 130 ResourceMessageCallParams params;
132 IPC::Message msg; 131 IPC::Message msg;
133 ASSERT_TRUE(sink().GetNextResourceCallMatching( 132 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
134 PpapiHostMsg_FileIO_Open::ID, &params, &msg)); 133 PpapiHostMsg_FileIO_Open::ID, &params, &msg));
134 sink().ClearMessages();
135 135
136 // Send a success reply. 136 // Send a success reply.
137 ResourceMessageReplyParams reply_params(params.pp_resource(), 137 ResourceMessageReplyParams reply_params(params.pp_resource(),
138 params.sequence()); 138 params.sequence());
139 reply_params.set_result(PP_OK); 139 reply_params.set_result(PP_OK);
140 PluginMessageFilter::DispatchResourceReplyForTest( 140 PluginMessageFilter::DispatchResourceReplyForTest(
141 reply_params, 141 reply_params,
142 PpapiPluginMsg_FileIO_OpenReply(file_system, 142 PpapiPluginMsg_FileIO_OpenReply(file_system,
143 0 /* max_written_offset */)); 143 0 /* max_written_offset */));
144 } 144 }
(...skipping 10 matching lines...) Expand all
155 LockingResourceReleaser file_system( 155 LockingResourceReleaser file_system(
156 fs_iface->Create(pp_instance(), PP_FILESYSTEMTYPE_LOCALTEMPORARY)); 156 fs_iface->Create(pp_instance(), PP_FILESYSTEMTYPE_LOCALTEMPORARY));
157 157
158 MockCompletionCallback cb; 158 MockCompletionCallback cb;
159 int32_t result = thunk::GetPPB_FileSystem_1_0_Thunk()->Open( 159 int32_t result = thunk::GetPPB_FileSystem_1_0_Thunk()->Open(
160 file_system.get(), 160 file_system.get(),
161 kExpectedFileSystemSize, 161 kExpectedFileSystemSize,
162 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb)); 162 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb));
163 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 163 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
164 164
165 ResourceMessageCallParams params1, params2; 165 ResourceMessageTestSink::ResourceCallVector open_messages =
166 IPC::Message msg1, msg2; 166 sink().GetAllResourceCallsMatching(PpapiHostMsg_FileSystem_Open::ID);
167 ASSERT_TRUE(sink().GetNextResourceCallMatching( 167 ASSERT_EQ(2U, open_messages.size());
168 PpapiHostMsg_FileSystem_Open::ID, &params1, &msg1)); 168 sink().ClearMessages();
169 ASSERT_TRUE(sink().GetNextResourceCallMatching(
170 PpapiHostMsg_FileSystem_Open::ID, &params2, &msg2));
171 169
172 SendOpenReply(params1, PP_ERROR_FAILED); 170 SendOpenReply(open_messages[0].first, PP_ERROR_FAILED);
173 SendOpenReply(params2, PP_OK); 171 SendOpenReply(open_messages[1].first, PP_OK);
174 172
175 ASSERT_TRUE(cb.called()); 173 ASSERT_TRUE(cb.called());
176 ASSERT_EQ(PP_ERROR_FAILED, cb.result()); 174 ASSERT_EQ(PP_ERROR_FAILED, cb.result());
177 } 175 }
178 // Fail if the second reply doesn't return PP_OK. 176 // Fail if the second reply doesn't return PP_OK.
179 { 177 {
180 LockingResourceReleaser file_system( 178 LockingResourceReleaser file_system(
181 fs_iface->Create(pp_instance(), PP_FILESYSTEMTYPE_LOCALTEMPORARY)); 179 fs_iface->Create(pp_instance(), PP_FILESYSTEMTYPE_LOCALTEMPORARY));
182 180
183 MockCompletionCallback cb; 181 MockCompletionCallback cb;
184 int32_t result = thunk::GetPPB_FileSystem_1_0_Thunk()->Open( 182 int32_t result = thunk::GetPPB_FileSystem_1_0_Thunk()->Open(
185 file_system.get(), 183 file_system.get(),
186 kExpectedFileSystemSize, 184 kExpectedFileSystemSize,
187 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb)); 185 PP_MakeCompletionCallback(&MockCompletionCallback::Callback, &cb));
188 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 186 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
189 187
190 ResourceMessageCallParams params1, params2; 188 ResourceMessageTestSink::ResourceCallVector open_messages =
191 IPC::Message msg1, msg2; 189 sink().GetAllResourceCallsMatching(PpapiHostMsg_FileSystem_Open::ID);
192 ASSERT_TRUE(sink().GetNextResourceCallMatching( 190 ASSERT_EQ(2U, open_messages.size());
193 PpapiHostMsg_FileSystem_Open::ID, &params1, &msg1)); 191 sink().ClearMessages();
194 ASSERT_TRUE(sink().GetNextResourceCallMatching(
195 PpapiHostMsg_FileSystem_Open::ID, &params2, &msg2));
196 192
197 SendOpenReply(params1, PP_OK); 193 SendOpenReply(open_messages[0].first, PP_OK);
198 SendOpenReply(params2, PP_ERROR_FAILED); 194 SendOpenReply(open_messages[1].first, PP_ERROR_FAILED);
199 195
200 ASSERT_TRUE(cb.called()); 196 ASSERT_TRUE(cb.called());
201 ASSERT_EQ(PP_ERROR_FAILED, cb.result()); 197 ASSERT_EQ(PP_ERROR_FAILED, cb.result());
202 } 198 }
203 } 199 }
204 200
205 TEST_F(FileSystemResourceTest, RequestQuota) { 201 TEST_F(FileSystemResourceTest, RequestQuota) {
206 const PPB_FileSystem_1_0* fs_iface = thunk::GetPPB_FileSystem_1_0_Thunk(); 202 const PPB_FileSystem_1_0* fs_iface = thunk::GetPPB_FileSystem_1_0_Thunk();
207 const PPB_FileRef_1_1* fref_iface = thunk::GetPPB_FileRef_1_1_Thunk(); 203 const PPB_FileRef_1_1* fref_iface = thunk::GetPPB_FileRef_1_1_Thunk();
208 const PPB_FileIO_1_1* fio_iface = thunk::GetPPB_FileIO_1_1_Thunk(); 204 const PPB_FileIO_1_1* fio_iface = thunk::GetPPB_FileIO_1_1_Thunk();
(...skipping 21 matching lines...) Expand all
230 MockRequestQuotaCallback cb1; 226 MockRequestQuotaCallback cb1;
231 int64_t result = file_system_api->RequestQuota( 227 int64_t result = file_system_api->RequestQuota(
232 kQuotaRequestAmount1, 228 kQuotaRequestAmount1,
233 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1))); 229 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1)));
234 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 230 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
235 231
236 // Should have sent a "reserve quota" message, with the amount of the request 232 // Should have sent a "reserve quota" message, with the amount of the request
237 // and a map of all currently open files to their max written offsets. 233 // and a map of all currently open files to their max written offsets.
238 ResourceMessageCallParams params; 234 ResourceMessageCallParams params;
239 IPC::Message msg; 235 IPC::Message msg;
240 ASSERT_TRUE(sink().GetNextResourceCallMatching( 236 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
241 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg)); 237 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
238 sink().ClearMessages();
239
242 int64_t amount = 0; 240 int64_t amount = 0;
243 FileOffsetMap max_written_offsets; 241 FileOffsetMap max_written_offsets;
244 ASSERT_TRUE(UnpackMessage<PpapiHostMsg_FileSystem_ReserveQuota>( 242 ASSERT_TRUE(UnpackMessage<PpapiHostMsg_FileSystem_ReserveQuota>(
245 msg, &amount, &max_written_offsets)); 243 msg, &amount, &max_written_offsets));
246 ASSERT_EQ(kQuotaRequestAmount1, amount); 244 ASSERT_EQ(kQuotaRequestAmount1, amount);
247 ASSERT_EQ(2U, max_written_offsets.size()); 245 ASSERT_EQ(2U, max_written_offsets.size());
248 ASSERT_EQ(0, max_written_offsets[file_io1.get()]); 246 ASSERT_EQ(0, max_written_offsets[file_io1.get()]);
249 ASSERT_EQ(0, max_written_offsets[file_io2.get()]); 247 ASSERT_EQ(0, max_written_offsets[file_io2.get()]);
250 248
251 // Make another request. 249 // Make another request while the "reserve quota" message is pending.
252 MockRequestQuotaCallback cb2; 250 MockRequestQuotaCallback cb2;
253 result = file_system_api->RequestQuota( 251 result = file_system_api->RequestQuota(
254 kQuotaRequestAmount2, 252 kQuotaRequestAmount2,
255 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2))); 253 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2)));
256 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 254 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
257 255 // No new "reserve quota" message should be sent while one is pending.
256 ASSERT_FALSE(sink().GetFirstResourceCallMatching(
257 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
258 { 258 {
259 ProxyAutoUnlock unlock_to_prevent_deadlock; 259 ProxyAutoUnlock unlock_to_prevent_deadlock;
260 // Reply with quota reservation amount sufficient to cover the two requests. 260 // Reply with quota reservation amount sufficient to cover both requests.
261 // Both callbacks should be called with the requests granted. 261 // Both callbacks should be called with the requests granted.
262 SendReply(params, 262 SendReply(params,
263 PP_OK, 263 PP_OK,
264 PpapiPluginMsg_FileSystem_ReserveQuotaReply( 264 PpapiPluginMsg_FileSystem_ReserveQuotaReply(
265 kQuotaRequestAmount1 + kQuotaRequestAmount2, 265 kQuotaRequestAmount1 + kQuotaRequestAmount2,
266 max_written_offsets)); 266 max_written_offsets));
267 } 267 }
268 ASSERT_TRUE(cb1.called()); 268 ASSERT_TRUE(cb1.called());
269 ASSERT_EQ(kQuotaRequestAmount1, cb1.result()); 269 ASSERT_EQ(kQuotaRequestAmount1, cb1.result());
270 ASSERT_TRUE(cb2.called()); 270 ASSERT_TRUE(cb2.called());
271 ASSERT_EQ(kQuotaRequestAmount2, cb2.result()); 271 ASSERT_EQ(kQuotaRequestAmount2, cb2.result());
272 cb1.Reset(); 272 cb1.Reset();
273 cb2.Reset(); 273 cb2.Reset();
274 274
275 // All requests should fail when insufficient quota is returned to satisfy 275 // All requests should fail when insufficient quota is returned to satisfy
276 // the first request. 276 // the first request.
277 result = file_system_api->RequestQuota( 277 result = file_system_api->RequestQuota(
278 kQuotaRequestAmount1, 278 kQuotaRequestAmount1,
279 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1))); 279 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1)));
280 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 280 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
281 result = file_system_api->RequestQuota( 281 result = file_system_api->RequestQuota(
282 kQuotaRequestAmount2, 282 kQuotaRequestAmount2,
283 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2))); 283 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2)));
284 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 284 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
285 285
286 ASSERT_TRUE(sink().GetNextResourceCallMatching( 286 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
287 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg)); 287 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
288 sink().ClearMessages();
288 { 289 {
289 ProxyAutoUnlock unlock_to_prevent_deadlock; 290 ProxyAutoUnlock unlock_to_prevent_deadlock;
290 // Reply with quota reservation amount insufficient to cover the first 291 // Reply with quota reservation amount insufficient to cover the first
291 // request. 292 // request.
292 SendReply(params, 293 SendReply(params,
293 PP_OK, 294 PP_OK,
294 PpapiPluginMsg_FileSystem_ReserveQuotaReply( 295 PpapiPluginMsg_FileSystem_ReserveQuotaReply(
295 kQuotaRequestAmount1 - 1, 296 kQuotaRequestAmount1 - 1,
296 max_written_offsets)); 297 max_written_offsets));
297 } 298 }
298 ASSERT_TRUE(cb1.called()); 299 ASSERT_TRUE(cb1.called());
299 ASSERT_EQ(0, cb1.result()); 300 ASSERT_EQ(0, cb1.result());
300 ASSERT_TRUE(cb2.called()); 301 ASSERT_TRUE(cb2.called());
301 ASSERT_EQ(0, cb2.result()); 302 ASSERT_EQ(0, cb2.result());
302 cb1.Reset(); 303 cb1.Reset();
303 cb2.Reset(); 304 cb2.Reset();
304 305
305 // A new request should be made if the quota reservation is enough to satisfy 306 // A new request should be made if the quota reservation is enough to satisfy
306 // at least one request. 307 // at least one request.
307 result = file_system_api->RequestQuota( 308 result = file_system_api->RequestQuota(
308 kQuotaRequestAmount1, 309 kQuotaRequestAmount1,
309 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1))); 310 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1)));
310 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 311 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
311 result = file_system_api->RequestQuota( 312 result = file_system_api->RequestQuota(
312 kQuotaRequestAmount2, 313 kQuotaRequestAmount2,
313 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2))); 314 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb2)));
314 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 315 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
315 316
316 ASSERT_TRUE(sink().GetNextResourceCallMatching( 317 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
317 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg)); 318 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
319 sink().ClearMessages();
318 { 320 {
319 ProxyAutoUnlock unlock_to_prevent_deadlock; 321 ProxyAutoUnlock unlock_to_prevent_deadlock;
320 // Reply with quota reservation amount sufficient only to cover the first 322 // Reply with quota reservation amount sufficient only to cover the first
321 // request. 323 // request.
322 SendReply(params, 324 SendReply(params,
323 PP_OK, 325 PP_OK,
324 PpapiPluginMsg_FileSystem_ReserveQuotaReply( 326 PpapiPluginMsg_FileSystem_ReserveQuotaReply(
325 kQuotaRequestAmount1, 327 kQuotaRequestAmount1,
326 max_written_offsets)); 328 max_written_offsets));
327 } 329 }
328 ASSERT_TRUE(cb1.called()); 330 ASSERT_TRUE(cb1.called());
329 ASSERT_EQ(kQuotaRequestAmount1, cb1.result()); 331 ASSERT_EQ(kQuotaRequestAmount1, cb1.result());
330 ASSERT_FALSE(cb2.called()); 332 ASSERT_FALSE(cb2.called());
331 333
332 // Another request message should have been sent. 334 // Another request message should have been sent.
333 ASSERT_TRUE(sink().GetNextResourceCallMatching( 335 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
334 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg)); 336 PpapiHostMsg_FileSystem_ReserveQuota::ID, &params, &msg));
337 sink().ClearMessages();
335 { 338 {
336 ProxyAutoUnlock unlock_to_prevent_deadlock; 339 ProxyAutoUnlock unlock_to_prevent_deadlock;
337 // Reply with quota reservation amount sufficient to cover the second 340 // Reply with quota reservation amount sufficient to cover the second
338 // request and some extra. 341 // request and some extra.
339 SendReply(params, 342 SendReply(params,
340 PP_OK, 343 PP_OK,
341 PpapiPluginMsg_FileSystem_ReserveQuotaReply( 344 PpapiPluginMsg_FileSystem_ReserveQuotaReply(
342 kQuotaRequestAmount1 + kQuotaRequestAmount2, 345 kQuotaRequestAmount1 + kQuotaRequestAmount2,
343 max_written_offsets)); 346 max_written_offsets));
344 } 347 }
345 348
346 ASSERT_TRUE(cb2.called()); 349 ASSERT_TRUE(cb2.called());
347 ASSERT_EQ(kQuotaRequestAmount2, cb2.result()); 350 ASSERT_EQ(kQuotaRequestAmount2, cb2.result());
348 cb1.Reset(); 351 cb1.Reset();
349 cb2.Reset(); 352 cb2.Reset();
350 353
351 // There is kQuotaRequestAmount1 of quota left, and a request for it should 354 // There is kQuotaRequestAmount1 of quota left, and a request for it should
352 // succeed immediately. 355 // succeed immediately.
353 result = file_system_api->RequestQuota( 356 result = file_system_api->RequestQuota(
354 kQuotaRequestAmount1, 357 kQuotaRequestAmount1,
355 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1))); 358 base::Bind(&MockRequestQuotaCallback::Callback, base::Unretained(&cb1)));
356 ASSERT_EQ(kQuotaRequestAmount1, result); 359 ASSERT_EQ(kQuotaRequestAmount1, result);
357 } 360 }
358 361
359 } // namespace proxy 362 } // namespace proxy
360 } // namespace ppapi 363 } // namespace ppapi
OLDNEW
« 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