summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-05-27 10:25:04 +1000
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-05-27 10:25:04 +1000
commitfb5d338236976690312660bc017a8fe1e199326f (patch)
treef126ea5dfb367fc5212a62652162b84e86513aa4 /tests
parent487c05895751985a695f117fd984d1ecfe7b1252 (diff)
parent84f35321b867894470391d4997b5d58e34bce0ed (diff)
Merge remote branch 'origin/4.7' into oslo-staging-1
Conflicts: doc/src/declarative/advtutorial.qdoc
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp14
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp94
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp95
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml24
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script.js1
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js4
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js6
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml21
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp43
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml2
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml2
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml2
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp43
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp36
-rw-r--r--tests/auto/qxmlstream/qxmlstream.pro5
-rw-r--r--tests/auto/qxmlstream/tst_qxmlstream.cpp26
18 files changed, 366 insertions, 69 deletions
diff --git a/tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml b/tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml
new file mode 100644
index 0000000000..7cd4f264f6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml
@@ -0,0 +1,11 @@
+import Qt 4.7
+
+Rectangle {
+ width: 77; height: 95
+ Rectangle {
+ objectName: "centered"
+ width: 57; height: 57; color: "blue"
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
index e169fa2116..22f7966cf7 100644
--- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
+++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
@@ -77,6 +77,7 @@ private slots:
void nullItem_data();
void crash1();
void centerIn();
+ void hvCenter();
void fill();
void margins();
};
@@ -526,6 +527,19 @@ void tst_qdeclarativeanchors::centerIn()
delete view;
}
+void tst_qdeclarativeanchors::hvCenter()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("centered"));
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+ // test QTBUG-10999
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 19.0);
+ delete view;
+}
+
void tst_qdeclarativeanchors::margins()
{
QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index b07849dc59..0df28d02e8 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include "../../../shared/util.h"
#include "../shared/testhttpserver.h"
#include <math.h>
@@ -811,7 +812,7 @@ QDeclarativeView *tst_qdeclarativetextedit::createView(const QString &filename)
class MyInputContext : public QInputContext
{
public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
+ MyInputContext() : openInputPanelReceived(false), closeInputPanelReceived(false) {}
~MyInputContext() {}
QString identifierName() { return QString(); }
@@ -824,10 +825,13 @@ public:
bool filterEvent( const QEvent *event )
{
if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
+ openInputPanelReceived = true;
+ if (event->type() == QEvent::CloseSoftwareInputPanel)
+ closeInputPanelReceived = true;
return QInputContext::filterEvent(event);
}
- bool softwareInputPanelEventReceived;
+ bool openInputPanelReceived;
+ bool closeInputPanelReceived;
};
void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
@@ -835,10 +839,9 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ view.setInputContext(&ic);
QDeclarativeTextEdit edit;
+ QSignalSpy inputPanelonFocusSpy(&edit, SIGNAL(showInputPanelOnFocusChanged(bool)));
edit.setText("Hello world");
edit.setPos(0, 0);
scene.addItem(&edit);
@@ -847,16 +850,77 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+
+ QVERIFY(edit.showInputPanelOnFocus());
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ // focus on press, input panel on focus
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
QApplication::processEvents();
- if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) {
- QCOMPARE(ic.softwareInputPanelEventReceived, false);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- } else if (behavior == QStyle::RSIP_OnMouseClick) {
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- }
+ QVERIFY(edit.hasFocus());
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // no events on release
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // Even with focus already gained, user needs
+ // to be able to open panel by pressing on the editor
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // input panel closed on focus lost
+ edit.setFocus(false);
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.closeInputPanelReceived = false;
+
+ // no input panel events if showInputPanelOnFocus is false
+ edit.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ edit.setFocus(false);
+ edit.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ edit.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+
+ // one show input panel event when openSoftwareInputPanel is called
+ edit.openSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // one close input panel event when closeSoftwareInputPanel is called
+ edit.closeSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.openInputPanelReceived = false;
+
+ // set showInputPanelOnFocus back to true
+ edit.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
+ edit.setFocus(false);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ edit.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+
+ edit.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
}
void tst_qdeclarativetextedit::geometrySignals()
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index ac80edb464..155223d9a7 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QtTest/QSignalSpy>
#include "../../../shared/util.h"
#include <QtDeclarative/qdeclarativeengine.h>
#include <QFile>
@@ -712,11 +713,10 @@ QDeclarativeView *tst_qdeclarativetextinput::createView(const QString &filename)
return canvas;
}
-
class MyInputContext : public QInputContext
{
public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
+ MyInputContext() : openInputPanelReceived(false), closeInputPanelReceived(false) {}
~MyInputContext() {}
QString identifierName() { return QString(); }
@@ -729,10 +729,13 @@ public:
bool filterEvent( const QEvent *event )
{
if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
+ openInputPanelReceived = true;
+ if (event->type() == QEvent::CloseSoftwareInputPanel)
+ closeInputPanelReceived = true;
return QInputContext::filterEvent(event);
}
- bool softwareInputPanelEventReceived;
+ bool openInputPanelReceived;
+ bool closeInputPanelReceived;
};
void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
@@ -740,10 +743,9 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ view.setInputContext(&ic);
QDeclarativeTextInput input;
+ QSignalSpy inputPanelonFocusSpy(&input, SIGNAL(showInputPanelOnFocusChanged(bool)));
input.setText("Hello world");
input.setPos(0, 0);
scene.addItem(&input);
@@ -752,16 +754,77 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+
+ QVERIFY(input.showInputPanelOnFocus());
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ // focus on press, input panel on focus
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
QApplication::processEvents();
- if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) {
- QCOMPARE(ic.softwareInputPanelEventReceived, false);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- } else if (behavior == QStyle::RSIP_OnMouseClick) {
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
- }
+ QVERIFY(input.hasFocus());
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // no events on release
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // Even with focus already gained, user needs
+ // to be able to open panel by pressing on the editor
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // input panel closed on focus lost
+ input.setFocus(false);
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.closeInputPanelReceived = false;
+
+ // no input panel events if showInputPanelOnFocus is false
+ input.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ input.setFocus(false);
+ input.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+
+ input.setShowInputPanelOnFocus(false);
+ QCOMPARE(inputPanelonFocusSpy.count(),1);
+
+ // one show input panel event when openSoftwareInputPanel is called
+ input.openSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
+ ic.openInputPanelReceived = false;
+
+ // one close input panel event when closeSoftwareInputPanel is called
+ input.closeSoftwareInputPanel();
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ ic.openInputPanelReceived = false;
+
+ // set showInputPanelOnFocus back to true
+ input.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
+ input.setFocus(false);
+ QCOMPARE(ic.openInputPanelReceived, false);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+ input.setFocus(true);
+ QCOMPARE(ic.openInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, true);
+
+ input.setShowInputPanelOnFocus(true);
+ QCOMPARE(inputPanelonFocusSpy.count(),2);
}
class MyTextInput : public QDeclarativeTextInput
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml
new file mode 100644
index 0000000000..d275ca8511
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml
@@ -0,0 +1,24 @@
+import Qt 4.7
+
+WorkerScript {
+ id: worker
+
+ property variant response
+
+ signal done()
+
+ function testSend(value) {
+ worker.sendMessage(value)
+ }
+
+ function compareLiteralResponse(expected) {
+ var e = eval('(' + expected + ')')
+ return worker.response == e
+ }
+
+ onMessage: {
+ worker.response = messageObject
+ worker.done()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
index 09199de9be..90aae263a1 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
@@ -2,4 +2,3 @@ WorkerScript.onMessage = function(msg) {
WorkerScript.sendMessage(msg)
}
-
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js
new file mode 100644
index 0000000000..14f6f178ae
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js
@@ -0,0 +1,4 @@
+WorkerScript.onMessage = function(msg) {
+ WorkerScript.sendMessage('Hello_World')
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js
new file mode 100644
index 0000000000..cb3b6d3398
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js
@@ -0,0 +1,6 @@
+.pragma library
+
+WorkerScript.onMessage = function(msg) {
+ WorkerScript.sendMessage(msg)
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
index 5c7a5ff26e..1a20098ef7 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
@@ -1,24 +1,5 @@
import Qt 4.7
-WorkerScript {
- id: worker
+BaseWorker {
source: "script.js"
-
- property variant response
-
- signal done()
-
- function testSend(value) {
- worker.sendMessage(value)
- }
-
- function compareLiteralResponse(expected) {
- var e = eval('(' + expected + ')')
- return worker.response == e
- }
-
- onMessage: {
- worker.response = messageObject
- worker.done()
- }
}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml
new file mode 100644
index 0000000000..3b720ef473
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml
@@ -0,0 +1,6 @@
+import Qt 4.7
+
+BaseWorker {
+ source: "script_pragma.js"
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index a1dae24770..7a4315a050 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -64,6 +64,7 @@ private slots:
void messaging_data();
void messaging_sendQObjectList();
void messaging_sendJsObject();
+ void script_with_pragma();
private:
void waitForEchoMessage(QDeclarativeWorkerScript *worker) {
@@ -82,18 +83,25 @@ private:
void tst_QDeclarativeWorkerScript::source()
{
- QUrl source = QUrl::fromLocalFile(SRCDIR "/data/worker.qml");
-
- QDeclarativeComponent component(&m_engine);
- component.setData("import Qt 4.7\nWorkerScript { source: '" + source.toString().toUtf8() + "'; }", QUrl());
+ QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml");
+ QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+ const QMetaObject *mo = worker->metaObject();
- QDeclarativeWorkerScript *item = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(item != 0);
+ QVariant value(100);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
- QCOMPARE(item->source(), source);
+ QUrl source = QUrl::fromLocalFile(SRCDIR "/data/script_fixed_return.js");
+ worker->setSource(source);
+ QCOMPARE(worker->source(), source);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
qApp->processEvents();
- delete item;
+ delete worker;
}
void tst_QDeclarativeWorkerScript::messaging()
@@ -177,6 +185,25 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
delete worker;
}
+void tst_QDeclarativeWorkerScript::script_with_pragma()
+{
+ QVariant value(100);
+
+ QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_pragma.qml");
+ QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ qApp->processEvents();
+ delete worker;
+}
+
+
QTEST_MAIN(tst_QDeclarativeWorkerScript)
#include "tst_qdeclarativeworkerscript.moc"
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml
index d948e4a494..73dd4d7844 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/plaintext.qml
@@ -85,7 +85,7 @@ Rectangle {
text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAnywhere
}
Text {
- text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.Wrap
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml
index d10cfd3d1b..b41b93a31a 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativetext/font/richtext.qml
@@ -85,7 +85,7 @@ Rectangle {
text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAnywhere
}
Text {
- text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ text: s.text + " thisisaverylongstringwithnospaces"; width: 150; wrapMode: Text.Wrap
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml
index abb446423c..a1dc5bf17f 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/wrap.qml
@@ -27,7 +27,7 @@ Item {
TextEdit {
width: 150
height: 100
- wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
+ wrapMode: TextEdit.Wrap
text: "This is a test that text edit wraps correctly. thisisaverylongstringwithnospaces"
y:300
}
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index a15522263c..67a41ca81a 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -275,6 +275,7 @@ private slots:
void polishItems2();
void isActive();
void siblingIndexAlwaysValid();
+ void removeFullyTransparentItem();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -4333,6 +4334,48 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid()
}
+void tst_QGraphicsScene::removeFullyTransparentItem()
+{
+ QGraphicsScene scene;
+
+ QGraphicsItem *parent = scene.addRect(0, 0, 100, 100);
+ parent->setFlag(QGraphicsItem::ItemHasNoContents);
+
+ QGraphicsItem *child = scene.addRect(0, 0, 100, 100);
+ child->setParentItem(parent);
+
+ CustomView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ // NB! The parent has the ItemHasNoContents flag set, which means
+ // the parent itself doesn't generate any update requests, only the
+ // child can possibly trigger an update. Also note that the child
+ // is removed before processing events.
+ view.repaints = 0;
+ parent->setOpacity(0);
+ QVERIFY(qFuzzyIsNull(child->effectiveOpacity()));
+ scene.removeItem(child);
+ QVERIFY(!scene.items().contains(child));
+ QTRY_VERIFY(view.repaints > 0);
+
+ // Re-add child. There's nothing new to display (child is still
+ // effectively hidden), so it shouldn't trigger an update.
+ view.repaints = 0;
+ child->setParentItem(parent);
+ QVERIFY(scene.items().contains(child));
+ QVERIFY(qFuzzyIsNull(child->effectiveOpacity()));
+ QApplication::processEvents();
+ QCOMPARE(view.repaints, 0);
+
+ // Nothing is visible on the screen, removing child item shouldn't trigger an update.
+ scene.removeItem(child);
+ QApplication::processEvents();
+ QCOMPARE(view.repaints, 0);
+ delete child;
+}
+
void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache()
{
QGraphicsScene scene;
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 992c95e4c0..53fefeedc8 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -127,6 +127,8 @@ private slots:
void sortColumnTracking1();
void sortColumnTracking2();
+ void sortStable();
+
void task236755_hiddenColumns();
void task247867_insertRowsSort();
void task248868_staticSorting();
@@ -2442,6 +2444,40 @@ void tst_QSortFilterProxyModel::sortColumnTracking2()
QCOMPARE(proxyModel.data(proxyModel.index(strings.count()-1,0)).toString(),QString::fromLatin1("zz"));
}
+void tst_QSortFilterProxyModel::sortStable()
+{
+ QStandardItemModel* model = new QStandardItemModel(5, 2);
+ for (int r=0; r<5; r++) {
+ for (int c=0; c<2; c++) {
+ QStandardItem* item = new QStandardItem(
+ QString("Row:%0, Column:%1").arg(r).arg(c) );
+ for( int i=0; i<3; i++ ) {
+ QStandardItem* child = new QStandardItem(
+ QString("Item %0").arg(i) );
+ item->appendRow( child );
+ }
+ model->setItem(r, c, item);
+ }
+ }
+ model->setHorizontalHeaderItem( 0, new QStandardItem( "Name" ));
+ model->setHorizontalHeaderItem( 1, new QStandardItem( "Value" ) );
+
+
+ QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(model);
+ filterModel->setSourceModel(model);
+
+ QTreeView *view = new QTreeView;
+ view->setModel(filterModel);
+ QModelIndex firstRoot = filterModel->index(0,0);
+ view->expand(firstRoot);
+ view->setSortingEnabled(true);
+
+ view->model()->sort(1, Qt::DescendingOrder);
+ QVariant lastItemData =filterModel->index(2,0, firstRoot).data();
+ view->model()->sort(1, Qt::DescendingOrder);
+ QCOMPARE(lastItemData, filterModel->index(2,0, firstRoot).data());
+}
+
void tst_QSortFilterProxyModel::task236755_hiddenColumns()
{
class MyStandardItemModel : public QStandardItemModel
diff --git a/tests/auto/qxmlstream/qxmlstream.pro b/tests/auto/qxmlstream/qxmlstream.pro
index ac03d421d1..f82a7b3dba 100644
--- a/tests/auto/qxmlstream/qxmlstream.pro
+++ b/tests/auto/qxmlstream/qxmlstream.pro
@@ -1,5 +1,5 @@
load(qttest_p4)
-SOURCES += tst_qxmlstream.cpp
+SOURCES += tst_qxmlstream.cpp
QT = core xml network
@@ -8,4 +8,7 @@ wince*|symbian*: {
addFiles.sources = data XML-Test-Suite
addFiles.path = .
DEPLOYMENT += addFiles
+ DEFINES += SRCDIR=\\\"\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp
index 3c5358c36c..7d5e3b7f8c 100644
--- a/tests/auto/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp
@@ -57,7 +57,7 @@
Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour)
-static const char *const catalogFile = "XML-Test-Suite/xmlconf/finalCatalog.xml";
+static const char *const catalogFile = SRCDIR "XML-Test-Suite/xmlconf/finalCatalog.xml";
static const int expectedRunCount = 1646;
static const int expectedSkipCount = 532;
@@ -527,8 +527,7 @@ class tst_QXmlStream: public QObject
{
Q_OBJECT
public:
- tst_QXmlStream() : m_handler(QUrl::fromLocalFile(QDir::currentPath() + QLatin1Char('/'))
- .resolved(QUrl(QLatin1String(catalogFile))))
+ tst_QXmlStream() : m_handler(QUrl::fromLocalFile(QLatin1String(catalogFile)))
{
}
@@ -546,6 +545,7 @@ private slots:
void writerHangs() const;
void writerAutoFormattingWithComments() const;
void writerAutoFormattingWithTabs() const;
+ void writerAutoFormattingWithProcessingInstructions() const;
void writerAutoEmptyTags() const;
void writeAttributesWithSpace() const;
void addExtraNamespaceDeclarations();
@@ -805,7 +805,7 @@ void tst_QXmlStream::testReader_data() const
QTest::addColumn<QString>("xml");
QTest::addColumn<QString>("ref");
QDir dir;
- dir.cd("data/");
+ dir.cd(SRCDIR "data/");
foreach(QString filename , dir.entryList(QStringList() << "*.xml")) {
QString reference = QFileInfo(filename).baseName() + ".ref";
QTest::newRow(dir.filePath(filename).toLatin1().data()) << dir.filePath(filename) << dir.filePath(reference);
@@ -1030,6 +1030,22 @@ void tst_QXmlStream::writerAutoFormattingWithTabs() const
QCOMPARE(buffer.buffer().data(), str);
}
+void tst_QXmlStream::writerAutoFormattingWithProcessingInstructions() const
+{
+ QBuffer buffer;
+ buffer.open(QIODevice::WriteOnly);
+
+ QXmlStreamWriter writer(&buffer);
+ writer.setAutoFormatting(true);
+ writer.writeStartDocument();
+ writer.writeProcessingInstruction("B", "C");
+ writer.writeStartElement("A");
+ writer.writeEndElement();
+ writer.writeEndDocument();
+ const char *str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?B C?>\n<A/>\n";
+ QCOMPARE(buffer.buffer().data(), str);
+}
+
/*!
Task 204822
*/
@@ -1184,7 +1200,7 @@ void tst_QXmlStream::crashInUTF16Codec() const
QEventLoop eventLoop;
QNetworkAccessManager networkManager;
- QNetworkRequest request(QUrl::fromLocalFile(QLatin1String("data/051reduced.xml")));
+ QNetworkRequest request(QUrl::fromLocalFile(QLatin1String(SRCDIR "data/051reduced.xml")));
QNetworkReply *const reply = networkManager.get(request);
eventLoop.connect(reply, SIGNAL(finished()), SLOT(quit()));