Changeset 169845 in webkit


Ignore:
Timestamp:
Jun 11, 2014 3:08:34 PM (10 years ago)
Author:
Simon Fraser
Message:

WTR cleanup: push per-test viewport configuration into TestController, where platforms can customize it
https://bugs.webkit.org/show_bug.cgi?id=133770

Reviewed by Anders Carlsson.

Push the per-test view configuration up to TestController, so that platforms
can modify the behavior. This also allows platform-specific changes (e.g.
for threaded scrolling) to made without #ifefs.

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::updateWebViewSizeForTest):
(WTR::TestController::updateWindowScaleForTest):
(WTR::shouldUseFixedLayout):
(WTR::TestController::updateLayoutTypeForTest):
(WTR::TestController::platformConfigureViewForTest):
(WTR::TestController::configureViewForTest):

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::invoke):
(WTR::sizeWebViewForCurrentTest): Deleted.
(WTR::changeWindowScaleIfNeeded): Deleted.
(WTR::shouldUseThreadedScrolling): Deleted.
(WTR::updateThreadedScrollingForCurrentTest): Deleted.
(WTR::shouldUseFixedLayout): Deleted.
(WTR::updateLayoutType): Deleted.

  • WebKitTestRunner/TestInvocation.h:

(WTR::TestInvocation::pathOrURL):

  • WebKitTestRunner/ios/TestControllerIOS.mm:

(WTR::shouldMakeViewportFlexible):
(WTR::TestController::platformConfigureViewForTest):

  • WebKitTestRunner/mac/TestControllerMac.mm:

(WTR::shouldUseThreadedScrolling):
(WTR::TestController::platformConfigureViewForTest):

Location:
trunk/Tools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r169840 r169845  
     12014-06-11  Simon Fraser  <simon.fraser@apple.com>
     2
     3        WTR cleanup: push per-test viewport configuration into TestController, where platforms can customize it
     4        https://bugs.webkit.org/show_bug.cgi?id=133770
     5
     6        Reviewed by Anders Carlsson.
     7       
     8        Push the per-test view configuration up to TestController, so that platforms
     9        can modify the behavior. This also allows platform-specific changes (e.g.
     10        for threaded scrolling) to made without #ifefs.
     11
     12        * WebKitTestRunner/TestController.cpp:
     13        (WTR::TestController::updateWebViewSizeForTest):
     14        (WTR::TestController::updateWindowScaleForTest):
     15        (WTR::shouldUseFixedLayout):
     16        (WTR::TestController::updateLayoutTypeForTest):
     17        (WTR::TestController::platformConfigureViewForTest):
     18        (WTR::TestController::configureViewForTest):
     19        * WebKitTestRunner/TestController.h:
     20        * WebKitTestRunner/TestInvocation.cpp:
     21        (WTR::TestInvocation::invoke):
     22        (WTR::sizeWebViewForCurrentTest): Deleted.
     23        (WTR::changeWindowScaleIfNeeded): Deleted.
     24        (WTR::shouldUseThreadedScrolling): Deleted.
     25        (WTR::updateThreadedScrollingForCurrentTest): Deleted.
     26        (WTR::shouldUseFixedLayout): Deleted.
     27        (WTR::updateLayoutType): Deleted.
     28        * WebKitTestRunner/TestInvocation.h:
     29        (WTR::TestInvocation::pathOrURL):
     30        * WebKitTestRunner/ios/TestControllerIOS.mm:
     31        (WTR::shouldMakeViewportFlexible):
     32        (WTR::TestController::platformConfigureViewForTest):
     33        * WebKitTestRunner/mac/TestControllerMac.mm:
     34        (WTR::shouldUseThreadedScrolling):
     35        (WTR::TestController::platformConfigureViewForTest):
     36
    1372014-06-11  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
    238
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r169113 r169845  
    669669}
    670670
     671
     672void TestController::updateWebViewSizeForTest(const TestInvocation& test)
     673{
     674    bool isSVGW3CTest = strstr(test.pathOrURL(), "svg/W3C-SVG-1.1") || strstr(test.pathOrURL(), "svg\\W3C-SVG-1.1");
     675
     676    unsigned width = viewWidth;
     677    unsigned height = viewHeight;
     678    if (isSVGW3CTest) {
     679        width = w3cSVGViewWidth;
     680        height = w3cSVGViewHeight;
     681    }
     682
     683    mainWebView()->resizeTo(width, height);
     684}
     685
     686void TestController::updateWindowScaleForTest(const TestInvocation& test)
     687{
     688    WTF::String localPathOrUrl = String(test.pathOrURL());
     689    bool needsHighDPIWindow = localPathOrUrl.findIgnoringCase("hidpi-") != notFound;
     690    mainWebView()->changeWindowScaleIfNeeded(needsHighDPIWindow ? 2 : 1);
     691}
     692
     693// FIXME: move into relevant platformConfigureViewForTest()?
     694static bool shouldUseFixedLayout(const char* pathOrURL)
     695{
     696#if ENABLE(CSS_DEVICE_ADAPTATION)
     697    if (strstr(pathOrURL, "device-adapt/") || strstr(pathOrURL, "device-adapt\\"))
     698        return true;
     699#endif
     700
     701#if USE(TILED_BACKING_STORE) && PLATFORM(EFL)
     702    if (strstr(pathOrURL, "sticky/") || strstr(pathOrURL, "sticky\\"))
     703        return true;
     704#endif
     705    return false;
     706
     707    UNUSED_PARAM(pathOrURL);
     708}
     709
     710void TestController::updateLayoutTypeForTest(const TestInvocation& test)
     711{
     712    auto viewOptions = adoptWK(WKMutableDictionaryCreate());
     713    auto useFixedLayoutKey = adoptWK(WKStringCreateWithUTF8CString("UseFixedLayout"));
     714    auto useFixedLayoutValue = adoptWK(WKBooleanCreate(shouldUseFixedLayout(test.pathOrURL())));
     715    WKDictionarySetItem(viewOptions.get(), useFixedLayoutKey.get(), useFixedLayoutValue.get());
     716
     717    ensureViewSupportsOptions(viewOptions.get());
     718}
     719
     720#if !PLATFORM(COCOA)
     721void TestController::platformConfigureViewForTest(const TestInvocation&)
     722{
     723}
     724#endif
     725
     726void TestController::configureViewForTest(const TestInvocation& test)
     727{
     728    updateWebViewSizeForTest(test);
     729    updateWindowScaleForTest(test);
     730    updateLayoutTypeForTest(test);
     731
     732    platformConfigureViewForTest(test);
     733}
     734
    671735struct TestCommand {
    672736    TestCommand() : shouldDumpPixels(false), timeout(0) { }
  • trunk/Tools/WebKitTestRunner/TestController.h

    r169113 r169845  
    7373    void runUntil(bool& done, TimeoutDuration);
    7474    void notifyDone();
     75   
     76    void configureViewForTest(const TestInvocation&);
    7577
    7678    int getCustomTimeout();
     
    117119    void platformDestroy();
    118120    void platformInitializeContext();
     121    void platformConfigureViewForTest(const TestInvocation&);
    119122    void platformWillRunTest(const TestInvocation&);
    120123    void platformRunUntil(bool& done, double timeout);
     
    122125    void initializeInjectedBundlePath();
    123126    void initializeTestPluginDirectory();
     127
     128    void updateWebViewSizeForTest(const TestInvocation&);
     129    void updateWindowScaleForTest(const TestInvocation&);
     130    void updateLayoutTypeForTest(const TestInvocation&);
    124131
    125132    void decidePolicyForGeolocationPermissionRequestIfPossible();
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r169700 r169845  
    123123}
    124124
    125 static void sizeWebViewForCurrentTest(const char* pathOrURL)
    126 {
    127     bool isSVGW3CTest = strstr(pathOrURL, "svg/W3C-SVG-1.1") || strstr(pathOrURL, "svg\\W3C-SVG-1.1");
    128 
    129     if (isSVGW3CTest)
    130         TestController::shared().mainWebView()->resizeTo(TestController::w3cSVGViewWidth, TestController::w3cSVGViewHeight);
    131     else
    132         TestController::shared().mainWebView()->resizeTo(TestController::viewWidth, TestController::viewHeight);
    133 }
    134 
    135 static void changeWindowScaleIfNeeded(const char* pathOrURL)
    136 {
    137     WTF::String localPathOrUrl = String(pathOrURL);
    138     bool needsHighDPIWindow = localPathOrUrl.findIgnoringCase("hidpi-") != notFound;
    139     TestController::shared().mainWebView()->changeWindowScaleIfNeeded(needsHighDPIWindow ? 2 : 1);
    140 }
    141 
    142125static bool shouldLogFrameLoadDelegates(const char* pathOrURL)
    143126{
     
    145128}
    146129
    147 #if PLATFORM(COCOA)
    148 static bool shouldUseThreadedScrolling(const char* pathOrURL)
    149 {
    150     return strstr(pathOrURL, "tiled-drawing/");
    151 }
    152 #endif
    153 
    154130static bool shouldLogHistoryClientCallbacks(const char* pathOrURL)
    155131{
     
    157133}
    158134
    159 static void updateThreadedScrollingForCurrentTest(const char* pathOrURL)
    160 {
    161 #if PLATFORM(COCOA)
    162     WKRetainPtr<WKMutableDictionaryRef> viewOptions = adoptWK(WKMutableDictionaryCreate());
    163     WKRetainPtr<WKStringRef> useThreadedScrollingKey = adoptWK(WKStringCreateWithUTF8CString("ThreadedScrolling"));
    164     WKRetainPtr<WKBooleanRef> useThreadedScrollingValue = adoptWK(WKBooleanCreate(shouldUseThreadedScrolling(pathOrURL)));
    165     WKDictionarySetItem(viewOptions.get(), useThreadedScrollingKey.get(), useThreadedScrollingValue.get());
    166 
    167     WKRetainPtr<WKStringRef> useRemoteLayerTreeKey = adoptWK(WKStringCreateWithUTF8CString("RemoteLayerTree"));
    168     WKRetainPtr<WKBooleanRef> useRemoteLayerTreeValue = adoptWK(WKBooleanCreate(TestController::shared().shouldUseRemoteLayerTree()));
    169     WKDictionarySetItem(viewOptions.get(), useRemoteLayerTreeKey.get(), useRemoteLayerTreeValue.get());
    170 
    171     TestController::shared().ensureViewSupportsOptions(viewOptions.get());
    172 #else
    173     UNUSED_PARAM(pathOrURL);
    174 #endif
    175 }
    176 
    177 static bool shouldUseFixedLayout(const char* pathOrURL)
    178 {
    179 #if ENABLE(CSS_DEVICE_ADAPTATION)
    180     if (strstr(pathOrURL, "device-adapt/") || strstr(pathOrURL, "device-adapt\\"))
    181         return true;
    182 #endif
    183 
    184 #if USE(TILED_BACKING_STORE) && PLATFORM(EFL)
    185     if (strstr(pathOrURL, "sticky/") || strstr(pathOrURL, "sticky\\"))
    186         return true;
    187 #endif
    188     return false;
    189 
    190     UNUSED_PARAM(pathOrURL);
    191 }
    192 
    193 static void updateLayoutType(const char* pathOrURL)
    194 {
    195     WKRetainPtr<WKMutableDictionaryRef> viewOptions = adoptWK(WKMutableDictionaryCreate());
    196     WKRetainPtr<WKStringRef> useFixedLayoutKey = adoptWK(WKStringCreateWithUTF8CString("UseFixedLayout"));
    197     WKRetainPtr<WKBooleanRef> useFixedLayoutValue = adoptWK(WKBooleanCreate(shouldUseFixedLayout(pathOrURL)));
    198     WKDictionarySetItem(viewOptions.get(), useFixedLayoutKey.get(), useFixedLayoutValue.get());
    199 
    200     TestController::shared().ensureViewSupportsOptions(viewOptions.get());
    201 }
    202 
    203135void TestInvocation::invoke()
    204136{
    205     TestController::TimeoutDuration timeoutToUse = TestController::LongTimeout;
    206     changeWindowScaleIfNeeded(m_pathOrURL.c_str());
    207     sizeWebViewForCurrentTest(m_pathOrURL.c_str());
    208     updateLayoutType(m_pathOrURL.c_str());
    209     updateThreadedScrollingForCurrentTest(m_pathOrURL.c_str());
     137    TestController::shared().configureViewForTest(*this);
    210138
    211139    WKPageSetAddsVisitedLinks(TestController::shared().mainWebView()->page(), false);
     
    235163
    236164    WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), beginTestMessageBody.get());
     165
     166    TestController::TimeoutDuration timeoutToUse = TestController::LongTimeout;
    237167
    238168    TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout);
  • trunk/Tools/WebKitTestRunner/TestInvocation.h

    r169113 r169845  
    4141
    4242    WKURLRef url() const;
     43    const char* pathOrURL() const { return m_pathOrURL.c_str(); }
    4344
    4445    void setIsPixelTest(const std::string& expectedPixelHash);
  • trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm

    r168961 r169845  
    6363}
    6464
     65static bool shouldMakeViewportFlexible(const char* pathOrURL)
     66{
     67    return strstr(pathOrURL, "viewport/");
     68}
     69
     70void TestController::platformConfigureViewForTest(const TestInvocation& test)
     71{
     72    if (shouldMakeViewportFlexible(test.pathOrURL())) {
     73        const unsigned phoneViewHeight = 480;
     74        const unsigned phoneViewWidth = 320;
     75
     76        mainWebView()->resizeTo(phoneViewWidth, phoneViewHeight);
     77        // FIXME: more viewport config to do here.
     78    }
     79}
     80
    6581void TestController::platformRunUntil(bool& done, double timeout)
    6682{
  • trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm

    r168961 r169845  
    7474}
    7575
     76static bool shouldUseThreadedScrolling(const char* pathOrURL)
     77{
     78    return strstr(pathOrURL, "tiled-drawing/");
     79}
     80
     81void TestController::platformConfigureViewForTest(const TestInvocation& test)
     82{
     83    auto viewOptions = adoptWK(WKMutableDictionaryCreate());
     84    auto useThreadedScrollingKey = adoptWK(WKStringCreateWithUTF8CString("ThreadedScrolling"));
     85    auto useThreadedScrollingValue = adoptWK(WKBooleanCreate(shouldUseThreadedScrolling(test.pathOrURL())));
     86    WKDictionarySetItem(viewOptions.get(), useThreadedScrollingKey.get(), useThreadedScrollingValue.get());
     87
     88    auto useRemoteLayerTreeKey = adoptWK(WKStringCreateWithUTF8CString("RemoteLayerTree"));
     89    auto useRemoteLayerTreeValue = adoptWK(WKBooleanCreate(shouldUseRemoteLayerTree()));
     90    WKDictionarySetItem(viewOptions.get(), useRemoteLayerTreeKey.get(), useRemoteLayerTreeValue.get());
     91
     92    ensureViewSupportsOptions(viewOptions.get());
     93}
     94
    7695void TestController::platformRunUntil(bool& done, double timeout)
    7796{
Note: See TracChangeset for help on using the changeset viewer.