diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-09 12:15:59 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-17 12:44:43 +0100 |
commit | 3146dcbdc768c90a03b58eed3f42630604443093 (patch) | |
tree | 10e234460c5f57012b346cdbe6304002ad0a446d /tests | |
parent | a7ea2afffd61e2a89f7bb2c586b4b733c4996bb5 (diff) | |
parent | 722725cf24e45e86a2844810b90787a29df8a4a9 (diff) |
Merge branch 'stable' into dev
Conflicts:
sync.profile
tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
Change-Id: I3620d15b4163fec420d18f6be50cae1635b99a2f
Diffstat (limited to 'tests')
53 files changed, 806 insertions, 229 deletions
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 1c57b04f..1d7aa0f9 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -68,7 +68,8 @@ tst_examples::tst_examples() { // Add directories you want excluded here excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex" - << "doc/src/snippets/declarative/qtbinding"; + << "doc/src/snippets/declarative/qtbinding" + << "examples/declarative/tutorials"; //Excluded when tutorials were moved into examples (not checked before) // Known to violate naming conventions, QTQAINFRA-428 excludedDirs << "demos/mobile/qtbubblelevel/qml" << "demos/mobile/quickhit"; diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 72f1afcb..9231c17b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -127,7 +127,7 @@ void registerTypes() qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit"); qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType"); - qRegisterMetaType<MyQmlObject::MyType>("MyEnum2"); + qRegisterMetaType<MyQmlObject::MyEnum2>("MyEnum2"); qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons"); } diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/a.js b/tests/auto/declarative/qdeclarativeimportorder/data/a.js new file mode 100644 index 00000000..49c40f77 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/a.js @@ -0,0 +1 @@ +console.log("a.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/b.js b/tests/auto/declarative/qdeclarativeimportorder/data/b.js new file mode 100644 index 00000000..786ef862 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/b.js @@ -0,0 +1 @@ +console.log("b.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/c.js b/tests/auto/declarative/qdeclarativeimportorder/data/c.js new file mode 100644 index 00000000..3e1d32f0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/c.js @@ -0,0 +1 @@ +console.log("c.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/d.js b/tests/auto/declarative/qdeclarativeimportorder/data/d.js new file mode 100644 index 00000000..4c339077 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/d.js @@ -0,0 +1 @@ +console.log("d.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/e.js b/tests/auto/declarative/qdeclarativeimportorder/data/e.js new file mode 100644 index 00000000..ac758f93 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/e.js @@ -0,0 +1 @@ +console.log("e.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/f.js b/tests/auto/declarative/qdeclarativeimportorder/data/f.js new file mode 100644 index 00000000..04b0cf3a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/f.js @@ -0,0 +1 @@ +console.log("f.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/g.js b/tests/auto/declarative/qdeclarativeimportorder/data/g.js new file mode 100644 index 00000000..e6747104 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/g.js @@ -0,0 +1 @@ +console.log("g.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/h.js b/tests/auto/declarative/qdeclarativeimportorder/data/h.js new file mode 100644 index 00000000..8f81e240 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/h.js @@ -0,0 +1 @@ +console.log("h.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/i.js b/tests/auto/declarative/qdeclarativeimportorder/data/i.js new file mode 100644 index 00000000..a074b78c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/i.js @@ -0,0 +1 @@ +console.log("i.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/importOrderJs.qml b/tests/auto/declarative/qdeclarativeimportorder/data/importOrderJs.qml new file mode 100644 index 00000000..6cad175e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/importOrderJs.qml @@ -0,0 +1,30 @@ +import QtQuick 1.1 +import "a.js" as A +import "b.js" as B +import "c.js" as C +import "d.js" as D +import "e.js" as E +import "f.js" as F +import "g.js" as G +import "h.js" as H +import "i.js" as I +import "j.js" as J +import "k.js" as K +import "l.js" as L +import "m.js" as M +import "n.js" as N +import "o.js" as O +import "p.js" as P +import "q.js" as Q +import "r.js" as R +import "s.js" as S +import "t.js" as T +import "u.js" as U +import "v.js" as V +import "w.js" as W +import "x.js" as X +import "y.js" as Y +import "z.js" as Z + +Item { +} diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/j.js b/tests/auto/declarative/qdeclarativeimportorder/data/j.js new file mode 100644 index 00000000..1b336d06 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/j.js @@ -0,0 +1 @@ +console.log("j.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/k.js b/tests/auto/declarative/qdeclarativeimportorder/data/k.js new file mode 100644 index 00000000..b205c1c4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/k.js @@ -0,0 +1 @@ +console.log("k.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/l.js b/tests/auto/declarative/qdeclarativeimportorder/data/l.js new file mode 100644 index 00000000..36331a88 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/l.js @@ -0,0 +1 @@ +console.log("l.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/m.js b/tests/auto/declarative/qdeclarativeimportorder/data/m.js new file mode 100644 index 00000000..f8ec9a06 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/m.js @@ -0,0 +1 @@ +console.log("m.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/n.js b/tests/auto/declarative/qdeclarativeimportorder/data/n.js new file mode 100644 index 00000000..59ea354c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/n.js @@ -0,0 +1 @@ +console.log("n.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/o.js b/tests/auto/declarative/qdeclarativeimportorder/data/o.js new file mode 100644 index 00000000..1bdad649 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/o.js @@ -0,0 +1 @@ +console.log("o.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/p.js b/tests/auto/declarative/qdeclarativeimportorder/data/p.js new file mode 100644 index 00000000..ba37e9cc --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/p.js @@ -0,0 +1 @@ +console.log("p.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/q.js b/tests/auto/declarative/qdeclarativeimportorder/data/q.js new file mode 100644 index 00000000..6f226207 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/q.js @@ -0,0 +1 @@ +console.log("q.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/r.js b/tests/auto/declarative/qdeclarativeimportorder/data/r.js new file mode 100644 index 00000000..9f9b25a0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/r.js @@ -0,0 +1 @@ +console.log("r.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/s.js b/tests/auto/declarative/qdeclarativeimportorder/data/s.js new file mode 100644 index 00000000..f81ca099 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/s.js @@ -0,0 +1 @@ +console.log("s.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/t.js b/tests/auto/declarative/qdeclarativeimportorder/data/t.js new file mode 100644 index 00000000..3f150a77 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/t.js @@ -0,0 +1 @@ +console.log("t.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/u.js b/tests/auto/declarative/qdeclarativeimportorder/data/u.js new file mode 100644 index 00000000..426bdd09 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/u.js @@ -0,0 +1 @@ +console.log("u.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/v.js b/tests/auto/declarative/qdeclarativeimportorder/data/v.js new file mode 100644 index 00000000..66d23f52 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/v.js @@ -0,0 +1 @@ +console.log("v.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/w.js b/tests/auto/declarative/qdeclarativeimportorder/data/w.js new file mode 100644 index 00000000..ecefb1d0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/w.js @@ -0,0 +1 @@ +console.log("w.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/x.js b/tests/auto/declarative/qdeclarativeimportorder/data/x.js new file mode 100644 index 00000000..64112bb4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/x.js @@ -0,0 +1 @@ +console.log("x.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/y.js b/tests/auto/declarative/qdeclarativeimportorder/data/y.js new file mode 100644 index 00000000..9ed70f26 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/y.js @@ -0,0 +1 @@ +console.log("y.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/data/z.js b/tests/auto/declarative/qdeclarativeimportorder/data/z.js new file mode 100644 index 00000000..0e6fc83e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/data/z.js @@ -0,0 +1 @@ +console.log("z.js") diff --git a/tests/auto/declarative/qdeclarativeimportorder/qdeclarativeimportorder.pro b/tests/auto/declarative/qdeclarativeimportorder/qdeclarativeimportorder.pro new file mode 100644 index 00000000..725b6d6a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/qdeclarativeimportorder.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qdeclarativeimportorder + +QT += testlib +contains(QT_CONFIG,declarative): QT += declarative widgets +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeimportorder.cpp + +include(../shared/qdeclarativedatatest.pri) + +CONFIG += parallel_test + +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/declarative/qdeclarativeimportorder/tst_qdeclarativeimportorder.cpp b/tests/auto/declarative/qdeclarativeimportorder/tst_qdeclarativeimportorder.cpp new file mode 100644 index 00000000..ecf35100 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimportorder/tst_qdeclarativeimportorder.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Jolla Mobile <robin.burchell@jollamobile.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <qdeclarativedatatest.h> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> +#include <QDeclarativeContext> + +#include <QDebug> + + +class tst_qdeclarativeimportorder : public QDeclarativeDataTest +{ + Q_OBJECT +public: + tst_qdeclarativeimportorder() + { + } + +private slots: + void qmlObject(); + +private: + QDeclarativeEngine engine; +}; + +Q_GLOBAL_STATIC(QStringList, importMessages); + +static void orderedImportMsgHandler(QtMsgType type, const QMessageLogContext &, const QString &message) +{ + if (type == QtDebugMsg) + importMessages()->append(message); + else + fprintf(stderr, "possibly unexpected message of type %d: %s", type, qPrintable(message)); +} + +void tst_qdeclarativeimportorder::qmlObject() +{ + QDeclarativeComponent component(&engine, testFileUrl("importOrderJs.qml")); + + QtMessageHandler old = qInstallMessageHandler(orderedImportMsgHandler); + QObject *object = component.create(); + qInstallMessageHandler(old); // do this before the QVERIFY so output goes out ok if it errors + QVERIFY(object != 0); + QCOMPARE(*importMessages(), QStringList() << "a.js" << "b.js" << "c.js" + << "d.js" << "e.js" << "f.js" + << "g.js" << "h.js" << "i.js" + << "j.js" << "k.js" << "l.js" + << "m.js" << "n.js" << "o.js" + << "p.js" << "q.js" << "r.js" + << "s.js" << "t.js" << "u.js" + << "v.js" << "w.js" << "x.js" + << "y.js" << "z.js"); + // now I know my ABCs, + // next time won't you sing with me? +} + +QTEST_MAIN(tst_qdeclarativeimportorder) + +#include "tst_qdeclarativeimportorder.moc" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt index 89e58ee7..59b0b874 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt @@ -1 +1 @@ -1:35:Library import requires a version +1:39:Library import requires a version diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml index 97ec2228..6ad2a812 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml @@ -1,3 +1,3 @@ -import com.nokia.installedtest as T +import org.qtproject.installedtest as T T.InstalledTest {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/InstalledTest.qml index 9985d332..9985d332 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/InstalledTest.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/InstalledTest2.qml index f63283e7..f63283e7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/InstalledTest2.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/LocalLast.qml index 7f491eb8..7f491eb8 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/LocalLast.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/PrivateType.qml index 03bf25bc..03bf25bc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/PrivateType.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/qmldir index d15720a1..d15720a1 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest/qmldir diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest0/InstalledTest.qml index 9985d332..9985d332 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest0/InstalledTest.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest0/InstalledTest2.qml index f63283e7..f63283e7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest0/InstalledTest2.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest0/qmldir index b3012260..b3012260 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/org/qtproject/installedtest0/qmldir diff --git a/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml index bdb13756..d3b31a3d 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml @@ -1,5 +1,5 @@ import QtQuick 1.0 -import com.nokia.installedtest 1.0 +import org.qtproject.installedtest 1.0 LocalLast2 { property Item item: LocalLast {} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 5dbcf456..f1467ef6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -1446,101 +1446,101 @@ void tst_qdeclarativelanguage::importsBuiltin_data() << "" << "Test is not a type"; QTest::newRow("not in version 0.0") - << "import com.nokia.Test 0.0\n" + << "import org.qtproject.Test 0.0\n" "Test {}" << "" << "Test is not a type"; QTest::newRow("version not installed") - << "import com.nokia.Test 99.0\n" + << "import org.qtproject.Test 99.0\n" "Test {}" << "" - << "module \"com.nokia.Test\" version 99.0 is not installed"; + << "module \"org.qtproject.Test\" version 99.0 is not installed"; QTest::newRow("in version 0.0") - << "import com.nokia.Test 0.0\n" + << "import org.qtproject.Test 0.0\n" "TestTP {}" << "TestType" << ""; QTest::newRow("qualified in version 0.0") - << "import com.nokia.Test 0.0 as T\n" + << "import org.qtproject.Test 0.0 as T\n" "T.TestTP {}" << "TestType" << ""; QTest::newRow("in version 1.0") - << "import com.nokia.Test 1.0\n" + << "import org.qtproject.Test 1.0\n" "Test {}" << "TestType" << ""; QTest::newRow("qualified wrong") - << "import com.nokia.Test 1.0 as T\n" // QT-610 + << "import org.qtproject.Test 1.0 as T\n" // QT-610 "Test {}" << "" << "Test is not a type"; QTest::newRow("qualified right") - << "import com.nokia.Test 1.0 as T\n" + << "import org.qtproject.Test 1.0 as T\n" "T.Test {}" << "TestType" << ""; QTest::newRow("qualified right but not in version 0.0") - << "import com.nokia.Test 0.0 as T\n" + << "import org.qtproject.Test 0.0 as T\n" "T.Test {}" << "" << "T.Test is not a type"; QTest::newRow("in version 1.1") - << "import com.nokia.Test 1.1\n" + << "import org.qtproject.Test 1.1\n" "Test {}" << "TestType" << ""; QTest::newRow("in version 1.3") - << "import com.nokia.Test 1.3\n" + << "import org.qtproject.Test 1.3\n" "Test {}" << "TestType" << ""; QTest::newRow("in version 1.5") - << "import com.nokia.Test 1.5\n" + << "import org.qtproject.Test 1.5\n" "Test {}" << "TestType" << ""; QTest::newRow("changed in version 1.8") - << "import com.nokia.Test 1.8\n" + << "import org.qtproject.Test 1.8\n" "Test {}" << "TestType2" << ""; QTest::newRow("in version 1.12") - << "import com.nokia.Test 1.12\n" + << "import org.qtproject.Test 1.12\n" "Test {}" << "TestType2" << ""; QTest::newRow("old in version 1.9") - << "import com.nokia.Test 1.9\n" + << "import org.qtproject.Test 1.9\n" "OldTest {}" << "TestType" << ""; QTest::newRow("old in version 1.11") - << "import com.nokia.Test 1.11\n" + << "import org.qtproject.Test 1.11\n" "OldTest {}" << "TestType" << ""; QTest::newRow("multiversion 1") - << "import com.nokia.Test 1.11\n" - "import com.nokia.Test 1.12\n" + << "import org.qtproject.Test 1.11\n" + "import org.qtproject.Test 1.12\n" "Test {}" << (!qmlCheckTypes()?"TestType2":"") - << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11"); + << (!qmlCheckTypes()?"":"Test is ambiguous. Found in org/qtproject/Test in version 1.12 and 1.11"); QTest::newRow("multiversion 2") - << "import com.nokia.Test 1.11\n" - "import com.nokia.Test 1.12\n" + << "import org.qtproject.Test 1.11\n" + "import org.qtproject.Test 1.12\n" "OldTest {}" << (!qmlCheckTypes()?"TestType":"") - << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11"); + << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in org/qtproject/Test in version 1.12 and 1.11"); QTest::newRow("qualified multiversion 3") - << "import com.nokia.Test 1.0 as T0\n" - "import com.nokia.Test 1.8 as T8\n" + << "import org.qtproject.Test 1.0 as T0\n" + "import org.qtproject.Test 1.8 as T8\n" "T0.Test {}" << "TestType" << ""; QTest::newRow("qualified multiversion 4") - << "import com.nokia.Test 1.0 as T0\n" - "import com.nokia.Test 1.8 as T8\n" + << "import org.qtproject.Test 1.0 as T0\n" + "import org.qtproject.Test 1.8 as T8\n" "T8.Test {}" << "TestType2" << ""; @@ -1597,10 +1597,10 @@ void tst_qdeclarativelanguage::importsLocal_data() << "Test is not a type"; QTest::newRow("library precedence over local import") << "import \"subdir\"\n" - "import com.nokia.Test 1.0\n" + "import org.qtproject.Test 1.0\n" "Test {}" << (!qmlCheckTypes()?"TestType":"") - << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir"); + << (!qmlCheckTypes()?"":"Test is ambiguous. Found in org/qtproject/Test and in subdir"); } void tst_qdeclarativelanguage::importsLocal() @@ -1690,47 +1690,47 @@ void tst_qdeclarativelanguage::importsInstalled_data() // import installed QTest::newRow("installed import 0") - << "import com.nokia.installedtest0 0.0\n" + << "import org.qtproject.installedtest0 0.0\n" "InstalledTestTP {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 0 as TP") - << "import com.nokia.installedtest0 0.0 as TP\n" + << "import org.qtproject.installedtest0 0.0 as TP\n" "TP.InstalledTestTP {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 1") - << "import com.nokia.installedtest 1.0\n" + << "import org.qtproject.installedtest 1.0\n" "InstalledTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 2") - << "import com.nokia.installedtest 1.3\n" + << "import org.qtproject.installedtest 1.3\n" "InstalledTest {}" << "QDeclarativeRectangle" << ""; QTest::newRow("installed import 3") - << "import com.nokia.installedtest 1.4\n" + << "import org.qtproject.installedtest 1.4\n" "InstalledTest {}" << "QDeclarativeText" << ""; QTest::newRow("installed import minor version not available") // QTBUG-11936 - << "import com.nokia.installedtest 0.1\n" + << "import org.qtproject.installedtest 0.1\n" "InstalledTest {}" << "" - << "module \"com.nokia.installedtest\" version 0.1 is not installed"; + << "module \"org.qtproject.installedtest\" version 0.1 is not installed"; QTest::newRow("installed import minor version not available") // QTBUG-9627 - << "import com.nokia.installedtest 1.10\n" + << "import org.qtproject.installedtest 1.10\n" "InstalledTest {}" << "" - << "module \"com.nokia.installedtest\" version 1.10 is not installed"; + << "module \"org.qtproject.installedtest\" version 1.10 is not installed"; QTest::newRow("installed import major version not available") // QTBUG-9627 - << "import com.nokia.installedtest 9.0\n" + << "import org.qtproject.installedtest 9.0\n" "InstalledTest {}" << "" - << "module \"com.nokia.installedtest\" version 9.0 is not installed"; + << "module \"org.qtproject.installedtest\" version 9.0 is not installed"; QTest::newRow("installed import visibility") // QT-614 - << "import com.nokia.installedtest 1.4\n" + << "import org.qtproject.installedtest 1.4\n" "PrivateType {}" << "" << "PrivateType is not a type"; @@ -1752,60 +1752,60 @@ void tst_qdeclarativelanguage::importsOrder_data() QTest::addColumn<QString>("error"); QTest::newRow("double import") << - "import com.nokia.installedtest 1.4\n" - "import com.nokia.installedtest 1.4\n" + "import org.qtproject.installedtest 1.4\n" + "import org.qtproject.installedtest 1.4\n" "InstalledTest {}" << (!qmlCheckTypes()?"QDeclarativeText":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/org/qtproject/installedtest in version 1.4 and 1.4"); QTest::newRow("installed import overrides 1") << - "import com.nokia.installedtest 1.0\n" - "import com.nokia.installedtest 1.4\n" + "import org.qtproject.installedtest 1.0\n" + "import org.qtproject.installedtest 1.4\n" "InstalledTest {}" << (!qmlCheckTypes()?"QDeclarativeText":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/org/qtproject/installedtest in version 1.4 and 1.0"); QTest::newRow("installed import overrides 2") << - "import com.nokia.installedtest 1.4\n" - "import com.nokia.installedtest 1.0\n" + "import org.qtproject.installedtest 1.4\n" + "import org.qtproject.installedtest 1.0\n" "InstalledTest {}" << (!qmlCheckTypes()?"QDeclarativeRectangle":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/org/qtproject/installedtest in version 1.0 and 1.4"); QTest::newRow("installed import re-overrides 1") << - "import com.nokia.installedtest 1.4\n" - "import com.nokia.installedtest 1.0\n" - "import com.nokia.installedtest 1.4\n" + "import org.qtproject.installedtest 1.4\n" + "import org.qtproject.installedtest 1.0\n" + "import org.qtproject.installedtest 1.4\n" "InstalledTest {}" << (!qmlCheckTypes()?"QDeclarativeText":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/org/qtproject/installedtest in version 1.4 and 1.0"); QTest::newRow("installed import re-overrides 2") << - "import com.nokia.installedtest 1.4\n" - "import com.nokia.installedtest 1.0\n" - "import com.nokia.installedtest 1.4\n" - "import com.nokia.installedtest 1.0\n" + "import org.qtproject.installedtest 1.4\n" + "import org.qtproject.installedtest 1.0\n" + "import org.qtproject.installedtest 1.4\n" + "import org.qtproject.installedtest 1.0\n" "InstalledTest {}" << (!qmlCheckTypes()?"QDeclarativeRectangle":"") - << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/org/qtproject/installedtest in version 1.0 and 1.4"); QTest::newRow("installed import versus builtin 1") << - "import com.nokia.installedtest 1.5\n" + "import org.qtproject.installedtest 1.5\n" "import QtQuick 1.0\n" "Rectangle {}" << (!qmlCheckTypes()?"QDeclarativeRectangle":"") - << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest"); + << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/org/qtproject/installedtest"); QTest::newRow("installed import versus builtin 2") << "import QtQuick 1.0\n" - "import com.nokia.installedtest 1.5\n" + "import org.qtproject.installedtest 1.5\n" "Rectangle {}" << (!qmlCheckTypes()?"QDeclarativeText":"") - << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt"); + << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/org/qtproject/installedtest and in Qt"); QTest::newRow("namespaces cannot be overridden by types 1") << "import QtQuick 1.0 as Rectangle\n" - "import com.nokia.installedtest 1.5\n" + "import org.qtproject.installedtest 1.5\n" "Rectangle {}" << "" << "Namespace Rectangle cannot be used as a type"; QTest::newRow("namespaces cannot be overridden by types 2") << "import QtQuick 1.0 as Rectangle\n" - "import com.nokia.installedtest 1.5\n" + "import org.qtproject.installedtest 1.5\n" "Rectangle.Image {}" << "QDeclarativeImage" << ""; @@ -1814,15 +1814,15 @@ void tst_qdeclarativelanguage::importsOrder_data() << "QDeclarativeText" << ""; QTest::newRow("local last 2") << - "import com.nokia.installedtest 1.0\n" + "import org.qtproject.installedtest 1.0\n" "LocalLast {}" - << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml - << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory"); + << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml + << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory"); QTest::newRow("local last 3") << - "import com.nokia.installedtest 1.0\n" + "import org.qtproject.installedtest 1.0\n" "LocalLast {LocalLast2{}}" - << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml - << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory"); + << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml + << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory"); } void tst_qdeclarativelanguage::importsOrder() @@ -1980,17 +1980,17 @@ void tst_qdeclarativelanguage::initTestCase() qmlRegisterType(testFileUrl("MyComponentType.qml"), "Test", 1, 0, "MyComponentType"); // Registering the TestType class in other modules should have no adverse effects - qmlRegisterType<TestType>("com.nokia.TestPre", 1, 0, "Test"); + qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test"); - qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP"); - qmlRegisterType<TestType>("com.nokia.Test", 1, 0, "Test"); - qmlRegisterType<TestType>("com.nokia.Test", 1, 5, "Test"); - qmlRegisterType<TestType2>("com.nokia.Test", 1, 8, "Test"); - qmlRegisterType<TestType>("com.nokia.Test", 1, 9, "OldTest"); - qmlRegisterType<TestType2>("com.nokia.Test", 1, 12, "Test"); + qmlRegisterType<TestType>("org.qtproject.Test", 0, 0, "TestTP"); + qmlRegisterType<TestType>("org.qtproject.Test", 1, 0, "Test"); + qmlRegisterType<TestType>("org.qtproject.Test", 1, 5, "Test"); + qmlRegisterType<TestType2>("org.qtproject.Test", 1, 8, "Test"); + qmlRegisterType<TestType>("org.qtproject.Test", 1, 9, "OldTest"); + qmlRegisterType<TestType2>("org.qtproject.Test", 1, 12, "Test"); // Registering the TestType class in other modules should have no adverse effects - qmlRegisterType<TestType>("com.nokia.TestPost", 1, 0, "Test"); + qmlRegisterType<TestType>("org.qtproject.TestPost", 1, 0, "Test"); // Create locale-specific file // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit diff --git a/tests/auto/declarative/qdeclarativepathview/data/initialCurrentIndex.qml b/tests/auto/declarative/qdeclarativepathview/data/initialCurrentIndex.qml new file mode 100644 index 00000000..e6361522 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/initialCurrentIndex.qml @@ -0,0 +1,60 @@ +import QtQuick 1.1 + +PathView { + id: photoPathView + y: 100; width: 800; height: 330; pathItemCount: 4 + currentIndex: 3 + dragMargin: 24 + preferredHighlightBegin: 0.50 + preferredHighlightEnd: 0.50 + + path: Path { + startX: -50; startY: 40; + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: -45 } + + PathCubic { + x: 400; y: 220 + control1X: 140; control1Y: 40 + control2X: 210; control2Y: 220 + } + + PathAttribute { name: "scale"; value: 1.2 } + PathAttribute { name: "angle"; value: 0 } + + PathCubic { + x: 850; y: 40 + control2X: 660; control2Y: 40 + control1X: 590; control1Y: 220 + } + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: 45 } + } + + model: ListModel { + id: rssModel + ListElement { lColor: "red" } + ListElement { lColor: "green" } + ListElement { lColor: "yellow" } + ListElement { lColor: "blue" } + ListElement { lColor: "purple" } + ListElement { lColor: "gray" } + ListElement { lColor: "brown" } + ListElement { lColor: "thistle" } + } + + delegate: Component { + id: photoDelegate + Rectangle { + id: wrapper + width: 85; height: 85; color: lColor + + transform: Rotation { + id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 + axis.y: 1; axis.z: 0 + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 247c19e3..0d7dbe6f 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -56,6 +56,33 @@ #include <QStandardItemModel> #include <QFile> +template<typename T> +static void qdeclarativepathview_move(int from, int to, int n, T *items) +{ + if (from > to) { + // Only move forwards - flip if backwards moving + int tfrom = from; + int tto = to; + from = tto; + to = tto+n; + n = tfrom-tto; + } + + T replaced; + int i=0; + typename T::ConstIterator it=items->begin(); it += from+n; + for (; i<to-from; ++i,++it) + replaced.append(*it); + i=0; + it=items->begin(); it += from; + for (; i<n; ++i,++it) + replaced.append(*it); + typename T::ConstIterator f=replaced.begin(); + typename T::Iterator t=items->begin(); t += from; + for (; f != replaced.end(); ++f, ++t) + *t = *f; +} + static void initStandardTreeModel(QStandardItemModel *model) { QStandardItem *item; @@ -87,6 +114,13 @@ private slots: void dataModel(); void pathview2(); void pathview3(); + void initialCurrentIndex(); + void insertModel_data(); + void insertModel(); + void removeModel_data(); + void removeModel(); + void moveModel_data(); + void moveModel(); void path(); void pathMoved(); void setCurrentIndex(); @@ -183,18 +217,41 @@ public: endInsertRows(); } + void insertItems(int index, const QList<QPair<QString, QString> > &items) + { + emit beginInsertRows(QModelIndex(), index, index+items.count()-1); + for (int i=0; i<items.count(); i++) + list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second)); + emit endInsertRows(); + } + void removeItem(int index) { beginRemoveRows(QModelIndex(), index, index); list.removeAt(index); endRemoveRows(); } + void removeItems(int index, int count) + { + emit beginRemoveRows(QModelIndex(), index, index+count-1); + while (count--) + list.removeAt(index); + emit endRemoveRows(); + } + void moveItem(int from, int to) { beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); list.move(from, to); endMoveRows(); } + void moveItems(int from, int to, int count) + { + emit beginMoveRows(QModelIndex(), from, from+count-1, QModelIndex(), to > from ? to+count : to); + qdeclarativepathview_move(from, to, count, &list); + emit endMoveRows(); + } + void modifyItem(int idx, const QString &name, const QString &number) { list[idx] = QPair<QString,QString>(name, number); emit dataChanged(index(idx,0), index(idx,0)); @@ -308,6 +365,116 @@ void tst_QDeclarativePathView::pathview3() QCOMPARE(obj->pathItemCount(), 4); } +void tst_QDeclarativePathView::initialCurrentIndex() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/initialCurrentIndex.qml")); + QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->path() != 0); + QVERIFY(obj->delegate() != 0); + QVERIFY(obj->model() != QVariant()); + QCOMPARE(obj->currentIndex(), 3); + QCOMPARE(obj->offset(), 5.0); + QCOMPARE(obj->preferredHighlightBegin(), 0.5); + QCOMPARE(obj->dragMargin(), 24.); + QCOMPARE(obj->count(), 8); + QCOMPARE(obj->pathItemCount(), 4); + + delete obj; +} + +void tst_QDeclarativePathView::insertModel_data() +{ + QTest::addColumn<int>("mode"); + QTest::addColumn<int>("idx"); + QTest::addColumn<int>("count"); + QTest::addColumn<qreal>("offset"); + QTest::addColumn<int>("currentIndex"); + + // We have 8 items, with currentIndex == 4 + QTest::newRow("insert after current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 6 << 1 << 5. << 4; + QTest::newRow("insert before current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 2 << 1 << 4. << 5; + QTest::newRow("insert multiple after current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 5 << 2 << 6. << 4; + QTest::newRow("insert multiple before current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 1 << 2 << 4. << 6; + QTest::newRow("insert at end") + << int(QDeclarativePathView::StrictlyEnforceRange) << 8 << 1 << 5. << 4; + QTest::newRow("insert at beginning") + << int(QDeclarativePathView::StrictlyEnforceRange) << 0 << 1 << 4. << 5; + QTest::newRow("insert at current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 4 << 1 << 4. << 5; + + QTest::newRow("no range - insert after current") + << int(QDeclarativePathView::NoHighlightRange) << 6 << 1 << 5. << 4; + QTest::newRow("no range - insert before current") + << int(QDeclarativePathView::NoHighlightRange) << 2 << 1 << 4. << 5; + QTest::newRow("no range - insert multiple after current") + << int(QDeclarativePathView::NoHighlightRange) << 5 << 2 << 6. << 4; + QTest::newRow("no range - insert multiple before current") + << int(QDeclarativePathView::NoHighlightRange) << 1 << 2 << 4. << 6; + QTest::newRow("no range - insert at end") + << int(QDeclarativePathView::NoHighlightRange) << 8 << 1 << 5. << 4; + QTest::newRow("no range - insert at beginning") + << int(QDeclarativePathView::NoHighlightRange) << 0 << 1 << 4. << 5; + QTest::newRow("no range - insert at current") + << int(QDeclarativePathView::NoHighlightRange) << 4 << 1 << 4. << 5; +} + +void tst_QDeclarativePathView::insertModel() +{ + QFETCH(int, mode); + QFETCH(int, idx); + QFETCH(int, count); + QFETCH(qreal, offset); + QFETCH(int, currentIndex); + + QDeclarativeView *window = createView(); + window->show(); + + TestModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + model.addItem("Jinny", "679"); + model.addItem("Milly", "73378"); + model.addItem("Jimmy", "3535"); + model.addItem("Barb", "9039"); + + QDeclarativeContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + + window->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); + qApp->processEvents(); + + QDeclarativePathView *pathview = findItem<QDeclarativePathView>(window->rootObject(), "view"); + QVERIFY(pathview != 0); + + pathview->setHighlightRangeMode((QDeclarativePathView::HighlightRangeMode)mode); + + pathview->setCurrentIndex(4); + if (mode == QDeclarativePathView::StrictlyEnforceRange) + QTRY_COMPARE(pathview->offset(), 4.0); + else + pathview->setOffset(4); + + QList<QPair<QString, QString> > items; + for (int i = 0; i < count; ++i) + items.append(qMakePair(QString("New"), QString::number(i))); + + model.insertItems(idx, items); + QTRY_COMPARE(pathview->offset(), offset); + + QCOMPARE(pathview->currentIndex(), currentIndex); + + delete window; +} + void tst_QDeclarativePathView::path() { QDeclarativeEngine engine; @@ -353,6 +520,192 @@ void tst_QDeclarativePathView::path() QCOMPARE(cubic->control2Y(), 90.); } +void tst_QDeclarativePathView::removeModel_data() +{ + QTest::addColumn<int>("mode"); + QTest::addColumn<int>("idx"); + QTest::addColumn<int>("count"); + QTest::addColumn<qreal>("offset"); + QTest::addColumn<int>("currentIndex"); + + // We have 8 items, with currentIndex == 4 + QTest::newRow("remove after current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 6 << 1 << 3. << 4; + QTest::newRow("remove before current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 2 << 1 << 4. << 3; + QTest::newRow("remove multiple after current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 5 << 2 << 2. << 4; + QTest::newRow("remove multiple before current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 1 << 2 << 4. << 2; + QTest::newRow("remove last") + << int(QDeclarativePathView::StrictlyEnforceRange) << 7 << 1 << 3. << 4; + QTest::newRow("remove first") + << int(QDeclarativePathView::StrictlyEnforceRange) << 0 << 1 << 4. << 3; + QTest::newRow("remove current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 4 << 1 << 3. << 4; + QTest::newRow("remove all") + << int(QDeclarativePathView::StrictlyEnforceRange) << 0 << 8 << 0. << 0; + + QTest::newRow("no range - remove after current") + << int(QDeclarativePathView::NoHighlightRange) << 6 << 1 << 3. << 4; + QTest::newRow("no range - remove before current") + << int(QDeclarativePathView::NoHighlightRange) << 2 << 1 << 4. << 3; + QTest::newRow("no range - remove multiple after current") + << int(QDeclarativePathView::NoHighlightRange) << 5 << 2 << 2. << 4; + QTest::newRow("no range - remove multiple before current") + << int(QDeclarativePathView::NoHighlightRange) << 1 << 2 << 4. << 2; + QTest::newRow("no range - remove last") + << int(QDeclarativePathView::NoHighlightRange) << 7 << 1 << 3. << 4; + QTest::newRow("no range - remove first") + << int(QDeclarativePathView::NoHighlightRange) << 0 << 1 << 4. << 3; + QTest::newRow("no range - remove current offset") + << int(QDeclarativePathView::NoHighlightRange) << 4 << 1 << 4. << 4; + QTest::newRow("no range - remove all") + << int(QDeclarativePathView::NoHighlightRange) << 0 << 8 << 0. << 0; +} + +void tst_QDeclarativePathView::removeModel() +{ + QFETCH(int, mode); + QFETCH(int, idx); + QFETCH(int, count); + QFETCH(qreal, offset); + QFETCH(int, currentIndex); + + QDeclarativeView *window = createView(); + window->show(); + + TestModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + model.addItem("Jinny", "679"); + model.addItem("Milly", "73378"); + model.addItem("Jimmy", "3535"); + model.addItem("Barb", "9039"); + + QDeclarativeContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + + window->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); + qApp->processEvents(); + + QDeclarativePathView *pathview = findItem<QDeclarativePathView>(window->rootObject(), "view"); + QVERIFY(pathview != 0); + + pathview->setHighlightRangeMode((QDeclarativePathView::HighlightRangeMode)mode); + + pathview->setCurrentIndex(4); + if (mode == QDeclarativePathView::StrictlyEnforceRange) + QTRY_COMPARE(pathview->offset(), 4.0); + else + pathview->setOffset(4); + + model.removeItems(idx, count); + QTRY_COMPARE(pathview->offset(), offset); + + QCOMPARE(pathview->currentIndex(), currentIndex); + + delete window; +} +void tst_QDeclarativePathView::moveModel_data() +{ + QTest::addColumn<int>("mode"); + QTest::addColumn<int>("from"); + QTest::addColumn<int>("to"); + QTest::addColumn<int>("count"); + QTest::addColumn<qreal>("offset"); + QTest::addColumn<int>("currentIndex"); + + // We have 8 items, with currentIndex == 4 + QTest::newRow("move after current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4. << 4; + QTest::newRow("move before current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4. << 4; + QTest::newRow("move before current to after") + << int(QDeclarativePathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5. << 3; + QTest::newRow("move multiple after current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4. << 4; + QTest::newRow("move multiple before current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4. << 4; + QTest::newRow("move before current to end") + << int(QDeclarativePathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5. << 3; + QTest::newRow("move last to beginning") + << int(QDeclarativePathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3. << 5; + QTest::newRow("move current") + << int(QDeclarativePathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2. << 6; + + QTest::newRow("no range - move after current") + << int(QDeclarativePathView::NoHighlightRange) << 5 << 6 << 1 << 4. << 4; + QTest::newRow("no range - move before current") + << int(QDeclarativePathView::NoHighlightRange) << 2 << 3 << 1 << 4. << 4; + QTest::newRow("no range - move before current to after") + << int(QDeclarativePathView::NoHighlightRange) << 2 << 6 << 1 << 5. << 3; + QTest::newRow("no range - move multiple after current") + << int(QDeclarativePathView::NoHighlightRange) << 5 << 6 << 2 << 4. << 4; + QTest::newRow("no range - move multiple before current") + << int(QDeclarativePathView::NoHighlightRange) << 0 << 1 << 2 << 4. << 4; + QTest::newRow("no range - move before current to end") + << int(QDeclarativePathView::NoHighlightRange) << 2 << 7 << 1 << 5. << 3; + QTest::newRow("no range - move last to beginning") + << int(QDeclarativePathView::NoHighlightRange) << 7 << 0 << 1 << 3. << 5; + QTest::newRow("no range - move current") + << int(QDeclarativePathView::NoHighlightRange) << 4 << 6 << 1 << 4. << 6; + QTest::newRow("no range - move multiple incl. current") + << int(QDeclarativePathView::NoHighlightRange) << 0 << 1 << 5 << 4. << 5; +} + +void tst_QDeclarativePathView::moveModel() +{ + QFETCH(int, mode); + QFETCH(int, from); + QFETCH(int, to); + QFETCH(int, count); + QFETCH(qreal, offset); + QFETCH(int, currentIndex); + + QDeclarativeView *window = createView(); + window->show(); + + TestModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + model.addItem("Jinny", "679"); + model.addItem("Milly", "73378"); + model.addItem("Jimmy", "3535"); + model.addItem("Barb", "9039"); + + QDeclarativeContext *ctxt = window->rootContext(); + ctxt->setContextProperty("testModel", &model); + + window->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); + qApp->processEvents(); + + QDeclarativePathView *pathview = findItem<QDeclarativePathView>(window->rootObject(), "view"); + QVERIFY(pathview != 0); + + pathview->setHighlightRangeMode((QDeclarativePathView::HighlightRangeMode)mode); + + pathview->setCurrentIndex(4); + if (mode == QDeclarativePathView::StrictlyEnforceRange) + QTRY_COMPARE(pathview->offset(), 4.0); + else + pathview->setOffset(4); + + model.moveItems(from, to, count); + + // don't enable this test as 371b2f6947779272494b34ec44445aaad0613756 has + // not been backported to QtQuick1 so offset is still buggy +// QTRY_COMPARE(pathview->offset(), offset); + + QCOMPARE(pathview->currentIndex(), currentIndex); + + delete window; +} + void tst_QDeclarativePathView::dataModel() { QDeclarativeView *canvas = createView(); @@ -586,6 +939,20 @@ void tst_QDeclarativePathView::setCurrentIndex() QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); + // Test positive indexes are wrapped. + pathview->setCurrentIndex(6); + QTRY_COMPARE(pathview->currentIndex(), 2); + firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 2); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + + // Test negative indexes are wrapped. + pathview->setCurrentIndex(-3); + QTRY_COMPARE(pathview->currentIndex(), 1); + firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 1); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro index bd0ba7c4..64481a08 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro @@ -16,3 +16,5 @@ DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +CONFIG += insignificant_test # QTBUG-21015 diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro index 566ca6c6..d4a5e771 100644 --- a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro +++ b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro @@ -5,8 +5,9 @@ QT += testlib contains(QT_CONFIG,declarative): QT += declarative declarative-private gui gui-private widgets widgets-private network core-private macx:CONFIG -= app_bundle +include(../shared/qdeclarativedatatest.pri) + SOURCES += tst_qdeclarativetextedit.cpp ../shared/testhttpserver.cpp HEADERS += ../shared/testhttpserver.h -DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 9c899445..2d71ca4b 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -41,6 +41,7 @@ #include <qtest.h> #include <QtTest/QSignalSpy> #include "../shared/testhttpserver.h" +#include <qdeclarativedatatest.h> #include <math.h> #include <QFile> #include <QTextDocument> @@ -63,20 +64,20 @@ Q_DECLARE_METATYPE(QDeclarativeTextEdit::SelectionMode) -QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) +// Make a widget frameless to prevent size constraints of title bars +// from interfering (Windows). +static inline void setFrameless(QWidget *w) { - // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = SRCDIR "/data"; - QString arch = "unknown-architecture"; // QTest needs to help with this. - - QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; - - if (!QFile::exists(expectfile)) { - actual.save(expectfile); - qWarning() << "created" << expectfile; - } + Qt::WindowFlags flags = w->windowFlags(); + flags |= Qt::FramelessWindowHint; + flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + w->setWindowFlags(flags); +} - return expectfile; +// Helper message for comparisons +static inline QByteArray msgComparison(int v1, int v2) +{ + return QByteArray::number(v1) + ' ' + QByteArray::number(v2); } void sendPreeditText(const QString &text, int cursor) @@ -90,7 +91,7 @@ void sendPreeditText(const QString &text, int cursor) } -class tst_qdeclarativetextedit : public QObject +class tst_qdeclarativetextedit : public QDeclarativeDataTest { Q_OBJECT @@ -168,6 +169,7 @@ private slots: private: void simulateKey(QDeclarativeView *, int key, Qt::KeyboardModifiers modifiers = 0); QDeclarativeView *createView(const QString &filename); + QString alignmentReferenceImage(const QString& filebasename) const; QStringList standard; QStringList richText; @@ -395,6 +397,12 @@ void tst_qdeclarativetextedit::alignments_data() QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc"; } +QString tst_qdeclarativetextedit::alignmentReferenceImage(const QString& filebasename) const +{ + // XXX This will be replaced by some clever persistent platform image store. + static const QString arch = QGuiApplication::platformName() + QLatin1Char('-') + qApp->style()->objectName(); + return testFile(filebasename + QLatin1Char('-') + arch + QStringLiteral(".png")); +} void tst_qdeclarativetextedit::alignments() { @@ -402,7 +410,14 @@ void tst_qdeclarativetextedit::alignments() QFETCH(int, vAlign); QFETCH(QString, expectfile); - QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml"); + const QString referenceImage = alignmentReferenceImage(expectfile); + if (!QFile(referenceImage).exists()) + QSKIP(qPrintable(QStringLiteral("Reference image '") + + QDir::toNativeSeparators(referenceImage) + + QStringLiteral("' does not exist."))); + + QDeclarativeView *canvas = createView(testFile("alignments.qml")); + setFrameless(canvas); canvas->show(); QApplication::setActiveWindow(canvas); @@ -419,9 +434,8 @@ void tst_qdeclarativetextedit::alignments() QPainter p(&actual); canvas->render(&p); - expectfile = createExpectedFileIfNotFound(expectfile, actual); - - QImage expect(expectfile); + QImage expect(referenceImage); + QVERIFY(!expect.isNull()); QCOMPARE(actual,expect); @@ -466,7 +480,7 @@ void tst_qdeclarativetextedit::hAlign() void tst_qdeclarativetextedit::hAlign_RightToLeft() { - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml"); + QDeclarativeView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml")); QDeclarativeTextEdit *textEdit = canvas->rootObject()->findChild<QDeclarativeTextEdit*>("text"); QVERIFY(textEdit != 0); canvas->show(); @@ -957,7 +971,7 @@ void tst_qdeclarativetextedit::isRightToLeft() void tst_qdeclarativetextedit::keySelection() { - QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml"); + QDeclarativeView *canvas = createView(testFile("navigation.qml")); canvas->show(); QApplication::setActiveWindow(canvas); QVERIFY(QTest::qWaitForWindowActive(canvas)); @@ -1349,19 +1363,19 @@ void tst_qdeclarativetextedit::mouseSelection_data() QTest::addColumn<QString>("selectedText"); // import installed - QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << 4 << 9 << "45678"; - QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << 4 << 9 << QString(); - QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << 4 << 9 << QString(); - QTest::newRow("off word selection") << SRCDIR "/data/mouseselection_false_words.qml" << 4 << 9 << QString(); - QTest::newRow("on word selection (4,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 4 << 9 << "0123456789"; - QTest::newRow("on word selection (2,13)") << SRCDIR "/data/mouseselection_true_words.qml" << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (2,30)") << SRCDIR "/data/mouseselection_true_words.qml" << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,13)") << SRCDIR "/data/mouseselection_true_words.qml" << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,30)") << SRCDIR "/data/mouseselection_true_words.qml" << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (13,2)") << SRCDIR "/data/mouseselection_true_words.qml" << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (20,2)") << SRCDIR "/data/mouseselection_true_words.qml" << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (12,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (30,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678"; + QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString(); + QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString(); + QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString(); + QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789"; + QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } void tst_qdeclarativetextedit::mouseSelection() @@ -1403,8 +1417,7 @@ void tst_qdeclarativetextedit::mouseSelection() void tst_qdeclarativetextedit::multilineMouseSelection() { - QDeclarativeView *canvas = createView(SRCDIR "/data/mouseselection_multiline.qml"); - + QDeclarativeView *canvas = createView(testFile("mouseselection_multiline.qml")); canvas->show(); QApplication::setActiveWindow(canvas); QVERIFY(QTest::qWaitForWindowActive(canvas)); @@ -1440,8 +1453,8 @@ void tst_qdeclarativetextedit::deferEnableSelectByMouse_data() { QTest::addColumn<QString>("qmlfile"); - QTest::newRow("writable") << SRCDIR "/data/mouseselection_false.qml"; - QTest::newRow("read only") << SRCDIR "/data/mouseselection_false_readonly.qml"; + QTest::newRow("writable") << testFile("mouseselection_false.qml"); + QTest::newRow("read only") << testFile("mouseselection_false_readonly.qml"); } void tst_qdeclarativetextedit::deferEnableSelectByMouse() @@ -1480,8 +1493,8 @@ void tst_qdeclarativetextedit::deferDisableSelectByMouse_data() { QTest::addColumn<QString>("qmlfile"); - QTest::newRow("writable") << SRCDIR "/data/mouseselection_true.qml"; - QTest::newRow("read only") << SRCDIR "/data/mouseselection_true_readonly.qml"; + QTest::newRow("writable") << testFile("mouseselection_true.qml"); + QTest::newRow("read only") << testFile("mouseselection_true_readonly.qml"); } void tst_qdeclarativetextedit::deferDisableSelectByMouse() @@ -1518,7 +1531,7 @@ void tst_qdeclarativetextedit::deferDisableSelectByMouse() void tst_qdeclarativetextedit::dragMouseSelection() { - QString qmlfile = SRCDIR "/data/mouseselection_true.qml"; + QString qmlfile = testFile("mouseselection_true.qml"); QDeclarativeView *canvas = createView(qmlfile); @@ -1569,9 +1582,9 @@ void tst_qdeclarativetextedit::mouseSelectionMode_data() QTest::addColumn<bool>("selectWords"); // import installed - QTest::newRow("SelectWords") << SRCDIR "/data/mouseselectionmode_words.qml" << true; - QTest::newRow("SelectCharacters") << SRCDIR "/data/mouseselectionmode_characters.qml" << false; - QTest::newRow("default") << SRCDIR "/data/mouseselectionmode_default.qml" << false; + QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true; + QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false; + QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false; } void tst_qdeclarativetextedit::mouseSelectionMode() @@ -1620,7 +1633,8 @@ void tst_qdeclarativetextedit::mouseSelectionMode() void tst_qdeclarativetextedit::inputMethodHints() { - QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); + QDeclarativeView *canvas = createView(testFile("inputmethodhints.qml")); + setFrameless(canvas); canvas->show(); canvas->setFocus(); @@ -1636,8 +1650,9 @@ void tst_qdeclarativetextedit::inputMethodHints() void tst_qdeclarativetextedit::positionAt() { - QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); + QDeclarativeView *canvas = createView(testFile("positionAt.qml")); QVERIFY(canvas->rootObject() != 0); + setFrameless(canvas); canvas->show(); canvas->setFocus(); QApplication::setActiveWindow(canvas); @@ -1676,8 +1691,9 @@ void tst_qdeclarativetextedit::positionAt() int widthBegin = floor(line.cursorToX(pos - 1)); int widthEnd = ceil(line.cursorToX(pos + 1)); - QVERIFY(widthBegin <= texteditObject->width() / 2); - QVERIFY(widthEnd >= texteditObject->width() / 2); + const int halfObjectWidth = texteditObject->width() / 2; + QVERIFY2(widthBegin <= halfObjectWidth, msgComparison(widthBegin, halfObjectWidth).constData()); + QVERIFY2(widthEnd >= halfObjectWidth, msgComparison(widthEnd, halfObjectWidth).constData()); const qreal x0 = texteditObject->positionToRectangle(pos).x(); const qreal x1 = texteditObject->positionToRectangle(pos + 1).x(); @@ -1705,7 +1721,7 @@ void tst_qdeclarativetextedit::positionAt() void tst_qdeclarativetextedit::cursorDelegate() { - QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); + QDeclarativeView* view = createView(testFile("cursorTest.qml")); view->show(); view->setFocus(); QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild<QDeclarativeTextEdit*>("textEditObject"); @@ -1877,9 +1893,9 @@ void tst_qdeclarativetextedit::delegateLoading() QFETCH(QString, error); TestHTTPServer server(42332); - server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect); - server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay); - server.serveDirectory(SRCDIR "/data/http"); + server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect); + server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay); + server.serveDirectory(testFile("http")); QDeclarativeView* view = new QDeclarativeView(0); @@ -1922,7 +1938,7 @@ the extent of the text, then they should ignore the keys. */ void tst_qdeclarativetextedit::navigation() { - QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml"); + QDeclarativeView *canvas = createView(testFile("navigation.qml")); canvas->show(); canvas->setFocus(); @@ -2054,7 +2070,7 @@ void tst_qdeclarativetextedit::canPasteEmpty() { void tst_qdeclarativetextedit::readOnly() { - QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml"); + QDeclarativeView *canvas = createView(testFile("readOnly.qml")); canvas->show(); canvas->setFocus(); @@ -2297,7 +2313,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() void tst_qdeclarativetextedit::geometrySignals() { - QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml"); + QDeclarativeComponent component(&engine, testFile("geometrySignals.qml")); QObject *o = component.create(); QVERIFY(o); QCOMPARE(o->property("bindingWidth").toInt(), 400); @@ -2385,8 +2401,10 @@ void tst_qdeclarativetextedit::implicitSizePreedit() QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>()); QCoreApplication::sendEvent(&view, &event); - QVERIFY(textObject->width() < textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); + QVERIFY2(textObject->width() < textObject->implicitWidth(), + msgComparison(textObject->width(), textObject->implicitWidth()).constData()); + QVERIFY2(textObject->height() == textObject->implicitHeight(), + msgComparison(textObject->height(), textObject->implicitHeight()).constData()); qreal wrappedHeight = textObject->height(); textObject->resetWidth(); @@ -2484,7 +2502,8 @@ void tst_qdeclarativetextedit::preeditMicroFocus() ic.clear(); sendPreeditText(preeditText, i); currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect(); - QVERIFY(previousRect.left() < currentRect.left()); + QVERIFY2(previousRect.left() < currentRect.left(), + msgComparison(previousRect.left(), currentRect.left()).constData()); #if defined(Q_WS_X11) QVERIFY(ic.updateCallCount > 0); #endif @@ -2592,7 +2611,8 @@ void tst_qdeclarativetextedit::inputMethodComposing() void tst_qdeclarativetextedit::cursorRectangleSize() { - QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml"); + QDeclarativeView *canvas = createView(testFile("CursorRect.qml")); + setFrameless(canvas); QVERIFY(canvas->rootObject() != 0); canvas->show(); canvas->setFocus(); @@ -2601,7 +2621,7 @@ void tst_qdeclarativetextedit::cursorRectangleSize() QDeclarativeTextEdit *textEdit = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject()); QVERIFY(textEdit != 0); - textEdit->setFocus(Qt::OtherFocusReason); + textEdit->setFocus(true); QRectF cursorRect = textEdit->positionToRectangle(textEdit->cursorPosition()); QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); @@ -2612,7 +2632,8 @@ void tst_qdeclarativetextedit::cursorRectangleSize() void tst_qdeclarativetextedit::deselect() { - QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml"); + QDeclarativeView *canvas = createView(testFile("CursorRect.qml")); + setFrameless(canvas); QVERIFY(canvas->rootObject() != 0); canvas->show(); canvas->setFocus(); diff --git a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro index 4f15073a..35260dca 100644 --- a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro +++ b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qdeclarativetimer QT += testlib -contains(QT_CONFIG,declarative): QT += declarative declarative-private gui +contains(QT_CONFIG,declarative): QT += declarative declarative-private gui core-private macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetimer.cpp diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp index decd2c34..58c27f3f 100644 --- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp +++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp @@ -45,6 +45,18 @@ #include <private/qdeclarativetimer_p.h> #include <QtDeclarative/qdeclarativeitem.h> #include <QDebug> +#include <QtCore/QPauseAnimation> +#include <private/qabstractanimation_p.h> + +void consistentWait(int ms) +{ + //Use animations for timing, because we enabled consistentTiming + //This function will qWait for >= ms worth of consistent timing to elapse + QPauseAnimation waitTimer(ms); + waitTimer.start(); + while (waitTimer.state() == QAbstractAnimation::Running) + QTest::qWait(20); +} class tst_qdeclarativetimer : public QObject { @@ -53,6 +65,7 @@ public: tst_qdeclarativetimer(); private slots: + void initTestCase(); void notRepeating(); void notRepeatingStart(); void repeat(); @@ -80,12 +93,15 @@ public slots: } }; -#define TIMEOUT_TIMEOUT 200 - tst_qdeclarativetimer::tst_qdeclarativetimer() { } +void tst_qdeclarativetimer::initTestCase() +{ + QUnifiedTimer::instance()->setConsistentTiming(true); +} + void tst_qdeclarativetimer::notRepeating() { QDeclarativeEngine engine; @@ -100,9 +116,10 @@ void tst_qdeclarativetimer::notRepeating() TimerHelper helper; connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(TIMEOUT_TIMEOUT); + + consistentWait(200); QCOMPARE(helper.count, 1); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QCOMPARE(helper.count, 1); QVERIFY(timer->isRunning() == false); } @@ -119,13 +136,13 @@ void tst_qdeclarativetimer::notRepeatingStart() TimerHelper helper; connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QCOMPARE(helper.count, 0); timer->start(); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QCOMPARE(helper.count, 1); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QCOMPARE(helper.count, 1); QVERIFY(timer->isRunning() == false); @@ -144,18 +161,18 @@ void tst_qdeclarativetimer::repeat() connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); QCOMPARE(helper.count, 0); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QVERIFY(helper.count > 0); int oldCount = helper.count; - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QVERIFY(helper.count > oldCount); QVERIFY(timer->isRunning()); oldCount = helper.count; timer->stop(); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QVERIFY(helper.count == oldCount); QVERIFY(timer->isRunning() == false); @@ -185,12 +202,11 @@ void tst_qdeclarativetimer::triggeredOnStart() TimerHelper helper; connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(1); + consistentWait(1); QCOMPARE(helper.count, 1); - - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QCOMPARE(helper.count, 2); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QCOMPARE(helper.count, 2); QVERIFY(timer->isRunning() == false); @@ -219,13 +235,13 @@ void tst_qdeclarativetimer::triggeredOnStartRepeat() TimerHelper helper; connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(1); + consistentWait(1); QCOMPARE(helper.count, 1); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QVERIFY(helper.count > 1); int oldCount = helper.count; - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QVERIFY(helper.count > oldCount); QVERIFY(timer->isRunning()); @@ -245,7 +261,7 @@ void tst_qdeclarativetimer::noTriggerIfNotRunning() ), QUrl::fromLocalFile("")); QObject *item = component.create(); QVERIFY(item != 0); - QTest::qWait(TIMEOUT_TIMEOUT); + consistentWait(200); QCOMPARE(item->property("ok").toBool(), true); delete item; @@ -263,12 +279,12 @@ void tst_qdeclarativetimer::changeDuration() connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); QCOMPARE(helper.count, 0); - QTest::qWait(500); + consistentWait(500); QCOMPARE(helper.count, 2); timer->setInterval(500); - QTest::qWait(600); + consistentWait(600); QCOMPARE(helper.count, 3); QVERIFY(timer->isRunning()); @@ -299,14 +315,14 @@ void tst_qdeclarativetimer::restart() connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); QCOMPARE(helper.count, 0); - QTest::qWait(600); + consistentWait(600); QCOMPARE(helper.count, 1); - QTest::qWait(300); + consistentWait(300); timer->restart(); - QTest::qWait(700); + consistentWait(700); QCOMPARE(helper.count, 2); QVERIFY(timer->isRunning()); diff --git a/tests/auto/declarative/symbianlibs.pri b/tests/auto/declarative/symbianlibs.pri deleted file mode 100644 index 4452f67f..00000000 --- a/tests/auto/declarative/symbianlibs.pri +++ /dev/null @@ -1,9 +0,0 @@ -#additional libs required for orientation sensor -symbian { - !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { - LIBS += -lsensrvclient -lsensrvutil - } - contains(QT_CONFIG, s60): { - LIBS += -lavkon -lcone - } -} diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro index 201fc143..d9bf7d84 100644 --- a/tests/auto/headersclean/headersclean.pro +++ b/tests/auto/headersclean/headersclean.pro @@ -1,6 +1,2 @@ -QT = core testlib gui declarative -HEADERSCLEAN_PRI = $${QT.core.sources}/../../tests/auto/other/headersclean/headersclean.pri -isEmpty(QT.core.sources)|!include($$HEADERSCLEAN_PRI) { - warning("headersclean.pri from QtCore sources not available. test disabled") - TEMPLATE=subdirs -} +QT = declarative +load(qt_headersclean) diff --git a/tests/auto/headersclean/qt_headersclean_headers.h b/tests/auto/headersclean/qt_headersclean_headers.h deleted file mode 100644 index 2133ce46..00000000 --- a/tests/auto/headersclean/qt_headersclean_headers.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT_HEADERSCLEAN_HEADERS -#define QT_HEADERSCLEAN_HEADERS - -#include <QtDeclarative> - -#endif |