| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 test_shell_->webView()->mainFrame()->executeScript(refresh); | 120 test_shell_->webView()->mainFrame()->executeScript(refresh); |
| 121 test_shell_->webView()->mainFrame()->executeScript(call_check); | 121 test_shell_->webView()->mainFrame()->executeScript(call_check); |
| 122 text = test_shell_->webView()->mainFrame()->contentAsText(10000).utf8(); | 122 text = test_shell_->webView()->mainFrame()->contentAsText(10000).utf8(); |
| 123 ASSERT_EQ(text, "DONE"); | 123 ASSERT_EQ(text, "DONE"); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Tests that if a frame is deleted as a result of calling NPP_HandleEvent, we | 126 // Tests that if a frame is deleted as a result of calling NPP_HandleEvent, we |
| 127 // don't crash. | 127 // don't crash. |
| 128 TEST_F(PluginTest, DeleteFrameDuringEvent) { | 128 TEST_F(PluginTest, DeleteFrameDuringEvent) { |
| 129 FilePath test_html = data_dir_; | 129 FilePath test_html = data_dir_; |
| 130 test_html = test_html.AppendASCII("plugins"); | 130 test_html = test_html.AppendASCII(TEST_PLUGIN_DIRECTORY); |
| 131 test_html = test_html.AppendASCII("delete_frame.html"); | 131 test_html = test_html.AppendASCII("delete_frame.html"); |
| 132 test_shell_->LoadFile(test_html); | 132 test_shell_->LoadFile(test_html); |
| 133 test_shell_->WaitTestFinished(); | 133 test_shell_->WaitTestFinished(); |
| 134 | 134 |
| 135 WebKit::WebMouseEvent input; | 135 WebKit::WebMouseEvent input; |
| 136 input.button = WebKit::WebMouseEvent::ButtonLeft; | 136 input.button = WebKit::WebMouseEvent::ButtonLeft; |
| 137 input.x = 50; | 137 input.x = 50; |
| 138 input.y = 50; | 138 input.y = 50; |
| 139 input.type = WebKit::WebInputEvent::MouseUp; | 139 input.type = WebKit::WebInputEvent::MouseUp; |
| 140 test_shell_->webView()->handleInputEvent(input); | 140 test_shell_->webView()->handleInputEvent(input); |
| 141 | 141 |
| 142 // No crash means we passed. | 142 // No crash means we passed. |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Tests that a forced reload of the plugin will not crash. |
| 146 TEST_F(PluginTest, ForceReload) { |
| 147 FilePath test_html = data_dir_; |
| 148 test_html = test_html.AppendASCII(TEST_PLUGIN_DIRECTORY); |
| 149 test_html = test_html.AppendASCII("force_reload.html"); |
| 150 test_shell_->LoadFile(test_html); |
| 151 test_shell_->WaitTestFinished(); |
| 152 |
| 153 // No crash means we passed. |
| 154 } |
| 155 |
| 145 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
| 146 BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lparam) { | 157 BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lparam) { |
| 147 HWND* plugin_hwnd = reinterpret_cast<HWND*>(lparam); | 158 HWND* plugin_hwnd = reinterpret_cast<HWND*>(lparam); |
| 148 if (*plugin_hwnd) { | 159 if (*plugin_hwnd) { |
| 149 // More than one child window found, unexpected. | 160 // More than one child window found, unexpected. |
| 150 plugin_hwnd = NULL; | 161 plugin_hwnd = NULL; |
| 151 return FALSE; | 162 return FALSE; |
| 152 } | 163 } |
| 153 *plugin_hwnd = hwnd; | 164 *plugin_hwnd = hwnd; |
| 154 return TRUE; | 165 return TRUE; |
| 155 } | 166 } |
| 156 | 167 |
| 157 // Tests that hiding/showing the parent frame hides/shows the plugin. | 168 // Tests that hiding/showing the parent frame hides/shows the plugin. |
| 158 TEST_F(PluginTest, PluginVisibilty) { | 169 TEST_F(PluginTest, PluginVisibilty) { |
| 159 FilePath test_html = data_dir_; | 170 FilePath test_html = data_dir_; |
| 160 test_html = test_html.AppendASCII("plugins"); | 171 test_html = test_html.AppendASCII(TEST_PLUGIN_DIRECTORY); |
| 161 test_html = test_html.AppendASCII("plugin_visibility.html"); | 172 test_html = test_html.AppendASCII("plugin_visibility.html"); |
| 162 test_shell_->LoadFile(test_html); | 173 test_shell_->LoadFile(test_html); |
| 163 test_shell_->WaitTestFinished(); | 174 test_shell_->WaitTestFinished(); |
| 164 | 175 |
| 165 WebFrame* main_frame = test_shell_->webView()->mainFrame(); | 176 WebFrame* main_frame = test_shell_->webView()->mainFrame(); |
| 166 HWND frame_hwnd = test_shell_->webViewWnd(); | 177 HWND frame_hwnd = test_shell_->webViewWnd(); |
| 167 HWND plugin_hwnd = NULL; | 178 HWND plugin_hwnd = NULL; |
| 168 EnumChildWindows(frame_hwnd, EnumChildProc, | 179 EnumChildWindows(frame_hwnd, EnumChildProc, |
| 169 reinterpret_cast<LPARAM>(&plugin_hwnd)); | 180 reinterpret_cast<LPARAM>(&plugin_hwnd)); |
| 170 ASSERT_TRUE(plugin_hwnd != NULL); | 181 ASSERT_TRUE(plugin_hwnd != NULL); |
| 171 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); | 182 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); |
| 172 | 183 |
| 173 main_frame->executeScript(WebString::fromUTF8("showPlugin(true)")); | 184 main_frame->executeScript(WebString::fromUTF8("showPlugin(true)")); |
| 174 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); | 185 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); |
| 175 | 186 |
| 176 main_frame->executeScript(WebString::fromUTF8("showFrame(false)")); | 187 main_frame->executeScript(WebString::fromUTF8("showFrame(false)")); |
| 177 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); | 188 ASSERT_FALSE(IsWindowVisible(plugin_hwnd)); |
| 178 | 189 |
| 179 main_frame->executeScript(WebString::fromUTF8("showFrame(true)")); | 190 main_frame->executeScript(WebString::fromUTF8("showFrame(true)")); |
| 180 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); | 191 ASSERT_TRUE(IsWindowVisible(plugin_hwnd)); |
| 181 } | 192 } |
| 182 #endif | 193 #endif |
| 183 #endif //!ARCH_CPU_64_BITS | 194 #endif //!ARCH_CPU_64_BITS |
| OLD | NEW |