summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-05 14:36:32 +0100
committerBen Murdoch <benm@google.com>2011-05-10 15:38:30 +0100
commitf05b935882198ccf7d81675736e3aeb089c5113a (patch)
tree4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win
parent60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff)
downloadexternal_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win')
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp118
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp73
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp188
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp90
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp114
5 files changed, 0 insertions, 583 deletions
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp
deleted file mode 100644
index 2b06198..0000000
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (C) 2010 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "WindowedPluginTest.h"
-
-#include "PluginObject.h"
-
-using namespace std;
-
-// Just fills its window with some gradients
-
-class DrawsGradient : public WindowedPluginTest {
-public:
- DrawsGradient(NPP, const string& identifier);
-
-private:
- void paint(HDC) const;
-
- LRESULT onPaint(WPARAM, LPARAM, bool& handled);
- LRESULT onPrintClient(WPARAM, LPARAM, bool& handled);
-
- virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled);
-};
-
-static PluginTest::Register<DrawsGradient> registrar("draws-gradient");
-
-DrawsGradient::DrawsGradient(NPP npp, const string& identifier)
- : WindowedPluginTest(npp, identifier)
-{
-}
-
-LRESULT DrawsGradient::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
-{
- LRESULT result = 0;
-
- switch (message) {
- case WM_PAINT:
- result = onPaint(wParam, lParam, handled);
- break;
- case WM_PRINTCLIENT:
- result = onPrintClient(wParam, lParam, handled);
- break;
- default:
- handled = false;
- }
-
- return result;
-}
-
-LRESULT DrawsGradient::onPaint(WPARAM, LPARAM, bool& handled)
-{
- PAINTSTRUCT paintStruct;
- HDC dc = ::BeginPaint(window(), &paintStruct);
- if (!dc)
- return 0;
-
- paint(dc);
- ::EndPaint(window(), &paintStruct);
-
- handled = true;
- return 0;
-}
-
-LRESULT DrawsGradient::onPrintClient(WPARAM wParam, LPARAM, bool& handled)
-{
- paint(reinterpret_cast<HDC>(wParam));
-
- handled = true;
- return 0;
-}
-
-void DrawsGradient::paint(HDC dc) const
-{
- RECT clientRect;
- if (!::GetClientRect(window(), &clientRect))
- return;
-
- TRIVERTEX vertices[] = {
- // Upper-left: green
- { clientRect.left, clientRect.top, 0, 0xff00, 0, 0 },
- // Upper-right: blue
- { clientRect.right, clientRect.top, 0, 0, 0xff00, 0 },
- // Lower-left: yellow
- { clientRect.left, clientRect.bottom, 0xff00, 0xff00, 0, 0 },
- // Lower-right: red
- { clientRect.right, clientRect.bottom, 0xff00, 0, 0, 0 },
- };
-
- GRADIENT_TRIANGLE mesh[] = {
- // Upper-left triangle
- { 0, 1, 2 },
- // Lower-right triangle
- { 1, 2, 3 },
- };
-
- ::GradientFill(dc, vertices, _countof(vertices), mesh, _countof(mesh), GRADIENT_FILL_TRIANGLE);
-}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp
deleted file mode 100644
index 32fd99b..0000000
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/GetValueNetscapeWindow.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2010 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "PluginTest.h"
-
-#include "PluginObject.h"
-
-using namespace std;
-
-// NPN_GetValue(NPNVnetscapeWindow) should return a valid HWND.
-
-class GetValueNetscapeWindow : public PluginTest {
-public:
- GetValueNetscapeWindow(NPP npp, const string& identifier)
- : PluginTest(npp, identifier)
- , m_didReceiveInitialSetWindowCall(false)
- {
- }
-
-private:
- virtual NPError NPP_SetWindow(NPP instance, NPWindow* window)
- {
- if (m_didReceiveInitialSetWindowCall)
- return NPERR_NO_ERROR;
- m_didReceiveInitialSetWindowCall = true;
-
- HWND hwnd;
- NPError error = NPN_GetValue(NPNVnetscapeWindow, &hwnd);
- if (error != NPERR_NO_ERROR) {
- pluginLog(instance, "NPN_GetValue(NPNVnetscapeWindow) failed with error %d", error);
- return NPERR_GENERIC_ERROR;
- }
-
- if (!::IsWindow(hwnd)) {
- pluginLog(instance, "::IsWindow returned FALSE");
- return NPERR_GENERIC_ERROR;
- }
-
- if (hwnd == window->window) {
- pluginLog(instance, "NPN_GetValue(NPNVnetscapeWindow) returned the same value as NPWindow::window");
- return NPERR_GENERIC_ERROR;
- }
-
- pluginLog(instance, "NPN_GetValue(NPNVnetscapeWindow) succeeded");
- return NPERR_NO_ERROR;
- }
-
- bool m_didReceiveInitialSetWindowCall;
-};
-
-static PluginTest::Register<GetValueNetscapeWindow> getValueNetscapeWindow("get-value-netscape-window");
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
deleted file mode 100644
index e598c49..0000000
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2010 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "WindowedPluginTest.h"
-
-#include "PluginObject.h"
-
-using namespace std;
-
-// NPN_InvalidateRect should invalidate the plugin's HWND.
-
-static const wchar_t instancePointerProperty[] = L"org.webkit.TestNetscapePlugin.NPNInvalidateRectInvalidatesWindow.InstancePointer";
-
-class TemporaryWindowMover {
-public:
- TemporaryWindowMover(HWND);
- ~TemporaryWindowMover();
-
- bool moveSucceeded() const { return m_moveSucceeded; }
-
-private:
- static const UINT standardSetWindowPosFlags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER;
- bool m_moveSucceeded;
- HWND m_window;
- RECT m_savedWindowRect;
-};
-
-TemporaryWindowMover::TemporaryWindowMover(HWND window)
- : m_window(window)
-{
- m_moveSucceeded = false;
-
- if (!::GetWindowRect(m_window, &m_savedWindowRect))
- return;
-
- if (!::SetWindowPos(m_window, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | standardSetWindowPosFlags))
- return;
-
- m_moveSucceeded = true;
-};
-
-TemporaryWindowMover::~TemporaryWindowMover()
-{
- if (!m_moveSucceeded)
- return;
-
- ::SetWindowPos(m_window, 0, m_savedWindowRect.left, m_savedWindowRect.top, 0, 0, SWP_HIDEWINDOW | standardSetWindowPosFlags);
-}
-
-class NPNInvalidateRectInvalidatesWindow : public WindowedPluginTest {
-public:
- NPNInvalidateRectInvalidatesWindow(NPP, const string& identifier);
- ~NPNInvalidateRectInvalidatesWindow();
-
-private:
- virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled);
-
- void onPaint();
- void testInvalidateRect();
-
- virtual NPError NPP_SetWindow(NPP, NPWindow*);
-
- TemporaryWindowMover* m_windowMover;
-};
-
-NPNInvalidateRectInvalidatesWindow::NPNInvalidateRectInvalidatesWindow(NPP npp, const string& identifier)
- : WindowedPluginTest(npp, identifier)
- , m_windowMover(0)
-{
-}
-
-NPNInvalidateRectInvalidatesWindow::~NPNInvalidateRectInvalidatesWindow()
-{
- delete m_windowMover;
-}
-
-NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow* npWindow)
-{
- NPError error = WindowedPluginTest::NPP_SetWindow(instance, npWindow);
- if (error != NPERR_NO_ERROR)
- return error;
-
- if (!window())
- return NPERR_NO_ERROR;
-
- // The test harness's window (the one that contains the WebView) is off-screen and hidden.
- // We need to move it on-screen and make it visible in order for the plugin's window to
- // accumulate an update region when the DWM is disabled.
-
- HWND testHarnessWindow = ::GetAncestor(window(), GA_ROOT);
- if (!testHarnessWindow) {
- pluginLog(instance, "Failed to get test harness window");
- return NPERR_GENERIC_ERROR;
- }
-
- m_windowMover = new TemporaryWindowMover(testHarnessWindow);
- if (!m_windowMover->moveSucceeded()) {
- pluginLog(instance, "Failed to move test harness window on-screen");
- return NPERR_GENERIC_ERROR;
- }
-
- // Wait until we receive a WM_PAINT message to ensure that the window is on-screen before we do
- // the NPN_InvalidateRect test.
- waitUntilDone();
- return NPERR_NO_ERROR;
-}
-
-LRESULT NPNInvalidateRectInvalidatesWindow::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
-{
- if (message == WM_PAINT)
- onPaint();
-
- handled = false;
- return 0;
-}
-
-void NPNInvalidateRectInvalidatesWindow::onPaint()
-{
- testInvalidateRect();
- notifyDone();
- delete m_windowMover;
- m_windowMover = 0;
-}
-
-void NPNInvalidateRectInvalidatesWindow::testInvalidateRect()
-{
- RECT clientRect;
- if (!::GetClientRect(window(), &clientRect)) {
- pluginLog(m_npp, "::GetClientRect failed");
- return;
- }
-
- if (::IsRectEmpty(&clientRect)) {
- pluginLog(m_npp, "Plugin's HWND has not been sized when NPP_SetWindow is called");
- return;
- }
-
- // Clear the invalid region.
- if (!::ValidateRect(window(), 0)) {
- pluginLog(m_npp, "::ValidateRect failed");
- return;
- }
-
- // Invalidate our lower-right quadrant.
- NPRect rectToInvalidate;
- rectToInvalidate.left = (clientRect.right - clientRect.left) / 2;
- rectToInvalidate.top = (clientRect.bottom - clientRect.top) / 2;
- rectToInvalidate.right = clientRect.right;
- rectToInvalidate.bottom = clientRect.bottom;
- NPN_InvalidateRect(&rectToInvalidate);
-
- RECT invalidRect;
- if (!::GetUpdateRect(window(), &invalidRect, FALSE)) {
- pluginLog(m_npp, "::GetUpdateRect failed");
- return;
- }
-
- if (invalidRect.left != rectToInvalidate.left || invalidRect.top != rectToInvalidate.top || invalidRect.right != rectToInvalidate.right || invalidRect.bottom != rectToInvalidate.bottom) {
- pluginLog(m_npp, "Expected invalid rect {left=%u, top=%u, right=%u, bottom=%u}, but got {left=%d, top=%d, right=%d, bottom=%d}", rectToInvalidate.left, rectToInvalidate.top, rectToInvalidate.right, rectToInvalidate.bottom, invalidRect.left, invalidRect.top, invalidRect.right, invalidRect.bottom);
- return;
- }
-
- pluginLog(m_npp, "Plugin's HWND has been invalidated as expected");
-}
-
-static PluginTest::Register<NPNInvalidateRectInvalidatesWindow> registrar("npn-invalidate-rect-invalidates-window");
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp
deleted file mode 100644
index 8054497..0000000
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2010 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "PluginTest.h"
-
-#include "PluginObject.h"
-
-using namespace std;
-
-// Plugin's HWND should be sized/positioned before NPP_SetWindow is called.
-
-class WindowGeometryInitializedBeforeSetWindow : public PluginTest {
-public:
- WindowGeometryInitializedBeforeSetWindow(NPP npp, const string& identifier)
- : PluginTest(npp, identifier)
- , m_didReceiveInitialSetWindowCall(false)
- {
- }
-
-private:
- virtual NPError NPP_SetWindow(NPP instance, NPWindow* window)
- {
- if (m_didReceiveInitialSetWindowCall)
- return NPERR_NO_ERROR;
- m_didReceiveInitialSetWindowCall = true;
-
- if (window->type != NPWindowTypeWindow) {
- pluginLog(instance, "window->type should be NPWindowTypeWindow but was %d", window->type);
- return NPERR_GENERIC_ERROR;
- }
-
- HWND hwnd = reinterpret_cast<HWND>(window->window);
- RECT rect;
- if (!::GetClientRect(hwnd, &rect)) {
- pluginLog(instance, "::GetClientRect failed");
- return NPERR_GENERIC_ERROR;
- }
-
- if (::IsRectEmpty(&rect)) {
- pluginLog(instance, "Plugin's HWND has not been sized when NPP_SetWindow is called");
- return NPERR_GENERIC_ERROR;
- }
-
- HWND parent = ::GetParent(hwnd);
- if (!parent) {
- pluginLog(instance, "::GetParent failed");
- return NPERR_GENERIC_ERROR;
- }
-
- // MSDN says that calling ::MapWindowPoints this way will tell it we're passing a RECT rather than two POINTs.
- if (!::MapWindowPoints(hwnd, parent, reinterpret_cast<POINT*>(&rect), 2)) {
- pluginLog(instance, "::MapWindowPoints failed");
- return NPERR_GENERIC_ERROR;
- }
-
- if (rect.left != window->x || rect.top != window->y || (rect.right - rect.left) != window->width || (rect.bottom - rect.top) != window->height) {
- pluginLog(instance, "HWND's rect and NPWindow's rect are not equal");
- return NPERR_GENERIC_ERROR;
- }
-
- pluginLog(instance, "Plugin's HWND has been sized and positioned before NPP_SetWindow was called");
- return NPERR_NO_ERROR;
- }
-
- bool m_didReceiveInitialSetWindowCall;
-};
-
-static PluginTest::Register<WindowGeometryInitializedBeforeSetWindow> windowGeometryInitializedBeforeSetWindow("window-geometry-initialized-before-set-window");
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
deleted file mode 100644
index 975a598..0000000
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2010 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "PluginTest.h"
-
-#include "PluginObject.h"
-
-using namespace std;
-
-// The plugin's window's window region should be set to the plugin's clip rect.
-
-class WindowRegionIsSetToClipRect : public PluginTest {
-public:
- WindowRegionIsSetToClipRect(NPP, const string& identifier);
-
-private:
- virtual NPError NPP_SetWindow(NPP, NPWindow*);
-
- bool m_didReceiveInitialSetWindowCall;
-};
-
-static PluginTest::Register<WindowRegionIsSetToClipRect> registrar("window-region-is-set-to-clip-rect");
-
-WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect(NPP npp, const string& identifier)
- : PluginTest(npp, identifier)
- , m_didReceiveInitialSetWindowCall(false)
-{
-}
-
-NPError WindowRegionIsSetToClipRect::NPP_SetWindow(NPP instance, NPWindow* window)
-{
- if (m_didReceiveInitialSetWindowCall)
- return NPERR_NO_ERROR;
- m_didReceiveInitialSetWindowCall = true;
-
- if (window->type != NPWindowTypeWindow) {
- pluginLog(instance, "window->type should be NPWindowTypeWindow but was %d", window->type);
- return NPERR_GENERIC_ERROR;
- }
-
- HWND hwnd = reinterpret_cast<HWND>(window->window);
-
- RECT regionRect;
- if (::GetWindowRgnBox(hwnd, &regionRect) == ERROR) {
- pluginLog(instance, "::GetWindowRgnBox failed with error %u", ::GetLastError());
- return NPERR_GENERIC_ERROR;
- }
-
- // This expected rect is based on the layout of window-region-is-set-to-clip-rect.html.
- RECT expectedRect = { 50, 50, 100, 100 };
- if (!::EqualRect(&regionRect, &expectedRect)) {
- pluginLog(instance, "Expected region rect {left=%u, top=%u, right=%u, bottom=%u}, but got {left=%d, top=%d, right=%d, bottom=%d}", expectedRect.left, expectedRect.top, expectedRect.right, expectedRect.bottom, regionRect.left, regionRect.top, regionRect.right, regionRect.bottom);
- return NPERR_GENERIC_ERROR;
- }
-
- pluginLog(instance, "PASS: Plugin's window's window region has been set as expected");
-
- // While we're here, check that our window class doesn't have the CS_PARENTDC style, which
- // defeats clipping by ignoring the window region and always clipping to the parent window.
- // FIXME: It would be nice to have a pixel test that shows that we're
- // getting clipped correctly, but unfortunately window regions are ignored
- // during WM_PRINT (see <http://webkit.org/b/49034>).
- wchar_t className[512];
- if (!::GetClassNameW(hwnd, className, _countof(className))) {
- pluginLog(instance, "::GetClassName failed with error %u", ::GetLastError());
- return NPERR_GENERIC_ERROR;
- }
-
-#ifdef DEBUG_ALL
- const wchar_t webKitDLLName[] = L"WebKit_debug.dll";
-#else
- const wchar_t webKitDLLName[] = L"WebKit.dll";
-#endif
- HMODULE webKitModule = ::GetModuleHandleW(webKitDLLName);
- if (!webKitModule) {
- pluginLog(instance, "::GetModuleHandleW failed with error %u", ::GetLastError());
- return NPERR_GENERIC_ERROR;
- }
-
- WNDCLASSW wndClass;
- if (!::GetClassInfoW(webKitModule, className, &wndClass)) {
- pluginLog(instance, "::GetClassInfoW failed with error %u", ::GetLastError());
- return NPERR_GENERIC_ERROR;
- }
-
- if (wndClass.style & CS_PARENTDC)
- pluginLog(instance, "FAIL: Plugin's window's class has the CS_PARENTDC style, which will defeat clipping");
- else
- pluginLog(instance, "PASS: Plugin's window's class does not have the CS_PARENTDC style");
-
- return NPERR_NO_ERROR;
-}