PictureTest.cpp revision d614c6a4e059bd9ea5b882ca845e886a82aeff5c
1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include "Test.h"
8#include "SkPicture.h"
9#include "SkStream.h"
10
11#ifdef SK_DEBUG
12// Ensure that deleting SkPicturePlayback does not assert. Asserts only fire in debug mode, so only
13// run in debug mode.
14static void test_deleting_empty_playback() {
15    SkPicture picture;
16    // Creates an SkPictureRecord
17    picture.beginRecording(0, 0);
18    // Turns that into an SkPicturePlayback
19    picture.endRecording();
20    // Deletes the old SkPicturePlayback, and creates a new SkPictureRecord
21    picture.beginRecording(0, 0);
22}
23
24// Ensure that serializing an empty picture does not assert. Likewise only runs in debug mode.
25static void test_serializing_empty_picture() {
26    SkPicture picture;
27    picture.beginRecording(0, 0);
28    picture.endRecording();
29    SkDynamicMemoryWStream stream;
30    picture.serialize(&stream);
31}
32#endif
33
34static void TestPicture(skiatest::Reporter* reporter) {
35#ifdef SK_DEBUG
36    test_deleting_empty_playback();
37    test_serializing_empty_picture();
38#endif
39}
40
41#include "TestClassDef.h"
42DEFINE_TESTCLASS("Picture", PictureTestClass, TestPicture)
43