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

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

Issue 19856004: Adds WebElement::imageContents() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: put image fetching logic in WebCore::Element, add basic smoke test 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
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 96601bbcff58bbdb3b69d50c16e9e49bedf7d67c..bcbc365fab57e8a6600cefc35550922d89002075 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -3466,5 +3466,27 @@ 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());
+ WebImage image = node.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
« Source/web/WebNode.cpp ('K') | « Source/web/WebNode.cpp ('k') | public/web/WebNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698