Changeset 86441 in webkit
- Timestamp:
- May 13, 2011 10:24:02 AM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r86434 r86441 1 2011-05-13 Adam Roben <aroben@apple.com> 2 3 Move code required for most tests of plugin window geometry into a base class 4 5 WebKit2's asynchronous plugin window positioning makes testing window geometry tricky. By 6 having all the trickiness in a shared base class, writing new window geometry tests will be 7 much easier. 8 9 Fixes <http://webkit.org/b/60776> It's hard to write tests that check plugin window geometry 10 11 Reviewed by Anders Carlsson. 12 13 * DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp: 14 (WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect): Changed to inherit from the new 15 WindowGeometryTest base class. Most of the code from this class was moved to the new base 16 class. 17 (WindowRegionIsSetToClipRect::performWindowGeometryTest): Renamed from checkWindowRegion. 18 This is called by the base class when it is safe to check the window's geometry. Note that 19 the m_didCheckWindowRegion logic was removed completely; it has never been needed and was 20 just vestigial code from an earlier version of this test. 21 22 * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj: Added new 23 WindowGeometryTest class. 24 25 * DumpRenderTree/TestNetscapePlugIn/win/WindowGeometryTest.cpp: Added. Code came from 26 WindowRegionIsSetToClipRect. 27 (WindowGeometryTest::finishTest): This is the only change from WindowRegionIsSetToClipRect. 28 We now call the new virtual performWindowGeometryTest function instead of checkWindowRegion. 29 Subclasses can implement that function to perform their own tests. 30 31 * DumpRenderTree/TestNetscapePlugIn/win/WindowGeometryTest.h: Added. 32 1 33 2011-05-13 Zoltan Herczeg <zherczeg@webkit.org> 2 34 -
trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
r86157 r86441 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #include "Window edPluginTest.h"26 #include "WindowGeometryTest.h" 27 27 28 28 #include "PluginObject.h" … … 32 32 // The plugin's window's window region should be set to the plugin's clip rect. 33 33 34 class WindowRegionIsSetToClipRect : public Window edPluginTest {34 class WindowRegionIsSetToClipRect : public WindowGeometryTest { 35 35 public: 36 36 WindowRegionIsSetToClipRect(NPP, const string& identifier); 37 37 38 38 private: 39 struct ScriptObject : Object<ScriptObject> { 40 bool hasMethod(NPIdentifier); 41 bool invoke(NPIdentifier, const NPVariant*, uint32_t, NPVariant*); 42 }; 43 44 static const UINT_PTR triggerPaintTimerID = 1; 45 46 void startTest(); 47 void finishTest(); 48 void checkWindowRegion(); 49 50 void showTestHarnessWindowIfNeeded(); 51 void hideTestHarnessWindowIfNeeded(); 52 53 // WindowedPluginTest 54 virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled); 55 56 // PluginTest 57 virtual NPError NPP_GetValue(NPPVariable, void*); 58 59 bool m_didCheckWindowRegion; 60 bool m_testHarnessWindowWasVisible; 39 virtual void performWindowGeometryTest(); 61 40 }; 62 41 … … 64 43 65 44 WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect(NPP npp, const string& identifier) 66 : WindowedPluginTest(npp, identifier) 67 , m_didCheckWindowRegion(false) 68 , m_testHarnessWindowWasVisible(false) 45 : WindowGeometryTest(npp, identifier) 69 46 { 70 47 } 71 48 72 void WindowRegionIsSetToClipRect:: startTest()49 void WindowRegionIsSetToClipRect::performWindowGeometryTest() 73 50 { 74 // In WebKit1, our window's window region will be set immediately. In WebKit2, it won't be set75 // until the UI process paints. Since the UI process will also show our window when it paints,76 // we can detect when the paint occurs (and thus when our window region should be set) by77 // starting with our plugin element hidden, then making it visible and waiting for a78 // WM_WINDOWPOSCHANGED event to tell us our window has been shown.79 80 waitUntilDone();81 82 // If the test harness window isn't visible, we might not receive a WM_WINDOWPOSCHANGED message83 // when our window is made visible. So we temporarily show the test harness window during this test.84 showTestHarnessWindowIfNeeded();85 86 // Make our window visible. (In WebKit2, this won't take effect immediately.)87 executeScript("document.getElementsByTagName('embed')[0].style.visibility = 'visible';");88 89 // We trigger a UI process paint after a slight delay to ensure that the UI process has90 // received the "make the plugin window visible" message before it paints.91 // FIXME: It would be nice to have a way to guarantee that the UI process had received that92 // message before we triggered a paint. Hopefully that would let us get rid of this semi-93 // arbitrary timeout.94 ::SetTimer(window(), triggerPaintTimerID, 250, 0);95 }96 97 void WindowRegionIsSetToClipRect::finishTest()98 {99 checkWindowRegion();100 hideTestHarnessWindowIfNeeded();101 notifyDone();102 }103 104 void WindowRegionIsSetToClipRect::checkWindowRegion()105 {106 if (m_didCheckWindowRegion)107 return;108 m_didCheckWindowRegion = true;109 110 51 RECT regionRect; 111 52 if (::GetWindowRgnBox(window(), ®ionRect) == ERROR) { … … 156 97 log("PASS: Plugin's window's class does not have the CS_PARENTDC style"); 157 98 } 158 159 void WindowRegionIsSetToClipRect::showTestHarnessWindowIfNeeded()160 {161 HWND testHarnessWindow = this->testHarnessWindow();162 m_testHarnessWindowWasVisible = ::IsWindowVisible(testHarnessWindow);163 if (m_testHarnessWindowWasVisible)164 return;165 ::ShowWindow(testHarnessWindow, SW_SHOWNA);166 }167 168 void WindowRegionIsSetToClipRect::hideTestHarnessWindowIfNeeded()169 {170 if (m_testHarnessWindowWasVisible)171 return;172 ::ShowWindow(testHarnessWindow(), SW_HIDE);173 }174 175 LRESULT WindowRegionIsSetToClipRect::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)176 {177 switch (message) {178 case WM_TIMER:179 if (wParam != triggerPaintTimerID)180 break;181 handled = true;182 ::KillTimer(window(), wParam);183 // Tell the UI process to paint.184 ::PostMessageW(::GetParent(window()), WM_PAINT, 0, 0);185 break;186 case WM_WINDOWPOSCHANGED: {187 WINDOWPOS* windowPos = reinterpret_cast<WINDOWPOS*>(lParam);188 if (!(windowPos->flags & SWP_SHOWWINDOW))189 break;190 finishTest();191 break;192 }193 194 }195 196 return 0;197 }198 199 NPError WindowRegionIsSetToClipRect::NPP_GetValue(NPPVariable variable, void* value)200 {201 if (variable != NPPVpluginScriptableNPObject)202 return NPERR_GENERIC_ERROR;203 204 *static_cast<NPObject**>(value) = ScriptObject::create(this);205 206 return NPERR_NO_ERROR;207 }208 209 bool WindowRegionIsSetToClipRect::ScriptObject::hasMethod(NPIdentifier methodName)210 {211 return methodName == pluginTest()->NPN_GetStringIdentifier("startTest");212 }213 214 bool WindowRegionIsSetToClipRect::ScriptObject::invoke(NPIdentifier identifier, const NPVariant*, uint32_t, NPVariant*)215 {216 assert(identifier == pluginTest()->NPN_GetStringIdentifier("startTest"));217 static_cast<WindowRegionIsSetToClipRect*>(pluginTest())->startTest();218 return true;219 } -
trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
r83300 r86441 474 474 > 475 475 </File> 476 <File 477 RelativePath=".\WindowGeometryTest.cpp" 478 > 479 </File> 480 <File 481 RelativePath=".\WindowGeometryTest.h" 482 > 483 </File> 476 484 </Filter> 477 485 <File
Note: See TracChangeset
for help on using the changeset viewer.