Index: content/renderer/render_view_browsertest.cc |
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc |
index e3ed9fad6c0bc1f7512f02501f3f2ea6d6d962a9..55b6ff059e9ea1a1378f0b68fc5540829cd96355 100644 |
--- a/content/renderer/render_view_browsertest.cc |
+++ b/content/renderer/render_view_browsertest.cc |
@@ -292,6 +292,54 @@ class RenderViewImplTest : public RenderViewTest { |
scoped_ptr<MockKeyboard> mock_keyboard_; |
}; |
+TEST_F(RenderViewImplTest, SaveImageFromDataURL) { |
+ const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( |
+ ViewHostMsg_SaveImageFromDataURL::ID); |
+ EXPECT_FALSE(msg1); |
+ render_thread_->sink().ClearMessages(); |
+ |
+ const std::string image_data_url = |
+ "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; |
+ |
+ view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url)); |
+ ProcessPendingMessages(); |
+ const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( |
+ ViewHostMsg_SaveImageFromDataURL::ID); |
+ EXPECT_TRUE(msg2); |
+ |
+ ViewHostMsg_SaveImageFromDataURL::Param param1; |
+ ViewHostMsg_SaveImageFromDataURL::Read(msg2, ¶m1); |
+ EXPECT_EQ(param1.b.length(), image_data_url.length()); |
+ EXPECT_EQ(param1.b, image_data_url); |
+ |
+ ProcessPendingMessages(); |
+ render_thread_->sink().ClearMessages(); |
+ |
+ const std::string large_data_url(1024 * 1024 * 10 - 1, 'd'); |
+ |
+ view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url)); |
+ ProcessPendingMessages(); |
+ const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
+ ViewHostMsg_SaveImageFromDataURL::ID); |
+ EXPECT_TRUE(msg3); |
+ |
+ ViewHostMsg_SaveImageFromDataURL::Param param2; |
+ ViewHostMsg_SaveImageFromDataURL::Read(msg3, ¶m2); |
+ EXPECT_EQ(param2.b.length(), large_data_url.length()); |
+ EXPECT_EQ(param2.b, large_data_url); |
+ |
+ ProcessPendingMessages(); |
+ render_thread_->sink().ClearMessages(); |
+ |
+ const std::string exceeded_data_url(1024 * 1024 * 10 + 1, 'd'); |
+ |
+ view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url)); |
+ ProcessPendingMessages(); |
+ const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( |
+ ViewHostMsg_SaveImageFromDataURL::ID); |
+ EXPECT_FALSE(msg4); |
+} |
+ |
// Test that we get form state change notifications when input fields change. |
TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) { |
// Don't want any delay for form state sync changes. This will still post a |