summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/testcases.txt14
-rw-r--r--src/quicktestlib/qdeclarativetest.cpp4
-rw-r--r--src/quicktestlib/qdeclarativetest.h26
-rw-r--r--tests/README2
-rw-r--r--tests/buttonclick/buttonclick.pro6
-rw-r--r--tests/buttonclick/buttonclick.qrc6
-rw-r--r--tests/qdeclarativebinding/qdeclarativebinding.pro6
-rw-r--r--tests/qdeclarativebinding/qdeclarativebinding.qrc6
-rw-r--r--tests/qdeclarativebinding/tst_qdeclarativebinding.cpp44
-rw-r--r--tests/qdeclarativeborderimage/qdeclarativeborderimage.pro6
-rw-r--r--tests/qdeclarativeborderimage/qdeclarativeborderimage.qrc9
-rw-r--r--tests/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp44
-rw-r--r--tests/qmlauto/buttonclick/Button.qml (renamed from tests/buttonclick/data/Button.qml)0
-rw-r--r--tests/qmlauto/buttonclick/tst_buttonclick.qml (renamed from tests/buttonclick/data/tst_buttonclick.qml)0
-rw-r--r--tests/qmlauto/qdecarativebinding/tst_binding.qml (renamed from tests/qdeclarativebinding/data/tst_binding.qml)0
-rw-r--r--tests/qmlauto/qdecarativebinding/tst_binding2.qml (renamed from tests/qdeclarativebinding/data/tst_binding2.qml)0
-rw-r--r--tests/qmlauto/qdecarativeborderimage/InvalidSciFile.qml (renamed from tests/qdeclarativeborderimage/data/InvalidSciFile.qml)0
-rw-r--r--tests/qmlauto/qdecarativeborderimage/colors-round.sci (renamed from tests/qdeclarativeborderimage/data/colors-round.sci)0
-rw-r--r--tests/qmlauto/qdecarativeborderimage/colors.png (renamed from tests/qdeclarativeborderimage/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/qmlauto/qdecarativeborderimage/invalid.sci (renamed from tests/qdeclarativeborderimage/data/invalid.sci)0
-rw-r--r--tests/qmlauto/qdecarativeborderimage/tst_borderimage.qml (renamed from tests/qdeclarativeborderimage/data/tst_borderimage.qml)14
-rw-r--r--tests/qmlauto/qmlauto.pro6
-rw-r--r--tests/qmlauto/tst_qmlauto.cpp (renamed from tests/buttonclick/tst_buttonclick.cpp)2
-rw-r--r--tests/tests.pro5
24 files changed, 53 insertions, 147 deletions
diff --git a/doc/testcases.txt b/doc/testcases.txt
index 8b52ae1..73e3a02 100644
--- a/doc/testcases.txt
+++ b/doc/testcases.txt
@@ -22,13 +22,23 @@ is an example .qrc file:
</qresource>
</RCC>
+The QTEST_QUICK_SOURCE_DIR macro can be defined at compile time to
+run tests from plain files without binding them into resources.
+Modify your .pro file to include the following line:
+
+ DEFINES += QTEST_QUICK_SOURCE_DIR=\"\\\"$$PWD\\\"\"
+
The QTEST_QUICK_SOURCE_DIR environment variable can also be set
-at runtime to run test cases from a non-resource directory.
+at runtime to run test cases from a different directory. This may
+be needed to run tests on a target device where the compiled-in
+directory name refers to a host.
Other *.qml files may appear for auxillary QML components that are
used by the test.
-See "tests/qmlexample" for an example of creating a test harness.
+See "tests/qmlexample" for an example of creating a test harness
+that uses resources and "tests/qmlauto" for an example that uses
+the QTEST_QUICK_SOURCE_DIR macro.
Basic test cases
================
diff --git a/src/quicktestlib/qdeclarativetest.cpp b/src/quicktestlib/qdeclarativetest.cpp
index 3eecb38..1e4c52f 100644
--- a/src/quicktestlib/qdeclarativetest.cpp
+++ b/src/quicktestlib/qdeclarativetest.cpp
@@ -71,13 +71,15 @@ private Q_SLOTS:
void quit() { hasQuit = true; }
};
-int qtest_quick_main(int argc, char **argv, const char *name, qtest_create_viewport createViewport)
+int qtest_quick_main(int argc, char **argv, const char *name, qtest_create_viewport createViewport, const char *sourceDir)
{
QApplication app(argc, argv);
// Determine where to look for the test data. If QTEST_QUICK_SOURCE_DIR
// is set, then use that. Otherwise scan the application's resources.
QString testPath = QString::fromLocal8Bit(qgetenv("QTEST_QUICK_SOURCE_DIR"));
+ if (testPath.isEmpty() && sourceDir)
+ testPath = QString::fromLocal8Bit(sourceDir);
if (testPath.isEmpty())
testPath = QLatin1String(":/");
diff --git a/src/quicktestlib/qdeclarativetest.h b/src/quicktestlib/qdeclarativetest.h
index ef9bb81..b76eb72 100644
--- a/src/quicktestlib/qdeclarativetest.h
+++ b/src/quicktestlib/qdeclarativetest.h
@@ -52,12 +52,14 @@ QT_BEGIN_NAMESPACE
typedef QWidget *(*qtest_create_viewport)();
-Q_TEST_QUICK_EXPORT int qtest_quick_main(int argc, char **argv, const char *name, qtest_create_viewport createViewport);
+Q_TEST_QUICK_EXPORT int qtest_quick_main(int argc, char **argv, const char *name, qtest_create_viewport createViewport, const char *sourceDir);
+
+#ifdef QTEST_QUICK_SOURCE_DIR
#define QTEST_QUICK_MAIN(name) \
int main(int argc, char **argv) \
{ \
- return qtest_quick_main(argc, argv, #name, 0); \
+ return qtest_quick_main(argc, argv, #name, 0, QTEST_QUICK_SOURCE_DIR); \
}
#define QTEST_QUICK_OPENGL_MAIN(name) \
@@ -67,11 +69,29 @@ Q_TEST_QUICK_EXPORT int qtest_quick_main(int argc, char **argv, const char *name
} \
int main(int argc, char **argv) \
{ \
- return qtest_quick_main(argc, argv, #name, name##_create_viewport); \
+ return qtest_quick_main(argc, argv, #name, name##_create_viewport, QTEST_QUICK_SOURCE_DIR); \
}
#else
+#define QTEST_QUICK_MAIN(name) \
+ int main(int argc, char **argv) \
+ { \
+ return qtest_quick_main(argc, argv, #name, 0, 0); \
+ }
+
+#define QTEST_QUICK_OPENGL_MAIN(name) \
+ static QWidget *name##_create_viewport() \
+ { \
+ return new QGLWidget(); \
+ } \
+ int main(int argc, char **argv) \
+ { \
+ return qtest_quick_main(argc, argv, #name, name##_create_viewport, 0); \
+ }
+
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/tests/README b/tests/README
deleted file mode 100644
index 4f56a04..0000000
--- a/tests/README
+++ /dev/null
@@ -1,2 +0,0 @@
-This directory contains some QtDeclarative tests that have been ported
-from the "tested with C++" style in Qt 4.7 to the qtest-qml style.
diff --git a/tests/buttonclick/buttonclick.pro b/tests/buttonclick/buttonclick.pro
deleted file mode 100644
index 9e41a01..0000000
--- a/tests/buttonclick/buttonclick.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-TEMPLATE=app
-TARGET=tst_buttonclick
-CONFIG += warn_on testcase
-SOURCES += tst_buttonclick.cpp
-RESOURCES += buttonclick.qrc
-include(../../src/quicktestlib/quicktestlib_dep.pri)
diff --git a/tests/buttonclick/buttonclick.qrc b/tests/buttonclick/buttonclick.qrc
deleted file mode 100644
index 8557e70..0000000
--- a/tests/buttonclick/buttonclick.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>data/tst_buttonclick.qml</file>
- <file>data/Button.qml</file>
-</qresource>
-</RCC>
diff --git a/tests/qdeclarativebinding/qdeclarativebinding.pro b/tests/qdeclarativebinding/qdeclarativebinding.pro
deleted file mode 100644
index 708794c..0000000
--- a/tests/qdeclarativebinding/qdeclarativebinding.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-TEMPLATE=app
-TARGET=tst_qdeclarativebinding
-CONFIG += warn_on testcase
-SOURCES += tst_qdeclarativebinding.cpp
-RESOURCES += qdeclarativebinding.qrc
-include(../../src/quicktestlib/quicktestlib_dep.pri)
diff --git a/tests/qdeclarativebinding/qdeclarativebinding.qrc b/tests/qdeclarativebinding/qdeclarativebinding.qrc
deleted file mode 100644
index dfda961..0000000
--- a/tests/qdeclarativebinding/qdeclarativebinding.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>data/tst_binding.qml</file>
- <file>data/tst_binding2.qml</file>
-</qresource>
-</RCC>
diff --git a/tests/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/qdeclarativebinding/tst_qdeclarativebinding.cpp
deleted file mode 100644
index adab1f4..0000000
--- a/tests/qdeclarativebinding/tst_qdeclarativebinding.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetest.h"
-
-QTEST_QUICK_MAIN(qdeclarativebinding)
diff --git a/tests/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/qdeclarativeborderimage/qdeclarativeborderimage.pro
deleted file mode 100644
index 503e565..0000000
--- a/tests/qdeclarativeborderimage/qdeclarativeborderimage.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-TEMPLATE=app
-TARGET=tst_qdeclarativeborderimage
-CONFIG += warn_on testcase
-SOURCES += tst_qdeclarativeborderimage.cpp
-RESOURCES += qdeclarativeborderimage.qrc
-include(../../src/quicktestlib/quicktestlib_dep.pri)
diff --git a/tests/qdeclarativeborderimage/qdeclarativeborderimage.qrc b/tests/qdeclarativeborderimage/qdeclarativeborderimage.qrc
deleted file mode 100644
index d3c103d..0000000
--- a/tests/qdeclarativeborderimage/qdeclarativeborderimage.qrc
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>data/tst_borderimage.qml</file>
- <file>data/InvalidSciFile.qml</file>
- <file>data/colors.png</file>
- <file>data/colors-round.sci</file>
- <file>data/invalid.sci</file>
-</qresource>
-</RCC>
diff --git a/tests/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
deleted file mode 100644
index 70f4663..0000000
--- a/tests/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativetest.h"
-
-QTEST_QUICK_MAIN(qdeclarativeborderimage)
diff --git a/tests/buttonclick/data/Button.qml b/tests/qmlauto/buttonclick/Button.qml
index a2716e0..a2716e0 100644
--- a/tests/buttonclick/data/Button.qml
+++ b/tests/qmlauto/buttonclick/Button.qml
diff --git a/tests/buttonclick/data/tst_buttonclick.qml b/tests/qmlauto/buttonclick/tst_buttonclick.qml
index 89e223b..89e223b 100644
--- a/tests/buttonclick/data/tst_buttonclick.qml
+++ b/tests/qmlauto/buttonclick/tst_buttonclick.qml
diff --git a/tests/qdeclarativebinding/data/tst_binding.qml b/tests/qmlauto/qdecarativebinding/tst_binding.qml
index 3b1cf8a..3b1cf8a 100644
--- a/tests/qdeclarativebinding/data/tst_binding.qml
+++ b/tests/qmlauto/qdecarativebinding/tst_binding.qml
diff --git a/tests/qdeclarativebinding/data/tst_binding2.qml b/tests/qmlauto/qdecarativebinding/tst_binding2.qml
index 414800f..414800f 100644
--- a/tests/qdeclarativebinding/data/tst_binding2.qml
+++ b/tests/qmlauto/qdecarativebinding/tst_binding2.qml
diff --git a/tests/qdeclarativeborderimage/data/InvalidSciFile.qml b/tests/qmlauto/qdecarativeborderimage/InvalidSciFile.qml
index 8a56582..8a56582 100644
--- a/tests/qdeclarativeborderimage/data/InvalidSciFile.qml
+++ b/tests/qmlauto/qdecarativeborderimage/InvalidSciFile.qml
diff --git a/tests/qdeclarativeborderimage/data/colors-round.sci b/tests/qmlauto/qdecarativeborderimage/colors-round.sci
index 5d2f49f..5d2f49f 100644
--- a/tests/qdeclarativeborderimage/data/colors-round.sci
+++ b/tests/qmlauto/qdecarativeborderimage/colors-round.sci
diff --git a/tests/qdeclarativeborderimage/data/colors.png b/tests/qmlauto/qdecarativeborderimage/colors.png
index dfb62f3..dfb62f3 100644
--- a/tests/qdeclarativeborderimage/data/colors.png
+++ b/tests/qmlauto/qdecarativeborderimage/colors.png
Binary files differ
diff --git a/tests/qdeclarativeborderimage/data/invalid.sci b/tests/qmlauto/qdecarativeborderimage/invalid.sci
index 98c72c9..98c72c9 100644
--- a/tests/qdeclarativeborderimage/data/invalid.sci
+++ b/tests/qmlauto/qdecarativeborderimage/invalid.sci
diff --git a/tests/qdeclarativeborderimage/data/tst_borderimage.qml b/tests/qmlauto/qdecarativeborderimage/tst_borderimage.qml
index 1048c05..341f902 100644
--- a/tests/qdeclarativeborderimage/data/tst_borderimage.qml
+++ b/tests/qmlauto/qdecarativeborderimage/tst_borderimage.qml
@@ -113,7 +113,7 @@ Item {
tag: "local not found",
source: "no-such-file.png",
remote: false,
- error: "qrc:data/inline:1:21: QML BorderImage: Cannot open: qrc:data/no-such-file.png"
+ error: "SUBinline:1:21: QML BorderImage: Cannot open: SUBno-such-file.png"
}
// TODO: remote tests that need to use http
]
@@ -121,8 +121,10 @@ Item {
function test_imageSource(row) {
var expectError = (row.error.length != 0)
- if (expectError)
- ignoreWarning(row.error)
+ if (expectError) {
+ var parentUrl = Qt.resolvedUrl(".")
+ ignoreWarning(row.error.replace(/SUB/g, parentUrl))
+ }
var img = Qt.createQmlObject
('import QtQuick 1.0; BorderImage { source: "' +
@@ -145,7 +147,7 @@ Item {
}
function test_clearSource() {
- compare(clearSource.source, "qrc:data/colors.png")
+ compare(clearSource.source, Qt.resolvedUrl("colors.png"))
compare(clearSource.width, 120)
compare(clearSource.height, 120)
@@ -187,14 +189,12 @@ Item {
{
tag: "local",
source: "colors-round.sci",
- sourceUrl: "qrc:data/colors-round.sci",
remote: false,
valid: true
},
{
tag: "local not found",
source: "no-such-file.sci",
- sourceUrl: "qrc:data/no-such-file.sci",
remote: false,
valid: false
}
@@ -210,7 +210,7 @@ Item {
if (row.remote)
tryCompare(img, "status", BorderImage.Loading)
- compare(img.source, row.sourceUrl)
+ compare(img.source, Qt.resolvedUrl(row.source))
compare(img.width, 300)
compare(img.height, 300)
diff --git a/tests/qmlauto/qmlauto.pro b/tests/qmlauto/qmlauto.pro
new file mode 100644
index 0000000..fa0c2dc
--- /dev/null
+++ b/tests/qmlauto/qmlauto.pro
@@ -0,0 +1,6 @@
+TEMPLATE=app
+TARGET=tst_qmlauto
+CONFIG += warn_on testcase
+SOURCES += tst_qmlauto.cpp
+DEFINES += QTEST_QUICK_SOURCE_DIR=\"\\\"$$PWD\\\"\"
+include(../../src/quicktestlib/quicktestlib_dep.pri)
diff --git a/tests/buttonclick/tst_buttonclick.cpp b/tests/qmlauto/tst_qmlauto.cpp
index d728d63..d5d85b6 100644
--- a/tests/buttonclick/tst_buttonclick.cpp
+++ b/tests/qmlauto/tst_qmlauto.cpp
@@ -41,4 +41,4 @@
#include "qdeclarativetest.h"
-QTEST_QUICK_MAIN(buttonclick)
+QTEST_QUICK_MAIN(qmlauto)
diff --git a/tests/tests.pro b/tests/tests.pro
index f13f49f..d13fd72 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -1,8 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS += \
- qdeclarativebinding \
- qdeclarativeborderimage \
- buttonclick
+SUBDIRS += qmlauto
# This test fails, so don't run it by default
#SUBDIRS += qmlexample