summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-03-23 07:36:02 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2011-03-23 07:36:02 (GMT)
commitb98ebf6be783413a36707ea16c4453e6f6fe6634 (patch)
tree361ea09226478a2496213a1ae713e1a1838f6460 /tests
parent0f5feed7dc260eabe1c2784a168e0b2fcc85e1d8 (diff)
parentf20b9460e1e67a0ddd7e4e69224722d5b8c3f5c9 (diff)
downloadQt-b98ebf6be783413a36707ea16c4453e6f6fe6634.zip
Qt-b98ebf6be783413a36707ea16c4453e6f6fe6634.tar.gz
Qt-b98ebf6be783413a36707ea16c4453e6f6fe6634.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp39
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp39
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp24
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp12
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp7
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/dragpath.qml2
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp40
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/Global.js1
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js5
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp19
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp69
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp14
-rwxr-xr-xtests/auto/qimagereader/images/txts.pngbin0 -> 5413 bytes
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc1
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp28
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp192
-rw-r--r--tests/auto/qpainterpath/tst_qpainterpath.cpp5
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp166
-rw-r--r--tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp2
-rw-r--r--tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp2
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp29
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp17
-rw-r--r--tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp85
-rw-r--r--tests/auto/qtextstream/tst_qtextstream.cpp36
-rw-r--r--tests/auto/qwindowsurface/tst_qwindowsurface.cpp48
31 files changed, 815 insertions, 128 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml b/tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml
new file mode 100644
index 0000000..dcbb20b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.0
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: 200; contentHeight: 300
+
+ QGraphicsWidget { width: 200; height: 300; enabled: false }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 65ba316..d499edf 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -69,6 +69,7 @@ private slots:
void maximumFlickVelocity();
void flickDeceleration();
void pressDelay();
+ void disabledContent();
void nestedPressDelay();
void flickableDirection();
void qgraphicswidget();
@@ -247,6 +248,44 @@ void tst_qdeclarativeflickable::pressDelay()
QCOMPARE(spy.count(),1);
}
+// QT-4677
+void tst_qdeclarativeflickable::disabledContent()
+{
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabledcontent.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QVERIFY(flickable->contentX() == 0);
+ QVERIFY(flickable->contentY() == 0);
+
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50)));
+ {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(70,70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(90,90)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(100,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ }
+
+ QVERIFY(flickable->contentX() < 0);
+ QVERIFY(flickable->contentY() < 0);
+
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(90, 90)));
+
+ delete canvas;
+}
+
+
// QTBUG-17361
void tst_qdeclarativeflickable::nestedPressDelay()
{
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 5ced02b..c183934 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -69,6 +69,7 @@ private slots:
void changed();
void inserted();
void removed();
+ void clear();
void moved();
void changeFlow();
void currentIndex();
@@ -501,6 +502,44 @@ void tst_QDeclarativeGridView::removed()
delete canvas;
}
+void tst_QDeclarativeGridView::clear()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ model.clear();
+
+ QVERIFY(gridview->count() == 0);
+ QVERIFY(gridview->currentItem() == 0);
+ QVERIFY(gridview->contentY() == 0);
+ QVERIFY(gridview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QVERIFY(gridview->count() == 1);
+ QVERIFY(gridview->currentItem() != 0);
+ QVERIFY(gridview->currentIndex() == 0);
+
+ delete canvas;
+}
+
void tst_QDeclarativeGridView::moved()
{
QDeclarativeView *canvas = createView();
diff --git a/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml
new file mode 100644
index 0000000..29fba40
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml
@@ -0,0 +1,30 @@
+import QtQuick 1.0
+Rectangle {
+ width: 400
+ height: 400
+
+ Item {
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.bottom: blueHandle.top
+ anchors.right: blueHandle.left
+
+ Image {
+ id: iconImage
+ objectName: "iconImage"
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ source: "heart200.png"
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ }
+ }
+
+ Rectangle {
+ id: blueHandle
+ objectName: "blueHandle"
+ color: "blue"
+ width: 25
+ height: 25
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index f1fe2bd..9e090d2 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -89,6 +89,7 @@ private slots:
void noLoading();
void paintedWidthHeight();
void sourceSize_QTBUG_14303();
+ void sourceSize_QTBUG_16389();
void nullPixmapPaint();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
@@ -640,6 +641,29 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303()
QTRY_COMPARE(sourceSizeSpy.count(), 2);
}
+void tst_qdeclarativeimage::sourceSize_QTBUG_16389()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug_16389.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QDeclarativeImage *image = findItem<QDeclarativeImage>(canvas->rootObject(), "iconImage");
+ QDeclarativeItem *handle = findItem<QDeclarativeItem>(canvas->rootObject(), "blueHandle");
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 0.0);
+ QCOMPARE(image->paintedHeight(), 0.0);
+
+ handle->setY(20);
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 20.0);
+ QCOMPARE(image->paintedHeight(), 20.0);
+}
+
static int numberOfWarnings = 0;
static void checkWarnings(QtMsgType, const char *)
{
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml
new file mode 100644
index 0000000..4526cf0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+
+QtObject {
+ property InlineAssignmentsOverrideBindingsType2 nested: InlineAssignmentsOverrideBindingsType2 {
+ value: 19 * 33
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml
new file mode 100644
index 0000000..4127ca4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+
+QtObject {
+ property int value
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml b/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml
new file mode 100644
index 0000000..8f3c5ce
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml
@@ -0,0 +1,6 @@
+import QtQuick 1.0
+
+InlineAssignmentsOverrideBindingsType {
+ property int test: nested.value
+ nested.value: 11
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index f3f41a9..5a2591f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -134,6 +134,7 @@ private slots:
void dontDoubleCallClassBegin();
void reservedWords_data();
void reservedWords();
+ void inlineAssignmentsOverrideBindings();
void basicRemote_data();
void basicRemote();
@@ -1413,9 +1414,18 @@ void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type,
}
}
+// QTBUG-17276
+void tst_qdeclarativelanguage::inlineAssignmentsOverrideBindings()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml"));
-// Import tests (QT-558)
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toInt(), 11);
+ delete o;
+}
+// Import tests (QT-558)
void tst_qdeclarativelanguage::importsBuiltin_data()
{
// QT-610
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index c87318e..2267a89 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -741,6 +741,13 @@ void tst_QDeclarativeListView::clear()
QTRY_VERIFY(listview->count() == 0);
QTRY_VERIFY(listview->currentItem() == 0);
QTRY_VERIFY(listview->contentY() == 0);
+ QVERIFY(listview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QTRY_VERIFY(listview->count() == 1);
+ QVERIFY(listview->currentItem() != 0);
+ QVERIFY(listview->currentIndex() == 0);
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml b/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml
index a361bdc..0f94840 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml
@@ -9,7 +9,7 @@ PathView {
startX: 0; startY: 100
PathLine { x: 400; y: 100 }
}
- delegate: Rectangle { height: 100; width: 1; color: PathView.isCurrentItem?"red" : "black" }
+ delegate: Rectangle { objectName: "wrapper"; height: 100; width: 2; color: PathView.isCurrentItem?"red" : "black" }
dragMargin: 100
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index ebb5f98..8000137 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -111,6 +111,7 @@ private slots:
void undefinedPath();
void mouseDrag();
void treeModel();
+ void changePreferredHighlight();
private:
QDeclarativeView *createView();
@@ -948,6 +949,45 @@ void tst_QDeclarativePathView::treeModel()
delete canvas;
}
+void tst_QDeclarativePathView::changePreferredHighlight()
+{
+ QDeclarativeView *canvas = createView();
+ canvas->setFixedSize(400,200);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml"));
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ int current = pathview->currentIndex();
+ QCOMPARE(current, 0);
+
+ QDeclarativeRectangle *firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.5);
+ start.setX(qRound(start.x()));
+ start.setY(qRound(start.y()));
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ pathview->setPreferredHighlightBegin(0.8);
+ pathview->setPreferredHighlightEnd(0.8);
+ start = path->pointAt(0.8);
+ start.setX(qRound(start.x()));
+ start.setY(qRound(start.y()));
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentIndex(), 0);
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js b/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
new file mode 100644
index 0000000..6bdb4a5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
@@ -0,0 +1 @@
+var data = "World"
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
new file mode 100644
index 0000000..0385d91
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
@@ -0,0 +1,5 @@
+WorkerScript.onMessage = function(msg) {
+ var res = Qt.include("Global.js");
+ WorkerScript.sendMessage(msg + " " + data)
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
new file mode 100644
index 0000000..595cb2b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+
+BaseWorker {
+ source: "script_include.js"
+}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index 4b922fb..b64e10c 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -79,6 +79,7 @@ private slots:
void messaging_sendQObjectList();
void messaging_sendJsObject();
void script_with_pragma();
+ void script_included();
void scriptError_onLoad();
void scriptError_onCall();
@@ -226,6 +227,24 @@ void tst_QDeclarativeWorkerScript::script_with_pragma()
delete worker;
}
+void tst_QDeclarativeWorkerScript::script_included()
+{
+ QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_include.qml");
+ QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QString value("Hello");
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World");
+
+ qApp->processEvents();
+ delete worker;
+}
+
static QString qdeclarativeworkerscript_lastWarning;
static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char *msg)
{
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index dacb61e..168f75e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -447,7 +447,8 @@ private slots:
void updateMicroFocus();
void textItem_shortcuts();
void scroll();
- void stopClickFocusPropagation();
+ void focusHandling_data();
+ void focusHandling();
void deviceCoordinateCache_simpleRotations();
// task specific tests below me
@@ -10537,8 +10538,39 @@ void tst_QGraphicsItem::scroll()
QCOMPARE(item2->lastExposedRect, expectedItem2Expose);
}
-void tst_QGraphicsItem::stopClickFocusPropagation()
+Q_DECLARE_METATYPE(QGraphicsItem::GraphicsItemFlag);
+
+void tst_QGraphicsItem::focusHandling_data()
{
+ QTest::addColumn<QGraphicsItem::GraphicsItemFlag>("focusFlag");
+ QTest::addColumn<bool>("useStickyFocus");
+ QTest::addColumn<int>("expectedFocusItem"); // 0: none, 1: focusableUnder, 2: itemWithFocus
+
+ QTest::newRow("Focus goes through.")
+ << static_cast<QGraphicsItem::GraphicsItemFlag>(0x0) << false << 1;
+
+ QTest::newRow("Focus goes through, even with sticky scene.")
+ << static_cast<QGraphicsItem::GraphicsItemFlag>(0x0) << true << 1;
+
+ QTest::newRow("With ItemStopsClickFocusPropagation, we cannot focus the item beneath the flagged one (but can still focus-out).")
+ << QGraphicsItem::ItemStopsClickFocusPropagation << false << 0;
+
+ QTest::newRow("With ItemStopsClickFocusPropagation, we cannot focus the item beneath the flagged one (and cannot focus-out if scene is sticky).")
+ << QGraphicsItem::ItemStopsClickFocusPropagation << true << 2;
+
+ QTest::newRow("With ItemStopsFocusHandling, focus cannot be changed by presses.")
+ << QGraphicsItem::ItemStopsFocusHandling << false << 2;
+
+ QTest::newRow("With ItemStopsFocusHandling, focus cannot be changed by presses (even if scene is sticky).")
+ << QGraphicsItem::ItemStopsFocusHandling << true << 2;
+}
+
+void tst_QGraphicsItem::focusHandling()
+{
+ QFETCH(QGraphicsItem::GraphicsItemFlag, focusFlag);
+ QFETCH(bool, useStickyFocus);
+ QFETCH(int, expectedFocusItem);
+
class MyItem : public QGraphicsRectItem
{
public:
@@ -10549,12 +10581,9 @@ void tst_QGraphicsItem::stopClickFocusPropagation()
}
};
- QGraphicsScene scene(-50, -50, 400, 400);
- scene.setStickyFocus(true);
-
QGraphicsRectItem *noFocusOnTop = new MyItem;
+ noFocusOnTop->setFlag(QGraphicsItem::ItemIsFocusable, false);
noFocusOnTop->setBrush(Qt::yellow);
- noFocusOnTop->setFlag(QGraphicsItem::ItemStopsClickFocusPropagation);
QGraphicsRectItem *focusableUnder = new MyItem;
focusableUnder->setBrush(Qt::blue);
@@ -10566,9 +10595,13 @@ void tst_QGraphicsItem::stopClickFocusPropagation()
itemWithFocus->setFlag(QGraphicsItem::ItemIsFocusable);
itemWithFocus->setPos(250, 10);
+ QGraphicsScene scene(-50, -50, 400, 400);
scene.addItem(noFocusOnTop);
scene.addItem(focusableUnder);
scene.addItem(itemWithFocus);
+ scene.setStickyFocus(useStickyFocus);
+
+ noFocusOnTop->setFlag(focusFlag);
focusableUnder->stackBefore(noFocusOnTop);
itemWithFocus->setFocus();
@@ -10580,14 +10613,28 @@ void tst_QGraphicsItem::stopClickFocusPropagation()
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
QVERIFY(itemWithFocus->hasFocus());
- QPointF mousePressPoint = noFocusOnTop->mapToScene(QPointF());
- mousePressPoint.rx() += 60;
- mousePressPoint.ry() += 60;
+ const QPointF mousePressPoint = noFocusOnTop->mapToScene(noFocusOnTop->boundingRect().center());
const QList<QGraphicsItem *> itemsAtMousePressPosition = scene.items(mousePressPoint);
- QVERIFY(itemsAtMousePressPosition.contains(focusableUnder));
+ QVERIFY(itemsAtMousePressPosition.contains(noFocusOnTop));
sendMousePress(&scene, mousePressPoint);
- QVERIFY(itemWithFocus->hasFocus());
+
+ switch (expectedFocusItem) {
+ case 0:
+ QCOMPARE(scene.focusItem(), static_cast<QGraphicsRectItem *>(0));
+ break;
+ case 1:
+ QCOMPARE(scene.focusItem(), focusableUnder);
+ break;
+ case 2:
+ QCOMPARE(scene.focusItem(), itemWithFocus);
+ break;
+ }
+
+ // Sanity check - manually setting the focus must work regardless of our
+ // focus handling flags:
+ focusableUnder->setFocus();
+ QCOMPARE(scene.focusItem(), focusableUnder);
}
void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations()
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
index 79f2213..9434a0b 100644
--- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -163,10 +163,11 @@ static inline bool fuzzyCompare(qreal p1, qreal p2)
{
// increase delta on small machines using float instead of double
if (sizeof(qreal) == sizeof(float))
- return (qAbs(p1 - p2) <= 0.00002f * qMin(qAbs(p1), qAbs(p2)));
+ return (qAbs(p1 - p2) <= 0.00003f * qMin(qAbs(p1), qAbs(p2)));
else
return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
}
+
static bool fuzzyCompare(const QTransform& t1, const QTransform& t2)
{
return fuzzyCompare(t1.m11(), t2.m11()) &&
@@ -180,6 +181,15 @@ static bool fuzzyCompare(const QTransform& t1, const QTransform& t2)
fuzzyCompare(t1.m33(), t2.m33());
}
+static inline bool fuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2)
+{
+ bool ok = true;
+ for (int y = 0; y < 4; ++y)
+ for (int x = 0; x < 4; ++x)
+ ok &= fuzzyCompare(m1(y, x), m2(y, x));
+ return ok;
+}
+
void tst_QGraphicsTransform::rotation()
{
QGraphicsRotation rotation;
@@ -267,7 +277,7 @@ void tst_QGraphicsTransform::rotation3d()
// because the deg2rad value in QTransform is not accurate
// enough to match what QMatrix4x4 is doing.
} else {
- QVERIFY(qFuzzyCompare(t, r));
+ QVERIFY(fuzzyCompare(t, r));
}
//now let's check that a null vector will not change the transform
diff --git a/tests/auto/qimagereader/images/txts.png b/tests/auto/qimagereader/images/txts.png
new file mode 100755
index 0000000..99be1eb
--- /dev/null
+++ b/tests/auto/qimagereader/images/txts.png
Binary files differ
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index 5536b38..632b73a 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -64,5 +64,6 @@
<file>images/corrupt.svg</file>
<file>images/corrupt.svgz</file>
<file>images/qtbug13653-no_eoi.jpg</file>
+ <file>images/txts.png</file>
</qresource>
</RCC>
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index f02fd6a..5db5f56 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -183,6 +183,9 @@ private slots:
void saveFormat_data();
void saveFormat();
+ void readText_data();
+ void readText();
+
void preserveTexts_data();
void preserveTexts();
};
@@ -1968,6 +1971,31 @@ void tst_QImageReader::saveFormat()
}
+void tst_QImageReader::readText_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QString>("key");
+ QTest::addColumn<QString>("text");
+
+ QTest::newRow("png, tEXt before img") << "txts.png" << "Title" << "PNG";
+ QTest::newRow("png, zTXt before img") << "txts.png" << "Comment" << "Some compressed text.";
+ QTest::newRow("png, tEXt after img") << "txts.png" << "Disclaimer" << "For testing only.";
+ QTest::newRow("png, zTXt after img") << "txts.png" << "Description" << "Rendered by Persistence of Vision (tm) Ray Tracer";
+}
+
+
+void tst_QImageReader::readText()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QString, key);
+ QFETCH(QString, text);
+
+ QImage img(prefix + fileName);
+ QVERIFY(img.textKeys().contains(key));
+ QCOMPARE(img.text(key), text);
+}
+
+
void tst_QImageReader::preserveTexts_data()
{
QTest::addColumn<QString>("text");
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 93e3051..2c79951 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -345,6 +345,8 @@ private Q_SLOTS:
void httpAbort();
+ void dontInsertPartialContentIntoTheCache();
+
// NOTE: This test must be last!
void parentingRepliesToTheApp();
};
@@ -498,7 +500,6 @@ public slots:
if (doClose && client->bytesToWrite() == 0) {
client->disconnectFromHost();
disconnect(client, 0, this, 0);
- client = 0;
}
}
};
@@ -590,6 +591,63 @@ public:
Q_DECLARE_METATYPE(MyMemoryCache::CachedContent)
Q_DECLARE_METATYPE(MyMemoryCache::CacheData)
+class MySpyMemoryCache: public QAbstractNetworkCache
+{
+public:
+ MySpyMemoryCache(QObject *parent) : QAbstractNetworkCache(parent) {}
+ ~MySpyMemoryCache()
+ {
+ qDeleteAll(m_buffers);
+ m_buffers.clear();
+ }
+
+ QHash<QUrl, QIODevice*> m_buffers;
+ QList<QUrl> m_insertedUrls;
+
+ QNetworkCacheMetaData metaData(const QUrl &)
+ {
+ return QNetworkCacheMetaData();
+ }
+
+ void updateMetaData(const QNetworkCacheMetaData &)
+ {
+ }
+
+ QIODevice *data(const QUrl &)
+ {
+ return 0;
+ }
+
+ bool remove(const QUrl &url)
+ {
+ delete m_buffers.take(url);
+ return m_insertedUrls.removeAll(url) > 0;
+ }
+
+ qint64 cacheSize() const
+ {
+ return 0;
+ }
+
+ QIODevice *prepare(const QNetworkCacheMetaData &metaData)
+ {
+ QBuffer* buffer = new QBuffer;
+ buffer->open(QIODevice::ReadWrite);
+ buffer->setProperty("url", metaData.url());
+ m_buffers.insert(metaData.url(), buffer);
+ return buffer;
+ }
+
+ void insert(QIODevice *buffer)
+ {
+ QUrl url = buffer->property("url").toUrl();
+ m_insertedUrls << url;
+ delete m_buffers.take(url);
+ }
+
+ void clear() { m_insertedUrls.clear(); }
+};
+
class DataReader: public QObject
{
Q_OBJECT
@@ -970,6 +1028,7 @@ tst_QNetworkReply::tst_QNetworkReply()
#ifndef QT_NO_OPENSSL
qRegisterMetaType<QList<QSslError> >();
#endif
+ qRegisterMetaType<QNetworkReply::NetworkError>();
Q_SET_DEFAULT_IAP
@@ -2606,6 +2665,9 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer_data()
QTest::newRow("justHalfStatus+disconnect") << QByteArray("HTTP/1.1") << true;
QTest::newRow("justStatus+disconnect") << QByteArray("HTTP/1.1 200 OK\r\n") << true;
QTest::newRow("justStatusAndHalfHeaders+disconnect") << QByteArray("HTTP/1.1 200 OK\r\nContent-L") << true;
+
+ QTest::newRow("halfContent+disconnect") << QByteArray("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\nAB") << true;
+
}
void tst_QNetworkReply::ioGetFromHttpBrokenServer()
@@ -2617,29 +2679,35 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply = manager.get(request);
+ QSignalSpy spy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
+
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->url(), request.url());
+ QCOMPARE(spy.count(), 1);
QVERIFY(reply->error() != QNetworkReply::NoError);
}
void tst_QNetworkReply::ioGetFromHttpStatus100_data()
{
QTest::addColumn<QByteArray>("dataToSend");
- QTest::newRow("normal") << QByteArray("HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("minimal") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("minimal2") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\r\n\r\n");
- QTest::newRow("minimal3") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\n\n");
- QTest::newRow("with_headers") << QByteArray("HTTP/1.1 100 Continue\r\nBla: x\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("with_headers2") << QByteArray("HTTP/1.1 100 Continue\nBla: x\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ QTest::addColumn<int>("statusCode");
+ QTest::newRow("normal") << QByteArray("HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
+ QTest::newRow("minimal") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
+ QTest::newRow("minimal2") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\r\n\r\n") << 200;
+ QTest::newRow("minimal3") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\n\n") << 200;
+ QTest::newRow("minimal+404") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 204 No Content\r\n\r\n") << 204;
+ QTest::newRow("with_headers") << QByteArray("HTTP/1.1 100 Continue\r\nBla: x\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
+ QTest::newRow("with_headers2") << QByteArray("HTTP/1.1 100 Continue\nBla: x\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << 200;
}
void tst_QNetworkReply::ioGetFromHttpStatus100()
{
QFETCH(QByteArray, dataToSend);
+ QFETCH(int, statusCode);
MiniHttpServer server(dataToSend);
server.doClose = true;
@@ -2652,7 +2720,7 @@ void tst_QNetworkReply::ioGetFromHttpStatus100()
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
- QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
QVERIFY(reply->rawHeader("bla").isNull());
}
@@ -2687,6 +2755,7 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
QTest::addColumn<QString>("body");
QTest::addColumn<MyMemoryCache::CachedContent>("cachedReply");
QTest::addColumn<int>("cacheMode");
+ QTest::addColumn<QStringList>("extraHttpHeaders");
QTest::addColumn<bool>("loadedFromCache");
QTest::addColumn<bool>("networkUsed");
@@ -2704,11 +2773,11 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
"\r\n";
QTest::newRow("not-cached,always-network")
- << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::AlwaysNetwork) << false << true;
+ << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::AlwaysNetwork) << QStringList() << false << true;
QTest::newRow("not-cached,prefer-network")
- << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferNetwork) << false << true;
+ << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true;
QTest::newRow("not-cached,prefer-cache")
- << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferCache) << false << true;
+ << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferCache) << QStringList() << false << true;
QDateTime present = QDateTime::currentDateTime().toUTC();
QDateTime past = present.addSecs(-3600);
@@ -2730,14 +2799,14 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
content.first.setLastModified(past);
QTest::newRow("expired,200,prefer-network")
- << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << false << true;
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true;
QTest::newRow("expired,200,prefer-cache")
- << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << false << true;
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << false << true;
QTest::newRow("expired,304,prefer-network")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << true;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << true;
QTest::newRow("expired,304,prefer-cache")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << true;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << true;
//
// Set to not-expired
@@ -2749,20 +2818,20 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
content.first.setExpirationDate(future);
QTest::newRow("not-expired,200,always-network")
- << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << false << true;
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << QStringList() << false << true;
QTest::newRow("not-expired,200,prefer-network")
- << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << false;
+ << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << false;
QTest::newRow("not-expired,200,prefer-cache")
- << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false;
+ << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false;
QTest::newRow("not-expired,200,always-cache")
- << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false;
+ << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false;
QTest::newRow("not-expired,304,prefer-network")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << false;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << false;
QTest::newRow("not-expired,304,prefer-cache")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false;
QTest::newRow("not-expired,304,always-cache")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false;
//
// Set must-revalidate now
@@ -2773,20 +2842,42 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
content.first.setRawHeaders(rawHeaders);
QTest::newRow("must-revalidate,200,always-network")
- << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << false << true;
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << QStringList() << false << true;
QTest::newRow("must-revalidate,200,prefer-network")
- << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << false << true;
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true;
QTest::newRow("must-revalidate,200,prefer-cache")
- << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false;
+ << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false;
QTest::newRow("must-revalidate,200,always-cache")
- << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false;
+ << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false;
QTest::newRow("must-revalidate,304,prefer-network")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << true;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << true;
QTest::newRow("must-revalidate,304,prefer-cache")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false;
QTest::newRow("must-revalidate,304,always-cache")
- << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false;
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false;
+
+ //
+ // Partial content
+ //
+ rawHeaders.clear();
+ rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1())
+ << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=7200"); // isn't used in cache loading
+ content.first.setRawHeaders(rawHeaders);
+ content.first.setExpirationDate(future);
+
+ QByteArray reply206 =
+ "HTTP/1.0 206\r\n"
+ "Connection: keep-alive\r\n"
+ "Content-Type: text/plain\r\n"
+ "Cache-control: no-cache\r\n"
+ "Content-Range: bytes 2-6/8\r\n"
+ "Content-length: 4\r\n"
+ "\r\n"
+ "load";
+
+ QTest::newRow("partial,dontuse-cache")
+ << reply206 << "load" << content << int(QNetworkRequest::PreferCache) << (QStringList() << "Range" << "bytes=2-6") << false << true;
}
void tst_QNetworkReply::ioGetFromHttpWithCache()
@@ -2808,6 +2899,15 @@ void tst_QNetworkReply::ioGetFromHttpWithCache()
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, cacheMode);
request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
+
+ QFETCH(QStringList, extraHttpHeaders);
+ QStringListIterator it(extraHttpHeaders);
+ while (it.hasNext()) {
+ QString header = it.next();
+ QString value = it.next();
+ request.setRawHeader(header.toLatin1(), value.toLatin1()); // To latin1? Deal with it!
+ }
+
QNetworkReplyPtr reply = manager.get(request);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -5563,6 +5663,39 @@ void tst_QNetworkReply::httpAbort()
// It must not crash either.
}
+void tst_QNetworkReply::dontInsertPartialContentIntoTheCache()
+{
+ QByteArray reply206 =
+ "HTTP/1.0 206\r\n"
+ "Connection: keep-alive\r\n"
+ "Content-Type: text/plain\r\n"
+ "Cache-control: no-cache\r\n"
+ "Content-Range: bytes 2-6/8\r\n"
+ "Content-length: 4\r\n"
+ "\r\n"
+ "load";
+
+ MiniHttpServer server(reply206);
+ server.doClose = false;
+
+ MySpyMemoryCache *memoryCache = new MySpyMemoryCache(&manager);
+ manager.setCache(memoryCache);
+
+ QUrl url = "http://localhost:" + QString::number(server.serverPort());
+ QNetworkRequest request(url);
+ request.setRawHeader("Range", "bytes=2-6");
+
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QVERIFY(server.totalConnections > 0);
+ QCOMPARE(reply->readAll().constData(), "load");
+ QCOMPARE(memoryCache->m_insertedUrls.count(), 0);
+}
+
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
{
@@ -5572,4 +5705,5 @@ void tst_QNetworkReply::parentingRepliesToTheApp()
}
QTEST_MAIN(tst_QNetworkReply)
+
#include "tst_qnetworkreply.moc"
diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp
index 8382edc..86adabb 100644
--- a/tests/auto/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp
@@ -305,6 +305,11 @@ void tst_QPainterPath::contains_QPointF_data()
QTest::newRow("horizontal cubic, out left") << path << QPointF(0, 100) << false;
QTest::newRow("horizontal cubic, out right") << path << QPointF(300, 100) <<false;
QTest::newRow("horizontal cubic, in mid") << path << QPointF(150, 100) << true;
+
+ path = QPainterPath();
+ path.addEllipse(QRectF(-5000.0, -5000.0, 1500000.0, 1500000.0));
+ QTest::newRow("huge ellipse, qreal=float crash") << path << QPointF(1100000.35, 1098000.2) << true;
+
}
void tst_QPainterPath::contains_QPointF()
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 739f902..ef5833ef 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -66,6 +66,7 @@ Q_DECLARE_METATYPE(QSslSocket::SslMode)
typedef QList<QSslError::SslError> SslErrorList;
Q_DECLARE_METATYPE(SslErrorList)
Q_DECLARE_METATYPE(QSslError)
+Q_DECLARE_METATYPE(QSsl::SslProtocol)
#endif
#if defined Q_OS_HPUX && defined Q_CC_GNU
@@ -145,10 +146,11 @@ private slots:
void peerCertificateChain();
void privateKey();
void protocol();
+ void protocolServerSide_data();
+ void protocolServerSide();
void setCaCertificates();
void setLocalCertificate();
void setPrivateKey();
- void setProtocol();
void setSocketDescriptor();
void waitForEncrypted();
void waitForConnectedEncryptedReadyRead();
@@ -385,7 +387,7 @@ void tst_QSslSocket::constructing()
QVERIFY(!socket.waitForConnected(10));
QTest::ignoreMessage(QtWarningMsg, "QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");
QVERIFY(!socket.waitForDisconnected(10));
- QCOMPARE(socket.protocol(), QSsl::SslV3);
+ QCOMPARE(socket.protocol(), QSsl::SecureProtocols);
QSslConfiguration savedDefault = QSslConfiguration::defaultConfiguration();
@@ -763,15 +765,13 @@ void tst_QSslSocket::protocol()
this->socket = socket;
QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
-// qDebug() << "certs:" << certs.at(0).issuerInfo(QSslCertificate::CommonName);
socket->setCaCertificates(certs);
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(untrustedWorkaroundSlot(QList<QSslError>)));
#endif
-// qDebug() << "socket cert:" << socket->caCertificates().at(0).issuerInfo(QSslCertificate::CommonName);
- QCOMPARE(socket->protocol(), QSsl::SslV3);
+ QCOMPARE(socket->protocol(), QSsl::SecureProtocols);
{
// Fluke allows SSLv3.
socket->setProtocol(QSsl::SslV3);
@@ -835,44 +835,36 @@ void tst_QSslSocket::protocol()
QCOMPARE(socket->protocol(), QSsl::AnyProtocol);
socket->abort();
}
-}
-
-void tst_QSslSocket::setCaCertificates()
-{
- if (!QSslSocket::supportsSsl())
- return;
-
- QSslSocket socket;
- QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
- socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"));
- QCOMPARE(socket.caCertificates().size(), 1);
- socket.setCaCertificates(socket.defaultCaCertificates());
- QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
-}
-
-void tst_QSslSocket::setLocalCertificate()
-{
-}
-
-void tst_QSslSocket::setPrivateKey()
-{
-}
-
-void tst_QSslSocket::setProtocol()
-{
+ {
+ // Fluke allows SSLV3, so it allows NoSslV2
+ socket->setProtocol(QSsl::TlsV1SslV3);
+ QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3);
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+ QVERIFY(socket->waitForEncrypted());
+ QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3);
+ socket->abort();
+ QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3);
+ socket->connectToHost(QtNetworkSettings::serverName(), 443);
+ QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString()));
+ socket->startClientEncryption();
+ QVERIFY2(socket->waitForEncrypted(), qPrintable(socket->errorString()));
+ QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3);
+ socket->abort();
+ }
}
class SslServer : public QTcpServer
{
Q_OBJECT
public:
- SslServer() : socket(0) { }
+ SslServer() : socket(0), protocol(QSsl::TlsV1) { }
QSslSocket *socket;
-
+ QSsl::SslProtocol protocol;
protected:
void incomingConnection(int socketDescriptor)
{
socket = new QSslSocket(this);
+ socket->setProtocol(protocol);
connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
QFile file(SRCDIR "certs/fluke.key");
@@ -902,6 +894,116 @@ protected slots:
}
};
+void tst_QSslSocket::protocolServerSide_data()
+{
+
+ QTest::addColumn<QSsl::SslProtocol>("serverProtocol");
+ QTest::addColumn<QSsl::SslProtocol>("clientProtocol");
+ QTest::addColumn<bool>("works");
+
+ QTest::newRow("ssl2-ssl2") << QSsl::SslV2 << QSsl::SslV2 << false; // no idea why it does not work, but we don't care about SSL 2
+ QTest::newRow("ssl3-ssl3") << QSsl::SslV3 << QSsl::SslV3 << true;
+ QTest::newRow("tls1-tls1") << QSsl::TlsV1 << QSsl::TlsV1 << true;
+ QTest::newRow("tls1ssl3-tls1ssl3") << QSsl::TlsV1SslV3 << QSsl::TlsV1SslV3 << true;
+ QTest::newRow("any-any") << QSsl::AnyProtocol << QSsl::AnyProtocol << true;
+ QTest::newRow("secure-secure") << QSsl::SecureProtocols << QSsl::SecureProtocols << true;
+
+ QTest::newRow("ssl2-ssl3") << QSsl::SslV2 << QSsl::SslV3 << false;
+ QTest::newRow("ssl2-tls1") << QSsl::SslV2 << QSsl::TlsV1 << false;
+ QTest::newRow("ssl2-tls1ssl3") << QSsl::SslV2 << QSsl::TlsV1SslV3 << false;
+ QTest::newRow("ssl2-secure") << QSsl::SslV2 << QSsl::SecureProtocols << false;
+ QTest::newRow("ssl2-any") << QSsl::SslV2 << QSsl::AnyProtocol << false; // no idea why it does not work, but we don't care about SSL 2
+
+ QTest::newRow("ssl3-ssl2") << QSsl::SslV3 << QSsl::SslV2 << false;
+ QTest::newRow("ssl3-tls1") << QSsl::SslV3 << QSsl::TlsV1 << false;
+ QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true;
+ QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << true;
+ QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << true;
+
+ QTest::newRow("tls1-ssl2") << QSsl::TlsV1 << QSsl::SslV2 << false;
+ QTest::newRow("tls1-ssl3") << QSsl::TlsV1 << QSsl::SslV3 << false;
+ QTest::newRow("tls1-tls1ssl3") << QSsl::TlsV1 << QSsl::TlsV1SslV3 << true;
+ QTest::newRow("tls1-secure") << QSsl::TlsV1 << QSsl::SecureProtocols << true;
+ QTest::newRow("tls1-any") << QSsl::TlsV1 << QSsl::AnyProtocol << true;
+
+ QTest::newRow("tls1ssl3-ssl2") << QSsl::TlsV1SslV3 << QSsl::SslV2 << false;
+ QTest::newRow("tls1ssl3-ssl3") << QSsl::TlsV1SslV3 << QSsl::SslV3 << true;
+ QTest::newRow("tls1ssl3-tls1") << QSsl::TlsV1SslV3 << QSsl::TlsV1 << true;
+ QTest::newRow("tls1ssl3-secure") << QSsl::TlsV1SslV3 << QSsl::SecureProtocols << true;
+ QTest::newRow("tls1ssl3-any") << QSsl::TlsV1SslV3 << QSsl::AnyProtocol << true;
+
+ QTest::newRow("secure-ssl2") << QSsl::SecureProtocols << QSsl::SslV2 << false;
+ QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << true;
+ QTest::newRow("secure-tls1") << QSsl::SecureProtocols << QSsl::TlsV1 << true;
+ QTest::newRow("secure-tls1ssl3") << QSsl::SecureProtocols << QSsl::TlsV1SslV3 << true;
+ QTest::newRow("secure-any") << QSsl::SecureProtocols << QSsl::AnyProtocol << true;
+
+ QTest::newRow("any-ssl2") << QSsl::AnyProtocol << QSsl::SslV2 << false; // no idea why it does not work, but we don't care about SSL 2
+ QTest::newRow("any-ssl3") << QSsl::AnyProtocol << QSsl::SslV3 << true;
+ QTest::newRow("any-tls1") << QSsl::AnyProtocol << QSsl::TlsV1 << true;
+ QTest::newRow("any-tls1ssl3") << QSsl::AnyProtocol << QSsl::TlsV1SslV3 << true;
+ QTest::newRow("any-secure") << QSsl::AnyProtocol << QSsl::SecureProtocols << true;
+}
+
+void tst_QSslSocket::protocolServerSide()
+{
+ if (!QSslSocket::supportsSsl()) {
+ qWarning("SSL not supported, skipping test");
+ return;
+ }
+
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ QFETCH(QSsl::SslProtocol, serverProtocol);
+ SslServer server;
+ server.protocol = serverProtocol;
+ QVERIFY(server.listen());
+
+ QEventLoop loop;
+ QTimer::singleShot(5000, &loop, SLOT(quit()));
+
+ QSslSocketPtr client = new QSslSocket;
+ socket = client;
+ QFETCH(QSsl::SslProtocol, clientProtocol);
+ socket->setProtocol(clientProtocol);
+ // upon SSL wrong version error, error will be triggered, not sslErrors
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
+ connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
+ connect(client, SIGNAL(encrypted()), &loop, SLOT(quit()));
+
+ client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
+
+ loop.exec();
+
+ QFETCH(bool, works);
+ QAbstractSocket::SocketState expectedState = (works) ? QAbstractSocket::ConnectedState : QAbstractSocket::UnconnectedState;
+ QCOMPARE(client->state(), expectedState);
+ QCOMPARE(client->isEncrypted(), works);
+}
+
+void tst_QSslSocket::setCaCertificates()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslSocket socket;
+ QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
+ socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"));
+ QCOMPARE(socket.caCertificates().size(), 1);
+ socket.setCaCertificates(socket.defaultCaCertificates());
+ QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
+}
+
+void tst_QSslSocket::setLocalCertificate()
+{
+}
+
+void tst_QSslSocket::setPrivateKey()
+{
+}
+
void tst_QSslSocket::setSocketDescriptor()
{
if (!QSslSocket::supportsSsl())
diff --git a/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
index 2a1358d..abdd550 100644
--- a/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
+++ b/tests/auto/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
@@ -209,7 +209,7 @@ void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMe
QSslSocketPtr socket = newSocket();
this->socket = socket;
socket->connectToHostEncrypted(host, 443);
- QVERIFY(socket->waitForEncrypted());
+ QVERIFY2(socket->waitForEncrypted(), qPrintable(socket->errorString()));
// not using any root certs again -> should not work
QSslSocketPtr socket3 = newSocket();
diff --git a/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp b/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp
index 8259977..5003b5c 100644
--- a/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp
+++ b/tests/auto/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp
@@ -210,7 +210,7 @@ void tst_QSslSocket_onDemandCertificates_static::onDemandRootCertLoadingStaticMe
QSslSocketPtr socket2 = newSocket();
this->socket = socket2;
socket2->connectToHostEncrypted(host, 443);
- QVERIFY(socket2->waitForEncrypted());
+ QVERIFY2(socket2->waitForEncrypted(), qPrintable(socket2->errorString()));
// not using any root certs again -> should not work
QSslSocket::setDefaultCaCertificates(QList<QSslCertificate>());
diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp
index b4f6334..f3c0ea9 100644
--- a/tests/auto/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/qstringbuilder1/stringbuilder.cpp
@@ -40,9 +40,13 @@
****************************************************************************/
#define LITERAL "some literal"
+#define LITERAL_LEN (sizeof(LITERAL)-1)
+#define LITERAL_EXTRA "some literal" "EXTRA"
// "some literal", but replacing all vocals by their umlauted UTF-8 string :)
#define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l"
+#define UTF8_LITERAL_LEN (sizeof(UTF8_LITERAL)-1)
+#define UTF8_LITERAL_EXTRA "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l" "EXTRA"
//fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS
@@ -65,7 +69,6 @@ void runScenario()
QLatin1Char achar('c');
QString r2(QLatin1String(LITERAL LITERAL));
QString r;
- QByteArray ba(LITERAL);
r = l1literal Q l1literal;
QCOMPARE(r, r2);
@@ -86,6 +89,15 @@ void runScenario()
QCOMPARE(r, r2);
r = LITERAL P string;
QCOMPARE(r, r2);
+
+ QByteArray ba = QByteArray(LITERAL);
+ r = ba P string;
+ QCOMPARE(r, r2);
+ r = string P ba;
+ QCOMPARE(r, r2);
+
+ static const char badata[] = LITERAL_EXTRA;
+ ba = QByteArray::fromRawData(badata, LITERAL_LEN);
r = ba P string;
QCOMPARE(r, r2);
r = string P ba;
@@ -109,5 +121,20 @@ void runScenario()
QCOMPARE(r, r2);
r = string P ba;
QCOMPARE(r, r2);
+
+ ba = QByteArray::fromRawData(UTF8_LITERAL_EXTRA, UTF8_LITERAL_LEN);
+ r = ba P string;
+ QCOMPARE(r, r2);
+ r = string P ba;
+ QCOMPARE(r, r2);
+
+ ba = QByteArray(); // empty
+ r = ba P string;
+ QCOMPARE(r, string);
+ r = string P ba;
+ QCOMPARE(r, string);
#endif
+
+ string = QString::fromLatin1(LITERAL);
+ QCOMPARE(QByteArray(qPrintable(string P string)), QByteArray(string.toLatin1() + string.toLatin1()));
}
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index 0a14e4a..83c7094 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -126,6 +126,7 @@ private slots:
void textWidthVsWIdth();
void textWithSurrogates_qtbug15679();
void textWidthWithStackedTextEngine();
+ void textWidthWithLineSeparator();
private:
QFont testFont;
@@ -1443,5 +1444,21 @@ void tst_QTextLayout::textWidthWithStackedTextEngine()
QCOMPARE(line.naturalTextWidth(), fm.width(text));
}
+void tst_QTextLayout::textWidthWithLineSeparator()
+{
+ QString s1("Save Project"), s2("Save Project\ntest");
+ s2.replace('\n', QChar::LineSeparator);
+
+ QTextLayout layout1(s1), layout2(s2);
+ layout1.beginLayout();
+ layout2.beginLayout();
+
+ QTextLine line1 = layout1.createLine();
+ QTextLine line2 = layout2.createLine();
+ line1.setLineWidth(0x1000);
+ line2.setLineWidth(0x1000);
+ QCOMPARE(line1.naturalTextWidth(), line2.naturalTextWidth());
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"
diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
index 4f4e706a..1952796 100644
--- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -61,6 +61,9 @@
#include <private/qtextengine_p.h>
#include <qtextlayout.h>
#undef private
+#else
+#include <private/qtextengine_p.h>
+#include <qtextlayout.h>
#endif
#include <qfontdatabase.h>
@@ -105,6 +108,9 @@ private slots:
void linearB();
void controlInSyllable_qtbug14204();
void combiningMarks_qtbug15675();
+
+ void mirroredChars_data();
+ void mirroredChars();
};
tst_QTextScriptEngine::tst_QTextScriptEngine()
@@ -1151,9 +1157,86 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675()
QVERIFY(e->layoutData->items[0].num_glyphs == 4);
QVERIFY(e->layoutData->glyphLayout.advances_y[2] > 0);
+#elif defined(Q_WS_X11)
+ QFontDatabase db;
+
+ if (!db.families().contains("DejaVu Sans Mono")) {
+ QSKIP("Required font (DejaVu Sans Mono) doesn't exist, skip test.", SkipAll);
+ return;
+ }
+
+ QString s;
+ s.append(QChar(0x0062));
+ s.append(QChar(0x0332));
+ s.append(QChar(0x0063));
+
+ QTextLayout layout(s, QFont("DejaVu Sans Mono"));
+ QTextEngine *e = layout.d;
+ e->itemize();
+ e->shape(0);
+
+ QVERIFY(e->layoutData->items[0].num_glyphs == 3);
+ QVERIFY(e->layoutData->glyphLayout.advances_x[1] == 0);
#else
- QSKIP("Mac specific test", SkipAll);
+ QSKIP("X11/Mac specific test", SkipAll);
+#endif
+}
+
+void tst_QTextScriptEngine::mirroredChars_data()
+{
+ QTest::addColumn<int>("hintingPreference");
+
+ QTest::newRow("Default hinting") << int(QFont::PreferDefaultHinting);
+ QTest::newRow("No hinting") << int(QFont::PreferNoHinting);
+ QTest::newRow("Vertical hinting") << int(QFont::PreferVerticalHinting);
+ QTest::newRow("Full hinting") << int(QFont::PreferFullHinting);
+}
+
+void tst_QTextScriptEngine::mirroredChars()
+{
+#if defined(Q_WS_MAC)
+ QSKIP("Not supported on Mac", SkipAll);
#endif
+ QFETCH(int, hintingPreference);
+
+ QFont font;
+ font.setHintingPreference(QFont::HintingPreference(hintingPreference));
+
+ QString s;
+ s.append(QLatin1Char('('));
+ s.append(QLatin1Char(')'));
+
+ HB_Glyph leftParenthesis;
+ HB_Glyph rightParenthesis;
+ {
+ QTextLayout layout(s);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QTextEngine *e = layout.engine();
+ e->itemize();
+ e->shape(0);
+ QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2));
+
+ const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout;
+ leftParenthesis = glyphLayout.glyphs[0];
+ rightParenthesis = glyphLayout.glyphs[1];
+ }
+
+ {
+ QTextLayout layout(s);
+ layout.setFlags(Qt::TextForceRightToLeft);
+
+ QTextEngine *e = layout.engine();
+ e->itemize();
+ e->shape(0);
+ QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2));
+
+ const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout;
+ QCOMPARE(glyphLayout.glyphs[0], rightParenthesis);
+ QCOMPARE(glyphLayout.glyphs[1], leftParenthesis);
+ }
}
QTEST_MAIN(tst_QTextScriptEngine)
diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp
index 99f2556..2d7c24d 100644
--- a/tests/auto/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/qtextstream/tst_qtextstream.cpp
@@ -208,6 +208,7 @@ private slots:
void seek();
void pos();
void pos2();
+ void pos3LargeFile();
void readStdin();
void readAllFromStdin();
void readLineFromStdin();
@@ -1502,6 +1503,41 @@ void tst_QTextStream::pos2()
}
// ------------------------------------------------------------------------------
+void tst_QTextStream::pos3LargeFile()
+{
+ {
+ QFile file(TestFileName);
+ file.open(QIODevice::WriteOnly | QIODevice::Text);
+ QTextStream out( &file );
+ // NOTE: The unusual spacing is to ensure non-1-character whitespace.
+ QString lineString = " 0 1 2\t3 4\t \t5 6 7 8 9 \n";
+ // Approximate 50kb text file
+ const int NbLines = (50*1024) / lineString.length() + 1;
+ for (int line = 0; line < NbLines; ++line)
+ out << lineString;
+ // File is automatically flushed and closed on destruction.
+ }
+ QFile file(TestFileName);
+ file.open(QIODevice::ReadOnly | QIODevice::Text);
+ QTextStream in( &file );
+ const int testValues[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ int value;
+ while (true) {
+ in.pos();
+ for ( int i = 0; i < 10; ++i ) {
+ in >> value;
+ if (in.status() != QTextStream::Ok) {
+ // End case, i == 0 && eof reached.
+ QCOMPARE(i, 0);
+ QCOMPARE(in.status(), QTextStream::ReadPastEnd);
+ return;
+ }
+ QCOMPARE(value, testValues[i]);
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
void tst_QTextStream::readStdin()
{
#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp
index b309917..b209258 100644
--- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp
+++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp
@@ -66,7 +66,6 @@ private slots:
void getSetWindowSurface();
void flushOutsidePaintEvent();
void grabWidget();
- void staticContentsAndPartialUpdateSupport();
};
class MyWindowSurface : public QWindowSurface
@@ -82,8 +81,6 @@ public:
/* nothing */
}
- using QWindowSurface::setStaticContentsSupport;
- using QWindowSurface::setPartialUpdateSupport;
private:
QImage image;
};
@@ -283,51 +280,6 @@ void tst_QWindowSurface::grabWidget()
QVERIFY(QColor(childInvalidSubImage.pixel(0, 0)) == QColor(Qt::white));
}
-void tst_QWindowSurface::staticContentsAndPartialUpdateSupport()
-{
- QWidget widget;
- MyWindowSurface surface(&widget);
-
- // Default values.
- QVERIFY(surface.hasPartialUpdateSupport());
- QVERIFY(!surface.hasStaticContentsSupport());
-
- // Partial: YES, Static: YES
- surface.setStaticContentsSupport(true);
- QVERIFY(surface.hasPartialUpdateSupport());
- QVERIFY(surface.hasStaticContentsSupport());
-
- // Static contents requires support for partial updates.
- // We simply ingore bad combinations and spit out a warning.
-
- // CONFLICT: Partial: NO, Static: YES
- QTest::ignoreMessage(QtWarningMsg, "QWindowSurface::setPartialUpdateSupport: static contents support requires partial update support");
- surface.setPartialUpdateSupport(false);
- QVERIFY(surface.hasPartialUpdateSupport());
- QVERIFY(surface.hasStaticContentsSupport());
-
- // Partial: YES, Static: NO
- surface.setStaticContentsSupport(false);
- QVERIFY(surface.hasPartialUpdateSupport());
- QVERIFY(!surface.hasStaticContentsSupport());
-
- // Partial: NO, Static: NO
- surface.setPartialUpdateSupport(false);
- QVERIFY(!surface.hasPartialUpdateSupport());
- QVERIFY(!surface.hasStaticContentsSupport());
-
- // CONFLICT: Partial: NO, Static: YES
- QTest::ignoreMessage(QtWarningMsg, "QWindowSurface::setStaticContentsSupport: static contents support requires partial update support");
- surface.setStaticContentsSupport(true);
- QVERIFY(!surface.hasPartialUpdateSupport());
- QVERIFY(!surface.hasStaticContentsSupport());
-
- // Partial: YES, Static: NO
- surface.setPartialUpdateSupport(true);
- QVERIFY(surface.hasPartialUpdateSupport());
- QVERIFY(!surface.hasStaticContentsSupport());
-}
-
QTEST_MAIN(tst_QWindowSurface)
#else // Q_WS_MAC