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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 WebPluginContainerTest() | 65 WebPluginContainerTest() |
66 : m_baseURL("http://www.test.com/") | 66 : m_baseURL("http://www.test.com/") |
67 { | 67 { |
68 } | 68 } |
69 | 69 |
70 void TearDown() override | 70 void TearDown() override |
71 { | 71 { |
72 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 72 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
73 } | 73 } |
74 | 74 |
| 75 void calculateGeometry(WebPluginContainerImpl* pluginContainerImpl, IntRect&
windowRect, IntRect& clipRect, IntRect& unobscuredRect, Vector<IntRect>& cutOut
Rects) |
| 76 { |
| 77 pluginContainerImpl->calculateGeometry(windowRect, clipRect, unobscuredR
ect, cutOutRects); |
| 78 } |
| 79 |
75 protected: | 80 protected: |
76 std::string m_baseURL; | 81 std::string m_baseURL; |
77 }; | 82 }; |
78 | 83 |
79 class TestPluginWebFrameClient; | 84 class TestPluginWebFrameClient; |
80 | 85 |
81 // Subclass of FakeWebPlugin that has a selection of 'x' as plain text and 'y' a
s markup text. | 86 // Subclass of FakeWebPlugin that has a selection of 'x' as plain text and 'y' a
s markup text. |
82 class TestPlugin : public FakeWebPlugin { | 87 class TestPlugin : public FakeWebPlugin { |
83 public: | 88 public: |
84 TestPlugin(WebFrame* frame, const WebPluginParams& params, TestPluginWebFram
eClient* testClient) | 89 TestPlugin(WebFrame* frame, const WebPluginParams& params, TestPluginWebFram
eClient* testClient) |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 400 |
396 WebRect rect = pluginContainerImpl->element().boundsInViewport(); | 401 WebRect rect = pluginContainerImpl->element().boundsInViewport(); |
397 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); | 402 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); |
398 | 403 |
399 // Cause the plugin's frame to be detached. | 404 // Cause the plugin's frame to be detached. |
400 webViewHelper.reset(); | 405 webViewHelper.reset(); |
401 | 406 |
402 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); | 407 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); |
403 } | 408 } |
404 | 409 |
| 410 #define EXPECT_RECT_EQ(expected, actual) \ |
| 411 do { \ |
| 412 const IntRect& actualRect = actual; \ |
| 413 EXPECT_EQ(expected.x(), actualRect.x()); \ |
| 414 EXPECT_EQ(expected.y(), actualRect.y()); \ |
| 415 EXPECT_EQ(expected.width(), actualRect.width()); \ |
| 416 EXPECT_EQ(expected.height(), actualRect.height()); \ |
| 417 } while (false) |
| 418 |
| 419 TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) |
| 420 { |
| 421 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 422 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_containing_page.html")); |
| 423 |
| 424 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 425 FrameTestHelpers::WebViewHelper webViewHelper; |
| 426 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
ining_page.html", true, &pluginWebFrameClient); |
| 427 ASSERT(webView); |
| 428 webView->settings()->setPluginsEnabled(true); |
| 429 webView->resize(WebSize(300, 300)); |
| 430 webView->updateAllLifecyclePhases(); |
| 431 runPendingTasks(); |
| 432 |
| 433 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge
tElementById("translated-plugin"); |
| 434 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPlugin
ContainerImpl(pluginElement.pluginContainer()); |
| 435 |
| 436 ASSERT(pluginContainerImpl.get()); |
| 437 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 438 |
| 439 IntRect windowRect, clipRect, unobscuredRect; |
| 440 Vector<IntRect> cutOutRects; |
| 441 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); |
| 442 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); |
| 443 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); |
| 444 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); |
| 445 |
| 446 // Cause the plugin's frame to be detached. |
| 447 webViewHelper.reset(); |
| 448 } |
| 449 |
405 TEST_F(WebPluginContainerTest, TopmostAfterDetachTest) | 450 TEST_F(WebPluginContainerTest, TopmostAfterDetachTest) |
406 { | 451 { |
407 static WebRect topmostRect(10, 10, 40, 40); | 452 static WebRect topmostRect(10, 10, 40, 40); |
408 | 453 |
409 // Plugin that checks isRectTopmost in destroy(). | 454 // Plugin that checks isRectTopmost in destroy(). |
410 class TopmostPlugin : public FakeWebPlugin { | 455 class TopmostPlugin : public FakeWebPlugin { |
411 public: | 456 public: |
412 TopmostPlugin(WebFrame* frame, const WebPluginParams& params) | 457 TopmostPlugin(WebFrame* frame, const WebPluginParams& params) |
413 : FakeWebPlugin(frame, params) {} | 458 : FakeWebPlugin(frame, params) {} |
414 | 459 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); | 496 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); |
452 EXPECT_TRUE(testPlugin->isRectTopmost()); | 497 EXPECT_TRUE(testPlugin->isRectTopmost()); |
453 | 498 |
454 // Cause the plugin's frame to be detached. | 499 // Cause the plugin's frame to be detached. |
455 webViewHelper.reset(); | 500 webViewHelper.reset(); |
456 | 501 |
457 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); | 502 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); |
458 } | 503 } |
459 | 504 |
460 } // namespace blink | 505 } // namespace blink |
OLD | NEW |