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

Side by Side Diff: tests/CanvasTest.cpp

Issue 340403003: SaveFlags be-gone (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: One more baseurl attempt Created 6 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
« no previous file with comments | « src/utils/debugger/SkObjectParser.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(kTestText.c_str(), 360 SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(kTestText.c_str(),
361 kTestText.size(), kTestPath, &kTestMatrix, kTestPaint)); 361 kTestText.size(), kTestPath, &kTestMatrix, kTestPaint));
362 SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size())); 362 SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size()));
363 SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(kTestText.c_str())); 363 SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(kTestText.c_str()));
364 SIMPLE_TEST_STEP(AddComment, addComment(kTestText.c_str(), kTestText.c_str())); 364 SIMPLE_TEST_STEP(AddComment, addComment(kTestText.c_str(), kTestText.c_str()));
365 SIMPLE_TEST_STEP(EndGroup, endCommentGroup()); 365 SIMPLE_TEST_STEP(EndGroup, endCommentGroup());
366 366
367 /////////////////////////////////////////////////////////////////////////////// 367 ///////////////////////////////////////////////////////////////////////////////
368 // Complex test steps 368 // Complex test steps
369 369
370 // Save/restore calls cannot be in isolated simple test steps because the test
371 // cases that use SkPicture require that save and restore calls be balanced.
372 static void SaveMatrixStep(SkCanvas* canvas,
373 skiatest::Reporter* reporter,
374 CanvasTestStep* testStep) {
375 int saveCount = canvas->getSaveCount();
376 canvas->save(SkCanvas::kMatrix_SaveFlag);
377 canvas->clipRegion(kTestRegion);
378 canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
379 canvas->restore();
380 REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount,
381 testStep->assertMessage());
382 REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalMatrix().isIdentity(),
383 testStep->assertMessage());
384 // REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() == kTestRegion, t estStep->assertMessage());
385 }
386 TEST_STEP(SaveMatrix, SaveMatrixStep);
387
388 static void SaveClipStep(SkCanvas* canvas,
389 skiatest::Reporter* reporter,
390 CanvasTestStep* testStep) {
391 int saveCount = canvas->getSaveCount();
392 canvas->save(SkCanvas::kClip_SaveFlag);
393 canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
394 canvas->clipRegion(kTestRegion);
395 canvas->restore();
396 REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount,
397 testStep->assertMessage());
398 REPORTER_ASSERT_MESSAGE(reporter, !canvas->getTotalMatrix().isIdentity(),
399 testStep->assertMessage());
400 // REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion, t estStep->assertMessage());
401 }
402 TEST_STEP(SaveClip, SaveClipStep);
403
404 static void SaveMatrixClipStep(SkCanvas* canvas, 370 static void SaveMatrixClipStep(SkCanvas* canvas,
405 skiatest::Reporter* reporter, 371 skiatest::Reporter* reporter,
406 CanvasTestStep* testStep) { 372 CanvasTestStep* testStep) {
407 int saveCount = canvas->getSaveCount(); 373 int saveCount = canvas->getSaveCount();
408 canvas->save(SkCanvas::kMatrixClip_SaveFlag); 374 canvas->save();
409 canvas->translate(SkIntToScalar(1), SkIntToScalar(2)); 375 canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
410 canvas->clipRegion(kTestRegion); 376 canvas->clipRegion(kTestRegion);
411 canvas->restore(); 377 canvas->restore();
412 REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount, 378 REPORTER_ASSERT_MESSAGE(reporter, canvas->getSaveCount() == saveCount,
413 testStep->assertMessage()); 379 testStep->assertMessage());
414 REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalMatrix().isIdentity(), 380 REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalMatrix().isIdentity(),
415 testStep->assertMessage()); 381 testStep->assertMessage());
416 // REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion, t estStep->assertMessage()); 382 // REPORTER_ASSERT_MESSAGE(reporter, canvas->getTotalClip() != kTestRegion, t estStep->assertMessage());
417 } 383 }
418 TEST_STEP(SaveMatrixClip, SaveMatrixClipStep); 384 TEST_STEP(SaveMatrixClip, SaveMatrixClipStep);
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 if (testStepArray()[testStep]->enablePdfTesting()) { 910 if (testStepArray()[testStep]->enablePdfTesting()) {
945 TestPdfDevice(reporter, testStepArray()[testStep]); 911 TestPdfDevice(reporter, testStepArray()[testStep]);
946 } 912 }
947 } 913 }
948 914
949 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global) 915 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global)
950 kTestBitmap.reset(); 916 kTestBitmap.reset();
951 917
952 test_newraster(reporter); 918 test_newraster(reporter);
953 } 919 }
OLDNEW
« no previous file with comments | « src/utils/debugger/SkObjectParser.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698