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

Unified Diff: ppapi/tests/test_graphics_2d.cc

Issue 12989006: Move HiDPI-related Pepper interfaces to stable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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
« 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 aea741dac8fcbb7a7222aa2894e5edf7f2649897..14ed49a2a09566de37140c3c9ac3b8c62a033736 100644
--- a/ppapi/tests/test_graphics_2d.cc
+++ b/ppapi/tests/test_graphics_2d.cc
@@ -59,6 +59,7 @@ void TestGraphics2D::RunTests(const std::string& filter) {
RUN_TEST(Humongous, filter);
RUN_TEST(InitToZero, filter);
RUN_TEST(Describe, filter);
+ RUN_TEST(Scale, filter);
RUN_TEST_FORCEASYNC_AND_NOT(Paint, filter);
RUN_TEST_FORCEASYNC_AND_NOT(Scroll, filter);
RUN_TEST_FORCEASYNC_AND_NOT(Replace, filter);
@@ -369,6 +370,44 @@ std::string TestGraphics2D::TestDescribe() {
PASS();
}
+std::string TestGraphics2D::TestScale() {
+ // Tests GetScale/SetScale
+ const int w = 20, h = 16;
+ const float scale = 1.0f/2.0f;
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
+ if (dc.is_null())
+ return "Failure creating a boring device";
+ if (dc.GetScale() != 1.0f)
+ return "GetScale returned unexpected value before SetScale";
+ if (!dc.SetScale(scale))
+ return "SetScale failed";
+ if (dc.GetScale() != scale)
+ return "GetScale mismatch with prior SetScale";
+ // Try setting a few invalid scale factors. Ensure that we catch these errors
+ // and don't change the actual scale
+ if (dc.SetScale(-1.0f))
+ return "SetScale(-1f) did not fail";
+ if (dc.SetScale(0.0f))
+ return "SetScale(0.0f) did not fail";
+ if (dc.GetScale() != scale)
+ return "SetScale with invalid parameter overwrote the scale";
+
+ // Verify that the context has the specified number of pixels, despite the
+ // non-identity scale
+ PP_Size size;
+ size.width = -1;
+ size.height = -1;
+ PP_Bool is_always_opaque = PP_FALSE;
+ if (!graphics_2d_interface_->Describe(dc.pp_resource(), &size,
+ &is_always_opaque))
+ return "Describe failed";
+ if (size.width != w || size.height != h ||
+ is_always_opaque != PP_FromBool(false))
+ return "Mismatch of data.";
+
+ PASS();
+}
+
std::string TestGraphics2D::TestPaint() {
const int w = 15, h = 17;
pp::Graphics2D dc(instance_, pp::Size(w, h), false);
« 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