summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp64
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/quit.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp14
-rw-r--r--tests/auto/qapplication/test/test.pro2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp188
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp48
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp23
-rw-r--r--tests/auto/qsettings/qsettings.pro1
-rw-r--r--tests/auto/qthread/tst_qthread.cpp41
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp27
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp22
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp33
18 files changed, 487 insertions, 8 deletions
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
index dca5205..e1b4c1c 100644
--- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -493,9 +493,11 @@ void tst_qdeclarativedom::loadDynamicProperty()
{
QByteArray qml = "import Qt 4.7\n"
"Item {\n"
+ " id: item\n"
" property int a: 12\n"
" property int b: a + 6\n"
" default property QtObject c\n"
+ " property alias d: item.a\n"
"}\n";
QDeclarativeDomDocument document;
@@ -504,11 +506,12 @@ void tst_qdeclarativedom::loadDynamicProperty()
QDeclarativeDomObject rootObject = document.rootObject();
QVERIFY(rootObject.isValid());
- QCOMPARE(rootObject.dynamicProperties().count(), 3);
+ QCOMPARE(rootObject.dynamicProperties().count(), 4);
{
QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(0);
QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.isAlias() == false);
QVERIFY(d.defaultValue().isValid());
QVERIFY(d.defaultValue().propertyName() == "a");
QVERIFY(d.defaultValue().value().isLiteral());
@@ -517,6 +520,7 @@ void tst_qdeclarativedom::loadDynamicProperty()
{
QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(1);
QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.isAlias() == false);
QVERIFY(d.defaultValue().isValid());
QVERIFY(d.defaultValue().propertyName() == "b");
QVERIFY(d.defaultValue().value().isBinding());
@@ -525,8 +529,15 @@ void tst_qdeclarativedom::loadDynamicProperty()
{
QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(2);
QVERIFY(d.isDefaultProperty() == true);
+ QVERIFY(d.isAlias() == false);
QVERIFY(d.defaultValue().isValid() == false);
}
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(3);
+ QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.isAlias() == true);
+ }
}
}
diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
index 03df71f..7fd6279 100644
--- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
+++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
@@ -63,6 +63,8 @@ private slots:
void nonQmlObject();
void nullObject();
void nonQmlContextedObject();
+ void types();
+ void chaining();
private:
QDeclarativeEngine engine;
@@ -139,6 +141,68 @@ void tst_qdeclarativeinfo::nonQmlContextedObject()
qmlInfo(&object) << "Test Message";
}
+void tst_qdeclarativeinfo::types()
+{
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false");
+ qmlInfo(0) << false;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.1");
+ qmlInfo(0) << 1.1;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.2");
+ qmlInfo(0) << 1.2f;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 15");
+ qmlInfo(0) << 15;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 'b'");
+ qmlInfo(0) << QChar('b');
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: \"Qt\"");
+ qmlInfo(0) << QByteArray("Qt");
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: true");
+ qmlInfo(0) << QBool(true);
+
+ //### do we actually want QUrl to show up in the output?
+ //### why the extra space at the end?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QUrl(\"http://qt.nokia.com\") ");
+ qmlInfo(0) << QUrl("http://qt.nokia.com");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: hello");
+ qmlInfo(0) << QLatin1String("hello");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: World");
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ qmlInfo(0) << ref;
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Quick");
+ qmlInfo(0) << QString ("Quick");
+}
+
+void tst_qdeclarativeinfo::chaining()
+{
+ //### should more of these be automatically inserting spaces?
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick ");
+ qmlInfo(0) << false << ' '
+ << 1.1 << ' '
+ << 1.2f << ' '
+ << 15 << ' '
+ << QLatin1String("hello") << ' '
+ << QChar('b') << ' '
+ << QUrl("http://qt.nokia.com")
+ << ref
+ << QByteArray("Qt")
+ << QBool(true)
+ << QString ("Quick");
+}
+
QTEST_MAIN(tst_qdeclarativeinfo)
#include "tst_qdeclarativeinfo.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt
new file mode 100644
index 0000000..af95a53
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt
@@ -0,0 +1 @@
+3:1:UnavailableType is unavailable for testing
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml
new file mode 100644
index 0000000..7c3c7ee
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml
@@ -0,0 +1,4 @@
+import Test 1.0
+
+UnavailableType {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
index 20cd976..e697aeb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -54,6 +54,8 @@ void registerTypes()
qmlRegisterType<MyGroupedObject>();
qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser);
+
+ qmlRegisterTypeNotAvailable("Test",1,0,"UnavailableType", "UnavailableType is unavailable for testing");
}
QVariant myCustomVariantTypeConverter(const QString &data)
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index ac55bae..2b23a49 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -508,6 +508,12 @@ public:
}
};
+class UnavailableType : public QObject
+{
+ Q_OBJECT
+public:
+ UnavailableType() {}
+};
class MyDotPropertyObject : public QObject
{
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 1825991..37e074b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -376,6 +376,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false;
+ QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
}
diff --git a/tests/auto/declarative/qdeclarativeqt/data/quit.qml b/tests/auto/declarative/qdeclarativeqt/data/quit.qml
new file mode 100644
index 0000000..f4c8441
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/quit.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+QtObject {
+ Component.onCompleted: Qt.quit()
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 895ee6c..739b10a 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -50,6 +50,7 @@
#include <QVector3D>
#include <QCryptographicHash>
#include <QDeclarativeItem>
+#include <QSignalSpy>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -84,6 +85,7 @@ private slots:
void btoa();
void atob();
void fontFamilies();
+ void quit();
private:
QDeclarativeEngine engine;
@@ -518,6 +520,18 @@ void tst_qdeclarativeqt::fontFamilies()
delete object;
}
+void tst_qdeclarativeqt::quit()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("quit.qml"));
+
+ QSignalSpy spy(&engine, SIGNAL(quit()));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(spy.count(), 1);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeqt)
#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro
index 30eb751..2c54c37 100644
--- a/tests/auto/qapplication/test/test.pro
+++ b/tests/auto/qapplication/test/test.pro
@@ -12,7 +12,7 @@ wince* {
}
symbian: {
- additional.sources = ../desktopsettingsaware/desktopsettingsaware.exe
+ additional.sources = $$OUT_PWD/../desktopsettingsaware/desktopsettingsaware.exe
additional.path = desktopsettingsaware
someTest.sources = test.pro
someTest.path = test
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 4476084..25ec040 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -377,6 +377,7 @@ private slots:
void itemClipsChildrenToShape2();
void itemClipsChildrenToShape3();
void itemClipsChildrenToShape4();
+ void itemClipsChildrenToShape5();
void itemClipsTextChildToShape();
void itemClippingDiscovery();
void ancestorFlags();
@@ -5464,6 +5465,193 @@ void tst_QGraphicsItem::itemClipsChildrenToShape4()
QTRY_COMPARE(innerWidget->painted, true);
}
+//#define DEBUG_ITEM_CLIPS_CHILDREN_TO_SHAPE_5
+static inline void renderSceneToImage(QGraphicsScene *scene, QImage *image, const QString &filename)
+{
+ image->fill(0);
+ QPainter painter(image);
+ scene->render(&painter);
+ painter.end();
+#ifdef DEBUG_ITEM_CLIPS_CHILDREN_TO_SHAPE_5
+ image->save(filename);
+#else
+ Q_UNUSED(filename);
+#endif
+}
+
+void tst_QGraphicsItem::itemClipsChildrenToShape5()
+{
+ class ParentItem : public QGraphicsRectItem
+ {
+ public:
+ ParentItem(qreal x, qreal y, qreal width, qreal height)
+ : QGraphicsRectItem(x, y, width, height) {}
+
+ QPainterPath shape() const
+ {
+ QPainterPath path;
+ path.addRect(50, 50, 200, 200);
+ return path;
+ }
+ };
+
+ ParentItem *parent = new ParentItem(0, 0, 300, 300);
+ parent->setBrush(Qt::blue);
+ parent->setOpacity(0.5);
+
+ const QRegion parentRegion(0, 0, 300, 300);
+ const QRegion clippedParentRegion = parentRegion & QRect(50, 50, 200, 200);
+ QRegion childRegion;
+ QRegion grandChildRegion;
+
+ QGraphicsRectItem *topLeftChild = new QGraphicsRectItem(0, 0, 100, 100);
+ topLeftChild->setBrush(Qt::red);
+ topLeftChild->setParentItem(parent);
+ childRegion += QRect(0, 0, 100, 100);
+
+ QGraphicsRectItem *topRightChild = new QGraphicsRectItem(0, 0, 100, 100);
+ topRightChild->setBrush(Qt::red);
+ topRightChild->setParentItem(parent);
+ topRightChild->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ topRightChild->setPos(200, 0);
+ childRegion += QRect(200, 0, 100, 100);
+
+ QGraphicsRectItem *topRightGrandChild = new QGraphicsRectItem(0, 0, 100, 100);
+ topRightGrandChild->setBrush(Qt::green);
+ topRightGrandChild->setParentItem(topRightChild);
+ topRightGrandChild->setPos(-40, 40);
+ grandChildRegion += QRect(200 - 40, 0 + 40, 100, 100) & QRect(200, 0, 100, 100);
+
+ QGraphicsRectItem *bottomLeftChild = new QGraphicsRectItem(0, 0, 100, 100);
+ bottomLeftChild->setBrush(Qt::red);
+ bottomLeftChild->setParentItem(parent);
+ bottomLeftChild->setFlag(QGraphicsItem::ItemClipsToShape);
+ bottomLeftChild->setPos(0, 200);
+ childRegion += QRect(0, 200, 100, 100);
+
+ QGraphicsRectItem *bottomLeftGrandChild = new QGraphicsRectItem(0, 0, 160, 160);
+ bottomLeftGrandChild->setBrush(Qt::green);
+ bottomLeftGrandChild->setParentItem(bottomLeftChild);
+ bottomLeftGrandChild->setFlag(QGraphicsItem::ItemClipsToShape);
+ bottomLeftGrandChild->setPos(0, -60);
+ grandChildRegion += QRect(0, 200 - 60, 160, 160);
+
+ QGraphicsRectItem *bottomRightChild = new QGraphicsRectItem(0, 0, 100, 100);
+ bottomRightChild->setBrush(Qt::red);
+ bottomRightChild->setParentItem(parent);
+ bottomRightChild->setPos(200, 200);
+ childRegion += QRect(200, 200, 100, 100);
+
+ QPoint controlPoints[17] = {
+ QPoint(5, 5) , QPoint(95, 5) , QPoint(205, 5) , QPoint(295, 5) ,
+ QPoint(5, 95) , QPoint(95, 95) , QPoint(205, 95) , QPoint(295, 95) ,
+ QPoint(150, 150),
+ QPoint(5, 205), QPoint(95, 205), QPoint(205, 205), QPoint(295, 205),
+ QPoint(5, 295), QPoint(95, 295), QPoint(205, 295), QPoint(295, 295),
+ };
+
+ const QRegion clippedChildRegion = childRegion & QRect(50, 50, 200, 200);
+ const QRegion clippedGrandChildRegion = grandChildRegion & QRect(50, 50, 200, 200);
+
+ QGraphicsScene scene;
+ scene.addItem(parent);
+ QImage sceneImage(300, 300, QImage::Format_ARGB32);
+
+#define VERIFY_CONTROL_POINTS(pRegion, cRegion, gRegion) \
+ for (int i = 0; i < 17; ++i) { \
+ QPoint controlPoint = controlPoints[i]; \
+ QRgb pixel = sceneImage.pixel(controlPoint.x(), controlPoint.y()); \
+ if (pRegion.contains(controlPoint)) \
+ QVERIFY(qBlue(pixel) != 0); \
+ else \
+ QVERIFY(qBlue(pixel) == 0); \
+ if (cRegion.contains(controlPoint)) \
+ QVERIFY(qRed(pixel) != 0); \
+ else \
+ QVERIFY(qRed(pixel) == 0); \
+ if (gRegion.contains(controlPoint)) \
+ QVERIFY(qGreen(pixel) != 0); \
+ else \
+ QVERIFY(qGreen(pixel) == 0); \
+ }
+
+ const QList<QGraphicsItem *> children = parent->childItems();
+ const int childrenCount = children.count();
+
+ for (int i = 0; i < 5; ++i) {
+ QString clipString;
+ QString childString;
+ switch (i) {
+ case 0:
+ // All children stacked in front.
+ childString = QLatin1String("ChildrenInFront.png");
+ foreach (QGraphicsItem *child, children)
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+ break;
+ case 1:
+ // All children stacked behind.
+ childString = QLatin1String("ChildrenBehind.png");
+ foreach (QGraphicsItem *child, children)
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
+ break;
+ case 2:
+ // First half of the children behind, second half in front.
+ childString = QLatin1String("FirstHalfBehind_SecondHalfInFront.png");
+ for (int j = 0; j < childrenCount; ++j) {
+ QGraphicsItem *child = children.at(j);
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, (j < childrenCount / 2));
+ }
+ break;
+ case 3:
+ // First half of the children in front, second half behind.
+ childString = QLatin1String("FirstHalfInFront_SecondHalfBehind.png");
+ for (int j = 0; j < childrenCount; ++j) {
+ QGraphicsItem *child = children.at(j);
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, (j >= childrenCount / 2));
+ }
+ break;
+ case 4:
+ // Child2 and child4 behind, rest in front.
+ childString = QLatin1String("Child2And4Behind_RestInFront.png");
+ for (int j = 0; j < childrenCount; ++j) {
+ QGraphicsItem *child = children.at(j);
+ if (j == 1 || j == 3)
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
+ else
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+ }
+ break;
+ default:
+ qFatal("internal error");
+ }
+
+ // Nothing is clipped.
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ parent->setFlag(QGraphicsItem::ItemClipsToShape, false);
+ clipString = QLatin1String("nothingClipped_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(parentRegion, childRegion, grandChildRegion);
+
+ // Parent clips children to shape.
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ clipString = QLatin1String("parentClipsChildrenToShape_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(parentRegion, clippedChildRegion, clippedGrandChildRegion);
+
+ // Parent clips itself and children to shape.
+ parent->setFlag(QGraphicsItem::ItemClipsToShape);
+ clipString = QLatin1String("parentClipsItselfAndChildrenToShape_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(clippedParentRegion, clippedChildRegion, clippedGrandChildRegion);
+
+ // Parent clips itself to shape.
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ clipString = QLatin1String("parentClipsItselfToShape_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(clippedParentRegion, childRegion, grandChildRegion);
+ }
+}
+
void tst_QGraphicsItem::itemClipsTextChildToShape()
{
// Construct a scene with a rect that clips its children, with one text
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 7b5ac7a..af02c55 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -2492,25 +2492,31 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState()
void tst_QGraphicsView::optimizationFlags_dontSavePainterState2_data()
{
QTest::addColumn<bool>("savePainter");
- QTest::newRow("With painter state protection") << true;
- QTest::newRow("Without painter state protection") << false;
+ QTest::addColumn<bool>("indirectPainting");
+ QTest::newRow("With painter state protection, without indirect painting") << true << false;
+ QTest::newRow("Without painter state protection, without indirect painting") << false << false;
+ QTest::newRow("With painter state protectionm, with indirect painting") << true << true;
+ QTest::newRow("Without painter state protection, with indirect painting") << false << true;
}
void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
{
QFETCH(bool, savePainter);
+ QFETCH(bool, indirectPainting);
class MyScene : public QGraphicsScene
{
public:
void drawBackground(QPainter *p, const QRectF &)
- { transformInDrawBackground = p->worldTransform(); }
+ { transformInDrawBackground = p->worldTransform(); opacityInDrawBackground = p->opacity(); }
void drawForeground(QPainter *p, const QRectF &)
- { transformInDrawForeground = p->worldTransform(); }
+ { transformInDrawForeground = p->worldTransform(); opacityInDrawForeground = p->opacity(); }
QTransform transformInDrawBackground;
QTransform transformInDrawForeground;
+ qreal opacityInDrawBackground;
+ qreal opacityInDrawForeground;
};
MyScene scene;
@@ -2518,9 +2524,13 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
scene.addRect(0, 0, 20, 20)->setTransform(QTransform::fromScale(2, 2));
scene.addRect(50, 50, 20, 20)->setTransform(QTransform::fromTranslate(200, 200));
+ foreach (QGraphicsItem *item, scene.items())
+ item->setOpacity(0.6);
+
CustomView view(&scene);
if (!savePainter)
view.setOptimizationFlag(QGraphicsView::DontSavePainterState);
+ view.setOptimizationFlag(QGraphicsView::IndirectPainting, indirectPainting);
view.rotate(45);
view.scale(1.5, 1.5);
view.show();
@@ -2534,10 +2544,38 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
QVERIFY(view.painted);
// Make sure the painter's world transform is preserved after drawItems.
- const QTransform expectedTransform = view.viewportTransform();
+ QTransform expectedTransform = view.viewportTransform();
QVERIFY(!expectedTransform.isIdentity());
QCOMPARE(scene.transformInDrawForeground, expectedTransform);
QCOMPARE(scene.transformInDrawBackground, expectedTransform);
+
+ qreal expectedOpacity = 1.0;
+ QCOMPARE(scene.opacityInDrawBackground, expectedOpacity);
+ QCOMPARE(scene.opacityInDrawForeground, expectedOpacity);
+
+ // Trigger more painting, this time from QGraphicsScene::render.
+ QImage image(scene.sceneRect().size().toSize(), QImage::Format_RGB32);
+ QPainter painter(&image);
+ scene.render(&painter);
+ painter.end();
+
+ expectedTransform = QTransform();
+ QCOMPARE(scene.transformInDrawForeground, expectedTransform);
+ QCOMPARE(scene.transformInDrawBackground, expectedTransform);
+ QCOMPARE(scene.opacityInDrawBackground, expectedOpacity);
+ QCOMPARE(scene.opacityInDrawForeground, expectedOpacity);
+
+ // Trigger more painting with another opacity on the painter.
+ painter.begin(&image);
+ painter.setOpacity(0.4);
+ expectedOpacity = 0.4;
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(scene.transformInDrawForeground, expectedTransform);
+ QCOMPARE(scene.transformInDrawBackground, expectedTransform);
+ QCOMPARE(scene.opacityInDrawBackground, expectedOpacity);
+ QCOMPARE(scene.opacityInDrawForeground, expectedOpacity);
}
class LodItem : public QGraphicsRectItem
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index f358681..45f5c3e 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -252,6 +252,8 @@ private slots:
void QTBUG5939_attachPainterPrivate();
+ void drawPointScaled();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -3170,7 +3172,6 @@ void fpe_steepSlopes()
p.setRenderHint(QPainter::Antialiasing, antialiased);
p.setTransform(transform);
- QEXPECT_FAIL("steep line 3 aa", "needs to be fixed", Continue);
p.drawLine(line);
}
@@ -4522,6 +4523,26 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate()
QCOMPARE(widget->deviceTransform, proxy->deviceTransform);
}
+void tst_QPainter::drawPointScaled()
+{
+ QImage image(32, 32, QImage::Format_RGB32);
+ image.fill(0xffffffff);
+
+ QPainter p(&image);
+
+ p.scale(0.1, 0.1);
+
+ QPen pen;
+ pen.setWidth(1000);
+ pen.setColor(Qt::red);
+
+ p.setPen(pen);
+ p.drawPoint(0, 0);
+ p.end();
+
+ QCOMPARE(image.pixel(16, 16), 0xffff0000);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/qsettings/qsettings.pro b/tests/auto/qsettings/qsettings.pro
index 115fb13..19513b3 100644
--- a/tests/auto/qsettings/qsettings.pro
+++ b/tests/auto/qsettings/qsettings.pro
@@ -5,3 +5,4 @@ RESOURCES += qsettings.qrc
contains(QT_CONFIG, qt3support):QT += qt3support
CONFIG -= debug
CONFIG += release
+win32-msvc*:LIBS += advapi32.lib
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp
index 7a5b053..843749a 100644
--- a/tests/auto/qthread/tst_qthread.cpp
+++ b/tests/auto/qthread/tst_qthread.cpp
@@ -49,6 +49,7 @@
#include <qtimer.h>
#include <qwaitcondition.h>
#include <qdebug.h>
+#include <qmetaobject.h>
#ifdef Q_OS_UNIX
#include <pthread.h>
@@ -104,6 +105,8 @@ private slots:
void adoptedThreadFinished();
void adoptMultipleThreads();
+ void QTBUG13810_exitAndStart();
+
void stressTest();
};
@@ -934,6 +937,44 @@ void tst_QThread::stressTest()
}
}
+class Syncronizer : public QObject
+{ Q_OBJECT
+public slots:
+ void setProp(int p) {
+ if(m_prop != p) {
+ m_prop = p;
+ emit propChanged(p);
+ }
+ }
+signals:
+ void propChanged(int);
+public:
+ Syncronizer() : m_prop(42) {}
+ int m_prop;
+};
+
+void tst_QThread::QTBUG13810_exitAndStart()
+{
+ QThread thread;
+ thread.exit(555); //should do nothing
+
+ thread.start();
+
+ //test that the thread is running by executing queued connected signal there
+ Syncronizer sync1;
+ sync1.moveToThread(&thread);
+ Syncronizer sync2;
+ sync2.moveToThread(&thread);
+ connect(&sync2, SIGNAL(propChanged(int)), &sync1, SLOT(setProp(int)), Qt::QueuedConnection);
+ connect(&sync1, SIGNAL(propChanged(int)), &thread, SLOT(quit()), Qt::QueuedConnection);
+ QMetaObject::invokeMethod(&sync2, "setProp", Qt::QueuedConnection , Q_ARG(int, 89));
+ QTest::qWait(50);
+ while(!thread.wait(10))
+ QTest::qWait(10);
+ QCOMPARE(sync2.m_prop, 89);
+ QCOMPARE(sync1.m_prop, 89);
+}
+
QTEST_MAIN(tst_QThread)
#include "tst_qthread.moc"
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index f23d065..102308e 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -89,6 +89,7 @@ private slots:
void recurseOnTimeoutAndStopTimer();
void QTBUG13633_dontBlockEvents();
+ void postedEventsShouldNotStarveTimers();
};
class TimerHelper : public QObject
@@ -723,5 +724,31 @@ void tst_QTimer::QTBUG13633_dontBlockEvents()
QVERIFY(t.total > 2);
}
+class SlotRepeater : public QObject {
+ Q_OBJECT
+public:
+ SlotRepeater() {}
+
+public slots:
+ void repeatThisSlot()
+ {
+ QMetaObject::invokeMethod(this, "repeatThisSlot", Qt::QueuedConnection);
+ }
+};
+
+void tst_QTimer::postedEventsShouldNotStarveTimers()
+{
+ TimerHelper timerHelper;
+ QTimer timer;
+ connect(&timer, SIGNAL(timeout()), &timerHelper, SLOT(timeout()));
+ timer.setInterval(0);
+ timer.setSingleShot(false);
+ timer.start();
+ SlotRepeater slotRepeater;
+ slotRepeater.repeatThisSlot();
+ QTest::qWait(100);
+ QVERIFY(timerHelper.count > 5);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 7e2e800..c7b53e9 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -240,6 +240,7 @@ private slots:
void taskQTBUG_6450_selectAllWith1stColumnHidden();
void taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint();
void taskQTBUG_11466_keyboardNavigationRegression();
+ void taskQTBUG_13567_removeLastItemRegression();
};
class QtTestModel: public QAbstractItemModel
@@ -3910,5 +3911,26 @@ void tst_QTreeView::taskQTBUG_11466_keyboardNavigationRegression()
QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first());
}
+void tst_QTreeView::taskQTBUG_13567_removeLastItemRegression()
+{
+ QtTestModel model(200, 1);
+
+ QTreeView view;
+ view.setSelectionMode(QAbstractItemView::ExtendedSelection);
+ view.setModel(&model);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ view.scrollToBottom();
+ QTest::qWait(10);
+ CHECK_VISIBLE(199, 0);
+
+ view.setCurrentIndex(model.index(199, 0));
+ model.removeLastRow();
+ QTest::qWait(10);
+ QCOMPARE(view.currentIndex(), model.index(198, 0));
+ CHECK_VISIBLE(198, 0);
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 098ce3c..2f221d2 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -70,6 +70,7 @@
#include <qtoolbar.h>
#include <QtGui/qpaintengine.h>
#include <private/qbackingstore_p.h>
+#include <qmenubar.h>
#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsProxyWidget>
@@ -81,8 +82,14 @@
#include <avkon.hrh> // EEikStatusPaneUidTitle
#include <akntitle.h> // CAknTitlePane
#include <akncontext.h> // CAknContextPane
+#endif
+
+#ifdef Q_OS_SYMBIAN
#include <eikspane.h> // CEikStatusPane
#include <eikbtgpc.h> // CEikButtonGroupContainer
+#include <eikenv.h> // CEikonEnv
+#include <eikaufty.h> // MEikAppUiFactory
+#include <eikmenub.h> // CEikMenuBar
#endif
#ifdef Q_WS_QWS
@@ -387,6 +394,7 @@ private slots:
void maximizedWindowModeTransitions();
void minimizedWindowModeTransitions();
void normalWindowModeTransitions();
+ void focusSwitchClosesPopupMenu();
#endif
void focusProxyAndInputMethods();
@@ -10253,6 +10261,31 @@ void tst_QWidget::normalWindowModeTransitions()
QVERIFY(!buttonGroup->IsVisible());
QVERIFY(!statusPane->IsVisible());
}
+
+void tst_QWidget::focusSwitchClosesPopupMenu()
+{
+ QMainWindow mainWindow;
+ QAction action("Test action", &mainWindow);
+ mainWindow.menuBar()->addAction(&action);
+
+ mainWindow.show();
+ QT_TRAP_THROWING(CEikonEnv::Static()->AppUiFactory()->MenuBar()->TryDisplayMenuBarL());
+ QVERIFY(CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+
+ // Close the popup by opening a new window.
+ QMainWindow mainWindow2;
+ QAction action2("Test action", &mainWindow2);
+ mainWindow2.menuBar()->addAction(&action2);
+ mainWindow2.show();
+ QVERIFY(!CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+
+ QT_TRAP_THROWING(CEikonEnv::Static()->AppUiFactory()->MenuBar()->TryDisplayMenuBarL());
+ QVERIFY(CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+
+ // Close the popup by switching focus.
+ mainWindow.activateWindow();
+ QVERIFY(!CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+}
#endif
class InputContextTester : public QInputContext