OLD | NEW |
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_image_data.h" | 5 #include "ppapi/tests/test_image_data.h" |
6 | 6 |
7 #include "ppapi/cpp/graphics_2d.h" | 7 #include "ppapi/cpp/graphics_2d.h" |
8 #include "ppapi/cpp/image_data.h" | 8 #include "ppapi/cpp/image_data.h" |
9 #include "ppapi/cpp/instance.h" | 9 #include "ppapi/cpp/instance.h" |
10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
11 #include "ppapi/tests/testing_instance.h" | 11 #include "ppapi/tests/testing_instance.h" |
12 | 12 |
13 REGISTER_TEST_CASE(ImageData); | 13 REGISTER_TEST_CASE(ImageData); |
14 | 14 |
15 bool TestImageData::Init() { | 15 bool TestImageData::Init() { |
16 image_data_interface_ = reinterpret_cast<PPB_ImageData const*>( | 16 image_data_interface_ = reinterpret_cast<PPB_ImageData const*>( |
17 pp::Module::Get()->GetBrowserInterface(PPB_IMAGEDATA_INTERFACE)); | 17 pp::Module::Get()->GetBrowserInterface(PPB_IMAGEDATA_INTERFACE)); |
18 return !!image_data_interface_; | 18 return !!image_data_interface_; |
19 } | 19 } |
20 | 20 |
21 void TestImageData::RunTest() { | 21 void TestImageData::RunTests(const std::string& filter) { |
22 instance_->LogTest("InvalidFormat", TestInvalidFormat()); | 22 instance_->LogTest("InvalidFormat", TestInvalidFormat()); |
23 instance_->LogTest("InvalidSize", TestInvalidSize()); | 23 instance_->LogTest("InvalidSize", TestInvalidSize()); |
24 instance_->LogTest("HugeSize", TestHugeSize()); | 24 instance_->LogTest("HugeSize", TestHugeSize()); |
25 instance_->LogTest("InitToZero", TestInitToZero()); | 25 instance_->LogTest("InitToZero", TestInitToZero()); |
26 instance_->LogTest("IsImageData", TestIsImageData()); | 26 instance_->LogTest("IsImageData", TestIsImageData()); |
27 } | 27 } |
28 | 28 |
29 std::string TestImageData::TestInvalidFormat() { | 29 std::string TestImageData::TestInvalidFormat() { |
30 pp::ImageData a(instance_, static_cast<PP_ImageDataFormat>(1337), | 30 pp::ImageData a(instance_, static_cast<PP_ImageDataFormat>(1337), |
31 pp::Size(16, 16), true); | 31 pp::Size(16, 16), true); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Make a valid image resource. | 133 // Make a valid image resource. |
134 pp::ImageData img(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL, | 134 pp::ImageData img(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL, |
135 pp::Size(w, h), true); | 135 pp::Size(w, h), true); |
136 if (img.is_null()) | 136 if (img.is_null()) |
137 return "Couldn't create image data"; | 137 return "Couldn't create image data"; |
138 if (!image_data_interface_->IsImageData(img.pp_resource())) | 138 if (!image_data_interface_->IsImageData(img.pp_resource())) |
139 return "Image data should be identified as an image"; | 139 return "Image data should be identified as an image"; |
140 | 140 |
141 PASS(); | 141 PASS(); |
142 } | 142 } |
OLD | NEW |