diff options
author | halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-13 18:29:51 +0000 |
---|---|---|
committer | halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-13 18:29:51 +0000 |
commit | 4428734907480cdb4ccecb47152d7be8cd1aec32 (patch) | |
tree | 520bff41ac842edf673efa42d59115366363c544 /tests/BitmapTest.cpp | |
parent | 0daa1adb03b4b1fc11d854cb7754416ac05a31e8 (diff) |
Allow 0-width SkBitmap in setConfig.
Previously, SkBitmap::setConfig would allow zero height, but not zero
width. This is changed for consistancy.
A unit test was added.
BUG=
R=reed@google.com, scroggo@google.com
Review URL: https://codereview.chromium.org/111953004
git-svn-id: http://skia.googlecode.com/svn/trunk@12673 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/BitmapTest.cpp')
-rw-r--r-- | tests/BitmapTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp new file mode 100644 index 0000000000..a6859fabf0 --- /dev/null +++ b/tests/BitmapTest.cpp @@ -0,0 +1,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, (width & height) != bm.empty()); + } + } +} |