| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 frame->printBegin(printParams); | 201 frame->printBegin(printParams); |
| 202 SkPictureRecorder recorder; | 202 SkPictureRecorder recorder; |
| 203 frame->printPagesWithBoundaries(recorder.beginRecording(IntRect()), WebSize(
)); | 203 frame->printPagesWithBoundaries(recorder.beginRecording(IntRect()), WebSize(
)); |
| 204 frame->printEnd(); | 204 frame->printEnd(); |
| 205 ASSERT(pluginWebFrameClient.printedAtLeastOnePage()); | 205 ASSERT(pluginWebFrameClient.printedAtLeastOnePage()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) | 208 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) |
| 209 { | 209 { |
| 210 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 210 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 211 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 211 FrameTestHelpers::WebViewHelper webViewHelper; | 212 FrameTestHelpers::WebViewHelper webViewHelper; |
| 212 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, new TestPluginWebFrameClient()); | 213 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 213 ASSERT(webView); | 214 ASSERT(webView); |
| 214 webView->settings()->setPluginsEnabled(true); | 215 webView->settings()->setPluginsEnabled(true); |
| 215 webView->resize(WebSize(300, 300)); | 216 webView->resize(WebSize(300, 300)); |
| 216 webView->layout(); | 217 webView->layout(); |
| 217 runPendingTasks(); | 218 runPendingTasks(); |
| 218 | 219 |
| 219 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); | 220 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); |
| 220 ASSERT(pluginContainerOne); | 221 ASSERT(pluginContainerOne); |
| 221 WebPoint point1 = pluginContainerOne->localToRootFramePoint(WebPoint(0, 0)); | 222 WebPoint point1 = pluginContainerOne->localToRootFramePoint(WebPoint(0, 0)); |
| 222 ASSERT_EQ(10, point1.x); | 223 ASSERT_EQ(10, point1.x); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return new EventTestPlugin(frame, params); | 317 return new EventTestPlugin(frame, params); |
| 317 return WebFrameClient::createPlugin(frame, params); | 318 return WebFrameClient::createPlugin(frame, params); |
| 318 } | 319 } |
| 319 }; | 320 }; |
| 320 | 321 |
| 321 TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) | 322 TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) |
| 322 { | 323 { |
| 323 URLTestHelpers::registerMockedURLFromBaseURL( | 324 URLTestHelpers::registerMockedURLFromBaseURL( |
| 324 WebString::fromUTF8(m_baseURL.c_str()), | 325 WebString::fromUTF8(m_baseURL.c_str()), |
| 325 WebString::fromUTF8("plugin_container.html")); | 326 WebString::fromUTF8("plugin_container.html")); |
| 327 EventTestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewH
elper. |
| 326 FrameTestHelpers::WebViewHelper webViewHelper; | 328 FrameTestHelpers::WebViewHelper webViewHelper; |
| 327 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, new EventTestPluginWebFrameClient()); | 329 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 328 ASSERT(webView); | 330 ASSERT(webView); |
| 329 webView->settings()->setPluginsEnabled(true); | 331 webView->settings()->setPluginsEnabled(true); |
| 330 webView->resize(WebSize(300, 300)); | 332 webView->resize(WebSize(300, 300)); |
| 331 webView->layout(); | 333 webView->layout(); |
| 332 runPendingTasks(); | 334 runPendingTasks(); |
| 333 | 335 |
| 334 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 336 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 335 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(pluginContainerOneE
lement.pluginContainer())->plugin(); | 337 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(pluginContainerOneE
lement.pluginContainer())->plugin(); |
| 336 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); | 338 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); |
| 337 | 339 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 }; | 411 }; |
| 410 | 412 |
| 411 class TopmostPluginWebFrameClient : public FrameTestHelpers::TestWebFrameCli
ent { | 413 class TopmostPluginWebFrameClient : public FrameTestHelpers::TestWebFrameCli
ent { |
| 412 WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& par
ams) override | 414 WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& par
ams) override |
| 413 { | 415 { |
| 414 return new TopmostPlugin(frame, params); | 416 return new TopmostPlugin(frame, params); |
| 415 } | 417 } |
| 416 }; | 418 }; |
| 417 | 419 |
| 418 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 420 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 421 TopmostPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHel
per. |
| 419 FrameTestHelpers::WebViewHelper webViewHelper; | 422 FrameTestHelpers::WebViewHelper webViewHelper; |
| 420 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, new TopmostPluginWebFrameClient()); | 423 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 421 ASSERT(webView); | 424 ASSERT(webView); |
| 422 webView->settings()->setPluginsEnabled(true); | 425 webView->settings()->setPluginsEnabled(true); |
| 423 webView->resize(WebSize(300, 300)); | 426 webView->resize(WebSize(300, 300)); |
| 424 webView->layout(); | 427 webView->layout(); |
| 425 runPendingTasks(); | 428 runPendingTasks(); |
| 426 | 429 |
| 427 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = | 430 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = |
| 428 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); | 431 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); |
| 429 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 432 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 430 | 433 |
| 431 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); | 434 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); |
| 432 | 435 |
| 433 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); | 436 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); |
| 434 EXPECT_TRUE(testPlugin->isRectTopmost()); | 437 EXPECT_TRUE(testPlugin->isRectTopmost()); |
| 435 | 438 |
| 436 // Cause the plugin's frame to be detached. | 439 // Cause the plugin's frame to be detached. |
| 437 webViewHelper.reset(); | 440 webViewHelper.reset(); |
| 438 | 441 |
| 439 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); | 442 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); |
| 440 } | 443 } |
| 441 | 444 |
| 442 } // namespace blink | 445 } // namespace blink |
| OLD | NEW |