aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-03-06 11:11:50 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-06 15:43:51 +0100
commit76516e9b152438cc8620dc65c2f49b95c46d1b57 (patch)
treecfe1811c7135f71aca03da3bab707509939a14a7 /tests
parent71b523811f3bb86d76caa35f6ef3006258e18351 (diff)
tst_qtgraphicaleffects: make the test work prior to installation
Tests should be working both before and after `make install'. Adjust this test so it can load QtGraphicalEffects either from the source tree or the install tree. This code already attempted to accomplish this: engine.addImportPath("../../src"); It didn't work, since the directory in the source tree is named "effects" and not "QtGraphicalEffects". It also would not work when the build tree and source tree are different. Change-Id: Ied964714d72e041caa937a4204668fe4f86da3f5 Reviewed-by: Marko Niemelä <marko.a.niemela@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/tst_qtgraphicaleffects.cpp69
1 files changed, 43 insertions, 26 deletions
diff --git a/tests/auto/tst_qtgraphicaleffects.cpp b/tests/auto/tst_qtgraphicaleffects.cpp
index cd41a38..48455ec 100644
--- a/tests/auto/tst_qtgraphicaleffects.cpp
+++ b/tests/auto/tst_qtgraphicaleffects.cpp
@@ -78,6 +78,7 @@ private slots:
private:
QString componentErrors(const QDeclarativeComponent*) const;
+ QString importSelf;
QDeclarativeEngine engine;
};
@@ -98,7 +99,23 @@ QString tst_qtgraphicaleffects::componentErrors(const QDeclarativeComponent* com
void tst_qtgraphicaleffects::initTestCase()
{
- engine.addImportPath("../../src");
+ QString import;
+
+ // Allow the test to work whether or not the module is yet installed.
+ if (QFile::exists(QLibraryInfo::location(QLibraryInfo::ImportsPath) + "/QtGraphicalEffects")) {
+ // Module is installed - import it the nice way
+ import = "QtGraphicalEffects";
+ }
+ else {
+ // Module is not installed - import it from the source tree, by URI
+ QString qmldir = QFINDTESTDATA("../../src/effects/qmldir");
+ QVERIFY2(QFile::exists(qmldir), qPrintable(qmldir));
+
+ QUrl url = QUrl::fromLocalFile(QFileInfo(qmldir).canonicalPath());
+ import = "\"" + url.toString() + "\"";
+ }
+
+ importSelf = QString("import %1 1.0\n").arg(import);
}
@@ -106,7 +123,7 @@ void tst_qtgraphicaleffects::brightnessContrast()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"BrightnessContrast {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -131,7 +148,7 @@ void tst_qtgraphicaleffects::colorize()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"Colorize {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -157,7 +174,7 @@ void tst_qtgraphicaleffects::fastBlur()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"FastBlur {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -182,7 +199,7 @@ void tst_qtgraphicaleffects::desaturate()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"Desaturate {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -206,7 +223,7 @@ void tst_qtgraphicaleffects::hueSaturation()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"HueSaturation {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -232,7 +249,7 @@ void tst_qtgraphicaleffects::opacityMask()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"OpacityMask {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -257,7 +274,7 @@ void tst_qtgraphicaleffects::radialGradient()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"RadialGradient {"
"width: 50; height: 50\n"
"}";
@@ -285,7 +302,7 @@ void tst_qtgraphicaleffects::linearGradient()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"LinearGradient {"
"width: 50; height: 50\n"
"}";
@@ -310,7 +327,7 @@ void tst_qtgraphicaleffects::rectangularGlow()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"RectangularGlow {"
"width: 50; height: 50\n"
"}";
@@ -335,7 +352,7 @@ void tst_qtgraphicaleffects::conicalGradient()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"ConicalGradient {"
"width: 50; height: 50\n"
"}";
@@ -361,7 +378,7 @@ void tst_qtgraphicaleffects::colorOverlay()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"ColorOverlay {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -384,7 +401,7 @@ void tst_qtgraphicaleffects::gaussianBlur()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"GaussianBlur {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -414,7 +431,7 @@ void tst_qtgraphicaleffects::dropShadow()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"DropShadow {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -446,7 +463,7 @@ void tst_qtgraphicaleffects::innerShadow()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"InnerShadow {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -476,7 +493,7 @@ void tst_qtgraphicaleffects::gammaAdjust()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"GammaAdjust {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -501,7 +518,7 @@ void tst_qtgraphicaleffects::thresholdMask()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"ThresholdMask {"
"width: 50; height: 50\n"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -528,7 +545,7 @@ void tst_qtgraphicaleffects::glow()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"Glow {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -556,7 +573,7 @@ void tst_qtgraphicaleffects::blend()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"Blend {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"foregroundSource: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -582,7 +599,7 @@ void tst_qtgraphicaleffects::displace()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"Displace {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"displacementSource: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
@@ -608,7 +625,7 @@ void tst_qtgraphicaleffects::recursiveBlur()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"RecursiveBlur {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -635,7 +652,7 @@ void tst_qtgraphicaleffects::directionalBlur()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"DirectionalBlur {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -662,7 +679,7 @@ void tst_qtgraphicaleffects::radialBlur()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"RadialBlur {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -690,7 +707,7 @@ void tst_qtgraphicaleffects::zoomBlur()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"ZoomBlur {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"width: 50; height: 50\n"
@@ -717,7 +734,7 @@ void tst_qtgraphicaleffects::levelAdjust()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"LevelAdjust {"
"width: 50; height: 50\n"
"}";
@@ -743,7 +760,7 @@ void tst_qtgraphicaleffects::maskedBlur()
{
// Creation
QString componentStr = "import QtQuick 2.0\n"
- "import QtGraphicalEffects 1.0\n"
+ + importSelf +
"MaskedBlur {"
"source: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"
"maskSource: ShaderEffectSource {sourceItem: Rectangle {width: 100; height: 100}}"