summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-09-09 05:14:50 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-09-09 05:14:50 (GMT)
commitd03ed1d1ff45ff484f35ace9d90f6c84dd73aa21 (patch)
tree954527301ce27777e5ec26f0b9c9abaee07e5481 /tests/auto
parent6878a0b7c507d21366cacee0a09bafeb81726d82 (diff)
parenta57af1d6856ffa3a50eb1e0cdd1653b7b4ebdb41 (diff)
downloadQt-d03ed1d1ff45ff484f35ace9d90f6c84dd73aa21.zip
Qt-d03ed1d1ff45ff484f35ace9d90f6c84dd73aa21.tar.gz
Qt-d03ed1d1ff45ff484f35ace9d90f6c84dd73aa21.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp117
-rw-r--r--tests/auto/network-settings.h16
-rw-r--r--tests/auto/qabstractbutton/tst_qabstractbutton.cpp5
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp8
-rw-r--r--tests/auto/qbytearray/qbytearray.pro11
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp10
-rw-r--r--tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp7
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp14
-rw-r--r--tests/auto/qfocusevent/tst_qfocusevent.cpp25
-rw-r--r--tests/auto/qgl/tst_qgl.cpp49
-rw-r--r--tests/auto/qgridlayout/tst_qgridlayout.cpp11
-rw-r--r--tests/auto/qgroupbox/tst_qgroupbox.cpp6
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp9
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp9
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp30
-rw-r--r--tests/auto/qmdiarea/tst_qmdiarea.cpp17
-rw-r--r--tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp42
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp14
-rw-r--r--tests/auto/qmultiscreen/qmultiscreen.pro1
-rw-r--r--tests/auto/qpushbutton/tst_qpushbutton.cpp8
-rw-r--r--tests/auto/qspinbox/tst_qspinbox.cpp20
-rw-r--r--tests/auto/qstackedlayout/tst_qstackedlayout.cpp13
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp25
-rw-r--r--tests/auto/qtextbrowser/tst_qtextbrowser.cpp6
-rw-r--r--tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp8
-rw-r--r--tests/auto/qtransformedscreen/qtransformedscreen.pro1
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp5
-rw-r--r--tests/auto/qwsembedwidget/qwsembedwidget.pro1
-rw-r--r--tests/auto/qwsinputmethod/qwsinputmethod.pro1
-rw-r--r--tests/auto/qwswindowsystem/qwswindowsystem.pro1
30 files changed, 357 insertions, 133 deletions
diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
index 075fa01..46d5b9d 100644
--- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
+++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
@@ -462,22 +462,62 @@ struct Integer
int Integer::instanceCount = 0;
-template <template<typename T> class Container>
+struct IntegerMoveable
+ {
+ IntegerMoveable(int value = 42)
+ : val(value)
+ {
+ delete new int;
+ ++instanceCount;
+ }
+
+ IntegerMoveable(const IntegerMoveable &other)
+ : val(other.val)
+ {
+ delete new int;
+ ++instanceCount;
+ }
+
+ IntegerMoveable &operator=(const IntegerMoveable &other)
+ {
+ delete new int;
+ val = other.val;
+ return *this;
+ }
+
+ ~IntegerMoveable()
+ {
+ --instanceCount;
+ }
+
+ int value() const
+ {
+ return val;
+ }
+
+ int val;
+ static int instanceCount;
+ };
+
+int IntegerMoveable::instanceCount = 0;
+Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE);
+
+template <typename T, template<typename> class Container >
void containerInsertTest(QObject*)
{
- Container<Integer> container;
+ Container<T> container;
// insert an item in an empty container
try {
container.insert(container.begin(), 41);
} catch (...) {
QVERIFY(container.isEmpty());
- QCOMPARE(Integer::instanceCount, 0);
+ QCOMPARE(T::instanceCount, 0);
return;
}
QCOMPARE(container.size(), 1);
- QCOMPARE(Integer::instanceCount, 1);
+ QCOMPARE(T::instanceCount, 1);
// insert an item before another item
try {
@@ -485,11 +525,11 @@ void containerInsertTest(QObject*)
} catch (...) {
QCOMPARE(container.size(), 1);
QCOMPARE(container.first().value(), 41);
- QCOMPARE(Integer::instanceCount, 1);
+ QCOMPARE(T::instanceCount, 1);
return;
}
- QCOMPARE(Integer::instanceCount, 2);
+ QCOMPARE(T::instanceCount, 2);
// insert an item in between
try {
@@ -498,24 +538,24 @@ void containerInsertTest(QObject*)
QCOMPARE(container.size(), 2);
QCOMPARE(container.first().value(), 41);
QCOMPARE((container.begin() + 1)->value(), 42);
- QCOMPARE(Integer::instanceCount, 2);
+ QCOMPARE(T::instanceCount, 2);
return;
}
- QCOMPARE(Integer::instanceCount, 3);
+ QCOMPARE(T::instanceCount, 3);
}
-template <template<typename T> class Container>
+template <typename T, template<typename> class Container>
void containerAppendTest(QObject*)
{
- Container<Integer> container;
+ Container<T> container;
// append to an empty container
try {
container.append(42);
} catch (...) {
QCOMPARE(container.size(), 0);
- QCOMPARE(Integer::instanceCount, 0);
+ QCOMPARE(T::instanceCount, 0);
return;
}
@@ -525,15 +565,38 @@ void containerAppendTest(QObject*)
} catch (...) {
QCOMPARE(container.size(), 1);
QCOMPARE(container.first().value(), 42);
- QCOMPARE(Integer::instanceCount, 1);
+ QCOMPARE(T::instanceCount, 1);
return;
}
+
+ Container<T> container2;
+
+ try {
+ container2.append(44);
+ } catch (...) {
+ // don't care
+ return;
+ }
+ QCOMPARE(T::instanceCount, 3);
+
+ // append another container with one item
+ try {
+ container += container2;
+ } catch (...) {
+ QCOMPARE(container.size(), 2);
+ QCOMPARE(container.first().value(), 42);
+ QCOMPARE((container.begin() + 1)->value(), 43);
+ QCOMPARE(T::instanceCount, 3);
+ return;
+ }
+
+ QCOMPARE(T::instanceCount, 4);
}
-template <template<typename T> class Container>
+template <typename T, template<typename> class Container>
void containerEraseTest(QObject*)
{
- Container<Integer> container;
+ Container<T> container;
try {
container.append(42);
@@ -548,7 +611,7 @@ void containerEraseTest(QObject*)
// sanity checks
QCOMPARE(container.size(), 5);
- QCOMPARE(Integer::instanceCount, 5);
+ QCOMPARE(T::instanceCount, 5);
// delete the first one
try {
@@ -556,20 +619,20 @@ void containerEraseTest(QObject*)
} catch (...) {
QCOMPARE(container.size(), 5);
QCOMPARE(container.first().value(), 42);
- QCOMPARE(Integer::instanceCount, 5);
+ QCOMPARE(T::instanceCount, 5);
return;
}
QCOMPARE(container.size(), 4);
QCOMPARE(container.first().value(), 43);
- QCOMPARE(Integer::instanceCount, 4);
+ QCOMPARE(T::instanceCount, 4);
// delete the last one
try {
container.erase(container.end() - 1);
} catch (...) {
QCOMPARE(container.size(), 4);
- QCOMPARE(Integer::instanceCount, 4);
+ QCOMPARE(T::instanceCount, 4);
return;
}
@@ -577,7 +640,7 @@ void containerEraseTest(QObject*)
QCOMPARE(container.first().value(), 43);
QCOMPARE((container.begin() + 1)->value(), 44);
QCOMPARE((container.begin() + 2)->value(), 45);
- QCOMPARE(Integer::instanceCount, 3);
+ QCOMPARE(T::instanceCount, 3);
// delete the middle one
try {
@@ -587,14 +650,14 @@ void containerEraseTest(QObject*)
QCOMPARE(container.first().value(), 43);
QCOMPARE((container.begin() + 1)->value(), 44);
QCOMPARE((container.begin() + 2)->value(), 45);
- QCOMPARE(Integer::instanceCount, 3);
+ QCOMPARE(T::instanceCount, 3);
return;
}
QCOMPARE(container.size(), 2);
QCOMPARE(container.first().value(), 43);
QCOMPARE((container.begin() + 1)->value(), 45);
- QCOMPARE(Integer::instanceCount, 2);
+ QCOMPARE(T::instanceCount, 2);
}
template <template<typename T> class Container>
@@ -602,9 +665,12 @@ static void containerData()
{
QTest::addColumn<TestFunction>("testFunction");
- QTest::newRow("insert") << static_cast<TestFunction>(containerInsertTest<Container>);
- QTest::newRow("append") << static_cast<TestFunction>(containerAppendTest<Container>);
- QTest::newRow("erase") << static_cast<TestFunction>(containerEraseTest<Container>);
+ QTest::newRow("insert static") << static_cast<TestFunction>(containerInsertTest<Integer, Container>);
+ QTest::newRow("append static") << static_cast<TestFunction>(containerAppendTest<Integer, Container>);
+ QTest::newRow("erase static") << static_cast<TestFunction>(containerEraseTest<Integer, Container>);
+ QTest::newRow("insert moveable") << static_cast<TestFunction>(containerInsertTest<IntegerMoveable, Container>);
+ QTest::newRow("append moveable") << static_cast<TestFunction>(containerAppendTest<IntegerMoveable, Container>);
+ QTest::newRow("erase moveable") << static_cast<TestFunction>(containerEraseTest<IntegerMoveable, Container>);
}
void tst_ExceptionSafetyObjects::vector_data()
@@ -616,7 +682,8 @@ void tst_ExceptionSafetyObjects::vector()
{
QFETCH(TestFunction, testFunction);
- if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert"))
+ if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert static")
+ || QLatin1String(QTest::currentDataTag()) == QLatin1String("insert moveable"))
QSKIP("QVector::insert is currently not strongly exception safe", SkipSingle);
doOOMTest(testFunction, 0);
diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h
index 144f7b3..a770f8e 100644
--- a/tests/auto/network-settings.h
+++ b/tests/auto/network-settings.h
@@ -328,3 +328,19 @@ QByteArray QtNetworkSettings::imapExpectedReplySsl;
#else
#define Q_SET_DEFAULT_IAP
#endif
+
+#ifdef QT_NETWORK_LIB
+class QtNetworkSettingsInitializerCode {
+public:
+ QtNetworkSettingsInitializerCode() {
+ QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName());
+ if (testServerResult.error() != QHostInfo::NoError) {
+ qWarning() << "Could not lookup" << QtNetworkSettings::serverName();
+ qWarning() << "Please configure the test environment!";
+ qWarning() << "See /etc/hosts or network-settings.h";
+ qFatal("Exiting");
+ }
+ }
+};
+QtNetworkSettingsInitializerCode qtNetworkSettingsInitializer;
+#endif
diff --git a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp
index de2d9f4..7ee52ad 100644
--- a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp
+++ b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp
@@ -550,6 +550,7 @@ void tst_QAbstractButton::setShortcut()
{
QKeySequence seq( Qt::Key_A );
testWidget->setShortcut( seq );
+ QApplication::setActiveWindow(testWidget);
// must be active to get shortcuts
for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) {
@@ -557,8 +558,8 @@ void tst_QAbstractButton::setShortcut()
QApplication::instance()->processEvents();
QTest::qWait(100);
}
- QVERIFY(testWidget->isActiveWindow());
-
+ QVERIFY(testWidget->isActiveWindow());
+
QTest::keyClick( testWidget, 'A' );
QTest::qWait(300); // Animate click takes time
QCOMPARE(click_count, (uint)1);
diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
index f49568d..82969b9 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -100,7 +100,7 @@ private slots:
#if QT_VERSION >= 0x040600
void autoIncrementId();
#endif
-
+
void task209485_removeFromGroupInEventHandler_data();
void task209485_removeFromGroupInEventHandler();
};
@@ -333,12 +333,12 @@ void tst_QButtonGroup::testSignals()
QCOMPARE(clickedSpy.count(), 1);
QCOMPARE(clickedIdSpy.count(), 1);
-
- int expectedId = -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);
diff --git a/tests/auto/qbytearray/qbytearray.pro b/tests/auto/qbytearray/qbytearray.pro
index d14534b..a0c143e 100644
--- a/tests/auto/qbytearray/qbytearray.pro
+++ b/tests/auto/qbytearray/qbytearray.pro
@@ -4,16 +4,17 @@ SOURCES += tst_qbytearray.cpp
QT = core
-wince*|symbian: {
+wince*|symbian {
addFile.sources = rfc3252.txt
addFile.path = .
DEPLOYMENT += addFile
}
-wince: {
- DEFINES += SRCDIR=\\\"\\\"
-} symbian: {
+wince* {
+ DEFINES += SRCDIR=\\\"./\\\"
+} else:symbian {
TARGET.EPOCHEAPSIZE="0x100 0x800000"
} else {
- DEFINES += SRCDIR=\\\"$$PWD/\\\"
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
+
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 928d826..7eefb26 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -1025,6 +1025,7 @@ void tst_QCompleter::multipleWidgets()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&window);
#endif
+ QApplication::setActiveWindow(&window);
QTest::qWait(50);
QTRY_VERIFY(qApp->focusWidget() == comboBox);
comboBox->lineEdit()->setText("it");
@@ -1058,6 +1059,7 @@ void tst_QCompleter::focusIn()
window.show();
QTest::qWait(100);
window.activateWindow();
+ QApplication::setActiveWindow(&window);
QTest::qWait(100);
QTRY_COMPARE(qApp->activeWindow(), &window);
@@ -1322,8 +1324,10 @@ void tst_QCompleter::task253125_lineEditCompletion()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&edit);
#endif
+ QTest::qWait(10);
+ QApplication::setActiveWindow(&edit);
+ QTRY_COMPARE(QApplication::activeWindow(), &edit);
- QTest::qWait(100);
QTest::keyClick(&edit, 'i');
QCOMPARE(edit.completer()->currentCompletion(), QString("iota"));
QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
@@ -1358,7 +1362,9 @@ void tst_QCompleter::task247560_keyboardNavigation()
qt_x11_wait_for_window_manager(&edit);
#endif
- QTest::qWait(100);
+ QTest::qWait(10);
+ QApplication::setActiveWindow(&edit);
+ QTRY_COMPARE(QApplication::activeWindow(), &edit);
QTest::keyClick(&edit, 'r');
QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
index 6162be0..aa3ccb7 100644
--- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -52,6 +52,9 @@
#include <qlineedit.h>
#include <qdebug.h>
+
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=gui/widgets/qspinbox.h gui/widgets/qspinbox.cpp gui/widgets/qabstractspinbox.cpp gui/widgets/qabstractspinbox_p.h gui/widgets/qabstractspinbox.h
@@ -772,8 +775,8 @@ void tst_QDoubleSpinBox::editingFinished()
layout->addWidget(box2);
testFocusWidget->show();
- QTest::qWait(100);
- QVERIFY(box->isActiveWindow());
+ QTest::qWait(10);
+ QTRY_VERIFY(box->isActiveWindow());
box->setFocus();
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index d951a86..076934c 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -411,6 +411,10 @@ void tst_QFileInfo::absolutePath_data()
QString drivePrefix;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
drivePrefix = QDir::currentPath().left(2);
+
+ // Make sure drive-relative paths return correct absolute paths (task 255326)
+ QTest::newRow("c:my.dll") << "c:my.dll" << QDir::currentPath() << "my.dll";
+ QTest::newRow("x:my.dll") << "x:my.dll" << "X:/" << "my.dll";
#endif
QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << "";
QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1";
@@ -449,6 +453,10 @@ void tst_QFileInfo::absFilePath_data()
curr.remove(0, 2); // Make it a absolute path with no drive specifier: \depot\qt-4.2\tests\auto\qfileinfo
QTest::newRow(".") << curr << QDir::currentPath();
QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt";
+
+ // Make sure drive-relative paths return correct absolute paths (task 255326)
+ QTest::newRow("c:my.dll") << "c:temp/my.dll" << QDir::currentPath() + "/temp/my.dll";
+ QTest::newRow("x:my.dll") << "x:temp/my.dll" << "X:/temp/my.dll";
#else
QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt";
#endif
@@ -1052,19 +1060,19 @@ void tst_QFileInfo::isHidden_data()
QFile file(hiddenFileName);
if (file.open(QIODevice::WriteOnly)) {
QTextStream t(&file);
- t << "foobar";
+ t << "foobar";
} else {
qWarning("Failed to create hidden file");
}
QFile file2(notHiddenFileName);
if (file2.open(QIODevice::WriteOnly)) {
QTextStream t(&file);
- t << "foobar";
+ t << "foobar";
} else {
qWarning("Failed to create non-hidden file");
}
}
-
+
RFs rfs;
TInt err = rfs.Connect();
if (err == KErrNone) {
diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp
index 662f115..5ad78de 100644
--- a/tests/auto/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp
@@ -56,6 +56,8 @@
#include <qlineedit.h>
#include <QBoxLayout>
+#include "../../shared/util.h"
+
QT_FORWARD_DECLARE_CLASS(QWidget)
//TESTED_CLASS=
@@ -168,6 +170,7 @@ void tst_QFocusEvent::initWidget()
{
// On X11 we have to ensure the event was processed before doing any checking, on Windows
// this is processed straight away.
+ QApplication::setActiveWindow(childFocusWidgetOne);
for (int i = 0; i < 1000; ++i) {
if (childFocusWidgetOne->isActiveWindow() && childFocusWidgetOne->hasFocus())
@@ -243,9 +246,9 @@ void tst_QFocusEvent::checkReason_BackTab()
// Now test the backtab key
QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab );
- QTest::qWait(2000);
+ QTest::qWait(200);
- QVERIFY(childFocusWidgetOne->focusOutEventRecieved);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved);
QVERIFY(childFocusWidgetTwo->focusInEventRecieved);
QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
QVERIFY(childFocusWidgetTwo->focusInEventGotFocus);
@@ -265,9 +268,9 @@ void tst_QFocusEvent::checkReason_Popup()
Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget );
popupMenu->insertItem( "Test" );
popupMenu->popup( QPoint(0,0) );
- QTest::qWait(500);
+ QTest::qWait(50);
- QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
QVERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( !childFocusWidgetOne->focusInEventRecieved );
@@ -290,11 +293,11 @@ void tst_QFocusEvent::checkReason_Popup()
QMenu* popupMenu = new QMenu( testFocusWidget );
popupMenu->addMenu( "Test" );
popupMenu->popup( QPoint(0,0) );
- QTest::qWait(500);
+ QTest::qWait(50);
- QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
- QVERIFY( childFocusWidgetOne->hasFocus() );
+ QTRY_VERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( !childFocusWidgetOne->focusInEventRecieved );
QVERIFY( childFocusWidgetOne->focusOutEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusInEventRecieved );
@@ -368,13 +371,13 @@ void tst_QFocusEvent::checkReason_focusWidget()
QLineEdit edit1;
QLineEdit edit2;
- QVBoxLayout outerLayout;
+ QVBoxLayout outerLayout;
outerLayout.addWidget(&frame1);
outerLayout.addWidget(&frame2);
window1.setLayout(&outerLayout);
-
- QVBoxLayout leftLayout;
- QVBoxLayout rightLayout;
+
+ QVBoxLayout leftLayout;
+ QVBoxLayout rightLayout;
leftLayout.addWidget(&edit1);
rightLayout.addWidget(&edit2);
frame1.setLayout(&leftLayout);
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 650c1ca..43f4227 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -1432,6 +1432,55 @@ void tst_QGL::fboFormat()
QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil);
QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D));
QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16));
+
+ // operator== and operator!= for QGLFramebufferObjectFormat.
+ QGLFramebufferObjectFormat format1c;
+ QGLFramebufferObjectFormat format2c;
+
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+ format1c.setSamples(8);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setSamples(8);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ format1c.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ format1c.setTextureTarget(GL_TEXTURE_3D);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setTextureTarget(GL_TEXTURE_3D);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ format1c.setInternalTextureFormat(GL_RGB16);
+ QVERIFY(!(format1c == format2c));
+ QVERIFY(format1c != format2c);
+ format2c.setInternalTextureFormat(GL_RGB16);
+ QVERIFY(format1c == format2c);
+ QVERIFY(!(format1c != format2c));
+
+ QGLFramebufferObjectFormat format3c(format1c);
+ QGLFramebufferObjectFormat format4c;
+ QVERIFY(format1c == format3c);
+ QVERIFY(!(format1c != format3c));
+ format3c.setInternalTextureFormat(DEFAULT_FORMAT);
+ QVERIFY(!(format1c == format3c));
+ QVERIFY(format1c != format3c);
+
+ format4c = format1c;
+ QVERIFY(format1c == format4c);
+ QVERIFY(!(format1c != format4c));
+ format4c.setInternalTextureFormat(DEFAULT_FORMAT);
+ QVERIFY(!(format1c == format4c));
+ QVERIFY(format1c != format4c);
}
QTEST_MAIN(tst_QGL)
diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp
index 13d79b1..590bafa 100644
--- a/tests/auto/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp
@@ -51,6 +51,8 @@
#include <QtGui/QWindowsStyle>
#include <QStyleFactory>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h
@@ -788,8 +790,8 @@ void tst_QGridLayout::minMaxSize_data()
QTest::addColumn<QSize>("fixedSize");
//input and expected output
QTest::addColumn<SizeInfoList>("sizeinfos");
-
- QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1
+
+ QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1
<< int(QSizePolicy::Minimum) << QSize(152, 50) << (SizeInfoList()
<< SizeInfo(QRect(10, 10, 43, 30), QSize( 75, 75), QSize(0,0))
<< SizeInfo(QRect(10 + 45, 10, 43, 30), QSize(75, 75), QSize( 0, 0))
@@ -917,13 +919,14 @@ void tst_QGridLayout::minMaxSize()
#if defined(Q_WS_X11)
qt_x11_wait_for_window_manager(m_toplevel); // wait for the show
#endif
+ QTest::qWait(20);
m_toplevel->adjustSize();
- QTest::qWait(200); // wait for the implicit adjustSize
+ QTest::qWait(20); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
// If that does not help there is likely a problem with the implicit adjustSize in show()
if (!fixedSize.isValid()) {
// Note that this can fail if the desktop has large fonts on windows.
- QCOMPARE(m_toplevel->size(), m_toplevel->sizeHint());
+ QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint());
}
// We are relying on the order here...
for (int pi = 0; pi < sizehinters.count(); ++pi) {
diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp
index 94b70e6..7346700 100644
--- a/tests/auto/qgroupbox/tst_qgroupbox.cpp
+++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp
@@ -49,6 +49,8 @@
#include "qgroupbox.h"
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -81,7 +83,7 @@ private slots:
void toggledVsClicked();
void childrenAreDisabled();
void propagateFocus();
-
+
private:
bool checked;
qint64 timeStamp;
@@ -467,7 +469,7 @@ void tst_QGroupBox::propagateFocus()
box.show();
box.setFocus();
QTest::qWait(250);
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
+ QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
}
QTEST_MAIN(tst_QGroupBox)
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 1ef77c0..9871da3 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -63,6 +63,8 @@
#include <QPlainTextEdit>
#include <QDialog>
+#include "../../shared/util.h"
+
Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint)
//TESTED_CLASS=
@@ -862,6 +864,8 @@ void tst_QItemDelegate::decoration()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&table);
#endif
+ QApplication::setActiveWindow(&table);
+ QTRY_COMPARE(QApplication::activeWindow(), &table);
QVariant value;
switch ((QVariant::Type)type) {
@@ -1164,10 +1168,7 @@ void tst_QItemDelegate::task257859_finalizeEdit()
QDialog dialog;
QTimer::singleShot(100, &dialog, SLOT(close()));
dialog.exec();
-
- QTest::qWait(100);
-
- QVERIFY(!editor);
+ QTRY_VERIFY(!editor);
}
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 6bbdf5d..47f0730 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -343,6 +343,7 @@ void tst_QLineEdit::initTestCase()
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(testWidget);
#endif
+ QTRY_VERIFY(testWidget->hasFocus());
changed_count = 0;
edited_count = 0;
@@ -1601,8 +1602,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
testWidget->setFocus();
testWidget->raise();
- QTest::qWait(250);
- QVERIFY(testWidget->hasFocus());
+ QTRY_VERIFY(testWidget->hasFocus());
QTest::keyPress(testWidget, '0');
QTest::keyPress(testWidget, '1');
@@ -1614,6 +1614,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
QVERIFY(!testWidget->hasFocus());
QCOMPARE(testWidget->displayText(), QString(5, fillChar));
testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
QCOMPARE(testWidget->displayText(), QString(5, fillChar));
QTest::keyPress(testWidget, '0');
@@ -3397,7 +3398,7 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
qt_x11_wait_for_window_manager(&lineEdit);
#endif
lineEdit.setFocus();
- QTest::qWait(200);
+ QTRY_VERIFY(lineEdit.hasFocus());
QTest::keyPress(&lineEdit, 'a');
QTest::keyPress(&lineEdit, Qt::Key_Return);
QCOMPARE(lineEdit.text(), completion);
@@ -3491,7 +3492,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
testWidget->setFocus();
- QTest::qWait(250);
+ QTRY_VERIFY(testWidget->hasFocus());
QTest::keyPress(testWidget, '0');
QCOMPARE(testWidget->displayText(), QString("0"));
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 2be1a03..2831747 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -113,6 +113,7 @@ private slots:
void task254449_draggingItemToNegativeCoordinates();
void keyboardSearch();
void shiftSelectionWithNonUniformItemSizes();
+ void clickOnViewportClearsSelection();
};
// Testing get/set functions
@@ -1733,5 +1734,34 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
}
}
+void tst_QListView::clickOnViewportClearsSelection()
+{
+ QStringList items;
+ items << "Text1";
+ QStringListModel model(items);
+ QListView view;
+ view.setModel(&model);
+ view.setSelectionMode(QListView::ExtendedSelection);
+
+ view.selectAll();
+ QModelIndex index = model.index(0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QVERIFY(view.selectionModel()->isSelected(index));
+
+ //we try to click outside of the index
+ const QPoint point = view.visualRect(index).bottomRight() + QPoint(10,10);
+
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, point);
+ //at this point, the selection shouldn't have changed
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QVERIFY(view.selectionModel()->isSelected(index));
+
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, point);
+ //now the selection should be cleared
+ QVERIFY(!view.selectionModel()->hasSelection());
+
+}
+
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp
index 65dab48..246410d 100644
--- a/tests/auto/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp
@@ -62,6 +62,8 @@
#endif
#include <QMacStyle>
+#include "../../shared/util.h"
+
static const Qt::WindowFlags DefaultWindowFlags
= Qt::SubWindow | Qt::WindowSystemMenuHint
| Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
@@ -467,7 +469,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
- QCOMPARE(spy.count(), 5);
+ QTRY_COMPARE(spy.count(), 5);
QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back());
spy.clear();
@@ -493,7 +495,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QVERIFY(!mdiArea.activeSubWindow());
QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
spy.clear();
@@ -503,7 +505,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
@@ -516,14 +518,14 @@ void tst_QMdiArea::subWindowActivated2()
if (!macHasAccessToWindowsServer())
QEXPECT_FAIL("", "showMinimized doesn't really minimize if you don't have access to the server", Abort);
#endif
- QTest::qWait(100);
+ QTest::qWait(10);
#if defined(Q_WS_QWS)
QEXPECT_FAIL("", "task 168682", Abort);
#endif
#ifdef Q_OS_WINCE
QSKIP("Not fixed yet. See Task 197453", SkipAll);
#endif
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QVERIFY(!mdiArea.activeSubWindow());
QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
spy.clear();
@@ -533,7 +535,7 @@ void tst_QMdiArea::subWindowActivated2()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
}
@@ -1734,6 +1736,7 @@ void tst_QMdiArea::tileSubWindows()
qt_x11_wait_for_window_manager(&workspace);
#endif
qApp->processEvents();
+ QTRY_COMPARE(workspace.size(), QSize(350, 150));
const QSize minSize(300, 100);
foreach (QMdiSubWindow *subWindow, workspace.subWindowList())
@@ -1885,7 +1888,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows()
workspace.resize(workspaceSize + QSize(increment, increment));
QTest::qWait(100);
qApp->processEvents();
- QCOMPARE(workspace.size(), workspaceSize + QSize(increment, increment));
+ QTRY_COMPARE(workspace.size(), workspaceSize + QSize(increment, increment));
QCOMPARE(window->size(), windowSize + QSize(increment, increment));
workspaceSize = workspace.size();
}
diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
index 78ba46b..4d5160b 100644
--- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -63,6 +63,9 @@
#include <QMacStyle>
#endif
+#include "../../shared/util.h"
+
+
QT_BEGIN_NAMESPACE
#if defined(Q_WS_X11)
extern void qt_x11_wait_for_window_manager(QWidget *w);
@@ -1004,15 +1007,16 @@ void tst_QMdiSubWindow::setSystemMenu()
qt_x11_wait_for_window_manager(&mainWindow);
#endif
- QVERIFY(subWindow->isVisible());
- QPoint globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft());
+ QTRY_VERIFY(subWindow->isVisible());
+ QPoint globalPopupPos;
// Show system menu
QVERIFY(!qApp->activePopupWidget());
subWindow->showSystemMenu();
- QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
+ (globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) );
systemMenu->hide();
QVERIFY(!qApp->activePopupWidget());
@@ -1034,9 +1038,9 @@ void tst_QMdiSubWindow::setSystemMenu()
// Show the new system menu
QVERIFY(!qApp->activePopupWidget());
subWindow->showSystemMenu();
- QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
systemMenu->hide();
QVERIFY(!qApp->activePopupWidget());
@@ -1048,12 +1052,12 @@ void tst_QMdiSubWindow::setSystemMenu()
QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget();
QVERIFY(menuLabel);
subWindow->showSystemMenu();
- QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
- globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height()));
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
+ (globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height()))));
systemMenu->hide();
- QVERIFY(!qApp->activePopupWidget());
+ QTRY_VERIFY(!qApp->activePopupWidget());
subWindow->showNormal();
#endif
@@ -1064,11 +1068,11 @@ void tst_QMdiSubWindow::setSystemMenu()
subWindow->showSystemMenu();
QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
// + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top())
globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0);
globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0);
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
systemMenu->hide();
QVERIFY(!qApp->activePopupWidget());
@@ -1081,10 +1085,10 @@ void tst_QMdiSubWindow::setSystemMenu()
QVERIFY(menuLabel);
subWindow->showSystemMenu();
QTest::qWait(250);
- QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height()));
globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0);
- QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
#endif
delete systemMenu;
@@ -1902,7 +1906,7 @@ void tst_QMdiSubWindow::task_182852()
mainWindow.show();
mainWindow.menuBar()->setVisible(true);
qApp->setActiveWindow(&mainWindow);
-
+
QString originalWindowTitle = QString::fromLatin1("MainWindow - [foo]");
mainWindow.setWindowTitle(originalWindowTitle);
@@ -1917,7 +1921,7 @@ void tst_QMdiSubWindow::task_182852()
window->showMaximized();
qApp->processEvents();
QVERIFY(window->isMaximized());
-
+
QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
.arg(originalWindowTitle, window->widget()->windowTitle()));
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index ab8dd48..4a4231a 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -55,6 +55,9 @@
#include <qmenu.h>
#include <qstyle.h>
#include <qdebug.h>
+
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -437,15 +440,16 @@ void tst_QMenu::overrideMenuAction()
m->addAction(aQuit);
w.show();
- QTest::qWait(200);
+ w.setFocus();
+ QTRY_VERIFY(w.hasFocus());
//test of the action inside the menu
QTest::keyClick(&w, Qt::Key_X, Qt::ControlModifier);
- QCOMPARE(activated, aQuit);
+ QTRY_COMPARE(activated, aQuit);
//test if the menu still pops out
QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier);
- QVERIFY(m->isVisible());
+ QTRY_VERIFY(m->isVisible());
delete aFileMenu;
@@ -703,12 +707,12 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
};
QMenu sub;
-
+
if (sub.style()->styleHint(QStyle::SH_Menu_Scrollable, 0, &sub)) {
//the style prevents the menus from getting columns
QSKIP("the style doesn't support multiple columns, it makes the menu scrollable", SkipSingle);
}
-
+
sub.addAction("Sub-Item1");
QAction *subAction = sub.addAction("Sub-Item2");
diff --git a/tests/auto/qmultiscreen/qmultiscreen.pro b/tests/auto/qmultiscreen/qmultiscreen.pro
index 4e92a65..30666d7 100644
--- a/tests/auto/qmultiscreen/qmultiscreen.pro
+++ b/tests/auto/qmultiscreen/qmultiscreen.pro
@@ -1,6 +1,5 @@
load(qttest_p4)
SOURCES += tst_qmultiscreen.cpp
-QT = core
requires(embedded)
diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp
index 5059578..2013258 100644
--- a/tests/auto/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp
@@ -54,6 +54,8 @@
#include <QStyleFactory>
#include <QTabWidget>
+#include "../../shared/util.h"
+
Q_DECLARE_METATYPE(QPushButton*)
//TESTED_CLASS=
@@ -413,6 +415,7 @@ void tst_QPushButton::setAccel()
// The shortcut will not be activated unless the button is in a active
// window and has focus
+ QApplication::setActiveWindow(testWidget);
testWidget->setFocus();
for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) {
testWidget->activateWindow();
@@ -421,8 +424,8 @@ void tst_QPushButton::setAccel()
}
QVERIFY(testWidget->isActiveWindow());
QTest::keyClick( testWidget, 'A', Qt::AltModifier );
- QTest::qWait( 500 );
- QVERIFY( click_count == 1 );
+ QTest::qWait( 50 );
+ QTRY_VERIFY( click_count == 1 );
QVERIFY( press_count == 1 );
QVERIFY( release_count == 1 );
QVERIFY( toggle_count == 0 );
@@ -430,6 +433,7 @@ void tst_QPushButton::setAccel()
// wait 200 ms because setAccel uses animateClick.
// if we don't wait this may screw up a next test.
QTest::qWait(200);
+ QTRY_VERIFY( !testWidget->isDown() );
}
void tst_QPushButton::animateClick()
diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp
index 73d25a2..f4d70d1 100644
--- a/tests/auto/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/qspinbox/tst_qspinbox.cpp
@@ -140,7 +140,7 @@ private slots:
void removeAll();
void startWithDash();
void undoRedo();
-
+
void specialValue();
void textFromValue();
@@ -750,11 +750,13 @@ void tst_QSpinBox::editingFinished()
QSpinBox *box2 = new QSpinBox(testFocusWidget);
layout->addWidget(box2);
+ testFocusWidget->show();
+ QApplication::setActiveWindow(testFocusWidget);
box->activateWindow();
- QTest::qWait(1000);//qApp->processEvents();
+ QTest::qWait(100);//qApp->processEvents();
box->setFocus();
- QTRY_VERIFY(qApp->focusWidget() == box);
+ QTRY_COMPARE(qApp->focusWidget(), box);
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
@@ -910,7 +912,7 @@ void tst_QSpinBox::undoRedo()
void tst_QSpinBox::specialValue()
{
QString specialText="foo";
-
+
QWidget topWidget;
QVBoxLayout layout(&topWidget);
SpinBox spin(&topWidget);
@@ -937,7 +939,7 @@ void tst_QSpinBox::specialValue()
QCOMPARE(spin.text(), QString("0"));
QTest::keyClick(&spin, Qt::Key_Return);
QCOMPARE(spin.text(), specialText);
-
+
spin.setValue(50);
QTest::keyClick(&spin, Qt::Key_Return);
QTest::keyClick(&spin, '0');
@@ -987,17 +989,17 @@ void tst_QSpinBox::sizeHint()
QVERIFY(spinBox->sizeHintRequests > 0);
// Suffix
- spinBox->sizeHintRequests = 0;
+ spinBox->sizeHintRequests = 0;
spinBox->setSuffix(QLatin1String("abcdefghij"));
qApp->processEvents();
- QVERIFY(spinBox->sizeHintRequests > 0);
+ QVERIFY(spinBox->sizeHintRequests > 0);
// Range
- spinBox->sizeHintRequests = 0;
+ spinBox->sizeHintRequests = 0;
spinBox->setRange(0, 1234567890);
spinBox->setValue(spinBox->maximum());
qApp->processEvents();
- QVERIFY(spinBox->sizeHintRequests > 0);
+ QVERIFY(spinBox->sizeHintRequests > 0);
}
QTEST_MAIN(tst_QSpinBox)
diff --git a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp
index c6a30a5..481ee2c 100644
--- a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp
@@ -47,6 +47,8 @@
#include <qwidget.h>
#include <QPushButton>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h
@@ -149,7 +151,7 @@ void tst_QStackedLayout::testCase()
QStackedLayout onStack(testWidget);
QStackedLayout *testLayout = &onStack;
testWidget->setLayout(testLayout);
-
+
QSignalSpy spy(testLayout,SIGNAL(currentChanged(int)));
// Nothing in layout
@@ -350,12 +352,15 @@ void tst_QStackedLayout::keepFocusAfterSetCurrent()
stackLayout->setCurrentIndex(0);
+ testWidget->show();
+ QTest::qWait(25);
+ QApplication::setActiveWindow(testWidget);
+
edit1->setFocus();
- QTest::qWait(250);
edit1->activateWindow();
- QTest::qWait(100);
+ QTest::qWait(25);
- QVERIFY(edit1->hasFocus());
+ QTRY_VERIFY(edit1->hasFocus());
stackLayout->setCurrentIndex(1);
QVERIFY(!edit1->hasFocus());
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 6fe2963..51d0e33 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -2334,8 +2334,10 @@ void tst_QTableView::scrollTo()
QtTestTableView view;
view.show();
- view.resize(columnWidth * 2, rowHeight * 2);
+ QSize forcedSize(columnWidth * 2, rowHeight * 2);
+ view.resize(forcedSize);
QTest::qWait(0);
+ QTRY_COMPARE(view.size(), forcedSize);
view.setModel(&model);
view.setSpan(row, column, rowSpan, columnSpan);
@@ -2910,6 +2912,7 @@ void tst_QTableView::tabFocus()
window.setFocus();
QTest::qWait(100);
window.activateWindow();
+ QApplication::setActiveWindow(&window);
QTest::qWait(100);
qApp->processEvents();
@@ -2926,43 +2929,43 @@ void tst_QTableView::tabFocus()
for (int i = 0; i < 2; ++i) {
// tab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
- QVERIFY(!window.hasFocus());
+ QTRY_VERIFY(!window.hasFocus());
QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// tab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
}
// backtab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(!window.hasFocus());
- QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// backtab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
QStandardItemModel *model = new QStandardItemModel;
view->setModel(model);
// backtab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(!window.hasFocus());
- QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// backtab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
model->insertRow(0, new QStandardItem("Hei"));
model->insertRow(0, new QStandardItem("Hei"));
@@ -2970,8 +2973,8 @@ void tst_QTableView::tabFocus()
// backtab to view
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(view->hasFocus());
QVERIFY(!window.hasFocus());
- QVERIFY(view->hasFocus());
QVERIFY(!edit->hasFocus());
// backtab to edit doesn't work
@@ -2984,14 +2987,14 @@ void tst_QTableView::tabFocus()
// backtab to edit
QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab);
+ QTRY_VERIFY(edit->hasFocus());
QVERIFY(!window.hasFocus());
QVERIFY(!view->hasFocus());
- QVERIFY(edit->hasFocus());
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
- QVERIFY(view->hasFocus());
+ QTRY_VERIFY(view->hasFocus());
QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab);
- QVERIFY(edit->hasFocus());
+ QTRY_VERIFY(edit->hasFocus());
delete model;
}
diff --git a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp
index 0311900..966e9c9 100644
--- a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp
@@ -49,6 +49,8 @@
#include <qtextbrowser.h>
#include <qtextobject.h>
+#include "../../shared/util.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -64,9 +66,11 @@ public:
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(this);
#endif
+ QApplication::setActiveWindow(this);
activateWindow();
setFocus();
- QTest::qWait(100);
+ QTest::qWait(50);
+ QTRY_VERIFY(hasFocus());
}
virtual QVariant loadResource(int type, const QUrl &name);
diff --git a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp
index 6f8dd2b..61f4456 100644
--- a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp
+++ b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp
@@ -772,7 +772,9 @@ void tst_QTextPieceTable::blockRemoval1()
QVERIFY(table->blocksFind(6).position() == 5);
QVERIFY(table->blocksFind(11).position() == 10);
+ table->beginEditBlock();
table->remove(5, 5);
+ table->endEditBlock();
QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(5).blockFormat() == fmt2);
QVERIFY(table->blocksFind(4).position() == 0);
@@ -864,7 +866,10 @@ void tst_QTextPieceTable::blockRemoval3()
QVERIFY(table->blocksFind(6).position() == 5);
QVERIFY(table->blocksFind(11).position() == 10);
+ table->beginEditBlock();
table->remove(3, 4);
+ table->endEditBlock();
+
QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(1).position() == 0);
@@ -958,7 +963,10 @@ void tst_QTextPieceTable::blockRemoval5()
QVERIFY(table->blocksFind(6).position() == 5);
QVERIFY(table->blocksFind(11).position() == 10);
+ table->beginEditBlock();
table->remove(3, 8);
+ table->endEditBlock();
+
QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat());
QVERIFY(table->blocksFind(1).position() == 0);
diff --git a/tests/auto/qtransformedscreen/qtransformedscreen.pro b/tests/auto/qtransformedscreen/qtransformedscreen.pro
index 39e3700..6914054 100644
--- a/tests/auto/qtransformedscreen/qtransformedscreen.pro
+++ b/tests/auto/qtransformedscreen/qtransformedscreen.pro
@@ -1,6 +1,5 @@
load(qttest_p4)
SOURCES += tst_qtransformedscreen.cpp
-QT = core
embedded:!contains(gfx-drivers, transformed) {
LIBS += ../../../plugins/gfxdrivers/libqgfxtransformed.so
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index fae4b26..f42d5f6 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -3354,7 +3354,7 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
o.count = 0;
tree.verticalScrollBar()->setValue(50);
QTest::qWait(100);
- QVERIFY(o.count > 0);
+ QTRY_VERIFY(o.count > 0);
}
void tst_QTreeView::task250683_wrongSectionSize()
@@ -3404,8 +3404,9 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden()
QStandardItem sub1("sub1"), sub11("sub11");
root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11);
- QTest::qWait(200);
+ QTest::qWait(20);
//items in the 2nd column should have been painted
+ QTRY_VERIFY(!delegate.paintedIndexes.isEmpty());
QVERIFY(delegate.paintedIndexes.contains(sub00.index()));
QVERIFY(delegate.paintedIndexes.contains(sub11.index()));
}
diff --git a/tests/auto/qwsembedwidget/qwsembedwidget.pro b/tests/auto/qwsembedwidget/qwsembedwidget.pro
index bd3c32c..c34212b 100644
--- a/tests/auto/qwsembedwidget/qwsembedwidget.pro
+++ b/tests/auto/qwsembedwidget/qwsembedwidget.pro
@@ -1,3 +1,2 @@
load(qttest_p4)
SOURCES += tst_qwsembedwidget.cpp
-QT = core
diff --git a/tests/auto/qwsinputmethod/qwsinputmethod.pro b/tests/auto/qwsinputmethod/qwsinputmethod.pro
index 69cce78..d549de0 100644
--- a/tests/auto/qwsinputmethod/qwsinputmethod.pro
+++ b/tests/auto/qwsinputmethod/qwsinputmethod.pro
@@ -1,3 +1,2 @@
load(qttest_p4)
SOURCES += tst_qwsinputmethod.cpp
-QT = core
diff --git a/tests/auto/qwswindowsystem/qwswindowsystem.pro b/tests/auto/qwswindowsystem/qwswindowsystem.pro
index 49466ee..ee33935 100644
--- a/tests/auto/qwswindowsystem/qwswindowsystem.pro
+++ b/tests/auto/qwswindowsystem/qwswindowsystem.pro
@@ -1,3 +1,2 @@
load(qttest_p4)
SOURCES += tst_qwswindowsystem.cpp
-QT = core