chrome/browser/extensions: Remove use of MessageLoopProxy and deprecated MessageLoop...
[chromium-blink-merge.git] / ppapi / proxy / video_decoder_resource_unittest.cc
blob7716940f5a51c94e0e65570d46e97d7121528a5d
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
3 // found in the LICENSE file.
5 #include <GLES2/gl2.h>
7 #include "base/memory/shared_memory.h"
8 #include "base/message_loop/message_loop.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_video_decoder.h"
11 #include "ppapi/proxy/locking_resource_releaser.h"
12 #include "ppapi/proxy/plugin_message_filter.h"
13 #include "ppapi/proxy/ppapi_message_utils.h"
14 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/proxy/ppapi_proxy_test.h"
16 #include "ppapi/proxy/ppb_graphics_3d_proxy.h"
17 #include "ppapi/proxy/video_decoder_constants.h"
18 #include "ppapi/proxy/video_decoder_resource.h"
19 #include "ppapi/shared_impl/proxy_lock.h"
20 #include "ppapi/thunk/thunk.h"
22 using ppapi::proxy::ResourceMessageTestSink;
24 namespace ppapi {
25 namespace proxy {
27 namespace {
29 const PP_Resource kGraphics3D = 7;
30 const uint32_t kShmSize = 256;
31 const size_t kDecodeBufferSize = 16;
32 const uint32_t kDecodeId = 5;
33 const uint32_t kTextureId1 = 1;
34 const uint32_t kTextureId2 = 2;
35 const uint32_t kNumRequestedTextures = 2;
37 class MockCompletionCallback {
38 public:
39 MockCompletionCallback() : called_(false) {}
41 bool called() { return called_; }
42 int32_t result() { return result_; }
44 void Reset() { called_ = false; }
46 static void Callback(void* user_data, int32_t result) {
47 MockCompletionCallback* that =
48 reinterpret_cast<MockCompletionCallback*>(user_data);
49 that->called_ = true;
50 that->result_ = result;
53 private:
54 bool called_;
55 int32_t result_;
58 class VideoDecoderResourceTest : public PluginProxyTest {
59 public:
60 VideoDecoderResourceTest()
61 : decoder_iface_(thunk::GetPPB_VideoDecoder_1_0_Thunk()) {}
63 const PPB_VideoDecoder_1_0* decoder_iface() const { return decoder_iface_; }
65 void SendReply(const ResourceMessageCallParams& params,
66 int32_t result,
67 const IPC::Message& nested_message) {
68 ResourceMessageReplyParams reply_params(params.pp_resource(),
69 params.sequence());
70 reply_params.set_result(result);
71 PluginMessageFilter::DispatchResourceReplyForTest(reply_params,
72 nested_message);
75 void SendReplyWithHandle(const ResourceMessageCallParams& params,
76 int32_t result,
77 const IPC::Message& nested_message,
78 const SerializedHandle& handle) {
79 ResourceMessageReplyParams reply_params(params.pp_resource(),
80 params.sequence());
81 reply_params.set_result(result);
82 reply_params.AppendHandle(handle);
83 PluginMessageFilter::DispatchResourceReplyForTest(reply_params,
84 nested_message);
87 PP_Resource CreateDecoder() {
88 PP_Resource result = decoder_iface()->Create(pp_instance());
89 if (result) {
90 ProxyAutoLock lock;
91 ppapi::Resource* resource =
92 GetGlobals()->GetResourceTracker()->GetResource(result);
93 proxy::VideoDecoderResource* decoder =
94 static_cast<proxy::VideoDecoderResource*>(resource);
95 decoder->SetForTest();
98 return result;
101 PP_Resource CreateGraphics3d() {
102 ProxyAutoLock lock;
104 HostResource host_resource;
105 host_resource.SetHostResource(pp_instance(), kGraphics3D);
106 scoped_refptr<ppapi::proxy::Graphics3D> graphics_3d(
107 new ppapi::proxy::Graphics3D(host_resource));
108 return graphics_3d->GetReference();
111 PP_Resource CreateAndInitializeDecoder() {
112 PP_Resource decoder = CreateDecoder();
113 LockingResourceReleaser graphics3d(CreateGraphics3d());
114 MockCompletionCallback cb;
115 int32_t result = decoder_iface()->Initialize(
116 decoder,
117 graphics3d.get(),
118 PP_VIDEOPROFILE_H264MAIN,
119 PP_HARDWAREACCELERATION_WITHFALLBACK,
120 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
121 &cb));
122 if (result != PP_OK_COMPLETIONPENDING)
123 return 0;
124 ResourceMessageCallParams params;
125 IPC::Message msg;
126 if (!sink().GetFirstResourceCallMatching(
127 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg))
128 return 0;
129 sink().ClearMessages();
130 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_InitializeReply());
131 return decoder;
134 int32_t CallDecode(PP_Resource pp_decoder,
135 MockCompletionCallback* cb,
136 const PpapiHostMsg_VideoDecoder_GetShm* expected_shm_msg) {
137 // Set up a handler in case the resource sends a sync message to create
138 // shared memory.
139 PpapiPluginMsg_VideoDecoder_GetShmReply shm_msg_reply(kShmSize);
140 ResourceSyncCallHandler shm_msg_handler(
141 &sink(), PpapiHostMsg_VideoDecoder_GetShm::ID, PP_OK, shm_msg_reply);
142 sink().AddFilter(&shm_msg_handler);
144 base::SharedMemory shm;
145 if (expected_shm_msg) {
146 shm.CreateAnonymous(kShmSize);
147 base::SharedMemoryHandle shm_handle;
148 shm.ShareToProcess(base::GetCurrentProcessHandle(), &shm_handle);
149 SerializedHandle serialized_handle(shm_handle, kShmSize);
150 shm_msg_handler.set_serialized_handle(&serialized_handle);
153 memset(decode_buffer_, 0x55, kDecodeBufferSize);
154 int32_t result =
155 decoder_iface()->Decode(pp_decoder,
156 kDecodeId,
157 kDecodeBufferSize,
158 decode_buffer_,
159 PP_MakeOptionalCompletionCallback(
160 &MockCompletionCallback::Callback, cb));
162 if (expected_shm_msg) {
163 uint32_t shm_id, shm_size, expected_shm_id, expected_shm_size;
164 UnpackMessage<PpapiHostMsg_VideoDecoder_GetShm>(
165 *expected_shm_msg, &expected_shm_id, &expected_shm_size);
166 if (shm_msg_handler.last_handled_msg().type() == 0 ||
167 !UnpackMessage<PpapiHostMsg_VideoDecoder_GetShm>(
168 shm_msg_handler.last_handled_msg(), &shm_id, &shm_size) ||
169 shm_id != expected_shm_id ||
170 shm_size != expected_shm_size) {
171 // Signal that the expected shm message wasn't sent by failing.
172 result = PP_ERROR_FAILED;
176 sink().RemoveFilter(&shm_msg_handler);
177 return result;
180 int32_t CallGetPicture(PP_Resource pp_decoder,
181 PP_VideoPicture* picture,
182 MockCompletionCallback* cb) {
183 int32_t result =
184 decoder_iface()->GetPicture(pp_decoder,
185 picture,
186 PP_MakeOptionalCompletionCallback(
187 &MockCompletionCallback::Callback, cb));
188 return result;
191 void CallRecyclePicture(PP_Resource pp_decoder,
192 const PP_VideoPicture& picture) {
193 decoder_iface()->RecyclePicture(pp_decoder, &picture);
196 int32_t CallFlush(PP_Resource pp_decoder, MockCompletionCallback* cb) {
197 int32_t result =
198 decoder_iface()->Flush(pp_decoder,
199 PP_MakeOptionalCompletionCallback(
200 &MockCompletionCallback::Callback, cb));
201 return result;
204 int32_t CallReset(PP_Resource pp_decoder, MockCompletionCallback* cb) {
205 int32_t result =
206 decoder_iface()->Reset(pp_decoder,
207 PP_MakeOptionalCompletionCallback(
208 &MockCompletionCallback::Callback, cb));
209 return result;
212 void SendDecodeReply(const ResourceMessageCallParams& params,
213 uint32_t shm_id) {
214 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_DecodeReply(shm_id));
217 void SendPictureReady(const ResourceMessageCallParams& params,
218 uint32_t decode_count,
219 uint32_t texture_id) {
220 PP_Rect visible_rect = PP_MakeRectFromXYWH(0, 0, 640, 480);
221 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_PictureReady(
222 decode_count, texture_id, visible_rect));
225 void SendFlushReply(const ResourceMessageCallParams& params) {
226 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_FlushReply());
229 void SendResetReply(const ResourceMessageCallParams& params) {
230 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_ResetReply());
233 void SendRequestTextures(const ResourceMessageCallParams& params) {
234 SendReply(params,
235 PP_OK,
236 PpapiPluginMsg_VideoDecoder_RequestTextures(
237 kNumRequestedTextures,
238 PP_MakeSize(320, 240),
239 GL_TEXTURE_2D,
240 std::vector<gpu::Mailbox>()));
243 void SendNotifyError(const ResourceMessageCallParams& params, int32_t error) {
244 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_NotifyError(error));
247 bool CheckDecodeMsg(ResourceMessageCallParams* params,
248 uint32_t* shm_id,
249 uint32_t* size,
250 int32_t* decode_id) {
251 IPC::Message msg;
252 if (!sink().GetFirstResourceCallMatching(
253 PpapiHostMsg_VideoDecoder_Decode::ID, params, &msg))
254 return false;
255 sink().ClearMessages();
256 return UnpackMessage<PpapiHostMsg_VideoDecoder_Decode>(
257 msg, shm_id, size, decode_id);
260 bool CheckRecyclePictureMsg(ResourceMessageCallParams* params,
261 uint32_t* texture_id) {
262 IPC::Message msg;
263 if (!sink().GetFirstResourceCallMatching(
264 PpapiHostMsg_VideoDecoder_RecyclePicture::ID, params, &msg))
265 return false;
266 sink().ClearMessages();
267 return UnpackMessage<PpapiHostMsg_VideoDecoder_RecyclePicture>(msg,
268 texture_id);
271 bool CheckFlushMsg(ResourceMessageCallParams* params) {
272 return CheckMsg(params, PpapiHostMsg_VideoDecoder_Flush::ID);
275 bool CheckResetMsg(ResourceMessageCallParams* params) {
276 return CheckMsg(params, PpapiHostMsg_VideoDecoder_Reset::ID);
279 void ClearCallbacks(PP_Resource pp_decoder) {
280 ResourceMessageCallParams params;
281 MockCompletionCallback cb;
283 // Reset to abort Decode and GetPicture callbacks.
284 CallReset(pp_decoder, &cb);
285 // Initialize params so we can reply to the Reset.
286 CheckResetMsg(&params);
287 // Run the Reset callback.
288 SendResetReply(params);
291 private:
292 bool CheckMsg(ResourceMessageCallParams* params, int id) {
293 IPC::Message msg;
294 if (!sink().GetFirstResourceCallMatching(id, params, &msg))
295 return false;
296 sink().ClearMessages();
297 return true;
300 const PPB_VideoDecoder_1_0* decoder_iface_;
302 char decode_buffer_[kDecodeBufferSize];
305 } // namespace
307 TEST_F(VideoDecoderResourceTest, Initialize) {
308 // Initialize with 0 graphics3d_context should fail.
310 LockingResourceReleaser decoder(CreateDecoder());
311 MockCompletionCallback cb;
312 int32_t result = decoder_iface()->Initialize(
313 decoder.get(),
314 0 /* invalid 3d graphics */,
315 PP_VIDEOPROFILE_H264MAIN,
316 PP_HARDWAREACCELERATION_WITHFALLBACK,
317 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
318 &cb));
319 ASSERT_EQ(PP_ERROR_BADRESOURCE, result);
321 // Initialize with bad profile value should fail.
323 LockingResourceReleaser decoder(CreateDecoder());
324 MockCompletionCallback cb;
325 int32_t result = decoder_iface()->Initialize(
326 decoder.get(),
327 1 /* non-zero resource */,
328 static_cast<PP_VideoProfile>(-1),
329 PP_HARDWAREACCELERATION_WITHFALLBACK,
330 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
331 &cb));
332 ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
334 // Initialize with valid graphics3d_context and profile should succeed.
336 LockingResourceReleaser decoder(CreateDecoder());
337 LockingResourceReleaser graphics3d(CreateGraphics3d());
338 MockCompletionCallback cb;
339 int32_t result = decoder_iface()->Initialize(
340 decoder.get(),
341 graphics3d.get(),
342 PP_VIDEOPROFILE_H264MAIN,
343 PP_HARDWAREACCELERATION_WITHFALLBACK,
344 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
345 &cb));
346 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
347 ASSERT_TRUE(decoder_iface()->IsVideoDecoder(decoder.get()));
349 // Another attempt while pending should fail.
350 result = decoder_iface()->Initialize(
351 decoder.get(),
352 graphics3d.get(),
353 PP_VIDEOPROFILE_H264MAIN,
354 PP_HARDWAREACCELERATION_WITHFALLBACK,
355 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
356 &cb));
357 ASSERT_EQ(PP_ERROR_INPROGRESS, result);
359 // Check for host message and send a reply to complete initialization.
360 ResourceMessageCallParams params;
361 IPC::Message msg;
362 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
363 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg));
364 sink().ClearMessages();
365 SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_InitializeReply());
366 ASSERT_TRUE(cb.called());
367 ASSERT_EQ(PP_OK, cb.result());
371 TEST_F(VideoDecoderResourceTest, Uninitialized) {
372 // Operations on uninitialized decoders should fail.
373 LockingResourceReleaser decoder(CreateDecoder());
374 MockCompletionCallback uncalled_cb;
376 ASSERT_EQ(PP_ERROR_FAILED, CallDecode(decoder.get(), &uncalled_cb, NULL));
377 ASSERT_FALSE(uncalled_cb.called());
379 ASSERT_EQ(PP_ERROR_FAILED, CallGetPicture(decoder.get(), NULL, &uncalled_cb));
380 ASSERT_FALSE(uncalled_cb.called());
382 ASSERT_EQ(PP_ERROR_FAILED, CallFlush(decoder.get(), &uncalled_cb));
383 ASSERT_FALSE(uncalled_cb.called());
385 ASSERT_EQ(PP_ERROR_FAILED, CallReset(decoder.get(), &uncalled_cb));
386 ASSERT_FALSE(uncalled_cb.called());
389 // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply
390 // message for GetShm isn't received, causing Decode to fail.
391 // http://crbug.com/379260
392 #if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
393 TEST_F(VideoDecoderResourceTest, DecodeAndGetPicture) {
394 LockingResourceReleaser decoder(CreateAndInitializeDecoder());
395 ResourceMessageCallParams params, params2;
396 MockCompletionCallback decode_cb, get_picture_cb, uncalled_cb;
398 uint32_t shm_id;
399 uint32_t decode_size;
400 int32_t decode_id;
401 // Call Decode until we have the maximum pending, minus one.
402 for (uint32_t i = 0; i < kMaximumPendingDecodes - 1; i++) {
403 PpapiHostMsg_VideoDecoder_GetShm shm_msg(i, kDecodeBufferSize);
404 ASSERT_EQ(PP_OK, CallDecode(decoder.get(), &uncalled_cb, &shm_msg));
405 ASSERT_FALSE(uncalled_cb.called());
406 CheckDecodeMsg(&params, &shm_id, &decode_size, &decode_id);
407 ASSERT_EQ(i, shm_id);
408 ASSERT_EQ(kDecodeBufferSize, decode_size);
409 // The resource generates uids internally, starting at 1.
410 int32_t uid = i + 1;
411 ASSERT_EQ(uid, decode_id);
413 // Once we've allocated the maximum number of buffers, we must wait.
414 PpapiHostMsg_VideoDecoder_GetShm shm_msg(7U, kDecodeBufferSize);
415 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
416 CallDecode(decoder.get(), &decode_cb, &shm_msg));
417 CheckDecodeMsg(&params, &shm_id, &decode_size, &decode_id);
418 ASSERT_EQ(7U, shm_id);
419 ASSERT_EQ(kDecodeBufferSize, decode_size);
421 // Calling Decode when another Decode is pending should fail.
422 ASSERT_EQ(PP_ERROR_INPROGRESS, CallDecode(decoder.get(), &uncalled_cb, NULL));
423 ASSERT_FALSE(uncalled_cb.called());
424 // Free up the first decode buffer.
425 SendDecodeReply(params, 0U);
426 // The decoder should run the pending callback.
427 ASSERT_TRUE(decode_cb.called());
428 ASSERT_EQ(PP_OK, decode_cb.result());
429 decode_cb.Reset();
431 // Now try to get a picture. No picture ready message has been received yet.
432 PP_VideoPicture picture;
433 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
434 CallGetPicture(decoder.get(), &picture, &get_picture_cb));
435 ASSERT_FALSE(get_picture_cb.called());
436 // Calling GetPicture when another GetPicture is pending should fail.
437 ASSERT_EQ(PP_ERROR_INPROGRESS,
438 CallGetPicture(decoder.get(), &picture, &uncalled_cb));
439 ASSERT_FALSE(uncalled_cb.called());
440 // Send 'request textures' message to initialize textures.
441 SendRequestTextures(params);
442 // Send a picture ready message for Decode call 1. The GetPicture callback
443 // should complete.
444 SendPictureReady(params, 1U, kTextureId1);
445 ASSERT_TRUE(get_picture_cb.called());
446 ASSERT_EQ(PP_OK, get_picture_cb.result());
447 ASSERT_EQ(kDecodeId, picture.decode_id);
448 get_picture_cb.Reset();
450 // Send a picture ready message for Decode call 2. Since there is no pending
451 // GetPicture call, the picture should be queued.
452 SendPictureReady(params, 2U, kTextureId2);
453 // The next GetPicture should return synchronously.
454 ASSERT_EQ(PP_OK, CallGetPicture(decoder.get(), &picture, &uncalled_cb));
455 ASSERT_FALSE(uncalled_cb.called());
456 ASSERT_EQ(kDecodeId, picture.decode_id);
458 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
460 // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply
461 // message for GetShm isn't received, causing Decode to fail.
462 // http://crbug.com/379260
463 #if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
464 TEST_F(VideoDecoderResourceTest, RecyclePicture) {
465 LockingResourceReleaser decoder(CreateAndInitializeDecoder());
466 ResourceMessageCallParams params;
467 MockCompletionCallback decode_cb, get_picture_cb, uncalled_cb;
469 // Get to a state where we have a picture to recycle.
470 PpapiHostMsg_VideoDecoder_GetShm shm_msg(0U, kDecodeBufferSize);
471 ASSERT_EQ(PP_OK, CallDecode(decoder.get(), &decode_cb, &shm_msg));
472 uint32_t shm_id;
473 uint32_t decode_size;
474 int32_t decode_id;
475 CheckDecodeMsg(&params, &shm_id, &decode_size, &decode_id);
476 SendDecodeReply(params, 0U);
477 // Send 'request textures' message to initialize textures.
478 SendRequestTextures(params);
479 // Call GetPicture and send 'picture ready' message to get a picture to
480 // recycle.
481 PP_VideoPicture picture;
482 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
483 CallGetPicture(decoder.get(), &picture, &get_picture_cb));
484 SendPictureReady(params, 0U, kTextureId1);
485 ASSERT_EQ(kTextureId1, picture.texture_id);
487 CallRecyclePicture(decoder.get(), picture);
488 uint32_t texture_id;
489 ASSERT_TRUE(CheckRecyclePictureMsg(&params, &texture_id));
490 ASSERT_EQ(kTextureId1, texture_id);
492 ClearCallbacks(decoder.get());
494 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
496 TEST_F(VideoDecoderResourceTest, Flush) {
497 LockingResourceReleaser decoder(CreateAndInitializeDecoder());
498 ResourceMessageCallParams params, params2;
499 MockCompletionCallback flush_cb, get_picture_cb, uncalled_cb;
501 ASSERT_EQ(PP_OK_COMPLETIONPENDING, CallFlush(decoder.get(), &flush_cb));
502 ASSERT_FALSE(flush_cb.called());
503 ASSERT_TRUE(CheckFlushMsg(&params));
505 ASSERT_EQ(PP_ERROR_FAILED, CallDecode(decoder.get(), &uncalled_cb, NULL));
506 ASSERT_FALSE(uncalled_cb.called());
508 // Plugin can call GetPicture while Flush is pending.
509 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
510 CallGetPicture(decoder.get(), NULL, &get_picture_cb));
511 ASSERT_FALSE(get_picture_cb.called());
513 ASSERT_EQ(PP_ERROR_INPROGRESS, CallFlush(decoder.get(), &uncalled_cb));
514 ASSERT_FALSE(uncalled_cb.called());
516 ASSERT_EQ(PP_ERROR_FAILED, CallReset(decoder.get(), &uncalled_cb));
517 ASSERT_FALSE(uncalled_cb.called());
519 // Plugin can call RecyclePicture while Flush is pending.
520 PP_VideoPicture picture;
521 picture.texture_id = kTextureId1;
522 CallRecyclePicture(decoder.get(), picture);
523 uint32_t texture_id;
524 ASSERT_TRUE(CheckRecyclePictureMsg(&params2, &texture_id));
526 SendFlushReply(params);
527 // Any pending GetPicture call is aborted.
528 ASSERT_TRUE(get_picture_cb.called());
529 ASSERT_EQ(PP_ERROR_ABORTED, get_picture_cb.result());
530 ASSERT_TRUE(flush_cb.called());
531 ASSERT_EQ(PP_OK, flush_cb.result());
534 // TODO(bbudge) Test Reset when we can run the message loop to get aborted
535 // callbacks to run.
537 // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply
538 // message for GetShm isn't received, causing Decode to fail.
539 // http://crbug.com/379260
540 #if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
541 TEST_F(VideoDecoderResourceTest, NotifyError) {
542 LockingResourceReleaser decoder(CreateAndInitializeDecoder());
543 ResourceMessageCallParams params;
544 MockCompletionCallback decode_cb, get_picture_cb, uncalled_cb;
546 // Call Decode and GetPicture to have some pending requests.
547 PpapiHostMsg_VideoDecoder_GetShm shm_msg(0U, kDecodeBufferSize);
548 ASSERT_EQ(PP_OK, CallDecode(decoder.get(), &decode_cb, &shm_msg));
549 ASSERT_FALSE(decode_cb.called());
550 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
551 CallGetPicture(decoder.get(), NULL, &get_picture_cb));
552 ASSERT_FALSE(get_picture_cb.called());
554 // Send the decoder resource an unsolicited notify error message. We first
555 // need to initialize 'params' so the message is routed to the decoder.
556 uint32_t shm_id;
557 uint32_t decode_size;
558 int32_t decode_id;
559 CheckDecodeMsg(&params, &shm_id, &decode_size, &decode_id);
560 SendNotifyError(params, PP_ERROR_RESOURCE_FAILED);
562 // Any pending message should be run with the reported error.
563 ASSERT_TRUE(get_picture_cb.called());
564 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, get_picture_cb.result());
566 // All further calls return the reported error.
567 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED,
568 CallDecode(decoder.get(), &uncalled_cb, NULL));
569 ASSERT_FALSE(uncalled_cb.called());
570 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED,
571 CallGetPicture(decoder.get(), NULL, &uncalled_cb));
572 ASSERT_FALSE(uncalled_cb.called());
573 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb));
574 ASSERT_FALSE(uncalled_cb.called());
575 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb));
576 ASSERT_FALSE(uncalled_cb.called());
578 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
580 } // namespace proxy
581 } // namespace ppapi