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

Side by Side Diff: ppapi/proxy/video_decoder_resource_unittest.cc

Issue 1207043002: Introduce a client minimum picture pool size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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 <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_video_decoder.h" 10 #include "ppapi/c/ppb_video_decoder.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 private: 53 private:
54 bool called_; 54 bool called_;
55 int32_t result_; 55 int32_t result_;
56 }; 56 };
57 57
58 class VideoDecoderResourceTest : public PluginProxyTest { 58 class VideoDecoderResourceTest : public PluginProxyTest {
59 public: 59 public:
60 VideoDecoderResourceTest() 60 VideoDecoderResourceTest()
61 : decoder_iface_(thunk::GetPPB_VideoDecoder_1_0_Thunk()) {} 61 : decoder_iface_(thunk::GetPPB_VideoDecoder_1_1_Thunk()) {}
62 62
63 const PPB_VideoDecoder_1_0* decoder_iface() const { return decoder_iface_; } 63 const PPB_VideoDecoder_1_1* decoder_iface() const { return decoder_iface_; }
64 64
65 void SendReply(const ResourceMessageCallParams& params, 65 void SendReply(const ResourceMessageCallParams& params,
66 int32_t result, 66 int32_t result,
67 const IPC::Message& nested_message) { 67 const IPC::Message& nested_message) {
68 ResourceMessageReplyParams reply_params(params.pp_resource(), 68 ResourceMessageReplyParams reply_params(params.pp_resource(),
69 params.sequence()); 69 params.sequence());
70 reply_params.set_result(result); 70 reply_params.set_result(result);
71 PluginMessageFilter::DispatchResourceReplyForTest(reply_params, 71 PluginMessageFilter::DispatchResourceReplyForTest(reply_params,
72 nested_message); 72 nested_message);
73 } 73 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 PP_Resource CreateAndInitializeDecoder() { 111 PP_Resource CreateAndInitializeDecoder() {
112 PP_Resource decoder = CreateDecoder(); 112 PP_Resource decoder = CreateDecoder();
113 LockingResourceReleaser graphics3d(CreateGraphics3d()); 113 LockingResourceReleaser graphics3d(CreateGraphics3d());
114 MockCompletionCallback cb; 114 MockCompletionCallback cb;
115 int32_t result = decoder_iface()->Initialize( 115 int32_t result = decoder_iface()->Initialize(
116 decoder, 116 decoder,
117 graphics3d.get(), 117 graphics3d.get(),
118 PP_VIDEOPROFILE_H264MAIN, 118 PP_VIDEOPROFILE_H264MAIN,
119 PP_HARDWAREACCELERATION_WITHFALLBACK, 119 PP_HARDWAREACCELERATION_WITHFALLBACK,
120 0,
120 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 121 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
121 &cb)); 122 &cb));
122 if (result != PP_OK_COMPLETIONPENDING) 123 if (result != PP_OK_COMPLETIONPENDING)
123 return 0; 124 return 0;
124 ResourceMessageCallParams params; 125 ResourceMessageCallParams params;
125 IPC::Message msg; 126 IPC::Message msg;
126 if (!sink().GetFirstResourceCallMatching( 127 if (!sink().GetFirstResourceCallMatching(
127 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg)) 128 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg))
128 return 0; 129 return 0;
129 sink().ClearMessages(); 130 sink().ClearMessages();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 private: 292 private:
292 bool CheckMsg(ResourceMessageCallParams* params, int id) { 293 bool CheckMsg(ResourceMessageCallParams* params, int id) {
293 IPC::Message msg; 294 IPC::Message msg;
294 if (!sink().GetFirstResourceCallMatching(id, params, &msg)) 295 if (!sink().GetFirstResourceCallMatching(id, params, &msg))
295 return false; 296 return false;
296 sink().ClearMessages(); 297 sink().ClearMessages();
297 return true; 298 return true;
298 } 299 }
299 300
300 const PPB_VideoDecoder_1_0* decoder_iface_; 301 const PPB_VideoDecoder_1_1* decoder_iface_;
301 302
302 char decode_buffer_[kDecodeBufferSize]; 303 char decode_buffer_[kDecodeBufferSize];
303 }; 304 };
304 305
305 } // namespace 306 } // namespace
306 307
307 TEST_F(VideoDecoderResourceTest, Initialize) { 308 TEST_F(VideoDecoderResourceTest, Initialize) {
308 // Initialize with 0 graphics3d_context should fail. 309 // Initialize with 0 graphics3d_context should fail.
309 { 310 {
310 LockingResourceReleaser decoder(CreateDecoder()); 311 LockingResourceReleaser decoder(CreateDecoder());
311 MockCompletionCallback cb; 312 MockCompletionCallback cb;
312 int32_t result = decoder_iface()->Initialize( 313 int32_t result = decoder_iface()->Initialize(
313 decoder.get(), 314 decoder.get(),
314 0 /* invalid 3d graphics */, 315 0 /* invalid 3d graphics */,
315 PP_VIDEOPROFILE_H264MAIN, 316 PP_VIDEOPROFILE_H264MAIN,
316 PP_HARDWAREACCELERATION_WITHFALLBACK, 317 PP_HARDWAREACCELERATION_WITHFALLBACK,
318 0,
317 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 319 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
318 &cb)); 320 &cb));
319 ASSERT_EQ(PP_ERROR_BADRESOURCE, result); 321 ASSERT_EQ(PP_ERROR_BADRESOURCE, result);
320 } 322 }
321 // Initialize with bad profile value should fail. 323 // Initialize with bad profile value should fail.
322 { 324 {
323 LockingResourceReleaser decoder(CreateDecoder()); 325 LockingResourceReleaser decoder(CreateDecoder());
324 MockCompletionCallback cb; 326 MockCompletionCallback cb;
325 int32_t result = decoder_iface()->Initialize( 327 int32_t result = decoder_iface()->Initialize(
326 decoder.get(), 328 decoder.get(),
327 1 /* non-zero resource */, 329 1 /* non-zero resource */,
328 static_cast<PP_VideoProfile>(-1), 330 static_cast<PP_VideoProfile>(-1),
329 PP_HARDWAREACCELERATION_WITHFALLBACK, 331 PP_HARDWAREACCELERATION_WITHFALLBACK,
332 0,
330 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 333 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
331 &cb)); 334 &cb));
332 ASSERT_EQ(PP_ERROR_BADARGUMENT, result); 335 ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
333 } 336 }
334 // Initialize with valid graphics3d_context and profile should succeed. 337 // Initialize with valid graphics3d_context and profile should succeed.
335 { 338 {
336 LockingResourceReleaser decoder(CreateDecoder()); 339 LockingResourceReleaser decoder(CreateDecoder());
337 LockingResourceReleaser graphics3d(CreateGraphics3d()); 340 LockingResourceReleaser graphics3d(CreateGraphics3d());
338 MockCompletionCallback cb; 341 MockCompletionCallback cb;
339 int32_t result = decoder_iface()->Initialize( 342 int32_t result = decoder_iface()->Initialize(
340 decoder.get(), 343 decoder.get(),
341 graphics3d.get(), 344 graphics3d.get(),
342 PP_VIDEOPROFILE_H264MAIN, 345 PP_VIDEOPROFILE_H264MAIN,
343 PP_HARDWAREACCELERATION_WITHFALLBACK, 346 PP_HARDWAREACCELERATION_WITHFALLBACK,
347 0,
344 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 348 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
345 &cb)); 349 &cb));
346 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 350 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
347 ASSERT_TRUE(decoder_iface()->IsVideoDecoder(decoder.get())); 351 ASSERT_TRUE(decoder_iface()->IsVideoDecoder(decoder.get()));
348 352
349 // Another attempt while pending should fail. 353 // Another attempt while pending should fail.
350 result = decoder_iface()->Initialize( 354 result = decoder_iface()->Initialize(
351 decoder.get(), 355 decoder.get(),
352 graphics3d.get(), 356 graphics3d.get(),
353 PP_VIDEOPROFILE_H264MAIN, 357 PP_VIDEOPROFILE_H264MAIN,
354 PP_HARDWAREACCELERATION_WITHFALLBACK, 358 PP_HARDWAREACCELERATION_WITHFALLBACK,
359 0,
355 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 360 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
356 &cb)); 361 &cb));
357 ASSERT_EQ(PP_ERROR_INPROGRESS, result); 362 ASSERT_EQ(PP_ERROR_INPROGRESS, result);
358 363
359 // Check for host message and send a reply to complete initialization. 364 // Check for host message and send a reply to complete initialization.
360 ResourceMessageCallParams params; 365 ResourceMessageCallParams params;
361 IPC::Message msg; 366 IPC::Message msg;
362 ASSERT_TRUE(sink().GetFirstResourceCallMatching( 367 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
363 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg)); 368 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg));
364 sink().ClearMessages(); 369 sink().ClearMessages();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 ASSERT_FALSE(uncalled_cb.called()); 577 ASSERT_FALSE(uncalled_cb.called());
573 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb)); 578 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb));
574 ASSERT_FALSE(uncalled_cb.called()); 579 ASSERT_FALSE(uncalled_cb.called());
575 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); 580 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb));
576 ASSERT_FALSE(uncalled_cb.called()); 581 ASSERT_FALSE(uncalled_cb.called());
577 } 582 }
578 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 583 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
579 584
580 } // namespace proxy 585 } // namespace proxy
581 } // namespace ppapi 586 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698