OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 151 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
152 update_rect_params.damage_buffer_identifier = | 152 update_rect_params.damage_buffer_identifier = |
153 #if defined(OS_MACOSX) | 153 #if defined(OS_MACOSX) |
154 browser_plugin->pending_damage_buffer_->id(); | 154 browser_plugin->pending_damage_buffer_->id(); |
155 #else | 155 #else |
156 browser_plugin->pending_damage_buffer_->handle(); | 156 browser_plugin->pending_damage_buffer_->handle(); |
157 #endif | 157 #endif |
158 update_rect_params.view_size = gfx::Size(640, 480); | 158 update_rect_params.view_size = gfx::Size(640, 480); |
159 update_rect_params.scale_factor = 1.0f; | 159 update_rect_params.scale_factor = 1.0f; |
160 update_rect_params.is_resize_ack = true; | 160 update_rect_params.is_resize_ack = true; |
161 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); | 161 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
162 browser_plugin->OnMessageReceived(msg); | 162 browser_plugin->OnMessageReceived(msg); |
163 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); | 163 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); |
164 } | 164 } |
165 | 165 |
166 // Verify that the src attribute on the browser plugin works as expected. | 166 // Verify that the src attribute on the browser plugin works as expected. |
167 TEST_F(BrowserPluginTest, SrcAttribute) { | 167 TEST_F(BrowserPluginTest, SrcAttribute) { |
168 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 168 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
169 // Verify that we're reporting the correct URL to navigate to based on the | 169 // Verify that we're reporting the correct URL to navigate to based on the |
170 // src attribute. | 170 // src attribute. |
171 { | 171 { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 update_rect_params.is_resize_ack = true; | 242 update_rect_params.is_resize_ack = true; |
243 // By sending the damage buffer handle back to BrowserPlugin on UpdateRect, | 243 // By sending the damage buffer handle back to BrowserPlugin on UpdateRect, |
244 // then the BrowserPlugin knows that the browser process has received and | 244 // then the BrowserPlugin knows that the browser process has received and |
245 // has begun to use the pending_damage_buffer. | 245 // has begun to use the pending_damage_buffer. |
246 update_rect_params.damage_buffer_identifier = | 246 update_rect_params.damage_buffer_identifier = |
247 #if defined(OS_MACOSX) | 247 #if defined(OS_MACOSX) |
248 browser_plugin->pending_damage_buffer_->id(); | 248 browser_plugin->pending_damage_buffer_->id(); |
249 #else | 249 #else |
250 browser_plugin->pending_damage_buffer_->handle(); | 250 browser_plugin->pending_damage_buffer_->handle(); |
251 #endif | 251 #endif |
252 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); | 252 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
253 browser_plugin->OnMessageReceived(msg); | 253 browser_plugin->OnMessageReceived(msg); |
254 EXPECT_EQ(NULL, browser_plugin->pending_damage_buffer_); | 254 EXPECT_EQ(NULL, browser_plugin->pending_damage_buffer_); |
255 } | 255 } |
256 | 256 |
257 browser_plugin_manager()->sink().ClearMessages(); | 257 browser_plugin_manager()->sink().ClearMessages(); |
258 | 258 |
259 // Resize the browser plugin three times. | 259 // Resize the browser plugin three times. |
260 ExecuteJavaScript("document.getElementById('browserplugin').width = '641px'"); | 260 ExecuteJavaScript("document.getElementById('browserplugin').width = '641px'"); |
261 ProcessPendingMessages(); | 261 ProcessPendingMessages(); |
262 ExecuteJavaScript("document.getElementById('browserplugin').width = '642px'"); | 262 ExecuteJavaScript("document.getElementById('browserplugin').width = '642px'"); |
(...skipping 22 matching lines...) Expand all Loading... |
285 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 285 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
286 update_rect_params.view_size = gfx::Size(641, 480); | 286 update_rect_params.view_size = gfx::Size(641, 480); |
287 update_rect_params.scale_factor = 1.0f; | 287 update_rect_params.scale_factor = 1.0f; |
288 update_rect_params.is_resize_ack = true; | 288 update_rect_params.is_resize_ack = true; |
289 update_rect_params.damage_buffer_identifier = | 289 update_rect_params.damage_buffer_identifier = |
290 #if defined(OS_MACOSX) | 290 #if defined(OS_MACOSX) |
291 browser_plugin->pending_damage_buffer_->id(); | 291 browser_plugin->pending_damage_buffer_->id(); |
292 #else | 292 #else |
293 browser_plugin->pending_damage_buffer_->handle(); | 293 browser_plugin->pending_damage_buffer_->handle(); |
294 #endif | 294 #endif |
295 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); | 295 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
296 browser_plugin->OnMessageReceived(msg); | 296 browser_plugin->OnMessageReceived(msg); |
297 // This tells us that the BrowserPlugin is still expecting another | 297 // This tells us that the BrowserPlugin is still expecting another |
298 // UpdateRect with the most recent size. | 298 // UpdateRect with the most recent size. |
299 EXPECT_TRUE(browser_plugin->pending_damage_buffer_); | 299 EXPECT_TRUE(browser_plugin->pending_damage_buffer_); |
300 } | 300 } |
301 // Send the BrowserPlugin another UpdateRect, but this time with a size | 301 // Send the BrowserPlugin another UpdateRect, but this time with a size |
302 // that matches the size of the container. | 302 // that matches the size of the container. |
303 { | 303 { |
304 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 304 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
305 update_rect_params.view_size = gfx::Size(643, 480); | 305 update_rect_params.view_size = gfx::Size(643, 480); |
306 update_rect_params.scale_factor = 1.0f; | 306 update_rect_params.scale_factor = 1.0f; |
307 update_rect_params.is_resize_ack = true; | 307 update_rect_params.is_resize_ack = true; |
308 update_rect_params.damage_buffer_identifier = | 308 update_rect_params.damage_buffer_identifier = |
309 #if defined(OS_MACOSX) | 309 #if defined(OS_MACOSX) |
310 browser_plugin->pending_damage_buffer_->id(); | 310 browser_plugin->pending_damage_buffer_->id(); |
311 #else | 311 #else |
312 browser_plugin->pending_damage_buffer_->handle(); | 312 browser_plugin->pending_damage_buffer_->handle(); |
313 #endif | 313 #endif |
314 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); | 314 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
315 browser_plugin->OnMessageReceived(msg); | 315 browser_plugin->OnMessageReceived(msg); |
316 // The BrowserPlugin has finally received an UpdateRect that satisifes | 316 // The BrowserPlugin has finally received an UpdateRect that satisifes |
317 // its current size, and so it is happy. | 317 // its current size, and so it is happy. |
318 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); | 318 EXPECT_FALSE(browser_plugin->pending_damage_buffer_); |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 TEST_F(BrowserPluginTest, GuestCrash) { | 322 TEST_F(BrowserPluginTest, GuestCrash) { |
323 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 323 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
324 | 324 |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 827 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
828 update_rect_params.damage_buffer_identifier = | 828 update_rect_params.damage_buffer_identifier = |
829 #if defined(OS_MACOSX) | 829 #if defined(OS_MACOSX) |
830 browser_plugin->pending_damage_buffer_->id(); | 830 browser_plugin->pending_damage_buffer_->id(); |
831 #else | 831 #else |
832 browser_plugin->pending_damage_buffer_->handle(); | 832 browser_plugin->pending_damage_buffer_->handle(); |
833 #endif | 833 #endif |
834 update_rect_params.view_size = gfx::Size(1337, 1338); | 834 update_rect_params.view_size = gfx::Size(1337, 1338); |
835 update_rect_params.scale_factor = 1.0f; | 835 update_rect_params.scale_factor = 1.0f; |
836 update_rect_params.is_resize_ack = true; | 836 update_rect_params.is_resize_ack = true; |
837 BrowserPluginMsg_UpdateRect msg(0, instance_id, 0, update_rect_params); | 837 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
838 browser_plugin->OnMessageReceived(msg); | 838 browser_plugin->OnMessageReceived(msg); |
839 | 839 |
840 // Verify that the autosize state has been updated. | 840 // Verify that the autosize state has been updated. |
841 { | 841 { |
842 const IPC::Message* auto_size_msg = | 842 const IPC::Message* auto_size_msg = |
843 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 843 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
844 BrowserPluginHostMsg_UpdateRect_ACK::ID); | 844 BrowserPluginHostMsg_UpdateRect_ACK::ID); |
845 ASSERT_TRUE(auto_size_msg); | 845 ASSERT_TRUE(auto_size_msg); |
846 | 846 |
847 int instance_id = 0; | 847 int instance_id = 0; |
848 int message_id = 0; | |
849 BrowserPluginHostMsg_AutoSize_Params auto_size_params; | 848 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
850 BrowserPluginHostMsg_ResizeGuest_Params resize_params; | 849 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
851 BrowserPluginHostMsg_UpdateRect_ACK::Read(auto_size_msg, | 850 BrowserPluginHostMsg_UpdateRect_ACK::Read(auto_size_msg, |
852 &instance_id, | 851 &instance_id, |
853 &message_id, | |
854 &auto_size_params, | 852 &auto_size_params, |
855 &resize_params); | 853 &resize_params); |
856 EXPECT_FALSE(auto_size_params.enable); | 854 EXPECT_FALSE(auto_size_params.enable); |
857 EXPECT_EQ(42, auto_size_params.min_size.width()); | 855 EXPECT_EQ(42, auto_size_params.min_size.width()); |
858 EXPECT_EQ(43, auto_size_params.min_size.height()); | 856 EXPECT_EQ(43, auto_size_params.min_size.height()); |
859 EXPECT_EQ(1337, auto_size_params.max_size.width()); | 857 EXPECT_EQ(1337, auto_size_params.max_size.width()); |
860 EXPECT_EQ(1338, auto_size_params.max_size.height()); | 858 EXPECT_EQ(1338, auto_size_params.max_size.height()); |
861 } | 859 } |
862 } | 860 } |
863 | 861 |
864 } // namespace content | 862 } // namespace content |
OLD | NEW |