OLD | NEW |
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" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ASSERT_EQ(true, StartsWithASCII(text, "DONE", true)); | 148 ASSERT_EQ(true, StartsWithASCII(text, "DONE", true)); |
149 } | 149 } |
150 #endif | 150 #endif |
151 | 151 |
152 // Tests that if a frame is deleted as a result of calling NPP_HandleEvent, we | 152 // Tests that if a frame is deleted as a result of calling NPP_HandleEvent, we |
153 // don't crash. | 153 // don't crash. |
154 TEST_F(PluginTest, DeleteFrameDuringEvent) { | 154 TEST_F(PluginTest, DeleteFrameDuringEvent) { |
155 FilePath test_html = data_dir_; | 155 FilePath test_html = data_dir_; |
156 test_html = test_html.AppendASCII("plugins"); | 156 test_html = test_html.AppendASCII("plugins"); |
157 test_html = test_html.AppendASCII("delete_frame.html"); | 157 test_html = test_html.AppendASCII("delete_frame.html"); |
158 test_shell_->LoadURL(test_html.ToWStringHack().c_str()); | 158 test_shell_->LoadFile(test_html); |
159 test_shell_->WaitTestFinished(); | 159 test_shell_->WaitTestFinished(); |
160 | 160 |
161 WebKit::WebMouseEvent input; | 161 WebKit::WebMouseEvent input; |
162 input.button = WebKit::WebMouseEvent::ButtonLeft; | 162 input.button = WebKit::WebMouseEvent::ButtonLeft; |
163 input.x = 50; | 163 input.x = 50; |
164 input.y = 50; | 164 input.y = 50; |
165 input.type = WebKit::WebInputEvent::MouseUp; | 165 input.type = WebKit::WebInputEvent::MouseUp; |
166 test_shell_->webView()->handleInputEvent(input); | 166 test_shell_->webView()->handleInputEvent(input); |
167 | 167 |
168 // No crash means we passed. | 168 // No crash means we passed. |
169 } | 169 } |
170 | 170 |
171 #if defined(OS_WIN) | 171 #if defined(OS_WIN) |
172 BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lparam) { | 172 BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lparam) { |
173 HWND* plugin_hwnd = reinterpret_cast<HWND*>(lparam); | 173 HWND* plugin_hwnd = reinterpret_cast<HWND*>(lparam); |
174 if (*plugin_hwnd) { | 174 if (*plugin_hwnd) { |
175 // More than one child window found, unexpected. | 175 // More than one child window found, unexpected. |
176 plugin_hwnd = NULL; | 176 plugin_hwnd = NULL; |
177 return FALSE; | 177 return FALSE; |
178 } | 178 } |
179 *plugin_hwnd = hwnd; | 179 *plugin_hwnd = hwnd; |
180 return TRUE; | 180 return TRUE; |
181 } | 181 } |
182 | 182 |
183 // Tests that hiding/showing the parent frame hides/shows the plugin. | 183 // Tests that hiding/showing the parent frame hides/shows the plugin. |
184 TEST_F(PluginTest, PluginVisibilty) { | 184 TEST_F(PluginTest, PluginVisibilty) { |
185 FilePath test_html = data_dir_; | 185 FilePath test_html = data_dir_; |
186 test_html = test_html.AppendASCII("plugins"); | 186 test_html = test_html.AppendASCII("plugins"); |
187 test_html = test_html.AppendASCII("plugin_visibility.html"); | 187 test_html = test_html.AppendASCII("plugin_visibility.html"); |
188 test_shell_->LoadURL(test_html.ToWStringHack().c_str()); | 188 test_shell_->LoadFile(test_html); |
189 test_shell_->WaitTestFinished(); | 189 test_shell_->WaitTestFinished(); |
190 | 190 |
191 WebFrame* main_frame = test_shell_->webView()->GetMainFrame(); | 191 WebFrame* main_frame = test_shell_->webView()->GetMainFrame(); |
192 HWND frame_hwnd = test_shell_->webViewWnd(); | 192 HWND frame_hwnd = test_shell_->webViewWnd(); |
193 HWND plugin_hwnd = NULL; | 193 HWND plugin_hwnd = NULL; |
194 EnumChildWindows(frame_hwnd, EnumChildProc, | 194 EnumChildWindows(frame_hwnd, EnumChildProc, |
195 reinterpret_cast<LPARAM>(&plugin_hwnd)); | 195 reinterpret_cast<LPARAM>(&plugin_hwnd)); |
196 ASSERT_TRUE(plugin_hwnd != NULL); | 196 ASSERT_TRUE(plugin_hwnd != NULL); |
197 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); | 197 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); |
198 | 198 |
199 main_frame->executeScript(WebString::fromUTF8("showPlugin(true)")); | 199 main_frame->executeScript(WebString::fromUTF8("showPlugin(true)")); |
200 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); | 200 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); |
201 | 201 |
202 main_frame->executeScript(WebString::fromUTF8("showFrame(false)")); | 202 main_frame->executeScript(WebString::fromUTF8("showFrame(false)")); |
203 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); | 203 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); |
204 | 204 |
205 main_frame->executeScript(WebString::fromUTF8("showFrame(true)")); | 205 main_frame->executeScript(WebString::fromUTF8("showFrame(true)")); |
206 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); | 206 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); |
207 } | 207 } |
208 #endif | 208 #endif |
209 #endif //!ARCH_CPU_64_BITS | 209 #endif //!ARCH_CPU_64_BITS |
OLD | NEW |