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

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 upstream Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/tests/test_graphics_2d.cc
diff --git a/ppapi/tests/test_graphics_2d.cc b/ppapi/tests/test_graphics_2d.cc
index 3418b1a716b917e2499fed5db4fe9efcdfd733a0..4431bc6f82672b2697d148ba6bbdf4915a4a09de 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();
}

Powered by Google App Engine
This is Rietveld 408576698