| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 BrowserPluginHostMsg_Attach_Params params; | 130 BrowserPluginHostMsg_Attach_Params params; |
| 131 return GetCurrentPluginWithAttachParams(¶ms); | 131 return GetCurrentPluginWithAttachParams(¶ms); |
| 132 } | 132 } |
| 133 | 133 |
| 134 MockBrowserPlugin* BrowserPluginTest::GetCurrentPluginWithAttachParams( | 134 MockBrowserPlugin* BrowserPluginTest::GetCurrentPluginWithAttachParams( |
| 135 BrowserPluginHostMsg_Attach_Params* params) { | 135 BrowserPluginHostMsg_Attach_Params* params) { |
| 136 MockBrowserPlugin* browser_plugin = static_cast<MockBrowserPluginManager*>( | 136 MockBrowserPlugin* browser_plugin = static_cast<MockBrowserPluginManager*>( |
| 137 browser_plugin_manager())->last_plugin(); | 137 browser_plugin_manager())->last_plugin(); |
| 138 if (!browser_plugin) | 138 if (!browser_plugin) |
| 139 return NULL; | 139 return NULL; |
| 140 browser_plugin_manager()->AllocateInstanceID(browser_plugin); | 140 |
| 141 browser_plugin->Attach(); |
| 141 | 142 |
| 142 int instance_id = 0; | 143 int instance_id = 0; |
| 143 const IPC::Message* msg = | 144 const IPC::Message* msg = |
| 144 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 145 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 145 BrowserPluginHostMsg_Attach::ID); | 146 BrowserPluginHostMsg_Attach::ID); |
| 146 if (!msg) | 147 if (!msg) |
| 147 return NULL; | 148 return NULL; |
| 148 | 149 |
| 149 PickleIterator iter(*msg); | 150 PickleIterator iter(*msg); |
| 150 if (!iter.ReadInt(&instance_id)) | 151 if (!iter.ReadInt(&instance_id)) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 169 | 170 |
| 170 EXPECT_EQ(640, params.resize_guest_params.view_size.width()); | 171 EXPECT_EQ(640, params.resize_guest_params.view_size.width()); |
| 171 EXPECT_EQ(480, params.resize_guest_params.view_size.height()); | 172 EXPECT_EQ(480, params.resize_guest_params.view_size.height()); |
| 172 ASSERT_TRUE(browser_plugin); | 173 ASSERT_TRUE(browser_plugin); |
| 173 } | 174 } |
| 174 | 175 |
| 175 TEST_F(BrowserPluginTest, ResizeFlowControl) { | 176 TEST_F(BrowserPluginTest, ResizeFlowControl) { |
| 176 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 177 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 177 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); | 178 MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); |
| 178 ASSERT_TRUE(browser_plugin); | 179 ASSERT_TRUE(browser_plugin); |
| 179 int instance_id = browser_plugin->guest_instance_id(); | 180 int instance_id = browser_plugin->browser_plugin_instance_id(); |
| 180 // 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 |
| 181 // resize related (SetAutoSize) message. | 182 // resize related (SetAutoSize) message. |
| 182 { | 183 { |
| 183 // We send a stale UpdateRect to the BrowserPlugin. | 184 // We send a stale UpdateRect to the BrowserPlugin. |
| 184 BrowserPluginMsg_UpdateRect_Params update_rect_params; | 185 BrowserPluginMsg_UpdateRect_Params update_rect_params; |
| 185 update_rect_params.view_size = gfx::Size(640, 480); | 186 update_rect_params.view_size = gfx::Size(640, 480); |
| 186 update_rect_params.scale_factor = 1.0f; | 187 update_rect_params.scale_factor = 1.0f; |
| 187 update_rect_params.is_resize_ack = true; | 188 update_rect_params.is_resize_ack = true; |
| 188 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); | 189 BrowserPluginMsg_UpdateRect msg(instance_id, update_rect_params); |
| 189 browser_plugin->OnMessageReceived(msg); | 190 browser_plugin->OnMessageReceived(msg); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 272 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 272 BrowserPluginHostMsg_PluginDestroyed::ID)); | 273 BrowserPluginHostMsg_PluginDestroyed::ID)); |
| 273 ExecuteJavaScript("x = document.getElementById('browserplugin'); " | 274 ExecuteJavaScript("x = document.getElementById('browserplugin'); " |
| 274 "x.parentNode.removeChild(x);"); | 275 "x.parentNode.removeChild(x);"); |
| 275 ProcessPendingMessages(); | 276 ProcessPendingMessages(); |
| 276 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 277 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 277 BrowserPluginHostMsg_PluginDestroyed::ID)); | 278 BrowserPluginHostMsg_PluginDestroyed::ID)); |
| 278 } | 279 } |
| 279 | 280 |
| 280 } // namespace content | 281 } // namespace content |
| OLD | NEW |