summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/languagechange/tst_languagechange.cpp3
-rw-r--r--tests/auto/linguist/lconvert/data/phrasebook.qph21
-rw-r--r--tests/auto/linguist/lconvert/tst_lconvert.cpp1
-rw-r--r--tests/auto/mediaobject/dummy/dummy.pro2
-rw-r--r--tests/auto/moc/namespaced-flags.h5
-rw-r--r--tests/auto/moc/tst_moc.cpp9
-rw-r--r--tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp21
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp2
-rw-r--r--tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp42
-rw-r--r--tests/auto/qfile/tst_qfile.cpp13
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp4
-rw-r--r--tests/auto/qfontcombobox/tst_qfontcombobox.cpp6
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp41
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp17
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp32
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp35
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp51
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp10
-rw-r--r--tests/auto/qmenubar/tst_qmenubar.cpp15
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp3
-rw-r--r--tests/auto/qobject/tst_qobject.cpp109
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp18
-rw-r--r--tests/auto/qsharedmemory/tst_qsharedmemory.cpp7
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp37
-rw-r--r--tests/auto/qspinbox/tst_qspinbox.cpp41
-rw-r--r--tests/auto/qstatusbar/tst_qstatusbar.cpp5
-rw-r--r--tests/auto/qvector/tst_qvector.cpp14
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp38
-rw-r--r--tests/auto/qwidget_window/tst_qwidget_window.cpp24
-rw-r--r--tests/auto/rcc/data/images.expected4
-rw-r--r--tests/auto/selftests/expected_xunit.txt4
-rw-r--r--tests/benchmarks/benchmarks.pro1
-rw-r--r--tests/benchmarks/qdir/tst_qdir.cpp3
-rw-r--r--tests/benchmarks/qfileinfo/main.cpp83
-rw-r--r--tests/benchmarks/qfileinfo/qfileinfo.pro12
35 files changed, 690 insertions, 43 deletions
diff --git a/tests/auto/languagechange/tst_languagechange.cpp b/tests/auto/languagechange/tst_languagechange.cpp
index 1319f15..449d34b 100644
--- a/tests/auto/languagechange/tst_languagechange.cpp
+++ b/tests/auto/languagechange/tst_languagechange.cpp
@@ -193,7 +193,7 @@ void tst_languageChange::retranslatability_data()
#else
<< "QFileSystemModel::Type::All other platforms"
#endif
- << "QFileSystemModel::%1 KB"
+// << "QFileSystemModel::%1 KB"
<< "QDialogButtonBox::Cancel"
<< "QDialogButtonBox::Open"
<< "QFileDialog::File &name:");
@@ -232,6 +232,7 @@ void tst_languageChange::retranslatability()
QSKIP("The native file dialog is used on Mac OS", SkipSingle);
#endif
QFileDialog dlg;
+ dlg.setOption(QFileDialog::DontUseNativeDialog);
QString tmpParentDir = QDir::tempPath() + "/languagechangetestdir";
QString tmpDir = tmpParentDir + "/finaldir";
QString fooName = tmpParentDir + "/foo";
diff --git a/tests/auto/linguist/lconvert/data/phrasebook.qph b/tests/auto/linguist/lconvert/data/phrasebook.qph
new file mode 100644
index 0000000..847a53b
--- /dev/null
+++ b/tests/auto/linguist/lconvert/data/phrasebook.qph
@@ -0,0 +1,21 @@
+<!DOCTYPE QPH>
+<QPH language="de" sourcelanguage="en_US">
+<phrase>
+ <source>About</source>
+ <target>Info</target>
+</phrase>
+<phrase>
+ <source>adornment</source>
+ <target>Zubehör</target>
+</phrase>
+<phrase>
+ <source>barrel button</source>
+ <target>Pen-Knopf</target>
+ <definition>pen</definition>
+</phrase>
+<phrase>
+ <source>foo &amp; bar</source>
+ <target>Foo &amp; bar</target>
+ <definition>&lt;test&gt;übergroß</definition>
+</phrase>
+</QPH>
diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp
index 10098a4..cf8f5c3 100644
--- a/tests/auto/linguist/lconvert/tst_lconvert.cpp
+++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp
@@ -213,6 +213,7 @@ void tst_lconvert::readverifies_data()
QTest::newRow("relative locations") << "relative.ts" << "ts";
QTest::newRow("message ids") << "msgid.ts" << "ts";
QTest::newRow("length variants") << "variants.ts" << "ts";
+ QTest::newRow("qph") << "phrasebook.qph" << "qph";
}
void tst_lconvert::readverifies()
diff --git a/tests/auto/mediaobject/dummy/dummy.pro b/tests/auto/mediaobject/dummy/dummy.pro
index 9febde7..5417b50 100644
--- a/tests/auto/mediaobject/dummy/dummy.pro
+++ b/tests/auto/mediaobject/dummy/dummy.pro
@@ -1,7 +1,7 @@
TEMPLATE = lib
isEmpty(QT_MAJOR_VERSION) {
- VERSION=4.6.0
+ VERSION=4.6.1
} else {
VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION}
}
diff --git a/tests/auto/moc/namespaced-flags.h b/tests/auto/moc/namespaced-flags.h
index d3f9548..b366447 100644
--- a/tests/auto/moc/namespaced-flags.h
+++ b/tests/auto/moc/namespaced-flags.h
@@ -62,13 +62,18 @@ namespace Foo {
Q_OBJECT
//Q_PROPERTY( Bar::Flags flags READ flags WRITE setFlags ) // triggers assertion
Q_PROPERTY( Foo::Bar::Flags flags READ flags WRITE setFlags ) // fails to compile, or with the same assertion if moc fix is applied
+ Q_PROPERTY( QList<Foo::Bar::Flags> flagsList READ flagsList WRITE setFlagsList )
public:
explicit Baz( QObject * parent=0 ) : QObject( parent ), mFlags() {}
void setFlags( Bar::Flags f ) { mFlags = f; }
Bar::Flags flags() const { return mFlags; }
+
+ void setFlagsList( const QList<Bar::Flags> &f ) { mList = f; }
+ QList<Bar::Flags> flagsList() const { return mList; }
private:
Bar::Flags mFlags;
+ QList<Bar::Flags> mList;
};
}
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index 69d6ca7..2316ba2 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -489,7 +489,6 @@ private slots:
void constructors();
void typenameWithUnsigned();
void warnOnVirtualSignal();
-
signals:
void sigWithUnsignedArg(unsigned foo);
void sigWithSignedArg(signed foo);
@@ -817,6 +816,8 @@ void tst_Moc::structQObject()
#include "namespaced-flags.h"
+Q_DECLARE_METATYPE(QList<Foo::Bar::Flags>);
+
void tst_Moc::namespacedFlags()
{
Foo::Baz baz;
@@ -829,6 +830,12 @@ void tst_Moc::namespacedFlags()
QVERIFY(v.isValid());
QVERIFY(baz.setProperty("flags", v));
QVERIFY(baz.flags() == bar.flags());
+
+ QList<Foo::Bar::Flags> l;
+ l << baz.flags();
+ QVariant v2 = baz.setProperty("flagsList", QVariant::fromValue(l));
+ QCOMPARE(l, baz.flagsList());
+ QCOMPARE(l, qvariant_cast<QList<Foo::Bar::Flags> >(baz.property("flagsList")));
}
void tst_Moc::warnOnMultipleInheritance()
diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 413419d..3736813 100644
--- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -112,6 +112,8 @@ private slots:
void testMoveWithinOwnRange_data();
void testMoveWithinOwnRange();
+ void testMoveThroughProxy();
+
void testReset();
@@ -1112,6 +1114,25 @@ void tst_QAbstractItemModel::testMoveSameParentUp()
}
}
+void tst_QAbstractItemModel::testMoveThroughProxy()
+{
+ QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
+ proxy->setSourceModel(m_model);
+
+ QList<QPersistentModelIndex> persistentList;
+
+ persistentList.append(proxy->index(0, 0));
+ persistentList.append(proxy->index(0, 0, proxy->mapFromSource(m_model->index(5, 0))));
+
+ ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this);
+ moveCommand->setNumCols(4);
+ moveCommand->setAncestorRowNumbers(QList<int>() << 5);
+ moveCommand->setStartRow(0);
+ moveCommand->setEndRow(0);
+ moveCommand->setDestRow(0);
+ moveCommand->doCommand();
+}
+
void tst_QAbstractItemModel::testMoveToGrandParent_data()
{
QTest::addColumn<int>("startRow");
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 941494f..75e646d 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -2517,10 +2517,12 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
layout.addWidget(&edit);
w.show();
+ QApplication::setActiveWindow(&w);
QTest::qWaitForWindowShown(&w);
cb.clearEditText();
cb.setFocus();
QApplication::processEvents();
+ QTRY_VERIFY(cb.hasFocus());
QTest::keyClick(0, '1');
QCOMPARE(spy.count(), 0);
edit.setFocus();
diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
index 3d2fa42..157c39d 100644
--- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -147,6 +147,8 @@ private slots:
void task221221();
void task255471_decimalsValidation();
+ void taskQTBUG_5008_textFromValueAndValidate();
+
public slots:
void valueChangedHelper(const QString &);
void valueChangedHelper(double);
@@ -682,7 +684,7 @@ void tst_QDoubleSpinBox::valueFromTextAndValidate_data()
QTest::newRow("data10") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1");
QTest::newRow("data11") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString("1");
QTest::newRow("data12") << QString("1,") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString();
- QTest::newRow("data13") << QString("1,") << Intermediate << 0.0 << 1000.0 << (int)QLocale::C << QString();
+ QTest::newRow("data13") << QString("1,") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString();
QTest::newRow("data14") << QString("1, ") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1,");
QTest::newRow("data15") << QString("1, ") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString();
QTest::newRow("data16") << QString("2") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString();
@@ -717,8 +719,8 @@ void tst_QDoubleSpinBox::valueFromTextAndValidate_data()
QTest::newRow("data45") << QString("200,2") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString();
QTest::newRow("data46") << QString("200,2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString();
QTest::newRow("data47") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString();
- QTest::newRow("data48") << QString("2.2") << Intermediate << 0.0 << 1000.0 << (int)QLocale::German << QString();
- QTest::newRow("data49") << QString("2.2,00") << Intermediate << 0.0 << 1000.0 << (int)QLocale::German << QString();
+ QTest::newRow("data48") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString();
+ QTest::newRow("data49") << QString("2.2,00") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString();
QTest::newRow("data50") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString();
QTest::newRow("data51") << QString("2.2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString();
QTest::newRow("data52") << QString("2..2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::German << QString();
@@ -1044,6 +1046,40 @@ void tst_QDoubleSpinBox::task255471_decimalsValidation()
}
}
+void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate()
+{
+ class DecoratedSpinBox : public QDoubleSpinBox
+ {
+ public:
+ DecoratedSpinBox()
+ {
+ setLocale(QLocale::French);
+ setMaximum(100000000);
+ setValue(1000);
+ }
+
+ QLineEdit *lineEdit() const
+ {
+ return QDoubleSpinBox::lineEdit();
+ }
+
+ //we use the French delimiters here
+ QString textFromValue (double value) const
+ {
+ return locale().toString(value);
+ }
+ } spinbox;
+ spinbox.show();
+ spinbox.activateWindow();
+ spinbox.setFocus();
+ QTest::qWaitForWindowShown(&spinbox);
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+ spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator
+ QTest::keyClick(0, Qt::Key_0); // let's insert a 0
+ QCOMPARE(spinbox.value(), 10000.);
+ spinbox.clearFocus(); //make sure the value is correctly formatted
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+}
QTEST_MAIN(tst_QDoubleSpinBox)
#include "tst_qdoublespinbox.moc"
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index cf46ce1..7ee5665 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -2783,10 +2783,21 @@ void tst_QFile::mapOpenMode()
void tst_QFile::openDirectory()
{
- QFile f1("resources");
+ QFile f1(SRCDIR "resources");
+ // it's a directory, it must exist
+ QVERIFY(f1.exists());
+
+ // ...but not be openable
QVERIFY(!f1.open(QIODevice::ReadOnly));
f1.close();
QVERIFY(!f1.open(QIODevice::ReadOnly|QIODevice::Unbuffered));
+ f1.close();
+ QVERIFY(!f1.open(QIODevice::ReadWrite));
+ f1.close();
+ QVERIFY(!f1.open(QIODevice::WriteOnly));
+ f1.close();
+ QVERIFY(!f1.open(QIODevice::WriteOnly|QIODevice::Unbuffered));
+ f1.close();
}
void tst_QFile::openStandardStreams()
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 21edbcf..cd58fd6 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -513,6 +513,10 @@ void tst_QFileInfo::canonicalFilePath()
QFileInfo info("/tmp/../../../../../../../../../../../../../../../../../");
info.canonicalFilePath();
+ // This used to crash on Mac
+ QFileInfo dontCrash(QLatin1String("/"));
+ QCOMPARE(dontCrash.canonicalFilePath(), QLatin1String("/"));
+
#ifndef Q_OS_WIN
// test symlinks
QFile::remove("link.lnk");
diff --git a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
index b974ecab..657be06 100644
--- a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
+++ b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
@@ -144,9 +144,11 @@ void tst_QFontComboBox::currentFont()
QFont oldCurrentFont = box.currentFont();
box.setCurrentFont(currentFont);
- QCOMPARE(box.currentFont(), currentFont);
- QString boxFontFamily = QFontInfo(box.currentFont()).family();
QRegExp foundry(" \\[.*\\]");
+ if (!box.currentFont().family().contains(foundry)) {
+ QCOMPARE(box.currentFont(), currentFont);
+ }
+ QString boxFontFamily = QFontInfo(box.currentFont()).family();
if (!currentFont.family().contains(foundry))
boxFontFamily.remove(foundry);
QCOMPARE(boxFontFamily, currentFont.family());
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index e2f87b8..aa67ac5 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -88,6 +88,7 @@ private slots:
void spacingPersistency();
void snakeParallelWithLayout();
void parallelToHalfLayout();
+ void globalSpacing();
};
class RectWidget : public QGraphicsWidget
@@ -1976,5 +1977,45 @@ void tst_QGraphicsAnchorLayout::parallelToHalfLayout()
QCOMPARE(maximumSizeHint, QSizeF(400, 100) + overhead);
}
+void tst_QGraphicsAnchorLayout::globalSpacing()
+{
+ QGraphicsWidget *a = createItem();
+ QGraphicsWidget *b = createItem();
+
+ QGraphicsWidget w;
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&w);
+
+ l->addCornerAnchors(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner);
+ l->addCornerAnchors(a, Qt::BottomRightCorner, b, Qt::TopLeftCorner);
+ l->addCornerAnchors(b, Qt::BottomRightCorner, l, Qt::BottomRightCorner);
+
+ w.resize(w.effectiveSizeHint(Qt::PreferredSize));
+ qreal vSpacing = b->geometry().top() - a->geometry().bottom();
+ qreal hSpacing = b->geometry().left() - a->geometry().right();
+
+ // Set spacings manually
+ l->setVerticalSpacing(vSpacing + 10);
+ l->setHorizontalSpacing(hSpacing + 5);
+
+ w.resize(w.effectiveSizeHint(Qt::PreferredSize));
+ qreal newVSpacing = b->geometry().top() - a->geometry().bottom();
+ qreal newHSpacing = b->geometry().left() - a->geometry().right();
+
+ QCOMPARE(newVSpacing, vSpacing + 10);
+ QCOMPARE(newHSpacing, hSpacing + 5);
+
+ // Set a negative spacing. This will unset the previous spacing and
+ // bring back the widget-defined spacing.
+ l->setSpacing(-1);
+
+ w.resize(w.effectiveSizeHint(Qt::PreferredSize));
+ newVSpacing = b->geometry().top() - a->geometry().bottom();
+ newHSpacing = b->geometry().left() - a->geometry().right();
+
+ QCOMPARE(newVSpacing, vSpacing);
+ QCOMPARE(newHSpacing, hSpacing);
+}
+
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index db80db6..565a3e7 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -9759,16 +9759,16 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
{
struct Item : public QGraphicsTextItem
{
- bool painted;
+ int painted;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid)
{
- painted = true;
+ painted++;
QGraphicsTextItem::paint(painter, opt, wid);
}
};
Item *i = new Item;
- i->painted = false;
+ i->painted = 0;
i->setPlainText("I AM A TROLL");
QGraphicsScene scene;
@@ -9780,11 +9780,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
QTRY_VERIFY(i->painted);
QApplication::processEvents();
- i->painted = false;
+ i->painted = 0;
QColor col(Qt::red);
i->setDefaultTextColor(col);
QApplication::processEvents();
- QTRY_VERIFY(i->painted); //check that changing the color force an update
+ QTRY_COMPARE(i->painted, 1); //check that changing the color force an update
i->painted = false;
QImage image(400, 200, QImage::Format_RGB32);
@@ -9792,7 +9792,7 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
QPainter painter(&image);
scene.render(&painter);
painter.end();
- QVERIFY(i->painted);
+ QCOMPARE(i->painted, 1);
int numRedPixel = 0;
QRgb rgb = col.rgb();
@@ -9810,6 +9810,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
}
}
QCOMPARE(numRedPixel, -1); //color not found, FAIL!
+
+ i->painted = 0;
+ i->setDefaultTextColor(col);
+ QApplication::processEvents();
+ QCOMPARE(i->painted, 0); //same color as before should not trigger an update (QTBUG-6242)
}
QTEST_MAIN(tst_QGraphicsItem)
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 20d9eb8..a8017ff 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -46,6 +46,8 @@
#endif
#include <QtGui>
+#include <private/qgraphicsscene_p.h>
+#include <private/qgraphicssceneindex_p.h>
#include <math.h>
#include "../../shared/util.h"
@@ -269,6 +271,7 @@ private slots:
void initialFocus();
void polishItems();
void isActive();
+ void siblingIndexAlwaysValid();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -4181,6 +4184,35 @@ void tst_QGraphicsScene::isActive()
}
+void tst_QGraphicsScene::siblingIndexAlwaysValid()
+{
+ QGraphicsScene scene;
+
+ QGraphicsWidget *parent = new QGraphicsWidget;
+ parent->setZValue(350);
+ parent->setGeometry(0, 0, 100, 100);
+ QGraphicsWidget *parent2 = new QGraphicsWidget;
+ parent2->setGeometry(10, 10, 50, 50);
+ QGraphicsWidget *child = new QGraphicsWidget(parent2);
+ child->setGeometry(15, 15, 25, 25);
+ child->setZValue(150);
+ //Both are top level
+ scene.addItem(parent);
+ scene.addItem(parent2);
+
+ //Then we make the child a top level
+ child->setParentItem(0);
+
+ //This is trigerred by a repaint...
+ QGraphicsScenePrivate::get(&scene)->index->estimateTopLevelItems(QRectF(), Qt::AscendingOrder);
+
+ delete child;
+
+ //If there are in the list that's bad, we crash...
+ QVERIFY(!QGraphicsScenePrivate::get(&scene)->topLevelItems.contains(static_cast<QGraphicsItem *>(child)));
+
+}
+
void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache()
{
QGraphicsScene scene;
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 3b98c2f..3303df5 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -106,6 +106,7 @@ private slots:
void font_data();
void font();
void fontPropagation();
+ void fontChangedEvent();
void fontPropagationWidgetItemWidget();
void fontPropagationSceneChange();
void geometry_data();
@@ -673,6 +674,40 @@ void tst_QGraphicsWidget::fontPropagation()
QCOMPARE(child2->font().pointSize(), 43);
}
+void tst_QGraphicsWidget::fontChangedEvent()
+{
+ QGraphicsWidget *root = new QGraphicsWidget;
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ // Check that only the application fonts apply.
+ QFont appFont = QApplication::font();
+ QCOMPARE(scene.font(), appFont);
+ QCOMPARE(root->font(), appFont);
+
+ EventSpy rootSpyFont(root, QEvent::FontChange);
+ EventSpy rootSpyPolish(root, QEvent::Polish);
+ QCOMPARE(rootSpyFont.count(), 0);
+ QApplication::processEvents(); //The polish event is sent
+ QCOMPARE(rootSpyPolish.count(), 1);
+ QApplication::processEvents(); //Process events to see if we get the font change event
+ //The font is still the same so no fontChangeEvent
+ QCOMPARE(rootSpyFont.count(), 0);
+
+ QFont font;
+ font.setPointSize(43);
+ root->setFont(font);
+ QApplication::processEvents(); //Process events to get the font change event
+ //The font changed
+ QCOMPARE(rootSpyFont.count(), 1);
+
+ //then roll back to the default one.
+ root->setFont(appFont);
+ QApplication::processEvents(); //Process events to get the font change event
+ //The font changed
+ QCOMPARE(rootSpyFont.count(), 2);
+}
+
void tst_QGraphicsWidget::fontPropagationWidgetItemWidget()
{
QGraphicsWidget *widget = new QGraphicsWidget;
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index dd5bb29..4f4761c 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -269,6 +269,8 @@ private slots:
void task241436_passwordEchoOnEditRestoreEchoMode();
void task248948_redoRemovedSelection();
void taskQTBUG_4401_enterKeyClearsPassword();
+ void taskQTBUG_4679_moveToStartEndOfBlock();
+ void taskQTBUG_4679_selectToStartEndOfBlock();
protected slots:
#ifdef QT3_SUPPORT
@@ -1415,8 +1417,22 @@ void tst_QLineEdit::undo_keypressevents()
}
#ifndef QT_NO_CLIPBOARD
+static bool nativeClipboardWorking()
+{
+#ifdef Q_WS_MAC
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ return status == noErr;
+#endif
+ return true;
+}
+
void tst_QLineEdit::QTBUG5786_undoPaste()
{
+ if (!nativeClipboardWorking())
+ QSKIP("this machine doesn't support the clipboard", SkipAll);
QString initial("initial");
QString string("test");
QString additional("add");
@@ -3586,5 +3602,40 @@ void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword()
QTRY_COMPARE(testWidget->text(), password);
}
+void tst_QLineEdit::taskQTBUG_4679_moveToStartEndOfBlock()
+{
+#ifdef Q_OS_MAC
+ const QString text("there are no blocks for lineEdit");
+ testWidget->setText(text);
+ testWidget->setCursorPosition(5);
+ QCOMPARE(testWidget->cursorPosition(), 5);
+ testWidget->setFocus();
+ QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier);
+ QCOMPARE(testWidget->cursorPosition(), 0);
+ QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier);
+ QCOMPARE(testWidget->cursorPosition(), text.size());
+#endif // Q_OS_MAC
+}
+
+void tst_QLineEdit::taskQTBUG_4679_selectToStartEndOfBlock()
+{
+#ifdef Q_OS_MAC
+ const QString text("there are no blocks for lineEdit, select all");
+ testWidget->setText(text);
+ testWidget->setCursorPosition(5);
+ QCOMPARE(testWidget->cursorPosition(), 5);
+ testWidget->setFocus();
+ QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier | Qt::ShiftModifier);
+ QCOMPARE(testWidget->cursorPosition(), 0);
+ QVERIFY(testWidget->hasSelectedText());
+ QCOMPARE(testWidget->selectedText(), text.mid(0, 5));
+
+ QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier | Qt::ShiftModifier);
+ QCOMPARE(testWidget->cursorPosition(), text.size());
+ QVERIFY(testWidget->hasSelectedText());
+ QCOMPARE(testWidget->selectedText(), text.mid(5));
+#endif // Q_OS_MAC
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 602da61..24a553f 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -586,7 +586,15 @@ void tst_QListView::indexAt()
index = view.indexAt(QPoint(20,2 * sz.height()));
QVERIFY(!index.isValid());
-
+ // Check when peeking out of the viewport bounds
+ index = view.indexAt(QPoint(view.viewport()->rect().width(), 0));
+ QVERIFY(!index.isValid());
+ index = view.indexAt(QPoint(-1, 0));
+ QVERIFY(!index.isValid());
+ index = view.indexAt(QPoint(20, view.viewport()->rect().height()));
+ QVERIFY(!index.isValid());
+ index = view.indexAt(QPoint(20, -1));
+ QVERIFY(!index.isValid());
model.rCount = 30;
QListViewShowEventListener view2;
diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index 320cd8d..aa6caae 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -168,7 +168,7 @@ private slots:
void task256322_highlight();
void menubarSizeHint();
void taskQTBUG4965_escapeEaten();
-
+
#if defined(QT3_SUPPORT)
void indexBasedInsertion_data();
void indexBasedInsertion();
@@ -1360,7 +1360,7 @@ tst_QMenuBar::allowActiveAndDisabled()
// disabled menu items are added
QMenu fileMenu("&File");
- // Task 241043 : check that second menu is activated
+ // Task 241043 : check that second menu is activated
// if all items are disabled
QAction *act = fileMenu.addAction("Disabled");
act->setEnabled(false);
@@ -1388,7 +1388,7 @@ tst_QMenuBar::allowActiveAndDisabled()
QCOMPARE(mb->activeAction()->text(), fileMenu.title());
else
QCOMPARE(mb->activeAction()->text(), fileMenu.title());
-
+
mb->hide();
#endif //Q_WS_MAC
}
@@ -1603,7 +1603,7 @@ void tst_QMenuBar::menubarSizeHint()
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const
{
// I chose strange values (prime numbers to be more sure that the size of the menubar is correct)
- switch (metric)
+ switch (metric)
{
case QStyle::PM_MenuBarItemSpacing:
return 7;
@@ -1621,7 +1621,7 @@ void tst_QMenuBar::menubarSizeHint()
QMenuBar mb;
mb.setNativeMenuBar(false); //we can't check the geometry of native menubars
-
+
mb.setStyle(&style);
//this is a list of arbitrary strings so that we check the geometry
QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz" << "er";
@@ -1667,12 +1667,15 @@ void tst_QMenuBar::menubarSizeHint()
void tst_QMenuBar::taskQTBUG4965_escapeEaten()
{
+#ifdef Q_WS_MAC
+ QSKIP("On Mac, do not test the menubar with escape key", SkipAll);
+#endif
QMenuBar menubar;
QMenu menu("menu1");
QAction *first = menubar.addMenu(&menu);
menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC"));
menubar.show();
- menubar.setActiveWindow();
+ QApplication::setActiveWindow(&menubar);
QTest::qWaitForWindowShown(&menubar);
menubar.setActiveAction(first);
QTRY_VERIFY(menu.isVisible());
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 5fe716a..6d43c1d 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -3241,8 +3241,11 @@ void tst_QNetworkReply::receiveCookiesFromHttp_data()
cookie = QNetworkCookie("a", "b");
cookie.setPath("/not/part-of-path");
header << cookie;
+ cookie.setDomain(QtNetworkSettings::serverName());
+ jar << cookie;
QTest::newRow("invalid-cookie-path") << "a=b; path=/not/part-of-path" << header << jar;
+ jar.clear();
cookie = QNetworkCookie("a", "b");
cookie.setDomain(".example.com");
header.clear();
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index b296e1b..d2073d2 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -60,6 +60,10 @@
#include <QProcess>
#include "qobject.h"
+#ifdef QT_BUILD_INTERNAL
+#include <private/qobject_p.h>
+#endif
+
#include <math.h>
@@ -121,6 +125,7 @@ private slots:
void interfaceIid();
void deleteQObjectWhenDeletingEvent();
void overloads();
+ void isSignalConnected();
protected:
};
@@ -3188,5 +3193,109 @@ void tst_QObject::overloads()
QCOMPARE(obj2.o4_obj, qApp); //default arg of the slot
}
+class ManySignals : public QObject
+{ Q_OBJECT
+ friend class tst_QObject;
+signals:
+ void sig00(); void sig01(); void sig02(); void sig03(); void sig04();
+ void sig05(); void sig06(); void sig07(); void sig08(); void sig09();
+ void sig10(); void sig11(); void sig12(); void sig13(); void sig14();
+ void sig15(); void sig16(); void sig17(); void sig18(); void sig19();
+ void sig20(); void sig21(); void sig22(); void sig23(); void sig24();
+ void sig25(); void sig26(); void sig27(); void sig28(); void sig29();
+ void sig30(); void sig31(); void sig32(); void sig33(); void sig34();
+ void sig35(); void sig36(); void sig37(); void sig38(); void sig39();
+ void sig40(); void sig41(); void sig42(); void sig43(); void sig44();
+ void sig45(); void sig46(); void sig47(); void sig48(); void sig49();
+ void sig50(); void sig51(); void sig52(); void sig53(); void sig54();
+ void sig55(); void sig56(); void sig57(); void sig58(); void sig59();
+ void sig60(); void sig61(); void sig62(); void sig63(); void sig64();
+ void sig65(); void sig66(); void sig67(); void sig68(); void sig69();
+
+public slots:
+ void received() { rec++; }
+public:
+ int rec;
+};
+
+
+void tst_QObject::isSignalConnected()
+{
+ ManySignals o;
+ o.rec = 0;
+#ifdef QT_BUILD_INTERNAL
+ QObjectPrivate *priv = QObjectPrivate::get(&o);
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig00()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()")));
+ if (sizeof(void *) >= 8) { //on 32bit isSignalConnected only works with the first 32 signals
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()")));
+ }
+#endif
+
+ QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69()));
+ QObject::connect(&o, SIGNAL(sig34()), &o, SIGNAL(sig03()));
+ QObject::connect(&o, SIGNAL(sig69()), &o, SIGNAL(sig34()));
+ QObject::connect(&o, SIGNAL(sig03()), &o, SIGNAL(sig18()));
+
+#ifdef QT_BUILD_INTERNAL
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()")));
+
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig18()")));
+#endif
+
+ QObject::connect(&o, SIGNAL(sig18()), &o, SIGNAL(sig29()));
+ QObject::connect(&o, SIGNAL(sig29()), &o, SIGNAL(sig62()));
+ QObject::connect(&o, SIGNAL(sig62()), &o, SIGNAL(sig28()));
+ QObject::connect(&o, SIGNAL(sig28()), &o, SIGNAL(sig27()));
+
+#ifdef QT_BUILD_INTERNAL
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig27()")));
+#endif
+
+ QCOMPARE(o.rec, 0);
+ emit o.sig01();
+ emit o.sig34();
+ QCOMPARE(o.rec, 0);
+
+ QObject::connect(&o, SIGNAL(sig27()), &o, SLOT(received()));
+
+#ifdef QT_BUILD_INTERNAL
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig27()")));
+
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig04()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig21()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig25()")));
+#endif
+
+ emit o.sig00();
+ QCOMPARE(o.rec, 1);
+ emit o.sig69();
+ QCOMPARE(o.rec, 2);
+ emit o.sig36();
+ QCOMPARE(o.rec, 2);
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 3bc2443..2d629b7 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -154,6 +154,7 @@ private slots:
void functionScopes();
void nativeFunctionScopes();
void evaluateProgram();
+ void collectGarbageAfterConnect();
void qRegExpInport_data();
void qRegExpInport();
@@ -4443,6 +4444,23 @@ void tst_QScriptEngine::evaluateProgram()
}
}
+void tst_QScriptEngine::collectGarbageAfterConnect()
+{
+ // QTBUG-6366
+ QScriptEngine engine;
+ QPointer<QWidget> widget = new QWidget;
+ engine.globalObject().setProperty(
+ "widget", engine.newQObject(widget, QScriptEngine::ScriptOwnership));
+ QVERIFY(engine.evaluate("widget.customContextMenuRequested.connect(\n"
+ " function() { print('hello'); }\n"
+ ");")
+ .isUndefined());
+ QVERIFY(widget != 0);
+ engine.evaluate("widget = null;");
+ collectGarbage_helper(engine);
+ QVERIFY(widget == 0);
+}
+
static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; }
void tst_QScriptEngine::qRegExpInport_data()
diff --git a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp
index 4ab3b0b..f72b6f7 100644
--- a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp
+++ b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp
@@ -708,10 +708,7 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer()
void tst_QSharedMemory::simpleProcessProducerConsumer_data()
{
QTest::addColumn<int>("processes");
- int tries = 10;
-#ifdef Q_OS_WIN
- tries = 5;
-#endif
+ int tries = 5;
for (int i = 0; i < tries; ++i) {
QTest::newRow("1 process") << 1;
QTest::newRow("5 processes") << 5;
@@ -737,7 +734,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
#endif
QProcess producer;
producer.setProcessChannelMode(QProcess::ForwardedChannels);
- producer.start( QFileInfo("./lackey/lackey.exe").absoluteFilePath(), arguments);
+ producer.start( "./lackey/lackey", arguments);
producer.waitForStarted();
QVERIFY(producer.error() != QProcess::FailedToStart);
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index e99e9d6..b7839f7 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -135,6 +135,7 @@ private slots:
void task251296_hiddenChildren();
void task252507_mapFromToSource();
void task255652_removeRowsRecursive();
+ void taskQTBUG_6205_doubleProxySelectionSetSourceModel();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -2815,5 +2816,41 @@ void tst_QSortFilterProxyModel::task255652_removeRowsRecursive()
delete pItem11;
}
+void tst_QSortFilterProxyModel::taskQTBUG_6205_doubleProxySelectionSetSourceModel()
+{
+ QStandardItemModel *model1 = new QStandardItemModel;
+ QStandardItem *parentItem = model1->invisibleRootItem();
+ for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QString("model1 item %0").arg(i));
+ parentItem->appendRow(item);
+ parentItem = item;
+ }
+
+ QStandardItemModel *model2 = new QStandardItemModel;
+ QStandardItem *parentItem2 = model2->invisibleRootItem();
+ for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QString("model2 item %0").arg(i));
+ parentItem2->appendRow(item);
+ parentItem2 = item;
+ }
+
+ QSortFilterProxyModel *toggleProxy = new QSortFilterProxyModel;
+ toggleProxy->setSourceModel(model1);
+
+ QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel;
+ proxyModel->setSourceModel(toggleProxy);
+
+ QModelIndex mi = proxyModel->index(0, 0, proxyModel->index(0, 0, proxyModel->index(0, 0)));
+ QItemSelectionModel ism(proxyModel);
+ ism.select(mi, QItemSelectionModel::Select);
+ QModelIndexList mil = ism.selectedIndexes();
+ QCOMPARE(mil.count(), 1);
+ QCOMPARE(mil.first(), mi);
+
+ toggleProxy->setSourceModel(model2);
+ // No crash, it's good news!
+ QVERIFY(ism.selection().isEmpty());
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp
index 2389060..cd65135 100644
--- a/tests/auto/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/qspinbox/tst_qspinbox.cpp
@@ -146,6 +146,8 @@ private slots:
void sizeHint();
+ void taskQTBUG_5008_textFromValueAndValidate();
+
public slots:
void valueChangedHelper(const QString &);
void valueChangedHelper(int);
@@ -756,7 +758,7 @@ void tst_QSpinBox::editingFinished()
box->activateWindow();
box->setFocus();
- QTRY_COMPARE(qApp->focusWidget(), box);
+ QTRY_COMPARE(qApp->focusWidget(), (QWidget *)box);
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
@@ -1004,5 +1006,42 @@ void tst_QSpinBox::sizeHint()
delete widget;
}
+void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate()
+{
+ class DecoratedSpinBox : public QSpinBox
+ {
+ public:
+ DecoratedSpinBox()
+ {
+ setLocale(QLocale::French);
+ setMaximum(100000000);
+ setValue(1000000);
+ }
+
+ QLineEdit *lineEdit() const
+ {
+ return QSpinBox::lineEdit();
+ }
+
+ //we use the French delimiters here
+ QString textFromValue (int value) const
+ {
+ return locale().toString(value);
+ }
+
+ } spinbox;
+ spinbox.show();
+ spinbox.activateWindow();
+ spinbox.setFocus();
+ QTest::qWaitForWindowShown(&spinbox);
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+ spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator
+ QTest::keyClick(0, Qt::Key_0); // let's insert a 0
+ QCOMPARE(spinbox.value(), 10000000); //it's been multiplied by 10
+ spinbox.clearFocus(); //make sure the value is correctly formatted
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+}
+
+
QTEST_MAIN(tst_QSpinBox)
#include "tst_qspinbox.moc"
diff --git a/tests/auto/qstatusbar/tst_qstatusbar.cpp b/tests/auto/qstatusbar/tst_qstatusbar.cpp
index 92d9185..03d8ca8 100644
--- a/tests/auto/qstatusbar/tst_qstatusbar.cpp
+++ b/tests/auto/qstatusbar/tst_qstatusbar.cpp
@@ -266,10 +266,15 @@ void tst_QStatusBar::QTBUG4334_hiddenOnMaximizedWindow()
main.setStatusBar(&statusbar);
main.showMaximized();
QTest::qWaitForWindowShown(&main);
+#ifndef Q_WS_MAC
QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible());
+#endif
main.showNormal();
QTest::qWaitForWindowShown(&main);
QVERIFY(statusbar.findChild<QSizeGrip*>()->isVisible());
+ main.showFullScreen();
+ QTest::qWaitForWindowShown(&main);
+ QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible());
}
QTEST_MAIN(tst_QStatusBar)
diff --git a/tests/auto/qvector/tst_qvector.cpp b/tests/auto/qvector/tst_qvector.cpp
index 21c9270..f538f6a 100644
--- a/tests/auto/qvector/tst_qvector.cpp
+++ b/tests/auto/qvector/tst_qvector.cpp
@@ -56,6 +56,7 @@ public:
private slots:
void outOfMemory();
+ void QTBUG6416_reserve();
};
int fooCtor;
@@ -220,5 +221,18 @@ void tst_QVector::outOfMemory()
}
}
+void tst_QVector::QTBUG6416_reserve()
+{
+ fooCtor = 0;
+ fooDtor = 0;
+ {
+ QVector<Foo> a;
+ a.resize(2);
+ QVector<Foo> b(a);
+ b.reserve(1);
+ }
+ QCOMPARE(fooCtor, fooDtor);
+}
+
QTEST_APPLESS_MAIN(tst_QVector)
#include "tst_qvector.moc"
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 1e3f5f8..9960f47 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -391,6 +391,7 @@ private slots:
#endif
void focusProxyAndInputMethods();
+ void scrollWithoutBackingStore();
private:
bool ensureScreenSize(int width, int height);
@@ -9703,5 +9704,42 @@ void tst_QWidget::focusProxyAndInputMethods()
delete toplevel;
}
+class scrollWidgetWBS : public QWidget
+{
+public:
+ void deleteBackingStore()
+ {
+ if (static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) {
+ delete static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore;
+ static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = 0;
+ }
+ }
+ void enableBackingStore()
+ {
+ if (!static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) {
+ static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = new QWidgetBackingStore(this);
+ static_cast<QWidgetPrivate*>(d_ptr.data())->invalidateBuffer(this->rect());
+ repaint();
+ }
+ }
+};
+
+void tst_QWidget::scrollWithoutBackingStore()
+{
+ scrollWidgetWBS scrollable;
+ scrollable.resize(100,100);
+ QLabel child(QString("@"),&scrollable);
+ child.resize(50,50);
+ scrollable.show();
+ QTest::qWaitForWindowShown(&scrollable);
+ scrollable.scroll(50,50);
+ QCOMPARE(child.pos(),QPoint(50,50));
+ scrollable.deleteBackingStore();
+ scrollable.scroll(-25,-25);
+ QCOMPARE(child.pos(),QPoint(25,25));
+ scrollable.enableBackingStore();
+ QCOMPARE(child.pos(),QPoint(25,25));
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/qwidget_window/tst_qwidget_window.cpp b/tests/auto/qwidget_window/tst_qwidget_window.cpp
index 13d1d2d..ec11ab3 100644
--- a/tests/auto/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/qwidget_window/tst_qwidget_window.cpp
@@ -52,6 +52,9 @@
#include <QX11Info>
#endif // Q_WS_X11
+#include "../../shared/util.h"
+
+
class tst_QWidget_window : public QWidget
{
Q_OBJECT
@@ -150,7 +153,7 @@ void tst_QWidget_window::tst_show_resize_hide_show()
class TestWidget : public QWidget
{
public:
- int m_first, m_next;
+ int m_first, m_next;
bool paintEventReceived;
void reset(){ m_first = m_next = 0; paintEventReceived = false; }
@@ -163,7 +166,7 @@ public:
case QEvent::Show:
if (m_first)
m_next = event->type();
- else
+ else
m_first = event->type();
break;
case QEvent::Paint:
@@ -173,7 +176,7 @@ public:
break;
}
return QWidget::event(event);
- }
+ }
};
void tst_QWidget_window::tst_windowFilePathAndwindowTitle_data()
@@ -289,7 +292,7 @@ void tst_QWidget_window::tst_showWithoutActivating()
#else
QWidget w;
w.show();
- qt_x11_wait_for_window_manager(&w);
+ QTest::qWaitForWindowShown(&w);
QApplication::processEvents();
QApplication::clipboard();
@@ -302,8 +305,11 @@ void tst_QWidget_window::tst_showWithoutActivating()
Window window;
int revertto;
- XGetInputFocus(QX11Info::display(), &window, &revertto);
- QCOMPARE(lineEdit->winId(), window);
+ QTRY_COMPARE(lineEdit->winId(),
+ (XGetInputFocus(QX11Info::display(), &window, &revertto), window) );
+ // Note the use of the , before window because we want the XGetInputFocus to be re-executed
+ // in each iteration of the inside loop of the QTRY_COMPARE macro
+
#endif // Q_WS_X11
}
@@ -315,11 +321,9 @@ void tst_QWidget_window::tst_paintEventOnSecondShow()
w.reset();
w.show();
-#ifdef Q_WS_X11
- QTest::qWait(500);
-#endif
+ QTest::qWaitForWindowShown(&w);
QApplication::processEvents();
- QVERIFY(w.paintEventReceived);
+ QTRY_VERIFY(w.paintEventReceived);
}
QTEST_MAIN(tst_QWidget_window)
diff --git a/tests/auto/rcc/data/images.expected b/tests/auto/rcc/data/images.expected
index 24d75b6..71be819 100644
--- a/tests/auto/rcc/data/images.expected
+++ b/tests/auto/rcc/data/images.expected
@@ -97,10 +97,10 @@ static const unsigned char qt_resource_struct[] = {
QT_BEGIN_NAMESPACE
-extern bool qRegisterResourceData
+extern Q_CORE_EXPORT bool qRegisterResourceData
(int, const unsigned char *, const unsigned char *, const unsigned char *);
-extern bool qUnregisterResourceData
+extern Q_CORE_EXPORT bool qUnregisterResourceData
(int, const unsigned char *, const unsigned char *, const unsigned char *);
QT_END_NAMESPACE
diff --git a/tests/auto/selftests/expected_xunit.txt b/tests/auto/selftests/expected_xunit.txt
index cb74491..d5cd531 100644
--- a/tests/auto/selftests/expected_xunit.txt
+++ b/tests/auto/selftests/expected_xunit.txt
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="5" failures="3" tests="9" name="tst_Xunit">
<properties>
- <property value="4.6.0" name="QTestVersion"/>
- <property value="4.6.0" name="QtVersion"/>
+ <property value="4.6.1" name="QTestVersion"/>
+ <property value="4.6.1" name="QtVersion"/>
</properties>
<testcase result="pass" name="initTestCase"/>
<testcase result="pass" name="testFunc1">
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index a63fb41..9170039 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -3,6 +3,7 @@ SUBDIRS = containers-associative \
containers-sequential \
qanimation \
qbytearray \
+ qfileinfo \
qfile_vs_qnetworkaccessmanager \
qpainter \
qtestlib-simple events \
diff --git a/tests/benchmarks/qdir/tst_qdir.cpp b/tests/benchmarks/qdir/tst_qdir.cpp
index 2e4a28a..fd558d3 100644
--- a/tests/benchmarks/qdir/tst_qdir.cpp
+++ b/tests/benchmarks/qdir/tst_qdir.cpp
@@ -68,7 +68,8 @@ public slots:
void cleanupTestCase() {
{
QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
-
+ testdir.setSorting(QDir::Unsorted);
+ testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
foreach (const QString &filename, testdir.entryList()) {
testdir.remove(filename);
}
diff --git a/tests/benchmarks/qfileinfo/main.cpp b/tests/benchmarks/qfileinfo/main.cpp
new file mode 100644
index 0000000..711209c
--- /dev/null
+++ b/tests/benchmarks/qfileinfo/main.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QDebug>
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QFileInfo>
+
+#include "private/qfsfileengine_p.h"
+
+class qfileinfo : public QObject
+{
+ Q_OBJECT
+private slots:
+ void canonicalFileNamePerformance();
+
+ void initTestCase();
+ void cleanupTestCase();
+public:
+ qfileinfo() : QObject() {};
+};
+
+void qfileinfo::initTestCase()
+{
+}
+
+void qfileinfo::cleanupTestCase()
+{
+}
+
+void qfileinfo::canonicalFileNamePerformance()
+{
+ QString appPath = QCoreApplication::applicationFilePath();
+ QFSFileEnginePrivate::canonicalized(appPath); // warmup
+ QFSFileEnginePrivate::canonicalized(appPath); // more warmup
+ QBENCHMARK {
+ for (int i = 0; i < 5000; i++) {
+ QFSFileEnginePrivate::canonicalized(appPath);
+ }
+ }
+}
+
+QTEST_MAIN(qfileinfo)
+
+#include "main.moc"
diff --git a/tests/benchmarks/qfileinfo/qfileinfo.pro b/tests/benchmarks/qfileinfo/qfileinfo.pro
new file mode 100644
index 0000000..295cb50
--- /dev/null
+++ b/tests/benchmarks/qfileinfo/qfileinfo.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = qfileinfo
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+
+CONFIG += release
+
+# Input
+SOURCES += main.cpp