summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-05-16 23:09:00 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-05-16 23:09:00 (GMT)
commit8c216aee5d2e52b6fa36e256615374b9435bb4c9 (patch)
treec65554b66874dae21a0876f804926254073aedd0 /tests
parent3340b23699f0286876f1e237a66bdc85076fe191 (diff)
parent3849cd0cca618fac88a54861a3ec30780711ce75 (diff)
downloadQt-8c216aee5d2e52b6fa36e256615374b9435bb4c9.zip
Qt-8c216aee5d2e52b6fa36e256615374b9435bb4c9.tar.gz
Qt-8c216aee5d2e52b6fa36e256615374b9435bb4c9.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/blank.js0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/exception.js1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include.js8
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml15
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js26
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml21
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js13
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml12
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js12
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml22
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js3
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp111
-rw-r--r--tests/auto/gestures/tst_gestures.cpp71
-rw-r--r--tests/auto/qbuffer/tst_qbuffer.cpp26
-rw-r--r--tests/auto/qcolumnview/tst_qcolumnview.cpp10
-rw-r--r--tests/auto/qdatetime/tst_qdatetime.cpp26
-rw-r--r--tests/auto/qdockwidget/tst_qdockwidget.cpp24
-rw-r--r--tests/auto/qfile/largefile/tst_largefile.cpp4
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp4
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp57
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp63
-rw-r--r--tests/auto/qmessagebox/tst_qmessagebox.cpp2
-rw-r--r--tests/auto/qnetworkreply/smb-file.txt1
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp23
-rw-r--r--tests/auto/qprinter/tst_qprinter.cpp28
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp24
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp61
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp31
-rw-r--r--tests/auto/qwidgetaction/tst_qwidgetaction.cpp6
-rw-r--r--tests/auto/qxmlquery/tst_qxmlquery.cpp18
-rw-r--r--tests/auto/xmlpatternsxqts/tst_suitetest.cpp15
-rw-r--r--tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp38
-rw-r--r--tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp79
38 files changed, 836 insertions, 70 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/blank.js b/tests/auto/declarative/qdeclarativeecmascript/data/blank.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/blank.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exception.js b/tests/auto/declarative/qdeclarativeecmascript/data/exception.js
new file mode 100644
index 0000000..160bbfa
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/exception.js
@@ -0,0 +1 @@
+throw("Whoops!");
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.js b/tests/auto/declarative/qdeclarativeecmascript/data/include.js
new file mode 100644
index 0000000..232fd80
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include.js
@@ -0,0 +1,8 @@
+var test1 = true
+var test2 = false
+var test3 = false
+
+function go() {
+ Qt.include("js/include2.js");
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml
new file mode 100644
index 0000000..18543b2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml
@@ -0,0 +1,23 @@
+import Qt 4.7
+import "include.js" as IncludeTest
+
+QtObject {
+ property int test0: 0
+ property bool test1: false
+ property bool test2: false
+ property bool test2_1: false
+ property bool test3: false
+ property bool test3_1: false
+
+ property int testValue: 99
+
+ Component.onCompleted: {
+ IncludeTest.go();
+ test0 = IncludeTest.value
+ test1 = IncludeTest.test1
+ test2 = IncludeTest.test2
+ test2_1 = IncludeTest.test2_1
+ test3 = IncludeTest.test3
+ test3_1 = IncludeTest.test3_1
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js
new file mode 100644
index 0000000..ea19eba
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js
@@ -0,0 +1,11 @@
+function go() {
+ var a = Qt.include("missing.js", function(o) { test2 = o.status == o.NETWORK_ERROR });
+ test1 = a.status == a.NETWORK_ERROR
+
+ var b = Qt.include("blank.js", function(o) { test4 = o.status == o.OK });
+ test3 = b.status == b.OK
+
+ var c = Qt.include("exception.js", function(o) { test6 = o.status == o.EXCEPTION });
+ test5 = c.status == c.EXCEPTION
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml
new file mode 100644
index 0000000..a39e821
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml
@@ -0,0 +1,15 @@
+import Qt 4.7
+import "include_callback.js" as IncludeTest
+
+QtObject {
+ property bool test1: false
+ property bool test2: false
+ property bool test3: false
+ property bool test4: false
+ property bool test5: false
+ property bool test6: false
+
+ Component.onCompleted: {
+ IncludeTest.go();
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js
new file mode 100644
index 0000000..e6a4676
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js
@@ -0,0 +1,26 @@
+var myvar = 10;
+
+function go()
+{
+ var a = Qt.include("http://127.0.0.1:8111/remote_file.js",
+ function(o) {
+ test2 = o.status == o.OK
+ test3 = a.status == a.OK
+ test4 = myvar == 13
+
+ done = true;
+ });
+ test1 = a.status == a.LOADING
+
+
+ var b = Qt.include("http://127.0.0.1:8111/exception.js",
+ function(o) {
+ test7 = o.status == o.EXCEPTION
+ test8 = b.status == a.EXCEPTION
+ test9 = b.exception.toString() == "Whoops!";
+ test10 = o.exception.toString() == "Whoops!";
+
+ done2 = true;
+ });
+ test6 = b.status == b.LOADING
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml
new file mode 100644
index 0000000..06bd174
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml
@@ -0,0 +1,21 @@
+import Qt 4.7
+import "include_remote.js" as IncludeTest
+
+QtObject {
+ property bool done: false
+ property bool done2: false
+
+ property bool test1: false
+ property bool test2: false
+ property bool test3: false
+ property bool test4: false
+ property bool test5: false
+
+ property bool test6: false
+ property bool test7: false
+ property bool test8: false
+ property bool test9: false
+ property bool test10: false
+
+ Component.onCompleted: IncludeTest.go();
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js
new file mode 100644
index 0000000..cc90860
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js
@@ -0,0 +1,13 @@
+function go()
+{
+ var a = Qt.include("http://127.0.0.1:8111/missing.js",
+ function(o) {
+ test2 = o.status == o.NETWORK_ERROR
+ test3 = a.status == a.NETWORK_ERROR
+
+ done = true;
+ });
+
+ test1 = a.status == a.LOADING
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml
new file mode 100644
index 0000000..8e486b2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml
@@ -0,0 +1,12 @@
+import Qt 4.7
+import "include_remote_missing.js" as IncludeTest
+
+QtObject {
+ property bool done: false
+
+ property bool test1: false
+ property bool test2: false
+ property bool test3: false
+
+ Component.onCompleted: IncludeTest.go();
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js
new file mode 100644
index 0000000..a49c07b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js
@@ -0,0 +1,12 @@
+.pragma library
+
+var test1 = true
+var test2 = false
+var test3 = false
+
+var testValue = 99;
+
+function go() {
+ Qt.include("js/include2.js");
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml
new file mode 100644
index 0000000..e957018
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml
@@ -0,0 +1,22 @@
+import Qt 4.7
+import "include_shared.js" as IncludeTest
+
+QtObject {
+ property int test0: 0
+ property bool test1: false
+ property bool test2: false
+ property bool test2_1: false
+ property bool test3: false
+ property bool test3_1: false
+
+ Component.onCompleted: {
+ IncludeTest.go();
+ test0 = IncludeTest.value
+ test1 = IncludeTest.test1
+ test2 = IncludeTest.test2
+ test2_1 = IncludeTest.test2_1
+ test3 = IncludeTest.test3
+ test3_1 = IncludeTest.test3_1
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js b/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js
new file mode 100644
index 0000000..2a0c039
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js
@@ -0,0 +1,4 @@
+test2 = true
+var test2_1 = true
+
+Qt.include("include3.js");
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js b/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js
new file mode 100644
index 0000000..84b2770
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js
@@ -0,0 +1,3 @@
+test3 = true
+var test3_1 = true
+var value = testValue
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js b/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js
new file mode 100644
index 0000000..1b123ae
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js
@@ -0,0 +1,2 @@
+myvar = 13;
+test5 = true;
diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
index eabed26..c907be5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
+++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
@@ -1,13 +1,18 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative script
+contains(QT_CONFIG,declarative): QT += declarative script network
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativeecmascript.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
+ testtypes.cpp \
+ ../shared/testhttpserver.cpp
+HEADERS += testtypes.h \
+ ../shared/testhttpserver.h
+INCLUDEPATH += ../shared
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
# LIBS += -lgcov
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 8c9290f..b8faa7c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -51,6 +51,7 @@
#include <private/qdeclarativeengine_p.h>
#include <private/qdeclarativeglobalscriptclass_p.h>
#include "testtypes.h"
+#include "testhttpserver.h"
/*
This test covers evaluation of ECMAScript expressions and bindings from within
@@ -149,6 +150,8 @@ private slots:
void eval();
void function();
+ void include();
+
void callQtInvokables();
private:
QDeclarativeEngine engine;
@@ -2361,6 +2364,114 @@ void tst_qdeclarativeecmascript::function()
delete o;
}
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+// Test the "Qt.include" method
+void tst_qdeclarativeecmascript::include()
+{
+ // Non-library relative include
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("include.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test0").toInt(), 99);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test2_1").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test3_1").toBool(), true);
+
+ delete o;
+ }
+
+ // Library relative include
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("include_shared.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test0").toInt(), 99);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test2_1").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test3_1").toBool(), true);
+
+ delete o;
+ }
+
+ // Callback
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("include_callback.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+
+ delete o;
+ }
+
+ // Remote - success
+ {
+ TestHTTPServer server(8111);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("include_remote.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ TRY_WAIT(o->property("done").toBool() == true);
+ TRY_WAIT(o->property("done2").toBool() == true);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ QCOMPARE(o->property("test8").toBool(), true);
+ QCOMPARE(o->property("test9").toBool(), true);
+ QCOMPARE(o->property("test10").toBool(), true);
+
+ delete o;
+ }
+
+ // Remote - error
+ {
+ TestHTTPServer server(8111);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("include_remote_missing.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ TRY_WAIT(o->property("done").toBool() == true);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+
+ delete o;
+ }
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index f8ecca3..dfadf48 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -50,6 +50,7 @@
#include <qgesturerecognizer.h>
#include <qgraphicsitem.h>
#include <qgraphicsview.h>
+#include <qmainwindow.h>
#include <qdebug.h>
@@ -355,6 +356,7 @@ private slots:
void deleteGestureTargetItem();
void viewportCoordinates();
void partialGesturePropagation();
+ void testQGestureRecognizerCleanup();
};
tst_Gestures::tst_Gestures()
@@ -1949,5 +1951,74 @@ void tst_Gestures::partialGesturePropagation()
QCOMPARE(item4->gestureEventsReceived, 0);
}
+class WinNativePan : public QPanGesture {
+public:
+ WinNativePan() {}
+};
+
+class Pan : public QPanGesture {
+public:
+ Pan() {}
+};
+
+class CustomPan : public QPanGesture {
+public:
+ CustomPan() {}
+};
+
+// Recognizer for active gesture triggers on mouse press
+class PanRecognizer : public QGestureRecognizer {
+public:
+ enum PanType { Platform, Default, Custom };
+
+ PanRecognizer(int id) : m_id(id) {}
+ QGesture *create(QObject *) {
+ switch(m_id) {
+ case Platform: return new WinNativePan();
+ case Default: return new Pan();
+ default: return new CustomPan();
+ }
+ }
+
+ Result recognize(QGesture *, QObject *, QEvent *) { return QGestureRecognizer::Ignore; }
+
+ const int m_id;
+};
+
+void tst_Gestures::testQGestureRecognizerCleanup()
+{
+ // Clean first the current recognizers in QGManager
+ QGestureRecognizer::unregisterRecognizer(Qt::PanGesture);
+
+ // v-- Qt singleton QGManager initialization
+
+ // Mimic QGestureManager: register both default and "platform" recognizers
+ // (this is done in windows when QT_NO_NATIVE_GESTURES is not defined)
+ PanRecognizer *def = new PanRecognizer(PanRecognizer::Default);
+ QGestureRecognizer::registerRecognizer(def);
+ PanRecognizer *plt = new PanRecognizer(PanRecognizer::Platform);
+ QGestureRecognizer::registerRecognizer(plt);
+ qDebug () << "register: default =" << def << "; platform =" << plt;
+
+ // ^-- Qt singleton QGManager initialization
+
+ // Here, application code would start
+
+ // Create QGV (has a QAScrollArea, which uses Qt::PanGesture)
+ QMainWindow *w = new QMainWindow;
+ QGraphicsView *v = new QGraphicsView();
+ w->setCentralWidget(v);
+
+ // Unregister Qt recognizers
+ QGestureRecognizer::unregisterRecognizer(Qt::PanGesture);
+
+ // Register a custom Pan recognizer
+ //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom));
+
+ w->show();
+ QTest::qWaitForWindowShown(w);
+ delete w;
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"
diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp
index fcef6a3..dd5ca91 100644
--- a/tests/auto/qbuffer/tst_qbuffer.cpp
+++ b/tests/auto/qbuffer/tst_qbuffer.cpp
@@ -76,6 +76,7 @@ private slots:
void atEnd();
void readLineBoundaries();
void writeAfterQByteArrayResize();
+ void read_null();
protected slots:
void readyReadSlot();
@@ -529,5 +530,30 @@ void tst_QBuffer::writeAfterQByteArrayResize()
QCOMPARE(buffer.buffer().size(), 1000);
}
+void tst_QBuffer::read_null()
+{
+ QByteArray buffer;
+ buffer.resize(32000);
+ for (int i = 0; i < buffer.size(); ++i)
+ buffer[i] = char(i & 0xff);
+
+ QBuffer in(&buffer);
+ in.open(QIODevice::ReadOnly);
+
+ QByteArray chunk;
+
+ chunk.resize(16380);
+ in.read(chunk.data(), 16380);
+
+ QCOMPARE(chunk, buffer.mid(0, chunk.size()));
+
+ in.read(chunk.data(), 0);
+
+ chunk.resize(8);
+ in.read(chunk.data(), chunk.size());
+
+ QCOMPARE(chunk, buffer.mid(16380, chunk.size()));
+}
+
QTEST_MAIN(tst_QBuffer)
#include "tst_qbuffer.moc"
diff --git a/tests/auto/qcolumnview/tst_qcolumnview.cpp b/tests/auto/qcolumnview/tst_qcolumnview.cpp
index 90f499d..1da8c5d 100644
--- a/tests/auto/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/qcolumnview/tst_qcolumnview.cpp
@@ -596,11 +596,11 @@ void tst_QColumnView::clicked()
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, localPoint);
QCOMPARE(clickedSpy.count(), 1);
qApp->processEvents();
-
+
if (sizeof(qreal) != sizeof(double)) {
QSKIP("Skipped due to rounding errors", SkipAll);
}
-
+
for (int i = 0; i < view.createdColumns.count(); ++i) {
QAbstractItemView *column = view.createdColumns.at(i);
if (column && column->selectionModel() && (column->rootIndex() == home))
@@ -961,9 +961,9 @@ void tst_QColumnView::parentCurrentIndex()
QVERIFY(third.isValid());
view.setCurrentIndex(third);
QTest::qWait(ANIMATION_DELAY);
- QCOMPARE(view.createdColumns[0]->currentIndex(), first);
- QCOMPARE(view.createdColumns[1]->currentIndex(), second);
- QCOMPARE(view.createdColumns[2]->currentIndex(), third);
+ QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
+ QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
+ QTRY_COMPARE(view.createdColumns[2]->currentIndex(), third);
first = model.index(0, 0, QModelIndex());
second = model.index(secondRow, 0, first);
diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp
index 6aca996..47c54a5 100644
--- a/tests/auto/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/qdatetime/tst_qdatetime.cpp
@@ -106,6 +106,8 @@ private slots:
void daysTo();
void secsTo_data();
void secsTo();
+ void msecsTo_data();
+ void msecsTo();
void operator_eqeq();
void currentDateTime();
void currentDateTimeUtc();
@@ -910,6 +912,30 @@ void tst_QDateTime::secsTo()
QVERIFY((dt >= result) == (0 >= nsecs));
}
+void tst_QDateTime::msecsTo_data()
+{
+ addMSecs_data();
+}
+
+void tst_QDateTime::msecsTo()
+{
+ QFETCH(QDateTime, dt);
+ QFETCH(int, nsecs);
+ QFETCH(QDateTime, result);
+
+#ifdef Q_OS_IRIX
+ QEXPECT_FAIL("cet4", "IRIX databases say 1970 had DST", Abort);
+#endif
+ QCOMPARE(dt.msecsTo(result), qint64(nsecs) * 1000);
+ QCOMPARE(result.msecsTo(dt), -qint64(nsecs) * 1000);
+ QVERIFY((dt == result) == (0 == (qint64(nsecs) * 1000)));
+ QVERIFY((dt != result) == (0 != (qint64(nsecs) * 1000)));
+ QVERIFY((dt < result) == (0 < (qint64(nsecs) * 1000)));
+ QVERIFY((dt <= result) == (0 <= (qint64(nsecs) * 1000)));
+ QVERIFY((dt > result) == (0 > (qint64(nsecs) * 1000)));
+ QVERIFY((dt >= result) == (0 >= (qint64(nsecs) * 1000)));
+}
+
void tst_QDateTime::currentDateTime()
{
#if defined(Q_OS_WINCE)
diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp
index a734985..2059101 100644
--- a/tests/auto/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp
@@ -96,6 +96,7 @@ private slots:
void task248604_infiniteResize();
void task258459_visibilityChanged();
void taskQTBUG_1665_closableChanged();
+ void taskQTBUG_9758_undockedGeometry();
};
// Testing get/set functions
@@ -653,7 +654,7 @@ void tst_QDockWidget::dockLocationChanged()
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::TopDockWidgetArea);
spy.clear();
-
+
dw.setFloating(true);
QTest::qWait(100);
dw.setFloating(false);
@@ -878,6 +879,27 @@ void tst_QDockWidget::taskQTBUG_1665_closableChanged()
QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint));
}
+void tst_QDockWidget::taskQTBUG_9758_undockedGeometry()
+{
+ QMainWindow window;
+ QDockWidget dock1(&window);
+ QDockWidget dock2(&window);
+ window.addDockWidget(Qt::RightDockWidgetArea, &dock1);
+ window.addDockWidget(Qt::RightDockWidgetArea, &dock2);
+ window.tabifyDockWidget(&dock1, &dock2);
+ dock1.hide();
+ dock2.hide();
+ window.show();
+ QTest::qWaitForWindowShown(&window);
+ dock1.setFloating(true);
+ dock1.show();
+ QTest::qWaitForWindowShown(&dock1);
+
+ QVERIFY(dock1.x() >= 0);
+ QVERIFY(dock1.y() >= 0);
+}
+
+
QTEST_MAIN(tst_QDockWidget)
#include "tst_qdockwidget.moc"
diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp
index 041e5f2..60c5f89 100644
--- a/tests/auto/qfile/largefile/tst_largefile.cpp
+++ b/tests/auto/qfile/largefile/tst_largefile.cpp
@@ -523,6 +523,10 @@ void tst_LargeFile::mapFile()
void tst_LargeFile::mapOffsetOverflow()
{
+#if defined(Q_OS_MAC)
+ QSKIP("mmap'ping beyond EOF may succeed; generate bus error on access", SkipAll);
+#endif
+
// Out-of-range mappings should fail, and not silently clip the offset
for (int i = 50; i < 63; ++i) {
uchar *address = 0;
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index 38a1ee7..ca7c445 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -529,10 +529,6 @@ void tst_QFiledialog::completer()
#endif
++expected;
}
-#if !defined(Q_OS_WIN)
- if (inputStartsWithRootPath)
- expected++;
-#endif
}
QTest::qWait(1000);
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 1df9a37..b8df7f6 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -218,6 +218,7 @@ private slots:
void update();
void update2_data();
void update2();
+ void update_ancestorClipsChildrenToShape();
void inputMethodSensitivity();
void inputContextReset();
void indirectPainting();
@@ -3758,6 +3759,62 @@ void tst_QGraphicsView::update2()
#endif
}
+void tst_QGraphicsView::update_ancestorClipsChildrenToShape()
+{
+ QGraphicsScene scene(-150, -150, 300, 300);
+
+ /*
+ Add three rects:
+
+ +------------------+
+ | child |
+ | +--------------+ |
+ | | parent | |
+ | | +-----------+ |
+ | | |grandParent| |
+ | | +-----------+ |
+ | +--------------+ |
+ +------------------+
+
+ ... where both the parent and the grand parent clips children to shape.
+ */
+ QApplication::processEvents(); // Get rid of pending update.
+
+ QGraphicsRectItem *grandParent = static_cast<QGraphicsRectItem *>(scene.addRect(0, 0, 50, 50));
+ grandParent->setBrush(Qt::black);
+ grandParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+
+ QGraphicsRectItem *parent = static_cast<QGraphicsRectItem *>(scene.addRect(-50, -50, 100, 100));
+ parent->setBrush(QColor(0, 0, 255, 125));
+ parent->setParentItem(grandParent);
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+
+ QGraphicsRectItem *child = static_cast<QGraphicsRectItem *>(scene.addRect(-100, -100, 200, 200));
+ child->setBrush(QColor(255, 0, 0, 125));
+ child->setParentItem(parent);
+
+ CustomView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(view.painted);
+
+ view.lastUpdateRegions.clear();
+ view.painted = false;
+
+ // Call child->update() and make sure the updated area is within the ancestors' clip.
+ QRectF expected = child->deviceTransform(view.viewportTransform()).mapRect(child->boundingRect());
+ expected &= grandParent->deviceTransform(view.viewportTransform()).mapRect(grandParent->boundingRect());
+
+ child->update();
+ QTRY_VERIFY(view.painted);
+
+#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
+ QTRY_VERIFY(view.painted);
+ QCOMPARE(view.lastUpdateRegions.size(), 1);
+ QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
+#endif
+}
+
class FocusItem : public QGraphicsRectItem
{
public:
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 1b4c502..aadee5b 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -114,6 +114,9 @@ private slots:
void readFromFileAfterJunk_data();
void readFromFileAfterJunk();
+ void devicePosition_data();
+ void devicePosition();
+
void setBackgroundColor_data();
void setBackgroundColor();
@@ -1117,7 +1120,7 @@ void tst_QImageReader::readFromFileAfterJunk()
QByteArray imageData = imageFile.readAll();
QVERIFY(!imageData.isNull());
- int iterations = 10;
+ int iterations = 3;
if (format == "ppm" || format == "pbm" || format == "pgm" || format == "svg" || format == "svgz")
iterations = 1;
@@ -1147,6 +1150,64 @@ void tst_QImageReader::readFromFileAfterJunk()
}
}
+void tst_QImageReader::devicePosition_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QByteArray>("format");
+
+ QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm");
+ QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm");
+ QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm");
+#ifdef QTEST_HAVE_JPEG
+ QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg");
+ QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg");
+#endif
+#if defined QTEST_HAVE_GIF
+ QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif");
+#endif
+ QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm");
+ QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm");
+ QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp");
+ QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp");
+ QTest::newRow("png") << QString("kollada.png") << QByteArray("png");
+// QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng");
+// QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng");
+#if defined QTEST_HAVE_SVG
+ QTest::newRow("svg") << QString("rect.svg") << QByteArray("svg");
+ QTest::newRow("svgz") << QString("rect.svgz") << QByteArray("svgz");
+#endif
+}
+
+void tst_QImageReader::devicePosition()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QByteArray, format);
+
+ QImage expected(prefix + fileName);
+ QVERIFY(!expected.isNull());
+
+ QFile imageFile(prefix + fileName);
+ QVERIFY(imageFile.open(QFile::ReadOnly));
+ QByteArray imageData = imageFile.readAll();
+ QVERIFY(!imageData.isNull());
+ int imageDataSize = imageData.size();
+
+ const char *preStr = "prebeef\n";
+ int preLen = qstrlen(preStr);
+ imageData.prepend(preStr);
+ if (format != "svg" && format != "svgz") // Doesn't handle trailing data
+ imageData.append("\npostbeef");
+ QBuffer buf(&imageData);
+ buf.open(QIODevice::ReadOnly);
+ buf.seek(preLen);
+ QImageReader reader(&buf, format);
+ QCOMPARE(expected, reader.read());
+ if (format != "ppm" && format != "gif") // Known not to work
+ QCOMPARE(buf.pos(), qint64(preLen+imageDataSize));
+}
+
+
void tst_QImageReader::description_data()
{
QTest::addColumn<QString>("fileName");
diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp
index 2de1c52..d4ca064 100644
--- a/tests/auto/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp
@@ -140,6 +140,8 @@ private:
tst_QMessageBox::tst_QMessageBox() : keyToSend(-1)
{
+ int argc = qApp->argc();
+ QT_REQUIRE_VERSION(argc, qApp->argv(), "4.6.2")
}
int tst_QMessageBox::exec(QMessageBox *msgBox, int key)
diff --git a/tests/auto/qnetworkreply/smb-file.txt b/tests/auto/qnetworkreply/smb-file.txt
new file mode 100644
index 0000000..73c3ac2
--- /dev/null
+++ b/tests/auto/qnetworkreply/smb-file.txt
@@ -0,0 +1 @@
+This is 34 bytes. Do not change... \ No newline at end of file
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index ff79c09..9d942bf 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -522,8 +522,8 @@ public:
active->connectToHost("127.0.0.1", server.serverPort());
#ifndef Q_OS_SYMBIAN
// need more time as working with embedded
- // device and testing from emualtor
- // things tend to get slower
+ // device and testing from emualtor
+ // things tend to get slower
if (!active->waitForConnected(1000))
return false;
@@ -929,7 +929,7 @@ void tst_QNetworkReply::invalidProtocol()
void tst_QNetworkReply::getFromData_data()
{
- QTest::addColumn<QString>("request");
+ QTest::addColumn<QString>("request");
QTest::addColumn<QByteArray>("expected");
QTest::addColumn<QString>("mimeType");
@@ -1025,7 +1025,7 @@ void tst_QNetworkReply::getFromData()
void tst_QNetworkReply::getFromFile()
{
- // create the file:
+ // create the file:
QTemporaryFile file(QDir::currentPath() + "/temp-XXXXXX");
file.setAutoRemove(true);
QVERIFY(file.open());
@@ -1073,11 +1073,14 @@ void tst_QNetworkReply::getFromFileSpecial_data()
QTest::newRow("resource") << ":/resource" << "qrc:/resource";
QTest::newRow("search-path") << "srcdir:/rfc3252.txt" << "srcdir:/rfc3252.txt";
QTest::newRow("bigfile-path") << "srcdir:/bigfile" << "srcdir:/bigfile";
+#ifdef Q_OS_WIN
+ QTest::newRow("smb-path") << "srcdir:/smb-file.txt" << "file://" + QtNetworkSettings::winServerName() + "/testshare/test.pri";
+#endif
}
void tst_QNetworkReply::getFromFileSpecial()
{
- QFETCH(QString, fileName);
+ QFETCH(QString, fileName);
QFETCH(QString, url);
// open the resource so we can find out its size
@@ -1107,7 +1110,7 @@ void tst_QNetworkReply::getFromFtp_data()
void tst_QNetworkReply::getFromFtp()
{
- QFETCH(QString, referenceName);
+ QFETCH(QString, referenceName);
QFETCH(QString, url);
QFile reference(referenceName);
@@ -1136,7 +1139,7 @@ void tst_QNetworkReply::getFromHttp_data()
void tst_QNetworkReply::getFromHttp()
{
- QFETCH(QString, referenceName);
+ QFETCH(QString, referenceName);
QFETCH(QString, url);
QFile reference(referenceName);
@@ -3456,8 +3459,8 @@ void tst_QNetworkReply::downloadProgress_data()
QTest::newRow("big") << 4096;
#else
// it can run even with 4096
- // but it takes lot time
- //especially on emulator
+ // but it takes lot time
+ //especially on emulator
QTest::newRow("big") << 1024;
#endif
}
@@ -3646,7 +3649,7 @@ void tst_QNetworkReply::receiveCookiesFromHttp_data()
void tst_QNetworkReply::receiveCookiesFromHttp()
{
- QFETCH(QString, cookieString);
+ QFETCH(QString, cookieString);
QByteArray data = cookieString.toLatin1() + '\n';
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi");
diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp
index 49bddb2..8b79533 100644
--- a/tests/auto/qprinter/tst_qprinter.cpp
+++ b/tests/auto/qprinter/tst_qprinter.cpp
@@ -110,6 +110,7 @@ private slots:
void testCurrentPage();
void taskQTBUG4497_reusePrinterOnDifferentFiles();
+ void testPdfTitle();
private:
};
@@ -417,7 +418,7 @@ void tst_QPrinter::testMargins()
printer.setFullPage(fullpage);
printer.setPageSize((QPrinter::PageSize)pagesize);
if (withPainter)
- painter = new QPainter(&printer);
+ painter = new QPainter(&printer);
#ifdef QT3_SUPPORT
Q3PaintDeviceMetrics metrics(&printer);
@@ -1028,5 +1029,30 @@ void tst_QPrinter::testCurrentPage()
}
+void tst_QPrinter::testPdfTitle()
+{
+ // Check the document name is represented correctly in produced pdf
+ {
+ QPainter painter;
+ QPrinter printer;
+ // This string is just the UTF-8 encoding of the string: \()f &oslash; hiragana o
+ const char title[]={0x5c, 0x28, 0x29, 0x66, 0xc3, 0xb8, 0xe3, 0x81, 0x8a, 0x00};
+ printer.setOutputFileName("file.pdf");
+ printer.setDocName(QString::fromUtf8(title));
+ painter.begin(&printer);
+ painter.end();
+ }
+ QFile file("file.pdf");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ // The we expect the title to appear in the PDF as:
+ // ASCII('\title (') UTF16(\\\(\)f &oslash; hiragana o) ASCII(')').
+ // which has the following binary representation
+ const char expected[] = {
+ 0x2f, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x20, 0x28, 0xfe,
+ 0xff, 0x00, 0x5c, 0x5c, 0x00, 0x5c, 0x28, 0x00, 0x5c,
+ 0x29, 0x00, 0x66, 0x00, 0xf8, 0x30, 0x4a, 0x29};
+ QVERIFY(file.readAll().contains(QByteArray(expected, 26)));
+}
+
QTEST_MAIN(tst_QPrinter)
#include "tst_qprinter.moc"
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 849b8b2..ea527de 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -133,6 +133,7 @@ private slots:
void twoAnimations();
void deletedInUpdateCurrentTime();
void totalDuration();
+ void zeroLoopCount();
};
tst_QPropertyAnimation::tst_QPropertyAnimation()
@@ -1214,6 +1215,29 @@ void tst_QPropertyAnimation::totalDuration()
QCOMPARE(anim.totalDuration(), 0);
}
+void tst_QPropertyAnimation::zeroLoopCount()
+{
+ DummyPropertyAnimation* anim;
+ anim = new DummyPropertyAnimation;
+ anim->setStartValue(0);
+ anim->setDuration(20);
+ anim->setLoopCount(0);
+
+ QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QSignalSpy finishedSpy(anim, SIGNAL(finished()));
+
+ QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim->currentValue().toInt(), 0);
+ QCOMPARE(runningSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ anim->start();
+
+ QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QCOMPARE(anim->currentValue().toInt(), 0);
+ QCOMPARE(runningSpy.count(), 0);
+ QCOMPARE(finishedSpy.count(), 0);
+}
QTEST_MAIN(tst_QPropertyAnimation)
#include "tst_qpropertyanimation.moc"
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 2339b21..992c95e 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -138,6 +138,7 @@ private slots:
void taskQTBUG_6205_doubleProxySelectionSetSourceModel();
void taskQTBUG_7537_appearsAndSort();
void taskQTBUG_7716_unnecessaryDynamicSorting();
+ void taskQTBUG_10287_unnecessaryMapCreation();
void testMultipleProxiesWithSelection();
@@ -3038,5 +3039,65 @@ void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection()
}
+class Model10287 : public QStandardItemModel
+{
+ Q_OBJECT
+
+public:
+ Model10287(QObject *parent = 0)
+ : QStandardItemModel(0, 1, parent)
+ {
+ parentItem = new QStandardItem("parent");
+ parentItem->setData(false, Qt::UserRole);
+ appendRow(parentItem);
+
+ childItem = new QStandardItem("child");
+ childItem->setData(true, Qt::UserRole);
+ parentItem->appendRow(childItem);
+
+ childItem2 = new QStandardItem("child2");
+ childItem2->setData(true, Qt::UserRole);
+ parentItem->appendRow(childItem2);
+ }
+
+ void removeChild()
+ {
+ childItem2->setData(false, Qt::UserRole);
+ parentItem->removeRow(0);
+ }
+
+private:
+ QStandardItem *parentItem, *childItem, *childItem2;
+};
+
+class Proxy10287 : public QSortFilterProxyModel
+{
+ Q_OBJECT
+
+public:
+ Proxy10287(QAbstractItemModel *model, QObject *parent = 0)
+ : QSortFilterProxyModel(parent)
+ {
+ setSourceModel(model);
+ setDynamicSortFilter(true);
+ }
+
+protected:
+ virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
+ {
+ // Filter based on UserRole in model
+ QModelIndex i = sourceModel()->index(source_row, 0, source_parent);
+ return i.data(Qt::UserRole).toBool();
+ }
+};
+
+void tst_QSortFilterProxyModel::taskQTBUG_10287_unnecessaryMapCreation()
+{
+ Model10287 m;
+ Proxy10287 p(&m);
+ m.removeChild();
+ // No assert failure, it passes.
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index e0512a9..e370309 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -98,6 +98,7 @@ private slots:
void complexWidgetFocus();
void task188195_baseBackground();
void task232085_spinBoxLineEditBg();
+ void changeStyleInChangeEvent();
//at the end because it mess with the style.
void widgetStyle();
@@ -1256,7 +1257,7 @@ void tst_QStyleSheetStyle::proxyStyle()
QStyleOptionViewItemV4 opt;
opt.initFrom(w);
opt.features |= QStyleOptionViewItemV2::HasCheckIndicator;
- QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator,
+ QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator,
&opt, pb5).width() == 3);
delete w;
delete proxy;
@@ -1579,6 +1580,34 @@ void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()
.toLocal8Bit().constData());
}
+class ChangeEventWidget : public QWidget
+{ public:
+ void changeEvent(QEvent * event)
+ {
+ if(event->type() == QEvent::StyleChange) {
+ static bool recurse = false;
+ if (!recurse) {
+ recurse = true;
+ QStyle *style = new QMotifStyle;
+ style->setParent(this);
+ setStyle(style);
+ recurse = false;
+ }
+ }
+ QWidget::changeEvent(event);
+ }
+};
+
+void tst_QStyleSheetStyle::changeStyleInChangeEvent()
+{ //must not crash;
+ ChangeEventWidget wid;
+ wid.ensurePolished();
+ wid.setStyleSheet(" /* */ ");
+ wid.ensurePolished();
+ wid.setStyleSheet(" /* ** */ ");
+ wid.ensurePolished();
+}
+
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"
diff --git a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
index 5dfcd43..53dc4b5 100644
--- a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp
@@ -51,6 +51,8 @@
#include <qmainwindow.h>
#include <qmenubar.h>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -190,8 +192,8 @@ void tst_QWidgetAction::visibilityUpdate()
QVERIFY(action->isVisible());
action->setVisible(false);
- QTest::qWait(100); //the call to hide is delayed by the toolbar layout
- QVERIFY(!combo->isVisible());
+ qApp->processEvents(); //the call to hide is delayed by the toolbar layout
+ QTRY_VERIFY(!combo->isVisible());
delete action;
// action also deletes combo
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index be0d708..6fd9b93 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -857,7 +857,7 @@ void tst_QXmlQuery::bindVariableXSLTSuccess() const
stylesheet.bindVariable(QLatin1String("paramSelectWithTypeIntBoundWithBindVariableRequired"),
QVariant(QLatin1String("param5")));
- stylesheet.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl"))));
+ stylesheet.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/parameters.xsl"))));
QVERIFY(stylesheet.isValid());
@@ -1798,11 +1798,11 @@ void tst_QXmlQuery::setFocusQUrl() const
{
QXmlQuery query(QXmlQuery::XSLT20);
- const TestURIResolver resolver(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
+ const TestURIResolver resolver(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
query.setUriResolver(&resolver);
QVERIFY(query.setFocus(QUrl(QLatin1String("arbitraryURI"))));
- query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl"))));
+ query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/copyWholeDocument.xsl"))));
QVERIFY(query.isValid());
QBuffer result;
@@ -2997,7 +2997,7 @@ void tst_QXmlQuery::setInitialTemplateNameQXmlName() const
QCOMPARE(query.initialTemplateName(), name);
- query.setQuery(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl"))));
+ query.setQuery(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/namedTemplate.xsl"))));
QVERIFY(query.isValid());
QBuffer result;
@@ -3059,7 +3059,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const
/* Ensure fn:doc() picks up the right QNetworkAccessManager. */
{
NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")),
- QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml"))));
+ QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml"))));
QXmlQuery query;
query.setNetworkAccessManager(&networkOverrider);
@@ -3075,7 +3075,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const
/* Ensure setQuery() is using the right network manager. */
{
NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")),
- QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq"))));
+ QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/queries/concat.xq"))));
QXmlQuery query;
query.setNetworkAccessManager(&networkOverrider);
@@ -3135,7 +3135,7 @@ void tst_QXmlQuery::multipleDocsAndFocus() const
query.setQuery(QLatin1String("string(doc('") +
inputFile(QLatin1String(SRCDIR "../xmlpatterns/queries/simpleDocument.xml")) +
QLatin1String("'))"));
- query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
+ query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
query.setQuery(QLatin1String("string(.)"));
QStringList result;
@@ -3159,11 +3159,11 @@ void tst_QXmlQuery::multipleEvaluationsWithDifferentFocus() const
QXmlQuery query;
QStringList result;
- query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
+ query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
query.setQuery(QLatin1String("string(.)"));
QVERIFY(query.evaluateTo(&result));
- query.setFocus(QUrl(inputFile(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
+ query.setFocus(QUrl(inputFileAsURI(QLatin1String(SRCDIR "../xmlpatterns/stylesheets/documentElement.xml"))));
QVERIFY(query.evaluateTo(&result));
}
diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
index 64120c7..ec63858 100644
--- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
+++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
@@ -89,10 +89,17 @@ void tst_SuiteTest::runTestSuite() const
TestSuite::SuiteType suiteType;
switch (m_suiteType) {
- case XQuerySuite: suiteType = TestSuite::XQuerySuite;
- case XsltSuite: suiteType = TestSuite::XsltSuite;
- case XsdSuite: suiteType = TestSuite::XsdSuite;
- default: break;
+ case XQuerySuite:
+ suiteType = TestSuite::XQuerySuite;
+ break;
+ case XsltSuite:
+ suiteType = TestSuite::XsltSuite;
+ break;
+ case XsdSuite:
+ suiteType = TestSuite::XsdSuite;
+ break;
+ default:
+ break;
}
TestSuite *const ts = TestSuite::openCatalog(catalogPath, errMsg, true, suiteType);
diff --git a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
index 9ffbefb..8e9de4a 100644
--- a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
@@ -43,6 +43,7 @@
#include <QPixmap>
#include <QBitmap>
#include <QPainter>
+#include <private/qpixmap_raster_p.h>
class tst_QPixmap : public QObject
{
@@ -67,6 +68,31 @@ Q_DECLARE_METATYPE(QImage::Format)
Q_DECLARE_METATYPE(Qt::AspectRatioMode)
Q_DECLARE_METATYPE(Qt::TransformationMode)
+QPixmap rasterPixmap(int width, int height)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->resize(width, height);
+
+ return QPixmap(data);
+}
+
+QPixmap rasterPixmap(const QSize &size)
+{
+ return rasterPixmap(size.width(), size.height());
+}
+
+QPixmap rasterPixmap(const QImage &image)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->fromImage(image, Qt::AutoColor);
+
+ return QPixmap(data);
+}
+
tst_QPixmap::tst_QPixmap()
{
}
@@ -90,7 +116,7 @@ void tst_QPixmap::fill()
QFETCH(int, height);
const QColor color = opaque ? QColor(255, 0, 0) : QColor(255, 0, 0, 200);
- QPixmap pixmap(width, height);
+ QPixmap pixmap = rasterPixmap(width, height);
QBENCHMARK {
pixmap.fill(color);
@@ -126,8 +152,8 @@ void tst_QPixmap::scaled()
QFETCH(Qt::AspectRatioMode, ratioMode);
QFETCH(Qt::TransformationMode, transformMode);
- QPixmap opaque(size);
- QPixmap transparent(size);
+ QPixmap opaque = rasterPixmap(size);
+ QPixmap transparent = rasterPixmap(size);
opaque.fill(QColor(255, 0, 0));
transparent.fill(QColor(255, 0, 0, 200));
@@ -180,8 +206,8 @@ void tst_QPixmap::transformed()
QFETCH(QTransform, transform);
QFETCH(Qt::TransformationMode, transformMode);
- QPixmap opaque(size);
- QPixmap transparent(size);
+ QPixmap opaque = rasterPixmap(size);
+ QPixmap transparent = rasterPixmap(size);
opaque.fill(QColor(255, 0, 0));
transparent.fill(QColor(255, 0, 0, 200));
@@ -209,7 +235,7 @@ void tst_QPixmap::mask()
{
QFETCH(QSize, size);
- QPixmap src(size);
+ QPixmap src = rasterPixmap(size);
src.fill(Qt::transparent);
{
QPainter p(&src);
diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
index d570bb3..318b671 100644
--- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
@@ -50,6 +50,8 @@
#define M_PI 3.14159265358979323846
#endif
+#include <private/qpixmap_raster_p.h>
+
Q_DECLARE_METATYPE(QLine)
Q_DECLARE_METATYPE(QRect)
Q_DECLARE_METATYPE(QSize)
@@ -125,6 +127,32 @@ struct PrimitiveSet {
};
+QPixmap rasterPixmap(int width, int height)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->resize(width, height);
+
+ return QPixmap(data);
+}
+
+QPixmap rasterPixmap(const QSize &size)
+{
+ return rasterPixmap(size.width(), size.height());
+}
+
+QPixmap rasterPixmap(const QImage &image)
+{
+ QPixmapData *data =
+ new QRasterPixmapData(QPixmapData::PixmapType);
+
+ data->fromImage(image, Qt::AutoColor);
+
+ return QPixmap(data);
+}
+
+
class tst_QPainter : public QObject
{
Q_OBJECT
@@ -222,7 +250,8 @@ private:
QPaintDevice *surface()
{
- return new QPixmap(1024, 1024);
+ m_pixmap = rasterPixmap(1024, 1024);
+ return &m_pixmap;
}
@@ -233,6 +262,7 @@ private:
PrimitiveSet m_primitives_100;
PrimitiveSet m_primitives_1000;
+ QPixmap m_pixmap;
QPaintDevice *m_surface;
QPainter m_painter;
@@ -490,7 +520,7 @@ void tst_QPainter::setupBrushes()
void tst_QPainter::beginAndEnd()
{
- QPixmap pixmap(100, 100);
+ QPixmap pixmap = rasterPixmap(100, 100);
QBENCHMARK {
QPainter p;
@@ -505,10 +535,11 @@ void tst_QPainter::drawLine()
QFETCH(QPen, pen);
const int offset = 5;
- QPixmap pixmapUnclipped(qMin(line.x1(), line.x2())
- + 2*offset + qAbs(line.dx()),
- qMin(line.y1(), line.y2())
- + 2*offset + qAbs(line.dy()));
+ QPixmap pixmapUnclipped =
+ rasterPixmap(qMin(line.x1(), line.x2())
+ + 2*offset + qAbs(line.dx()),
+ qMin(line.y1(), line.y2())
+ + 2*offset + qAbs(line.dy()));
pixmapUnclipped.fill(Qt::white);
QPainter p(&pixmapUnclipped);
@@ -535,10 +566,11 @@ void tst_QPainter::drawLine_clipped()
QFETCH(QPen, pen);
const int offset = 5;
- QPixmap pixmapClipped(qMin(line.x1(), line.x2())
- + 2*offset + qAbs(line.dx()),
- qMin(line.y1(), line.y2())
- + 2*offset + qAbs(line.dy()));
+ QPixmap pixmapClipped
+ = rasterPixmap(qMin(line.x1(), line.x2())
+ + 2*offset + qAbs(line.dx()),
+ qMin(line.y1(), line.y2())
+ + 2*offset + qAbs(line.dy()));
const QRect clip = QRect(line.p1(), line.p2()).normalized();
@@ -569,10 +601,11 @@ void tst_QPainter::drawLine_antialiased_clipped()
QFETCH(QPen, pen);
const int offset = 5;
- QPixmap pixmapClipped(qMin(line.x1(), line.x2())
- + 2*offset + qAbs(line.dx()),
- qMin(line.y1(), line.y2())
- + 2*offset + qAbs(line.dy()));
+ QPixmap pixmapClipped
+ = rasterPixmap(qMin(line.x1(), line.x2())
+ + 2*offset + qAbs(line.dx()),
+ qMin(line.y1(), line.y2())
+ + 2*offset + qAbs(line.dy()));
const QRect clip = QRect(line.p1(), line.p2()).normalized();
@@ -696,8 +729,8 @@ void tst_QPainter::drawPixmap()
QImage sourceImage = createImage(type, size).convertToFormat(sourceFormat);
QImage targetImage(size, targetFormat);
- QPixmap sourcePixmap = QPixmap::fromImage(sourceImage);
- QPixmap targetPixmap = QPixmap::fromImage(targetImage);
+ QPixmap sourcePixmap = rasterPixmap(sourceImage);
+ QPixmap targetPixmap = rasterPixmap(targetImage);
QPainter p(&targetPixmap);
@@ -759,10 +792,10 @@ void tst_QPainter::compositionModes()
QFETCH(QSize, size);
QFETCH(QColor, color);
- QPixmap src(size);
+ QPixmap src = rasterPixmap(size);
src.fill(color);
- QPixmap dest(size);
+ QPixmap dest = rasterPixmap(size);
if (mode < QPainter::RasterOp_SourceOrDestination)
color.setAlpha(127); // porter-duff needs an alpha channel
dest.fill(color);
@@ -844,11 +877,11 @@ void tst_QPainter::drawTiledPixmap()
QFETCH(QColor, color);
QFETCH(QPainter::RenderHint, renderHint);
- QPixmap src(srcSize);
+ QPixmap src = rasterPixmap(srcSize);
src.fill(color);
const QRect dstRect = transform.mapRect(QRect(QPoint(), dstSize));
- QPixmap dst(dstRect.right() + 5, dstRect.bottom() + 5);
+ QPixmap dst = rasterPixmap(dstRect.right() + 5, dstRect.bottom() + 5);
QPainter p(&dst);
p.setTransform(transform);
p.setRenderHint(renderHint);
@@ -1411,7 +1444,7 @@ void tst_QPainter::drawBorderPixmapRoundedRect()
rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius);
else
rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius);
- QPixmap rectPixmap = QPixmap::fromImage(rectImage);
+ QPixmap rectPixmap = rasterPixmap(rectImage);
//setup surface
QImage surface(100, 100, QImage::Format_RGB16);
@@ -1466,7 +1499,7 @@ void tst_QPainter::drawScaledBorderPixmapRoundedRect()
else
rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius);
- QPixmap rectPixmap = QPixmap::fromImage(rectImage);
+ QPixmap rectPixmap = rasterPixmap(rectImage);
//setup surface
QImage surface(400, 400, QImage::Format_RGB16);
@@ -1522,7 +1555,7 @@ void tst_QPainter::drawTransformedBorderPixmapRoundedRect()
else
rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius);
- QPixmap rectPixmap = QPixmap::fromImage(rectImage);
+ QPixmap rectPixmap = rasterPixmap(rectImage);
//setup surface
QImage surface(400, 400, QImage::Format_RGB16);