Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_browsertest.cc

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: Clean up BrowserPluginHostTest, remove unused var, use constants for str. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 namespace { 23 namespace {
24 const char kHTMLForBrowserPluginObject[] = 24 const char kHTMLForBrowserPluginObject[] =
25 "<object id='browserplugin' width='640px' height='480px'" 25 "<object id='browserplugin' width='640px' height='480px'"
26 " src='foo' type='%s'>"; 26 " src='foo' type='%s'>";
27 27
28 std::string GetHTMLForBrowserPluginObject() { 28 std::string GetHTMLForBrowserPluginObject() {
29 return StringPrintf(kHTMLForBrowserPluginObject, 29 return StringPrintf(kHTMLForBrowserPluginObject,
30 content::kBrowserPluginNewMimeType); 30 content::kBrowserPluginNewMimeType);
31 } 31 }
32 32
33 } 33 }
awong 2012/09/09 18:08:09 closing namespace comment.
lazyboy 2012/09/10 16:30:17 Done.
lazyboy 2012/09/10 16:30:17 Done.
34 34
35 namespace content { 35 namespace content {
36 36
37 BrowserPluginTest::BrowserPluginTest() {} 37 BrowserPluginTest::BrowserPluginTest() {}
38 38
39 BrowserPluginTest::~BrowserPluginTest() {} 39 BrowserPluginTest::~BrowserPluginTest() {}
40 40
41 void BrowserPluginTest::SetUp() { 41 void BrowserPluginTest::SetUp() {
42 GetContentClient()->set_renderer_for_testing(&content_renderer_client_); 42 GetContentClient()->set_renderer_for_testing(&content_renderer_client_);
43 content::RenderViewTest::SetUp(); 43 content::RenderViewTest::SetUp();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698