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

Side by Side Diff: ppapi/tests/test_graphics_2d.cc

Issue 10544168: Implement HiDPI support in Pepper dev interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_graphics_2d.h ('k') | ppapi/thunk/interfaces_ppb_public_dev.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ppapi/tests/test_graphics_2d.h" 5 #include "ppapi/tests/test_graphics_2d.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "ppapi/c/dev/ppb_testing_dev.h" 10 #include "ppapi/c/dev/ppb_testing_dev.h"
11 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/ppb_graphics_2d.h" 12 #include "ppapi/c/ppb_graphics_2d.h"
13 #include "ppapi/cpp/completion_callback.h" 13 #include "ppapi/cpp/completion_callback.h"
14 #include "ppapi/cpp/dev/graphics_2d_dev.h"
14 #include "ppapi/cpp/graphics_2d.h" 15 #include "ppapi/cpp/graphics_2d.h"
15 #include "ppapi/cpp/image_data.h" 16 #include "ppapi/cpp/image_data.h"
16 #include "ppapi/cpp/instance.h" 17 #include "ppapi/cpp/instance.h"
17 #include "ppapi/cpp/module.h" 18 #include "ppapi/cpp/module.h"
18 #include "ppapi/cpp/rect.h" 19 #include "ppapi/cpp/rect.h"
19 #include "ppapi/tests/testing_instance.h" 20 #include "ppapi/tests/testing_instance.h"
20 21
21 REGISTER_TEST_CASE(Graphics2D); 22 REGISTER_TEST_CASE(Graphics2D);
22 23
23 namespace { 24 namespace {
(...skipping 20 matching lines...) Expand all
44 void TestGraphics2D::RunTests(const std::string& filter) { 45 void TestGraphics2D::RunTests(const std::string& filter) {
45 RUN_TEST(InvalidResource, filter); 46 RUN_TEST(InvalidResource, filter);
46 RUN_TEST(InvalidSize, filter); 47 RUN_TEST(InvalidSize, filter);
47 RUN_TEST(Humongous, filter); 48 RUN_TEST(Humongous, filter);
48 RUN_TEST(InitToZero, filter); 49 RUN_TEST(InitToZero, filter);
49 RUN_TEST(Describe, filter); 50 RUN_TEST(Describe, filter);
50 RUN_TEST_FORCEASYNC_AND_NOT(Paint, filter); 51 RUN_TEST_FORCEASYNC_AND_NOT(Paint, filter);
51 RUN_TEST_FORCEASYNC_AND_NOT(Scroll, filter); 52 RUN_TEST_FORCEASYNC_AND_NOT(Scroll, filter);
52 RUN_TEST_FORCEASYNC_AND_NOT(Replace, filter); 53 RUN_TEST_FORCEASYNC_AND_NOT(Replace, filter);
53 RUN_TEST_FORCEASYNC_AND_NOT(Flush, filter); 54 RUN_TEST_FORCEASYNC_AND_NOT(Flush, filter);
55 RUN_TEST(Dev, filter);
54 } 56 }
55 57
56 void TestGraphics2D::QuitMessageLoop() { 58 void TestGraphics2D::QuitMessageLoop() {
57 testing_interface_->QuitMessageLoop(instance_->pp_instance()); 59 testing_interface_->QuitMessageLoop(instance_->pp_instance());
58 } 60 }
59 61
60 bool TestGraphics2D::ReadImageData(const pp::Graphics2D& dc, 62 bool TestGraphics2D::ReadImageData(const pp::Graphics2D& dc,
61 pp::ImageData* image, 63 pp::ImageData* image,
62 const pp::Point& top_left) const { 64 const pp::Point& top_left) const {
63 return PP_ToBool(testing_interface_->ReadImageData( 65 return PP_ToBool(testing_interface_->ReadImageData(
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if (rv != PP_OK_COMPLETIONPENDING) 623 if (rv != PP_OK_COMPLETIONPENDING)
622 return "Second flush must fail asynchronously."; 624 return "Second flush must fail asynchronously.";
623 } else { 625 } else {
624 if (rv == PP_OK || rv == PP_OK_COMPLETIONPENDING) 626 if (rv == PP_OK || rv == PP_OK_COMPLETIONPENDING)
625 return "Second flush succeeded before callback ran."; 627 return "Second flush succeeded before callback ran.";
626 } 628 }
627 } 629 }
628 630
629 PASS(); 631 PASS();
630 } 632 }
633
634 std::string TestGraphics2D::TestDev() {
635 // Tests GetScale/SetScale via the Graphics2DDev C++ wrapper
636 const int w=20, h=16;
637 const float scale=1.0f/2.0f;
638 pp::Graphics2D dc(instance_, pp::Size(w, h), false);
639 if (dc.is_null())
640 return "Failure creating a boring device";
641 pp::Graphics2DDev dc_dev(dc);
642 if (dc_dev.GetScale() != 1.0f)
643 return "GetScale returned unexpected value before SetScale";
644 if (!dc_dev.SetScale(scale))
645 return "SetScale failed";
646 if (dc_dev.GetScale() != scale)
647 return "GetScale mismatch with prior SetScale";
648 // Try setting a few invalid scale factors. Ensure that we catch these errors
649 // and don't change the actual scale
650 if (dc_dev.SetScale(-1.0f))
651 return "SetScale(-1f) did not fail";
652 if (dc_dev.SetScale(0.0f))
653 return "SetScale(0.0f) did not fail";
654 if (dc_dev.GetScale() != scale)
655 return "SetScale with invalid parameter overwrote the scale";
656
657 // Verify that the context has the specified number of pixels, despite the
658 // non-identity scale
659 PP_Size size;
660 size.width = -1;
661 size.height = -1;
662 PP_Bool is_always_opaque = PP_FALSE;
663 if (!graphics_2d_interface_->Describe(dc_dev.pp_resource(), &size,
664 &is_always_opaque))
665 return "Describe failed";
666 if (size.width != w || size.height != h ||
667 is_always_opaque != PP_FromBool(false))
668 return "Mismatch of data.";
669
670 PASS();
671 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_graphics_2d.h ('k') | ppapi/thunk/interfaces_ppb_public_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698