Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1560)

Unified Diff: Source/web/tests/WebFrameTest.cpp

Issue 19856004: Adds WebElement::imageContents() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix webkit_test_support in static build, it needs to depend on skia so the SkBitma.h include works Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebNode.cpp ('k') | public/web/WebElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 96601bbcff58bbdb3b69d50c16e9e49bedf7d67c..8b208a9cb989416c3378b9f11f475cbe17ed8502 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -3466,5 +3466,28 @@ TEST_F(WebFrameTest, NavigateToSame)
m_webView = 0;
}
+TEST_F(WebFrameTest, WebNodeImageContents)
+{
+ m_webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true);
+ WebFrame* frame = m_webView->mainFrame();
+
+ static const char bluePNG[] = "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2NkYPj/n4EIwDiqEF8oUT94AFIQE/cCn90IAAAAAElFTkSuQmCC\">";
+
+ // Load up the image and test that we can extract the contents.
+ WebCore::KURL testURL = toKURL("about:blank");
+ frame->loadHTMLString(bluePNG, testURL);
+ runPendingTasks();
+
+ WebNode node = frame->document().body().firstChild();
+ EXPECT_TRUE(node.isElementNode());
+ WebElement element = node.to<WebElement>();
+ WebImage image = element.imageContents();
+ ASSERT_FALSE(image.isNull());
+ EXPECT_EQ(image.size().width, 10);
+ EXPECT_EQ(image.size().height, 10);
+ SkBitmap bitmap = image.getSkBitmap();
+ SkAutoLockPixels locker(bitmap);
+ EXPECT_EQ(bitmap.getColor(0, 0), SK_ColorBLUE);
+}
} // namespace
« no previous file with comments | « Source/web/WebNode.cpp ('k') | public/web/WebElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698