summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webkit_glue_unittest.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-07-29 17:14:53 +0100
committerBen Murdoch <benm@google.com>2010-08-04 14:29:45 +0100
commitc407dc5cd9bdc5668497f21b26b09d988ab439de (patch)
tree7eaf8707c0309516bdb042ad976feedaf72b0bb1 /webkit/glue/webkit_glue_unittest.cc
parent0998b1cdac5733f299c12d88bc31ef9c8035b8fa (diff)
downloadexternal_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.zip
external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.gz
external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.bz2
Merge Chromium src@r53293
Change-Id: Ia79acf8670f385cee48c45b0a75371d8e950af34
Diffstat (limited to 'webkit/glue/webkit_glue_unittest.cc')
-rw-r--r--webkit/glue/webkit_glue_unittest.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/webkit/glue/webkit_glue_unittest.cc b/webkit/glue/webkit_glue_unittest.cc
new file mode 100644
index 0000000..9ba56e3
--- /dev/null
+++ b/webkit/glue/webkit_glue_unittest.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "webkit/glue/webkit_glue.h"
+
+namespace {
+
+TEST(WebkitGlueTest, DecodeImageFail) {
+ std::string data("not an image");
+ SkBitmap image;
+ EXPECT_FALSE(webkit_glue::DecodeImage(data, &image));
+ EXPECT_TRUE(image.isNull());
+}
+
+TEST(WebkitGlueTest, DecodeImage) {
+ std::string data("GIF87a\x02\x00\x02\x00\xa1\x04\x00\x00\x00\x00\x00\x00\xff"
+ "\xff\x00\x00\x00\xff\x00,\x00\x00\x00\x00\x02\x00\x02\x00"
+ "\x00\x02\x03\x84\x16\x05\x00;", 42);
+ EXPECT_EQ(42u, data.size());
+ SkBitmap image;
+ EXPECT_TRUE(webkit_glue::DecodeImage(data, &image));
+ EXPECT_FALSE(image.isNull());
+ EXPECT_EQ(2, image.width());
+ EXPECT_EQ(2, image.height());
+ EXPECT_EQ(SkBitmap::kARGB_8888_Config, image.config());
+ image.lockPixels();
+ EXPECT_EQ(SK_ColorBLACK, *image.getAddr32(0, 0));
+ EXPECT_EQ(SK_ColorRED, *image.getAddr32(1, 0));
+ EXPECT_EQ(SK_ColorGREEN, *image.getAddr32(0, 1));
+ EXPECT_EQ(SK_ColorBLUE, *image.getAddr32(1, 1));
+ image.unlockPixels();
+}
+
+} // namespace