diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-21 07:09:33 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-21 07:09:33 (GMT) |
commit | a14765de5b1bb26b4cbc6ebbdee71145e54650a8 (patch) | |
tree | 5ce3cd3acb9448a3d86eef96ac1f4129ce3b8936 /tools/qmlviewer/qmlviewer.cpp | |
parent | 26bd84ec3625c825c04228b76dd37cd5e75fb36b (diff) | |
download | Qt-a14765de5b1bb26b4cbc6ebbdee71145e54650a8.zip Qt-a14765de5b1bb26b4cbc6ebbdee71145e54650a8.tar.gz Qt-a14765de5b1bb26b4cbc6ebbdee71145e54650a8.tar.bz2 |
Basic implementation of visual "test scripts"
Test scripts allow the qmlviewer to record a set of input actions, and the resulting visual frames.
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 1c0f496..2894f1d 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -19,8 +19,8 @@ #include <QtDeclarative/qmlengine.h> #include "qml.h" #include <private/qperformancelog_p.h> -#include <QAbstractAnimation> #include <private/qabstractanimation_p.h> +#include <QAbstractAnimation> #include "deviceskin.h" #include <QSettings> @@ -51,6 +51,8 @@ #include <QGLWidget> #endif +#include <qfxtester.h> + QT_BEGIN_NAMESPACE class PreviewDeviceSkin : public DeviceSkin @@ -251,7 +253,8 @@ QString QmlViewer::getVideoFileName() QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) - : QWidget(parent, flags), frame_stream(0), scaleSkin(true), mb(0) + : QWidget(parent, flags), frame_stream(0), scaleSkin(true), mb(0), m_scriptOptions(0), + tester(0) { devicemode = false; skin = 0; @@ -291,6 +294,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) canvas->setFocus(); QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); + QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors())); QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); @@ -589,10 +593,18 @@ void QmlViewer::open() } } +void QmlViewer::executeErrors() +{ + if (tester) tester->executefailure(); +} + void QmlViewer::openQml(const QString& fileName) { setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(fileName)); + if (!m_script.isEmpty()) + tester = new QFxTester(m_script, m_scriptOptions, canvas); + canvas->reset(); currentFileName = fileName; @@ -617,6 +629,7 @@ void QmlViewer::openQml(const QString& fileName) foreach (const QmlError &error, errors) { qWarning() << error; } + if (tester) tester->executefailure(); } if (dummyData) { @@ -762,17 +775,19 @@ void QmlViewer::keyPressEvent(QKeyEvent *event) exit(0); else if (event->key() == Qt::Key_F1 || (event->key() == Qt::Key_1 && devicemode)) { qDebug() << "F1 - help\n" - << "F2 - toggle video recording\n" + << "F2 - save test script\n" << "F3 - take PNG snapshot\n" << "F4 - show items and state\n" << "F5 - reload QML\n" << "F6 - show object tree\n" << "F7 - show timing\n" << "F8 - show performance (if available)\n" + << "F9 - toggle video recording\n" << "device keys: 0=quit, 1..8=F1..F8" ; - } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) { - toggleRecording(); + } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_3 && devicemode)) { + if (tester && m_scriptOptions & Record) + tester->save(m_script); } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) { takeSnapShot(); } else if (event->key() == Qt::Key_F5 || (event->key() == Qt::Key_5 && devicemode)) { @@ -780,6 +795,8 @@ void QmlViewer::keyPressEvent(QKeyEvent *event) } else if (event->key() == Qt::Key_F8 || (event->key() == Qt::Key_8 && devicemode)) { QPerformanceLog::displayData(); QPerformanceLog::clear(); + } else if (event->key() == Qt::Key_F9 || (event->key() == Qt::Key_9 && devicemode)) { + toggleRecording(); } QWidget::keyPressEvent(event); @@ -1051,7 +1068,6 @@ void QmlViewer::setUseGL(bool useGL) } #endif } - QT_END_NAMESPACE #include "qmlviewer.moc" |