| Index: ppapi/tests/test_graphics_2d.cc
|
| diff --git a/ppapi/tests/test_graphics_2d.cc b/ppapi/tests/test_graphics_2d.cc
|
| index 4b31c927c02ae7005589196e012d8349b1a212ea..5131cb6279c67db7531cfba3102e71fde7507128 100644
|
| --- a/ppapi/tests/test_graphics_2d.cc
|
| +++ b/ppapi/tests/test_graphics_2d.cc
|
| @@ -19,6 +19,7 @@
|
| #include "ppapi/cpp/instance.h"
|
| #include "ppapi/cpp/module.h"
|
| #include "ppapi/cpp/rect.h"
|
| +#include "ppapi/tests/test_utils.h"
|
| #include "ppapi/tests/testing_instance.h"
|
|
|
| REGISTER_TEST_CASE(Graphics2D);
|
| @@ -89,6 +90,29 @@ bool TestGraphics2D::IsDCUniformColor(const pp::Graphics2D& dc,
|
| return IsSquareInImage(readback, 0, pp::Rect(dc.size()), color);
|
| }
|
|
|
| +bool TestGraphics2D::ResourceHealthCheck(pp::Instance* instance,
|
| + pp::Graphics2D* context) {
|
| + TestCompletionCallback callback(instance->pp_instance(), callback_type());
|
| + callback.WaitForResult(context->Flush(callback));
|
| + if (callback.result() < 0)
|
| + return callback.result() != PP_ERROR_FAILED;
|
| + else if (callback.result() == 0)
|
| + return false;
|
| + return true;
|
| +}
|
| +
|
| +bool TestGraphics2D::ResourceHealthCheckForC(pp::Instance* instance,
|
| + PP_Resource graphics_2d) {
|
| + TestCompletionCallback callback(instance->pp_instance(), callback_type());
|
| + callback.WaitForResult(graphics_2d_interface_->Flush(
|
| + graphics_2d, callback.GetCallback().pp_completion_callback()));
|
| + if (callback.result() < 0)
|
| + return callback.result() != PP_ERROR_FAILED;
|
| + else if (callback.result() == 0)
|
| + return false;
|
| + return true;
|
| +}
|
| +
|
| bool TestGraphics2D::FlushAndWaitForDone(pp::Graphics2D* context) {
|
| int32_t flags = (force_async_ ? 0 : PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
|
| pp::CompletionCallback cc(&FlushCallbackQuitMessageLoop, this, flags);
|
| @@ -260,31 +284,33 @@ std::string TestGraphics2D::TestInvalidResource() {
|
|
|
| std::string TestGraphics2D::TestInvalidSize() {
|
| pp::Graphics2D a(instance_, pp::Size(16, 0), false);
|
| - if (!a.is_null())
|
| + if (ResourceHealthCheck(instance_, &a))
|
| return "0 height accepted";
|
|
|
| pp::Graphics2D b(instance_, pp::Size(0, 16), false);
|
| - if (!b.is_null())
|
| - return "0 width accepted";
|
| + if (ResourceHealthCheck(instance_, &b))
|
| + return "0 height accepted";
|
|
|
| // Need to use the C API since pp::Size prevents negative sizes.
|
| PP_Size size;
|
| size.width = 16;
|
| size.height = -16;
|
| - ASSERT_FALSE(!!graphics_2d_interface_->Create(
|
| - instance_->pp_instance(), &size, PP_FALSE));
|
| + PP_Resource graphics = graphics_2d_interface_->Create(
|
| + instance_->pp_instance(), &size, PP_FALSE);
|
| + ASSERT_FALSE(ResourceHealthCheckForC(instance_, graphics));
|
|
|
| size.width = -16;
|
| size.height = 16;
|
| - ASSERT_FALSE(!!graphics_2d_interface_->Create(
|
| - instance_->pp_instance(), &size, PP_FALSE));
|
| + graphics = graphics_2d_interface_->Create(
|
| + instance_->pp_instance(), &size, PP_FALSE);
|
| + ASSERT_FALSE(ResourceHealthCheckForC(instance_, graphics));
|
|
|
| PASS();
|
| }
|
|
|
| std::string TestGraphics2D::TestHumongous() {
|
| pp::Graphics2D a(instance_, pp::Size(100000, 100000), false);
|
| - if (!a.is_null())
|
| + if (ResourceHealthCheck(instance_, &a))
|
| return "Humongous device created";
|
| PASS();
|
| }
|
|
|