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/path_service.h" | 9 #include "base/path_service.h" |
10 #include "content/common/browser_plugin_messages.h" | 10 #include "content/common/browser_plugin_messages.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 v8_str->WriteUtf8(str.get(), length); | 63 v8_str->WriteUtf8(str.get(), length); |
64 return str.get(); | 64 return str.get(); |
65 } | 65 } |
66 | 66 |
67 // This test verifies that an initial resize occurs when we instantiate the | 67 // This test verifies that an initial resize occurs when we instantiate the |
68 // browser plugin. This test also verifies that the browser plugin is waiting | 68 // browser plugin. This test also verifies that the browser plugin is waiting |
69 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and | 69 // for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and |
70 // we observe an UpdateRect_ACK, with the resize_pending_ reset, indiciating | 70 // we observe an UpdateRect_ACK, with the resize_pending_ reset, indiciating |
71 // that the BrowserPlugin is not waiting for any more UpdateRects to | 71 // that the BrowserPlugin is not waiting for any more UpdateRects to |
72 // satisfy its resize request. | 72 // satisfy its resize request. |
73 TEST_F(BrowserPluginTest, InitialResize) { | 73 TEST_F(BrowserPluginTest, InitialResize) { |
awong
2012/09/06 19:55:26
Do we need to test resize being preserved when src
lazyboy
2012/09/07 19:33:19
If I understand this one correctly: since we got a
Fady Samuel
2012/09/07 19:37:52
I think the test being suggested is the following:
| |
74 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 74 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
75 // Verify that the information based on ResizeGuest is correct, and | 75 // Verify that the information based on ResizeGuest is correct, and |
76 // use its TransportDIB::Id to paint. | 76 // use its TransportDIB::Id to paint. |
77 const IPC::Message* msg = | 77 const IPC::Message* msg = |
78 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 78 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
79 BrowserPluginHostMsg_ResizeGuest::ID); | 79 BrowserPluginHostMsg_ResizeGuest::ID); |
80 ASSERT_TRUE(msg); | 80 ASSERT_TRUE(msg); |
81 PickleIterator iter = IPC::SyncMessage::GetDataIterator(msg); | 81 PickleIterator iter = IPC::SyncMessage::GetDataIterator(msg); |
82 BrowserPluginHostMsg_ResizeGuest::SendParam resize_params; | 82 BrowserPluginHostMsg_ResizeGuest::SendParam resize_params; |
83 ASSERT_TRUE(IPC::ReadParam(msg, &iter, &resize_params)); | 83 ASSERT_TRUE(IPC::ReadParam(msg, &iter, &resize_params)); |
(...skipping 23 matching lines...) Expand all Loading... | |
107 } | 107 } |
108 | 108 |
109 // Verify that the src attribute on the browser plugin works as expected. | 109 // Verify that the src attribute on the browser plugin works as expected. |
110 TEST_F(BrowserPluginTest, SrcAttribute) { | 110 TEST_F(BrowserPluginTest, SrcAttribute) { |
111 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 111 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
112 // Verify that we're reporting the correct URL to navigate to based on the | 112 // Verify that we're reporting the correct URL to navigate to based on the |
113 // src attribute. | 113 // src attribute. |
114 { | 114 { |
115 const IPC::Message* msg = | 115 const IPC::Message* msg = |
116 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 116 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
117 BrowserPluginHostMsg_NavigateOrCreateGuest::ID); | 117 BrowserPluginHostMsg_NavigateGuest::ID); |
118 ASSERT_TRUE(msg); | 118 ASSERT_TRUE(msg); |
119 | 119 |
120 int instance_id; | 120 int instance_id; |
121 long long frame_id; | 121 long long frame_id; |
122 std::string src; | 122 std::string src; |
123 BrowserPluginHostMsg_NavigateOrCreateGuest::Read( | 123 gfx::Size size; |
124 BrowserPluginHostMsg_NavigateGuest::Read( | |
124 msg, | 125 msg, |
125 &instance_id, | 126 &instance_id, |
126 &frame_id, | 127 &frame_id, |
127 &src); | 128 &src, |
129 &size); | |
128 EXPECT_EQ("foo", src); | 130 EXPECT_EQ("foo", src); |
129 } | 131 } |
130 | 132 |
131 browser_plugin_manager()->sink().ClearMessages(); | 133 browser_plugin_manager()->sink().ClearMessages(); |
132 // Navigate to bar and observe the associated | 134 // Navigate to bar and observe the associated |
133 // BrowserPluginHostMsg_NavigateOrCreateGuest message. | 135 // BrowserPluginHostMsg_NavigateGuest message. |
134 // Verify that the src attribute is updated as well. | 136 // Verify that the src attribute is updated as well. |
135 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 137 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
136 { | 138 { |
137 const IPC::Message* msg = | 139 const IPC::Message* msg = |
138 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 140 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
139 BrowserPluginHostMsg_NavigateOrCreateGuest::ID); | 141 BrowserPluginHostMsg_NavigateGuest::ID); |
140 ASSERT_TRUE(msg); | 142 ASSERT_TRUE(msg); |
141 | 143 |
142 int instance_id; | 144 int instance_id; |
143 long long frame_id; | 145 long long frame_id; |
144 std::string src; | 146 std::string src; |
145 BrowserPluginHostMsg_NavigateOrCreateGuest::Read( | 147 gfx::Size size; |
148 BrowserPluginHostMsg_NavigateGuest::Read( | |
146 msg, | 149 msg, |
147 &instance_id, | 150 &instance_id, |
148 &frame_id, | 151 &frame_id, |
149 &src); | 152 &src, |
153 &size); | |
150 EXPECT_EQ("bar", src); | 154 EXPECT_EQ("bar", src); |
151 std::string src_value = | 155 std::string src_value = |
152 ExecuteScriptAndReturnString( | 156 ExecuteScriptAndReturnString( |
153 "document.getElementById('browserplugin').src"); | 157 "document.getElementById('browserplugin').src"); |
154 EXPECT_EQ("bar", src_value); | 158 EXPECT_EQ("bar", src_value); |
155 } | 159 } |
156 } | 160 } |
157 | 161 |
158 TEST_F(BrowserPluginTest, ResizeFlowControl) { | 162 TEST_F(BrowserPluginTest, ResizeFlowControl) { |
159 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 163 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 317 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
314 | 318 |
315 ExecuteJavaScript(kRemoveEventListener); | 319 ExecuteJavaScript(kRemoveEventListener); |
316 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); | 320 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); |
317 // The URL variable should not change because we've removed the event | 321 // The URL variable should not change because we've removed the event |
318 // listener. | 322 // listener. |
319 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 323 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
320 } | 324 } |
321 | 325 |
322 } // namespace content | 326 } // namespace content |
OLD | NEW |