Home

testgui.cpp Example File
tutorial4/testgui.cpp

    /***************************************************************************
    ** This file may be distributed under the terms of the Q Public License
    ** as defined by Trolltech AS of Norway and appearing in the file
    ** LICENSE.QPL included in the packaging of this file.
    **
    ** This file may be distributed and/or modified under the terms of the
    ** GNU General Public License version 2 as published by the Free Software
    ** Foundation and appearing in the file LICENSE.GPL included in the
    ** packaging of this file.
    */
    #include <QtGui>
    #include <QtTest>

    class TestGui: public QObject
    {
        Q_OBJECT

    private slots:
        void testGui_data(QtTestTable &t);
        void testGui();
    };

    void TestGui::testGui_data(QtTestTable &t)
    {
        t.defineElement("QtTestEventList", "events");
        t.defineElement("QString", "expected");

        QtTestEventList list1;
        list1.addKeyClick('a');
        *t.newData("char") << list1 << "a";

        QtTestEventList list2;
        list2.addKeyClick('a');
        list2.addKeyClick(Qt::Key_Backspace);
        *t.newData("there and back again") << list2 << "";
    }

    void TestGui::testGui()
    {
        FETCH(QtTestEventList, events);
        FETCH(QString, expected);

        QLineEdit lineEdit;

        events.simulate(&lineEdit);

        COMPARE(lineEdit.text(), expected);
    }

    QTTEST_MAIN(TestGui)
    #include "testgui.moc"


Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions