| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 146 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); |
| 147 | 147 |
| 148 // Send the BrowserPlugin an UpdateRect equal to its container size with | 148 // Send the BrowserPlugin an UpdateRect equal to its container size with |
| 149 // the same damage buffer. That should clear |pending_damage_buffer_|. | 149 // the same damage buffer. That should clear |pending_damage_buffer_|. |
| 150 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 150 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 151 update_rect_params.damage_buffer_sequence_id = | 151 update_rect_params.damage_buffer_sequence_id = |
| 152 browser_plugin->damage_buffer_sequence_id_; | 152 browser_plugin->damage_buffer_sequence_id_; |
| 153 update_rect_params.view_size = gfx::Size(640, 480); | 153 update_rect_params.view_size = gfx::Size(640, 480); |
| 154 update_rect_params.scale_factor = 1.0f; | 154 update_rect_params.scale_factor = 1.0f; |
| 155 update_rect_params.is_resize_ack = true; | 155 update_rect_params.is_resize_ack = true; |
| 156 update_rect_params.needs_ack = true; |
| 156 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); | 157 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
| 157 browser_plugin->OnMessageReceived(msg); | 158 browser_plugin->OnMessageReceived(msg); |
| 158 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); | 159 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); |
| 159 } | 160 } |
| 160 | 161 |
| 161 // Verify that the src attribute on the browser plugin works as expected. | 162 // Verify that the src attribute on the browser plugin works as expected. |
| 162 TEST_F(BrowserPluginTest, SrcAttribute) { | 163 TEST_F(BrowserPluginTest, SrcAttribute) { |
| 163 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 164 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 164 // Verify that we're reporting the correct URL to navigate to based on the | 165 // Verify that we're reporting the correct URL to navigate to based on the |
| 165 // src attribute. | 166 // src attribute. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ASSERT_TRUE(browser_plugin); | 229 ASSERT_TRUE(browser_plugin); |
| 229 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 230 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); |
| 230 // Send an UpdateRect to the BrowserPlugin to make it use the pending damage | 231 // Send an UpdateRect to the BrowserPlugin to make it use the pending damage |
| 231 // buffer. | 232 // buffer. |
| 232 { | 233 { |
| 233 // We send a stale UpdateRect to the BrowserPlugin. | 234 // We send a stale UpdateRect to the BrowserPlugin. |
| 234 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 235 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 235 update_rect_params.view_size = gfx::Size(640, 480); | 236 update_rect_params.view_size = gfx::Size(640, 480); |
| 236 update_rect_params.scale_factor = 1.0f; | 237 update_rect_params.scale_factor = 1.0f; |
| 237 update_rect_params.is_resize_ack = true; | 238 update_rect_params.is_resize_ack = true; |
| 239 update_rect_params.needs_ack = true; |
| 238 // By sending |damage_buffer_sequence_id| back to BrowserPlugin on | 240 // By sending |damage_buffer_sequence_id| back to BrowserPlugin on |
| 239 // UpdateRect, then the BrowserPlugin knows that the browser process has | 241 // UpdateRect, then the BrowserPlugin knows that the browser process has |
| 240 // received and has begun to use the |pending_damage_buffer_|. | 242 // received and has begun to use the |pending_damage_buffer_|. |
| 241 update_rect_params.damage_buffer_sequence_id = | 243 update_rect_params.damage_buffer_sequence_id = |
| 242 browser_plugin->damage_buffer_sequence_id_; | 244 browser_plugin->damage_buffer_sequence_id_; |
| 243 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); | 245 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
| 244 browser_plugin->OnMessageReceived(msg); | 246 browser_plugin->OnMessageReceived(msg); |
| 245 EXPECT_EQ(NULL, browser_plugin->pending_damage_buffer_.get()); | 247 EXPECT_EQ(NULL, browser_plugin->pending_damage_buffer_.get()); |
| 246 } | 248 } |
| 247 | 249 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 270 // This indicates that the BrowserPlugin has sent out a previous resize | 272 // This indicates that the BrowserPlugin has sent out a previous resize |
| 271 // request but has not yet received an UpdateRect for that request. | 273 // request but has not yet received an UpdateRect for that request. |
| 272 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 274 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); |
| 273 | 275 |
| 274 { | 276 { |
| 275 // We send a stale UpdateRect to the BrowserPlugin. | 277 // We send a stale UpdateRect to the BrowserPlugin. |
| 276 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 278 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 277 update_rect_params.view_size = gfx::Size(641, 480); | 279 update_rect_params.view_size = gfx::Size(641, 480); |
| 278 update_rect_params.scale_factor = 1.0f; | 280 update_rect_params.scale_factor = 1.0f; |
| 279 update_rect_params.is_resize_ack = true; | 281 update_rect_params.is_resize_ack = true; |
| 282 update_rect_params.needs_ack = true; |
| 280 update_rect_params.damage_buffer_sequence_id = | 283 update_rect_params.damage_buffer_sequence_id = |
| 281 browser_plugin->damage_buffer_sequence_id_; | 284 browser_plugin->damage_buffer_sequence_id_; |
| 282 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); | 285 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
| 283 browser_plugin->OnMessageReceived(msg); | 286 browser_plugin->OnMessageReceived(msg); |
| 284 // This tells us that the BrowserPlugin is still expecting another | 287 // This tells us that the BrowserPlugin is still expecting another |
| 285 // UpdateRect with the most recent size. | 288 // UpdateRect with the most recent size. |
| 286 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); | 289 EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); |
| 287 } | 290 } |
| 288 // Send the BrowserPlugin another UpdateRect, but this time with a size | 291 // Send the BrowserPlugin another UpdateRect, but this time with a size |
| 289 // that matches the size of the container. | 292 // that matches the size of the container. |
| 290 { | 293 { |
| 291 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 294 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 292 update_rect_params.view_size = gfx::Size(643, 480); | 295 update_rect_params.view_size = gfx::Size(643, 480); |
| 293 update_rect_params.scale_factor = 1.0f; | 296 update_rect_params.scale_factor = 1.0f; |
| 294 update_rect_params.is_resize_ack = true; | 297 update_rect_params.is_resize_ack = true; |
| 298 update_rect_params.needs_ack = true; |
| 295 update_rect_params.damage_buffer_sequence_id = | 299 update_rect_params.damage_buffer_sequence_id = |
| 296 browser_plugin->damage_buffer_sequence_id_; | 300 browser_plugin->damage_buffer_sequence_id_; |
| 297 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); | 301 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
| 298 browser_plugin->OnMessageReceived(msg); | 302 browser_plugin->OnMessageReceived(msg); |
| 299 // The BrowserPlugin has finally received an UpdateRect that satisifes | 303 // The BrowserPlugin has finally received an UpdateRect that satisifes |
| 300 // its current size, and so it is happy. | 304 // its current size, and so it is happy. |
| 301 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); | 305 EXPECT_FALSE(browser_plugin->pending_damage_buffer_.get()); |
| 302 } | 306 } |
| 303 } | 307 } |
| 304 | 308 |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 EXPECT_FALSE(auto_size_msg); | 810 EXPECT_FALSE(auto_size_msg); |
| 807 | 811 |
| 808 // Send the BrowserPlugin an UpdateRect equal to its |max_size| with | 812 // Send the BrowserPlugin an UpdateRect equal to its |max_size| with |
| 809 // the same damage buffer. | 813 // the same damage buffer. |
| 810 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 814 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 811 update_rect_params.damage_buffer_sequence_id = | 815 update_rect_params.damage_buffer_sequence_id = |
| 812 browser_plugin->damage_buffer_sequence_id_; | 816 browser_plugin->damage_buffer_sequence_id_; |
| 813 update_rect_params.view_size = gfx::Size(1337, 1338); | 817 update_rect_params.view_size = gfx::Size(1337, 1338); |
| 814 update_rect_params.scale_factor = 1.0f; | 818 update_rect_params.scale_factor = 1.0f; |
| 815 update_rect_params.is_resize_ack = true; | 819 update_rect_params.is_resize_ack = true; |
| 820 update_rect_params.needs_ack = true; |
| 816 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); | 821 BrowserPluginMsg_UpdateRect msg(0, instance_id, update_rect_params); |
| 817 browser_plugin->OnMessageReceived(msg); | 822 browser_plugin->OnMessageReceived(msg); |
| 818 | 823 |
| 819 // Verify that the autosize state has been updated. | 824 // Verify that the autosize state has been updated. |
| 820 { | 825 { |
| 821 const IPC::Message* auto_size_msg = | 826 const IPC::Message* auto_size_msg = |
| 822 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 827 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 823 BrowserPluginHostMsg_UpdateRect_ACK::ID); | 828 BrowserPluginHostMsg_UpdateRect_ACK::ID); |
| 824 ASSERT_TRUE(auto_size_msg); | 829 ASSERT_TRUE(auto_size_msg); |
| 825 | 830 |
| 826 int instance_id = 0; | 831 int instance_id = 0; |
| 827 BrowserPluginHostMsg_AutoSize_Params auto_size_params; | 832 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
| 828 BrowserPluginHostMsg_ResizeGuest_Params resize_params; | 833 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
| 829 BrowserPluginHostMsg_UpdateRect_ACK::Read(auto_size_msg, | 834 BrowserPluginHostMsg_UpdateRect_ACK::Read(auto_size_msg, |
| 830 &instance_id, | 835 &instance_id, |
| 831 &auto_size_params, | 836 &auto_size_params, |
| 832 &resize_params); | 837 &resize_params); |
| 833 EXPECT_FALSE(auto_size_params.enable); | 838 EXPECT_FALSE(auto_size_params.enable); |
| 834 EXPECT_EQ(42, auto_size_params.min_size.width()); | 839 EXPECT_EQ(42, auto_size_params.min_size.width()); |
| 835 EXPECT_EQ(43, auto_size_params.min_size.height()); | 840 EXPECT_EQ(43, auto_size_params.min_size.height()); |
| 836 EXPECT_EQ(1337, auto_size_params.max_size.width()); | 841 EXPECT_EQ(1337, auto_size_params.max_size.width()); |
| 837 EXPECT_EQ(1338, auto_size_params.max_size.height()); | 842 EXPECT_EQ(1338, auto_size_params.max_size.height()); |
| 838 } | 843 } |
| 839 } | 844 } |
| 840 | 845 |
| 841 } // namespace content | 846 } // namespace content |
| OLD | NEW |