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

Side by Side Diff: webkit/tools/test_shell/plugin_tests.cc

Issue 164225: Switch to WebFrame from the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « webkit/tools/test_shell/layout_test_controller.cc ('k') | webkit/tools/test_shell/test_shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <string> 5 #include <string>
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 "base/string_util.h" 10 #include "base/string_util.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "webkit/api/public/WebData.h" 13 #include "webkit/api/public/WebData.h"
14 #include "webkit/api/public/WebFrame.h"
14 #include "webkit/api/public/WebInputEvent.h" 15 #include "webkit/api/public/WebInputEvent.h"
15 #include "webkit/api/public/WebScriptSource.h" 16 #include "webkit/api/public/WebScriptSource.h"
16 #include "webkit/glue/webframe.h"
17 #include "webkit/glue/webview.h" 17 #include "webkit/glue/webview.h"
18 #include "webkit/tools/test_shell/test_shell.h" 18 #include "webkit/tools/test_shell/test_shell.h"
19 #include "webkit/tools/test_shell/test_shell_test.h" 19 #include "webkit/tools/test_shell/test_shell_test.h"
20 20
21 using WebKit::WebFrame;
21 using WebKit::WebScriptSource; 22 using WebKit::WebScriptSource;
22 using WebKit::WebString; 23 using WebKit::WebString;
23 24
24 #if defined(OS_WIN) 25 #if defined(OS_WIN)
25 #define TEST_PLUGIN_NAME "npapi_test_plugin.dll" 26 #define TEST_PLUGIN_NAME "npapi_test_plugin.dll"
26 #elif defined(OS_MACOSX) 27 #elif defined(OS_MACOSX)
27 #define TEST_PLUGIN_NAME "npapi_test_plugin.bundle" 28 #define TEST_PLUGIN_NAME "npapi_test_plugin.bundle"
28 #elif defined(OS_LINUX) 29 #elif defined(OS_LINUX)
29 #define TEST_PLUGIN_NAME "libnpapi_test_plugin.so" 30 #define TEST_PLUGIN_NAME "libnpapi_test_plugin.so"
30 #endif 31 #endif
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 WebScriptSource call_check( 91 WebScriptSource call_check(
91 WebString::fromUTF8("check();")); 92 WebString::fromUTF8("check();"));
92 WebScriptSource refresh( 93 WebScriptSource refresh(
93 WebString::fromUTF8("navigator.plugins.refresh(false)")); 94 WebString::fromUTF8("navigator.plugins.refresh(false)"));
94 95
95 // Remove any leftover from previous tests if they exist. We must also 96 // Remove any leftover from previous tests if they exist. We must also
96 // refresh WebKit's plugin cache since it might have had an entry for the 97 // refresh WebKit's plugin cache since it might have had an entry for the
97 // test plugin from a previous test. 98 // test plugin from a previous test.
98 DeleteTestPlugin(); 99 DeleteTestPlugin();
99 ASSERT_FALSE(file_util::PathExists(plugin_file_path_)); 100 ASSERT_FALSE(file_util::PathExists(plugin_file_path_));
100 test_shell_->webView()->GetMainFrame()->ExecuteScript(refresh); 101 test_shell_->webView()->GetMainFrame()->executeScript(refresh);
101 102
102 test_shell_->webView()->GetMainFrame()->LoadHTMLString( 103 test_shell_->webView()->GetMainFrame()->loadHTMLString(
103 html, GURL("about:blank")); 104 html, GURL("about:blank"));
104 test_shell_->WaitTestFinished(); 105 test_shell_->WaitTestFinished();
105 106
106 std::wstring text; 107 std::string text;
107 test_shell_->webView()->GetMainFrame()->ExecuteScript(call_check); 108 test_shell_->webView()->GetMainFrame()->executeScript(call_check);
108 test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text); 109 text = test_shell_->webView()->GetMainFrame()->contentAsText(10000).utf8();
109 ASSERT_EQ(text, L"FAIL"); 110 ASSERT_EQ(text, "FAIL");
110 111
111 CopyTestPlugin(); 112 CopyTestPlugin();
112 113
113 test_shell_->webView()->GetMainFrame()->ExecuteScript(refresh); 114 test_shell_->webView()->GetMainFrame()->executeScript(refresh);
114 test_shell_->webView()->GetMainFrame()->ExecuteScript(call_check); 115 test_shell_->webView()->GetMainFrame()->executeScript(call_check);
115 test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text); 116 text = test_shell_->webView()->GetMainFrame()->contentAsText(10000).utf8();
116 ASSERT_EQ(text, L"DONE"); 117 ASSERT_EQ(text, "DONE");
117 } 118 }
118 119
119 #if defined(OS_WIN) 120 #if defined(OS_WIN)
120 // TODO(port): Reenable on mac and linux once they have working default plugins. 121 // TODO(port): Reenable on mac and linux once they have working default plugins.
121 TEST_F(PluginTest, DefaultPluginLoadTest) { 122 TEST_F(PluginTest, DefaultPluginLoadTest) {
122 std::string html = "\ 123 std::string html = "\
123 <div id='result'>Test running....</div>\ 124 <div id='result'>Test running....</div>\
124 <script>\ 125 <script>\
125 function onSuccess() {\ 126 function onSuccess() {\
126 var result = document.getElementById('result');\ 127 var result = document.getElementById('result');\
127 result.innerHTML = 'DONE';\ 128 result.innerHTML = 'DONE';\
128 }\ 129 }\
129 </script>\ 130 </script>\
130 <DIV ID=PluginDiv>\ 131 <DIV ID=PluginDiv>\
131 <object classid=\"clsid:9E8BC6CE-AF35-400c-ABF6-A3F746A1871D\">\ 132 <object classid=\"clsid:9E8BC6CE-AF35-400c-ABF6-A3F746A1871D\">\
132 <embed type=\"application/chromium-test-default-plugin\"\ 133 <embed type=\"application/chromium-test-default-plugin\"\
133 mode=\"np_embed\"\ 134 mode=\"np_embed\"\
134 ></embed>\ 135 ></embed>\
135 </object>\ 136 </object>\
136 </DIV>\ 137 </DIV>\
137 "; 138 ";
138 139
139 test_shell_->webView()->GetMainFrame()->LoadHTMLString( 140 test_shell_->webView()->GetMainFrame()->loadHTMLString(
140 html, GURL("about:blank")); 141 html, GURL("about:blank"));
141 test_shell_->WaitTestFinished(); 142 test_shell_->WaitTestFinished();
142 143
143 std::wstring text; 144 std::string text =
144 test_shell_->webView()->GetMainFrame()->GetContentAsPlainText(10000, &text); 145 test_shell_->webView()->GetMainFrame()->contentAsText(10000).utf8();
145 146 ASSERT_EQ(true, StartsWithASCII(text, "DONE", true));
146 ASSERT_EQ(true, StartsWith(text, L"DONE", true));
147 } 147 }
148 #endif 148 #endif
149 149
150 // Tests that if a frame is deleted as a result of calling NPP_HandleEvent, we 150 // Tests that if a frame is deleted as a result of calling NPP_HandleEvent, we
151 // don't crash. 151 // don't crash.
152 TEST_F(PluginTest, DeleteFrameDuringEvent) { 152 TEST_F(PluginTest, DeleteFrameDuringEvent) {
153 FilePath test_html = data_dir_; 153 FilePath test_html = data_dir_;
154 test_html = test_html.AppendASCII("plugins"); 154 test_html = test_html.AppendASCII("plugins");
155 test_html = test_html.AppendASCII("delete_frame.html"); 155 test_html = test_html.AppendASCII("delete_frame.html");
156 test_shell_->LoadURL(test_html.ToWStringHack().c_str()); 156 test_shell_->LoadURL(test_html.ToWStringHack().c_str());
(...skipping 30 matching lines...) Expand all
187 test_shell_->WaitTestFinished(); 187 test_shell_->WaitTestFinished();
188 188
189 WebFrame* main_frame = test_shell_->webView()->GetMainFrame(); 189 WebFrame* main_frame = test_shell_->webView()->GetMainFrame();
190 HWND frame_hwnd = test_shell_->webViewWnd(); 190 HWND frame_hwnd = test_shell_->webViewWnd();
191 HWND plugin_hwnd = NULL; 191 HWND plugin_hwnd = NULL;
192 EnumChildWindows(frame_hwnd, EnumChildProc, 192 EnumChildWindows(frame_hwnd, EnumChildProc,
193 reinterpret_cast<LPARAM>(&plugin_hwnd)); 193 reinterpret_cast<LPARAM>(&plugin_hwnd));
194 ASSERT_TRUE(plugin_hwnd != NULL); 194 ASSERT_TRUE(plugin_hwnd != NULL);
195 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); 195 ASSERT_FALSE(IsWindowVisible(plugin_hwnd));
196 196
197 main_frame->ExecuteScript(WebString::fromUTF8("showPlugin(true)")); 197 main_frame->executeScript(WebString::fromUTF8("showPlugin(true)"));
198 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); 198 ASSERT_TRUE(IsWindowVisible(plugin_hwnd));
199 199
200 main_frame->ExecuteScript(WebString::fromUTF8("showFrame(false)")); 200 main_frame->executeScript(WebString::fromUTF8("showFrame(false)"));
201 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); 201 ASSERT_FALSE(IsWindowVisible(plugin_hwnd));
202 202
203 main_frame->ExecuteScript(WebString::fromUTF8("showFrame(true)")); 203 main_frame->executeScript(WebString::fromUTF8("showFrame(true)"));
204 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); 204 ASSERT_TRUE(IsWindowVisible(plugin_hwnd));
205 } 205 }
206 #endif 206 #endif
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/layout_test_controller.cc ('k') | webkit/tools/test_shell/test_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698