| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 10 #include <set> |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 if (!ReadImageData(dc, &image, pp::Point(0, 0))) | 300 if (!ReadImageData(dc, &image, pp::Point(0, 0))) |
| 301 return "Couldn't read image data"; | 301 return "Couldn't read image data"; |
| 302 if (!IsSquareInImage(image, 0, pp::Rect(0, 0, w, h), 0)) | 302 if (!IsSquareInImage(image, 0, pp::Rect(0, 0, w, h), 0)) |
| 303 return "Got a nonzero pixel"; | 303 return "Got a nonzero pixel"; |
| 304 | 304 |
| 305 PASS(); | 305 PASS(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 std::string TestGraphics2D::TestDescribe() { | 308 std::string TestGraphics2D::TestDescribe() { |
| 309 const int w = 15, h = 17; | 309 const int w = 15, h = 17; |
| 310 const bool always_opaque = ::rand() % 2 ? true : false; | 310 const bool always_opaque = (::rand() % 2 == 1); |
| 311 pp::Graphics2D dc(instance_, pp::Size(w, h), always_opaque); | 311 pp::Graphics2D dc(instance_, pp::Size(w, h), always_opaque); |
| 312 if (dc.is_null()) | 312 if (dc.is_null()) |
| 313 return "Failure creating a boring device"; | 313 return "Failure creating a boring device"; |
| 314 | 314 |
| 315 PP_Size size; | 315 PP_Size size; |
| 316 size.width = -1; | 316 size.width = -1; |
| 317 size.height = -1; | 317 size.height = -1; |
| 318 PP_Bool is_always_opaque = PP_FALSE; | 318 PP_Bool is_always_opaque = PP_FALSE; |
| 319 if (!graphics_2d_interface_->Describe(dc.pp_resource(), &size, | 319 if (!graphics_2d_interface_->Describe(dc.pp_resource(), &size, |
| 320 &is_always_opaque)) | 320 &is_always_opaque)) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 if (rv == PP_OK || rv == PP_OK_COMPLETIONPENDING) | 644 if (rv == PP_OK || rv == PP_OK_COMPLETIONPENDING) |
| 645 return "Second flush succeeded before callback ran."; | 645 return "Second flush succeeded before callback ran."; |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 | 648 |
| 649 PASS(); | 649 PASS(); |
| 650 } | 650 } |
| 651 | 651 |
| 652 std::string TestGraphics2D::TestDev() { | 652 std::string TestGraphics2D::TestDev() { |
| 653 // Tests GetScale/SetScale via the Graphics2D_Dev C++ wrapper | 653 // Tests GetScale/SetScale via the Graphics2D_Dev C++ wrapper |
| 654 const int w=20, h=16; | 654 const int w = 20, h = 16; |
| 655 const float scale=1.0f/2.0f; | 655 const float scale = 1.0f/2.0f; |
| 656 pp::Graphics2D dc(instance_, pp::Size(w, h), false); | 656 pp::Graphics2D dc(instance_, pp::Size(w, h), false); |
| 657 if (dc.is_null()) | 657 if (dc.is_null()) |
| 658 return "Failure creating a boring device"; | 658 return "Failure creating a boring device"; |
| 659 pp::Graphics2D_Dev dc_dev(dc); | 659 pp::Graphics2D_Dev dc_dev(dc); |
| 660 if (dc_dev.GetScale() != 1.0f) | 660 if (dc_dev.GetScale() != 1.0f) |
| 661 return "GetScale returned unexpected value before SetScale"; | 661 return "GetScale returned unexpected value before SetScale"; |
| 662 if (!dc_dev.SetScale(scale)) | 662 if (!dc_dev.SetScale(scale)) |
| 663 return "SetScale failed"; | 663 return "SetScale failed"; |
| 664 if (dc_dev.GetScale() != scale) | 664 if (dc_dev.GetScale() != scale) |
| 665 return "GetScale mismatch with prior SetScale"; | 665 return "GetScale mismatch with prior SetScale"; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 722 |
| 723 // Now doing more replace contents should re-use older IDs if the cache is | 723 // Now doing more replace contents should re-use older IDs if the cache is |
| 724 // working. | 724 // working. |
| 725 imageres = ReplaceContentsAndReturnID(&dc, size); | 725 imageres = ReplaceContentsAndReturnID(&dc, size); |
| 726 ASSERT_TRUE(resources.find(imageres) != resources.end()); | 726 ASSERT_TRUE(resources.find(imageres) != resources.end()); |
| 727 imageres = ReplaceContentsAndReturnID(&dc, size); | 727 imageres = ReplaceContentsAndReturnID(&dc, size); |
| 728 ASSERT_TRUE(resources.find(imageres) != resources.end()); | 728 ASSERT_TRUE(resources.find(imageres) != resources.end()); |
| 729 | 729 |
| 730 PASS(); | 730 PASS(); |
| 731 } | 731 } |
| OLD | NEW |