summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp17
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp23
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp16
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp16
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp16
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/data/daniel.ttfbin0 -> 51984 bytes
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp42
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp21
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp311
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml14
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/datamodel.qml1
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp23
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml25
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/editProperties.qml34
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange6.qml30
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp172
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cb.pngbin496 -> 496 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cc.pngbin556 -> 556 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_ct.pngbin533 -> 533 bytes
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml11
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml11
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp82
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp67
-rw-r--r--tests/auto/gestures/tst_gestures.cpp26
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt1
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp41
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result16
-rw-r--r--tests/auto/linguist/lupdate/tst_lupdate.cpp9
-rw-r--r--tests/auto/moc/tst_moc.cpp8
-rw-r--r--tests/auto/q3table/tst_q3table.cpp8
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp4
-rw-r--r--tests/auto/qfontdatabase/tst_qfontdatabase.cpp35
-rw-r--r--tests/auto/qglthreads/tst_qglthreads.cpp160
-rw-r--r--tests/auto/qglthreads/tst_qglthreads.h2
-rw-r--r--tests/auto/qglyphs/tst_qglyphs.cpp8
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp81
-rw-r--r--tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp8
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp20
-rw-r--r--tests/auto/qimagereader/images/qtbug13653-no_eoi.jpgbin0 -> 8250 bytes
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc1
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp5
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp18
-rw-r--r--tests/auto/qlist/tst_qlist.cpp2
-rw-r--r--tests/auto/qmainwindow/tst_qmainwindow.cpp3
-rw-r--r--tests/auto/qobject/tst_qobject.cpp8
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp69
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp5
-rw-r--r--tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp22
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp4
-rw-r--r--tests/auto/qsettings/tst_qsettings.cpp63
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp39
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp13
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp69
-rw-r--r--tests/auto/qurl/tst_qurl.cpp10
-rw-r--r--tests/auto/qvector/tst_qvector.cpp2
60 files changed, 1546 insertions, 212 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
index 1001278735..da15a855e4 100644
--- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
@@ -47,22 +47,13 @@
#include <private/qdeclarativeanimatedimage_p.h>
#include "../shared/testhttpserver.h"
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
#define SRCDIR "."
#endif
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
class tst_qdeclarativeanimatedimage : public QObject
{
Q_OBJECT
@@ -152,14 +143,14 @@ void tst_qdeclarativeanimatedimage::remote()
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
- TRY_WAIT(component.isReady());
+ QTRY_VERIFY(component.isReady());
QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
QVERIFY(anim);
- TRY_WAIT(anim->isPlaying());
+ QTRY_VERIFY(anim->isPlaying());
if (paused) {
- TRY_WAIT(anim->isPaused());
+ QTRY_VERIFY(anim->isPaused());
QCOMPARE(anim->currentFrame(), 2);
}
QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error);
diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
index 1b73cf7ae8..c77d395ac7 100644
--- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
+++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
@@ -53,6 +53,7 @@
#include <QtDeclarative/qdeclarativecontext.h>
#include "../shared/testhttpserver.h"
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -62,16 +63,6 @@
#define SERVER_PORT 14446
#define SERVER_ADDR "http://127.0.0.1:14446"
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 60; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
class tst_qdeclarativeborderimage : public QObject
{
@@ -154,18 +145,18 @@ void tst_qdeclarativeborderimage::imageSource()
QVERIFY(obj != 0);
if (remote)
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready);
QCOMPARE(obj->width(), 120.);
QCOMPARE(obj->height(), 120.);
QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
} else {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error);
}
delete obj;
@@ -273,14 +264,14 @@ void tst_qdeclarativeborderimage::sciSource()
QVERIFY(obj != 0);
if (remote)
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading);
QCOMPARE(obj->source(), remote ? source : QUrl(source));
QCOMPARE(obj->width(), 300.);
QCOMPARE(obj->height(), 300.);
if (valid) {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready);
QCOMPARE(obj->border()->left(), 10);
QCOMPARE(obj->border()->top(), 20);
QCOMPARE(obj->border()->right(), 30);
@@ -288,7 +279,7 @@ void tst_qdeclarativeborderimage::sciSource()
QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round);
QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat);
} else {
- TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error);
}
delete obj;
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
index 20ccccbb90..adba190390 100644
--- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -279,7 +279,7 @@ void tst_QDeclarativeDebug::initTestCase()
qRegisterMetaType<QDeclarativeDebugWatch::State>();
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768...");
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
+
m_engine = new QDeclarativeEngine(this);
QList<QByteArray> qml;
@@ -891,6 +891,18 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
compareProperties(r, ref);
}
-QTEST_MAIN(tst_QDeclarativeDebug)
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3768";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebug tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebug.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
index a19c2c24fb..7db0e60014 100644
--- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -76,7 +76,6 @@ void tst_QDeclarativeDebugClient::initTestCase()
{
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3770...");
- qputenv("QML_DEBUG_SERVER_PORT", "3770");
new QDeclarativeEngine(this);
m_conn = new QDeclarativeDebugConnection(this);
@@ -151,7 +150,19 @@ void tst_QDeclarativeDebugClient::sendMessage()
QCOMPARE(resp, msg);
}
-QTEST_MAIN(tst_QDeclarativeDebugClient)
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3770";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebugClient tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebugclient.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
index 9ebbbaf7a0..4683199e38 100644
--- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
+++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
@@ -77,7 +77,6 @@ private slots:
void tst_QDeclarativeDebugService::initTestCase()
{
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3769...");
- qputenv("QML_DEBUG_SERVER_PORT", "3769");
new QDeclarativeEngine(this);
m_conn = new QDeclarativeDebugConnection(this);
@@ -184,6 +183,19 @@ void tst_QDeclarativeDebugService::objectToString()
delete obj;
}
-QTEST_MAIN(tst_QDeclarativeDebugService)
+
+int main(int argc, char *argv[])
+{
+ int _argc = argc + 1;
+ char **_argv = new char*[_argc];
+ for (int i = 0; i < argc; ++i)
+ _argv[i] = argv[i];
+ _argv[_argc - 1] = "-qmljsdebugger=port:3769";
+
+ QApplication app(_argc, _argv);
+ tst_QDeclarativeDebugService tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
#include "tst_qdeclarativedebugservice.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 33bf7ea589..c10a110985 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -52,6 +52,7 @@
#include <private/qdeclarativeglobalscriptclass_p.h>
#include "testtypes.h"
#include "testhttpserver.h"
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -2416,15 +2417,6 @@ 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()
{
@@ -2496,8 +2488,8 @@ void tst_qdeclarativeecmascript::include()
QObject *o = component.create();
QVERIFY(o != 0);
- TRY_WAIT(o->property("done").toBool() == true);
- TRY_WAIT(o->property("done2").toBool() == true);
+ QTRY_VERIFY(o->property("done").toBool() == true);
+ QTRY_VERIFY(o->property("done2").toBool() == true);
QCOMPARE(o->property("test1").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
@@ -2524,7 +2516,7 @@ void tst_qdeclarativeecmascript::include()
QObject *o = component.create();
QVERIFY(o != 0);
- TRY_WAIT(o->property("done").toBool() == true);
+ QTRY_VERIFY(o->property("done").toBool() == true);
QCOMPARE(o->property("test1").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
diff --git a/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf b/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf
new file mode 100644
index 0000000000..aae50d5035
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
index ae23017bdf..87654267ab 100644
--- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -39,8 +39,10 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativecontext.h>
#include <private/qdeclarativefontloader_p.h>
#include "../../../shared/util.h"
#include "../shared/testhttpserver.h"
@@ -67,6 +69,7 @@ private slots:
void webFont();
void redirWebFont();
void failWebFont();
+ void changeFont();
private slots:
@@ -181,6 +184,45 @@ void tst_qdeclarativefontloader::failWebFont()
QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
}
+void tst_qdeclarativefontloader::changeFont()
+{
+ QString componentStr = "import Qt 4.7\nFontLoader { source: font }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+
+ QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
+ QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
+
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 0);
+ QCOMPARE(statusSpy.count(), 0);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Loading);
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 1);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+
+ ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 2);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 3);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+}
+
QTEST_MAIN(tst_qdeclarativefontloader)
#include "tst_qdeclarativefontloader.moc"
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index d4d8bf6e80..5fd373cad4 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -604,6 +604,8 @@ void tst_QDeclarativeGridView::currentIndex()
// no wrap
gridview->setCurrentIndex(0);
QCOMPARE(gridview->currentIndex(), 0);
+ // confirm that the velocity is updated
+ QTRY_VERIFY(gridview->verticalVelocity() != 0.0);
gridview->moveCurrentIndexUp();
QCOMPARE(gridview->currentIndex(), 0);
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
index d0afc8a688..d38160d28f 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -45,26 +45,15 @@
#include <private/qdeclarativeimage_p.h>
#include <QImageReader>
#include <QWaitCondition>
+#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
#define SRCDIR "."
#endif
-// QDeclarativeImageProvider::request() is run in an idle thread where possible
-// Be generous in our timeout.
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 10; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(100); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
Q_DECLARE_METATYPE(QDeclarativeImageProvider*);
-
class tst_qdeclarativeimageprovider : public QObject
{
Q_OBJECT
@@ -212,13 +201,13 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide
QVERIFY(obj != 0);
if (async)
- TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading);
QCOMPARE(obj->source(), QUrl(source));
if (error.isEmpty()) {
if (async)
- TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
else
QVERIFY(obj->status() == QDeclarativeImage::Ready);
QCOMPARE(obj->width(), qreal(size.width()));
@@ -229,7 +218,7 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide
QCOMPARE(obj->progress(), 1.0);
} else {
if (async)
- TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Error);
else
QVERIFY(obj->status() == QDeclarativeImage::Error);
}
@@ -391,7 +380,7 @@ void tst_qdeclarativeimageprovider::threadTest()
provider->cond.wakeAll();
QTest::qWait(250);
foreach(QDeclarativeImage *img, images) {
- TRY_WAIT(img->status() == QDeclarativeImage::Ready);
+ QTRY_VERIFY(img->status() == QDeclarativeImage::Ready);
}
}
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 10805b44c7..f4567788c6 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -49,6 +49,7 @@
#include <QtCore/qtimer.h>
#include <QtCore/qdebug.h>
#include <QtCore/qtranslator.h>
+#include <QSignalSpy>
#include "../../../shared/util.h"
@@ -57,6 +58,8 @@
#define SRCDIR "."
#endif
+Q_DECLARE_METATYPE(QList<int>)
+
class tst_qdeclarativelistmodel : public QObject
{
Q_OBJECT
@@ -64,6 +67,7 @@ public:
tst_qdeclarativelistmodel() {}
private:
+ int roleFromName(const QDeclarativeListModel *model, const QString &roleName);
QScriptValue nestedListValue(QScriptEngine *eng) const;
QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model);
void waitForWorker(QDeclarativeItem *item);
@@ -78,6 +82,8 @@ private slots:
void dynamic();
void dynamic_worker_data();
void dynamic_worker();
+ void dynamic_worker_sync_data();
+ void dynamic_worker_sync();
void convertNestedToFlat_fail();
void convertNestedToFlat_fail_data();
void convertNestedToFlat_ok();
@@ -86,7 +92,23 @@ private slots:
void error_data();
void error();
void set();
+ void get();
+ void get_data();
+ void get_worker();
+ void get_worker_data();
+ void get_nested();
+ void get_nested_data();
};
+int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName)
+{
+ QList<int> roles = model->roles();
+ for (int i=0; i<roles.count(); i++) {
+ if (model->toString(roles[i]) == roleName)
+ return roles[i];
+ }
+ Q_ASSERT(false);
+ return -1;
+}
QScriptValue tst_qdeclarativelistmodel::nestedListValue(QScriptEngine *eng) const
{
@@ -196,6 +218,10 @@ void tst_qdeclarativelistmodel::dynamic_data()
QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "";
QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "";
QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "";
+ QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "";
+
+ QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "";
+ QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "";
QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
@@ -310,8 +336,12 @@ void tst_qdeclarativelistmodel::dynamic_worker()
QFETCH(int, result);
QFETCH(QString, warning);
+ if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
+ return;
+
// This is same as dynamic() except it applies the test to a ListModel called
- // from a WorkerScript (i.e. testing the internal NestedListModel class)
+ // from a WorkerScript (i.e. testing the internal FlatListModel that is created
+ // by the WorkerListModelAgent)
QDeclarativeListModel model;
QDeclarativeEngine eng;
@@ -330,27 +360,62 @@ void tst_qdeclarativelistmodel::dynamic_worker()
if (!warning.isEmpty())
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
- if (operations.count() == 1) {
- // test count(), get() return the correct default values in the worker list model
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations)));
- waitForWorker(item);
- QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result);
- } else {
- // execute a set of commands on the worker list model, then check the
- // changes are reflected in the list model in the main thread
- if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: Cannot add nested list values when modifying or after modification from a worker script");
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
- waitForWorker(item);
-
- QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString());
- if (!QByteArray(QTest::currentDataTag()).startsWith("nested"))
- QCOMPARE(e.evaluate().toInt(), result);
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations)));
+ waitForWorker(item);
+ QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result);
+
+ delete item;
+ qApp->processEvents();
+}
+
+
+
+void tst_qdeclarativelistmodel::dynamic_worker_sync_data()
+{
+ dynamic_data();
+}
+
+void tst_qdeclarativelistmodel::dynamic_worker_sync()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+
+ // This is the same as dynamic_worker() except that it executes a set of list operations
+ // from the worker script, calls sync(), and tests the changes are reflected in the
+ // list in the main thread
+
+ QDeclarativeListModel model;
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
+ script = script.mid(1, script.length() - 2);
+ QVariantList operations;
+ foreach (const QString &s, script.split(';')) {
+ if (!s.isEmpty())
+ operations << s;
}
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ // execute a set of commands on the worker list model, then check the
+ // changes are reflected in the list model in the main thread
+ if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script");
+
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ waitForWorker(item);
+
+ QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString());
+ if (!QByteArray(QTest::currentDataTag()).startsWith("nested"))
+ QCOMPARE(e.evaluate().toInt(), result);
+
delete item;
qApp->processEvents();
}
@@ -374,7 +439,7 @@ void tst_qdeclarativelistmodel::convertNestedToFlat_fail()
model.append(nestedListValue(&s_eng));
QCOMPARE(model.count(), 2);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: List contains nested list values and cannot be used from a worker script");
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: List contains list-type data and cannot be used from a worker script");
QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script)));
waitForWorker(item);
@@ -426,7 +491,7 @@ void tst_qdeclarativelistmodel::convertNestedToFlat_ok()
QCOMPARE(model.count(), count+1);
QScriptValue nested = nestedListValue(&s_eng);
- const char *warning = "<Unknown File>: QML ListModel: Cannot add nested list values when modifying or after modification from a worker script";
+ const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
QTest::ignoreMessage(QtWarningMsg, warning);
model.append(nested);
@@ -595,6 +660,9 @@ void tst_qdeclarativelistmodel::error()
}
}
+/*
+ Test model changes from set() are available to the view
+*/
void tst_qdeclarativelistmodel::set()
{
QDeclarativeEngine engine;
@@ -618,6 +686,205 @@ void tst_qdeclarativelistmodel::set()
QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
}
+/*
+ Test model changes on values returned by get() are available to the view
+*/
+void tst_qdeclarativelistmodel::get()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng);
+ component.setData(
+ "import Qt 4.7\n"
+ "ListModel { \n"
+ "ListElement { roleA: 100 }\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "}", QUrl());
+ QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
+ int role = roleFromName(model, roleName);
+
+ QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
+ QDeclarativeExpression expr(eng.rootContext(), model, expression);
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ QCOMPARE(model->data(index, role), roleValue);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
+}
+
+void tst_qdeclarativelistmodel::get_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<QVariant>("roleValue");
+
+ QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500);
+ QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500);
+
+ QVariantMap map;
+ map["zzz"] = 123;
+ QTest::newRow("object value") << "get(1).roleB = {'zzz':123}" << 1 << "roleB" << QVariant::fromValue(map);
+
+ QVariantList list;
+ map.clear(); map["a"] = 50; map["b"] = 500;
+ list << map;
+ map.clear(); map["c"] = 1000;
+ list << map;
+ QTest::newRow("list of objects") << "get(2).roleB = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleB" << QVariant::fromValue(list);
+}
+
+void tst_qdeclarativelistmodel::get_worker()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+
+ QDeclarativeListModel model;
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+ QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(&eng);
+
+ // Add some values like get() test
+ QScriptValue sv = seng->newObject();
+ sv.setProperty(QLatin1String("roleA"), seng->newVariant(QVariant::fromValue(100)));
+ model.append(sv);
+ sv = seng->newObject();
+ sv.setProperty(QLatin1String("roleA"), seng->newVariant(QVariant::fromValue(200)));
+ sv.setProperty(QLatin1String("roleB"), seng->newVariant(QVariant::fromValue(400)));
+ model.append(sv);
+ model.append(sv);
+ int role = roleFromName(&model, roleName);
+
+ const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
+ if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map)
+ QTest::ignoreMessage(QtWarningMsg, warning);
+ QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
+
+ // in the worker thread, change the model data and call sync()
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, QStringList(expression))));
+ waitForWorker(item);
+
+ // see if we receive the model changes in the main thread's model
+ if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) {
+ QVERIFY(model.data(index, role) != roleValue);
+ QCOMPARE(spy.count(), 0);
+ } else {
+ QCOMPARE(model.data(index, role), roleValue);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QVERIFY(spyResult.at(2).value<QList<int> >().contains(role));
+ }
+}
+
+void tst_qdeclarativelistmodel::get_worker_data()
+{
+ get_data();
+}
+
+/*
+ Test that the tests run in get() also work for nested list data
+*/
+void tst_qdeclarativelistmodel::get_nested()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng);
+ component.setData(
+ "import Qt 4.7\n"
+ "ListModel { \n"
+ "ListElement {\n"
+ "listRoleA: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "}\n"
+ "ListElement {\n"
+ "listRoleA: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "listRoleB: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "listRoleC: [\n"
+ "ListElement { roleA: 100 },\n"
+ "ListElement { roleA: 200; roleB: 400 },\n"
+ "ListElement { roleA: 200; roleB: 400 } \n"
+ "]\n"
+ "}\n"
+ "}", QUrl());
+ QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(component.errorString().isEmpty());
+ QDeclarativeListModel *childModel;
+
+ // Test setting the inner list data for:
+ // get(0).listRoleA
+ // get(1).listRoleA
+ // get(1).listRoleB
+ // get(1).listRoleC
+
+ QList<QPair<int, QString> > testData;
+ testData << qMakePair(0, QString("listRoleA"));
+ testData << qMakePair(1, QString("listRoleA"));
+ testData << qMakePair(1, QString("listRoleB"));
+ testData << qMakePair(1, QString("listRoleC"));
+
+ for (int i=0; i<testData.count(); i++) {
+ int outerListIndex = testData[i].first;
+ QString outerListRoleName = testData[i].second;
+ int outerListRole = roleFromName(model, outerListRoleName);
+
+ childModel = qobject_cast<QDeclarativeListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
+ QVERIFY(childModel);
+
+ QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression);
+ QDeclarativeExpression expr(eng.rootContext(), model, extendedExpression);
+
+ QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>)));
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ int role = roleFromName(childModel, roleName);
+ QCOMPARE(childModel->data(index, role), roleValue);
+ QCOMPARE(spy.count(), 1);
+
+ QList<QVariant> spyResult = spy.takeFirst();
+ QCOMPARE(spyResult.at(0).toInt(), index);
+ QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
+ QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
+ }
+}
+
+void tst_qdeclarativelistmodel::get_nested_data()
+{
+ get_data();
+}
QTEST_MAIN(tst_qdeclarativelistmodel)
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index e4b59a711a..cd17fadb83 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -1016,6 +1016,8 @@ void tst_QDeclarativeListView::currentIndex()
// no wrap
listview->setCurrentIndex(0);
QCOMPARE(listview->currentIndex(), 0);
+ // confirm that the velocity is updated
+ QTRY_VERIFY(listview->verticalVelocity() != 0.0);
listview->incrementCurrentIndex();
QCOMPARE(listview->currentIndex(), 1);
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
index 3baf8481d0..b62392d326 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -61,15 +61,6 @@ inline QUrl TEST_FILE(const QString &filename)
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
}
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
class tst_QDeclarativeLoader : public QObject
{
@@ -460,7 +451,7 @@ void tst_QDeclarativeLoader::networkRequestUrl()
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
- TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+ QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
@@ -491,7 +482,7 @@ void tst_QDeclarativeLoader::networkComponent()
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
QVERIFY(loader);
- TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+ QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
@@ -515,7 +506,7 @@ void tst_QDeclarativeLoader::failNetworkRequest()
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
QVERIFY(loader != 0);
- TRY_WAIT(loader->status() == QDeclarativeLoader::Error);
+ QTRY_VERIFY(loader->status() == QDeclarativeLoader::Error);
QVERIFY(loader->item() == 0);
QCOMPARE(loader->progress(), 0.0);
diff --git a/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml b/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml
new file mode 100644
index 0000000000..9cddf1bb91
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+Item {
+ id: root
+ property int clicked: 0
+ property int doubleClicked: 0
+
+ MouseArea {
+ width: 200; height: 200
+ onClicked: { root.clicked++ }
+ onDoubleClicked: { root.doubleClicked++ }
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
index c9bb467fe0..e4ec01f63e 100644
--- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -62,6 +62,7 @@ private slots:
void updateMouseAreaPosOnResize();
void noOnClickedWithPressAndHold();
void onMousePressRejected();
+ void doubleClick();
private:
QDeclarativeView *createView();
@@ -390,6 +391,37 @@ void tst_QDeclarativeMouseArea::onMousePressRejected()
QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
}
+void tst_QDeclarativeMouseArea::doubleClick()
+{
+ QDeclarativeView *canvas = createView();
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/doubleclick.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QGraphicsScene *scene = canvas->scene();
+ QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
+ pressEvent.setScenePos(QPointF(100, 100));
+ pressEvent.setButton(Qt::LeftButton);
+ pressEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &pressEvent);
+
+ QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
+ releaseEvent.setScenePos(QPointF(100, 100));
+ releaseEvent.setButton(Qt::LeftButton);
+ releaseEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &releaseEvent);
+
+ QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick);
+ dblClickEvent.setScenePos(QPointF(100, 100));
+ dblClickEvent.setButton(Qt::LeftButton);
+ dblClickEvent.setButtons(Qt::LeftButton);
+ QApplication::sendEvent(scene, &dblClickEvent);
+
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1);
+}
+
QTEST_MAIN(tst_QDeclarativeMouseArea)
#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
index a5c3772efa..fb3c91008a 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
@@ -21,6 +21,7 @@ PathView {
Rectangle {
id: wrapper
objectName: "wrapper"
+ property bool onPath: PathView.onPath
width: 20; height: 20; color: name
Text {
objectName: "myText"
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 74d2f0a619..cbfbfbd715 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -152,27 +152,27 @@ public:
QString number(int index) const { return list.at(index).second; }
void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ beginInsertRows(QModelIndex(), list.count(), list.count());
list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
+ endInsertRows();
}
void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
+ beginInsertRows(QModelIndex(), index, index);
list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
+ endInsertRows();
}
void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
+ beginRemoveRows(QModelIndex(), index, index);
list.removeAt(index);
- emit endRemoveRows();
+ endRemoveRows();
}
void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
list.move(from, to);
- emit endMoveRows();
+ endMoveRows();
}
void modifyItem(int idx, const QString &name, const QString &number) {
@@ -411,6 +411,13 @@ void tst_QDeclarativePathView::dataModel()
QVERIFY(text);
QCOMPARE(text->text(), model.name(3));
+ model.moveItem(3, 5);
+ QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
+ QList<QDeclarativeItem*> items = findItems<QDeclarativeItem>(pathview, "wrapper");
+ foreach (QDeclarativeItem *item, items) {
+ QVERIFY(item->property("onPath").toBool());
+ }
+
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml
new file mode 100644
index 0000000000..4ed2815502
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml
@@ -0,0 +1,25 @@
+import Qt 4.7
+
+Rectangle {
+ id: root
+ width:200; height:300
+
+ Rectangle {
+ id: rectangle
+ objectName: "mover"
+ color: "green"
+ width:50; height:50
+ }
+
+ states: [
+ State {
+ name: "anchored"
+ AnchorChanges {
+ target: rectangle
+ anchors.left: root.left
+ anchors.right: root.right
+ anchors.bottom: root.bottom
+ }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/editProperties.qml b/tests/auto/declarative/qdeclarativestates/data/editProperties.qml
new file mode 100644
index 0000000000..4cb1ddd539
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/editProperties.qml
@@ -0,0 +1,34 @@
+import Qt 4.7
+Rectangle {
+ id: myRectangle
+
+ property color sourceColor: "blue"
+ width: 400; height: 400
+ color: "red"
+
+ Rectangle {
+ id: rect2
+ objectName: "rect2"
+ width: parent.width + 2
+ height: 200
+ color: "yellow"
+ }
+
+ states: [
+ State {
+ name: "blue"
+ PropertyChanges {
+ target: rect2
+ width:50
+ height: 40
+ }
+ },
+ State {
+ name: "green"
+ PropertyChanges {
+ target: rect2
+ width: myRectangle.width / 2
+ height: myRectangle.width / 4
+ }
+ }]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml
new file mode 100644
index 0000000000..be92abadd3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+
+Rectangle {
+ width: 400; height: 400
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ x: 5; y: 5
+ width: 100; height: 100
+ color: "red"
+ }
+ MouseArea {
+ id: clickable
+ anchors.fill: parent
+ }
+
+ Item {
+ id: newParent
+ rotation: 180
+ }
+
+ states: State {
+ name: "reparented"
+ when: clickable.pressed
+ ParentChange {
+ target: myRect
+ parent: newParent
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 6ae27592b4..0d10c10d18 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -48,6 +48,7 @@
#include <private/qdeclarativepropertychanges_p.h>
#include <private/qdeclarativestategroup_p.h>
#include <private/qdeclarativeitem_p.h>
+#include <private/qdeclarativeproperty_p.h>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -122,6 +123,7 @@ private slots:
void anchorChanges5();
void anchorChangesCrash();
void anchorRewindBug();
+ void anchorRewindBug2();
void script();
void restoreEntryValues();
void explicitChanges();
@@ -140,6 +142,7 @@ private slots:
void unnamedWhen();
void returnToBase();
void extendsBug();
+ void editProperties();
};
void tst_qdeclarativestates::initTestCase()
@@ -581,6 +584,21 @@ void tst_qdeclarativestates::parentChange()
//do a non-qFuzzyCompare fuzzy compare
QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
}
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange6.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(180));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(-105));
+ QCOMPARE(innerRect->y(), qreal(-105));
+ }
}
void tst_qdeclarativestates::parentChangeErrors()
@@ -843,6 +861,32 @@ void tst_qdeclarativestates::anchorRewindBug()
delete rect;
}
+// QTBUG-11834
+void tst_qdeclarativestates::anchorRewindBug2()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *mover = rect->findChild<QDeclarativeRectangle*>("mover");
+
+ QVERIFY(mover != 0);
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ QDeclarativeItemPrivate::get(rect)->setState("anchored");
+ QCOMPARE(mover->y(), qreal(250.0));
+ QCOMPARE(mover->width(), qreal(200.0));
+
+ QDeclarativeItemPrivate::get(rect)->setState("");
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ delete rect;
+}
+
void tst_qdeclarativestates::script()
{
QDeclarativeEngine engine;
@@ -1203,6 +1247,134 @@ void tst_qdeclarativestates::extendsBug()
QCOMPARE(greenRect->y(), qreal(100));
}
+void tst_qdeclarativestates::editProperties()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/editProperties.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+
+ QDeclarativeStateGroup *stateGroup = rectPrivate->_states();
+ QVERIFY(stateGroup != 0);
+ qmlExecuteDeferred(stateGroup);
+
+ QDeclarativeState *blueState = stateGroup->findState("blue");
+ QVERIFY(blueState != 0);
+ qmlExecuteDeferred(blueState);
+
+ QDeclarativePropertyChanges *propertyChangesBlue = qobject_cast<QDeclarativePropertyChanges*>(blueState->operationAt(0));
+ QVERIFY(propertyChangesBlue != 0);
+
+ QDeclarativeState *greenState = stateGroup->findState("green");
+ QVERIFY(greenState != 0);
+ qmlExecuteDeferred(greenState);
+
+ QDeclarativePropertyChanges *propertyChangesGreen = qobject_cast<QDeclarativePropertyChanges*>(greenState->operationAt(0));
+ QVERIFY(propertyChangesGreen != 0);
+
+ QDeclarativeRectangle *childRect = rect->findChild<QDeclarativeRectangle*>("rect2");
+ QVERIFY(childRect != 0);
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(50));
+ QCOMPARE(childRect->height(), qreal(40));
+ QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QVERIFY(blueState->bindingInRevertList(childRect, "width"));
+
+
+ rectPrivate->setState("green");
+ QCOMPARE(childRect->width(), qreal(200));
+ QCOMPARE(childRect->height(), qreal(100));
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+
+
+ rectPrivate->setState("");
+
+
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QVERIFY(propertyChangesBlue->containsValue("width"));
+ QVERIFY(!propertyChangesBlue->containsProperty("x"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
+ QVERIFY(!propertyChangesBlue->value("x").isValid());
+
+ propertyChangesBlue->changeValue("width", 60);
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+
+ propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
+ QVERIFY(!propertyChangesBlue->containsValue("width"));
+ QVERIFY(propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+ propertyChangesBlue->changeValue("width", 50);
+ QVERIFY(propertyChangesBlue->containsValue("width"));
+ QVERIFY(!propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(50));
+ QCOMPARE(childRect->height(), qreal(40));
+
+ propertyChangesBlue->changeValue("width", 60);
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QCOMPARE(childRect->width(), qreal(60));
+ QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+
+ propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
+ QVERIFY(!propertyChangesBlue->containsValue("width"));
+ QVERIFY(propertyChangesBlue->containsExpression("width"));
+ QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
+ QCOMPARE(propertyChangesBlue->actions().length(), 2);
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QCOMPARE(childRect->width(), qreal(200));
+
+ propertyChangesBlue->changeValue("width", 50);
+ QCOMPARE(childRect->width(), qreal(50));
+
+ rectPrivate->setState("");
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+ rectPrivate->setState("green");
+ QCOMPARE(childRect->width(), qreal(200));
+ QCOMPARE(childRect->height(), qreal(100));
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+
+
+ propertyChangesGreen->removeProperty("height");
+ QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "height")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QVERIFY(greenState->containsPropertyInRevertList(childRect, "width"));
+ propertyChangesGreen->removeProperty("width");
+ QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(!greenState->bindingInRevertList(childRect, "width"));
+ QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width"));
+
+ propertyChangesBlue->removeProperty("width");
+ QCOMPARE(childRect->width(), qreal(402));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(402));
+ QCOMPARE(childRect->height(), qreal(40));
+}
+
QTEST_MAIN(tst_qdeclarativestates)
#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
index 99de2192de..b5c6bbad05 100644
--- a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
index cb85251180..c9ffcc11d0 100644
--- a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
index ddca549c82..eda0d250ce 100644
--- a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml
new file mode 100644
index 0000000000..7ea74f21fb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Text { objectName: "name"; text: name }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml
new file mode 100644
index 0000000000..6654d6beec
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Text { objectName: "name"; text: modelData }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 95ef4fcd59..d73a872d02 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -75,6 +75,39 @@ static void initStandardTreeModel(QStandardItemModel *model)
model->insertRow(2, item);
}
+class SingleRoleModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ SingleRoleModel(QObject *parent = 0) {
+ QHash<int, QByteArray> roles;
+ roles.insert(Qt::DisplayRole , "name");
+ setRoleNames(roles);
+ list << "one" << "two" << "three" << "four";
+ }
+
+public slots:
+ void set(int idx, QString string) {
+ list[idx] = string;
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+protected:
+ int rowCount(const QModelIndex &parent = QModelIndex()) const {
+ return list.count();
+ }
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
+ if (role == Qt::DisplayRole)
+ return list.at(index.row());
+ return QVariant();
+ }
+
+private:
+ QStringList list;
+};
+
+
class tst_qdeclarativevisualdatamodel : public QObject
{
Q_OBJECT
@@ -86,6 +119,7 @@ private slots:
void updateLayout();
void childChanged();
void objectListModel();
+ void singleRole();
private:
QDeclarativeEngine engine;
@@ -282,6 +316,54 @@ void tst_qdeclarativevisualdatamodel::objectListModel()
QCOMPARE(name->text(), QString("Changed"));
}
+void tst_qdeclarativevisualdatamodel::singleRole()
+{
+ {
+ QDeclarativeView view;
+
+ SingleRoleModel model;
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole1.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+ {
+ QDeclarativeView view;
+
+ SingleRoleModel model;
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole2.qml"));
+
+ QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+}
+
template<typename T>
T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index)
{
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
index ecce349203..89252fbb20 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
@@ -45,6 +45,7 @@
#include <QDebug>
#include <QNetworkCookieJar>
#include "testhttpserver.h"
+#include "../../../shared/util.h"
#define SERVER_PORT 14445
@@ -156,16 +157,6 @@ void tst_qdeclarativexmlhttprequest::domExceptionCodes()
delete object;
}
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
void tst_qdeclarativexmlhttprequest::callbackException_data()
{
QTest::addColumn<QString>("which");
@@ -193,7 +184,7 @@ void tst_qdeclarativexmlhttprequest::callbackException()
object->setProperty("which", which);
component.completeCreate();
- TRY_WAIT(object->property("threw").toBool() == true);
+ QTRY_VERIFY(object->property("threw").toBool() == true);
delete object;
}
@@ -289,7 +280,7 @@ void tst_qdeclarativexmlhttprequest::open()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete server;
delete object;
@@ -372,7 +363,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -442,7 +433,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -464,7 +455,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_sent()
QCOMPARE(object->property("test").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -501,7 +492,7 @@ void tst_qdeclarativexmlhttprequest::send_alreadySent()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -523,7 +514,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -542,7 +533,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -566,7 +557,7 @@ void tst_qdeclarativexmlhttprequest::send_withdata()
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -601,7 +592,7 @@ void tst_qdeclarativexmlhttprequest::abort_unsent()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -622,7 +613,7 @@ void tst_qdeclarativexmlhttprequest::abort_opened()
QCOMPARE(object->property("responseText").toBool(), true);
QCOMPARE(object->property("responseXML").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -647,7 +638,7 @@ void tst_qdeclarativexmlhttprequest::abort()
QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
QCOMPARE(object->property("endStateUnsent").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
delete object;
}
@@ -674,7 +665,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader()
QCOMPARE(object->property("readyState").toBool(), true);
QCOMPARE(object->property("openedState").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("headersReceivedState").toBool(), true);
QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
@@ -722,7 +713,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader_args()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
delete object;
}
@@ -748,7 +739,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders()
QCOMPARE(object->property("readyState").toBool(), true);
QCOMPARE(object->property("openedState").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("headersReceivedState").toBool(), true);
QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
@@ -790,7 +781,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
delete object;
}
@@ -813,7 +804,7 @@ void tst_qdeclarativexmlhttprequest::status()
object->setProperty("expectedStatus", status);
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("unsentException").toBool(), true);
QCOMPARE(object->property("openedException").toBool(), true);
@@ -853,7 +844,7 @@ void tst_qdeclarativexmlhttprequest::statusText()
object->setProperty("expectedStatus", statusText);
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("unsentException").toBool(), true);
QCOMPARE(object->property("openedException").toBool(), true);
@@ -894,7 +885,7 @@ void tst_qdeclarativexmlhttprequest::responseText()
object->setProperty("expectedText", responseText);
component.completeCreate();
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("unsent").toBool(), true);
QCOMPARE(object->property("opened").toBool(), true);
@@ -931,7 +922,7 @@ void tst_qdeclarativexmlhttprequest::nonUtf8()
object->setProperty("fileName", fileName);
QMetaObject::invokeMethod(object, "startRequest");
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("responseText").toString(), responseText);
@@ -1000,7 +991,7 @@ void tst_qdeclarativexmlhttprequest::redirects()
object->setProperty("expectedText", "");
component.completeCreate();
- TRY_WAIT(object->property("done").toBool() == true);
+ QTRY_VERIFY(object->property("done").toBool() == true);
QCOMPARE(object->property("dataOK").toBool(), true);
delete object;
@@ -1019,7 +1010,7 @@ void tst_qdeclarativexmlhttprequest::redirects()
object->setProperty("expectedText", "");
component.completeCreate();
- TRY_WAIT(object->property("done").toBool() == true);
+ QTRY_VERIFY(object->property("done").toBool() == true);
QCOMPARE(object->property("dataOK").toBool(), true);
delete object;
@@ -1056,7 +1047,7 @@ void tst_qdeclarativexmlhttprequest::responseXML_invalid()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlNull").toBool(), true);
@@ -1070,7 +1061,7 @@ void tst_qdeclarativexmlhttprequest::document()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1084,7 +1075,7 @@ void tst_qdeclarativexmlhttprequest::element()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1098,7 +1089,7 @@ void tst_qdeclarativexmlhttprequest::attr()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1112,7 +1103,7 @@ void tst_qdeclarativexmlhttprequest::text()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
@@ -1126,7 +1117,7 @@ void tst_qdeclarativexmlhttprequest::cdata()
QObject *object = component.create();
QVERIFY(object != 0);
- TRY_WAIT(object->property("dataOK").toBool() == true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
QCOMPARE(object->property("xmlTest").toBool(), true);
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index ddc3939b67..667cdd3726 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
+#include <QtTest/qtesttouch.h>
#include "../../shared/util.h"
#include <qevent.h>
@@ -361,6 +362,7 @@ private slots:
void partialGesturePropagation();
void testQGestureRecognizerCleanup();
void testReuseCanceledGestures();
+ void bug_13501_gesture_not_accepted();
};
tst_Gestures::tst_Gestures()
@@ -2306,5 +2308,29 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
}
+class NoConsumeWidgetBug13501 :public QWidget
+{
+ Q_OBJECT
+protected:
+ bool event(QEvent *e) {
+ if(e->type() == QEvent::Gesture) {
+ return false;
+ }
+ return QWidget::event(e);
+ }
+};
+
+void tst_Gestures::bug_13501_gesture_not_accepted()
+{
+ // Create a gesture event that is not accepted by any widget
+ // make sure this does not lead to an assert in QGestureManager
+ NoConsumeWidgetBug13501 w;
+ w.grabGesture(Qt::TapGesture);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ //QTest::mousePress(&ignoreEvent, Qt::LeftButton);
+ QTest::touchEvent(&w).press(0, QPoint(10, 10), &w);
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"
diff --git a/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt
index 093610dbdb..1eed403b7c 100644
--- a/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt
+++ b/tests/auto/linguist/lupdate/testdata/good/heuristics/expectedoutput.txt
@@ -1,4 +1,3 @@
-*.*Function 'eval' is not implemented
Updating 'project\.ts'\.\.\.
Found 3 source text\(s\) \(3 new and 0 already existing\)
Removed 5 obsolete entries
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
index f58f932391..706e8d020a 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp
@@ -302,3 +302,44 @@ static inline QString message2()
}
}
+
+
+
+// QTBUG-11426: operator overloads
+class LotsaFun : public QObject
+{
+ Q_OBJECT
+public:
+ int operator<<(int left, int right);
+};
+
+int LotsaFun::operator<<(int left, int right)
+{
+ tr("this is inside operator<<");
+ return left << right;
+}
+
+
+
+// QTBUG-12683: define in re-opened namespace
+namespace NameSchpace {
+
+class YetMoreFun : public QObject
+{
+ Q_OBJECT
+public:
+ void funStuff();
+};
+
+}
+
+namespace NameSchpace {
+
+#define somevar 1
+
+void YetMoreFun::funStuff()
+{
+ tr("funStuff!");
+}
+
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
index 7ac318e685..f73fc64776 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result
@@ -141,6 +141,22 @@ backslashed \ stuff.</source>
</message>
</context>
<context>
+ <name>LotsaFun</name>
+ <message>
+ <location filename="main.cpp" line="318"/>
+ <source>this is inside operator&lt;&lt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>NameSchpace::YetMoreFun</name>
+ <message>
+ <location filename="main.cpp" line="342"/>
+ <source>funStuff!</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>Plurals, QCoreApplication</name>
<message numerus="yes">
<location filename="main.cpp" line="81"/>
diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp
index 5ba6c52694..e6d21350bc 100644
--- a/tests/auto/linguist/lupdate/tst_lupdate.cpp
+++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp
@@ -122,12 +122,19 @@ static bool prepareMatch(const QString &expect, QString *tmpl, int *require, int
return true;
}
-void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn, bool err)
+void tst_lupdate::doCompare(const QStringList &_actual, const QString &expectedFn, bool err)
{
QFile file(expectedFn);
QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(expectedFn));
QStringList expected = QString(file.readAll()).split('\n');
+ QStringList actual;
+ actual.reserve(_actual.size());
+ QRegExp niRx(".*:Function '\\w+' is not implemented");
+ foreach (const QString &a, _actual)
+ if (!niRx.exactMatch(a))
+ actual << a;
+
int ei = 0, ai = 0, em = expected.size(), am = actual.size();
int oei = 0, oai = 0, oem = em, oam = am;
int require = 0, accept = 0;
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index f9c3ccbaff..bb23f497e2 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -1077,10 +1077,10 @@ void tst_Moc::qprivateslots()
class PrivatePropertyTest : public QObject
{
Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo);
- Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar);
- Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop);
- Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz);
+ Q_PROPERTY(int foo READ foo WRITE setFoo)
+ Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar)
+ Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop)
+ Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz)
class MyDPointer {
public:
MyDPointer() : mBar(0), mPlop(0) {}
diff --git a/tests/auto/q3table/tst_q3table.cpp b/tests/auto/q3table/tst_q3table.cpp
index 90bf80698a..93de2517bf 100644
--- a/tests/auto/q3table/tst_q3table.cpp
+++ b/tests/auto/q3table/tst_q3table.cpp
@@ -502,7 +502,7 @@ void tst_Q3Table::pageUpDownNavigation()
void tst_Q3Table::simpleKeyboardNavigation()
{
QApplication::setActiveWindow(testWidget);
- QTRY_COMPARE(QApplication::activeWindow(), testWidget);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(testWidget));
QWidget *w;
// Test for task #24726
@@ -1208,7 +1208,7 @@ void tst_Q3Table::editCheck()
table.show();
QApplication::setActiveWindow(&table);
QTest::qWaitForWindowShown(&table);
- QTRY_COMPARE(QApplication::activeWindow(), &table);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&table));
table.setCurrentCell(0, 0);
#ifdef WAITS
QTest::qWait(50);
@@ -1345,7 +1345,7 @@ void tst_Q3Table::valueChanged()
testWidget->show();
QApplication::setActiveWindow(testWidget);
QTest::qWaitForWindowShown(testWidget);
- QTRY_COMPARE(QApplication::activeWindow(), testWidget);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(testWidget));
#ifdef WAITS
QTest::qWait(50);
#endif
@@ -1395,7 +1395,7 @@ void tst_Q3Table::dateTimeEdit()
testWidget->show();
QApplication::setActiveWindow(testWidget);
QTest::qWaitForWindowShown(testWidget);
- QTRY_COMPARE(QApplication::activeWindow(), testWidget);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(testWidget));
#ifdef WAITS
QTest::qWait(50);
#endif
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index a62720b066..15905285c2 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -1324,7 +1324,7 @@ void tst_QCompleter::task253125_lineEditCompletion()
#endif
QTest::qWait(10);
QApplication::setActiveWindow(&edit);
- QTRY_COMPARE(QApplication::activeWindow(), &edit);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&edit));
QTest::keyClick(&edit, 'i');
QCOMPARE(edit.completer()->currentCompletion(), QString("iota"));
@@ -1362,7 +1362,7 @@ void tst_QCompleter::task247560_keyboardNavigation()
QTest::qWait(10);
QApplication::setActiveWindow(&edit);
- QTRY_COMPARE(QApplication::activeWindow(), &edit);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&edit));
QTest::keyClick(&edit, 'r');
QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
diff --git a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
index 357b82ed90..bddd92abcb 100644
--- a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
@@ -70,6 +70,11 @@ private slots:
void fixedPitch_data();
void fixedPitch();
+#ifdef Q_WS_MAC
+ void trickyFonts_data();
+ void trickyFonts();
+#endif
+
void widthTwoTimes_data();
void widthTwoTimes();
@@ -131,10 +136,16 @@ void tst_QFontDatabase::fixedPitch_data()
QTest::newRow( "Times New Roman" ) << QString( "Times New Roman" ) << false;
QTest::newRow( "Arial" ) << QString( "Arial" ) << false;
- QTest::newRow( "Script" ) << QString( "Script" ) << false;
+ QTest::newRow( "Andale Mono" ) << QString( "Andale Mono" ) << true;
QTest::newRow( "Courier" ) << QString( "Courier" ) << true;
QTest::newRow( "Courier New" ) << QString( "Courier New" ) << true;
+#ifndef Q_WS_MAC
+ QTest::newRow( "Script" ) << QString( "Script" ) << false;
QTest::newRow( "Lucida Console" ) << QString( "Lucida Console" ) << true;
+#else
+ QTest::newRow( "Menlo" ) << QString( "Menlo" ) << true;
+ QTest::newRow( "Monaco" ) << QString( "Monaco" ) << true;
+#endif
}
void tst_QFontDatabase::fixedPitch()
@@ -156,6 +167,28 @@ void tst_QFontDatabase::fixedPitch()
QCOMPARE(fi.fixedPitch(), fixedPitch);
}
+#ifdef Q_WS_MAC
+void tst_QFontDatabase::trickyFonts_data()
+{
+ QTest::addColumn<QString>("font");
+
+ QTest::newRow( "Geeza Pro" ) << QString( "Geeza Pro" );
+}
+
+void tst_QFontDatabase::trickyFonts()
+{
+ QFETCH(QString, font);
+
+ QFontDatabase fdb;
+ if (!fdb.families().contains(font))
+ QSKIP( "Font not installed", SkipSingle);
+
+ QFont qfont(font);
+ QFontInfo fi(qfont);
+ QCOMPARE(fi.family(), font);
+}
+#endif
+
void tst_QFontDatabase::widthTwoTimes_data()
{
QTest::addColumn<QString>("font");
diff --git a/tests/auto/qglthreads/tst_qglthreads.cpp b/tests/auto/qglthreads/tst_qglthreads.cpp
index 4777fb1438..38b0dab8a2 100644
--- a/tests/auto/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/qglthreads/tst_qglthreads.cpp
@@ -456,11 +456,71 @@ void tst_QGLThreads::renderInThread()
QVERIFY(!thread.failure);
}
+class Device
+{
+public:
+ virtual ~Device() {}
+ virtual QPaintDevice *realPaintDevice() = 0;
+ virtual void prepareDevice() {}
+};
+
+class GLWidgetWrapper : public Device
+{
+public:
+ GLWidgetWrapper() {
+ widget.resize(150, 150);
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+ widget.doneCurrent();
+ }
+ QPaintDevice *realPaintDevice() { return &widget; }
+
+ ThreadSafeGLWidget widget;
+};
+
+class PixmapWrapper : public Device
+{
+public:
+ PixmapWrapper() { pixmap = new QPixmap(512, 512); }
+ ~PixmapWrapper() { delete pixmap; }
+ QPaintDevice *realPaintDevice() { return pixmap; }
+
+ QPixmap *pixmap;
+};
+
+class PixelBufferWrapper : public Device
+{
+public:
+ PixelBufferWrapper() { pbuffer = new QGLPixelBuffer(512, 512); }
+ ~PixelBufferWrapper() { delete pbuffer; }
+ QPaintDevice *realPaintDevice() { return pbuffer; }
+
+ QGLPixelBuffer *pbuffer;
+};
+
+
+class FrameBufferObjectWrapper : public Device
+{
+public:
+ FrameBufferObjectWrapper() {
+ widget.makeCurrent();
+ fbo = new QGLFramebufferObject(512, 512);
+ widget.doneCurrent();
+ }
+ ~FrameBufferObjectWrapper() { delete fbo; }
+ QPaintDevice *realPaintDevice() { return fbo; }
+ void prepareDevice() { widget.makeCurrent(); }
+
+ ThreadSafeGLWidget widget;
+ QGLFramebufferObject *fbo;
+};
+
+
class ThreadPainter : public QObject
{
Q_OBJECT
public:
- ThreadPainter(QPaintDevice *pd) : paintDevice(pd), fail(true) {
+ ThreadPainter(Device *pd) : device(pd), fail(true) {
pixmap = QPixmap(40, 40);
pixmap.fill(Qt::green);
QPainter p(&pixmap);
@@ -474,6 +534,8 @@ public slots:
QTime time;
time.start();
int rotAngle = 10;
+ device->prepareDevice();
+ QPaintDevice *paintDevice = device->realPaintDevice();
QSize s(paintDevice->width(), paintDevice->height());
while (time.elapsed() < RUNNING_TIME) {
QPainter p;
@@ -506,7 +568,7 @@ public slots:
private:
QPixmap pixmap;
- QPaintDevice *paintDevice;
+ Device *device;
bool fail;
};
@@ -520,16 +582,6 @@ public:
devices.append(new T);
threads.append(new QThread);
painters.append(new ThreadPainter(devices.at(i)));
- if (devices.at(i)->devType() == QInternal::Widget) {
- QWidget *widget = static_cast<QWidget *>(devices.at(i));
- widget->resize(150, 150);
- widget->show();
- QTest::qWaitForWindowShown(widget);
- if (widget->inherits("QGLWidget")) {
- QGLWidget *glWidget = static_cast<QGLWidget *>(widget);
- glWidget->doneCurrent();
- }
- }
painters.at(i)->moveToThread(threads.at(i));
painters.at(i)->connect(threads.at(i), SIGNAL(started()), painters.at(i), SLOT(draw()));
}
@@ -568,7 +620,7 @@ public:
private:
QList<QThread *> threads;
- QList<QPaintDevice *> devices;
+ QList<Device *> devices;
QList<ThreadPainter *> painters;
int numThreads;
};
@@ -587,7 +639,12 @@ void tst_QGLThreads::painterOnGLWidgetInThread()
#ifdef Q_OS_MAC
QSKIP("OpenGL threading tests are currently disabled on Mac as they were causing reboots", SkipAll);
#endif
- PaintThreadManager<ThreadSafeGLWidget> painterThreads(5);
+ if (!((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) ||
+ (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) {
+ QSKIP("The OpenGL based threaded QPainter tests requires OpenGL/ES 2.0.", SkipAll);
+ }
+
+ PaintThreadManager<GLWidgetWrapper> painterThreads(5);
painterThreads.start();
while (painterThreads.areRunning()) {
@@ -601,12 +658,6 @@ void tst_QGLThreads::painterOnGLWidgetInThread()
QVERIFY(!painterThreads.failed());
}
-class Pixmap : public QPixmap
-{
-public:
- Pixmap() : QPixmap(200, 200) {}
-};
-
/*
This test uses QPainter to draw onto different QPixmaps in
different threads at the same time.
@@ -616,7 +667,74 @@ void tst_QGLThreads::painterOnPixmapInThread()
#ifdef Q_WS_X11
QSKIP("Drawing text in threads onto X11 drawables currently crashes on some X11 servers.", SkipAll);
#endif
- PaintThreadManager<Pixmap> painterThreads(5);
+ PaintThreadManager<PixmapWrapper> painterThreads(5);
+ painterThreads.start();
+
+ while (painterThreads.areRunning()) {
+ qApp->processEvents();
+#ifdef Q_WS_WIN
+ Sleep(100);
+#else
+ usleep(100 * 1000);
+#endif
+ }
+ QVERIFY(!painterThreads.failed());
+}
+
+/* This test uses QPainter to draw onto different QGLPixelBuffer
+ objects in different threads at the same time.
+*/
+void tst_QGLThreads::painterOnPboInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on Mac as they were causing reboots", SkipAll);
+#endif
+ if (!((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) ||
+ (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) {
+ QSKIP("The OpenGL based threaded QPainter tests requires OpenGL/ES 2.0.", SkipAll);
+ return;
+ }
+
+ if (!QGLPixelBuffer::hasOpenGLPbuffers()) {
+ QSKIP("This system doesn't support pbuffers.", SkipAll);
+ return;
+ }
+
+ PaintThreadManager<PixelBufferWrapper> painterThreads(5);
+ painterThreads.start();
+
+ while (painterThreads.areRunning()) {
+ qApp->processEvents();
+#ifdef Q_WS_WIN
+ Sleep(100);
+#else
+ usleep(100 * 1000);
+#endif
+ }
+ QVERIFY(!painterThreads.failed());
+}
+
+/* This test uses QPainter to draw onto different
+ QGLFramebufferObjects (bound in a QGLWidget's context) in different
+ threads at the same time.
+*/
+void tst_QGLThreads::painterOnFboInThread()
+{
+#ifdef Q_OS_MAC
+ QSKIP("OpenGL threading tests are currently disabled on Mac as they were causing reboots", SkipAll);
+#endif
+ if (!((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) ||
+ (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0))) {
+ QSKIP("The OpenGL based threaded QPainter tests requires OpenGL/ES 2.0.", SkipAll);
+ return;
+ }
+
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
+ QSKIP("This system doesn't support framebuffer objects.", SkipAll);
+ return;
+ }
+
+ PaintThreadManager<FrameBufferObjectWrapper> painterThreads(5);
painterThreads.start();
while (painterThreads.areRunning()) {
diff --git a/tests/auto/qglthreads/tst_qglthreads.h b/tests/auto/qglthreads/tst_qglthreads.h
index ae6b9530c0..a8c2963047 100644
--- a/tests/auto/qglthreads/tst_qglthreads.h
+++ b/tests/auto/qglthreads/tst_qglthreads.h
@@ -58,6 +58,8 @@ private slots:
void renderInThread();
void painterOnGLWidgetInThread();
void painterOnPixmapInThread();
+ void painterOnPboInThread();
+ void painterOnFboInThread();
};
#endif // TST_QGLTHREADS_H
diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp
index b75e801295..da91063d87 100644
--- a/tests/auto/qglyphs/tst_qglyphs.cpp
+++ b/tests/auto/qglyphs/tst_qglyphs.cpp
@@ -347,10 +347,6 @@ void tst_QGlyphs::drawMultiScriptText1()
void tst_QGlyphs::drawMultiScriptText2()
{
-#if defined(Q_WS_MAC)
- QSKIP("Unstable because of QTBUG-11145", SkipAll);
-#endif
-
QString text;
text += QChar(0x0621); // Arabic, Hamza
text += QChar(0x03D0); // Greek, beta
@@ -530,10 +526,6 @@ void tst_QGlyphs::drawUnderlinedText()
void tst_QGlyphs::drawRightToLeft()
{
-#if defined(Q_WS_MAC)
- QSKIP("Unstable because of QTBUG-11145", SkipAll);
-#endif
-
QString s;
s.append(QChar(1575));
s.append(QChar(1578));
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index fa6a5ecbd7..07fa630066 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -66,6 +66,7 @@ private slots:
void source();
void boundingRectFor();
void boundingRect();
+ void boundingRect2();
void draw();
void opacity();
void grayscale();
@@ -76,6 +77,7 @@ private slots:
void dropShadowClipping();
void childrenVisibilityShouldInvalidateCache();
void prepareGeometryChangeInvalidateCache();
+ void itemHasNoContents();
};
void tst_QGraphicsEffect::initTestCase()
@@ -263,6 +265,57 @@ void tst_QGraphicsEffect::boundingRect()
delete item;
}
+void tst_QGraphicsEffect::boundingRect2()
+{
+ CustomEffect *effect = new CustomEffect;
+ QGraphicsRectItem *root = new QGraphicsRectItem;
+ root->setGraphicsEffect(effect);
+
+ QGraphicsRectItem *child = new QGraphicsRectItem;
+ QRectF childRect(0, 0, 100, 100);
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ child->setRect(childRect);
+ child->setParentItem(root);
+
+ QGraphicsRectItem *grandChild = new QGraphicsRectItem;
+ QRectF grandChildRect(0, 0, 200, 200);
+ grandChild->setRect(grandChildRect);
+ grandChild->setParentItem(child);
+
+ // Make sure the effect's bounding rect is clipped to the child's bounding rect.
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect));
+
+ // Disable ItemClipsChildrenToShape; effect's bounding rect is no longer clipped.
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+
+ // Add root item to a scene, do the same tests as above. Results should be the same.
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect));
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+
+ // Now add the scene to a view, results should be the same.
+ QGraphicsView view(&scene);
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect));
+
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+
+ CustomEffect *childEffect = new CustomEffect;
+ child->setGraphicsEffect(childEffect);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childEffect->boundingRectFor(childRect | grandChildRect)));
+
+ child->setGraphicsEffect(0);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+}
+
void tst_QGraphicsEffect::draw()
{
QGraphicsScene scene;
@@ -675,6 +728,34 @@ void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache()
QCOMPARE(item->nbPaint, 0);
}
+void tst_QGraphicsEffect::itemHasNoContents()
+{
+ QGraphicsRectItem *parent = new QGraphicsRectItem;
+ parent->setFlag(QGraphicsItem::ItemHasNoContents);
+
+ MyGraphicsItem *child = new MyGraphicsItem;
+ child->setParentItem(parent);
+ child->resize(200, 200);
+
+ QGraphicsScene scene;
+ scene.addItem(parent);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(child->nbPaint, 1);
+
+ CustomEffect *effect = new CustomEffect;
+ parent->setGraphicsEffect(effect);
+ QTRY_COMPARE(effect->numRepaints, 1);
+
+ for (int i = 0; i < 3; ++i) {
+ effect->reset();
+ effect->update();
+ QTRY_COMPARE(effect->numRepaints, 1);
+ }
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"
diff --git a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
index 879e12b0bd..dbffa6e389 100644
--- a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
+++ b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
@@ -75,6 +75,7 @@ private slots:
void setPreferredSize_data();
void setPreferredSize();
void setSizePolicy_data();
+ void setPreferredSize2();
void setSizePolicy();
};
@@ -343,6 +344,13 @@ void tst_QGraphicsLayoutItem::setPreferredSize()
}
}
+void tst_QGraphicsLayoutItem::setPreferredSize2()
+{
+ SubQGraphicsLayoutItem layoutItem;
+ layoutItem.setPreferredSize(QSizeF(30, -1));
+ QCOMPARE(layoutItem.preferredWidth(), qreal(30));
+}
+
void tst_QGraphicsLayoutItem::setSizePolicy_data()
{
QTest::addColumn<QSizePolicy>("policy");
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index c145623240..b8e729eb7c 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -287,6 +287,7 @@ private slots:
void taskQTBUG_5904_crashWithDeviceCoordinateCache();
void taskQT657_paintIntoCacheWithTransparentParts();
void taskQTBUG_7863_paintIntoCacheWithTransparentParts();
+ void taskQT_3674_doNotCrash();
};
void tst_QGraphicsScene::initTestCase()
@@ -4565,6 +4566,25 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
}
}
+void tst_QGraphicsScene::taskQT_3674_doNotCrash()
+{
+ QGraphicsScene scene;
+
+ QGraphicsView view(&scene);
+ view.resize(200, 200);
+
+ QPixmap pixmap(view.size());
+ QPainter painter(&pixmap);
+ view.render(&painter);
+ painter.end();
+
+ scene.addItem(new QGraphicsWidget);
+ scene.setBackgroundBrush(Qt::green);
+
+ QApplication::processEvents();
+ QApplication::processEvents();
+}
+
void tst_QGraphicsScene::zeroScale()
{
//should not crash
diff --git a/tests/auto/qimagereader/images/qtbug13653-no_eoi.jpg b/tests/auto/qimagereader/images/qtbug13653-no_eoi.jpg
new file mode 100644
index 0000000000..605e8a85da
--- /dev/null
+++ b/tests/auto/qimagereader/images/qtbug13653-no_eoi.jpg
Binary files differ
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index 1acc82f514..5536b38b32 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -63,5 +63,6 @@
<file>images/rect.svgz</file>
<file>images/corrupt.svg</file>
<file>images/corrupt.svgz</file>
+ <file>images/qtbug13653-no_eoi.jpg</file>
</qresource>
</RCC>
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 5b30b04352..3bee5d98aa 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -239,6 +239,7 @@ void tst_QImageReader::readImage_data()
#if defined QTEST_HAVE_JPEG
QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg");
+ QTest::newRow("JPEG: qtbug13653") << QString("qtbug13653-no_eoi.jpg") << true << QByteArray("jpeg");
#endif
#if defined QTEST_HAVE_GIF
QTest::newRow("GIF: earth") << QString("earth.gif") << true << QByteArray("gif");
@@ -1039,6 +1040,7 @@ void tst_QImageReader::readFromDevice_data()
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");
+ QTest::newRow("jpeg-4") << QString("qtbug13653-no_eoi.jpg") << QByteArray("jpeg");
#endif // QTEST_HAVE_JPEG
#ifdef QTEST_HAVE_GIF
QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif");
@@ -1314,6 +1316,9 @@ void tst_QImageReader::readFromResources_data()
QTest::newRow("YCbCr_rgb.jpg") << QString("YCbCr_rgb.jpg")
<< QByteArray("jpg") << QSize(75, 50)
<< QString("");
+ QTest::newRow("qtbug13653-no_eoi.jpg") << QString("qtbug13653-no_eoi.jpg")
+ << QByteArray("jpg") << QSize(240, 180)
+ << QString("");
#endif
#ifdef QTEST_HAVE_MNG
QTest::newRow("corrupt.mng") << QString("corrupt.mng")
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index bfa940626a..93bd447b8c 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -3747,15 +3747,15 @@ void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
void tst_QLineEdit::QTBUG13520_textNotVisible()
{
LineEdit le;
- le.setAlignment( Qt::AlignRight | Qt::AlignVCenter);
- le.show();
- QTest::qWaitForWindowShown(&le);
- le.setText("01-ST16-01SIL-MPL001wfgsdfgsdgsdfgsdfgsdfgsdfgsdfg");
- le.setCursorPosition(0);
- QTest::qWait(100); //just make sure we get he lineedit correcly painted
-
- QVERIFY(le.cursorRect().center().x() < le.width() / 2);
-
+ le.setAlignment( Qt::AlignRight | Qt::AlignVCenter);
+ le.show();
+ QTest::qWaitForWindowShown(&le);
+ le.setText("01-ST16-01SIL-MPL001wfgsdfgsdgsdfgsdfgsdfgsdfgsdfg");
+ le.setCursorPosition(0);
+ QTest::qWait(100); //just make sure we get he lineedit correcly painted
+
+ QVERIFY(le.cursorRect().center().x() < le.width() / 2);
+
}
diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp
index 9f6b4a59ff..14b8057486 100644
--- a/tests/auto/qlist/tst_qlist.cpp
+++ b/tests/auto/qlist/tst_qlist.cpp
@@ -666,7 +666,7 @@ void tst_QList::testSTLIterators() const
void tst_QList::initializeList() const
{
-#ifdef QT_CXX0X_INITIALIZERLIST
+#ifdef Q_COMPILER_INITIALIZER_LISTS
QList<int> v1{2,3,4};
QCOMPARE(v1, QList<int>() << 2 << 3 << 4);
QCOMPARE(v1, (QList<int>{2,3,4}));
diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp
index 1273e85603..5a69d9c314 100644
--- a/tests/auto/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp
@@ -1449,8 +1449,7 @@ Q_DECLARE_METATYPE(MoveList)
void MoveSeparator::apply(QMainWindow *mw) const
{
-
- QMainWindowLayout *l = qobject_cast<QMainWindowLayout*>(mw->layout());
+ QMainWindowLayout *l = qFindChild<QMainWindowLayout *>(mw);
QVERIFY(l);
QList<int> path;
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index abfe24b29e..24cd5a35e1 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -3285,16 +3285,16 @@ void tst_QObject::overloads()
QCOMPARE(obj2.s_num, 101);
emit obj1.sig(&obj2, &obj3); //this signal is connected
QCOMPARE(obj1.s_num, 11);
- QCOMPARE(obj1.o1_obj, &obj2);
+ QCOMPARE(obj1.o1_obj, (QObject *)&obj2);
QCOMPARE(obj1.o2_obj, &obj3);
QCOMPARE(obj1.o3_obj, (QObject *)0); //default arg of the signal
- QCOMPARE(obj1.o4_obj, qApp); //default arg of the slot
+ QCOMPARE(obj1.o4_obj, (QObject *)qApp); //default arg of the slot
QCOMPARE(obj2.s_num, 111);
- QCOMPARE(obj2.o1_obj, &obj2);
+ QCOMPARE(obj2.o1_obj, (QObject *)&obj2);
QCOMPARE(obj2.o2_obj, &obj3);
QCOMPARE(obj2.o3_obj, (QObject *)0); //default arg of the signal
- QCOMPARE(obj2.o4_obj, qApp); //default arg of the slot
+ QCOMPARE(obj2.o4_obj, (QObject *)qApp); //default arg of the slot
}
class ManySignals : public QObject
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 1ba5859737..ae972854e4 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -221,6 +221,8 @@ private slots:
void drawRect_task215378();
void drawRect_task247505();
+ void drawText_subPixelPositionsInRaster_qtbug5053();
+
void drawImage_data();
void drawImage();
@@ -4541,6 +4543,14 @@ void tst_QPainter::clipBoundingRect()
QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20)));
QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+ // Test a basic float rectangle
+ p.setClipRect(QRectF(100, 100, 200, 100));
+ QVERIFY(p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(50, 50, 300, 200)));
+ p.setClipRect(QRectF(120, 120, 20, 20), Qt::IntersectClip);
+ QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20)));
+ QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100)));
+
// Test a basic path + region
QPainterPath path;
path.addRect(100, 100, 200, 100);
@@ -4562,6 +4572,65 @@ void tst_QPainter::clipBoundingRect()
}
+void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
+{
+#if !defined(Q_WS_MAC) || !defined(QT_MAC_USE_COCOA)
+ QSKIP("Only Mac/Cocoa supports sub pixel positions in raster engine currently", SkipAll);
+#endif
+
+ int w = 10, h = 10;
+ QImage image(w, h, QImage::Format_RGB32);
+ image.fill(0xffffffff);
+ QPainter p(&image);
+ p.drawText(0, h, "X\\");
+ p.end();
+
+ bool foundNonGrayPixel = false;
+ const int *bits = (const int *) ((const QImage &) image).bits();
+ int bpl = image.bytesPerLine() / 4;
+ for (int y=0; y<w; ++y) {
+ for (int x=0; x<h; ++x) {
+ int r = qRed(bits[x]);
+ int g = qGreen(bits[x]);
+ int b = qBlue(bits[x]);
+ if (r != g || r != b) {
+ foundNonGrayPixel = true;
+ break;
+ }
+ }
+ bits += bpl;
+ }
+ if (!foundNonGrayPixel)
+ QSKIP("Font smoothing must be turned on for this test", SkipAll);
+
+ QFontMetricsF fm(qApp->font());
+
+ QImage baseLine(fm.width(QChar::fromLatin1('e')), fm.height(), QImage::Format_RGB32);
+ baseLine.fill(Qt::white);
+ {
+ QPainter p(&baseLine);
+ p.drawText(0, fm.ascent(), QString::fromLatin1("e"));
+ }
+
+ bool foundDifferentRasterization = false;
+ for (int i=1; i<12; ++i) {
+ QImage comparison(baseLine.size(), QImage::Format_RGB32);
+ comparison.fill(Qt::white);
+
+ {
+ QPainter p(&comparison);
+ p.drawText(QPointF(i / 12.0, fm.ascent()), QString::fromLatin1("e"));
+ }
+
+ if (comparison != baseLine) {
+ foundDifferentRasterization = true;
+ break;
+ }
+ }
+
+ QVERIFY(foundDifferentRasterization);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 7e0f466cd5..8005ec5d50 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -742,6 +742,11 @@ void tst_QPixmap::testMetrics()
QCOMPARE(bitmap.width(), 100);
QCOMPARE(bitmap.height(), 100);
QCOMPARE(bitmap.depth(), 1);
+
+ QPixmap null;
+
+ QCOMPARE(null.size().width(), null.width());
+ QCOMPARE(null.size().height(), null.height());
}
void tst_QPixmap::createMaskFromColor()
diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
index f0f087d985..12d2c57dc3 100644
--- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
+++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
@@ -72,6 +72,7 @@ private slots:
void convolutionBoundingRectFor();
void convolutionDrawSubRect();
void dropShadowBoundingRectFor();
+ void blurIndexed8();
void testDefaultImplementations();
};
@@ -423,6 +424,27 @@ void tst_QPixmapFilter::dropShadowBoundingRectFor()
QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta - 10, -delta - 10, 0, 0));
}
+QT_BEGIN_NAMESPACE
+void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
+QT_END_NAMESPACE
+
+void tst_QPixmapFilter::blurIndexed8()
+{
+ QImage img(16, 32, QImage::Format_Indexed8);
+ img.setColorCount(256);
+ for (int i = 0; i < 256; ++i)
+ img.setColor(i, qRgb(i, i, i));
+
+ img.fill(255);
+
+ QImage original = img;
+ qt_blurImage(img, 10, true, false);
+ QCOMPARE(original.size(), img.size());
+
+ original = img;
+ qt_blurImage(img, 10, true, true);
+ QCOMPARE(original.size(), QSize(img.height(), img.width()));
+}
QTEST_MAIN(tst_QPixmapFilter)
#include "tst_qpixmapfilter.moc"
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index e154528ea2..e16be8b93a 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -381,7 +381,7 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
QCOMPARE(a1_s_o2->currentLoopTime(), 250);
QCOMPARE(notTimeDriven->currentLoopTime(), 0);
QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), notTimeDriven);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation *>(notTimeDriven));
// Current time = 505
group.setCurrentTime(505);
@@ -391,7 +391,7 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
QCOMPARE(a1_s_o2->currentLoopTime(), 250);
QCOMPARE(notTimeDriven->currentLoopTime(), 5);
QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), notTimeDriven);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation *>(notTimeDriven));
QCOMPARE(sequence->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp
index 058a750fa5..0395eff4a8 100644
--- a/tests/auto/qsettings/tst_qsettings.cpp
+++ b/tests/auto/qsettings/tst_qsettings.cpp
@@ -60,6 +60,10 @@
#include <io.h>
#endif
+#if defined(Q_OS_WIN)
+#include <QtCore/qt_windows.h>
+#endif
+
#ifndef QSETTINGS_P_H_VERSION
#define QSETTINGS_P_H_VERSION 1
#endif
@@ -127,6 +131,9 @@ private slots:
#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN)
void dontReorderIniKeysNeedlessly();
#endif
+#if defined(Q_OS_WIN)
+ void qtbug_13249();
+#endif
/*
These tests were developed for the Qt 3 QSettings class.
@@ -3801,6 +3808,62 @@ void tst_QSettings::setPathBug()
}
#endif
+#if defined(Q_OS_WIN)
+
+static DWORD readKeyType(HKEY handle, const QString &rSubKey)
+{
+ DWORD dataType;
+ DWORD dataSize;
+ LONG res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), 0, &dataType, 0, &dataSize);
+
+ if (res == ERROR_SUCCESS)
+ return dataType;
+
+ return 0;
+}
+
+void tst_QSettings::qtbug_13249()
+{
+ QSettings settings1(QSettings::UserScope, "software.org", "KillerAPP");
+
+ qint32 x = 1024;
+ settings1.setValue("qtbug_13249_a", (qint32)x);
+ QCOMPARE(settings1.value("qtbug_13249_a").toInt(), (qint32)1024);
+ settings1.setValue("qtbug_13249_b", (quint32)x);
+ QCOMPARE(settings1.value("qtbug_13249_b").toUInt(), (quint32)1024);
+ settings1.setValue("qtbug_13249_c", (qint64)x);
+ QCOMPARE(settings1.value("qtbug_13249_c").toLongLong(), (qint64)1024);
+ settings1.setValue("qtbug_13249_d", (quint64)x);
+ QCOMPARE(settings1.value("qtbug_13249_d").toULongLong(), (quint64)1024);
+ settings1.sync();
+
+ HKEY handle;
+ LONG res;
+ QString keyName = "Software\\software.org\\KillerAPP";
+ res = RegOpenKeyEx(HKEY_CURRENT_USER, reinterpret_cast<const wchar_t *>(keyName.utf16()), 0, KEY_READ, &handle);
+ if (res == ERROR_SUCCESS)
+ {
+ DWORD dataType;
+ dataType = readKeyType(handle, QString("qtbug_13249_a"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_DWORD, (int)dataType);
+ }
+ dataType = readKeyType(handle, QString("qtbug_13249_b"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_DWORD, (int)dataType);
+ }
+ dataType = readKeyType(handle, QString("qtbug_13249_c"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_QWORD, (int)dataType);
+ }
+ dataType = readKeyType(handle, QString("qtbug_13249_d"));
+ if (dataType != 0) {
+ QCOMPARE((int)REG_QWORD, (int)dataType);
+ }
+ RegCloseKey(handle);
+ }
+}
+#endif
/*
// Not tested at the moment.
void tst_QSettings::oldSubkeyList()
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 53fefeedc8..66caf4a71c 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -143,6 +143,7 @@ private slots:
void taskQTBUG_10287_unnecessaryMapCreation();
void testMultipleProxiesWithSelection();
+ void mapSelectionFromSource();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -3075,6 +3076,44 @@ void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection()
}
+static bool isValid(const QItemSelection &selection) {
+ foreach(const QItemSelectionRange &range, selection)
+ if (!range.isValid())
+ return false;
+ return true;
+}
+
+void tst_QSortFilterProxyModel::mapSelectionFromSource()
+{
+ QStringListModel model;
+ const QStringList initial = QString("bravo charlie delta echo").split(" ");
+ model.setStringList(initial);
+
+ QSortFilterProxyModel proxy;
+ proxy.setDynamicSortFilter(true);
+ proxy.setFilterRegExp("d.*");
+ proxy.setSourceModel(&model);
+
+ // Only "delta" remains.
+ QVERIFY(proxy.rowCount() == 1);
+
+ QItemSelection selection;
+ QModelIndex charlie = model.index(1, 0);
+ selection.append(QItemSelectionRange(charlie, charlie));
+ QModelIndex delta = model.index(2, 0);
+ selection.append(QItemSelectionRange(delta, delta));
+ QModelIndex echo = model.index(3, 0);
+ selection.append(QItemSelectionRange(echo, echo));
+
+ QVERIFY(isValid(selection));
+
+ QItemSelection proxiedSelection = proxy.mapSelectionFromSource(selection);
+
+ // Only "delta" is in the mapped result.
+ QVERIFY(proxiedSelection.size() == 1);
+ QVERIFY(isValid(proxiedSelection));
+}
+
class Model10287 : public QStandardItemModel
{
Q_OBJECT
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 49d6633100..daf0fa3dfa 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -94,6 +94,8 @@ private slots:
void drawStruckOutText();
void drawOverlinedText();
void drawUnderlinedText();
+
+ void unprintableCharacter_qtbug12614();
};
void tst_QStaticText::init()
@@ -359,7 +361,7 @@ bool tst_QStaticText::supportsTransformations() const
QPaintEngine::Type type = engine->type();
if (type == QPaintEngine::OpenGL
-#if !defined Q_WS_WIN
+#if !defined(Q_WS_WIN) && !defined(Q_WS_X11)
|| type == QPaintEngine::Raster
#endif
)
@@ -772,5 +774,14 @@ void tst_QStaticText::drawUnderlinedText()
QCOMPARE(imageDrawText, imageDrawStaticText);
}
+void tst_QStaticText::unprintableCharacter_qtbug12614()
+{
+ QString s(QChar(0x200B)); // U+200B, ZERO WIDTH SPACE
+
+ QStaticText staticText(s);
+
+ QVERIFY(staticText.size().isValid()); // Force layout. Should not crash.
+}
+
QTEST_MAIN(tst_QStaticText)
#include "tst_qstatictext.moc"
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index b651187e9c..f23d0655d6 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -87,6 +87,8 @@ private slots:
void cancelLongTimer();
void singleShotStaticFunctionZeroTimeout();
void recurseOnTimeoutAndStopTimer();
+
+ void QTBUG13633_dontBlockEvents();
};
class TimerHelper : public QObject
@@ -269,13 +271,7 @@ void tst_QTimer::livelock()
QCOMPARE(tester.timeoutsForFirst, 1);
QCOMPARE(tester.timeoutsForExtra, 0);
QCOMPARE(tester.timeoutsForSecond, 1);
-#if defined(Q_OS_MAC)
- QEXPECT_FAIL("zero timer", "Posted events source are handled AFTER timers", Continue);
- QEXPECT_FAIL("non-zero timer", "Posted events source are handled AFTER timers", Continue);
-#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
- QEXPECT_FAIL("zero timer", "", Continue);
- QEXPECT_FAIL("non-zero timer", "", Continue);
-#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
#elif defined(Q_OS_WINCE)
@@ -668,5 +664,64 @@ void tst_QTimer::recurseOnTimeoutAndStopTimer()
QVERIFY(!t.two->isActive());
}
+
+
+class DontBlockEvents : public QObject
+{
+ Q_OBJECT
+public:
+ DontBlockEvents();
+ void timerEvent(QTimerEvent*);
+
+ int count;
+ int total;
+ QBasicTimer m_timer;
+
+public slots:
+ void paintEvent();
+
+};
+
+DontBlockEvents::DontBlockEvents()
+{
+ count = 0;
+ total = 0;
+
+ //QTBUG-13633 need few unrelated timer running to reproduce the bug.
+ (new QTimer(this))->start(2000);
+ (new QTimer(this))->start(2500);
+ (new QTimer(this))->start(3000);
+ (new QTimer(this))->start(5000);
+ (new QTimer(this))->start(1000);
+ (new QTimer(this))->start(2000);
+
+ m_timer.start(1, this);
+}
+
+void DontBlockEvents::timerEvent(QTimerEvent* event)
+{
+ if (event->timerId() == m_timer.timerId()) {
+ QMetaObject::invokeMethod(this, "paintEvent", Qt::QueuedConnection);
+ m_timer.start(0, this);
+ count++;
+ QCOMPARE(count, 1);
+ total++;
+ }
+}
+
+void DontBlockEvents::paintEvent()
+{
+ count--;
+ QCOMPARE(count, 0);
+}
+
+
+void tst_QTimer::QTBUG13633_dontBlockEvents()
+{
+ DontBlockEvents t;
+ QTest::qWait(60);
+ QVERIFY(t.total > 2);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 8091607dc3..eff4658a39 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -2489,16 +2489,26 @@ void tst_QUrl::isValid()
QUrl url = QUrl::fromEncoded("http://strange;hostname/here");
QVERIFY(!url.isValid());
QCOMPARE(url.path(), QString("/here"));
+ url.setAuthority("strange;hostname");
+ QVERIFY(!url.isValid());
url.setAuthority("foobar@bar");
QVERIFY(url.isValid());
+ url.setAuthority("strange;hostname");
+ QVERIFY(!url.isValid());
+ QVERIFY(url.errorString().contains("invalid hostname"));
}
{
QUrl url = QUrl::fromEncoded("foo://stuff;1/g");
QVERIFY(!url.isValid());
QCOMPARE(url.path(), QString("/g"));
+ url.setHost("stuff;1");
+ QVERIFY(!url.isValid());
url.setHost("stuff-1");
QVERIFY(url.isValid());
+ url.setHost("stuff;1");
+ QVERIFY(!url.isValid());
+ QVERIFY(url.errorString().contains("invalid hostname"));
}
}
diff --git a/tests/auto/qvector/tst_qvector.cpp b/tests/auto/qvector/tst_qvector.cpp
index d8dfacfeaf..a04ce604b4 100644
--- a/tests/auto/qvector/tst_qvector.cpp
+++ b/tests/auto/qvector/tst_qvector.cpp
@@ -837,7 +837,7 @@ void tst_QVector::QTBUG6416_reserve()
void tst_QVector::initializeList()
{
-#ifdef QT_CXX0X_INITIALIZERLIST
+#ifdef Q_COMPILER_INITIALIZER_LISTS
QVector<int> v1{2,3,4};
QCOMPARE(v1, QVector<int>() << 2 << 3 << 4);
QCOMPARE(v1, (QVector<int>{2,3,4}));