~fboucault/ubuntu-ui-toolkit/icon_api_sanitization

« back to all changes in this revision

Viewing changes to manual-tests/testcaseexecutor/testcaseexecutiondialog.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 "testcaseexecutiondialog.h"
 
2
#include "ui_testcaseexecutiondialog.h"
 
3
 
 
4
TestCaseExecutionDialog::TestCaseExecutionDialog(QString testcase, QString testdata, QUrl qmlFile, QWidget *parent) :
 
5
    QDialog(parent),
 
6
    ui(new Ui::TestCaseExecutionDialog),
 
7
    m_declarativeView(new QDeclarativeView)
 
8
{
 
9
    ui->setupUi(this);
 
10
    ui->plainTextEdit->setPlainText(testdata);
 
11
    this->setWindowTitle(testcase);
 
12
    ui->horizontalLayout->addWidget(m_declarativeView);
 
13
 
 
14
    QFile qmldata(qmlFile.toLocalFile());
 
15
    QString data;
 
16
    if (qmldata.open(QIODevice::ReadOnly)) {
 
17
        data = qmldata.readAll();
 
18
        qmldata.close();
 
19
    }
 
20
 
 
21
    ui->plainTextEdit_2->setPlainText(data);
 
22
    tmpQmlFile.open();
 
23
    tmpQmlFile.write(data.toAscii());
 
24
    tmpQmlFile.close();
 
25
 
 
26
    m_declarativeView->engine()->addImportPath("..");
 
27
    m_declarativeView->setSource(QUrl::fromLocalFile(tmpQmlFile.fileName()));
 
28
    m_declarativeView->show();
 
29
    m_declarativeView->viewport()->setFocusPolicy(Qt::StrongFocus);
 
30
}
 
31
 
 
32
void TestCaseExecutionDialog::on_pushButton_clicked() {
 
33
    tmpQmlFile.open();
 
34
    tmpQmlFile.write(ui->plainTextEdit_2->toPlainText().toAscii());
 
35
    tmpQmlFile.close();
 
36
    m_declarativeView->engine()->clearComponentCache();
 
37
    m_declarativeView->setSource(QUrl::fromLocalFile(tmpQmlFile.fileName()));
 
38
}
 
39
 
 
40
TestCaseExecutionDialog::~TestCaseExecutionDialog()
 
41
{
 
42
    delete ui;
 
43
}