summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-06 15:33:32 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-06 15:33:32 (GMT)
commit0822e845b2678ab626cd5fe9919364188c06a70e (patch)
tree552f9e9a285330d3682c8fe645b74e3a56d379a0 /tests
parent7a5da4486708b096084fdaf83aba88f5d1b83e00 (diff)
parent2eb0312c96ab828809158802d4cb7e0980227389 (diff)
downloadQt-0822e845b2678ab626cd5fe9919364188c06a70e.zip
Qt-0822e845b2678ab626cd5fe9919364188c06a70e.tar.gz
Qt-0822e845b2678ab626cd5fe9919364188c06a70e.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp49
-rw-r--r--tests/auto/qformlayout/tst_qformlayout.cpp30
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp27
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp25
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp27
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp40
-rw-r--r--tests/auto/selftests/badxml/tst_badxml.cpp7
-rw-r--r--tests/auto/selftests/tst_selftests.cpp74
8 files changed, 241 insertions, 38 deletions
diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
index 15cca56..4bb414c 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -92,11 +92,15 @@ private slots:
void exclusive();
void exclusiveWithActions();
void testSignals();
-
void checkedButton();
void task106609();
+ // fixed for Qt 4.6.0
+#if QT_VERSION >= 0x040600
+ void autoIncrementId();
+#endif
+
void task209485_removeFromGroupInEventHandler_data();
void task209485_removeFromGroupInEventHandler();
};
@@ -329,13 +333,19 @@ void tst_QButtonGroup::testSignals()
QCOMPARE(clickedSpy.count(), 1);
QCOMPARE(clickedIdSpy.count(), 1);
- QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == -1);
+
+ int expectedId = -1;
+#if QT_VERSION >= 0x040600
+ expectedId = -2;
+#endif
+
+ QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId);
QCOMPARE(pressedSpy.count(), 1);
QCOMPARE(pressedIdSpy.count(), 1);
- QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == -1);
+ QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == expectedId);
QCOMPARE(releasedSpy.count(), 1);
QCOMPARE(releasedIdSpy.count(), 1);
- QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == -1);
+ QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == expectedId);
clickedSpy.clear();
clickedIdSpy.clear();
@@ -483,5 +493,36 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
QCOMPARE(spy1.count() + spy2.count(), signalCount);
}
+#if QT_VERSION >= 0x040600
+void tst_QButtonGroup::autoIncrementId()
+{
+ QDialog dlg(0);
+ QButtonGroup *buttons = new QButtonGroup(&dlg);
+ QVBoxLayout *vbox = new QVBoxLayout(&dlg);
+
+ QRadioButton *radio1 = new QRadioButton(&dlg);
+ radio1->setText("radio1");
+ QRadioButton *radio2 = new QRadioButton(&dlg);
+ radio2->setText("radio2");
+ QRadioButton *radio3 = new QRadioButton(&dlg);
+ radio3->setText("radio3");
+
+ buttons->addButton(radio1);
+ vbox->addWidget(radio1);
+ buttons->addButton(radio2);
+ vbox->addWidget(radio2);
+ buttons->addButton(radio3);
+ vbox->addWidget(radio3);
+
+ radio1->setChecked(true);
+
+ QVERIFY(buttons->id(radio1) == -2);
+ QVERIFY(buttons->id(radio2) == -3);
+ QVERIFY(buttons->id(radio3) == -4);
+
+ dlg.show();
+}
+#endif
+
QTEST_MAIN(tst_QButtonGroup)
#include "tst_qbuttongroup.moc"
diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp
index c4c6f70..242974d 100644
--- a/tests/auto/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/qformlayout/tst_qformlayout.cpp
@@ -125,6 +125,7 @@ private slots:
Qt::Orientations expandingDirections() const;
*/
+ void fieldMinimumSize();
};
tst_QFormLayout::tst_QFormLayout()
@@ -905,6 +906,35 @@ void tst_QFormLayout::layoutAlone()
QTest::qWait(500);
}
+
+void tst_QFormLayout::fieldMinimumSize()
+{
+ //check that the field with is bigger than its minimumSizeHint for any size of the widget
+ // even if the label with is not fixed
+ QWidget w;
+ QFormLayout layout;
+ layout.setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+ w.setLayout(&layout);
+ QLabel label1("Here is a strange test case");
+ label1.setWordWrap(true);
+ QLabel label2("Here is another label");
+ label2.setWordWrap(true);
+ QLabel shortLabel("short");
+ QLabel longLabel("Quite long label");
+ layout.addRow(&label1, &shortLabel);
+ layout.addRow(&label2, &longLabel);
+ w.show();
+ int width = w.size().width() + 9;
+
+ do {
+ w.resize(width, w.size().height());
+ layout.activate();
+ QVERIFY(shortLabel.size().width() >= shortLabel.minimumSizeHint().width());
+ QVERIFY(longLabel.size().width() >= longLabel.minimumSizeHint().width());
+ width -= 3;
+ } while(width >= w.minimumSizeHint().width());
+}
+
QTEST_MAIN(tst_QFormLayout)
#include "tst_qformlayout.moc"
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index ca88afc..bb61f90 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -190,6 +190,7 @@ private slots:
void scrollAfterResize();
void centerOnDirtyItem();
void mouseTracking();
+ void mouseTracking2();
// task specific tests below me
void task172231_untransformableItems();
@@ -3173,5 +3174,31 @@ void tst_QGraphicsView::mouseTracking()
}
}
+void tst_QGraphicsView::mouseTracking2()
+{
+ // Make sure mouse move events propagates to the scene when
+ // mouse tracking is explicitly enabled on the view,
+ // even when all items ignore hover events / use default cursor.
+
+ QGraphicsScene scene;
+ scene.addRect(0, 0, 100, 100);
+
+ QGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(200);
+
+ QVERIFY(!view.viewport()->hasMouseTracking());
+ view.viewport()->setMouseTracking(true); // Explicitly enable mouse tracking.
+ QVERIFY(view.viewport()->hasMouseTracking());
+
+ EventSpy spy(&scene, QEvent::GraphicsSceneMouseMove);
+ QCOMPARE(spy.count(), 0);
+ sendMouseMove(view.viewport(), view.viewport()->rect().center());
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index c372475..791a472 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -106,6 +106,7 @@ private slots:
void task228566_infiniteRelayout();
void task248430_crashWith0SizedItem();
void task250446_scrollChanged();
+ void keyboardSearch();
};
// Testing get/set functions
@@ -1555,6 +1556,30 @@ void tst_QListView::task250446_scrollChanged()
QCOMPARE(view.currentIndex(), index);
}
+void tst_QListView::keyboardSearch()
+{
+ QStringList items;
+ items << "AB" << "AC" << "BA" << "BB" << "BD" << "KAFEINE" << "KONQUEROR" << "KOPETE" << "KOOKA" << "OKULAR";
+ QStringListModel model(items);
+
+ QListView view;
+ view.setModel(&model);
+ view.show();
+ QTest::qWait(30);
+// QCOMPARE(view.currentIndex() , model.index(0,0));
+
+ QTest::keyClick(&view, Qt::Key_K);
+ QTest::qWait(10);
+ QCOMPARE(view.currentIndex() , model.index(5,0)); //KAFEINE
+
+ QTest::keyClick(&view, Qt::Key_O);
+ QTest::qWait(10);
+ QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
+
+ QTest::keyClick(&view, Qt::Key_N);
+ QTest::qWait(10);
+ QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
+}
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index deabda6..785eab0 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -101,6 +101,8 @@ private slots:
void recycleServer();
+ void multiConnect();
+
void debug();
};
@@ -842,6 +844,31 @@ void tst_QLocalSocket::recycleServer()
QVERIFY(server.nextPendingConnection() != 0);
}
+void tst_QLocalSocket::multiConnect()
+{
+ QLocalServer server;
+ QLocalSocket client1;
+ QLocalSocket client2;
+ QLocalSocket client3;
+
+ QVERIFY(server.listen("multiconnect"));
+
+ client1.connectToServer("multiconnect");
+ client2.connectToServer("multiconnect");
+ client3.connectToServer("multiconnect");
+
+ QVERIFY(client1.waitForConnected(201));
+ QVERIFY(client2.waitForConnected(202));
+ QVERIFY(client3.waitForConnected(203));
+
+ QVERIFY(server.waitForNewConnection(201));
+ QVERIFY(server.nextPendingConnection() != 0);
+ QVERIFY(server.waitForNewConnection(202));
+ QVERIFY(server.nextPendingConnection() != 0);
+ QVERIFY(server.waitForNewConnection(203));
+ QVERIFY(server.nextPendingConnection() != 0);
+}
+
void tst_QLocalSocket::debug()
{
// Make sure this compiles
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 37cb5b0..71d7b4d 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -226,6 +226,7 @@ private slots:
void task244304_clickOnDecoration();
void task246536_scrollbarsNotWorking();
void task250683_wrongSectionSize();
+ void task239271_addRowsWithFirstColumnHidden();
};
class QtTestModel: public QAbstractItemModel
@@ -3289,6 +3290,45 @@ void tst_QTreeView::task250683_wrongSectionSize()
QCOMPARE(treeView.header()->sectionSize(0) + treeView.header()->sectionSize(1), treeView.viewport()->width());
}
+void tst_QTreeView::task239271_addRowsWithFirstColumnHidden()
+{
+ class MyDelegate : public QStyledItemDelegate
+ {
+ public:
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
+ {
+ paintedIndexes << index;
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+
+ mutable QSet<QModelIndex> paintedIndexes;
+ };
+
+ QTreeView view;
+ QStandardItemModel model;
+ view.setModel(&model);
+ MyDelegate delegate;
+ view.setItemDelegate(&delegate);
+ QStandardItem root0("root0"), root1("root1");
+ model.invisibleRootItem()->appendRow(QList<QStandardItem*>() << &root0 << &root1);
+ QStandardItem sub0("sub0"), sub00("sub00");
+ root0.appendRow(QList<QStandardItem*>() << &sub0 << &sub00);
+ view.expand(root0.index());
+
+ view.hideColumn(0);
+ view.show();
+ QTest::qWait(200);
+ delegate.paintedIndexes.clear();
+ QStandardItem sub1("sub1"), sub11("sub11");
+ root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11);
+
+ QTest::qWait(200);
+ //items in the 2nd column should have been painted
+ QVERIFY(delegate.paintedIndexes.contains(sub00.index()));
+ QVERIFY(delegate.paintedIndexes.contains(sub11.index()));
+}
+
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/selftests/badxml/tst_badxml.cpp b/tests/auto/selftests/badxml/tst_badxml.cpp
index 6b2e4c4..fa5b717 100644
--- a/tests/auto/selftests/badxml/tst_badxml.cpp
+++ b/tests/auto/selftests/badxml/tst_badxml.cpp
@@ -58,6 +58,8 @@ private slots:
void badMessage() const;
void badMessage_data() const;
+ void failWithNoFile() const;
+
public:
static QList<QByteArray> const& badStrings();
};
@@ -116,6 +118,11 @@ void tst_BadXml::badDataTag_data() const
}
}
+void tst_BadXml::failWithNoFile() const
+{
+ QTest::qFail("failure message", 0, 0);
+}
+
/*
Outputs a message containing a bad string.
*/
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index aa1048b..603e730 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -307,13 +307,12 @@ void tst_Selftests::initTestCase()
m_checkXMLBlacklist.append("qexecstringlist");
m_checkXMLBlacklist.append("benchliboptions");
+ /* These tests use printf and therefore corrupt the testlog */
+ m_checkXMLBlacklist.append("subtest");
+ m_checkXMLBlacklist.append("globaldata");
+ m_checkXMLBlacklist.append("warnings");
+
m_checkXunitBlacklist = m_checkXMLBlacklist;
- m_checkXunitBlacklist.append("benchlibwalltime");
- m_checkXunitBlacklist.append("benchlibeventcounter");
- m_checkXunitBlacklist.append("benchlibcallgrind");
- m_checkXunitBlacklist.append("subtest");
- m_checkXunitBlacklist.append("globaldata");
- m_checkXunitBlacklist.append("warnings");
}
void tst_Selftests::checkXML() const
@@ -324,34 +323,41 @@ void tst_Selftests::checkXML() const
if(m_checkXMLBlacklist.contains(subdir))
return;
- arguments.prepend("-xml");
- arguments.prepend("-flush");
-
- QProcess proc;
- proc.setEnvironment(QStringList(""));
- proc.start(subdir + "/" + subdir, arguments);
- QVERIFY(proc.waitForFinished());
-
- QByteArray out(proc.readAllStandardOutput());
- QByteArray err(proc.readAllStandardError());
-
- /* Some platforms decides to output a message for uncaught exceptions. For instance,
- * this is what windows platforms says:
- * "This application has requested the Runtime to terminate it in an unusual way.
- * Please contact the application's support team for more information." */
- if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus"))
- QVERIFY2(err.isEmpty(), err.constData());
-
- QXmlStreamReader reader(out);
-
- while(!reader.atEnd())
- reader.readNext();
-
- QVERIFY2(!reader.error(), qPrintable(QString("line %1, col %2: %3")
- .arg(reader.lineNumber())
- .arg(reader.columnNumber())
- .arg(reader.errorString())
- ));
+ QStringList args;
+ /* Test both old (-flush) and new XML logger implementation */
+ for (int i = 0; i < 2; ++i) {
+ bool flush = i;
+ args = arguments;
+ args.prepend("-xml");
+ if (flush) args.prepend("-flush");
+
+ QProcess proc;
+ proc.setEnvironment(QStringList(""));
+ proc.start(subdir + "/" + subdir, args);
+ QVERIFY(proc.waitForFinished());
+
+ QByteArray out(proc.readAllStandardOutput());
+ QByteArray err(proc.readAllStandardError());
+
+ /* Some platforms decides to output a message for uncaught exceptions. For instance,
+ * this is what windows platforms says:
+ * "This application has requested the Runtime to terminate it in an unusual way.
+ * Please contact the application's support team for more information." */
+ if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus"))
+ QVERIFY2(err.isEmpty(), err.constData());
+
+ QXmlStreamReader reader(out);
+
+ while(!reader.atEnd())
+ reader.readNext();
+
+ QVERIFY2(!reader.error(), qPrintable(QString("(flush %0) line %1, col %2: %3")
+ .arg(flush)
+ .arg(reader.lineNumber())
+ .arg(reader.columnNumber())
+ .arg(reader.errorString())
+ ));
+ }
}
void tst_Selftests::checkXunitxml() const