aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/CanvasTest.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-20 15:57:27 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-20 15:57:27 -0700
commita814000cbb0e90624a410b4359fff7f3ec66f0e0 (patch)
tree6b296b486fdc3e21769e5f2dd45f801d9253ca2b /tests/CanvasTest.cpp
parent9bc22351b59a77d9cafb0bccf69aac84425a7503 (diff)
Hide SkCanvas::LayerIter
Diffstat (limited to 'tests/CanvasTest.cpp')
-rw-r--r--tests/CanvasTest.cpp59
1 files changed, 37 insertions, 22 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 02b875eb42..284e3cdedb 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -46,7 +46,6 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkClipStack.h"
-#include "SkDevice.h"
#include "SkDocument.h"
#include "SkMatrix.h"
#include "SkNWayCanvas.h"
@@ -498,6 +497,40 @@ static void NestedSaveRestoreWithFlushTestStep(SkCanvas* canvas, const TestData&
}
TEST_STEP(NestedSaveRestoreWithFlush, NestedSaveRestoreWithFlushTestStep);
+class CanvasTestingAccess {
+public:
+ static bool SameState(const SkCanvas* canvas1, const SkCanvas* canvas2) {
+ SkCanvas::LayerIter layerIter1(const_cast<SkCanvas*>(canvas1), false);
+ SkCanvas::LayerIter layerIter2(const_cast<SkCanvas*>(canvas2), false);
+ while (!layerIter1.done() && !layerIter2.done()) {
+ if (layerIter1.matrix() != layerIter2.matrix()) {
+ return false;
+ }
+ if (layerIter1.clip() != layerIter2.clip()) {
+ return false;
+ }
+ if (layerIter1.paint() != layerIter2.paint()) {
+ return false;
+ }
+ if (layerIter1.x() != layerIter2.x()) {
+ return false;
+ }
+ if (layerIter1.y() != layerIter2.y()) {
+ return false;
+ }
+ layerIter1.next();
+ layerIter2.next();
+ }
+ if (!layerIter1.done()) {
+ return false;
+ }
+ if (!layerIter2.done()) {
+ return false;
+ }
+ return true;
+ }
+};
+
static void AssertCanvasStatesEqual(skiatest::Reporter* reporter, const TestData& d,
const SkCanvas* canvas1, const SkCanvas* canvas2,
CanvasTestStep* testStep) {
@@ -528,27 +561,9 @@ static void AssertCanvasStatesEqual(skiatest::Reporter* reporter, const TestData
canvas2->getTotalMatrix(), testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, equal_clips(*canvas1, *canvas2), testStep->assertMessage());
- SkCanvas::LayerIter layerIter1(const_cast<SkCanvas*>(canvas1), false);
- SkCanvas::LayerIter layerIter2(const_cast<SkCanvas*>(canvas2), false);
- while (!layerIter1.done() && !layerIter2.done()) {
- REPORTER_ASSERT_MESSAGE(reporter, layerIter1.matrix() ==
- layerIter2.matrix(), testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, layerIter1.clip() ==
- layerIter2.clip(), testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, layerIter1.paint() ==
- layerIter2.paint(), testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, layerIter1.x() ==
- layerIter2.x(), testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, layerIter1.y() ==
- layerIter2.y(), testStep->assertMessage());
- layerIter1.next();
- layerIter2.next();
- }
- REPORTER_ASSERT_MESSAGE(reporter, layerIter1.done(),
- testStep->assertMessage());
- REPORTER_ASSERT_MESSAGE(reporter, layerIter2.done(),
- testStep->assertMessage());
-
+ REPORTER_ASSERT_MESSAGE(reporter,
+ CanvasTestingAccess::SameState(canvas1, canvas2),
+ testStep->assertMessage());
}
static void TestPdfDevice(skiatest::Reporter* reporter,