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

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

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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_c_includes.c ('k') | ppapi/tests/test_image_data.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string.h> 7 #include <string.h>
8 8
9 #include "ppapi/c/dev/ppb_testing_dev.h" 9 #include "ppapi/c/dev/ppb_testing_dev.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/c/ppb_graphics_2d.h" 11 #include "ppapi/c/ppb_graphics_2d.h"
12 #include "ppapi/cpp/common.h"
12 #include "ppapi/cpp/completion_callback.h" 13 #include "ppapi/cpp/completion_callback.h"
13 #include "ppapi/cpp/graphics_2d.h" 14 #include "ppapi/cpp/graphics_2d.h"
14 #include "ppapi/cpp/image_data.h" 15 #include "ppapi/cpp/image_data.h"
15 #include "ppapi/cpp/instance.h" 16 #include "ppapi/cpp/instance.h"
16 #include "ppapi/cpp/module.h" 17 #include "ppapi/cpp/module.h"
17 #include "ppapi/cpp/rect.h" 18 #include "ppapi/cpp/rect.h"
18 #include "ppapi/tests/testing_instance.h" 19 #include "ppapi/tests/testing_instance.h"
19 20
20 REGISTER_TEST_CASE(Graphics2D); 21 REGISTER_TEST_CASE(Graphics2D);
21 22
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 instance_->LogTest("Flush", TestFlush()); 62 instance_->LogTest("Flush", TestFlush());
62 } 63 }
63 64
64 void TestGraphics2D::QuitMessageLoop() { 65 void TestGraphics2D::QuitMessageLoop() {
65 testing_interface_->QuitMessageLoop(); 66 testing_interface_->QuitMessageLoop();
66 } 67 }
67 68
68 bool TestGraphics2D::ReadImageData(const pp::Graphics2D& dc, 69 bool TestGraphics2D::ReadImageData(const pp::Graphics2D& dc,
69 pp::ImageData* image, 70 pp::ImageData* image,
70 const pp::Point& top_left) const { 71 const pp::Point& top_left) const {
71 return testing_interface_->ReadImageData(dc.pp_resource(), 72 return pp::PPBoolToBool(testing_interface_->ReadImageData(
72 image->pp_resource(), 73 dc.pp_resource(),
73 &top_left.pp_point()); 74 image->pp_resource(),
75 &top_left.pp_point()));
74 } 76 }
75 77
76 bool TestGraphics2D::IsDCUniformColor(const pp::Graphics2D& dc, 78 bool TestGraphics2D::IsDCUniformColor(const pp::Graphics2D& dc,
77 uint32_t color) const { 79 uint32_t color) const {
78 pp::ImageData readback(PP_IMAGEDATAFORMAT_BGRA_PREMUL, 80 pp::ImageData readback(PP_IMAGEDATAFORMAT_BGRA_PREMUL,
79 dc.size(), false); 81 dc.size(), false);
80 if (readback.is_null()) 82 if (readback.is_null())
81 return false; 83 return false;
82 if (!ReadImageData(dc, &readback, pp::Point(0, 0))) 84 if (!ReadImageData(dc, &readback, pp::Point(0, 0)))
83 return false; 85 return false;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 176 }
175 177
176 // Test all the functions with an invalid handle. Most of these just check for 178 // Test all the functions with an invalid handle. Most of these just check for
177 // a crash since the browser don't return a value. 179 // a crash since the browser don't return a value.
178 std::string TestGraphics2D::TestInvalidResource() { 180 std::string TestGraphics2D::TestInvalidResource() {
179 pp::Graphics2D null_context; 181 pp::Graphics2D null_context;
180 pp::ImageData image(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(16, 16), true); 182 pp::ImageData image(PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp::Size(16, 16), true);
181 183
182 // Describe. 184 // Describe.
183 PP_Size size; 185 PP_Size size;
184 bool opaque; 186 PP_Bool opaque;
185 graphics_2d_interface_->Describe(image.pp_resource(), &size, &opaque); 187 graphics_2d_interface_->Describe(image.pp_resource(), &size, &opaque);
186 graphics_2d_interface_->Describe(null_context.pp_resource(), 188 graphics_2d_interface_->Describe(null_context.pp_resource(),
187 &size, &opaque); 189 &size, &opaque);
188 190
189 // PaintImageData. 191 // PaintImageData.
190 PP_Point zero_zero; 192 PP_Point zero_zero;
191 zero_zero.x = 0; 193 zero_zero.x = 0;
192 zero_zero.y = 0; 194 zero_zero.y = 0;
193 graphics_2d_interface_->PaintImageData(image.pp_resource(), 195 graphics_2d_interface_->PaintImageData(image.pp_resource(),
194 image.pp_resource(), 196 image.pp_resource(),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 243
242 pp::Graphics2D b(pp::Size(0, 16), false); 244 pp::Graphics2D b(pp::Size(0, 16), false);
243 if (!b.is_null()) 245 if (!b.is_null())
244 return "0 width accepted"; 246 return "0 width accepted";
245 247
246 // Need to use the C API since pp::Size prevents negative sizes. 248 // Need to use the C API since pp::Size prevents negative sizes.
247 PP_Size size; 249 PP_Size size;
248 size.width = 16; 250 size.width = 16;
249 size.height = -16; 251 size.height = -16;
250 ASSERT_FALSE(!!graphics_2d_interface_->Create( 252 ASSERT_FALSE(!!graphics_2d_interface_->Create(
251 pp::Module::Get()->pp_module(), &size, false)); 253 pp::Module::Get()->pp_module(), &size, PP_FALSE));
252 254
253 size.width = -16; 255 size.width = -16;
254 size.height = 16; 256 size.height = 16;
255 ASSERT_FALSE(!!graphics_2d_interface_->Create( 257 ASSERT_FALSE(!!graphics_2d_interface_->Create(
256 pp::Module::Get()->pp_module(), &size, false)); 258 pp::Module::Get()->pp_module(), &size, PP_FALSE));
257 259
258 return ""; 260 return "";
259 } 261 }
260 262
261 std::string TestGraphics2D::TestHumongous() { 263 std::string TestGraphics2D::TestHumongous() {
262 pp::Graphics2D a(pp::Size(100000, 100000), false); 264 pp::Graphics2D a(pp::Size(100000, 100000), false);
263 if (!a.is_null()) 265 if (!a.is_null())
264 return "Humongous device created"; 266 return "Humongous device created";
265 return ""; 267 return "";
266 } 268 }
(...skipping 22 matching lines...) Expand all
289 291
290 std::string TestGraphics2D::TestDescribe() { 292 std::string TestGraphics2D::TestDescribe() {
291 const int w = 15, h = 17; 293 const int w = 15, h = 17;
292 pp::Graphics2D dc(pp::Size(w, h), false); 294 pp::Graphics2D dc(pp::Size(w, h), false);
293 if (dc.is_null()) 295 if (dc.is_null())
294 return "Failure creating a boring device"; 296 return "Failure creating a boring device";
295 297
296 PP_Size size; 298 PP_Size size;
297 size.width = -1; 299 size.width = -1;
298 size.height = -1; 300 size.height = -1;
299 bool is_always_opaque = true; 301 PP_Bool is_always_opaque = PP_TRUE;
300 if (!graphics_2d_interface_->Describe(dc.pp_resource(), &size, 302 if (!graphics_2d_interface_->Describe(dc.pp_resource(), &size,
301 &is_always_opaque)) 303 &is_always_opaque))
302 return "Describe failed"; 304 return "Describe failed";
303 if (size.width != w || size.height != h || is_always_opaque != false) 305 if (size.width != w || size.height != h || is_always_opaque != PP_FALSE)
304 return "Mismatch of data."; 306 return "Mismatch of data.";
305 307
306 return ""; 308 return "";
307 } 309 }
308 310
309 std::string TestGraphics2D::TestPaint() { 311 std::string TestGraphics2D::TestPaint() {
310 const int w = 15, h = 17; 312 const int w = 15, h = 17;
311 pp::Graphics2D dc(pp::Size(w, h), false); 313 pp::Graphics2D dc(pp::Size(w, h), false);
312 if (dc.is_null()) 314 if (dc.is_null())
313 return "Failure creating a boring device"; 315 return "Failure creating a boring device";
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 535
534 if (rv != PP_OK) { 536 if (rv != PP_OK) {
535 // If the first flush would block, then a second should fail. 537 // If the first flush would block, then a second should fail.
536 rv = dc_nopaints.Flush(pp::CompletionCallback(&FlushCallbackNOP, NULL)); 538 rv = dc_nopaints.Flush(pp::CompletionCallback(&FlushCallbackNOP, NULL));
537 if (rv == PP_OK || rv == PP_ERROR_WOULDBLOCK) 539 if (rv == PP_OK || rv == PP_ERROR_WOULDBLOCK)
538 return "Second flush succeeded before callback ran."; 540 return "Second flush succeeded before callback ran.";
539 } 541 }
540 542
541 return ""; 543 return "";
542 } 544 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_c_includes.c ('k') | ppapi/tests/test_image_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698