Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
3 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro

    r561 r846  
    1 TEMPLATE = app
    2 TARGET = tst_qgraphicswebview
    3 include(../../../../WebKit.pri)
    4 SOURCES  += tst_qgraphicswebview.cpp
    5 QT += testlib network
    6 QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
    7 
    8 symbian {
    9     TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
    10 }
     1isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../../..
     2include(../tests.pri)
     3exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
  • trunk/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp

    r561 r846  
    1818*/
    1919
     20
    2021#include <QtTest/QtTest>
    21 
     22#include <QGraphicsSceneMouseEvent>
    2223#include <QGraphicsView>
    2324#include <qgraphicswebview.h>
     
    2526#include <qwebframe.h>
    2627
    27 /**
    28  * Starts an event loop that runs until the given signal is received.
    29  * Optionally the event loop
    30  * can return earlier on a timeout.
    31  *
    32  * \return \p true if the requested signal was received
    33  *         \p false on timeout
    34  */
    35 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
    36 {
    37     QEventLoop loop;
    38     QObject::connect(obj, signal, &loop, SLOT(quit()));
    39     QTimer timer;
    40     QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
    41     if (timeout > 0) {
    42         QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
    43         timer.setSingleShot(true);
    44         timer.start(timeout);
    45     }
    46     loop.exec();
    47     return timeoutSpy.isEmpty();
    48 }
    49 
    5028class tst_QGraphicsWebView : public QObject
    5129{
     
    5533    void qgraphicswebview();
    5634    void crashOnViewlessWebPages();
     35
     36
     37
    5738};
    5839
     
    9879};
    9980
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
    100104void tst_QGraphicsWebView::crashOnViewlessWebPages()
    101105{
     
    107111    webView->setPage(page);
    108112    page->webView = webView;
    109     connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting()));
    110 
    111113    scene.addItem(webView);
    112114
     
    114116    view.resize(600, 480);
    115117    webView->resize(view.geometry().size());
    116     QTest::qWait(200);
     118
     119    QCoreApplication::processEvents();
    117120    view.show();
     121
     122
     123
     124
    118125
    119126    page->mainFrame()->setHtml(QString("data:text/html,"
     
    123130                                            "</frameset>"));
    124131
    125     QVERIFY(::waitForSignal(page, SIGNAL(loadFinished(bool))));
    126 }
     132    QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool))));
     133    delete page;
     134}
     135
     136void tst_QGraphicsWebView::crashOnSetScaleBeforeSetUrl()
     137{
     138    QGraphicsWebView* webView = new QGraphicsWebView;
     139    webView->setScale(2.0);
     140    delete webView;
     141}
     142
     143void tst_QGraphicsWebView::microFocusCoordinates()
     144{
     145    QWebPage* page = new QWebPage;
     146    QGraphicsWebView* webView = new QGraphicsWebView;
     147    webView->setPage( page );
     148    QGraphicsView* view = new QGraphicsView;
     149    QGraphicsScene* scene = new QGraphicsScene(view);
     150    view->setScene(scene);
     151    scene->addItem(webView);
     152    view->setGeometry(QRect(0,0,500,500));
     153
     154    page->mainFrame()->setHtml("<html><body>" \
     155        "<input type='text' id='input1' style='font--family: serif' value='' maxlength='20'/><br>" \
     156        "<canvas id='canvas1' width='500' height='500'/>" \
     157        "<input type='password'/><br>" \
     158        "<canvas id='canvas2' width='500' height='500'/>" \
     159        "</body></html>");
     160
     161    page->mainFrame()->setFocus();
     162
     163    QVariant initialMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus);
     164    QVERIFY(initialMicroFocus.isValid());
     165
     166    page->mainFrame()->scroll(0,300);
     167
     168    QVariant currentMicroFocus = page->inputMethodQuery(Qt::ImMicroFocus);
     169    QVERIFY(currentMicroFocus.isValid());
     170
     171    QCOMPARE(initialMicroFocus.toRect().translated(QPoint(0,-300)), currentMicroFocus.toRect());
     172
     173    delete view;
     174}
     175
     176void tst_QGraphicsWebView::focusInputTypes()
     177{
     178    QWebPage* page = new QWebPage;
     179    GraphicsWebView* webView = new GraphicsWebView;
     180    webView->setPage( page );
     181    QGraphicsView* view = new QGraphicsView;
     182    QGraphicsScene* scene = new QGraphicsScene(view);
     183    view->setScene(scene);
     184    scene->addItem(webView);
     185    view->setGeometry(QRect(0,0,500,500));
     186    QCoreApplication::processEvents();
     187    QUrl url("qrc:///resources/input_types.html");
     188    page->mainFrame()->load(url);
     189    page->mainFrame()->setFocus();
     190
     191    QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool))));
     192
     193    // 'text' type
     194    webView->fireMouseClick(QPointF(20.0, 10.0));
     195#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN)
     196    QVERIFY(webView->inputMethodHints() & Qt::ImhNoAutoUppercase);
     197    QVERIFY(webView->inputMethodHints() & Qt::ImhNoPredictiveText);
     198#else
     199    QVERIFY(webView->inputMethodHints() == Qt::ImhNone);
     200#endif
     201
     202    // 'password' field
     203    webView->fireMouseClick(QPointF(20.0, 60.0));
     204    QVERIFY(webView->inputMethodHints() & Qt::ImhHiddenText);
     205
     206    // 'tel' field
     207    webView->fireMouseClick(QPointF(20.0, 110.0));
     208    QVERIFY(webView->inputMethodHints() & Qt::ImhDialableCharactersOnly);
     209
     210    // 'number' field
     211    webView->fireMouseClick(QPointF(20.0, 160.0));
     212    QVERIFY(webView->inputMethodHints() & Qt::ImhDigitsOnly);
     213
     214    // 'email' field
     215    webView->fireMouseClick(QPointF(20.0, 210.0));
     216    QVERIFY(webView->inputMethodHints() & Qt::ImhEmailCharactersOnly);
     217
     218    // 'url' field
     219    webView->fireMouseClick(QPointF(20.0, 260.0));
     220    QVERIFY(webView->inputMethodHints() & Qt::ImhUrlCharactersOnly);
     221
     222    delete webView;
     223    delete view;
     224}
     225
     226
    127227
    128228QTEST_MAIN(tst_QGraphicsWebView)
Note: See TracChangeset for help on using the changeset viewer.