~faenil/ubuntu-ui-toolkit/update_import_statement_docs

« back to all changes in this revision

Viewing changes to manual-tests/testcaseexecutor/tst_manualtestcase.cpp

  • Committer: Juhapekka Piiroinen
  • Date: 2012-08-27 11:43:50 UTC
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: juhapekka.piiroinen@canonical.com-20120827114350-14lz26bkdtx8jo5k
Added a manual testcase executor

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "tst_manualtestcase.h"
 
2
#include <QtTest>
 
3
#include "testcaseexecutiondialog.h"
 
4
#include <QDialogButtonBox>
 
5
 
 
6
tst_manualtestcase::tst_manualtestcase(QObject *parent) :
 
7
    QObject(parent)
 
8
{
 
9
 
 
10
}
 
11
 
 
12
void tst_manualtestcase::run() {
 
13
    foreach (QString testcase, m_testCases) {
 
14
        qDebug() << "Starting" << testcase;
 
15
        qDebug() << "Loading data to QDeclarativeView";
 
16
        QString testfile = testcase.split("_").takeAt(1) + ".qml";
 
17
        QFile test(testcase);
 
18
        if (test.open(QIODevice::ReadOnly)) {
 
19
            QString testdata = test.readAll();
 
20
            test.close();
 
21
            runTest(testcase,testdata,testfile);
 
22
        }
 
23
    }
 
24
}
 
25
 
 
26
void tst_manualtestcase::list() {
 
27
    QDir currentDirectory = QDir::currentPath();
 
28
    m_testCases = currentDirectory.entryList(QStringList() << "tst*.txt");
 
29
    qDebug() << m_testCases;
 
30
}
 
31
 
 
32
void tst_manualtestcase::runTest(QString testcase, QString testdata, QString qmlFile) {
 
33
 
 
34
    TestCaseExecutionDialog testcaseExecutor(testcase,testdata,QUrl::fromLocalFile(qmlFile));
 
35
 
 
36
    int result = testcaseExecutor.exec();
 
37
    switch (result) {
 
38
    case 1:
 
39
        qDebug() << testcase << "was PASSED";
 
40
        QVERIFY(true);
 
41
        break;
 
42
    default:
 
43
        qDebug() << testcase << "was FAILED!";
 
44
        QVERIFY(false);
 
45
        break;
 
46
    }
 
47
 
 
48
}
 
49
 
 
50
QTEST_MAIN(tst_manualtestcase)
 
51