aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/BitmapTest.cpp
blob: 250b6da32c2aa748db19d8996a6dfc3d2384ec06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkBitmap.h"

#include "Test.h"
#include "TestClassDef.h"

/**
 *  This test contains basic sanity checks concerning bitmaps.
 */
DEF_TEST(Bitmap, reporter) {
    const SkBitmap::Config conf = SkBitmap::kARGB_8888_Config;
    // Zero-sized bitmaps are allowed
    for (int width = 0; width < 2; ++width) {
        for (int height = 0; height < 2; ++height) {
            SkBitmap bm;
            bool setConf = bm.setConfig(conf, width, height);
            REPORTER_ASSERT(reporter, setConf);
            if (setConf) {
                REPORTER_ASSERT(reporter, bm.allocPixels(NULL));
            }
            REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
        }
    }
}