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

Unified Diff: ppapi/tests/test_graphics_2d.cc

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_graphics_2d.h ('k') | ppapi/thunk/interfaces_ppb_public_stable.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f71b84026ebf054f64d04458862deb62763c6cab 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,40 @@ 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));
+
+ // Overflow to negative size
+ size.width = std::numeric_limits<int32_t>::max();
+ size.height = std::numeric_limits<int32_t>::max();
+ 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();
}
« no previous file with comments | « ppapi/tests/test_graphics_2d.h ('k') | ppapi/thunk/interfaces_ppb_public_stable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698