Index: Source/web/tests/WebViewTest.cpp |
diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp |
index 4c2c66242524996fa67ee4ccb32934e21604f351..3090d24a8e117dd25b86b68aa81ae15216747e44 100644 |
--- a/Source/web/tests/WebViewTest.cpp |
+++ b/Source/web/tests/WebViewTest.cpp |
@@ -130,6 +130,19 @@ private: |
TestData m_testData; |
}; |
+class SaveImageFromDataURLWebViewClient : public FrameTestHelpers::TestWebViewClient { |
+public: |
+ // WebViewClient methods |
+ virtual void saveImageFromDataURL(const WebString& dataURL) { m_dataURL = dataURL; } |
+ |
+ // Local methods |
+ const WebString& result() const { return m_dataURL; } |
+ void reset() { m_dataURL = WebString(); } |
+ |
+private: |
+ WebString m_dataURL; |
+}; |
+ |
class TapHandlingWebViewClient : public FrameTestHelpers::TestWebViewClient { |
public: |
// WebViewClient methods |
@@ -219,6 +232,27 @@ protected: |
FrameTestHelpers::WebViewHelper m_webViewHelper; |
}; |
+TEST_F(WebViewTest, SaveImageAt) |
+{ |
+ SaveImageFromDataURLWebViewClient client; |
+ |
+ std::string url = m_baseURL + "image-with-data-url.html"; |
+ URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-with-data-url.html"); |
+ WebView* webView = m_webViewHelper.initializeAndLoad(url, true, 0, &client); |
+ webView->resize(WebSize(400, 400)); |
+ |
+ client.reset(); |
+ webView->saveImageAt(WebPoint(1, 1)); |
+ EXPECT_EQ(WebString::fromUTF8("data:image/gif;base64" |
+ ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), client.result()); |
+ |
+ client.reset(); |
+ webView->saveImageAt(WebPoint(1, 2)); |
+ EXPECT_EQ(WebString(), client.result()); |
+ |
+ m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. |
+}; |
+ |
TEST_F(WebViewTest, CopyImageAt) |
{ |
std::string url = m_baseURL + "canvas-copy-image.html"; |