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