Add testing support for 3x device scale factor.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 03:31:00 +0000 (03:31 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 03:31:00 +0000 (03:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158597

Reviewed by Simon Fraser.

Set 3x device scale factor on the test canvas when the test url is prefixed with hidpi-3x-.

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(changeWindowScaleIfNeeded):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::updateWindowScaleForTest):
* WebKitTestRunner/TestOptions.cpp:
(WTR::deviceScaleFactorForTest):
(WTR::TestOptions::TestOptions):
(WTR::isHiDPITestPath): Deleted.
* WebKitTestRunner/TestOptions.h:

LayoutTests:

* fast/hidpi/hidpi-3x-device-pixel-ratio-expected.txt: Added.
* fast/hidpi/hidpi-3x-device-pixel-ratio.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201904 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/hidpi/hidpi-3x-device-pixel-ratio-expected.txt [new file with mode: 0644]
LayoutTests/fast/hidpi/hidpi-3x-device-pixel-ratio.html [new file with mode: 0644]
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestOptions.cpp
Tools/WebKitTestRunner/TestOptions.h

index 6b37be3..fc4e156 100644 (file)
@@ -1,3 +1,15 @@
+2016-06-09  Zalan Bujtas  <zalan@apple.com>
+
+        Add testing support for 3x device scale factor.
+        https://bugs.webkit.org/show_bug.cgi?id=158597
+
+        Reviewed by Simon Fraser.
+
+        Set 3x device scale factor on the test canvas when the test url is prefixed with hidpi-3x-. 
+
+        * fast/hidpi/hidpi-3x-device-pixel-ratio-expected.txt: Added.
+        * fast/hidpi/hidpi-3x-device-pixel-ratio.html: Added.
+
 2016-06-09  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(r201823) editing/selection/selection-in-iframe-removed-crash.html is flaky
diff --git a/LayoutTests/fast/hidpi/hidpi-3x-device-pixel-ratio-expected.txt b/LayoutTests/fast/hidpi/hidpi-3x-device-pixel-ratio-expected.txt
new file mode 100644 (file)
index 0000000..ff66341
--- /dev/null
@@ -0,0 +1 @@
+The user interface scale factor is 3.
diff --git a/LayoutTests/fast/hidpi/hidpi-3x-device-pixel-ratio.html b/LayoutTests/fast/hidpi/hidpi-3x-device-pixel-ratio.html
new file mode 100644 (file)
index 0000000..ee21e52
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that 3x device scale ratio is enabled.</title>
+</head>
+<body>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+    document.write("The user interface scale factor is " + window.devicePixelRatio + ".");
+</script>
+</body>
+</html>
index fa1ceba..5796be3 100644 (file)
@@ -1,3 +1,22 @@
+2016-06-09  Zalan Bujtas  <zalan@apple.com>
+
+        Add testing support for 3x device scale factor.
+        https://bugs.webkit.org/show_bug.cgi?id=158597
+
+        Reviewed by Simon Fraser.
+
+        Set 3x device scale factor on the test canvas when the test url is prefixed with hidpi-3x-. 
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (changeWindowScaleIfNeeded):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::updateWindowScaleForTest):
+        * WebKitTestRunner/TestOptions.cpp:
+        (WTR::deviceScaleFactorForTest):
+        (WTR::TestOptions::TestOptions):
+        (WTR::isHiDPITestPath): Deleted.
+        * WebKitTestRunner/TestOptions.h:
+
 2016-06-09  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Add comments to clarify feature enablement
index 00726c4..9e44708 100644 (file)
@@ -1621,16 +1621,18 @@ static void dumpBackForwardListForWebView(WebView *view)
 #if !PLATFORM(IOS)
 static void changeWindowScaleIfNeeded(const char* testPathOrUR)
 {
-    bool hasHighDPIWindow = [[[mainFrame webView] window] backingScaleFactor] != 1;
     WTF::String localPathOrUrl = String(testPathOrUR);
-    bool needsHighDPIWindow = localPathOrUrl.findIgnoringCase("/hidpi-") != notFound;
-    if (hasHighDPIWindow == needsHighDPIWindow)
+    float currentScaleFactor = [[[mainFrame webView] window] backingScaleFactor];
+    float requiredScaleFactor = 1;
+    if (localPathOrUrl.findIgnoringCase("/hidpi-3x-") != notFound)
+        requiredScaleFactor = 3;
+    else if (localPathOrUrl.findIgnoringCase("/hidpi-") != notFound)
+        requiredScaleFactor = 2;
+    if (currentScaleFactor == requiredScaleFactor)
         return;
-
-    CGFloat newScaleFactor = needsHighDPIWindow ? 2 : 1;
     // When the new scale factor is set on the window first, WebView doesn't see it as a new scale and stops propagating the behavior change to WebCore::Page.
-    gTestRunner->setBackingScaleFactor(newScaleFactor);
-    [[[mainFrame webView] window] _setWindowResolution:newScaleFactor displayIfChanged:YES];
+    gTestRunner->setBackingScaleFactor(requiredScaleFactor);
+    [[[mainFrame webView] window] _setWindowResolution:requiredScaleFactor displayIfChanged:YES];
 }
 #endif
 
index b126f51..6dabc21 100644 (file)
@@ -990,7 +990,7 @@ void TestController::updateWebViewSizeForTest(const TestInvocation& test)
 
 void TestController::updateWindowScaleForTest(PlatformWebView* view, const TestInvocation& test)
 {
-    view->changeWindowScaleIfNeeded(test.options().isHiDPITest ? 2 : 1);
+    view->changeWindowScaleIfNeeded(test.options().deviceScaleFactor);
 }
 
 void TestController::configureViewForTest(const TestInvocation& test)
index 453e077..6eed2cc 100644 (file)
@@ -56,16 +56,20 @@ static bool isSVGTestPath(const std::string& pathOrURL)
     return pathContains(pathOrURL, "svg/W3C-SVG-1.1") || pathContains(pathOrURL, "svg\\W3C-SVG-1.1");
 }
 
-static bool isHiDPITestPath(const std::string& pathOrURL)
+static float deviceScaleFactorForTest(const std::string& pathOrURL)
 {
-    return pathContains(pathOrURL, "/hidpi-");
+    if (pathContains(pathOrURL, "/hidpi-3x-"))
+        return 3;
+    if (pathContains(pathOrURL, "/hidpi-"))
+        return 2;
+    return 1;
 }
 
 TestOptions::TestOptions(const std::string& pathOrURL)
     : useFlexibleViewport(shouldMakeViewportFlexible(pathOrURL))
     , useFixedLayout(shouldUseFixedLayout(pathOrURL))
     , isSVGTest(isSVGTestPath(pathOrURL))
-    , isHiDPITest(isHiDPITestPath(pathOrURL))
+    , deviceScaleFactor(deviceScaleFactorForTest(pathOrURL))
 {
 }
 
index c1bae4d..771269e 100644 (file)
@@ -38,11 +38,11 @@ struct TestOptions {
     bool useFlexibleViewport { false };
     bool useFixedLayout { false };
     bool isSVGTest { false };
-    bool isHiDPITest { false };
     bool useDataDetection { false };
     bool useMockScrollbars { true };
     bool needsSiteSpecificQuirks { false };
 
+    float deviceScaleFactor { 1 };
     Vector<String> overrideLanguages;
     
     TestOptions(const std::string& pathOrURL);