Title: [183651] trunk/Tools
Revision
183651
Author
bfulg...@apple.com
Date
2015-04-30 16:13:52 -0700 (Thu, 30 Apr 2015)

Log Message

Provide a runtime flag to run-webkit-tests that shows the test view
https://bugs.webkit.org/show_bug.cgi?id=144079.

Reviewed by Dean Jackson.

Add a new flag (--show-webview) that causes DumpRenderTree and WebKitTestRunner to display
their WebViews on-screen. This can be used when running tests via the "--additional-drt-flag"
option:
        
--additional-drt-flag="--show-webview"

* DumpRenderTree/mac/DumpRenderTree.mm:
(createWebViewAndOffscreenWindow): Use an on-screen window rect if the user passed the
'--show-webview' flag.
(initializeGlobalsFromCommandLineOptions): Recognize the "--show-webview" option.
* WebKitTestRunner/Options.cpp:
(WTR::Options::Options):
(WTR::handleOptionShowWebView):
(WTR::OptionsHandler::OptionsHandler): Recognize the new "--show-webview" option.
* WebKitTestRunner/Options.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::initialize): Use value of 'shouldShowWebView' from the Options bundle.
* WebKitTestRunner/TestController.h:
(WTR::TestController::shouldShowWebView):
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::PlatformWebView): Retrieve the value of the 'ShouldShowWebView' key from the
options dictionary. If it is true, display the web view while running the test.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (183650 => 183651)


--- trunk/Tools/ChangeLog	2015-04-30 23:02:33 UTC (rev 183650)
+++ trunk/Tools/ChangeLog	2015-04-30 23:13:52 UTC (rev 183651)
@@ -1,3 +1,34 @@
+2015-04-30  Brent Fulgham  <bfulg...@apple.com>
+
+        Provide a runtime flag to run-webkit-tests that shows the test view
+        https://bugs.webkit.org/show_bug.cgi?id=144079.
+
+        Reviewed by Dean Jackson.
+
+        Add a new flag (--show-webview) that causes DumpRenderTree and WebKitTestRunner to display
+        their WebViews on-screen. This can be used when running tests via the "--additional-drt-flag"
+        option:
+        
+        --additional-drt-flag="--show-webview"
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (createWebViewAndOffscreenWindow): Use an on-screen window rect if the user passed the
+        '--show-webview' flag.
+        (initializeGlobalsFromCommandLineOptions): Recognize the "--show-webview" option.
+        * WebKitTestRunner/Options.cpp:
+        (WTR::Options::Options):
+        (WTR::handleOptionShowWebView):
+        (WTR::OptionsHandler::OptionsHandler): Recognize the new "--show-webview" option.
+        * WebKitTestRunner/Options.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::TestController):
+        (WTR::TestController::initialize): Use value of 'shouldShowWebView' from the Options bundle.
+        * WebKitTestRunner/TestController.h:
+        (WTR::TestController::shouldShowWebView):
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        (WTR::PlatformWebView::PlatformWebView): Retrieve the value of the 'ShouldShowWebView' key from the
+        options dictionary. If it is true, display the web view while running the test.
+
 2015-04-30  Alexey Proskuryakov  <a...@apple.com>
 
         r183355 didn't trigger Mac tests

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (183650 => 183651)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2015-04-30 23:02:33 UTC (rev 183650)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2015-04-30 23:13:52 UTC (rev 183651)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2009, 2015 Apple Inc. All rights reserved.
  *           (C) 2007 Graham Dennis (graham.den...@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -205,6 +205,7 @@
 static int forceComplexText;
 static int useAcceleratedDrawing;
 static int gcBetweenTests;
+static int showWebView = NO;
 static BOOL printSeparators;
 static RetainPtr<CFStringRef> persistentUserStyleSheetLocation;
 static std::set<std::string> allowedHosts;
@@ -784,13 +785,16 @@
     // To make things like certain NSViews, dragging, and plug-ins work, put the WebView a window, but put it off-screen so you don't see it.
     // Put it at -10000, -10000 in "flipped coordinates", since WebCore and the DOM use flipped coordinates.
     NSScreen *firstScreen = [[NSScreen screens] firstObject];
-    NSRect windowRect = NSOffsetRect(rect, -10000, [firstScreen frame].size.height - rect.size.height + 10000);
+    NSRect windowRect = (showWebView) ? NSOffsetRect(rect, 100, 100) : NSOffsetRect(rect, -10000, [firstScreen frame].size.height - rect.size.height + 10000);
     DumpRenderTreeWindow *window = [[DumpRenderTreeWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
 
     [window setColorSpace:[firstScreen colorSpace]];
     [window setCollectionBehavior:NSWindowCollectionBehaviorStationary];
     [[window contentView] addSubview:webView];
-    [window orderBack:nil];
+    if (showWebView)
+        [window orderFront:nil];
+    else
+        [window orderBack:nil];
     [window setAutodisplay:NO];
 
     [window startListeningForAcceleratedCompositingChanges];
@@ -1121,6 +1125,7 @@
         {"gc-between-tests", no_argument, &gcBetweenTests, YES},
         {"no-timeout", no_argument, &useTimeoutWatchdog, NO},
         {"allowed-host", required_argument, nullptr, 'a'},
+        {"show-webview", no_argument, &showWebView, YES},
         {nullptr, 0, nullptr, 0}
     };
     

Modified: trunk/Tools/WebKitTestRunner/Options.cpp (183650 => 183651)


--- trunk/Tools/WebKitTestRunner/Options.cpp	2015-04-30 23:02:33 UTC (rev 183650)
+++ trunk/Tools/WebKitTestRunner/Options.cpp	2015-04-30 23:13:52 UTC (rev 183651)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2013 University of Szeged. All rights reserved.
  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,6 +42,7 @@
     , forceComplexText(false)
     , shouldUseAcceleratedDrawing(false)
     , shouldUseRemoteLayerTree(false)
+    , shouldShowWebView(false)
 {
 }
 
@@ -93,6 +95,12 @@
     return true;
 }
 
+bool handleOptionShowWebView(Options& options, const char*, const char*)
+{
+    options.shouldShowWebView = true;
+    return true;
+}
+
 bool handleOptionAllowedHost(Options& options, const char*, const char* host)
 {
     options.allowedHosts.push_back(host);
@@ -120,6 +128,7 @@
     optionList.append(Option("--accelerated-drawing", "Use accelerated drawing.", handleOptionAcceleratedDrawing));
     optionList.append(Option("--remote-layer-tree", "Use remote layer tree.", handleOptionRemoteLayerTree));
     optionList.append(Option("--allowed-host", "Allows access to the specified host from tests.", handleOptionAllowedHost, true));
+    optionList.append(Option("--show-webview", "Show the WebView during test runs (for Debugging)", handleOptionShowWebView));
 
     optionList.append(Option(0, 0, handleOptionUnmatched));
 }

Modified: trunk/Tools/WebKitTestRunner/Options.h (183650 => 183651)


--- trunk/Tools/WebKitTestRunner/Options.h	2015-04-30 23:02:33 UTC (rev 183650)
+++ trunk/Tools/WebKitTestRunner/Options.h	2015-04-30 23:13:52 UTC (rev 183651)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2013 University of Szeged. All rights reserved.
  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -46,6 +47,7 @@
     bool forceComplexText;
     bool shouldUseAcceleratedDrawing;
     bool shouldUseRemoteLayerTree;
+    bool shouldShowWebView;
     std::vector<std::string> paths;
     std::vector<std::string> allowedHosts;
 };

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (183650 => 183651)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2015-04-30 23:02:33 UTC (rev 183650)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2015-04-30 23:13:52 UTC (rev 183651)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -125,6 +125,7 @@
     , m_shouldUseAcceleratedDrawing(false)
     , m_shouldUseRemoteLayerTree(false)
     , m_shouldLogHistoryClientCallbacks(false)
+    , m_shouldShowWebView(false)
 {
     initialize(argc, argv);
     controller = this;
@@ -328,6 +329,7 @@
     m_shouldUseRemoteLayerTree = options.shouldUseRemoteLayerTree;
     m_paths = options.paths;
     m_allowedHosts = options.allowedHosts;
+    m_shouldShowWebView = options.shouldShowWebView;
 
     if (options.printSupportedFeatures) {
         // FIXME: On Windows, DumpRenderTree uses this to expose whether it supports 3d

Modified: trunk/Tools/WebKitTestRunner/TestController.h (183650 => 183651)


--- trunk/Tools/WebKitTestRunner/TestController.h	2015-04-30 23:02:33 UTC (rev 183650)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2015-04-30 23:13:52 UTC (rev 183651)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -74,7 +74,9 @@
     bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; }
     void runUntil(bool& done, double timeoutSeconds);
     void notifyDone();
-    
+
+    bool shouldShowWebView() const { return m_shouldShowWebView; }
+
     void configureViewForTest(const TestInvocation&);
     
     bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; }
@@ -269,6 +271,7 @@
     bool m_shouldUseRemoteLayerTree;
 
     bool m_shouldLogHistoryClientCallbacks;
+    bool m_shouldShowWebView;
 
     std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
 

Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (183650 => 183651)


--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2015-04-30 23:02:33 UTC (rev 183650)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2015-04-30 23:13:52 UTC (rev 183651)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -141,14 +141,21 @@
     m_view = [[TestRunnerWKView alloc] initWithFrame:rect contextRef:contextRef pageGroupRef:pageGroupRef relatedToPage:relatedPage useThreadedScrolling:useThreadedScrolling];
     [m_view setWindowOcclusionDetectionEnabled:NO];
 
+    WKRetainPtr<WKStringRef> shouldShowWebViewKey(AdoptWK, WKStringCreateWithUTF8CString("ShouldShowWebView"));
+    WKTypeRef shouldShowWebViewValue = options ? WKDictionaryGetItemForKey(options, shouldShowWebViewKey.get()) : NULL;
+    bool shouldShowWebView = shouldShowWebViewValue && WKBooleanGetValue(static_cast<WKBooleanRef>(shouldShowWebViewValue));
+
     NSScreen *firstScreen = [[NSScreen screens] objectAtIndex:0];
-    NSRect windowRect = NSOffsetRect(rect, -10000, [firstScreen frame].size.height - rect.size.height + 10000);
+    NSRect windowRect = (shouldShowWebView) ? NSOffsetRect(rect, 100, 100) : NSOffsetRect(rect, -10000, [firstScreen frame].size.height - rect.size.height + 10000);
     m_window = [[WebKitTestRunnerWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:(NSBackingStoreType)_NSBackingStoreUnbuffered defer:YES];
     m_window.platformWebView = this;
     [m_window setColorSpace:[firstScreen colorSpace]];
     [m_window setCollectionBehavior:NSWindowCollectionBehaviorStationary];
     [[m_window contentView] addSubview:m_view];
-    [m_window orderBack:nil];
+    if (shouldShowWebView)
+        [m_window orderFront:nil];
+    else
+        [m_window orderBack:nil];
     [m_window setReleasedWhenClosed:NO];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to