chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc

/*
 * Copyright (C) 2012 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "third_party/blink/public/web/web_plugin_container.h"

#include <memory>
#include <string>

#include "build/build_config.h"
#include "cc/layers/layer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/web_coalesced_input_event.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#include "third_party/blink/public/common/input/web_pointer_event.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_element.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_plugin_params.h"
#include "third_party/blink/public/web/web_print_params.h"
#include "third_party/blink/public/web/web_settings.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/core/clipboard/system_clipboard.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/events/keyboard_event.h"
#include "third_party/blink/renderer/core/exported/web_plugin_container_impl.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/event_handler_registry.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/testing/fake_web_plugin.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/core/testing/scoped_fake_plugin_registry.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/cull_rect.h"
#include "third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_recorder.h"
#include "third_party/blink/renderer/platform/keyboard_codes.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_loader_mock_factory.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"

RunPendingTasks;

namespace blink {

class WebPluginContainerTest : public PageTestBase {};

namespace {

#if BUILDFLAG(IS_MAC)
const WebInputEvent::Modifiers kEditingModifier = WebInputEvent::kMetaKey;
#else
const WebInputEvent::Modifiers kEditingModifier =;
#endif

template <typename T>
class CustomPluginWebFrameClient
    : public frame_test_helpers::TestWebFrameClient {};

class TestPluginWebFrameClient;

// Subclass of FakeWebPlugin that has a selection of 'x' as plain text and 'y'
// as markup text.
class TestPlugin : public FakeWebPlugin {};

// Subclass of FakeWebPlugin used for testing edit commands, so HasSelection()
// and CanEditText() return true by default.
class TestPluginWithEditableText : public FakeWebPlugin {};

class TestPluginWebFrameClient : public frame_test_helpers::TestWebFrameClient {};

bool TestPlugin::CanCopy() const {}

void TestPlugin::PrintPage(int page_index, cc::PaintCanvas* canvas) {}

void EnablePlugins(WebView* web_view, const gfx::Size& size) {}

WebPluginContainer* GetWebPluginContainer(WebViewImpl* web_view,
                                          const WebString& id) {}

String ReadClipboard(LocalFrame& frame) {}

void ClearClipboardBuffer(LocalFrame& frame) {}

void CreateAndHandleKeyboardEvent(WebElement* plugin_container_one_element,
                                  WebInputEvent::Modifiers modifier_key,
                                  int key_code) {}

void ExecuteContextMenuCommand(WebViewImpl* web_view,
                               const WebString& command_name) {}

}  // namespace

TEST_F(WebPluginContainerTest, WindowToLocalPointTest) {}

TEST_F(WebPluginContainerTest, LocalToWindowPointTest) {}

// Verifies executing the command 'Copy' results in copying to the clipboard.
TEST_F(WebPluginContainerTest, Copy) {}

// Verifies executing the command 'Copy' results in copying nothing to the
// clipboard when the plugin does not have the copy permission.
TEST_F(WebPluginContainerTest, CopyWithoutPermission) {}

TEST_F(WebPluginContainerTest, CopyFromContextMenu) {}

TEST_F(WebPluginContainerTest, CopyFromContextMenuWithoutCopyPermission) {}

// Verifies `Ctrl-C` and `Ctrl-Insert` keyboard events, results in copying to
// the clipboard.
TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) {}

// Verifies `Ctrl-C` and `Ctrl-Insert` keyboard events, results in copying
// nothing to the clipboard.
TEST_F(WebPluginContainerTest,
       CopyInsertKeyboardEventsTestWithoutCopyPermission) {}

// Verifies |Ctrl-X| and |Shift-Delete| keyboard events, results in the "Cut"
// command being invoked.
TEST_F(WebPluginContainerTest, CutDeleteKeyboardEventsTest) {}

// Verifies |Ctrl-V| and |Shift-Insert| keyboard events, results in the "Paste"
// command being invoked.
TEST_F(WebPluginContainerTest, PasteInsertKeyboardEventsTest) {}

// Verifies |Ctrl-Shift-V| keyboard event results in the "PasteAndMatchStyle"
// command being invoked.
TEST_F(WebPluginContainerTest, PasteAndMatchStyleKeyboardEventsTest) {}

TEST_F(WebPluginContainerTest, CutFromContextMenu) {}

TEST_F(WebPluginContainerTest, PasteFromContextMenu) {}

TEST_F(WebPluginContainerTest, PasteAndMatchStyleFromContextMenu) {}

// A class to facilitate testing that events are correctly received by plugins.
class EventTestPlugin : public FakeWebPlugin {};

TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {}

TEST_F(WebPluginContainerTest, MouseEventButtons) {}

TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) {}

TEST_F(WebPluginContainerTest, TouchEventScrolled) {}

TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {}

TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) {}

TEST_F(WebPluginContainerTest, MouseEventScrolled) {}

TEST_F(WebPluginContainerTest, MouseEventZoomed) {}

TEST_F(WebPluginContainerTest, MouseWheelEventZoomed) {}

TEST_F(WebPluginContainerTest, TouchEventZoomed) {}

// Verify that isRectTopmost returns false when the document is detached.
TEST_F(WebPluginContainerTest, IsRectTopmostTest) {}

// Verify that IsRectTopmost works with odd and even dimensions.
TEST_F(WebPluginContainerTest, IsRectTopmostTestWithOddAndEvenDimensions) {}

TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) {}

TEST_F(WebPluginContainerTest, ClippedRectsForShiftedIframedElement) {}

TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) {}

TEST_F(WebPluginContainerTest, TopmostAfterDetachTest) {}

namespace {

class CompositedPlugin : public FakeWebPlugin {};

}  // namespace

TEST_F(WebPluginContainerTest, CompositedPlugin) {}

TEST_F(WebPluginContainerTest, NeedsWheelEvents) {}

}  // namespace blink