Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "public/web/WebPrintParams.h" 59 #include "public/web/WebPrintParams.h"
60 #include "public/web/WebSettings.h" 60 #include "public/web/WebSettings.h"
61 #include "public/web/WebView.h" 61 #include "public/web/WebView.h"
62 #include "testing/gtest/include/gtest/gtest.h" 62 #include "testing/gtest/include/gtest/gtest.h"
63 #include "third_party/skia/include/core/SkPictureRecorder.h" 63 #include "third_party/skia/include/core/SkPictureRecorder.h"
64 #include "web/WebLocalFrameImpl.h" 64 #include "web/WebLocalFrameImpl.h"
65 #include "web/WebPluginContainerImpl.h" 65 #include "web/WebPluginContainerImpl.h"
66 #include "web/WebViewImpl.h" 66 #include "web/WebViewImpl.h"
67 #include "web/tests/FakeWebPlugin.h" 67 #include "web/tests/FakeWebPlugin.h"
68 #include "web/tests/FrameTestHelpers.h" 68 #include "web/tests/FrameTestHelpers.h"
69 #include "wtf/PtrUtil.h"
70 #include <memory>
69 71
70 using blink::testing::runPendingTasks; 72 using blink::testing::runPendingTasks;
71 73
72 namespace blink { 74 namespace blink {
73 75
74 class WebPluginContainerTest : public ::testing::Test { 76 class WebPluginContainerTest : public ::testing::Test {
75 public: 77 public:
76 WebPluginContainerTest() 78 WebPluginContainerTest()
77 : m_baseURL("http://www.test.com/") 79 : m_baseURL("http://www.test.com/")
78 { 80 {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 597
596 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); 598 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect));
597 } 599 }
598 600
599 namespace { 601 namespace {
600 602
601 class CompositedPlugin : public FakeWebPlugin { 603 class CompositedPlugin : public FakeWebPlugin {
602 public: 604 public:
603 CompositedPlugin(WebLocalFrame* frame, const WebPluginParams& params) 605 CompositedPlugin(WebLocalFrame* frame, const WebPluginParams& params)
604 : FakeWebPlugin(frame, params) 606 : FakeWebPlugin(frame, params)
605 , m_layer(adoptPtr(Platform::current()->compositorSupport()->createLayer ())) 607 , m_layer(wrapUnique(Platform::current()->compositorSupport()->createLay er()))
606 { 608 {
607 } 609 }
608 610
609 WebLayer* getWebLayer() const { return m_layer.get(); } 611 WebLayer* getWebLayer() const { return m_layer.get(); }
610 612
611 // WebPlugin 613 // WebPlugin
612 614
613 bool initialize(WebPluginContainer* container) override 615 bool initialize(WebPluginContainer* container) override
614 { 616 {
615 if (!FakeWebPlugin::initialize(container)) 617 if (!FakeWebPlugin::initialize(container))
616 return false; 618 return false;
617 container->setWebLayer(m_layer.get()); 619 container->setWebLayer(m_layer.get());
618 return true; 620 return true;
619 } 621 }
620 622
621 void destroy() override 623 void destroy() override
622 { 624 {
623 container()->setWebLayer(nullptr); 625 container()->setWebLayer(nullptr);
624 FakeWebPlugin::destroy(); 626 FakeWebPlugin::destroy();
625 } 627 }
626 628
627 private: 629 private:
628 OwnPtr<WebLayer> m_layer; 630 std::unique_ptr<WebLayer> m_layer;
629 }; 631 };
630 632
631 class ScopedSPv2 { 633 class ScopedSPv2 {
632 public: 634 public:
633 ScopedSPv2() { RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); } 635 ScopedSPv2() { RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); }
634 ~ScopedSPv2() { m_featuresBackup.restore(); } 636 ~ScopedSPv2() { m_featuresBackup.restore(); }
635 private: 637 private:
636 RuntimeEnabledFeatures::Backup m_featuresBackup; 638 RuntimeEnabledFeatures::Backup m_featuresBackup;
637 }; 639 };
638 640
(...skipping 10 matching lines...) Expand all
649 webView->settings()->setPluginsEnabled(true); 651 webView->settings()->setPluginsEnabled(true);
650 webView->resize(WebSize(800, 600)); 652 webView->resize(WebSize(800, 600));
651 webView->updateAllLifecyclePhases(); 653 webView->updateAllLifecyclePhases();
652 runPendingTasks(); 654 runPendingTasks();
653 655
654 WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(get WebPluginContainer(webView, WebString::fromUTF8("plugin"))); 656 WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(get WebPluginContainer(webView, WebString::fromUTF8("plugin")));
655 ASSERT_TRUE(container); 657 ASSERT_TRUE(container);
656 Element* element = static_cast<Element*>(container->element()); 658 Element* element = static_cast<Element*>(container->element());
657 const auto* plugin = static_cast<const CompositedPlugin*>(container->plugin( )); 659 const auto* plugin = static_cast<const CompositedPlugin*>(container->plugin( ));
658 660
659 OwnPtr<PaintController> paintController = PaintController::create(); 661 std::unique_ptr<PaintController> paintController = PaintController::create() ;
660 GraphicsContext graphicsContext(*paintController); 662 GraphicsContext graphicsContext(*paintController);
661 container->paint(graphicsContext, CullRect(IntRect(10, 10, 400, 300))); 663 container->paint(graphicsContext, CullRect(IntRect(10, 10, 400, 300)));
662 paintController->commitNewDisplayItems(); 664 paintController->commitNewDisplayItems();
663 665
664 const auto& displayItems = paintController->paintArtifact().getDisplayItemLi st(); 666 const auto& displayItems = paintController->paintArtifact().getDisplayItemLi st();
665 ASSERT_EQ(1u, displayItems.size()); 667 ASSERT_EQ(1u, displayItems.size());
666 EXPECT_EQ(element->layoutObject(), &displayItems[0].client()); 668 EXPECT_EQ(element->layoutObject(), &displayItems[0].client());
667 ASSERT_EQ(DisplayItem::ForeignLayerPlugin, displayItems[0].getType()); 669 ASSERT_EQ(DisplayItem::ForeignLayerPlugin, displayItems[0].getType());
668 const auto& foreignLayerDisplayItem = static_cast<const ForeignLayerDisplayI tem&>(displayItems[0]); 670 const auto& foreignLayerDisplayItem = static_cast<const ForeignLayerDisplayI tem&>(displayItems[0]);
669 EXPECT_EQ(plugin->getWebLayer()->ccLayer(), foreignLayerDisplayItem.layer()) ; 671 EXPECT_EQ(plugin->getWebLayer()->ccLayer(), foreignLayerDisplayItem.layer()) ;
(...skipping 14 matching lines...) Expand all
684 runPendingTasks(); 686 runPendingTasks();
685 687
686 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin")); 688 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin"));
687 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); 689 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true);
688 690
689 runPendingTasks(); 691 runPendingTasks();
690 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand lers(EventHandlerRegistry::WheelEventBlocking)); 692 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand lers(EventHandlerRegistry::WheelEventBlocking));
691 } 693 }
692 694
693 } // namespace blink 695 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebFrameTest.cpp ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698