summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-05-27 21:04:41 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-05-27 21:04:41 (GMT)
commitfcfdccc03b6dd26a82e87a6b6a0ca48d67f78cf6 (patch)
tree2cdd417bc0be39b12674f33052462d19d9e38ef9 /tests
parent7b1f8c542bc9f41408f0a54b853d75d0c09a2775 (diff)
parentd0bc0a26f8ac4c2f02819c262b8aa7c3dd1cad3b (diff)
downloadQt-fcfdccc03b6dd26a82e87a6b6a0ca48d67f78cf6.zip
Qt-fcfdccc03b6dd26a82e87a6b6a0ca48d67f78cf6.tar.gz
Qt-fcfdccc03b6dd26a82e87a6b6a0ca48d67f78cf6.tar.bz2
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: tests/auto/qtreeview/tst_qtreeview.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp8
-rw-r--r--tests/auto/qdate/tst_qdate.cpp26
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp33
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp36
-rw-r--r--tests/auto/qmake/tst_qmake.cpp16
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp10
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp30
7 files changed, 154 insertions, 5 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 2fff6d0..816b2e8 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -2171,7 +2171,7 @@ void tst_QComboBox::noScrollbar_data()
QTest::newRow("everything and more") << QString::fromLatin1("QAbstractItemView { border: 1px 3px 5px 1px solid blue; "
" padding: 2px 5px 3px 1px; margin: 2px 5px 3px 1px; } "
" QAbstractItemView::item { border: 2px solid green; "
- " padding: 1px 1px 2px 2px margin: 1px; } " );
+ " padding: 1px 1px 2px 2px; margin: 1px; } " );
}
void tst_QComboBox::noScrollbar()
@@ -2179,10 +2179,11 @@ void tst_QComboBox::noScrollbar()
QStringList initialContent;
initialContent << "foo" << "bar" << "foobar" << "moo";
QFETCH(QString, stylesheet);
+ QString oldCss = qApp->styleSheet();
+ qApp->setStyleSheet(stylesheet);
{
QComboBox comboBox;
- comboBox.setStyleSheet(stylesheet);
comboBox.addItems(initialContent);
comboBox.show();
comboBox.resize(200, comboBox.height());
@@ -2196,7 +2197,6 @@ void tst_QComboBox::noScrollbar()
{
QTableWidget *table = new QTableWidget(2,2);
QComboBox comboBox;
- comboBox.setStyleSheet(stylesheet);
comboBox.setView(table);
comboBox.setModel(table->model());
comboBox.show();
@@ -2207,6 +2207,8 @@ void tst_QComboBox::noScrollbar()
QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
}
+
+ qApp->setStyleSheet(oldCss);
}
void tst_QComboBox::setItemDelegate()
diff --git a/tests/auto/qdate/tst_qdate.cpp b/tests/auto/qdate/tst_qdate.cpp
index d4273d0..4d6c80c 100644
--- a/tests/auto/qdate/tst_qdate.cpp
+++ b/tests/auto/qdate/tst_qdate.cpp
@@ -82,6 +82,8 @@ private slots:
void operator_gt_eq();
void fromString_data();
void fromString();
+ void fromString_format_data();
+ void fromString_format();
void toString_format_data();
void toString_format();
void isLeapYear();
@@ -618,6 +620,30 @@ void tst_QDate::fromString()
QCOMPARE( QDate::fromString( str2, Qt::ISODate ), d1 );
}
+void tst_QDate::fromString_format_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<QDate>("date");
+
+ //year with yy is always 19xx for compatibility
+ QTest::newRow( "data0" ) << QString("21052006") << QString("ddMMyyyy") << QDate(2006,5,21);
+ QTest::newRow( "data1" ) << QString("210506") << QString("ddMMyy") << QDate(1906,5,21);
+ QTest::newRow( "data2" ) << QString("21/5/2006") << QString("d/M/yyyy") << QDate(2006,5,21);
+ QTest::newRow( "data3" ) << QString("21/5/06") << QString("d/M/yy") << QDate(1906,5,21);
+ QTest::newRow( "data4" ) << QString("20060521") << QString("yyyyMMdd") << QDate(2006,5,21);
+ QTest::newRow( "data5" ) << QString("060521") << QString("yyMMdd") << QDate(1906,5,21);
+}
+
+void tst_QDate::fromString_format()
+{
+ QFETCH( QString, string );
+ QFETCH( QString, format );
+ QFETCH( QDate, date );
+
+ QCOMPARE( QDate::fromString( string, format ), date );
+}
+
void tst_QDate::toString_format_data()
{
QTest::addColumn<QDate>("t");
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index 689f73d..16c84d8 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -159,6 +159,7 @@ private slots:
void task218353_relativePaths();
void task251321_sideBarHiddenEntries();
void task251341_sideBarRemoveEntries();
+ void task254490_selectFileMultipleTimes();
private:
QByteArray userSettings;
@@ -1981,5 +1982,37 @@ void tst_QFiledialog::task251341_sideBarRemoveEntries()
current.rmdir("testDir");
}
+void tst_QFiledialog::task254490_selectFileMultipleTimes()
+{
+ QString tempPath = QDir::tempPath();
+ QTemporaryFile *t;
+ t = new QTemporaryFile;
+ t->open();
+ QNonNativeFileDialog fd(0, "TestFileDialog");
+
+ fd.setDirectory(tempPath);
+ fd.setViewMode(QFileDialog::List);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setFileMode(QFileDialog::AnyFile);
+
+ //This should select the file in the QFileDialog
+ fd.selectFile(t->fileName());
+
+ //This should clear the selection and write it into the filename line edit
+ fd.selectFile("new_file.txt");
+
+ fd.show();
+ QTest::qWait(250);
+
+ QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit");
+ QVERIFY(lineEdit);
+ QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt"));
+ QListView *list = qFindChild<QListView*>(&fd, "listView");
+ QVERIFY(list);
+ QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0);
+
+ t->deleteLater();
+}
+
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index c03c420..8afdeb4 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -230,6 +230,7 @@ private slots:
void task240400_clickOnTextItem_data();
void task240400_clickOnTextItem();
void task243707_addChildBeforeParent();
+ void task197802_childrenVisibility();
};
void tst_QGraphicsItem::init()
@@ -5437,6 +5438,41 @@ void tst_QGraphicsItem::task243707_addChildBeforeParent()
QVERIFY(!widget2->commonAncestorItem(widget));
}
+void tst_QGraphicsItem::task197802_childrenVisibility()
+{
+ QGraphicsScene scene;
+ QGraphicsRectItem item(QRectF(0,0,20,20));
+
+ QGraphicsRectItem *item2 = new QGraphicsRectItem(QRectF(0,0,10,10), &item);
+ scene.addItem(&item);
+
+ //freshly created: both visible
+ QVERIFY(item.isVisible());
+ QVERIFY(item2->isVisible());
+
+ //hide child: parent visible, child not
+ item2->hide();
+ QVERIFY(item.isVisible());
+ QVERIFY(!item2->isVisible());
+
+ //hide parent: parent and child invisible
+ item.hide();
+ QVERIFY(!item.isVisible());
+ QVERIFY(!item2->isVisible());
+
+ //ask to show the child: parent and child invisible anyways
+ item2->show();
+ QVERIFY(!item.isVisible());
+ QVERIFY(!item2->isVisible());
+
+ //show the parent: both parent and child visible
+ item.show();
+ QVERIFY(item.isVisible());
+ QVERIFY(item2->isVisible());
+
+ delete item2;
+}
+
void tst_QGraphicsItem::boundingRegion_data()
{
QTest::addColumn<QLineF>("line");
diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp
index 70f1f3c..1178c81 100644
--- a/tests/auto/qmake/tst_qmake.cpp
+++ b/tests/auto/qmake/tst_qmake.cpp
@@ -63,6 +63,7 @@ public slots:
private slots:
void simple_app();
+ void simple_app_shadowbuild();
void simple_lib();
void simple_dll();
void subdirs();
@@ -143,6 +144,21 @@ void tst_qmake::simple_app()
QVERIFY( test_compiler.removeMakefile( workDir ) );
}
+void tst_qmake::simple_app_shadowbuild()
+{
+ QString workDir = base_path + "/testdata/simple_app";
+ QString buildDir = base_path + "/testdata/simple_app_build";
+
+ QVERIFY( test_compiler.qmake( workDir, "simple_app", buildDir ));
+ QVERIFY( test_compiler.make( buildDir ));
+ QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" ));
+ QVERIFY( test_compiler.makeClean( buildDir ));
+ QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should still exist after a make clean
+ QVERIFY( test_compiler.makeDistClean( buildDir ));
+ QVERIFY( !test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should not exist after a make distclean
+ QVERIFY( test_compiler.removeMakefile( buildDir ) );
+}
+
void tst_qmake::simple_dll()
{
QString workDir = base_path + "/testdata/simple_dll";
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index f414d3a..d7c231f 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -2585,6 +2585,16 @@ void tst_QSortFilterProxyModel::task248868_dynamicSorting()
QModelIndex index = proxy1.index(row, 0, QModelIndex());
QCOMPARE(proxy1.data(index, Qt::DisplayRole).toString(), expected.at(row));
}
+
+ //set up the sorting before seting the model up
+ QSortFilterProxyModel proxy2;
+ proxy2.setDynamicSortFilter(true);
+ proxy2.sort(0);
+ proxy2.setSourceModel(&model2);
+ for (int row = 0; row < proxy2.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy2.index(row, 0, QModelIndex());
+ QCOMPARE(proxy2.data(index, Qt::DisplayRole).toString(), expected.at(row));
+ }
}
class QtTestModel: public QAbstractItemModel
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index c4517d6..2ef76a4 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -227,6 +227,7 @@ private slots:
void task246536_scrollbarsNotWorking();
void task250683_wrongSectionSize();
void task239271_addRowsWithFirstColumnHidden();
+ void task254234_proxySort();
};
class QtTestModel: public QAbstractItemModel
@@ -2498,7 +2499,6 @@ void tst_QTreeView::sortByColumn()
QCOMPARE(view.header()->sortIndicatorSection(), 0);
QCOMPARE(view.model()->data(view.model()->index(0,0)).toString(), QString::fromLatin1("a"));
QCOMPARE(view.model()->data(view.model()->index(1,0)).toString(), QString::fromLatin1("b"));
-
}
/*
@@ -3346,7 +3346,6 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
QVERIFY(o.count > 0);
}
-
void tst_QTreeView::task250683_wrongSectionSize()
{
QDirModel model;
@@ -3400,5 +3399,32 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden()
QVERIFY(delegate.paintedIndexes.contains(sub11.index()));
}
+void tst_QTreeView::task254234_proxySort()
+{
+ //based on tst_QTreeView::sortByColumn
+ // it used not to work when setting the source of a proxy after enabling sorting
+ QTreeView view;
+ QStandardItemModel model(4,2);
+ model.setItem(0,0,new QStandardItem("b"));
+ model.setItem(1,0,new QStandardItem("d"));
+ model.setItem(2,0,new QStandardItem("c"));
+ model.setItem(3,0,new QStandardItem("a"));
+ model.setItem(0,1,new QStandardItem("e"));
+ model.setItem(1,1,new QStandardItem("g"));
+ model.setItem(2,1,new QStandardItem("h"));
+ model.setItem(3,1,new QStandardItem("f"));
+
+ view.sortByColumn(1);
+ view.setSortingEnabled(true);
+
+ QSortFilterProxyModel proxy;
+ proxy.setDynamicSortFilter(true);
+ view.setModel(&proxy);
+ proxy.setSourceModel(&model);
+ QCOMPARE(view.header()->sortIndicatorSection(), 1);
+ QCOMPARE(view.model()->data(view.model()->index(0,1)).toString(), QString::fromLatin1("h"));
+ QCOMPARE(view.model()->data(view.model()->index(1,1)).toString(), QString::fromLatin1("g"));
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"