summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test.qml77
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test2.qml39
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test3.qml52
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test4.qml76
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test5.qml84
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro6
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp278
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp178
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp3
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp91
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp13
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp9
13 files changed, 807 insertions, 100 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index bebc54e..2d88058 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -23,6 +23,7 @@ SUBDIRS += \
qdeclarativeborderimage \ # Cover
qdeclarativeflickable \ # Cover
qdeclarativeflipable \ # Cover
+ qdeclarativefocusscope \ # Cover
qdeclarativegridview \ # Cover
qdeclarativeitem \ # Cover
qdeclarativelistview \ # Cover
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
new file mode 100644
index 0000000..647e5bf
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
@@ -0,0 +1,77 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Keys.onDigit9Pressed: console.log("Error - Root")
+
+ FocusScope {
+ id: myScope
+ focus: true
+
+ Keys.onDigit9Pressed: console.log("Error - FocusScope")
+
+ Rectangle {
+ objectName: "item0"
+ height: 120
+ width: 420
+
+ color: "transparent"
+ border.width: 5
+ //border.color: myScope.wantsFocus?"blue":"black"
+
+ Rectangle {
+ id: item1; objectName: "item1"
+ x: 10; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ Keys.onDigit9Pressed: console.debug("Top Left");
+ KeyNavigation.right: item2
+ focus: true
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+ Rectangle {
+ id: item2; objectName: "item2"
+ x: 310; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ KeyNavigation.left: item1
+ Keys.onDigit9Pressed: console.log("Top Right");
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+ }
+ KeyNavigation.down: item3
+ }
+
+ Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" }
+
+ Rectangle {
+ id: item3; objectName: "item3"
+ x: 10; y: 300
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+
+ Keys.onDigit9Pressed: console.log("Bottom Left");
+ KeyNavigation.up: myScope
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml
new file mode 100644
index 0000000..277fda4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Text { text: "All five rectangles should be red" }
+
+ FocusScope {
+ y: 100
+ focus: true; objectName: "item1"
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true; objectName: "item2"
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true; objectName: "item3"
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true; objectName: "item4"
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true; objectName: "item5"
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml
new file mode 100644
index 0000000..9344d07
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml
@@ -0,0 +1,52 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ ListModel {
+ id: model
+ ListElement { name: "1" }
+ ListElement { name: "2" }
+ ListElement { name: "3" }
+ ListElement { name: "4" }
+ ListElement { name: "5" }
+ ListElement { name: "6" }
+ ListElement { name: "6" }
+ ListElement { name: "8" }
+ ListElement { name: "9" }
+ }
+
+ Component {
+ id: verticalDelegate
+ FocusScope {
+ id: root
+ width: 50; height: 50;
+ Keys.onDigit9Pressed: console.log("Error - " + name)
+ Rectangle {
+ focus: true
+ Keys.onDigit9Pressed: console.log(name)
+ width: 50; height: 50;
+ color: root.ListView.isCurrentItem?"red":"green"
+ Text { text: name; anchors.centerIn: parent }
+ }
+ }
+ }
+
+ ListView {
+ width: 800; height: 50; orientation: "Horizontal"
+ focus: true
+ model: model
+ delegate: verticalDelegate
+ preferredHighlightBegin: 100
+ preferredHighlightEnd: 100
+ highlightRangeMode: "StrictlyEnforceRange"
+ }
+
+
+ Text {
+ y: 100; x: 50
+ text: "Currently selected element should be red\nPressing \"9\" should print the number of the currently selected item\nBe sure to scroll all the way to the right, pause, and then all the way to the left."
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml
new file mode 100644
index 0000000..d8bd390
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml
@@ -0,0 +1,76 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Keys.onDigit9Pressed: console.log("Error - Root")
+
+ FocusScope {
+ id: myScope
+
+ Keys.onDigit9Pressed: console.log("Error - FocusScope")
+
+ Rectangle {
+ objectName: "item0"
+ height: 120
+ width: 420
+
+ color: "transparent"
+ border.width: 5
+ //border.color: myScope.wantsFocus?"blue":"black"
+
+ Rectangle {
+ id: item1; objectName: "item1"
+ x: 10; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ Keys.onDigit9Pressed: console.log("Error - Top Left");
+ KeyNavigation.right: item2
+ focus: true
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+ Rectangle {
+ id: item2; objectName: "item2"
+ x: 310; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ KeyNavigation.left: item1
+ Keys.onDigit9Pressed: console.log("Error - Top Right");
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+ }
+ KeyNavigation.down: item3
+ }
+
+ Text { x:100; y:170; text: "There should be no blue borders, or red squares.\nPressing \"9\" should do nothing.\nArrow keys should have no effect." }
+
+ Rectangle {
+ id: item3; objectName: "item3"
+ x: 10; y: 300
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+
+ Keys.onDigit9Pressed: console.log("Error - Bottom Left");
+ KeyNavigation.up: myScope
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
new file mode 100644
index 0000000..0b75ec4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
@@ -0,0 +1,84 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Keys.onReturnPressed: console.log("Error - Root")
+
+ FocusScope {
+ id: myScope
+ focus: true
+
+ Keys.onReturnPressed: console.log("Error - FocusScope")
+
+ Rectangle {
+ objectName: "item0"
+ height: 120
+ width: 420
+
+ color: "transparent"
+ border.width: 5
+ //border.color: myScope.wantsFocus?"blue":"black"
+
+ Rectangle {
+ x: 10; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: item1.wantsFocus?"blue":"black"
+ }
+
+ TextEdit {
+ id: item1; objectName: "item1"
+ x: 20; y: 20
+ width: 90; height: 90
+ color: "white"
+ font.pixelSize: 20
+ Keys.onReturnPressed: console.log("Top Left");
+ KeyNavigation.right: item2
+ focus: true
+ wrap: true
+ text: "Box 1"
+ }
+
+ Rectangle {
+ id: item2; objectName: "item2"
+ x: 310; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ KeyNavigation.left: item1
+ Keys.onReturnPressed: console.log("Top Right");
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+ }
+ KeyNavigation.down: item3
+ }
+
+ Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box or flashing cursor indicates active focus\nUse arrow keys to navigate\nPress Ctrl-Return to print currently focused item" }
+
+ Rectangle {
+ x: 10; y: 300
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: item3.wantsFocus?"blue":"black"
+ }
+
+ TextEdit {
+ id: item3; objectName: "item3"
+ x: 20; y: 310
+ width: 90; height: 90
+ color: "white"
+ font.pixelSize: 20
+ text: "Box 3"
+
+ Keys.onReturnPressed: console.log("Bottom Left");
+ KeyNavigation.up: myScope
+ wrap: true
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro
new file mode 100644
index 0000000..4d7a9b3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativefocusscope.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
new file mode 100644
index 0000000..1bd8331
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** 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 <qtest.h>
+#include <QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetextedit_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativefocusscope_p.h>
+
+
+class tst_qdeclarativefocusscope : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativefocusscope() {}
+
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id);
+
+private slots:
+ void basic();
+ void nested();
+ void noFocus();
+ void textEdit();
+};
+
+/*
+ Find an item with the specified id.
+*/
+template<typename T>
+T *tst_qdeclarativefocusscope::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ QList<QGraphicsItem *> children = parent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(children.at(i)->toGraphicsObject());
+ if (item) {
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ return static_cast<T*>(item);
+ }
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+ }
+ return 0;
+}
+
+void tst_qdeclarativefocusscope::basic()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml"));
+
+ QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ qApp->setActiveWindow(view);
+ qApp->processEvents();
+
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(view);
+#endif
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == true);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == true);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == true);
+
+ delete view;
+}
+
+void tst_qdeclarativefocusscope::nested()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test2.qml"));
+
+ QDeclarativeFocusScope *item1 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeFocusScope *item2 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeFocusScope *item3 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item3"));
+ QDeclarativeFocusScope *item4 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item4"));
+ QDeclarativeFocusScope *item5 = findItem<QDeclarativeFocusScope>(view->rootObject(), QLatin1String("item5"));
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+ QVERIFY(item5 != 0);
+
+ view->show();
+ qApp->setActiveWindow(view);
+ qApp->processEvents();
+
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(view);
+#endif
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+
+ QVERIFY(item1->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->wantsFocus() == true);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->wantsFocus() == true);
+ QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item4->wantsFocus() == true);
+ QVERIFY(item4->hasFocus() == false);
+ QVERIFY(item5->wantsFocus() == true);
+ QVERIFY(item5->hasFocus() == true);
+ delete view;
+}
+
+void tst_qdeclarativefocusscope::noFocus()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test4.qml"));
+
+ QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeRectangle *item1 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeRectangle *item3 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ qApp->setActiveWindow(view);
+ qApp->processEvents();
+
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(view);
+#endif
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ delete view;
+}
+
+void tst_qdeclarativefocusscope::textEdit()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml"));
+
+ QDeclarativeRectangle *item0 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item0"));
+ QDeclarativeTextEdit *item1 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item1"));
+ QDeclarativeRectangle *item2 = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("item2"));
+ QDeclarativeTextEdit *item3 = findItem<QDeclarativeTextEdit>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ qApp->setActiveWindow(view);
+ qApp->processEvents();
+
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(view);
+#endif
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == true);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == true);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->wantsFocus() == true);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == true);
+ QVERIFY(item3->hasFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->wantsFocus() == false);
+ QVERIFY(item1->hasFocus() == false);
+ QVERIFY(item2->hasFocus() == false);
+ QVERIFY(item3->hasFocus() == true);
+
+ delete view;
+}
+
+QTEST_MAIN(tst_qdeclarativefocusscope)
+
+#include "tst_qdeclarativefocusscope.moc"
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index f837564..f3c2c09 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -44,7 +44,7 @@
#include <q3sqlcursor.h>
#include <qsqlfield.h>
#include <qsqldriver.h>
-
+#include <QSet>
#include "../qsqldatabase/tst_databases.h"
@@ -122,7 +122,7 @@ void tst_Q3SqlCursor::generic_data(const QString &engine)
{
if ( dbs.fillTestTable(engine) == 0 ) {
if(engine.isEmpty())
- QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
else
QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
}
@@ -131,7 +131,7 @@ void tst_Q3SqlCursor::generic_data(const QString &engine)
void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
{
if ( !db.isValid() )
- return;
+ return;
QSqlQuery q( db );
if (tst_Databases::isSqlServer(db)) {
@@ -143,20 +143,20 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
// please never ever change this table; otherwise fix all tests ;)
if ( tst_Databases::isMSAccess( db ) ) {
- QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null,"
- "t_char char(40), t_numeric number, primary key (id, t_varchar) )" ));
+ QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null,"
+ "t_char char(40), t_numeric number, primary key (id, t_varchar) )" ));
} else {
- QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null,"
- "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" ));
+ QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null,"
+ "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" ));
}
if ( tst_Databases::isSqlServer( db ) ) {
- //workaround for SQL SERVER since he can store unicode only in nvarchar fields
- QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, "
- "t_varchar nvarchar(80) not null, t_char nchar(80) )" ));
+ //workaround for SQL SERVER since he can store unicode only in nvarchar fields
+ QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, "
+ "t_varchar nvarchar(80) not null, t_char nchar(80) )" ));
} else {
- QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, "
- "t_varchar varchar(100) not null," "t_char char(100))" ));
+ QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, "
+ "t_varchar varchar(100) not null," "t_char char(100))" ));
}
if (tst_Databases::isMSAccess(db)) {
@@ -169,7 +169,7 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
void tst_Q3SqlCursor::dropTestTables( QSqlDatabase db )
{
if ( !db.isValid() )
- return;
+ return;
QStringList tableNames;
tableNames << qtest
<< qTableName( "qtest_unicode", __FILE__ )
@@ -183,7 +183,7 @@ void tst_Q3SqlCursor::dropTestTables( QSqlDatabase db )
void tst_Q3SqlCursor::populateTestTables( QSqlDatabase db )
{
if (!db.isValid())
- return;
+ return;
QSqlQuery q( db );
q.exec( "delete from " + qtest ); //not fatal
@@ -200,21 +200,21 @@ void tst_Q3SqlCursor::initTestCase()
dbs.open();
for ( QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it ) {
- QSqlDatabase db = QSqlDatabase::database( (*it) );
- CHECK_DATABASE( db );
+ QSqlDatabase db = QSqlDatabase::database( (*it) );
+ CHECK_DATABASE( db );
- dropTestTables( db ); //in case of leftovers
- createTestTables( db );
- populateTestTables( db );
+ dropTestTables( db ); //in case of leftovers
+ createTestTables( db );
+ populateTestTables( db );
}
}
void tst_Q3SqlCursor::cleanupTestCase()
{
for ( QStringList::ConstIterator it = dbs.dbNames.begin(); it != dbs.dbNames.end(); ++it ) {
- QSqlDatabase db = QSqlDatabase::database( (*it) );
- CHECK_DATABASE( db );
- dropTestTables( db );
+ QSqlDatabase db = QSqlDatabase::database( (*it) );
+ CHECK_DATABASE( db );
+ dropTestTables( db );
}
dbs.close();
@@ -230,9 +230,9 @@ void tst_Q3SqlCursor::cleanup()
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
if ( QTest::currentTestFailed() ) {
- //since Oracle ODBC totally craps out on error, we init again
- db.close();
- db.open();
+ //since Oracle ODBC totally craps out on error, we init again
+ db.close();
+ db.open();
}
}
@@ -244,10 +244,10 @@ void tst_Q3SqlCursor::copyConstructor()
Q3SqlCursor cur2;
{
- Q3SqlCursor cur( qtest, true, db );
- QVERIFY_SQL(cur, select( cur.index( QString("id") ) ));
- cur2 = Q3SqlCursor( cur );
- // let "cur" run out of scope...
+ Q3SqlCursor cur( qtest, true, db );
+ QVERIFY_SQL(cur, select( cur.index( QString("id") ) ));
+ cur2 = Q3SqlCursor( cur );
+ // let "cur" run out of scope...
}
QSqlRecord* rec = cur2.primeUpdate();
@@ -256,8 +256,8 @@ void tst_Q3SqlCursor::copyConstructor()
int i = 0;
while ( cur2.next() ) {
- QVERIFY( cur2.value("id").toInt() == i );
- i++;
+ QVERIFY( cur2.value("id").toInt() == i );
+ i++;
}
}
@@ -271,8 +271,8 @@ void tst_Q3SqlCursor::value()
QVERIFY_SQL(cur, select( cur.index( QString("id") ) ));
int i = 0;
while ( cur.next() ) {
- QCOMPARE(cur.value("id").toInt(), i);
- i++;
+ QCOMPARE(cur.value("id").toInt(), i);
+ i++;
}
}
@@ -285,11 +285,11 @@ void tst_Q3SqlCursor::primaryIndex()
Q3SqlCursor cur( qtest, true, db );
QSqlIndex index = cur.primaryIndex();
if ( tst_Databases::isMSAccess( db ) ) {
- QCOMPARE( index.fieldName(1).upper(), QString( "ID" ) );
- QCOMPARE( index.fieldName(0).upper(), QString( "T_VARCHAR" ) );
+ QCOMPARE( index.fieldName(1).upper(), QString( "ID" ) );
+ QCOMPARE( index.fieldName(0).upper(), QString( "T_VARCHAR" ) );
} else {
- QCOMPARE( index.fieldName(0).upper(), QString( "ID" ) );
- QCOMPARE( index.fieldName(1).upper(), QString( "T_VARCHAR" ) );
+ QCOMPARE( index.fieldName(0).upper(), QString( "ID" ) );
+ QCOMPARE( index.fieldName(1).upper(), QString( "T_VARCHAR" ) );
}
QVERIFY(!index.isDescending(0));
QVERIFY(!index.isDescending(1));
@@ -308,10 +308,10 @@ void tst_Q3SqlCursor::insert()
// check that primeInsert returns a valid QSqlRecord
QCOMPARE( (int)irec->count(), 4 );
if ( ( irec->field( 0 ).type() != QVariant::Int ) &&
- ( irec->field( 0 ).type() != QVariant::String ) &&
+ ( irec->field( 0 ).type() != QVariant::String ) &&
( irec->field( 0 ).type() != QVariant::Double ) ) {
- QFAIL( QString( "Wrong datatype %1 for field 'ID'"
- " (expected Int or String)" ).arg( QVariant::typeToName( irec->field( 0 ).type() ) ) );
+ QFAIL( QString( "Wrong datatype %1 for field 'ID'"
+ " (expected Int or String)" ).arg( QVariant::typeToName( irec->field( 0 ).type() ) ) );
}
QCOMPARE( QVariant::typeToName( irec->field( 1 ).type() ), QVariant::typeToName( QVariant::String ) );
QCOMPARE( QVariant::typeToName( irec->field( 2 ).type() ), QVariant::typeToName( QVariant::String ) );
@@ -327,7 +327,9 @@ void tst_Q3SqlCursor::insert()
irec->setValue( "t_char", "SomeChar" );
irec->setValue( "t_numeric", 400.400 );
- QCOMPARE( cur.insert(), 1 );
+ QSet<int> validReturns(QSet<int>() << -1 << 1);
+
+ QVERIFY( validReturns.contains(cur.insert()) );
// restore old test-tables
populateTestTables( db );
@@ -338,6 +340,7 @@ void tst_Q3SqlCursor::insertSpecial()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
+ QSet<int> validReturns(QSet<int>() << -1 << 1);
Q3SqlCursor cur( qtest, true, db );
QSqlRecord* irec = cur.primeInsert();
@@ -355,25 +358,25 @@ void tst_Q3SqlCursor::insertSpecial()
// INSERT the strings
QStringList::Iterator it;
for ( it = strings.begin(); it != strings.end(); ++it ) {
- QSqlRecord* irec = cur.primeInsert();
- QVERIFY( irec != 0 );
- irec->setValue( "id", i );
- irec->setValue( "t_varchar", (*it) );
- irec->setValue( "t_char", (*it) );
- irec->setValue( "t_numeric", (double)i );
- ++i;
- QCOMPARE( cur.insert(), 1 );
+ QSqlRecord* irec = cur.primeInsert();
+ QVERIFY( irec != 0 );
+ irec->setValue( "id", i );
+ irec->setValue( "t_varchar", (*it) );
+ irec->setValue( "t_char", (*it) );
+ irec->setValue( "t_numeric", (double)i );
+ ++i;
+ QVERIFY( validReturns.contains(cur.insert()) );
}
QVERIFY( cur.select( "id >= 800 and id < 900" ) );
int i2 = 800;
while( cur.next() ) {
- QCOMPARE( cur.value( "id" ).toInt(), i2 );
- QCOMPARE( cur.value( "t_varchar" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) );
- QCOMPARE( cur.value( "t_char" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) );
- QCOMPARE( cur.value( "t_numeric" ).toDouble(), (double)i2 );
- ++i2;
+ QCOMPARE( cur.value( "id" ).toInt(), i2 );
+ QCOMPARE( cur.value( "t_varchar" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) );
+ QCOMPARE( cur.value( "t_char" ).toString().stripWhiteSpace(), strings.at( i2 - 800 ) );
+ QCOMPARE( cur.value( "t_numeric" ).toDouble(), (double)i2 );
+ ++i2;
}
QCOMPARE( i, i2 );
@@ -385,6 +388,7 @@ void tst_Q3SqlCursor::batchInsert()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
+ QSet<int> validReturns(QSet<int>() << -1 << 1);
QSqlQuery q( db );
q.exec( "delete from " + qtest );
@@ -393,16 +397,16 @@ void tst_Q3SqlCursor::batchInsert()
int i = 0;
for ( ; i < 100; ++i ) {
- QSqlRecord* irec = cur.primeInsert();
- Q_ASSERT( irec );
- irec->setValue( "id", i );
- irec->setValue( "t_varchar", "blah" );
- irec->setValue( "t_char", "blah" );
- irec->setValue( "t_numeric", 1.1 );
- if ( db.driverName().startsWith( "QSQLITE" ) ) {
- QVERIFY( cur.insert( true ) );
- } else {
- QCOMPARE( cur.insert( true ), 1 );
+ QSqlRecord* irec = cur.primeInsert();
+ Q_ASSERT( irec );
+ irec->setValue( "id", i );
+ irec->setValue( "t_varchar", "blah" );
+ irec->setValue( "t_char", "blah" );
+ irec->setValue( "t_numeric", 1.1 );
+ if ( db.driverName().startsWith( "QSQLITE" ) ) {
+ QVERIFY( cur.insert( true ) );
+ } else {
+ QVERIFY( validReturns.contains(cur.insert( true )) );
}
}
@@ -413,18 +417,18 @@ void tst_Q3SqlCursor::batchInsert()
irec->setValue( "t_varchar", "blah" );
irec->setValue( "t_char", "blah" );
irec->setValue( "t_numeric", 1.1 );
- if ( db.driverName().startsWith( "QSQLITE" ) ) {
- QVERIFY( cur.insert( false ) );
- } else {
- QCOMPARE( cur.insert( false ), 1 );
+ if ( db.driverName().startsWith( "QSQLITE" ) ) {
+ QVERIFY( cur.insert( false ) );
+ } else {
+ QVERIFY( validReturns.contains(cur.insert( false )) );
}
}
i = 0;
QVERIFY_SQL(q, exec( "select * from " + qtest + " order by id" ));
while ( q.next() ) {
- QCOMPARE( q.value( 0 ).toInt(), i );
- i++;
+ QCOMPARE( q.value( 0 ).toInt(), i );
+ i++;
}
QCOMPARE( i, 200 );
@@ -436,7 +440,7 @@ static QString dumpUtf8( const QString& str )
{
QString res;
for ( int i = 0; i < (int)str.length(); ++i ) {
- res += "0x" + QString::number( str[ i ].unicode(), 16 ) + ' ';
+ res += "0x" + QString::number( str[ i ].unicode(), 16 ) + ' ';
}
return res;
}
@@ -448,7 +452,7 @@ void tst_Q3SqlCursor::insertORA()
CHECK_DATABASE( db );
if (tst_Databases::getOraVersion(db) < 9)
- QSKIP("Need Oracle >= 9", SkipSingle);
+ QSKIP("Need Oracle >= 9", SkipSingle);
/****** CHARSET TEST ******/
@@ -466,8 +470,8 @@ void tst_Q3SqlCursor::insertORA()
QVERIFY_SQL(cur, select());
QVERIFY( cur.next() );
if ( cur.value( "t_char" ).toString() != val1 )
- qDebug( QString( "Wrong value for t_char: expected '%1', got '%2'" ).arg( val1 ).arg(
- cur.value( "t_char" ).toString() ) );
+ qDebug( QString( "Wrong value for t_char: expected '%1', got '%2'" ).arg( val1 ).arg(
+ cur.value( "t_char" ).toString() ) );
static const unsigned short utf8arr[] = { 0xd792,0xd79c,0xd792,0xd79c,0xd799,0x00 };
static const QString utf8str = QString::fromUcs2( utf8arr );
@@ -524,7 +528,7 @@ void tst_Q3SqlCursor::unicode()
static const QString utf8str = QString::fromUtf8( "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει." );
if ( !db.driver()->hasFeature( QSqlDriver::Unicode ) ) {
- QSKIP( "DBMS not Unicode capable", SkipSingle );
+ QSKIP( "DBMS not Unicode capable", SkipSingle );
}
// ascii in the data storage, can't transliterate properly. invalid test.
if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb"))
@@ -640,11 +644,11 @@ void tst_Q3SqlCursor::select()
QSqlIndex idx = cur4.primaryIndex( false );
QCOMPARE( (int)idx.count(), 2 );
if ( tst_Databases::isMSAccess( db ) ) {
- QCOMPARE( idx.field( 1 ).name().upper(), QString("ID") );
- QCOMPARE( idx.field( 0 ).name().upper(), QString("T_VARCHAR") );
+ QCOMPARE( idx.field( 1 ).name().upper(), QString("ID") );
+ QCOMPARE( idx.field( 0 ).name().upper(), QString("T_VARCHAR") );
} else {
- QCOMPARE( idx.field( 0 ).name().upper(), QString("ID") );
- QCOMPARE( idx.field( 1 ).name().upper(), QString("T_VARCHAR") );
+ QCOMPARE( idx.field( 0 ).name().upper(), QString("ID") );
+ QCOMPARE( idx.field( 1 ).name().upper(), QString("T_VARCHAR") );
}
#ifdef QT_DEBUG
@@ -688,17 +692,18 @@ void tst_Q3SqlCursor::updateNoPK()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
-
+ QSet<int> validReturns(QSet<int>() << -1 << 1);
+
QSqlQuery q(db);
QVERIFY_SQL(q, exec("create table " + qTableName( "qtestPK", __FILE__ ) + " (id int, name varchar(20), num numeric)"));
-
+
Q3SqlCursor cur(qTableName("qtestPK", __FILE__), true, db);
QSqlRecord* rec = cur.primeInsert();
Q_ASSERT(rec);
rec->setNull(0);
rec->setNull(1);
rec->setNull(2);
- QVERIFY_SQL(cur, insert() == 1);
+ QVERIFY(validReturns.contains(cur.insert()));
if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) {
// Only QPSQL, QMYSQL, QODBC and QOCI drivers currently use escape identifiers for column names
@@ -713,8 +718,8 @@ void tst_Q3SqlCursor::updateNoPK()
+ " values (NULL,NULL,NULL)");
QCOMPARE(cur.lastQuery(), query);
} else {
- QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) +
- " (\"id\",\"name\",\"num\") values (NULL,NULL,NULL)"));
+ QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) +
+ " (\"id\",\"name\",\"num\") values (NULL,NULL,NULL)"));
}
}
@@ -733,7 +738,7 @@ void tst_Q3SqlCursor::updateNoPK()
qTableName("qtestPK", __FILE__) + ".num IS NULL";
if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) {
if (!db.driverName().startsWith("QSQLITE")) {
- QCOMPARE(cur.lastQuery(), expect);
+ QCOMPARE(cur.lastQuery(), expect);
}
}
QVERIFY(cur.select(cur.index(QString("id"))));
@@ -750,6 +755,7 @@ void tst_Q3SqlCursor::insertFieldNameContainsWS() {
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
+ QSet<int> validReturns(QSet<int>() << -1 << 1);
// The bugfix (and this test) depends on QSqlDriver::escapeIdentifier(...)
// to be implemented, which is currently only the case for the
@@ -778,7 +784,7 @@ void tst_Q3SqlCursor::insertFieldNameContainsWS() {
r->setValue("firsT NaMe", "Kong");
r->setValue("lastNaMe", "Harald");
- QVERIFY(cur.insert() == 1);
+ QVERIFY(validReturns.contains(cur.insert()));
cur.select();
cur.next();
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index f246750..9adb4fc 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -547,6 +547,9 @@ void tst_QFiledialog::completer()
// ### FIXME: This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel
// are fixed to properly capitalize paths, so that some folders are not duplicated in QFileSystemModel.
+#if defined(Q_OS_SYMBIAN)
+ QSKIP("This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel are fixed to properly capitalize paths")
+#endif
QTRY_COMPARE(cModel->rowCount(), expected);
} QT_CATCH(...) {
qDeleteAll(files);
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index f4fdacc..01ef9a2 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -384,6 +384,7 @@ private slots:
void tabChangesFocus();
void tabChangesFocus_data();
void cacheMode();
+ void cacheMode2();
void updateCachedItemAfterMove();
void deviceTransform_data();
void deviceTransform();
@@ -6824,6 +6825,9 @@ void tst_QGraphicsItem::cacheMode()
QTRY_COMPARE(tester->repaints, 4);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
+ tester->resetTransform();
+ testerChild->resetTransform();
+ testerChild2->resetTransform();
// Explicit update causes a repaint.
tester->update(0, 0, 5, 5);
@@ -6897,23 +6901,24 @@ void tst_QGraphicsItem::cacheMode()
// because the parent is rotated with a perspective.
testerChild->setPos(1, 1);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 10);
+ QTRY_COMPARE(tester->repaints, 11);
QCOMPARE(testerChild->repaints, 10);
QCOMPARE(testerChild2->repaints, 5);
+ tester->resetTransform();
// Make a huge item
tester->setGeometry(QRectF(-4000, -4000, 8000, 8000));
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 11);
- QCOMPARE(testerChild->repaints, 10);
+ QTRY_COMPARE(tester->repaints, 12);
+ QCOMPARE(testerChild->repaints, 11);
QCOMPARE(testerChild2->repaints, 5);
// Move the large item - will cause a repaint as the
// cache is clipped.
tester->setPos(5, 0);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 12);
- QCOMPARE(testerChild->repaints, 10);
+ QTRY_COMPARE(tester->repaints, 13);
+ QCOMPARE(testerChild->repaints, 11);
QCOMPARE(testerChild2->repaints, 5);
// Hiding and showing should invalidate the cache
@@ -6921,11 +6926,83 @@ void tst_QGraphicsItem::cacheMode()
QTest::qWait(25);
tester->show();
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 13);
- QCOMPARE(testerChild->repaints, 11);
+ QTRY_COMPARE(tester->repaints, 14);
+ QCOMPARE(testerChild->repaints, 12);
QCOMPARE(testerChild2->repaints, 6);
}
+void tst_QGraphicsItem::cacheMode2()
+{
+ QGraphicsScene scene(0, 0, 100, 100);
+ QGraphicsView view(&scene);
+ view.resize(150, 150);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+
+ // Increase the probability of window activation
+ // not causing another repaint of test items.
+ QTest::qWait(50);
+
+ EventTester *tester = new EventTester;
+ scene.addItem(tester);
+ QTest::qWait(10);
+ QTRY_COMPARE(tester->repaints, 1);
+
+ // Switching from NoCache to NoCache (no repaint)
+ tester->setCacheMode(QGraphicsItem::NoCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 1);
+
+ // Switching from NoCache to DeviceCoordinateCache (no repaint)
+ tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 1);
+
+ // Switching from DeviceCoordinateCache to DeviceCoordinateCache (no repaint)
+ tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 1);
+
+ // Switching from DeviceCoordinateCache to NoCache (no repaint)
+ tester->setCacheMode(QGraphicsItem::NoCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 1);
+
+ // Switching from NoCache to ItemCoordinateCache (repaint)
+ tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 2);
+
+ // Switching from ItemCoordinateCache to ItemCoordinateCache (no repaint)
+ tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 2);
+
+ // Switching from ItemCoordinateCache to ItemCoordinateCache with different size (repaint)
+ tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(100, 100));
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 3);
+
+ // Switching from ItemCoordinateCache to NoCache (repaint)
+ tester->setCacheMode(QGraphicsItem::NoCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 4);
+
+ // Switching from DeviceCoordinateCache to ItemCoordinateCache (repaint)
+ tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 4);
+ tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 5);
+
+ // Switching from ItemCoordinateCache to DeviceCoordinateCache (repaint)
+ tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ QTest::qWait(50);
+ QTRY_COMPARE(tester->repaints, 6);
+}
+
void tst_QGraphicsItem::updateCachedItemAfterMove()
{
// A simple item that uses ItemCoordinateCache
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 4922a89..e269092 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -283,6 +283,9 @@ private Q_SLOTS:
void ignoreSslErrorsListWithSlot_data();
void ignoreSslErrorsListWithSlot();
#endif
+
+ // NOTE: This test must be last!
+ void parentingRepliesToTheApp();
};
QT_BEGIN_NAMESPACE
@@ -3931,7 +3934,7 @@ void tst_QNetworkReply::httpConnectionCount()
for (int i = 0; i < 10; i++) {
QNetworkRequest request (QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/" + QString::number(i)));
QNetworkReply* reply = manager.get(request);
- reply->setParent(this);
+ reply->setParent(&server);
}
int pendingConnectionCount = 0;
@@ -4205,5 +4208,13 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot()
#endif // QT_NO_OPENSSL
+// NOTE: This test must be last testcase in tst_qnetworkreply!
+void tst_QNetworkReply::parentingRepliesToTheApp()
+{
+ QNetworkRequest request (QUrl("http://" + QtNetworkSettings::serverName()));
+ manager.get(request)->setParent(this); // parent to this object
+ manager.get(request)->setParent(qApp); // parent to the app
+}
+
QTEST_MAIN(tst_QNetworkReply)
#include "tst_qnetworkreply.moc"
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index b9ab73f..db3a929 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -1137,17 +1137,14 @@ void tst_QSqlQuery::last()
QVERIFY( q.last() );
- if ( !tst_Databases::isMSAccess( db ) )
- // Access doesn't return the correct position
- QCOMPARE( q.at(), ( i-1 ) );
+ QSet<int> validReturns(QSet<int>() << -1 << i-1);
+ QVERIFY( validReturns.contains(q.at()) );
QSqlQuery q2( "select * from " + qtest, db );
QVERIFY( q2.last() );
- if ( !tst_Databases::isMSAccess( db ) )
- // Access doesn't return the correct position
- QCOMPARE( q.at(), ( i-1 ) );
+ QVERIFY( validReturns.contains(q.at()) );
}
void tst_QSqlQuery::seek()