summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKeith Isdale <keith.isdale@nokia.com>2009-06-24 10:57:03 +1000
committerKeith Isdale <keith.isdale@nokia.com>2009-06-24 10:57:03 +1000
commit188919b3c6e94714de71e4d12d3713aabb52ab8d (patch)
tree8552f757a2fea1b3c303ffb7ee9e7e199da29f7f /tests
parent07d3055a7402ba58bc299e79b96808c8025e33de (diff)
parent7e9eaea489f9760b74e8930069222dd1200fb854 (diff)
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into 4.5
Diffstat (limited to 'tests')
-rw-r--r--tests/arthur/data/qps/clipping_state.qps15
-rw-r--r--tests/arthur/data/qps/clipping_state_qps.pngbin5089 -> 5133 bytes
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp11
-rw-r--r--tests/auto/qinputdialog/tst_qinputdialog.cpp25
-rw-r--r--tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp38
-rw-r--r--tests/auto/qrect/tst_qrect.cpp2
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp28
-rw-r--r--tests/auto/qwizard/tst_qwizard.cpp22
8 files changed, 132 insertions, 9 deletions
diff --git a/tests/arthur/data/qps/clipping_state.qps b/tests/arthur/data/qps/clipping_state.qps
index fd9a80a558..3a661226a5 100644
--- a/tests/arthur/data/qps/clipping_state.qps
+++ b/tests/arthur/data/qps/clipping_state.qps
@@ -55,3 +55,18 @@ setClipping true
setBrush #6300ff00
drawRect 25 25 50 50
+
+# disable clipping followed by setClipRect
+translate 150 0
+
+setClipRect 0 0 50 50 ReplaceClip
+
+setClipping false
+
+setBrush #630000ff
+drawRect 0 0 100 100
+
+setClipRect 25 25 75 75 IntersectClip
+
+setBrush #6300ff00
+drawRect 25 25 50 50
diff --git a/tests/arthur/data/qps/clipping_state_qps.png b/tests/arthur/data/qps/clipping_state_qps.png
index 9b3dee244a..28bee462c6 100644
--- a/tests/arthur/data/qps/clipping_state_qps.png
+++ b/tests/arthur/data/qps/clipping_state_qps.png
Binary files differ
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index f739499ceb..90c4636986 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -170,6 +170,7 @@ private slots:
void boundingRects2();
void sceneBoundingRect();
void childrenBoundingRect();
+ void childrenBoundingRect2();
void group();
void setGroup();
void nestedGroups();
@@ -2900,6 +2901,16 @@ void tst_QGraphicsItem::childrenBoundingRect()
QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800));
}
+void tst_QGraphicsItem::childrenBoundingRect2()
+{
+ QGraphicsItemGroup box;
+ QGraphicsLineItem l1(0, 0, 100, 0, &box);
+ QGraphicsLineItem l2(100, 0, 100, 100, &box);
+ QGraphicsLineItem l3(0, 0, 0, 100, &box);
+ // Make sure lines (zero with/height) are included in the childrenBoundingRect.
+ QCOMPARE(box.childrenBoundingRect(), QRectF(0, 0, 100, 100));
+}
+
void tst_QGraphicsItem::group()
{
QGraphicsScene scene;
diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp
index a658aeb69e..7e4b828397 100644
--- a/tests/auto/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp
@@ -56,6 +56,7 @@ class tst_QInputDialog : public QObject
{
Q_OBJECT
QWidget *parent;
+ QDialog::DialogCode doneCode;
void (*testFunc)(QInputDialog *);
static void testFuncGetInteger(QInputDialog *dialog);
static void testFuncGetDouble(QInputDialog *dialog);
@@ -72,6 +73,7 @@ private slots:
void getText();
void getItem_data();
void getItem();
+ void task256299_getTextReturnNullStringOnRejected();
};
QString stripFraction(const QString &s)
@@ -245,8 +247,9 @@ void tst_QInputDialog::timerEvent(QTimerEvent *event)
killTimer(event->timerId());
QInputDialog *dialog = qFindChild<QInputDialog *>(parent);
Q_ASSERT(dialog);
- testFunc(dialog);
- dialog->done(QDialog::Accepted); // cause static function call to return
+ if (testFunc)
+ testFunc(dialog);
+ dialog->done(doneCode); // cause static function call to return
}
void tst_QInputDialog::getInteger_data()
@@ -266,6 +269,7 @@ void tst_QInputDialog::getInteger()
QFETCH(int, max);
Q_ASSERT(min < max);
parent = new QWidget;
+ doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetInteger;
startTimer(0);
bool ok = false;
@@ -305,6 +309,7 @@ void tst_QInputDialog::getDouble()
QFETCH(int, decimals);
Q_ASSERT(min < max && decimals >= 0 && decimals <= 13);
parent = new QWidget;
+ doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetDouble;
startTimer(0);
bool ok = false;
@@ -322,6 +327,7 @@ void tst_QInputDialog::getDouble()
void tst_QInputDialog::task255502getDouble()
{
parent = new QWidget;
+ doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetDouble;
startTimer(0);
bool ok = false;
@@ -347,6 +353,7 @@ void tst_QInputDialog::getText()
{
QFETCH(QString, text);
parent = new QWidget;
+ doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetText;
startTimer(0);
bool ok = false;
@@ -356,6 +363,19 @@ void tst_QInputDialog::getText()
delete parent;
}
+void tst_QInputDialog::task256299_getTextReturnNullStringOnRejected()
+{
+ parent = new QWidget;
+ doneCode = QDialog::Rejected;
+ testFunc = 0;
+ startTimer(0);
+ bool ok = true;
+ const QString result = QInputDialog::getText(parent, "", "", QLineEdit::Normal, "foobar", &ok);
+ QVERIFY(!ok);
+ QVERIFY(result.isNull());
+ delete parent;
+}
+
void tst_QInputDialog::getItem_data()
{
QTest::addColumn<QStringList>("items");
@@ -373,6 +393,7 @@ void tst_QInputDialog::getItem()
QFETCH(QStringList, items);
QFETCH(bool, editable);
parent = new QWidget;
+ doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetItem;
startTimer(0);
bool ok = false;
diff --git a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp
index 5540b38183..d9a7d56f4a 100644
--- a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp
+++ b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp
@@ -61,16 +61,40 @@ void tst_QItemEditorFactory::createEditor()
void tst_QItemEditorFactory::createCustomEditor()
{
- QItemEditorFactory editorFactory;
+ //we make it inherit from QObject so that we can use QPointer
+ class MyEditor : public QObject, public QStandardItemEditorCreator<QDoubleSpinBox>
+ {
+ };
- QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<QDoubleSpinBox>();
- editorFactory.registerEditor(QVariant::Rect, creator);
+ QPointer<MyEditor> creator = new MyEditor;
+ QPointer<MyEditor> creator2 = new MyEditor;
- QWidget parent;
+ {
+ QItemEditorFactory editorFactory;
+
+ editorFactory.registerEditor(QVariant::Rect, creator);
+ editorFactory.registerEditor(QVariant::RectF, creator);
+
+ //creator should not be deleted as a result of calling the next line
+ editorFactory.registerEditor(QVariant::Rect, creator2);
+ QVERIFY(creator);
+
+ //this should erase creator2
+ editorFactory.registerEditor(QVariant::Rect, creator);
+ QVERIFY(creator2.isNull());
+
+
+ QWidget parent;
+
+ QWidget *w = editorFactory.createEditor(QVariant::Rect, &parent);
+ QCOMPARE(w->metaObject()->className(), "QDoubleSpinBox");
+ QCOMPARE(w->metaObject()->userProperty().type(), QVariant::Double);
+ }
- QWidget *w = editorFactory.createEditor(QVariant::Rect, &parent);
- QCOMPARE(w->metaObject()->className(), "QDoubleSpinBox");
- QCOMPARE(w->metaObject()->userProperty().type(), QVariant::Double);
+ //editorFactory has been deleted, so should be creator
+ //because editorFActory has the ownership
+ QVERIFY(creator.isNull());
+ QVERIFY(creator2.isNull());
delete creator;
}
diff --git a/tests/auto/qrect/tst_qrect.cpp b/tests/auto/qrect/tst_qrect.cpp
index cdb556015d..5a916363f5 100644
--- a/tests/auto/qrect/tst_qrect.cpp
+++ b/tests/auto/qrect/tst_qrect.cpp
@@ -4125,6 +4125,7 @@ void tst_QRect::unitedRect_data()
QTest::newRow("test 13") << QRect() << QRect(10, 10, 10, 10) << QRect(10, 10, 10, 10);
QTest::newRow("test 14") << QRect(10, 10, 10, 10) << QRect() << QRect(10, 10, 10, 10);
QTest::newRow("test 15") << QRect() << QRect() << QRect();
+ QTest::newRow("test 16") << QRect(0, 0, 100, 0) << QRect(0, 0, 0, 100) << QRect(0, 0, 100, 100);
}
void tst_QRect::unitedRect()
@@ -4160,6 +4161,7 @@ void tst_QRect::unitedRectF_data()
QTest::newRow("test 13") << QRectF() << QRectF(10, 10, 10, 10) << QRectF(10, 10, 10, 10);
QTest::newRow("test 14") << QRectF(10, 10, 10, 10) << QRectF() << QRectF(10, 10, 10, 10);
QTest::newRow("test 15") << QRectF() << QRectF() << QRectF();
+ QTest::newRow("test 16") << QRectF(0, 0, 100, 0) << QRectF(0, 0, 0, 100) << QRectF(0, 0, 100, 100);
}
void tst_QRect::unitedRectF()
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index a6458a58eb..e65fef12e0 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -252,6 +252,7 @@ private slots:
void moveChild_data();
void moveChild();
+ void showAndMoveChild();
void subtractOpaqueSiblings();
@@ -5303,6 +5304,33 @@ void tst_QWidget::moveChild()
parent.color);
}
+void tst_QWidget::showAndMoveChild()
+{
+ QWidget parent(0, Qt::FramelessWindowHint);
+ parent.resize(300, 300);
+ parent.setPalette(Qt::red);
+ parent.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&parent);
+#endif
+ QTest::qWait(200);
+
+ const QPoint tlwOffset = parent.geometry().topLeft();
+ QWidget child(&parent);
+ child.resize(100, 100);
+ child.setPalette(Qt::blue);
+ child.setAutoFillBackground(true);
+
+ // Ensure that the child is repainted correctly when moved right after show.
+ // NB! Do NOT processEvents() (or qWait()) in between show() and move().
+ child.show();
+ child.move(150, 150);
+ qApp->processEvents();
+
+ VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue);
+ VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red);
+}
+
void tst_QWidget::subtractOpaqueSiblings()
{
#ifdef QT_MAC_USE_COCOA
diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp
index 71e1c3e5c8..e5074b3c01 100644
--- a/tests/auto/qwizard/tst_qwizard.cpp
+++ b/tests/auto/qwizard/tst_qwizard.cpp
@@ -112,6 +112,7 @@ private slots:
void task161658_alignments();
void task177022_setFixedSize();
void task248107_backButton();
+ void task255350_fieldObjectDestroyed();
/*
Things that could be added:
@@ -2517,5 +2518,26 @@ void tst_QWizard::task248107_backButton()
QCOMPARE(wizard.currentPage(), &page1);
}
+class WizardPage_task255350 : public QWizardPage
+{
+public:
+ QLineEdit *lineEdit;
+ WizardPage_task255350()
+ : lineEdit(new QLineEdit)
+ {
+ registerField("dummy*", lineEdit);
+ }
+};
+
+void tst_QWizard::task255350_fieldObjectDestroyed()
+{
+ QWizard wizard;
+ WizardPage_task255350 *page = new WizardPage_task255350;
+ int id = wizard.addPage(page);
+ delete page->lineEdit;
+ wizard.removePage(id); // don't crash!
+ delete page;
+}
+
QTEST_MAIN(tst_QWizard)
#include "tst_qwizard.moc"