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

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: Moved constant to shared header, validate min_picture_size now in resource proxy as well as host co… 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
« no previous file with comments | « ppapi/proxy/video_decoder_resource.cc ('k') | ppapi/tests/test_video_decoder.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 <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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 private: 55 private:
56 bool called_; 56 bool called_;
57 int32_t result_; 57 int32_t result_;
58 }; 58 };
59 59
60 class VideoDecoderResourceTest : public PluginProxyTest { 60 class VideoDecoderResourceTest : public PluginProxyTest {
61 public: 61 public:
62 VideoDecoderResourceTest() 62 VideoDecoderResourceTest()
63 : decoder_iface_(thunk::GetPPB_VideoDecoder_1_0_Thunk()) {} 63 : decoder_iface_(thunk::GetPPB_VideoDecoder_1_1_Thunk()) {}
64 64
65 const PPB_VideoDecoder_1_0* decoder_iface() const { return decoder_iface_; } 65 const PPB_VideoDecoder_1_1* decoder_iface() const { return decoder_iface_; }
66 66
67 void SendReply(const ResourceMessageCallParams& params, 67 void SendReply(const ResourceMessageCallParams& params,
68 int32_t result, 68 int32_t result,
69 const IPC::Message& nested_message) { 69 const IPC::Message& nested_message) {
70 ResourceMessageReplyParams reply_params(params.pp_resource(), 70 ResourceMessageReplyParams reply_params(params.pp_resource(),
71 params.sequence()); 71 params.sequence());
72 reply_params.set_result(result); 72 reply_params.set_result(result);
73 PluginMessageFilter::DispatchResourceReplyForTest(reply_params, 73 PluginMessageFilter::DispatchResourceReplyForTest(reply_params,
74 nested_message); 74 nested_message);
75 } 75 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 PP_Resource CreateAndInitializeDecoder() { 113 PP_Resource CreateAndInitializeDecoder() {
114 PP_Resource decoder = CreateDecoder(); 114 PP_Resource decoder = CreateDecoder();
115 LockingResourceReleaser graphics3d(CreateGraphics3d()); 115 LockingResourceReleaser graphics3d(CreateGraphics3d());
116 MockCompletionCallback cb; 116 MockCompletionCallback cb;
117 int32_t result = decoder_iface()->Initialize( 117 int32_t result = decoder_iface()->Initialize(
118 decoder, 118 decoder,
119 graphics3d.get(), 119 graphics3d.get(),
120 PP_VIDEOPROFILE_H264MAIN, 120 PP_VIDEOPROFILE_H264MAIN,
121 PP_HARDWAREACCELERATION_WITHFALLBACK, 121 PP_HARDWAREACCELERATION_WITHFALLBACK,
122 0,
122 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 123 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
123 &cb)); 124 &cb));
124 if (result != PP_OK_COMPLETIONPENDING) 125 if (result != PP_OK_COMPLETIONPENDING)
125 return 0; 126 return 0;
126 ResourceMessageCallParams params; 127 ResourceMessageCallParams params;
127 IPC::Message msg; 128 IPC::Message msg;
128 if (!sink().GetFirstResourceCallMatching( 129 if (!sink().GetFirstResourceCallMatching(
129 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg)) 130 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg))
130 return 0; 131 return 0;
131 sink().ClearMessages(); 132 sink().ClearMessages();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 293
293 private: 294 private:
294 bool CheckMsg(ResourceMessageCallParams* params, int id) { 295 bool CheckMsg(ResourceMessageCallParams* params, int id) {
295 IPC::Message msg; 296 IPC::Message msg;
296 if (!sink().GetFirstResourceCallMatching(id, params, &msg)) 297 if (!sink().GetFirstResourceCallMatching(id, params, &msg))
297 return false; 298 return false;
298 sink().ClearMessages(); 299 sink().ClearMessages();
299 return true; 300 return true;
300 } 301 }
301 302
302 const PPB_VideoDecoder_1_0* decoder_iface_; 303 const PPB_VideoDecoder_1_1* decoder_iface_;
303 304
304 char decode_buffer_[kDecodeBufferSize]; 305 char decode_buffer_[kDecodeBufferSize];
305 }; 306 };
306 307
307 } // namespace 308 } // namespace
308 309
309 TEST_F(VideoDecoderResourceTest, Initialize) { 310 TEST_F(VideoDecoderResourceTest, Initialize) {
310 // Initialize with 0 graphics3d_context should fail. 311 // Initialize with 0 graphics3d_context should fail.
311 { 312 {
312 LockingResourceReleaser decoder(CreateDecoder()); 313 LockingResourceReleaser decoder(CreateDecoder());
313 MockCompletionCallback cb; 314 MockCompletionCallback cb;
314 int32_t result = decoder_iface()->Initialize( 315 int32_t result = decoder_iface()->Initialize(
315 decoder.get(), 316 decoder.get(),
316 0 /* invalid 3d graphics */, 317 0 /* invalid 3d graphics */,
317 PP_VIDEOPROFILE_H264MAIN, 318 PP_VIDEOPROFILE_H264MAIN,
318 PP_HARDWAREACCELERATION_WITHFALLBACK, 319 PP_HARDWAREACCELERATION_WITHFALLBACK,
320 0,
319 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 321 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
320 &cb)); 322 &cb));
321 ASSERT_EQ(PP_ERROR_BADRESOURCE, result); 323 ASSERT_EQ(PP_ERROR_BADRESOURCE, result);
322 } 324 }
323 // Initialize with bad profile value should fail. 325 // Initialize with bad profile value should fail.
324 { 326 {
325 LockingResourceReleaser decoder(CreateDecoder()); 327 LockingResourceReleaser decoder(CreateDecoder());
326 MockCompletionCallback cb; 328 MockCompletionCallback cb;
327 int32_t result = decoder_iface()->Initialize( 329 int32_t result = decoder_iface()->Initialize(
328 decoder.get(), 330 decoder.get(),
329 1 /* non-zero resource */, 331 1 /* non-zero resource */,
330 static_cast<PP_VideoProfile>(-1), 332 static_cast<PP_VideoProfile>(-1),
331 PP_HARDWAREACCELERATION_WITHFALLBACK, 333 PP_HARDWAREACCELERATION_WITHFALLBACK,
334 0,
332 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 335 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
333 &cb)); 336 &cb));
334 ASSERT_EQ(PP_ERROR_BADARGUMENT, result); 337 ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
335 } 338 }
336 // Initialize with valid graphics3d_context and profile should succeed. 339 // Initialize with valid graphics3d_context and profile should succeed.
337 { 340 {
338 LockingResourceReleaser decoder(CreateDecoder()); 341 LockingResourceReleaser decoder(CreateDecoder());
339 LockingResourceReleaser graphics3d(CreateGraphics3d()); 342 LockingResourceReleaser graphics3d(CreateGraphics3d());
340 MockCompletionCallback cb; 343 MockCompletionCallback cb;
341 int32_t result = decoder_iface()->Initialize( 344 int32_t result = decoder_iface()->Initialize(
342 decoder.get(), 345 decoder.get(),
343 graphics3d.get(), 346 graphics3d.get(),
344 PP_VIDEOPROFILE_H264MAIN, 347 PP_VIDEOPROFILE_H264MAIN,
345 PP_HARDWAREACCELERATION_WITHFALLBACK, 348 PP_HARDWAREACCELERATION_WITHFALLBACK,
349 0,
346 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 350 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
347 &cb)); 351 &cb));
348 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); 352 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
349 ASSERT_TRUE(decoder_iface()->IsVideoDecoder(decoder.get())); 353 ASSERT_TRUE(decoder_iface()->IsVideoDecoder(decoder.get()));
350 354
351 // Another attempt while pending should fail. 355 // Another attempt while pending should fail.
352 result = decoder_iface()->Initialize( 356 result = decoder_iface()->Initialize(
353 decoder.get(), 357 decoder.get(),
354 graphics3d.get(), 358 graphics3d.get(),
355 PP_VIDEOPROFILE_H264MAIN, 359 PP_VIDEOPROFILE_H264MAIN,
356 PP_HARDWAREACCELERATION_WITHFALLBACK, 360 PP_HARDWAREACCELERATION_WITHFALLBACK,
361 0,
357 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback, 362 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
358 &cb)); 363 &cb));
359 ASSERT_EQ(PP_ERROR_INPROGRESS, result); 364 ASSERT_EQ(PP_ERROR_INPROGRESS, result);
360 365
361 // Check for host message and send a reply to complete initialization. 366 // Check for host message and send a reply to complete initialization.
362 ResourceMessageCallParams params; 367 ResourceMessageCallParams params;
363 IPC::Message msg; 368 IPC::Message msg;
364 ASSERT_TRUE(sink().GetFirstResourceCallMatching( 369 ASSERT_TRUE(sink().GetFirstResourceCallMatching(
365 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg)); 370 PpapiHostMsg_VideoDecoder_Initialize::ID, &params, &msg));
366 sink().ClearMessages(); 371 sink().ClearMessages();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 ASSERT_FALSE(uncalled_cb.called()); 579 ASSERT_FALSE(uncalled_cb.called());
575 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb)); 580 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb));
576 ASSERT_FALSE(uncalled_cb.called()); 581 ASSERT_FALSE(uncalled_cb.called());
577 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); 582 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb));
578 ASSERT_FALSE(uncalled_cb.called()); 583 ASSERT_FALSE(uncalled_cb.called());
579 } 584 }
580 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 585 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
581 586
582 } // namespace proxy 587 } // namespace proxy
583 } // namespace ppapi 588 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/video_decoder_resource.cc ('k') | ppapi/tests/test_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698