Changeset 134228 in webkit


Ignore:
Timestamp:
Nov 12, 2012 7:24:41 AM (11 years ago)
Author:
jocelyn.turcotte@digia.com
Message:

[Qt] Fix tst_QWebPage::inputMethods on Qt5
https://bugs.webkit.org/show_bug.cgi?id=101571

Reviewed by Simon Hausmann.

QEvent::RequestSoftwareInputPanel isn't passed through event filters anymore.
Use QInputMethodPrivate::testContext instead to capture input method events,
the same way as qtbase tests like tst_QTextEdit are doing.

  • tests/qwebpage/tst_qwebpage.cpp:

(TestInputContext::TestInputContext):
(TestInputContext::~TestInputContext):
(TestInputContext):
(TestInputContext::showInputPanel):
(TestInputContext::hideInputPanel):
(TestInputContext::isInputPanelVisible):
(tst_QWebPage::inputMethods):

Location:
trunk/Source/WebKit/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/qt/ChangeLog

    r134062 r134228  
     12012-11-08  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
     2
     3        [Qt] Fix tst_QWebPage::inputMethods on Qt5
     4        https://bugs.webkit.org/show_bug.cgi?id=101571
     5
     6        Reviewed by Simon Hausmann.
     7
     8        QEvent::RequestSoftwareInputPanel isn't passed through event filters anymore.
     9        Use QInputMethodPrivate::testContext instead to capture input method events,
     10        the same way as qtbase tests like tst_QTextEdit are doing.
     11
     12        * tests/qwebpage/tst_qwebpage.cpp:
     13        (TestInputContext::TestInputContext):
     14        (TestInputContext::~TestInputContext):
     15        (TestInputContext):
     16        (TestInputContext::showInputPanel):
     17        (TestInputContext::hideInputPanel):
     18        (TestInputContext::isInputPanelVisible):
     19        (tst_QWebPage::inputMethods):
     20
    1212012-11-09  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
    222
  • trunk/Source/WebKit/qt/tests/qwebpage/qwebpage.pro

    r99274 r134228  
    11include(../tests.pri)
    22exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
     3QT *= core-private gui-private
  • trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r134062 r134228  
    3333#include <QtTest/QtTest>
    3434#include <QTextCharFormat>
     35#include <private/qinputmethod_p.h>
    3536#include <qgraphicsscene.h>
    3637#include <qgraphicsview.h>
     
    3839#include <qnetworkcookiejar.h>
    3940#include <qnetworkrequest.h>
     41#include <qpa/qplatforminputcontext.h>
    4042#include <qwebdatabase.h>
    4143#include <qwebelement.h>
     
    5961}
    6062
    61 class EventSpy : public QObject, public QList<QEvent::Type>
    62 {
    63     Q_OBJECT
     63class TestInputContext : public QPlatformInputContext
     64{
    6465public:
    65     EventSpy(QObject* objectToSpy)
    66     {
    67         objectToSpy->installEventFilter(this);
    68     }
    69 
    70     virtual bool eventFilter(QObject* receiver, QEvent* event)
    71     {
    72         append(event->type());
    73         return false;
    74     }
     66    TestInputContext()
     67    : m_visible(false)
     68    {
     69        QInputMethodPrivate* inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
     70        inputMethodPrivate->testContext = this;
     71    }
     72
     73    ~TestInputContext()
     74    {
     75        QInputMethodPrivate* inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
     76        inputMethodPrivate->testContext = 0;
     77    }
     78
     79    virtual void showInputPanel()
     80    {
     81        m_visible = true;
     82    }
     83    virtual void hideInputPanel()
     84    {
     85        m_visible = false;
     86    }
     87    virtual bool isInputPanelVisible() const
     88    {
     89        return m_visible;
     90    }
     91
     92    bool m_visible;
    7593};
    7694
     
    16461664    page->mainFrame()->setFocus();
    16471665
    1648     EventSpy viewEventSpy(container);
     1666    TestInputContext testContext;
    16491667
    16501668    QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input");
     
    16711689    // this part of the test can verified as the checks below.
    16721690    if (inputPanel)
    1673         QVERIFY(viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
     1691        QVERIFY(testContext.isInputPanelVisible());
    16741692    else
    1675         QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
    1676     viewEventSpy.clear();
     1693        QVERIFY(!testContext.isInputPanelVisible());
     1694    testContext.hideInputPanel();
    16771695
    16781696    clickOnPage(page, textInputCenter);
    1679     QVERIFY(viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
     1697    QVERIFY(testContext.isInputPanelVisible());
    16801698
    16811699    //ImMicroFocus
     
    18821900
    18831901    page->mainFrame()->setHtml("<html><body><p>nothing to input here");
    1884     viewEventSpy.clear();
     1902    testContext.hideInputPanel();
    18851903
    18861904    QWebElement para = page->mainFrame()->findFirstElement("p");
    18871905    clickOnPage(page, para.geometry().center());
    18881906
    1889     QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
     1907    QVERIFY(!testContext.isInputPanelVisible());
    18901908
    18911909    //START - Test for sending empty QInputMethodEvent
     
    22192237    clickOnPage(page, inputElement.geometry().center());
    22202238
    2221     QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
     2239    QVERIFY(!testContext.isInputPanelVisible());
    22222240
    22232241    // START - Newline test for textarea
Note: See TracChangeset for help on using the changeset viewer.