| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 bool CanFlushContext(pp::Instance* instance, pp::Graphics2D* context) { | 28 bool CanFlushContext(pp::Instance* instance, pp::Graphics2D* context) { |
| 29 TestCompletionCallback callback(instance->pp_instance()); | 29 TestCompletionCallback callback(instance->pp_instance()); |
| 30 callback.WaitForResult(context->Flush(callback.GetCallback())); | 30 callback.WaitForResult(context->Flush(callback.GetCallback())); |
| 31 return (callback.result() == PP_OK); | 31 return (callback.result() == PP_OK); |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool CanFlushContextC(pp::Instance* instance, PP_Resource graphics_2d, | 34 bool CanFlushContextC(pp::Instance* instance, PP_Resource graphics_2d, |
| 35 const PPB_Graphics2D_1_1* graphics_2d_if) { | 35 const PPB_Graphics2D_1_2* graphics_2d_if) { |
| 36 TestCompletionCallback callback(instance->pp_instance()); | 36 TestCompletionCallback callback(instance->pp_instance()); |
| 37 callback.WaitForResult(graphics_2d_if->Flush( | 37 callback.WaitForResult(graphics_2d_if->Flush( |
| 38 graphics_2d, callback.GetCallback().pp_completion_callback())); | 38 graphics_2d, callback.GetCallback().pp_completion_callback())); |
| 39 return (callback.result() == PP_OK); | 39 return (callback.result() == PP_OK); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 TestGraphics2D::TestGraphics2D(TestingInstance* instance) | 44 TestGraphics2D::TestGraphics2D(TestingInstance* instance) |
| 45 : TestCase(instance), | 45 : TestCase(instance), |
| 46 is_view_changed_(false), | 46 is_view_changed_(false), |
| 47 post_quit_on_view_changed_(false) { | 47 post_quit_on_view_changed_(false) { |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool TestGraphics2D::Init() { | 50 bool TestGraphics2D::Init() { |
| 51 graphics_2d_interface_ = static_cast<const PPB_Graphics2D*>( | 51 graphics_2d_interface_ = static_cast<const PPB_Graphics2D*>( |
| 52 pp::Module::Get()->GetBrowserInterface(PPB_GRAPHICS_2D_INTERFACE_1_1)); | 52 pp::Module::Get()->GetBrowserInterface(PPB_GRAPHICS_2D_INTERFACE_1_2)); |
| 53 image_data_interface_ = static_cast<const PPB_ImageData*>( | 53 image_data_interface_ = static_cast<const PPB_ImageData*>( |
| 54 pp::Module::Get()->GetBrowserInterface(PPB_IMAGEDATA_INTERFACE_1_0)); | 54 pp::Module::Get()->GetBrowserInterface(PPB_IMAGEDATA_INTERFACE_1_0)); |
| 55 return graphics_2d_interface_ && image_data_interface_ && | 55 return graphics_2d_interface_ && image_data_interface_ && |
| 56 CheckTestingInterface(); | 56 CheckTestingInterface(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void TestGraphics2D::RunTests(const std::string& filter) { | 59 void TestGraphics2D::RunTests(const std::string& filter) { |
| 60 RUN_TEST(InvalidResource, filter); | 60 RUN_TEST(InvalidResource, filter); |
| 61 RUN_TEST(InvalidSize, filter); | 61 RUN_TEST(InvalidSize, filter); |
| 62 RUN_TEST(Humongous, filter); | 62 RUN_TEST(Humongous, filter); |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 pp::Graphics2D dc(instance_, pp::Size(w, h), false); | 796 pp::Graphics2D dc(instance_, pp::Size(w, h), false); |
| 797 ASSERT_FALSE(dc.is_null()); | 797 ASSERT_FALSE(dc.is_null()); |
| 798 ASSERT_TRUE(instance_->BindGraphics(dc)); | 798 ASSERT_TRUE(instance_->BindGraphics(dc)); |
| 799 | 799 |
| 800 ASSERT_TRUE(instance_->BindGraphics(pp::Graphics2D())); | 800 ASSERT_TRUE(instance_->BindGraphics(pp::Graphics2D())); |
| 801 ASSERT_TRUE(instance_->BindGraphics(pp::Graphics3D())); | 801 ASSERT_TRUE(instance_->BindGraphics(pp::Graphics3D())); |
| 802 | 802 |
| 803 PASS(); | 803 PASS(); |
| 804 } | 804 } |
| 805 | 805 |
| OLD | NEW |