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/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 177 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
178 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); | 178 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); |
179 ASSERT_TRUE(browser_plugin); | 179 ASSERT_TRUE(browser_plugin); |
180 int instance_id = browser_plugin->browser_plugin_instance_id(); | 180 int instance_id = browser_plugin->browser_plugin_instance_id(); |
181 // Send an UpdateRect to the BrowserPlugin to make sure the browser sees a | 181 // Send an UpdateRect to the BrowserPlugin to make sure the browser sees a |
182 // resize related (SetAutoSize) message. | 182 // resize related (SetAutoSize) message. |
183 { | 183 { |
184 // We send a stale UpdateRect to the BrowserPlugin. | 184 // We send a stale UpdateRect to the BrowserPlugin. |
185 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 185 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
186 update_rect_params.view_size = gfx::Size(640, 480); | 186 update_rect_params.view_size = gfx::Size(640, 480); |
187 update_rect_params.scale_factor = 1.0f; | |
188 update_rect_params.is_resize_ack = true; | 187 update_rect_params.is_resize_ack = true; |
189 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); | 188 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); |
190 browser_plugin->OnMessageReceived(msg); | 189 browser_plugin->OnMessageReceived(msg); |
191 } | 190 } |
192 | 191 |
193 browser_plugin_manager()->sink().ClearMessages(); | 192 browser_plugin_manager()->sink().ClearMessages(); |
194 | 193 |
195 // Resize the browser plugin three times. | 194 // Resize the browser plugin three times. |
196 | 195 |
197 ExecuteJavaScript("document.getElementById('browserplugin').width = '641px'"); | 196 ExecuteJavaScript("document.getElementById('browserplugin').width = '641px'"); |
(...skipping 27 matching lines...) Expand all Loading... |
225 BrowserPluginHostMsg_ResizeGuest::Read(msg, ¶m); | 224 BrowserPluginHostMsg_ResizeGuest::Read(msg, ¶m); |
226 instance_id = param.a; | 225 instance_id = param.a; |
227 BrowserPluginHostMsg_ResizeGuest_Params params = param.b; | 226 BrowserPluginHostMsg_ResizeGuest_Params params = param.b; |
228 EXPECT_EQ(641, params.view_size.width()); | 227 EXPECT_EQ(641, params.view_size.width()); |
229 EXPECT_EQ(480, params.view_size.height()); | 228 EXPECT_EQ(480, params.view_size.height()); |
230 | 229 |
231 { | 230 { |
232 // We send a stale UpdateRect to the BrowserPlugin. | 231 // We send a stale UpdateRect to the BrowserPlugin. |
233 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 232 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
234 update_rect_params.view_size = gfx::Size(641, 480); | 233 update_rect_params.view_size = gfx::Size(641, 480); |
235 update_rect_params.scale_factor = 1.0f; | |
236 update_rect_params.is_resize_ack = true; | 234 update_rect_params.is_resize_ack = true; |
237 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); | 235 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); |
238 browser_plugin->OnMessageReceived(msg); | 236 browser_plugin->OnMessageReceived(msg); |
239 } | 237 } |
240 // Send the BrowserPlugin another UpdateRect, but this time with a size | 238 // Send the BrowserPlugin another UpdateRect, but this time with a size |
241 // that matches the size of the container. | 239 // that matches the size of the container. |
242 { | 240 { |
243 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 241 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
244 update_rect_params.view_size = gfx::Size(643, 480); | 242 update_rect_params.view_size = gfx::Size(643, 480); |
245 update_rect_params.scale_factor = 1.0f; | |
246 update_rect_params.is_resize_ack = true; | 243 update_rect_params.is_resize_ack = true; |
247 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); | 244 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); |
248 browser_plugin->OnMessageReceived(msg); | 245 browser_plugin->OnMessageReceived(msg); |
249 } | 246 } |
250 } | 247 } |
251 | 248 |
252 TEST_F(BrowserPluginTest, RemovePlugin) { | 249 TEST_F(BrowserPluginTest, RemovePlugin) { |
253 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 250 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
254 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); | 251 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); |
255 ASSERT_TRUE(browser_plugin); | 252 ASSERT_TRUE(browser_plugin); |
(...skipping 16 matching lines...) Expand all Loading... |
272 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 269 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
273 BrowserPluginHostMsg_PluginDestroyed::ID)); | 270 BrowserPluginHostMsg_PluginDestroyed::ID)); |
274 ExecuteJavaScript("x = document.getElementById('browserplugin'); " | 271 ExecuteJavaScript("x = document.getElementById('browserplugin'); " |
275 "x.parentNode.removeChild(x);"); | 272 "x.parentNode.removeChild(x);"); |
276 ProcessPendingMessages(); | 273 ProcessPendingMessages(); |
277 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 274 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
278 BrowserPluginHostMsg_PluginDestroyed::ID)); | 275 BrowserPluginHostMsg_PluginDestroyed::ID)); |
279 } | 276 } |
280 | 277 |
281 } // namespace content | 278 } // namespace content |
OLD | NEW |