aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-10-18 15:02:36 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-20 09:05:03 +0200
commit7ccd053e63a8d1f2ce361c2b910dce9ac43bb923 (patch)
tree45df9ac8ed9b060f2bfc5967cddeaaa530959d92 /src
parente0521a579e967d670a5f6d7d4a4cd90a6aa56e17 (diff)
Fix qmltest library.
- Avoid hangs (waiting for frameSwapped) and crashes in window managers for empty windows by giving windows a minimum size if they have 0x0 (observed on Mac, Windows). - Polishing, set proper window flags, title, object name, output. Change-Id: Iad5d66c3adbbfe085390132987e95f4c69272831 Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qmltest/quicktest.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 769deb08f9..0a99654d39 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -118,7 +118,7 @@ void handleCompileErrors(const QFileInfo &fi, QQuickView *view)
foreach (const QQmlError &e, errors) {
str << " ";
if (e.url().isLocalFile()) {
- str << e.url().toLocalFile();
+ str << QDir::toNativeSeparators(e.url().toLocalFile());
} else {
str << e.url().toString();
}
@@ -269,6 +269,9 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
// Scan through all of the "tst_*.qml" files and run each of them
// in turn with a QQuickView.
QQuickView *view = new QQuickView;
+ view->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint
+ | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint
+ | Qt::WindowCloseButtonHint);
QTestRootObject rootobj;
QEventLoop eventLoop;
QObject::connect(view->engine(), SIGNAL(quit()),
@@ -279,12 +282,13 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
(QLatin1String("qtest"), &rootobj);
foreach (const QString &path, imports)
view->engine()->addImportPath(path);
-
- foreach (QString file, files) {
- QFileInfo fi(file);
+ foreach (const QString &file, files) {
+ const QFileInfo fi(file);
if (!fi.exists())
continue;
+ view->setObjectName(fi.baseName());
+ view->setWindowTitle(view->objectName());
rootobj.setHasTestCase(false);
rootobj.setWindowShown(false);
rootobj.hasQuit = false;
@@ -306,11 +310,19 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
// an asynchronous test and we need to show the window
// and wait for the first frame to be rendered
// and then wait for quit indication.
+ view->setFramePos(QPoint(50, 50));
+ if (view->size().isEmpty()) { // Avoid hangs with empty windows.
+ qWarning().nospace()
+ << "Test '" << QDir::toNativeSeparators(path) << "' has invalid size "
+ << view->size() << ", resizing.";
+ view->resize(200, 200);
+ }
view->show();
if (qWaitForSignal(view, SIGNAL(frameSwapped())))
rootobj.setWindowShown(true);
if (!rootobj.hasQuit && rootobj.hasTestCase())
eventLoop.exec();
+ view->hide();
}
}