Changeset 137993 in webkit


Ignore:
Timestamp:
Dec 18, 2012 12:25:58 AM (11 years ago)
Author:
jochen@chromium.org
Message:

[chromium] move editing callback dumping to the WebTestProxy
https://bugs.webkit.org/show_bug.cgi?id=105013

Reviewed by Darin Fisher.

To decide whether or not to dump the editing callbacks, the WebTestProxy
needs to query the TestRunner. For this purpose, I introduce a
WebTestRunner class that just exposes the shouldDumpEditingCallbacks
method. In contrast to e.g. WebEventSender, the WebTestRunner is just
an interface, and it is not owned by the WebTestInterfaces, but the
embedder of the TestRunner library must provide it. This will change
once all TestRunner methods are in the library.

  • DumpRenderTree/DumpRenderTree.gypi:
  • DumpRenderTree/chromium/DRTTestRunner.cpp:

(DRTTestRunner::DRTTestRunner):
(DRTTestRunner::reset):

  • DumpRenderTree/chromium/DRTTestRunner.h:

(DRTTestRunner):
(DRTTestRunner::taskList):
(DRTTestRunner::WorkQueue::taskList):

  • DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h:

(WebTestRunner):
(WebTestInterfaces):

  • DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:

(WebKit):
(WebTestRunner):
(WebTestProxyBase):
(WebTestRunner::WebTestProxy::shouldBeginEditing):
(WebTestRunner::WebTestProxy::shouldEndEditing):
(WebTestRunner::WebTestProxy::shouldInsertNode):
(WebTestRunner::WebTestProxy::shouldInsertText):
(WebTestRunner::WebTestProxy::shouldChangeSelectedRange):
(WebTestRunner::WebTestProxy::shouldDeleteRange):
(WebTestRunner::WebTestProxy::shouldApplyStyle):
(WebTestRunner::WebTestProxy::didBeginEditing):
(WebTestRunner::WebTestProxy::didChangeSelection):
(WebTestRunner::WebTestProxy::didChangeContents):
(WebTestRunner::WebTestProxy::didEndEditing):

  • DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h: Copied from Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h.

(WebTestRunner):
(WebTestRunner::WebTestRunner::shouldDumpEditingCallbacks):

  • DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:

(WebTestRunner::TestRunner::TestRunner):
(WebTestRunner::TestRunner::~TestRunner):
(WebTestRunner):
(WebTestRunner::TestRunner::reset):
(WebTestRunner::TestRunner::shouldDumpEditingCallbacks):
(WebTestRunner::TestRunner::dumpEditingCallbacks):

  • DumpRenderTree/chromium/TestRunner/src/TestRunner.h:

(TestRunner):

  • DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp:

(WebTestRunner::WebTestInterfaces::Internal::testRunner):
(WebTestRunner::WebTestInterfaces::Internal::setTestRunner):
(WebTestInterfaces::Internal):
(WebTestRunner::WebTestInterfaces::Internal::Internal):
(WebTestRunner::WebTestInterfaces::testRunner):
(WebTestRunner):
(WebTestRunner::WebTestInterfaces::setTestRunner):

  • DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:

(WebTestRunner::WebTestProxyBase::postAccessibilityNotification):
(WebTestRunner):
(WebTestRunner::WebTestProxyBase::shouldBeginEditing):
(WebTestRunner::WebTestProxyBase::shouldEndEditing):
(WebTestRunner::WebTestProxyBase::shouldInsertNode):
(WebTestRunner::WebTestProxyBase::shouldInsertText):
(WebTestRunner::WebTestProxyBase::shouldChangeSelectedRange):
(WebTestRunner::WebTestProxyBase::shouldDeleteRange):
(WebTestRunner::WebTestProxyBase::shouldApplyStyle):
(WebTestRunner::WebTestProxyBase::didBeginEditing):
(WebTestRunner::WebTestProxyBase::didChangeSelection):
(WebTestRunner::WebTestProxyBase::didChangeContents):
(WebTestRunner::WebTestProxyBase::didEndEditing):

  • DumpRenderTree/chromium/TestShell.cpp:

(TestShell::initialize):
(TestShell::createNewWindow):

  • DumpRenderTree/chromium/WebViewHost.cpp:

(WebViewHost::shouldBeginEditing):
(WebViewHost::shouldEndEditing):
(WebViewHost::shouldInsertNode):
(WebViewHost::shouldInsertText):
(WebViewHost::shouldChangeSelectedRange):
(WebViewHost::shouldDeleteRange):
(WebViewHost::shouldApplyStyle):

  • DumpRenderTree/chromium/WebViewHost.h:

(WebViewHost):

Location:
trunk/Tools
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r137992 r137993  
     12012-12-18  Jochen Eisinger  <jochen@chromium.org>
     2
     3        [chromium] move editing callback dumping to the WebTestProxy
     4        https://bugs.webkit.org/show_bug.cgi?id=105013
     5
     6        Reviewed by Darin Fisher.
     7
     8        To decide whether or not to dump the editing callbacks, the WebTestProxy
     9        needs to query the TestRunner. For this purpose, I introduce a
     10        WebTestRunner class that just exposes the shouldDumpEditingCallbacks
     11        method. In contrast to e.g. WebEventSender, the WebTestRunner is just
     12        an interface, and it is not owned by the WebTestInterfaces, but the
     13        embedder of the TestRunner library must provide it. This will change
     14        once all TestRunner methods are in the library.
     15
     16        * DumpRenderTree/DumpRenderTree.gypi:
     17        * DumpRenderTree/chromium/DRTTestRunner.cpp:
     18        (DRTTestRunner::DRTTestRunner):
     19        (DRTTestRunner::reset):
     20        * DumpRenderTree/chromium/DRTTestRunner.h:
     21        (DRTTestRunner):
     22        (DRTTestRunner::taskList):
     23        (DRTTestRunner::WorkQueue::taskList):
     24        * DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h:
     25        (WebTestRunner):
     26        (WebTestInterfaces):
     27        * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
     28        (WebKit):
     29        (WebTestRunner):
     30        (WebTestProxyBase):
     31        (WebTestRunner::WebTestProxy::shouldBeginEditing):
     32        (WebTestRunner::WebTestProxy::shouldEndEditing):
     33        (WebTestRunner::WebTestProxy::shouldInsertNode):
     34        (WebTestRunner::WebTestProxy::shouldInsertText):
     35        (WebTestRunner::WebTestProxy::shouldChangeSelectedRange):
     36        (WebTestRunner::WebTestProxy::shouldDeleteRange):
     37        (WebTestRunner::WebTestProxy::shouldApplyStyle):
     38        (WebTestRunner::WebTestProxy::didBeginEditing):
     39        (WebTestRunner::WebTestProxy::didChangeSelection):
     40        (WebTestRunner::WebTestProxy::didChangeContents):
     41        (WebTestRunner::WebTestProxy::didEndEditing):
     42        * DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h: Copied from Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h.
     43        (WebTestRunner):
     44        (WebTestRunner::WebTestRunner::shouldDumpEditingCallbacks):
     45        * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
     46        (WebTestRunner::TestRunner::TestRunner):
     47        (WebTestRunner::TestRunner::~TestRunner):
     48        (WebTestRunner):
     49        (WebTestRunner::TestRunner::reset):
     50        (WebTestRunner::TestRunner::shouldDumpEditingCallbacks):
     51        (WebTestRunner::TestRunner::dumpEditingCallbacks):
     52        * DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
     53        (TestRunner):
     54        * DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp:
     55        (WebTestRunner::WebTestInterfaces::Internal::testRunner):
     56        (WebTestRunner::WebTestInterfaces::Internal::setTestRunner):
     57        (WebTestInterfaces::Internal):
     58        (WebTestRunner::WebTestInterfaces::Internal::Internal):
     59        (WebTestRunner::WebTestInterfaces::testRunner):
     60        (WebTestRunner):
     61        (WebTestRunner::WebTestInterfaces::setTestRunner):
     62        * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
     63        (WebTestRunner::WebTestProxyBase::postAccessibilityNotification):
     64        (WebTestRunner):
     65        (WebTestRunner::WebTestProxyBase::shouldBeginEditing):
     66        (WebTestRunner::WebTestProxyBase::shouldEndEditing):
     67        (WebTestRunner::WebTestProxyBase::shouldInsertNode):
     68        (WebTestRunner::WebTestProxyBase::shouldInsertText):
     69        (WebTestRunner::WebTestProxyBase::shouldChangeSelectedRange):
     70        (WebTestRunner::WebTestProxyBase::shouldDeleteRange):
     71        (WebTestRunner::WebTestProxyBase::shouldApplyStyle):
     72        (WebTestRunner::WebTestProxyBase::didBeginEditing):
     73        (WebTestRunner::WebTestProxyBase::didChangeSelection):
     74        (WebTestRunner::WebTestProxyBase::didChangeContents):
     75        (WebTestRunner::WebTestProxyBase::didEndEditing):
     76        * DumpRenderTree/chromium/TestShell.cpp:
     77        (TestShell::initialize):
     78        (TestShell::createNewWindow):
     79        * DumpRenderTree/chromium/WebViewHost.cpp:
     80        (WebViewHost::shouldBeginEditing):
     81        (WebViewHost::shouldEndEditing):
     82        (WebViewHost::shouldInsertNode):
     83        (WebViewHost::shouldInsertText):
     84        (WebViewHost::shouldChangeSelectedRange):
     85        (WebViewHost::shouldDeleteRange):
     86        (WebViewHost::shouldApplyStyle):
     87        * DumpRenderTree/chromium/WebViewHost.h:
     88        (WebViewHost):
     89
    1902012-12-17  Jochen Eisinger  <jochen@chromium.org>
    291
  • trunk/Tools/DumpRenderTree/DumpRenderTree.gypi

    r137441 r137993  
    6969            'chromium/TestRunner/public/WebTestPlugin.h',
    7070            'chromium/TestRunner/public/WebTestProxy.h',
     71            'chromium/TestRunner/public/WebTestRunner.h',
    7172            'chromium/TestRunner/src/AccessibilityControllerChromium.cpp',
    7273            'chromium/TestRunner/src/AccessibilityControllerChromium.h',
  • trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp

    r136846 r137993  
    135135    bindMethod("dumpChildFramesAsText", &DRTTestRunner::dumpChildFramesAsText);
    136136    bindMethod("dumpChildFrameScrollPositions", &DRTTestRunner::dumpChildFrameScrollPositions);
    137     bindMethod("dumpEditingCallbacks", &DRTTestRunner::dumpEditingCallbacks);
    138137    bindMethod("dumpFrameLoadCallbacks", &DRTTestRunner::dumpFrameLoadCallbacks);
    139138    bindMethod("dumpProgressFinishedCallback", &DRTTestRunner::dumpProgressFinishedCallback);
     
    278277}
    279278
    280 void DRTTestRunner::dumpEditingCallbacks(const CppArgumentList&, CppVariant* result)
    281 {
    282     m_dumpEditingCallbacks = true;
    283     result->setNull();
    284 }
    285 
    286279void DRTTestRunner::dumpBackForwardList(const CppArgumentList&, CppVariant* result)
    287280{
     
    549542    m_dumpAsAudio = false;
    550543    m_dumpCreateView = false;
    551     m_dumpEditingCallbacks = false;
    552544    m_dumpFrameLoadCallbacks = false;
    553545    m_dumpProgressFinishedCallback = false;
  • trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.h

    r136552 r137993  
    6666using WebTestRunner::CppArgumentList;
    6767using WebTestRunner::CppVariant;
     68using WebTestRunner::WebMethodTask;
     69using WebTestRunner::WebTaskList;
    6870
    6971class DRTTestRunner : public WebTestRunner::TestRunner {
     
    7375    DRTTestRunner(TestShell*);
    7476
    75     ~DRTTestRunner();
     77    virtual ~DRTTestRunner();
    7678
    7779    // This function sets a flag that tells the test_shell to dump pages as
     
    7981    // It takes an optional argument, whether to dump pixels results or not.
    8082    void dumpAsText(const CppArgumentList&, CppVariant*);
    81 
    82     // This function sets a flag that tells the test_shell to print a line of
    83     // descriptive text for each editing command. It takes no arguments, and
    84     // ignores any that may be present.
    85     void dumpEditingCallbacks(const CppArgumentList&, CppVariant*);
    8683
    8784    // This function sets a flag that tells the test_shell to print a line of
     
    296293    bool shouldDumpAsText() { return m_dumpAsText; }
    297294    void setShouldDumpAsText(bool value) { m_dumpAsText = value; }
    298     bool shouldDumpEditingCallbacks() { return m_dumpEditingCallbacks; }
    299295    bool shouldDumpFrameLoadCallbacks() { return m_dumpFrameLoadCallbacks; }
    300296    void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; }
     
    358354    };
    359355
    360     WebTestRunner::WebTaskList* taskList() { return &m_taskList; }
     356    WebTaskList* taskList() { return &m_taskList; }
    361357
    362358    bool shouldStayOnPageAfterHandlingBeforeUnload() const { return m_shouldStayOnPageAfterHandlingBeforeUnload; }
     
    381377        void setFrozen(bool frozen) { m_frozen = frozen; }
    382378        bool isEmpty() { return m_queue.isEmpty(); }
    383         WebTestRunner::WebTaskList* taskList() { return &m_taskList; }
     379        WebTaskList* taskList() { return &m_taskList; }
    384380
    385381    private:
    386382        void processWork();
    387         class WorkQueueTask: public WebTestRunner::WebMethodTask<WorkQueue> {
     383        class WorkQueueTask: public WebMethodTask<WorkQueue> {
    388384        public:
    389             WorkQueueTask(WorkQueue* object): WebTestRunner::WebMethodTask<WorkQueue>(object) { }
     385            WorkQueueTask(WorkQueue* object): WebMethodTask<WorkQueue>(object) { }
    390386            virtual void runIfValid() { m_object->processWork(); }
    391387        };
    392388
    393         WebTestRunner::WebTaskList m_taskList;
     389        WebTaskList m_taskList;
    394390        Deque<WorkItem*> m_queue;
    395391        bool m_frozen;
     
    397393    };
    398394    void completeNotifyDone(bool isTimeout);
    399     class NotifyDoneTimedOutTask: public WebTestRunner::WebMethodTask<DRTTestRunner> {
     395    class NotifyDoneTimedOutTask: public WebMethodTask<DRTTestRunner> {
    400396    public:
    401         NotifyDoneTimedOutTask(DRTTestRunner* object): WebTestRunner::WebMethodTask<DRTTestRunner>(object) { }
     397        NotifyDoneTimedOutTask(DRTTestRunner* object): WebMethodTask<DRTTestRunner>(object) { }
    402398        virtual void runIfValid() { m_object->completeNotifyDone(true); }
    403399    };
    404400
    405401    // Used for test timeouts.
    406     WebTestRunner::WebTaskList m_taskList;
     402    WebTaskList m_taskList;
    407403
    408404    // Non-owning pointer. The DRTTestRunner is owned by the host.
     
    415411    // If true, the test_shell will output a base64 encoded WAVE file.
    416412    bool m_dumpAsAudio;
    417 
    418     // If true, the test_shell will write a descriptive line for each editing
    419     // command.
    420     bool m_dumpEditingCallbacks;
    421413
    422414    // If true, the test_shell will draw the bounds of the current selection rect
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h

    r132029 r137993  
    4242class WebEventSender;
    4343class WebTestDelegate;
     44class WebTestRunner;
    4445
    4546class WebTestInterfaces {
     
    5556    WebAccessibilityController* accessibilityController();
    5657    WebEventSender* eventSender();
     58    WebTestRunner* testRunner();
     59    // FIXME: Remove this once TestRunner is complete.
     60    void setTestRunner(WebTestRunner*);
    5761
    5862private:
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h

    r135006 r137993  
    3535#include "WebKit/chromium/public/WebAccessibilityNotification.h"
    3636#include "WebKit/chromium/public/WebDragOperation.h"
     37#include "WebKit/chromium/public/WebEditingAction.h"
    3738#include "WebKit/chromium/public/WebNavigationPolicy.h"
     39#include "WebKit/chromium/public/WebTextAffinity.h"
    3840
    3941namespace WebKit {
     
    4244class WebFrame;
    4345class WebImage;
     46class WebNode;
     47class WebRange;
     48class WebString;
    4449struct WebPoint;
    4550struct WebSize;
     
    5055class WebTestDelegate;
    5156class WebTestInterfaces;
     57class WebTestRunner;
    5258
    5359class WebTestProxyBase {
     
    7278    void postAccessibilityNotification(const WebKit::WebAccessibilityObject&, WebKit::WebAccessibilityNotification);
    7379    void startDragging(WebKit::WebFrame*, const WebKit::WebDragData&, WebKit::WebDragOperationsMask, const WebKit::WebImage&, const WebKit::WebPoint&);
     80    bool shouldBeginEditing(const WebKit::WebRange&);
     81    bool shouldEndEditing(const WebKit::WebRange&);
     82    bool shouldInsertNode(const WebKit::WebNode&, const WebKit::WebRange&, WebKit::WebEditingAction);
     83    bool shouldInsertText(const WebKit::WebString& text, const WebKit::WebRange&, WebKit::WebEditingAction);
     84    bool shouldChangeSelectedRange(const WebKit::WebRange& fromRange, const WebKit::WebRange& toRange, WebKit::WebTextAffinity, bool stillSelecting);
     85    bool shouldDeleteRange(const WebKit::WebRange&);
     86    bool shouldApplyStyle(const WebKit::WebString& style, const WebKit::WebRange&);
     87    void didBeginEditing();
     88    void didChangeSelection(bool isEmptySelection);
     89    void didChangeContents();
     90    void didEndEditing();
    7491
    7592private:
     
    137154        WebViewClientImpl::startDragging(frame, data, mask, image, point);
    138155    }
     156    virtual bool shouldBeginEditing(const WebKit::WebRange& range)
     157    {
     158        WebTestProxyBase::shouldBeginEditing(range);
     159        return WebViewClientImpl::shouldBeginEditing(range);
     160    }
     161    virtual bool shouldEndEditing(const WebKit::WebRange& range)
     162    {
     163        WebTestProxyBase::shouldEndEditing(range);
     164        return WebViewClientImpl::shouldEndEditing(range);
     165    }
     166    virtual bool shouldInsertNode(const WebKit::WebNode& node, const WebKit::WebRange& range, WebKit::WebEditingAction action)
     167    {
     168        WebTestProxyBase::shouldInsertNode(node, range, action);
     169        return WebViewClientImpl::shouldInsertNode(node, range, action);
     170    }
     171    virtual bool shouldInsertText(const WebKit::WebString& text, const WebKit::WebRange& range, WebKit::WebEditingAction action)
     172    {
     173        WebTestProxyBase::shouldInsertText(text, range, action);
     174        return WebViewClientImpl::shouldInsertText(text, range, action);
     175    }
     176    virtual bool shouldChangeSelectedRange(const WebKit::WebRange& fromRange, const WebKit::WebRange& toRange, WebKit::WebTextAffinity affinity, bool stillSelecting)
     177    {
     178        WebTestProxyBase::shouldChangeSelectedRange(fromRange, toRange, affinity, stillSelecting);
     179        return WebViewClientImpl::shouldChangeSelectedRange(fromRange, toRange, affinity, stillSelecting);
     180    }
     181    virtual bool shouldDeleteRange(const WebKit::WebRange& range)
     182    {
     183        WebTestProxyBase::shouldDeleteRange(range);
     184        return WebViewClientImpl::shouldDeleteRange(range);
     185    }
     186    virtual bool shouldApplyStyle(const WebKit::WebString& style, const WebKit::WebRange& range)
     187    {
     188        WebTestProxyBase::shouldApplyStyle(style, range);
     189        return WebViewClientImpl::shouldApplyStyle(style, range);
     190    }
     191    virtual void didBeginEditing()
     192    {
     193        WebTestProxyBase::didBeginEditing();
     194        WebViewClientImpl::didBeginEditing();
     195    }
     196    virtual void didChangeSelection(bool isEmptySelection)
     197    {
     198        WebTestProxyBase::didChangeSelection(isEmptySelection);
     199        WebViewClientImpl::didChangeSelection(isEmptySelection);
     200    }
     201    virtual void didChangeContents()
     202    {
     203        WebTestProxyBase::didChangeContents();
     204        WebViewClientImpl::didChangeContents();
     205    }
     206    virtual void didEndEditing()
     207    {
     208        WebTestProxyBase::didEndEditing();
     209        WebViewClientImpl::didEndEditing();
     210    }
    139211};
    140212
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h

    r137992 r137993  
    2929 */
    3030
    31 #ifndef WebTestInterfaces_h
    32 #define WebTestInterfaces_h
    33 
    34 namespace WebKit {
    35 class WebFrame;
    36 class WebView;
    37 }
     31#ifndef WebTestRunner_h
     32#define WebTestRunner_h
    3833
    3934namespace WebTestRunner {
    4035
    41 class WebAccessibilityController;
    42 class WebEventSender;
    43 class WebTestDelegate;
    44 
    45 class WebTestInterfaces {
     36// FIXME: Once the TestRunner class is complete, this class should take a
     37// TestRunner* as ctor argument, and not have default implementations.
     38class WebTestRunner {
    4639public:
    47     WebTestInterfaces();
    48     ~WebTestInterfaces();
    49 
    50     void setWebView(WebKit::WebView*);
    51     void setDelegate(WebTestDelegate*);
    52     void bindTo(WebKit::WebFrame*);
    53     void resetAll();
    54 
    55     WebAccessibilityController* accessibilityController();
    56     WebEventSender* eventSender();
    57 
    58 private:
    59     class Internal;
    60     Internal* m_internal;
     40    virtual bool shouldDumpEditingCallbacks() const { return false; }
    6141};
    6242
    6343}
    6444
    65 #endif // WebTestInterfaces_h
     45#endif // WebTestRunner_h
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp

    r137992 r137993  
    115115    bindMethod("setTouchDragDropEnabled", &TestRunner::setTouchDragDropEnabled);
    116116
     117    // The following modify the state of the TestRunner.
     118    bindMethod("dumpEditingCallbacks", &TestRunner::dumpEditingCallbacks);
     119
    117120    // Properties.
    118121    bindProperty("workerThreadCount", &TestRunner::workerThreadCount);
     
    152155}
    153156
     157TestRunner::~TestRunner()
     158{
     159}
     160
    154161void TestRunner::reset()
    155162{
     
    170177#endif
    171178
     179    m_dumpEditingCallbacks = false;
     180
    172181    m_globalFlag.set(false);
    173182    m_platformName.set("chromium");
    174183
    175184    m_userStyleSheetLocation = WebURL();
     185}
     186
     187bool TestRunner::shouldDumpEditingCallbacks() const
     188{
     189    return m_dumpEditingCallbacks;
    176190}
    177191
     
    838852}
    839853
     854void TestRunner::dumpEditingCallbacks(const CppArgumentList&, CppVariant* result)
     855{
     856    m_dumpEditingCallbacks = true;
     857    result->setNull();
     858}
     859
    840860void TestRunner::workerThreadCount(CppVariant* result)
    841861{
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h

    r137992 r137993  
    3434
    3535#include "CppBoundClass.h"
     36#include "WebTestRunner.h"
    3637#include "platform/WebURL.h"
    3738
     
    4445class WebTestDelegate;
    4546
    46 class TestRunner : public CppBoundClass {
     47class TestRunner : public CppBoundClass, public WebTestRunner {
    4748public:
    4849    TestRunner();
     50    virtual ~TestRunner();
    4951
    5052    // FIXME: once DRTTestRunner is moved entirely to this class, change this
     
    5456
    5557    void reset();
     58
     59    // WebTestRunner implementation.
     60    virtual bool shouldDumpEditingCallbacks() const OVERRIDE;
    5661
    5762protected:
     
    174179
    175180    ///////////////////////////////////////////////////////////////////////////
     181    // Methods that modify the state of TestRunner
     182
     183    // This function sets a flag that tells the test_shell to print a line of
     184    // descriptive text for each editing command. It takes no arguments, and
     185    // ignores any that may be present.
     186    void dumpEditingCallbacks(const CppArgumentList&, CppVariant*);
     187
     188    ///////////////////////////////////////////////////////////////////////////
    176189    // Properties
    177190    void workerThreadCount(CppVariant*);
     
    205218    CppVariant m_platformName;
    206219
     220    // If true, the test_shell will write a descriptive line for each editing
     221    // command.
     222    bool m_dumpEditingCallbacks;
     223
    207224    WebTestDelegate* m_delegate;
    208225    WebKit::WebView* m_webView;
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestInterfaces.cpp

    r132781 r137993  
    5656    WebAccessibilityController* accessibilityController() { return &m_accessibilityController; }
    5757    WebEventSender* eventSender() { return &m_eventSender; }
     58    WebTestRunner* testRunner() { return m_testRunner; }
     59    void setTestRunner(WebTestRunner* testRunner) { m_testRunner = testRunner; }
    5860
    5961    // TestDelegate implementation.
     
    7577    WebAccessibilityController m_accessibilityController;
    7678    WebEventSender m_eventSender;
     79    WebTestRunner* m_testRunner;
    7780    WebTestDelegate* m_delegate;
    7881};
     
    8184    : m_accessibilityController(m_interfaces.accessibilityController())
    8285    , m_eventSender(m_interfaces.eventSender())
     86    , m_testRunner(0)
    8387    , m_delegate(0)
    8488{
     
    200204}
    201205
    202 }
     206WebTestRunner* WebTestInterfaces::testRunner()
     207{
     208    return m_internal->testRunner();
     209}
     210
     211void WebTestInterfaces::setTestRunner(WebTestRunner* testRunner)
     212{
     213    m_internal->setTestRunner(testRunner);
     214}
     215
     216}
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp

    r135006 r137993  
    3838#include "WebEventSender.h"
    3939#include "WebNode.h"
     40#include "WebRange.h"
    4041#include "WebTestDelegate.h"
    4142#include "WebTestInterfaces.h"
     43#include "WebTestRunner.h"
    4244#include "platform/WebCString.h"
     45#include <wtf/StringExtras.h>
    4346
    4447using namespace WebKit;
     
    4649
    4750namespace WebTestRunner {
     51
     52namespace {
     53
     54void printNodeDescription(WebTestDelegate* delegate, const WebNode& node, int exception)
     55{
     56    if (exception) {
     57        delegate->printMessage("ERROR");
     58        return;
     59    }
     60    if (node.isNull()) {
     61        delegate->printMessage("(null)");
     62        return;
     63    }
     64    delegate->printMessage(node.nodeName().utf8().data());
     65    const WebNode& parent = node.parentNode();
     66    if (!parent.isNull()) {
     67        delegate->printMessage(" > ");
     68        printNodeDescription(delegate, parent, 0);
     69    }
     70}
     71
     72void printRangeDescription(WebTestDelegate* delegate, const WebRange& range)
     73{
     74    if (range.isNull()) {
     75        delegate->printMessage("(null)");
     76        return;
     77    }
     78    char buffer[100];
     79    snprintf(buffer, sizeof(buffer), "range from %d of ", range.startOffset());
     80    delegate->printMessage(buffer);
     81    int exception = 0;
     82    WebNode startNode = range.startContainer(exception);
     83    printNodeDescription(delegate, startNode, exception);
     84    snprintf(buffer, sizeof(buffer), " to %d of ", range.endOffset());
     85    delegate->printMessage(buffer);
     86    WebNode endNode = range.endContainer(exception);
     87    printNodeDescription(delegate, endNode, exception);
     88}
     89
     90string editingActionDescription(WebEditingAction action)
     91{
     92    switch (action) {
     93    case WebKit::WebEditingActionTyped:
     94        return "WebViewInsertActionTyped";
     95    case WebKit::WebEditingActionPasted:
     96        return "WebViewInsertActionPasted";
     97    case WebKit::WebEditingActionDropped:
     98        return "WebViewInsertActionDropped";
     99    }
     100    return "(UNKNOWN ACTION)";
     101}
     102
     103string textAffinityDescription(WebTextAffinity affinity)
     104{
     105    switch (affinity) {
     106    case WebKit::WebTextAffinityUpstream:
     107        return "NSSelectionAffinityUpstream";
     108    case WebKit::WebTextAffinityDownstream:
     109        return "NSSelectionAffinityDownstream";
     110    }
     111    return "(UNKNOWN AFFINITY)";
     112}
     113
     114}
    48115
    49116WebTestProxyBase::WebTestProxyBase()
     
    198265
    199266    if (m_testInterfaces->accessibilityController()->shouldLogAccessibilityEvents()) {
    200         std::string message("AccessibilityNotification - ");
     267        string message("AccessibilityNotification - ");
    201268        message += notificationName;
    202269
     
    221288}
    222289
    223 }
     290// The output from these methods in layout test mode should match that
     291// expected by the layout tests. See EditingDelegate.m in DumpRenderTree.
     292
     293// FIXME: Remove the 0 checks for m_testInterfaces->testRunner() once the
     294// TestInterfaces class owns the TestRunner.
     295
     296bool WebTestProxyBase::shouldBeginEditing(const WebRange& range)
     297{
     298    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) {
     299        m_delegate->printMessage("EDITING DELEGATE: shouldBeginEditingInDOMRange:");
     300        printRangeDescription(m_delegate, range);
     301        m_delegate->printMessage("\n");
     302    }
     303    return true;
     304}
     305
     306bool WebTestProxyBase::shouldEndEditing(const WebRange& range)
     307{
     308    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) {
     309        m_delegate->printMessage("EDITING DELEGATE: shouldEndEditingInDOMRange:");
     310        printRangeDescription(m_delegate, range);
     311        m_delegate->printMessage("\n");
     312    }
     313    return true;
     314}
     315
     316bool WebTestProxyBase::shouldInsertNode(const WebNode& node, const WebRange& range, WebEditingAction action)
     317{
     318    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) {
     319        m_delegate->printMessage("EDITING DELEGATE: shouldInsertNode:");
     320        printNodeDescription(m_delegate, node, 0);
     321        m_delegate->printMessage(" replacingDOMRange:");
     322        printRangeDescription(m_delegate, range);
     323        printf(" givenAction:%s\n", editingActionDescription(action).c_str());
     324    }
     325    return true;
     326}
     327
     328bool WebTestProxyBase::shouldInsertText(const WebString& text, const WebRange& range, WebEditingAction action)
     329{
     330    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) {
     331        m_delegate->printMessage(string("EDITING DELEGATE: shouldInsertText:") + text.utf8().data() + " replacingDOMRange:");
     332        printRangeDescription(m_delegate, range);
     333        m_delegate->printMessage(string(" givenAction:") + editingActionDescription(action) + "\n");
     334    }
     335    return true;
     336}
     337
     338bool WebTestProxyBase::shouldChangeSelectedRange(
     339    const WebRange& fromRange, const WebRange& toRange, WebTextAffinity affinity, bool stillSelecting)
     340{
     341    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) {
     342        m_delegate->printMessage("EDITING DELEGATE: shouldChangeSelectedDOMRange:");
     343        printRangeDescription(m_delegate, fromRange);
     344        m_delegate->printMessage(" toDOMRange:");
     345        printRangeDescription(m_delegate, toRange);
     346        m_delegate->printMessage(string(" affinity:") + textAffinityDescription(affinity) + " stillSelecting:" + (stillSelecting ? "TRUE" : "FALSE") + "\n");
     347    }
     348    return true;
     349}
     350
     351bool WebTestProxyBase::shouldDeleteRange(const WebRange& range)
     352{
     353    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) {
     354        m_delegate->printMessage("EDITING DELEGATE: shouldDeleteDOMRange:");
     355        printRangeDescription(m_delegate, range);
     356        m_delegate->printMessage("\n");
     357    }
     358    return true;
     359}
     360
     361bool WebTestProxyBase::shouldApplyStyle(const WebString& style, const WebRange& range)
     362{
     363    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) {
     364        m_delegate->printMessage(string("EDITING DELEGATE: shouldApplyStyle:") + style.utf8().data() + " toElementsInDOMRange:");
     365        printRangeDescription(m_delegate, range);
     366        m_delegate->printMessage("\n");
     367    }
     368    return true;
     369}
     370
     371void WebTestProxyBase::didBeginEditing()
     372{
     373    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks())
     374        m_delegate->printMessage("EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification\n");
     375}
     376
     377void WebTestProxyBase::didChangeSelection(bool isEmptySelection)
     378{
     379    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks())
     380        m_delegate->printMessage("EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n");
     381}
     382
     383void WebTestProxyBase::didChangeContents()
     384{
     385    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks())
     386        m_delegate->printMessage("EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n");
     387}
     388
     389void WebTestProxyBase::didEndEditing()
     390{
     391    if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpEditingCallbacks())
     392        m_delegate->printMessage("EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification\n");
     393}
     394
     395}
  • trunk/Tools/DumpRenderTree/chromium/TestShell.cpp

    r137710 r137993  
    164164    m_testInterfaces = adoptPtr(new WebTestInterfaces());
    165165    m_testRunner = adoptPtr(new DRTTestRunner(this));
     166    m_testInterfaces->setTestRunner(m_testRunner.get());
    166167#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    167168    m_notificationPresenter = adoptPtr(new NotificationPresenter(this));
     
    752753WebViewHost* TestShell::createNewWindow(const WebKit::WebURL& url, DRTDevToolsAgent* devToolsAgent)
    753754{
    754     WebTestRunner::WebTestProxy<WebViewHost, TestShell*>* host = new WebTestRunner::WebTestProxy<WebViewHost, TestShell*>(this);
     755    WebTestProxy<WebViewHost, TestShell*>* host = new WebTestProxy<WebViewHost, TestShell*>(this);
    755756    host->setInterfaces(m_testInterfaces.get());
    756757    if (m_webViewHost)
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r137921 r137993  
    204204}
    205205
    206 static void printRangeDescription(const WebRange& range)
    207 {
    208     if (range.isNull()) {
    209         fputs("(null)", stdout);
    210         return;
    211     }
    212     printf("range from %d of ", range.startOffset());
    213     int exception = 0;
    214     WebNode startNode = range.startContainer(exception);
    215     printNodeDescription(startNode, exception);
    216     printf(" to %d of ", range.endOffset());
    217     WebNode endNode = range.endContainer(exception);
    218     printNodeDescription(endNode, exception);
    219 }
    220 
    221 static string editingActionDescription(WebEditingAction action)
    222 {
    223     switch (action) {
    224     case WebKit::WebEditingActionTyped:
    225         return "WebViewInsertActionTyped";
    226     case WebKit::WebEditingActionPasted:
    227         return "WebViewInsertActionPasted";
    228     case WebKit::WebEditingActionDropped:
    229         return "WebViewInsertActionDropped";
    230     }
    231     return "(UNKNOWN ACTION)";
    232 }
    233 
    234 static string textAffinityDescription(WebTextAffinity affinity)
    235 {
    236     switch (affinity) {
    237     case WebKit::WebTextAffinityUpstream:
    238         return "NSSelectionAffinityUpstream";
    239     case WebKit::WebTextAffinityDownstream:
    240         return "NSSelectionAffinityDownstream";
    241     }
    242     return "(UNKNOWN AFFINITY)";
    243 }
    244 
    245206// WebViewClient -------------------------------------------------------------
    246207
     
    326287}
    327288
    328 // The output from these methods in layout test mode should match that
    329 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree.
    330 
    331289bool WebViewHost::shouldBeginEditing(const WebRange& range)
    332290{
    333     if (testRunner()->shouldDumpEditingCallbacks()) {
    334         fputs("EDITING DELEGATE: shouldBeginEditingInDOMRange:", stdout);
    335         printRangeDescription(range);
    336         fputs("\n", stdout);
    337     }
    338291    return true;
    339292}
     
    341294bool WebViewHost::shouldEndEditing(const WebRange& range)
    342295{
    343     if (testRunner()->shouldDumpEditingCallbacks()) {
    344         fputs("EDITING DELEGATE: shouldEndEditingInDOMRange:", stdout);
    345         printRangeDescription(range);
    346         fputs("\n", stdout);
    347     }
    348296    return true;
    349297}
     
    351299bool WebViewHost::shouldInsertNode(const WebNode& node, const WebRange& range, WebEditingAction action)
    352300{
    353     if (testRunner()->shouldDumpEditingCallbacks()) {
    354         fputs("EDITING DELEGATE: shouldInsertNode:", stdout);
    355         printNodeDescription(node, 0);
    356         fputs(" replacingDOMRange:", stdout);
    357         printRangeDescription(range);
    358         printf(" givenAction:%s\n", editingActionDescription(action).c_str());
    359     }
    360301    return true;
    361302}
     
    363304bool WebViewHost::shouldInsertText(const WebString& text, const WebRange& range, WebEditingAction action)
    364305{
    365     if (testRunner()->shouldDumpEditingCallbacks()) {
    366         printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:", text.utf8().data());
    367         printRangeDescription(range);
    368         printf(" givenAction:%s\n", editingActionDescription(action).c_str());
    369     }
    370306    return true;
    371307}
     
    374310    const WebRange& fromRange, const WebRange& toRange, WebTextAffinity affinity, bool stillSelecting)
    375311{
    376     if (testRunner()->shouldDumpEditingCallbacks()) {
    377         fputs("EDITING DELEGATE: shouldChangeSelectedDOMRange:", stdout);
    378         printRangeDescription(fromRange);
    379         fputs(" toDOMRange:", stdout);
    380         printRangeDescription(toRange);
    381         printf(" affinity:%s stillSelecting:%s\n",
    382                textAffinityDescription(affinity).c_str(),
    383                (stillSelecting ? "TRUE" : "FALSE"));
    384     }
    385312    return true;
    386313}
     
    388315bool WebViewHost::shouldDeleteRange(const WebRange& range)
    389316{
    390     if (testRunner()->shouldDumpEditingCallbacks()) {
    391         fputs("EDITING DELEGATE: shouldDeleteDOMRange:", stdout);
    392         printRangeDescription(range);
    393         fputs("\n", stdout);
    394     }
    395317    return true;
    396318}
     
    398320bool WebViewHost::shouldApplyStyle(const WebString& style, const WebRange& range)
    399321{
    400     if (testRunner()->shouldDumpEditingCallbacks()) {
    401         printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:", style.utf8().data());
    402         printRangeDescription(range);
    403         fputs("\n", stdout);
    404     }
    405322    return true;
    406323}
     
    414331{
    415332    return m_selectTrailingWhitespaceEnabled;
    416 }
    417 
    418 void WebViewHost::didBeginEditing()
    419 {
    420     if (!testRunner()->shouldDumpEditingCallbacks())
    421         return;
    422     fputs("EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification\n", stdout);
    423 }
    424 
    425 void WebViewHost::didChangeSelection(bool isEmptySelection)
    426 {
    427     if (testRunner()->shouldDumpEditingCallbacks())
    428         fputs("EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n", stdout);
    429     // No need to update clipboard with the selected text in DRT.
    430 }
    431 
    432 void WebViewHost::didChangeContents()
    433 {
    434     if (!testRunner()->shouldDumpEditingCallbacks())
    435         return;
    436     fputs("EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n", stdout);
    437 }
    438 
    439 void WebViewHost::didEndEditing()
    440 {
    441     if (!testRunner()->shouldDumpEditingCallbacks())
    442         return;
    443     fputs("EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification\n", stdout);
    444333}
    445334
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.h

    r137921 r137993  
    179179    virtual bool isSmartInsertDeleteEnabled();
    180180    virtual bool isSelectTrailingWhitespaceEnabled();
    181     virtual void didBeginEditing();
    182     virtual void didChangeSelection(bool isSelectionEmpty);
    183     virtual void didChangeContents();
    184     virtual void didEndEditing();
    185181    virtual bool handleCurrentKeyboardEvent();
    186182    virtual void runModalAlertDialog(WebKit::WebFrame*, const WebKit::WebString&);
Note: See TracChangeset for help on using the changeset viewer.