summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro3
-rw-r--r--tests/auto/bic/tst_bic.cpp19
-rw-r--r--tests/auto/collections/tst_collections.cpp38
-rw-r--r--tests/auto/compilerwarnings/tst_compilerwarnings.cpp2
-rw-r--r--tests/auto/mediaobject/tst_mediaobject.cpp20
-rw-r--r--tests/auto/moc/forgotten-qinterface.h2
-rw-r--r--tests/auto/moc/tst_moc.cpp84
-rw-r--r--tests/auto/q3accel/tst_q3accel.cpp86
-rw-r--r--tests/auto/q3cstring/tst_q3cstring.cpp86
-rw-r--r--tests/auto/q3header/tst_q3header.cpp4
-rw-r--r--tests/auto/q3ptrlist/tst_q3ptrlist.cpp13
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp20
-rw-r--r--tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp12
-rw-r--r--tests/auto/q3table/tst_q3table.cpp1
-rw-r--r--tests/auto/q3textedit/tst_q3textedit.cpp2
-rw-r--r--tests/auto/q3textstream/tst_q3textstream.cpp10
-rw-r--r--tests/auto/q3timeedit/tst_q3timeedit.cpp4
-rw-r--r--tests/auto/q3valuelist/tst_q3valuelist.cpp6
-rw-r--r--tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp5
-rw-r--r--tests/auto/qabstractitemview/tst_qabstractitemview.cpp68
-rw-r--r--tests/auto/qabstractslider/tst_qabstractslider.cpp4
-rw-r--r--tests/auto/qaccessibility/tst_qaccessibility.cpp525
-rw-r--r--tests/auto/qalgorithms/tst_qalgorithms.cpp8
-rw-r--r--tests/auto/qbitarray/tst_qbitarray.cpp163
-rw-r--r--tests/auto/qbuttongroup/tst_qbuttongroup.cpp19
-rw-r--r--tests/auto/qbytearraymatcher/qbytearraymatcher.pro4
-rw-r--r--tests/auto/qbytearraymatcher/tst_qbytearraymatcher.cpp124
-rw-r--r--tests/auto/qcache/tst_qcache.cpp14
-rw-r--r--tests/auto/qcheckbox/tst_qcheckbox.cpp6
-rw-r--r--tests/auto/qcolordialog/tst_qcolordialog.cpp2
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp84
-rw-r--r--tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp4
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp91
-rw-r--r--tests/auto/qcssparser/tst_cssparser.cpp10
-rw-r--r--tests/auto/qdatastream/tst_qdatastream.cpp4
-rw-r--r--tests/auto/qdate/tst_qdate.cpp21
-rw-r--r--tests/auto/qdatetime/tst_qdatetime.cpp15
-rw-r--r--tests/auto/qdesktopservices/tst_qdesktopservices.cpp5
-rw-r--r--tests/auto/qdialog/tst_qdialog.cpp21
-rw-r--r--tests/auto/qdir/tst_qdir.cpp4
-rw-r--r--tests/auto/qdirmodel/tst_qdirmodel.cpp2
-rw-r--r--tests/auto/qfile/rename-fallback.qrc5
-rw-r--r--tests/auto/qfile/test/test.pro2
-rw-r--r--tests/auto/qfile/tst_qfile.cpp78
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp179
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp41
-rw-r--r--tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp6
-rw-r--r--tests/auto/qfont/tst_qfont.cpp3
-rw-r--r--tests/auto/qfontdatabase/tst_qfontdatabase.cpp2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp236
-rw-r--r--tests/auto/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp6
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp21
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp31
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp66
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp64
-rw-r--r--tests/auto/qhash/tst_qhash.cpp23
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp24
-rw-r--r--tests/auto/qhttp/tst_qhttp.cpp2
-rw-r--r--tests/auto/qicoimageformat/tst_qticoimageformat.cpp35
-rw-r--r--tests/auto/qicon/tst_qicon.cpp2
-rw-r--r--tests/auto/qimage/tst_qimage.cpp5
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp27
-rw-r--r--tests/auto/qiodevice/tst_qiodevice.cpp6
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp1
-rw-r--r--tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp4
-rw-r--r--tests/auto/qitemmodel/modelstotest.cpp9
-rw-r--r--tests/auto/qitemview/tst_qitemview.cpp20
-rw-r--r--tests/auto/qkeysequence/tst_qkeysequence.cpp8
-rw-r--r--tests/auto/qlabel/tst_qlabel.cpp2
-rw-r--r--tests/auto/qlibrary/tst_qlibrary.cpp12
-rw-r--r--tests/auto/qline/tst_qline.cpp8
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp4
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp11
-rw-r--r--tests/auto/qlocalsocket/test/test.pro14
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp22
-rw-r--r--tests/auto/qmainwindow/tst_qmainwindow.cpp10
-rw-r--r--tests/auto/qmake/qmake.pro2
-rw-r--r--tests/auto/qmake/testcompiler.cpp305
-rw-r--r--tests/auto/qmake/testcompiler.h49
-rw-r--r--tests/auto/qmake/testdata/functions/functions.pro14
-rw-r--r--tests/auto/qmake/testdata/shadow_files_build/README2
-rw-r--r--tests/auto/qmake/tst_qmake.cpp34
-rw-r--r--tests/auto/qmap/tst_qmap.cpp10
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp34
-rw-r--r--tests/auto/qmenubar/tst_qmenubar.cpp37
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp4
-rw-r--r--tests/auto/qmetatype/tst_qmetatype.cpp2
-rw-r--r--tests/auto/qmovie/tst_qmovie.cpp5
-rw-r--r--tests/auto/qmutexlocker/tst_qmutexlocker.cpp4
-rw-r--r--tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp6
-rw-r--r--tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp295
-rw-r--r--tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp6
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp4
-rw-r--r--tests/auto/qobject/tst_qobject.cpp6
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp115
-rw-r--r--tests/auto/qpainterpath/tst_qpainterpath.cpp5
-rw-r--r--tests/auto/qpicture/tst_qpicture.cpp2
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp16
-rw-r--r--tests/auto/qprinter/tst_qprinter.cpp20
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp28
-rw-r--r--tests/auto/qpushbutton/tst_qpushbutton.cpp4
-rw-r--r--tests/auto/qreadlocker/tst_qreadlocker.cpp4
-rw-r--r--tests/auto/qrect/tst_qrect.cpp40
-rw-r--r--tests/auto/qregexp/tst_qregexp.cpp18
-rw-r--r--tests/auto/qregion/tst_qregion.cpp13
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp28
-rw-r--r--tests/auto/qset/tst_qset.cpp8
-rw-r--r--tests/auto/qsettings/tst_qsettings.cpp14
-rw-r--r--tests/auto/qsidebar/tst_qsidebar.cpp26
-rw-r--r--tests/auto/qsizef/tst_qsizef.cpp23
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp251
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h59
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp223
-rw-r--r--tests/auto/qsqldriver/qsqldriver.pro16
-rw-r--r--tests/auto/qsqldriver/tst_qsqldriver.cpp218
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp129
-rw-r--r--tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp12
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp455
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp174
-rw-r--r--tests/auto/qsqlthread/tst_qsqlthread.cpp12
-rw-r--r--tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp52
-rw-r--r--tests/auto/qstring/tst_qstring.cpp4
-rw-r--r--tests/auto/qstyle/tst_qstyle.cpp4
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp23
-rw-r--r--tests/auto/qsvgdevice/tst_qsvgdevice.cpp10
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp44
-rw-r--r--tests/auto/qsystemtrayicon/tst_qsystemtrayicon.cpp5
-rw-r--r--tests/auto/qtabbar/tst_qtabbar.cpp32
-rw-r--r--tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp31
-rw-r--r--tests/auto/qtextcodec/test/test.pro1
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp12
-rw-r--r--tests/auto/qtextcursor/tst_qtextcursor.cpp10
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp81
-rw-r--r--tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp17
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp3
-rw-r--r--tests/auto/qtextobject/tst_qtextobject.cpp19
-rw-r--r--tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp2
-rw-r--r--tests/auto/qtextstream/tst_qtextstream.cpp8
-rw-r--r--tests/auto/qthread/tst_qthread.cpp5
-rw-r--r--tests/auto/qtime/tst_qtime.cpp14
-rw-r--r--tests/auto/qtimeline/tst_qtimeline.cpp6
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp65
-rw-r--r--tests/auto/qtransform/tst_qtransform.cpp10
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp49
-rw-r--r--tests/auto/qtreewidget/tst_qtreewidget.cpp9
-rw-r--r--tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp14
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp4
-rw-r--r--tests/auto/qurl/tst_qurl.cpp8
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp4
-rw-r--r--tests/auto/qwaitcondition/tst_qwaitcondition.cpp18
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp37
-rw-r--r--tests/auto/qwmatrix/tst_qwmatrix.cpp17
-rw-r--r--tests/auto/qwritelocker/tst_qwritelocker.cpp4
-rw-r--r--tests/auto/rcc/tst_rcc.cpp15
-rw-r--r--tests/auto/selftests/alive/alive.pro1
-rw-r--r--tests/auto/selftests/assert/assert.pro1
-rw-r--r--tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro1
-rw-r--r--tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro1
-rw-r--r--tests/auto/selftests/benchliboptions/benchliboptions.pro1
-rw-r--r--tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro1
-rw-r--r--tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro1
-rw-r--r--tests/auto/selftests/cmptest/cmptest.pro1
-rw-r--r--tests/auto/selftests/commandlinedata/commandlinedata.pro1
-rw-r--r--tests/auto/selftests/crashes/crashes.pro1
-rw-r--r--tests/auto/selftests/datatable/datatable.pro1
-rw-r--r--tests/auto/selftests/datetime/datetime.pro1
-rw-r--r--tests/auto/selftests/differentexec/differentexec.pro1
-rw-r--r--tests/auto/selftests/exception/exception.pro1
-rw-r--r--tests/auto/selftests/expectfail/expectfail.pro1
-rw-r--r--tests/auto/selftests/failinit/failinit.pro1
-rw-r--r--tests/auto/selftests/failinitdata/failinitdata.pro1
-rw-r--r--tests/auto/selftests/fetchbogus/fetchbogus.pro1
-rw-r--r--tests/auto/selftests/globaldata/globaldata.pro1
-rw-r--r--tests/auto/selftests/maxwarnings/maxwarnings.pro1
-rw-r--r--tests/auto/selftests/multiexec/multiexec.pro1
-rw-r--r--tests/auto/selftests/qexecstringlist/qexecstringlist.pro1
-rw-r--r--tests/auto/selftests/singleskip/singleskip.pro1
-rw-r--r--tests/auto/selftests/skip/skip.pro1
-rw-r--r--tests/auto/selftests/skipglobal/skipglobal.pro1
-rw-r--r--tests/auto/selftests/skipinit/skipinit.pro1
-rw-r--r--tests/auto/selftests/skipinitdata/skipinitdata.pro1
-rw-r--r--tests/auto/selftests/sleep/sleep.pro1
-rw-r--r--tests/auto/selftests/strcmp/strcmp.pro1
-rw-r--r--tests/auto/selftests/subtest/subtest.pro1
-rw-r--r--tests/auto/selftests/tst_selftests.cpp4
-rwxr-xr-xtests/auto/selftests/updateBaselines.sh34
-rw-r--r--tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro1
-rw-r--r--tests/auto/selftests/warnings/warnings.pro1
188 files changed, 3721 insertions, 2322 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 173867587b..aa7c1167ed 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -408,8 +408,7 @@ SUBDIRS += checkxmlfiles \
xmlpatternsdiagnosticsts \
xmlpatternsview \
xmlpatternsxqts \
- xmlpatternsxslts \
- xmlpatterns
+ xmlpatternsxslts
xmlpatternsdiagnosticsts.depends = xmlpatternsxqts
xmlpatternsview.depends = xmlpatternsxqts
diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp
index e0f42f0acd..181c27587e 100644
--- a/tests/auto/bic/tst_bic.cpp
+++ b/tests/auto/bic/tst_bic.cpp
@@ -195,29 +195,10 @@ void tst_Bic::sizesAndVTables_data()
&& archFileName420.isEmpty())
QSKIP("No reference files found for this platform", SkipAll);
-#if QT_VERSION >= 0x040100
bool isPatchRelease400 = false;
-#else
- bool isPatchRelease400 = true;
-#endif
-
-#if QT_VERSION >= 0x040200
bool isPatchRelease410 = false;
-#else
- bool isPatchRelease410 = true;
-#endif
-
-#if QT_VERSION >= 0x040300
bool isPatchRelease420 = false;
-#else
- bool isPatchRelease420 = true;
-#endif
-
-#if QT_VERSION >= 0x040400
bool isPatchRelease430 = false;
-#else
- bool isPatchRelease430 = true;
-#endif
QTest::addColumn<QString>("oldLib");
QTest::addColumn<bool>("isPatchRelease");
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp
index 6d3d1dfc64..c05d8da276 100644
--- a/tests/auto/collections/tst_collections.cpp
+++ b/tests/auto/collections/tst_collections.cpp
@@ -161,9 +161,7 @@ private slots:
void q_init();
void pointersize();
void containerInstantiation();
-#if QT_VERSION >= 0x040101
void qtimerList();
-#endif
void containerTypedefs();
void forwardDeclared();
};
@@ -1907,11 +1905,9 @@ void tst_Collections::map()
i.toFront();
while(i.hasNext()) {
sum += i.next().value();
-#if QT_VERSION >= 0x040100
i.setValue(10);
i.value() += 22;
QVERIFY(i.value() == 32);
-#endif
}
QVERIFY(sum == 11);
}
@@ -2870,10 +2866,8 @@ void tst_Collections::javaStyleIterators()
while (i.hasPrevious()) {
i.previous();
QVERIFY(i.value().isEmpty());
-#if QT_VERSION >= 0x040100
i.value() = "x";
QCOMPARE(i.value(), QString("x"));
-#endif
}
}
@@ -3355,7 +3349,6 @@ void tst_Collections::containerInstantiation()
instantiateRandomAccess<Stack, EqualsComparable>();
}
-#if QT_VERSION >= 0x040101
void tst_Collections::qtimerList()
{
QList<double> foo;
@@ -3378,7 +3371,6 @@ void tst_Collections::qtimerList()
}
QFAIL("QList preallocates too much memory");
}
-#endif
template <typename Container>
void testContainerTypedefs(Container container)
@@ -3387,11 +3379,11 @@ void testContainerTypedefs(Container container)
{ typedef typename Container::value_type Foo; }
{ typedef typename Container::iterator Foo; }
{ typedef typename Container::const_iterator Foo; }
- { typedef typename Container::reference Foo; }
- { typedef typename Container::const_reference Foo; }
- { typedef typename Container::pointer Foo; }
- { typedef typename Container::difference_type Foo; }
- { typedef typename Container::size_type Foo; }
+ { typedef typename Container::reference Foo; }
+ { typedef typename Container::const_reference Foo; }
+ { typedef typename Container::pointer Foo; }
+ { typedef typename Container::difference_type Foo; }
+ { typedef typename Container::size_type Foo; }
}
template <typename Container>
@@ -3403,11 +3395,11 @@ void testPairAssociativeContainerTypedefs(Container container)
// { typedef typename Container::value_type Foo; }
// { typedef typename Container::const_iterator Foo; }
// { typedef typename Container::reference Foo; }
-// { typedef typename Container::const_reference Foo; }
-// { typedef typename Container::pointer Foo; }
+// { typedef typename Container::const_reference Foo; }
+// { typedef typename Container::pointer Foo; }
- { typedef typename Container::difference_type Foo; }
- { typedef typename Container::size_type Foo; }
+ { typedef typename Container::difference_type Foo; }
+ { typedef typename Container::size_type Foo; }
{ typedef typename Container::iterator Foo; }
{ typedef typename Container::key_type Foo; }
{ typedef typename Container::mapped_type Foo; }
@@ -3422,11 +3414,11 @@ void testSetContainerTypedefs(Container container)
Q_UNUSED(container)
{ typedef typename Container::iterator Foo; }
{ typedef typename Container::const_iterator Foo; }
- { typedef typename Container::reference Foo; }
- { typedef typename Container::const_reference Foo; }
- { typedef typename Container::pointer Foo; }
- { typedef typename Container::difference_type Foo; }
- { typedef typename Container::size_type Foo; }
+ { typedef typename Container::reference Foo; }
+ { typedef typename Container::const_reference Foo; }
+ { typedef typename Container::pointer Foo; }
+ { typedef typename Container::difference_type Foo; }
+ { typedef typename Container::size_type Foo; }
{ typedef typename Container::key_type Foo; }
}
@@ -3450,7 +3442,7 @@ void tst_Collections::containerTypedefs()
}
#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
-class Key1
+class Key1
{};
class T1
{};
diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
index 232af553f1..1f5f479507 100644
--- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
+++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
@@ -173,9 +173,7 @@ void tst_CompilerWarnings::warnings()
<< "-Wno-long-long" << "-Wshadow" << "-Wpacked" << "-Wunreachable-code"
<< "-Wundef" << "-Wchar-subscripts" << "-Wformat-nonliteral" << "-Wformat-security"
<< "-Wcast-align"
-#if QT_VERSION >= 0x040100
<< "-Wfloat-equal"
-#endif
<< "-o" << tmpFile
<< tmpSourceFile;
#elif defined(Q_CC_XLC)
diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp
index 96589b7e10..1b113b2c9f 100644
--- a/tests/auto/mediaobject/tst_mediaobject.cpp
+++ b/tests/auto/mediaobject/tst_mediaobject.cpp
@@ -349,6 +349,18 @@ void tst_MediaObject::_pausePlayback()
void tst_MediaObject::initTestCase()
{
QCoreApplication::setApplicationName("tst_MediaObject");
+ m_stateChangedSignalSpy = 0;
+ m_media = 0;
+
+#ifdef Q_OS_WINCE
+ QString pluginsPath = QLibraryInfo::location(QLibraryInfo::PluginsPath);
+#ifdef DEBUG
+ QVERIFY(QFile::exists(pluginsPath + "/phonon_backend/phonon_waveoutd4.dll") || QFile::exists(pluginsPath + "/phonon_backend/phonon_phonon_ds9d4.dll"));
+#else
+ QVERIFY(QFile::exists(pluginsPath + "/phonon_backend/phonon_waveout4.dll") || QFile::exists(pluginsPath + "/phonon_backend/phonon_phonon_ds94.dll"));
+#endif
+#endif
+
m_url = qgetenv("PHONON_TESTURL");
m_media = new MediaObject(this);
@@ -787,7 +799,7 @@ void tst_MediaObject::setMediaAndPlay()
QSignalSpy totalTimeChangedSignalSpy(m_media, SIGNAL(totalTimeChanged(qint64)));
QVERIFY(m_media->currentSource().type() != MediaSource::Invalid);
Phonon::State state = m_media->state();
- QVERIFY(state == Phonon::StoppedState || state == Phonon::PlayingState);
+ QVERIFY(state == Phonon::StoppedState || state == Phonon::PlayingState || Phonon::PausedState);
m_media->setCurrentSource(m_url);
// before calling play() we better make sure that if play() finishes very fast that we don't get
// called again
@@ -856,8 +868,10 @@ void tst_MediaObject::testPlayBeforeFinish()
void tst_MediaObject::cleanupTestCase()
{
- delete m_stateChangedSignalSpy;
- delete m_media;
+ if (m_stateChangedSignalSpy)
+ delete m_stateChangedSignalSpy;
+ if (m_media)
+ delete m_media;
#ifdef Q_OS_WINCE
QTest::qWait(200);
#endif
diff --git a/tests/auto/moc/forgotten-qinterface.h b/tests/auto/moc/forgotten-qinterface.h
index a11793bbe0..370a3d0e2c 100644
--- a/tests/auto/moc/forgotten-qinterface.h
+++ b/tests/auto/moc/forgotten-qinterface.h
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include <QObject>
+
struct MyInterface
{
virtual ~MyInterface() {}
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index 39f4f23812..afb31f6b14 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -151,7 +151,6 @@ public slots:
Q_DECLARE_METATYPE(MyStruct)
Q_DECLARE_METATYPE(MyStruct*)
-#if QT_VERSION >= 0x040200
namespace myNS {
struct Points
{
@@ -161,7 +160,6 @@ namespace myNS {
}
Q_DECLARE_METATYPE(myNS::Points)
-#endif
class TestClassinfoWithEscapes: public QObject
{
@@ -195,10 +193,7 @@ class TestClass : public MyNamespace::TestSuperClass, public DONT_CONFUSE_MOC(My
public DONT_CONFUSE_MOC_EVEN_MORE(MyStruct2, dummy, ignored)
{
Q_OBJECT
-#if QT_VERSION >= 0x040101
Q_CLASSINFO("help", QT_TR_NOOP("Opening this will let you configure something"))
-#endif
-#if QT_VERSION >= 0x040102
Q_PROPERTY(short int shortIntProperty READ shortIntProperty)
Q_PROPERTY(unsigned short int unsignedShortIntProperty READ unsignedShortIntProperty)
Q_PROPERTY(signed short int signedShortIntProperty READ signedShortIntProperty)
@@ -206,10 +201,7 @@ class TestClass : public MyNamespace::TestSuperClass, public DONT_CONFUSE_MOC(My
Q_PROPERTY(unsigned long int unsignedLongIntProperty READ unsignedLongIntProperty)
Q_PROPERTY(signed long int signedLongIntProperty READ signedLongIntProperty)
Q_PROPERTY(long double longDoubleProperty READ longDoubleProperty)
-#endif
-#if QT_VERSION >= 0x040200
Q_PROPERTY(myNS::Points points READ points WRITE setPoints)
-#endif
Q_CLASSINFO("Multi"
"line",
@@ -294,9 +286,7 @@ private slots:
#ifndef NOLONGLONG
void slotWithULongLong(unsigned long long) {}
-#if QT_VERSION >= 0x040101
void slotWithULongLongP(unsigned long long*) {}
-#endif
void slotWithULong(unsigned long) {}
void slotWithLongLong(long long) {}
void slotWithLong(long) {}
@@ -304,9 +294,7 @@ private slots:
void slotWithColonColonType(::Int::Type) {}
-#if QT_VERSION >= 0x040101
TestClass &slotWithReferenceReturnType() { return *this; }
-#endif
#if (0 && 1) || 1
void expressionEvaluationShortcut1() {}
@@ -321,7 +309,6 @@ public slots:
void slotWithNamedArray(const double namedArray[3]) {}
void slotWithMultiArray(const double[3][4]) {}
-#if QT_VERSION >= 0x040102
short int shortIntProperty() { return 0; }
unsigned short int unsignedShortIntProperty() { return 0; }
signed short int signedShortIntProperty() { return 0; }
@@ -329,12 +316,9 @@ public slots:
unsigned long int unsignedLongIntProperty() { return 0; }
signed long int signedLongIntProperty() { return 0; }
long double longDoubleProperty() { return 0.0; }
-#endif
-#if QT_VERSION >= 0x040200
myNS::Points points() { return m_points; }
void setPoints(myNS::Points points) { m_points = points; }
-#endif
signals:
void signalWithArray(const double[3]);
@@ -384,10 +368,8 @@ public:
public slots:
void slotWithVoidStar(void *) {}
-#if QT_VERSION >= 0x040200
private:
myNS::Points m_points;
-#endif
private slots:
inline virtual void blub1() {}
@@ -466,6 +448,8 @@ public:
inline tst_Moc() {}
private slots:
+ void initTestCase();
+
void slotWithException() throw(MyStruct);
void dontStripNamespaces();
void oldStyleCasts();
@@ -519,8 +503,28 @@ private:
bool user2() { return false; };
bool user3() { return false; };
bool userFunction(){ return false; };
+
+private:
+ QString qtIncludePath;
};
+void tst_Moc::initTestCase()
+{
+#if defined(Q_OS_UNIX)
+ QProcess proc;
+ proc.start("qmake", QStringList() << "-query" << "QT_INSTALL_HEADERS");
+ QVERIFY(proc.waitForFinished());
+ QCOMPARE(proc.exitCode(), 0);
+ QByteArray output = proc.readAllStandardOutput();
+ QVERIFY(!output.isEmpty());
+ QCOMPARE(proc.readAllStandardError(), QByteArray());
+ qtIncludePath = QString::fromLocal8Bit(output).trimmed();
+ QFileInfo fi(qtIncludePath);
+ QVERIFY(fi.exists());
+ QVERIFY(fi.isDir());
+#endif
+}
+
void tst_Moc::slotWithException() throw(MyStruct)
{
// be happy
@@ -552,8 +556,6 @@ void tst_Moc::oldStyleCasts()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
proc.start("moc", QStringList(srcify("/oldstyle-casts.h")));
QVERIFY(proc.waitForFinished());
@@ -564,7 +566,7 @@ void tst_Moc::oldStyleCasts()
QStringList args;
args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
- << "-I" << qgetenv("QTDIR") + "/include" << "-o" << "/dev/null" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -584,8 +586,6 @@ void tst_Moc::warnOnExtraSignalSlotQualifiaction()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
proc.start("moc", QStringList(srcify("extraqualification.h")));
QVERIFY(proc.waitForFinished());
@@ -610,10 +610,8 @@ void tst_Moc::uLongLong()
QVERIFY(idx != -1);
idx = mobj->indexOfSlot("slotWithULongLong(unsigned long long)");
QVERIFY(idx != -1);
-#if QT_VERSION >= 0x040101
idx = mobj->indexOfSlot("slotWithULongLongP(unsigned long long*)");
QVERIFY(idx != -1);
-#endif
idx = mobj->indexOfSlot("slotWithLong(long)");
QVERIFY(idx != -1);
@@ -630,8 +628,6 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
proc.setWorkingDirectory(QString(SRCDIR) + "/task71021");
proc.start("moc", QStringList("../Header"));
@@ -643,7 +639,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
QStringList args;
args << "-c" << "-x" << "c++" << "-I" << ".."
- << "-I" << qgetenv("QTDIR") + "/include" << "-o" << "/dev/null" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -691,22 +687,14 @@ void tst_Moc::supportConstSignals()
void tst_Moc::task87883()
{
-#if QT_VERSION >= 0x040101
QVERIFY(Task87883::staticMetaObject.className());
-#else
- QSKIP("Fixed in >= 4.1.1", SkipAll);
-#endif
}
#include "c-comments.h"
void tst_Moc::multilineComments()
{
-#if QT_VERSION >= 0x040101
QVERIFY(IfdefedClass::staticMetaObject.className());
-#else
- QSKIP("Fixed in >= 4.1.1", SkipAll);
-#endif
}
void tst_Moc::classinfoWithEscapes()
@@ -848,10 +836,11 @@ void tst_Moc::warnOnMultipleInheritance()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
- proc.start("moc", QStringList(srcify("warn-on-multiple-qobject-subclasses.h")));
+ QStringList args;
+ args << "-I" << qtIncludePath + "/QtGui"
+ << srcify("warn-on-multiple-qobject-subclasses.h");
+ proc.start("moc", args);
QVERIFY(proc.waitForFinished());
QCOMPARE(proc.exitCode(), 0);
QByteArray mocOut = proc.readAllStandardOutput();
@@ -870,17 +859,18 @@ void tst_Moc::forgottenQInterface()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
- proc.start("moc", QStringList(srcify("forgotten-qinterface.h")));
+ QStringList args;
+ args << "-I" << qtIncludePath + "/QtCore"
+ << srcify("forgotten-qinterface.h");
+ proc.start("moc", args);
QVERIFY(proc.waitForFinished());
QCOMPARE(proc.exitCode(), 0);
QByteArray mocOut = proc.readAllStandardOutput();
QVERIFY(!mocOut.isEmpty());
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
QCOMPARE(mocWarning, QString(SRCDIR) +
- QString("/forgotten-qinterface.h:53: Warning: Class Test implements the interface MyInterface but does not list it in Q_INTERFACES. qobject_cast to MyInterface will not work!\n"));
+ QString("/forgotten-qinterface.h:55: Warning: Class Test implements the interface MyInterface but does not list it in Q_INTERFACES. qobject_cast to MyInterface will not work!\n"));
#else
QSKIP("Only tested on linux/gcc", SkipAll);
#endif
@@ -951,8 +941,6 @@ void tst_Moc::frameworkSearchPath()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_UNIX)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QStringList args;
args << "-F" << srcify(".")
<< srcify("interface-from-framework.h")
@@ -991,8 +979,6 @@ void tst_Moc::templateGtGt()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
proc.start("moc", QStringList(srcify("template-gtgt.h")));
QVERIFY(proc.waitForFinished());
@@ -1009,8 +995,6 @@ void tst_Moc::templateGtGt()
void tst_Moc::defineMacroViaCmdline()
{
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
QStringList args;
@@ -1099,8 +1083,6 @@ void tst_Moc::warnOnPropertyWithoutREAD()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
proc.start("moc", QStringList(srcify("warn-on-property-without-read.h")));
QVERIFY(proc.waitForFinished());
diff --git a/tests/auto/q3accel/tst_q3accel.cpp b/tests/auto/q3accel/tst_q3accel.cpp
index c2ba9dd2fd..7b1c8aee77 100644
--- a/tests/auto/q3accel/tst_q3accel.cpp
+++ b/tests/auto/q3accel/tst_q3accel.cpp
@@ -142,10 +142,8 @@ void tst_Q3Accel::initTestCase()
edit->setObjectName("test_edit");
connect( accel1, SIGNAL(activated(int)), this, SLOT(accelTrig1()) );
connect( accel2, SIGNAL(activated(int)), this, SLOT(accelTrig2()) );
-#if QT_VERSION >= 0x30100
connect( accel1, SIGNAL(activatedAmbiguously(int)), this, SLOT(ambig1()) );
connect( accel2, SIGNAL(activatedAmbiguously(int)), this, SLOT(ambig2()) );
-#endif
mainW->setCentralWidget( edit );
connect( mainW->statusBar(), SIGNAL(messageChanged(const QString&)),
this, SLOT(statusMessage(const QString&)) );
@@ -160,11 +158,9 @@ int tst_Q3Accel::toButtons( int key )
result |= Qt::ShiftModifier;
if ( key & Qt::CTRL )
result |= Qt::ControlModifier;
-#if QT_VERSION >= 0x30100
- if ( key & Qt::META )
+ if ( key & Qt::META )
result |= Qt::MetaModifier;
-#endif
- if ( key & Qt::ALT )
+ if ( key & Qt::ALT )
result |= Qt::AltModifier;
return result;
}
@@ -185,7 +181,6 @@ void tst_Q3Accel::defElements()
QTest::addColumn<int>("theResult");
}
-#if QT_VERSION >= 0x30100
void tst_Q3Accel::number()
{
testElement();
@@ -369,34 +364,17 @@ void tst_Q3Accel::number_data()
int(Qt::Key_Aring)
UNICODE_ACCEL + int(Qt::Key_K)
*/
- /* The #ifdefs for Qt4 are there, because accelerators are always case insensitive in Qt4.
- It was not wise to differentiate between ASCII (where accelerators where case insensitive) and all other
- unicode chars in 3.x.
- */
QTest::newRow( "N06 - sA1" ) << int(SetupAccel) << int(Accel1) << QString("")
<< int(Qt::Key_aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(NoResult);
-#if QT_VERSION < 0x040000
- QTest::newRow( "N07 - sA2" ) << int(SetupAccel) << int(Accel2) << QString("")
- << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(NoResult);
-#endif
QTest::newRow( "N08 - sA2" ) << int(SetupAccel) << int(Accel1) << QString("")
<< int(Qt::UNICODE_ACCEL) + int(Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(NoResult);
QTest::newRow( "N:int(Qt::Key_aring)" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::Key_aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
-#if QT_VERSION < 0x040000
- QTest::newRow( "N:int(Qt::Key_Aring)" ) << int(TestAccel) << int(NoWidget) << QString("")
- << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel2Triggered);
-#endif
QTest::newRow( "N:int(Qt::Key_aring) - Text Form" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::Key_unknown) << 0xE5 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
-#if QT_VERSION < 0x040000
- QTest::newRow( "N:int(Qt::Key_Aring) - Text Form" ) << int(TestAccel) << int(NoWidget) << QString("")
- << int(Qt::Key_unknown) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel2Triggered);
-#else
QTest::newRow( "N:int(Qt::Key_Aring) - Text Form" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::Key_unknown) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
-#endif
QTest::newRow( "N:UNICODE_ACCEL + int(Qt::Key_K)" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::UNICODE_ACCEL) + int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
@@ -615,28 +593,15 @@ void tst_Q3Accel::text_data()
/* see comments above on the #ifdef'ery */
QTest::newRow( "T06 - sA1" ) << int(SetupAccel) << int(Accel1) << QString("\x0E5")
<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(NoResult);
-#if QT_VERSION < 0x040000
- QTest::newRow( "T07 - sA2" ) << int(SetupAccel) << int(Accel2) << QString("\x0C5")
- << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(NoResult);
-#endif
QTest::newRow( "T08 - sA2" ) << int(SetupAccel) << int(Accel1) << QString("K")
<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(NoResult);
QTest::newRow( "T:int(Qt::Key_aring)" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::Key_aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
-#if QT_VERSION < 0x040000
- QTest::newRow( "T:int(Qt::Key_Aring)" ) << int(TestAccel) << int(NoWidget) << QString("")
- << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel2Triggered);
-#endif
QTest::newRow( "T:int(Qt::Key_aring) - Text Form" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::Key_unknown) << 0xE5 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
-#if QT_VERSION < 0x040000
- QTest::newRow( "T:int(Qt::Key_Aring) - Text Form" ) << int(TestAccel) << int(NoWidget) << QString("")
- << int(Qt::Key_unknown) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel2Triggered);
-#else
QTest::newRow( "T:int(Qt::Key_Aring) - Text Form" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::Key_unknown) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
-#endif
QTest::newRow( "T:UNICODE_ACCEL + int(Qt::Key_K)" ) << int(TestAccel) << int(NoWidget) << QString("")
<< int(Qt::UNICODE_ACCEL) + int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << int(Accel1Triggered);
@@ -986,11 +951,7 @@ void tst_Q3Accel::sendKeyEvents( int k1, QChar c1, int k2, QChar c2, int k3, QCh
k2 &= ~Qt::MODIFIER_MASK;
k3 &= ~Qt::MODIFIER_MASK;
k4 &= ~Qt::MODIFIER_MASK;
-#if QT_VERSION < 0x040000
- QKeyEvent ke( QEvent::Accel, k1, k1, b1, QString(c1) );
-#else
QKeyEvent ke( QEvent::Accel, k1, (Qt::KeyboardModifiers)b1, QString(c1) );
-#endif
QApplication::sendEvent( mainW, &ke );
if ( k2 ) {
QKeyEvent ke( QEvent::Accel, k2, k2, b2, QString(c2) );
@@ -1006,48 +967,5 @@ void tst_Q3Accel::sendKeyEvents( int k1, QChar c1, int k2, QChar c2, int k3, QCh
}
}
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-
-#else // For Qt < 3.1
-void tst_Q3Accel::number_data()
-{
- QTest::addColumn<int>("bogus");
- QTest::newRow( "b01" ) << 0;
-}
-
-void tst_Q3Accel::number()
-{
- QSKIP( "Accel test for Qt < 3.1 not implemented", SkipAll);
-}
-
-void tst_Q3Accel::text_data()
-{
- QTest::addColumn<int>("bogus");
- QTest::newRow( "b02" ) << 0;
-}
-
-void tst_Q3Accel::text()
-{
- QSKIP( "Accel test for Qt < 3.1 not implemented", SkipAll);
-}
-void tst_Q3Accel::disabledItems()
-{
- QSKIP( "Accel test for Qt < 3.1 not implemented", SkipAll);
-}
-void tst_Q3Accel::ambiguousItems()
-{
- QSKIP( "Amibguous signals non-existant in Qt < 3.1", SkipAll);
-}
-void tst_Q3Accel::unicodeCompare()
-{
- QSKIP( "Accel test for Qt < 3.1 not implemented", SkipAll);
-}
-void tst_Q3Accel::unicodeCompose()
-{
- QSKIP( "Unicode composing non-existant in Qt < 3.1", SkipAll);
-}
-#endif // QT_VERSION >= 0x30100
-
QTEST_MAIN(tst_Q3Accel)
#include "tst_q3accel.moc"
diff --git a/tests/auto/q3cstring/tst_q3cstring.cpp b/tests/auto/q3cstring/tst_q3cstring.cpp
index f9bdf6bc2a..60a66a9a65 100644
--- a/tests/auto/q3cstring/tst_q3cstring.cpp
+++ b/tests/auto/q3cstring/tst_q3cstring.cpp
@@ -69,8 +69,6 @@ private slots:
void replace_uint_uint();
void replace_string_data();
void replace_string();
- void replace_regexp_data();
- void replace_regexp();
void remove_uint_uint_data();
void remove_uint_uint();
void prepend();
@@ -132,11 +130,6 @@ void tst_Q3CString::remove_string_data()
replace_string_data();
}
-void tst_Q3CString::remove_regexp_data()
-{
- replace_regexp_data();
-}
-
void tst_Q3CString::length_data()
{
QTest::addColumn<Q3CString>("s1");
@@ -202,9 +195,6 @@ void tst_Q3CString::replace_string_data()
QTest::newRow( "rem13" ) << Q3CString("") << Q3CString("A") << Q3CString(0) << Q3CString("");
QTest::newRow( "rem14" ) << Q3CString(0) << Q3CString("A") << Q3CString("") << Q3CString(0);
QTest::newRow( "rem15" ) << Q3CString(0) << Q3CString("A") << Q3CString(0) << Q3CString(0);
-#if QT_VERSION < 0x040000
- QTest::newRow( "rem16" ) << Q3CString(0) << Q3CString("") << Q3CString("A") << Q3CString(0);
-#endif
QTest::newRow( "rem17" ) << Q3CString(0) << Q3CString("") << Q3CString("") << Q3CString(0);
// ### how should the one below behave in Q3CString????
// QTest::newRow( "rem18" ) << Q3CString("") << Q3CString(0) << Q3CString("A") << Q3CString("A");
@@ -216,7 +206,7 @@ void tst_Q3CString::replace_string_data()
QTest::newRow( "rep03" ) << Q3CString("") << Q3CString("") << Q3CString("X") << Q3CString("X");
}
-void tst_Q3CString::replace_regexp_data()
+void tst_Q3CString::remove_regexp_data()
{
QTest::addColumn<Q3CString>("string");
QTest::addColumn<Q3CString>("regexp");
@@ -224,20 +214,16 @@ void tst_Q3CString::replace_regexp_data()
QTest::addColumn<Q3CString>("result");
QTest::newRow( "rem00" ) << Q3CString("alpha") << Q3CString("a+") << Q3CString("") << Q3CString("lph");
-#if QT_VERSION >= 0x030100
QTest::newRow( "rem01" ) << Q3CString("banana") << Q3CString("^.a") << Q3CString("") << Q3CString("nana");
-#endif
QTest::newRow( "rem02" ) << Q3CString("") << Q3CString("^.a") << Q3CString("") << Q3CString("");
QTest::newRow( "rem03" ) << Q3CString("") << Q3CString("^.a") << Q3CString(0) << Q3CString("");
QTest::newRow( "rem04" ) << Q3CString(0) << Q3CString("^.a") << Q3CString("") << Q3CString(0);
QTest::newRow( "rem05" ) << Q3CString(0) << Q3CString("^.a") << Q3CString(0) << Q3CString(0);
-#if QT_VERSION >= 0x030100
QTest::newRow( "rep00" ) << Q3CString("A <i>bon mot</i>.") << Q3CString("<i>([^<]*)</i>") << Q3CString("\\emph{\\1}") << Q3CString("A \\emph{bon mot}.");
QTest::newRow( "rep01" ) << Q3CString("banana") << Q3CString("^.a()") << Q3CString("\\1") << Q3CString("nana");
QTest::newRow( "rep02" ) << Q3CString("banana") << Q3CString("(ba)") << Q3CString("\\1X\\1") << Q3CString("baXbanana");
QTest::newRow( "rep03" ) << Q3CString("banana") << Q3CString("(ba)(na)na") << Q3CString("\\2X\\1") << Q3CString("naXba");
-#endif
}
void tst_Q3CString::length()
@@ -364,11 +350,7 @@ void tst_Q3CString::acc_01()
QCOMPARE('X'+a,(Q3CString)"XABC");
a = (const char*)0;
QVERIFY(a.isNull());
-#if QT_VERSION < 0x040000
- QVERIFY((const char*)a==0);
-#else
QVERIFY(*((const char *)a) == 0);
-#endif
{
QFile f("COMPARE.txt");
@@ -420,11 +402,7 @@ void tst_Q3CString::constructor()
QCOMPARE(a,ca);
QVERIFY(a.isNull());
-#if QT_VERSION < 0x040000
- QVERIFY(a != (Q3CString)"");
-#else
QVERIFY(a == Q3CString(""));
-#endif
QCOMPARE(b,cb);
QCOMPARE(c,cc);
QCOMPARE(d,(Q3CString)"String D");
@@ -509,18 +487,6 @@ void tst_Q3CString::find()
//QCOMPARE(a.find('G',-1),14); // -ve does what? Parameter should be uint?
//QCOMPARE(a.find('G',-2),11); // -ve does what? Parameter should be uint?
QCOMPARE(a.find('f'),10);
-#if QT_VERSION < 0x040000
- // case sensitive find has been removed in 4.0
- QCOMPARE(a.find('f',0,FALSE),5);
- QCOMPARE(a.find('g',0,TRUE),-1);
- QCOMPARE(a.find("fgh",0,FALSE),5);
- QCOMPARE(a.find("fgh",0,TRUE),-1);
- QCOMPARE(a.find("EFG",5,TRUE),12);
- QCOMPARE(a.find("EFG",5,FALSE),9);
- QCOMPARE(a.find("EFG",4,TRUE),4);
- QCOMPARE(a.find("EfG",4,FALSE),4);
- QCOMPARE(a.find("EfG",4,TRUE),9);
-#endif
// QCOMPARE(a.find("efg",-1,FALSE),12); // -ve does what? Parameter should be uint?
// QCOMPARE(a.find("efg",-2,FALSE),12); // -ve does what? Parameter should be uint?
// QCOMPARE(a.find("efg",-3,FALSE),12); // -ve does what? Parameter should be uint?
@@ -544,14 +510,6 @@ void tst_Q3CString::findRev()
QCOMPARE(a.findRev('B'),1);
QCOMPARE(a.findRev('B',1),1);
QCOMPARE(a.findRev('B',0),-1);
-#if QT_VERSION < 0x040000
- QCOMPARE(a.findRev("efg",99,FALSE),-1);
-// QCOMPARE(a.findRev("efg",15,FALSE),-1);
- QCOMPARE(a.findRev("efg",16,FALSE),-1);
- QCOMPARE(a.findRev("efg",14,FALSE),12);
- QCOMPARE(a.findRev("efg",12,FALSE),12);
- QCOMPARE(a.findRev("efg",11,FALSE),9);
-#endif
// QCOMPARE(a.findRev(QRegExp("[EFG][EFG]"),14),13);
// QCOMPARE(a.findRev(QRegExp("[EFG][EFG]"),11),11);
}
@@ -560,15 +518,6 @@ void tst_Q3CString::contains()
{
Q3CString a;
a="ABCDEFGHIEfGEFG"; // 15 chars
-#if QT_VERSION < 0x040000
- QCOMPARE(a.contains('A'),1);
- QCOMPARE(a.contains('Z'),0);
- QCOMPARE(a.contains('E'),3);
- QCOMPARE(a.contains('F'),2);
- QCOMPARE(a.contains('F',FALSE),3);
- QCOMPARE(a.contains("FG"),2);
- QCOMPARE(a.contains("FG",FALSE),3);
-#else
QVERIFY(a.contains('A'));
QVERIFY(!a.contains('Z'));
QVERIFY(a.contains('E'));
@@ -579,7 +528,6 @@ void tst_Q3CString::contains()
QCOMPARE(a.count('E'),3);
QCOMPARE(a.count('F'),2);
QCOMPARE(a.count("FG"),2);
-#endif
// QCOMPARE(a.contains(QRegExp("[FG][HI]")),1);
// QCOMPARE(a.contains(QRegExp("[G][HE]")),2);
}
@@ -771,7 +719,6 @@ void tst_Q3CString::replace_uint_uint()
void tst_Q3CString::replace_string()
{
-#if QT_VERSION >= 0x030100
QFETCH( Q3CString, string );
QFETCH( Q3CString, before );
QFETCH( Q3CString, after );
@@ -788,37 +735,6 @@ void tst_Q3CString::replace_string()
Q3CString s3 = string;
s3.replace( before, after );
QCOMPARE( s3, result );
-
-#if QT_VERSION < 0x040000
- if ( !string.isNull() ) {
- /*
- I've changed the isNull() behavior in QString::replace() in
- Qt 3.2, according to the philosophy that null and empty
- should behave mostly the same.
- */
- Q3CString s4 = string;
- s4.replace( QRegExp(QRegExp::escape(before)), after );
- QVERIFY( s4 == result );
- }
-#endif
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-#endif
-}
-
-void tst_Q3CString::replace_regexp()
-{
-#if QT_VERSION >= 0x040000
- QSKIP("This functionality has been removed in Qt 4.", SkipAll);
-#else
- QFETCH( Q3CString, string );
- QFETCH( Q3CString, regexp );
- QFETCH( Q3CString, after );
- QFETCH( Q3CString, result );
-
- string.replace( QRegExp(regexp), after );
- QVERIFY( string == result );
-#endif
}
void tst_Q3CString::remove_uint_uint()
diff --git a/tests/auto/q3header/tst_q3header.cpp b/tests/auto/q3header/tst_q3header.cpp
index f0ad9d410a..fe290e8c43 100644
--- a/tests/auto/q3header/tst_q3header.cpp
+++ b/tests/auto/q3header/tst_q3header.cpp
@@ -59,9 +59,7 @@ public slots:
void cleanupTestCase();
private slots:
void bug_setOffset();
-#if QT_VERSION >= 0x040101
void nullStringLabel();
-#endif
private:
Q3Header *testW;
@@ -108,7 +106,6 @@ void tst_Q3Header::bug_setOffset()
QCOMPARE( testW->offset(), offs );
}
-#if QT_VERSION >= 0x040101
// Task 95640
void tst_Q3Header::nullStringLabel()
{
@@ -123,7 +120,6 @@ void tst_Q3Header::nullStringLabel()
QCOMPARE(testW->label(testW->addLabel(QString())), QString());
QCOMPARE(testW->label(testW->addLabel(QString(""))), QString(""));
}
-#endif
QTEST_MAIN(tst_Q3Header)
#include "tst_q3header.moc"
diff --git a/tests/auto/q3ptrlist/tst_q3ptrlist.cpp b/tests/auto/q3ptrlist/tst_q3ptrlist.cpp
index 49b5a3ed9d..c3d8b16eb7 100644
--- a/tests/auto/q3ptrlist/tst_q3ptrlist.cpp
+++ b/tests/auto/q3ptrlist/tst_q3ptrlist.cpp
@@ -92,7 +92,6 @@ void tst_Q3PtrList::cleanup()
void tst_Q3PtrList::replace()
{
-#if QT_VERSION >= 0x030100
Q3PtrList<int> list;
int foo = 4;
list.setAutoDelete( TRUE );
@@ -110,15 +109,10 @@ void tst_Q3PtrList::replace()
int *p = new int(7);
QCOMPARE( list.insert(2, p), (bool)TRUE );
QCOMPARE( list.replace(2, p), (bool)TRUE );
-
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-#endif
}
void tst_Q3PtrList::replaceStrDeep()
{
-#if QT_VERSION >= 0x030100
Q3StrList list;
const char *str;
@@ -137,14 +131,10 @@ void tst_Q3PtrList::replaceStrDeep()
QCOMPARE( list.insert(2, str), (bool)TRUE );
QCOMPARE( list.replace(2, str), (bool)TRUE );
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-#endif
}
void tst_Q3PtrList::replaceStrShallow()
{
-#if QT_VERSION >= 0x030100
Q3StrList list( FALSE );
char str1[] = "This is string 1";
char str2[] = "This is string 2";
@@ -166,9 +156,6 @@ void tst_Q3PtrList::replaceStrShallow()
QCOMPARE( list.insert(2, str), (bool)TRUE );
QCOMPARE( list.replace(2, str), (bool)TRUE );
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-#endif
}
void tst_Q3PtrList::take()
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index c06485d36c..2d9118642b 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -89,7 +89,7 @@ private slots:
void unicode();
void precision_data() { generic_data(); }
void precision();
- void insertORA_data();
+ void insertORA_data() { generic_data("QOCI"); }
void insertORA();
void batchInsert_data() { generic_data(); }
void batchInsert();
@@ -101,7 +101,7 @@ private slots:
void insertFieldNameContainsWS(); // For task 117996
private:
- void generic_data();
+ void generic_data(const QString &engine=QString());
void createTestTables( QSqlDatabase db );
void dropTestTables( QSqlDatabase db );
void populateTestTables( QSqlDatabase db );
@@ -117,10 +117,14 @@ tst_Q3SqlCursor::~tst_Q3SqlCursor()
{
}
-void tst_Q3SqlCursor::generic_data()
+void tst_Q3SqlCursor::generic_data(const QString &engine)
{
- if ( dbs.fillTestTable() == 0 )
- QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ if ( dbs.fillTestTable(engine) == 0 ) {
+ if(engine.isEmpty())
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ else
+ QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
+ }
}
void tst_Q3SqlCursor::createTestTables( QSqlDatabase db )
@@ -429,12 +433,6 @@ static QString dumpUtf8( const QString& str )
return res;
}
-void tst_Q3SqlCursor::insertORA_data()
-{
- if ( dbs.fillTestTable( "QOCI" ) == 0 )
- QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll );
-}
-
void tst_Q3SqlCursor::insertORA()
{
QFETCH( QString, dbName );
diff --git a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
index a8c59400f1..9ab74f039e 100644
--- a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
+++ b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp
@@ -76,7 +76,7 @@ private slots:
void _exec();
private:
- void generic_data();
+ void generic_data(const QString &engine=QString());
void createTestTables( QSqlDatabase db );
void dropTestTables( QSqlDatabase db );
void populateTestTables( QSqlDatabase db );
@@ -92,10 +92,14 @@ tst_Q3SqlSelectCursor::~tst_Q3SqlSelectCursor()
{
}
-void tst_Q3SqlSelectCursor::generic_data()
+void tst_Q3SqlSelectCursor::generic_data(const QString& engine)
{
- if ( dbs.fillTestTable() == 0 )
- QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ if ( dbs.fillTestTable(engine) == 0 ) {
+ if(engine.isEmpty())
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ else
+ QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
+ }
}
void tst_Q3SqlSelectCursor::createTestTables( QSqlDatabase db )
diff --git a/tests/auto/q3table/tst_q3table.cpp b/tests/auto/q3table/tst_q3table.cpp
index 2fab3eba0a..7db0a40f8d 100644
--- a/tests/auto/q3table/tst_q3table.cpp
+++ b/tests/auto/q3table/tst_q3table.cpp
@@ -387,7 +387,6 @@ public:
void tst_Q3Table::selectComboTableItem()
{
-// #if QT_VERSION >= 0x030100
#if 0
MyTable table(4,4,0,"subclassTestWidget");
// Test for task #25026
diff --git a/tests/auto/q3textedit/tst_q3textedit.cpp b/tests/auto/q3textedit/tst_q3textedit.cpp
index 21bc8b59b4..1fcce7b441 100644
--- a/tests/auto/q3textedit/tst_q3textedit.cpp
+++ b/tests/auto/q3textedit/tst_q3textedit.cpp
@@ -159,12 +159,10 @@ void tst_Q3TextEdit::getSetCheck()
Q3TextDocument *var2 = new Q3TextDocument(0);
obj1.setDocument(var2);
QCOMPARE(obj1.document(), var2);
-#if QT_VERSION >= 0x040200
// Should've done as QTextEdit, and created a new document, if you setDocument(0).
// Unfortunately it doesn't, and we cannot change it.
obj1.setDocument((Q3TextDocument *)0);
QCOMPARE(obj1.document(), var2);
-#endif
// delete var2; // No delete, since Q3TextEdit takes ownership
}
diff --git a/tests/auto/q3textstream/tst_q3textstream.cpp b/tests/auto/q3textstream/tst_q3textstream.cpp
index 7932b79caf..b13e83f04e 100644
--- a/tests/auto/q3textstream/tst_q3textstream.cpp
+++ b/tests/auto/q3textstream/tst_q3textstream.cpp
@@ -346,9 +346,6 @@ void tst_Q3TextStream::operator_shiftleft()
QFETCH( QString, device );
QFETCH( QString, encoding );
QFETCH( QByteArray, encoded );
-#if QT_VERSION < 0x040000
- encoded.resize( encoded.size() - 1 );
-#endif
if ( device == "file" ) {
QFile outFile( "qtextstream.out" );
@@ -400,9 +397,6 @@ void tst_Q3TextStream::operator_shiftright()
QFETCH( int, intVal );
QFETCH( QString, stringVal );
QFETCH( QByteArray, encoded );
-#if QT_VERSION < 0x040000
- encoded.resize( encoded.size() - 1 );
-#endif
if ( device == "file" ) {
QFile outFile( "qtextstream.out" );
@@ -1295,7 +1289,6 @@ void tst_Q3TextStream::write_Q3CString( Q3TextStream *s )
void tst_Q3TextStream::task28319()
{
/*
-#if QT_VERSION >= 0x040000
// Specific test for task 28319
QFile f("28319.txt");
if (f.open(IO_WriteOnly)) {
@@ -1324,9 +1317,6 @@ void tst_Q3TextStream::task28319()
} else {
QVERIFY(FALSE);
}
-#else
- QSKIP( "A minor bug we don't want to fix in 3.2.", SkipAll);
-#endif
*/
}
diff --git a/tests/auto/q3timeedit/tst_q3timeedit.cpp b/tests/auto/q3timeedit/tst_q3timeedit.cpp
index 967bb51d69..1cdd87c29b 100644
--- a/tests/auto/q3timeedit/tst_q3timeedit.cpp
+++ b/tests/auto/q3timeedit/tst_q3timeedit.cpp
@@ -130,10 +130,8 @@ void tst_Q3TimeEdit::init()
QTime maximumTime(23, 59, 59);
testWidget->setMinValue(minimumTime);
testWidget->setMaxValue(maximumTime);
-#if QT_VERSION >= 0x030100
// We don't want the locale impacting on the test
testWidget->setDisplay(Q3TimeEdit::Hours | Q3TimeEdit::Minutes | Q3TimeEdit::Seconds);
-#endif
testWidget->setTime(QTime(11, 0, 0));
// make sure we start with the hour focused
@@ -174,10 +172,8 @@ void tst_Q3TimeEdit::valueRange()
QTime maximumTime(maximumHours, maximumMinutes, maximumSeconds);
testWidget->setMinValue(minimumTime);
testWidget->setMaxValue(maximumTime);
-#if QT_VERSION >= 0x030100
// We don't want the locale impacting on the test
testWidget->setDisplay(Q3TimeEdit::Hours | Q3TimeEdit::Minutes | Q3TimeEdit::Seconds);
-#endif
// When pressing Key_Up we want to check it goes to the minimum time
testWidget->setTime(maximumTime);
diff --git a/tests/auto/q3valuelist/tst_q3valuelist.cpp b/tests/auto/q3valuelist/tst_q3valuelist.cpp
index 8abeee22ce..b10664aca0 100644
--- a/tests/auto/q3valuelist/tst_q3valuelist.cpp
+++ b/tests/auto/q3valuelist/tst_q3valuelist.cpp
@@ -296,7 +296,6 @@ void tst_Q3ValueList::beginEnd()
QCOMPARE( *(cit1), 2 );
QCOMPARE( *(cit2), 200 );
-#if (QT_VERSION >= 0x030200)
Q3ValueList<int> b;
b.append( 1 );
Q3ValueList<int> b2 = b;
@@ -305,7 +304,6 @@ void tst_Q3ValueList::beginEnd()
b2.append( 2 );
QVERIFY( b.constBegin() != b2.constBegin() );
QVERIFY( b2.constBegin() == b2.constBegin() );
-#endif
}
void tst_Q3ValueList::pushing()
@@ -593,11 +591,7 @@ void tst_Q3ValueList::opStreamOut()
class ListVerifier : public Q3ValueList<int>
{
public:
-#if QT_VERSION < 0x040000
- void* pointer() { return sh; }
-#else
const int* pointer() const { return &*begin(); }
-#endif
};
void tst_Q3ValueList::shared()
{
diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
index b613b8190c..c0ffea034a 100644
--- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -346,14 +346,11 @@ void tst_QAbstractItemModel::match()
QCOMPARE(res.count(), 2);
res = model.match(start, Qt::DisplayRole, QVariant(".*O.*"), -1, Qt::MatchRegExp | Qt::MatchCaseSensitive);
QCOMPARE(res.count(), 0);
- // MatchFixedString seems new in 4.2
-#if QT_VERSION >= 0x040200
res = model.match(start, Qt::DisplayRole, QVariant("BOAR"), -1, Qt::MatchFixedString);
QCOMPARE(res.count(), 1);
res = model.match(start, Qt::DisplayRole, QVariant("bat"), -1,
Qt::MatchFixedString | Qt::MatchCaseSensitive);
QCOMPARE(res.count(), 1);
-#endif
}
typedef QPair<int, int> Position;
@@ -582,7 +579,6 @@ void tst_QAbstractItemModel::dropMimeData_data()
<< (qStringTableRow("" , "" , "A"))
<< (qStringTableRow("" , "" , "B")));
}
-#if QT_VERSION >= 0x040200
{
QTest::newRow("2x 1x2 dropped at [3, 2] (different rows)")
<< (STRINGTABLE // source table
@@ -624,7 +620,6 @@ void tst_QAbstractItemModel::dropMimeData_data()
<< (qStringTableRow("" , "" , "B"))
<< (qStringTableRow("" , "" , "H")));
}
-#endif
}
void tst_QAbstractItemModel::dropMimeData()
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
index 2d55ca1982..69b310c484 100644
--- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
@@ -53,6 +53,8 @@
#include <qspinbox.h>
#include <qitemdelegate.h>
#include <qpushbutton.h>
+#include <qscrollbar.h>
+#include <qboxlayout.h>
#include "../../shared/util.h"
//TESTED_CLASS=
@@ -211,6 +213,7 @@ private slots:
void setCurrentIndex();
void task221955_selectedEditor();
+ void task250754_fontChange();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -233,11 +236,8 @@ void tst_QAbstractItemView::getSetCheck()
MyAbstractItemDelegate *var1 = new MyAbstractItemDelegate;
obj1->setItemDelegate(var1);
QCOMPARE((QAbstractItemDelegate*)var1, obj1->itemDelegate());
-#if QT_VERSION >= 0x040200
- // Itemviews in Qt < 4.2 have asserts for this. Qt >= 4.2 should handle this gracefully
obj1->setItemDelegate((QAbstractItemDelegate *)0);
QCOMPARE((QAbstractItemDelegate *)0, obj1->itemDelegate());
-#endif
delete var1;
// EditTriggers QAbstractItemView::editTriggers()
@@ -279,26 +279,6 @@ void tst_QAbstractItemView::getSetCheck()
obj1->setAlternatingRowColors(true);
QCOMPARE(true, obj1->alternatingRowColors());
-#if QT_VERSION < 0x040200
- // int QAbstractItemView::horizontalStepsPerItem()
- // void QAbstractItemView::setHorizontalStepsPerItem(int)
- obj1->tst_setHorizontalStepsPerItem(0);
- QCOMPARE(0, obj1->tst_horizontalStepsPerItem());
- obj1->tst_setHorizontalStepsPerItem(INT_MIN);
- QCOMPARE(INT_MIN, obj1->tst_horizontalStepsPerItem());
- obj1->tst_setHorizontalStepsPerItem(INT_MAX);
- QCOMPARE(INT_MAX, obj1->tst_horizontalStepsPerItem());
-
- // int QAbstractItemView::verticalStepsPerItem()
- // void QAbstractItemView::setVerticalStepsPerItem(int)
- obj1->tst_setVerticalStepsPerItem(0);
- QCOMPARE(0, obj1->tst_verticalStepsPerItem());
- obj1->tst_setVerticalStepsPerItem(INT_MIN);
- QCOMPARE(INT_MIN, obj1->tst_verticalStepsPerItem());
- obj1->tst_setVerticalStepsPerItem(INT_MAX);
- QCOMPARE(INT_MAX, obj1->tst_verticalStepsPerItem());
-#endif
-
// State QAbstractItemView::state()
// void QAbstractItemView::setState(State)
obj1->tst_setState(TestView::tst_State(TestView::NoState));
@@ -314,13 +294,11 @@ void tst_QAbstractItemView::getSetCheck()
obj1->tst_setState(TestView::tst_State(TestView::CollapsingState));
QCOMPARE(TestView::tst_State(TestView::CollapsingState), obj1->tst_state());
-#if QT_VERSION >= 0x040200
// QWidget QAbstractScrollArea::viewport()
// void setViewport(QWidget*)
QWidget *vp = new QWidget;
obj1->setViewport(vp);
QCOMPARE(vp, obj1->viewport());
-#endif
QCOMPARE(16, obj1->autoScrollMargin());
obj1->setAutoScrollMargin(20);
@@ -1186,8 +1164,46 @@ void tst_QAbstractItemView::task221955_selectedEditor()
button->setFocus();
QTest::qWait(50);
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
+}
+
+void tst_QAbstractItemView::task250754_fontChange()
+{
+ QString app_css = qApp->styleSheet();
+ qApp->setStyleSheet("/* */");
+
+ QWidget w;
+ QTreeView tree(&w);
+ QVBoxLayout *vLayout = new QVBoxLayout(&w);
+ vLayout->addWidget(&tree);
+
+ QStandardItemModel *m = new QStandardItemModel(this);
+ for (int i=0; i<5; ++i) {
+ QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i));
+ for (int j=0; j<5; ++j) {
+ QStandardItem *child = new QStandardItem(QString("Child Item number %1").arg(j));
+ item->setChild(j, 0, child);
+ }
+ m->setItem(i, 0, item);
+ }
+ tree.setModel(m);
+
+ w.show();
+ w.resize(150,150);
+ QTest::qWait(30);
+ QFont font = tree.font();
+ font.setPointSize(5);
+ tree.setFont(font);
+ QTest::qWait(30);
+
+ QVERIFY(!tree.verticalScrollBar()->isVisible());
+
+ font.setPointSize(45);
+ tree.setFont(font);
+ QTest::qWait(30);
+ //now with the huge items, the scrollbar must be visible
+ QVERIFY(tree.verticalScrollBar()->isVisible());
-
+ qApp->setStyleSheet(app_css);
}
QTEST_MAIN(tst_QAbstractItemView)
diff --git a/tests/auto/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp
index 9e3acb8e41..dc1c866a3f 100644
--- a/tests/auto/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp
@@ -864,11 +864,7 @@ void tst_QAbstractSlider::wheelEvent()
QVERIFY(applicationInstance->sendEvent(slider,&event));
QCOMPARE(slider->sliderPosition(),expectedSliderPosition);
int expectedSignalCount = (initialSliderPosition == expectedSliderPosition) ? 0 : 1;
-#if QT_VERSION >= 0x040200
QCOMPARE(spy1.count(), expectedSignalCount);
-#else
- QCOMPARE(spy1.count(), 0);
-#endif
QCOMPARE(spy2.count(), expectedSignalCount);
if (expectedSignalCount)
QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp);
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp
index d02355793b..df770b38fc 100644
--- a/tests/auto/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp
@@ -218,8 +218,6 @@ public:
tst_QAccessibility();
virtual ~tst_QAccessibility();
-
-
public slots:
void initTestCase();
void cleanupTestCase();
@@ -275,6 +273,7 @@ private slots:
void accessibleName();
void treeWidgetTest();
void labelTest();
+ void accelerators();
private:
QWidget *createGUI();
@@ -408,15 +407,15 @@ public:
QtTestAccessibleWidgetIface(QtTestAccessibleWidget *w): QAccessibleWidget(w) {}
QString text(Text t, int control) const
{
- if (t == Help)
- return QString::fromLatin1("Help yourself");
- return QAccessibleWidget::text(t, control);
+ if (t == Help)
+ return QString::fromLatin1("Help yourself");
+ return QAccessibleWidget::text(t, control);
}
static QAccessibleInterface *ifaceFactory(const QString &key, QObject *o)
{
- if (key == "QtTestAccessibleWidget")
- return new QtTestAccessibleWidgetIface(static_cast<QtTestAccessibleWidget*>(o));
- return 0;
+ if (key == "QtTestAccessibleWidget")
+ return new QtTestAccessibleWidgetIface(static_cast<QtTestAccessibleWidget*>(o));
+ return 0;
}
};
#endif
@@ -454,15 +453,15 @@ void tst_QAccessibility::cleanup()
#ifdef QTEST_ACCESSIBILITY
const EventList list = QTestAccessibility::events();
if (!list.isEmpty()) {
- qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(),
- QString(QTest::currentTestFunction()).toAscii().constData());
- for (int i = 0; i < list.count(); ++i)
- qWarning(" %d: Object: %p Event: '%s' (%d) Child: %d", i + 1, list.at(i).object,
- eventName(list.at(i).event).toAscii().constData(), list.at(i).event, list.at(i).child);
+ qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(),
+ QString(QTest::currentTestFunction()).toAscii().constData());
+ for (int i = 0; i < list.count(); ++i)
+ qWarning(" %d: Object: %p Event: '%s' (%d) Child: %d", i + 1, list.at(i).object,
+ eventName(list.at(i).event).toAscii().constData(), list.at(i).event, list.at(i).child);
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -485,7 +484,7 @@ void tst_QAccessibility::eventTest()
delete button;
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -504,7 +503,7 @@ void tst_QAccessibility::customWidget()
delete iface;
delete widget;
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -522,7 +521,7 @@ void tst_QAccessibility::deletedWidget()
QVERIFY(!iface->isValid());
delete iface;
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -541,52 +540,52 @@ QWidget *tst_QAccessibility::createGUI()
topLeft->setSpacing(2);
grid->addWidget(topLeft, 0, 0);
- Q3VButtonGroup *group1 = new Q3VButtonGroup("Title1:", topLeft, "group1");
- /*QPushButton *pb1 = */ new QPushButton("Button&1", group1, "pb1");
- Q3VButtonGroup *group2 = new Q3VButtonGroup("Title2:", topLeft, "group2");
- /*QPushButton *pb2 = */ new QPushButton("Button2", group2, "pb2");
+ Q3VButtonGroup *group1 = new Q3VButtonGroup("Title1:", topLeft, "group1");
+ /*QPushButton *pb1 = */ new QPushButton("Button&1", group1, "pb1");
+ Q3VButtonGroup *group2 = new Q3VButtonGroup("Title2:", topLeft, "group2");
+ /*QPushButton *pb2 = */ new QPushButton("Button2", group2, "pb2");
- Q3WidgetStack *stack = new Q3WidgetStack(topLeft, "stack");
- QLabel *page1 = new QLabel("Page 1", stack, "page1");
- stack->addWidget(page1);
- QLabel *page2 = new QLabel("Page 2", stack, "page2");
- stack->addWidget(page2);
- QLabel *page3 = new QLabel("Page 3", stack, "page3");
- stack->addWidget(page3);
+ Q3WidgetStack *stack = new Q3WidgetStack(topLeft, "stack");
+ QLabel *page1 = new QLabel("Page 1", stack, "page1");
+ stack->addWidget(page1);
+ QLabel *page2 = new QLabel("Page 2", stack, "page2");
+ stack->addWidget(page2);
+ QLabel *page3 = new QLabel("Page 3", stack, "page3");
+ stack->addWidget(page3);
// topRight - controlling
Q3VBox *topRight= new Q3VBox(toplevel, "topRight");
grid->addWidget(topRight, 0, 1);
- QPushButton *pbOk = new QPushButton("Ok", topRight, "pbOk" );
- pbOk->setDefault(TRUE);
- QSlider *slider = new QSlider(Qt::Horizontal, topRight, "slider");
- QLCDNumber *sliderLcd = new QLCDNumber(topRight, "sliderLcd");
- QSpinBox *spinBox = new QSpinBox(topRight, "spinBox");
+ QPushButton *pbOk = new QPushButton("Ok", topRight, "pbOk" );
+ pbOk->setDefault(TRUE);
+ QSlider *slider = new QSlider(Qt::Horizontal, topRight, "slider");
+ QLCDNumber *sliderLcd = new QLCDNumber(topRight, "sliderLcd");
+ QSpinBox *spinBox = new QSpinBox(topRight, "spinBox");
- connect(pbOk, SIGNAL(clicked()), toplevel, SLOT(close()) );
- connect(slider, SIGNAL(valueChanged(int)), sliderLcd, SLOT(display(int)));
- connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
+ connect(pbOk, SIGNAL(clicked()), toplevel, SLOT(close()) );
+ connect(slider, SIGNAL(valueChanged(int)), sliderLcd, SLOT(display(int)));
+ connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
- spinBox->setValue(50);
+ spinBox->setValue(50);
// bottomLeft - labeling and controlling
Q3HBox *bottomLeft = new Q3HBox(toplevel, "bottomLeft");
grid->addWidget(bottomLeft, 1, 0);
- QLabel *label = new QLabel("This is a &lineedit:", bottomLeft, "label");
- QLineEdit *lineedit = new QLineEdit(bottomLeft, "lineedit");
- label->setBuddy(lineedit);
- QLabel *label2 = new QLabel(bottomLeft, "label2");
+ QLabel *label = new QLabel("This is a &lineedit:", bottomLeft, "label");
+ QLineEdit *lineedit = new QLineEdit(bottomLeft, "lineedit");
+ label->setBuddy(lineedit);
+ QLabel *label2 = new QLabel(bottomLeft, "label2");
- connect(lineedit, SIGNAL(textChanged(const QString&)), label2, SLOT(setText(const QString&)));
+ connect(lineedit, SIGNAL(textChanged(const QString&)), label2, SLOT(setText(const QString&)));
- Q3VButtonGroup *radiogroup = new Q3VButtonGroup("Exclusive &choices:", bottomLeft, "radiogroup");
- QLineEdit *frequency = new QLineEdit(radiogroup, "frequency");
- frequency->setText("100 Mhz");
- QRadioButton *radioAM = new QRadioButton("&AM", radiogroup, "radioAM");
- /* QRadioButton *radioFM = */ new QRadioButton("&FM", radiogroup, "radioFM");
- /* QRadioButton *radioSW = */ new QRadioButton("&Shortwave", radiogroup, "radioSW");
+ Q3VButtonGroup *radiogroup = new Q3VButtonGroup("Exclusive &choices:", bottomLeft, "radiogroup");
+ QLineEdit *frequency = new QLineEdit(radiogroup, "frequency");
+ frequency->setText("100 Mhz");
+ QRadioButton *radioAM = new QRadioButton("&AM", radiogroup, "radioAM");
+ /* QRadioButton *radioFM = */ new QRadioButton("&FM", radiogroup, "radioFM");
+ /* QRadioButton *radioSW = */ new QRadioButton("&Shortwave", radiogroup, "radioSW");
// bottomRight - ### empty
Q3HBox *bottomRight = new Q3HBox(toplevel, "bottomRight");
@@ -625,23 +624,23 @@ void tst_QAccessibility::childAt()
QObjectList children = toplevel->queryList("QWidget", 0, 0, 0);
for (int c = 1; c <= children.count(); ++c) {
- QWidget *child = qobject_cast<QWidget*>(children.at(c-1));
- QAccessibleInterface *acc_child = QAccessible::queryAccessibleInterface(child);
- QVERIFY(acc_child);
- QCOMPARE(acc_child->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask, QAccessible::Child);
-
- QPoint center(child->mapToGlobal(child->rect().center()));
- QRect childRect(child->geometry());
- childRect.moveCenter(center);
-
- QCOMPARE(acc_child->rect(0), childRect);
- QCOMPARE(acc_toplevel->childAt(childRect.center().x(), childRect.center().y()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.left(), childRect.top()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.left(), childRect.bottom()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.right(), childRect.top()), c);
- QCOMPARE(acc_toplevel->childAt(childRect.right(), childRect.bottom()), c);
-
- QCOMPARE(acc_toplevel->indexOfChild(acc_child), c);
+ QWidget *child = qobject_cast<QWidget*>(children.at(c-1));
+ QAccessibleInterface *acc_child = QAccessible::queryAccessibleInterface(child);
+ QVERIFY(acc_child);
+ QCOMPARE(acc_child->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask, QAccessible::Child);
+
+ QPoint center(child->mapToGlobal(child->rect().center()));
+ QRect childRect(child->geometry());
+ childRect.moveCenter(center);
+
+ QCOMPARE(acc_child->rect(0), childRect);
+ QCOMPARE(acc_toplevel->childAt(childRect.center().x(), childRect.center().y()), c);
+ QCOMPARE(acc_toplevel->childAt(childRect.left(), childRect.top()), c);
+ QCOMPARE(acc_toplevel->childAt(childRect.left(), childRect.bottom()), c);
+ QCOMPARE(acc_toplevel->childAt(childRect.right(), childRect.top()), c);
+ QCOMPARE(acc_toplevel->childAt(childRect.right(), childRect.bottom()), c);
+
+ QCOMPARE(acc_toplevel->indexOfChild(acc_child), c);
delete acc_child;
}
@@ -649,7 +648,7 @@ void tst_QAccessibility::childAt()
delete toplevel;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // !QT3_SUPPORT
}
@@ -693,7 +692,7 @@ void tst_QAccessibility::childCount()
delete toplevel;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // !QT3_SUPPORT
}
@@ -715,33 +714,33 @@ void tst_QAccessibility::relationTo()
QAccessibleInterface *acc_toplevel = QAccessible::queryAccessibleInterface(toplevel);
- QAccessibleInterface *acc_topLeft = QAccessible::queryAccessibleInterface(topLeft);
- QAccessibleInterface *acc_group1 = QAccessible::queryAccessibleInterface(topLeft->child("group1"));
- QVERIFY(topLeft->child("group1"));
- QAccessibleInterface *acc_pb1 = QAccessible::queryAccessibleInterface(topLeft->child("group1")->child("pb1"));
- QAccessibleInterface *acc_group2 = QAccessible::queryAccessibleInterface(topLeft->child("group2"));
- QAccessibleInterface *acc_pb2 = 0;
- QAccessibleInterface *acc_stack = QAccessible::queryAccessibleInterface(topLeft->child("stack"));
- QAccessibleInterface *acc_page1 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page1"));
- QAccessibleInterface *acc_page2 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page2"));
- QAccessibleInterface *acc_page3 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page3"));
- QAccessibleInterface *acc_topRight = QAccessible::queryAccessibleInterface(topRight);
- QAccessibleInterface *acc_pbOk = QAccessible::queryAccessibleInterface(topRight->child("pbOk"));
- QAccessibleInterface *acc_slider = QAccessible::queryAccessibleInterface(topRight->child("slider"));
- QAccessibleInterface *acc_spinBox = QAccessible::queryAccessibleInterface(topRight->child("spinBox"));
- QAccessibleInterface *acc_sliderLcd = QAccessible::queryAccessibleInterface(topRight->child("sliderLcd"));
-
- QAccessibleInterface *acc_bottomLeft = QAccessible::queryAccessibleInterface(bottomLeft);
- QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(bottomLeft->child("label"));
- QAccessibleInterface *acc_lineedit = QAccessible::queryAccessibleInterface(bottomLeft->child("lineedit"));
- QAccessibleInterface *acc_label2 = QAccessible::queryAccessibleInterface(bottomLeft->child("label2"));
- QAccessibleInterface *acc_radiogroup = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup"));
- QAccessibleInterface *acc_radioAM = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioAM"));
- QAccessibleInterface *acc_radioFM = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioFM"));
- QAccessibleInterface *acc_radioSW = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioSW"));
- QAccessibleInterface *acc_frequency = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("frequency"));
-
- QAccessibleInterface *acc_bottomRight = QAccessible::queryAccessibleInterface(bottomRight);
+ QAccessibleInterface *acc_topLeft = QAccessible::queryAccessibleInterface(topLeft);
+ QAccessibleInterface *acc_group1 = QAccessible::queryAccessibleInterface(topLeft->child("group1"));
+ QVERIFY(topLeft->child("group1"));
+ QAccessibleInterface *acc_pb1 = QAccessible::queryAccessibleInterface(topLeft->child("group1")->child("pb1"));
+ QAccessibleInterface *acc_group2 = QAccessible::queryAccessibleInterface(topLeft->child("group2"));
+ QAccessibleInterface *acc_pb2 = 0;
+ QAccessibleInterface *acc_stack = QAccessible::queryAccessibleInterface(topLeft->child("stack"));
+ QAccessibleInterface *acc_page1 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page1"));
+ QAccessibleInterface *acc_page2 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page2"));
+ QAccessibleInterface *acc_page3 = QAccessible::queryAccessibleInterface(topLeft->child("stack")->child("page3"));
+ QAccessibleInterface *acc_topRight = QAccessible::queryAccessibleInterface(topRight);
+ QAccessibleInterface *acc_pbOk = QAccessible::queryAccessibleInterface(topRight->child("pbOk"));
+ QAccessibleInterface *acc_slider = QAccessible::queryAccessibleInterface(topRight->child("slider"));
+ QAccessibleInterface *acc_spinBox = QAccessible::queryAccessibleInterface(topRight->child("spinBox"));
+ QAccessibleInterface *acc_sliderLcd = QAccessible::queryAccessibleInterface(topRight->child("sliderLcd"));
+
+ QAccessibleInterface *acc_bottomLeft = QAccessible::queryAccessibleInterface(bottomLeft);
+ QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(bottomLeft->child("label"));
+ QAccessibleInterface *acc_lineedit = QAccessible::queryAccessibleInterface(bottomLeft->child("lineedit"));
+ QAccessibleInterface *acc_label2 = QAccessible::queryAccessibleInterface(bottomLeft->child("label2"));
+ QAccessibleInterface *acc_radiogroup = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup"));
+ QAccessibleInterface *acc_radioAM = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioAM"));
+ QAccessibleInterface *acc_radioFM = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioFM"));
+ QAccessibleInterface *acc_radioSW = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("radioSW"));
+ QAccessibleInterface *acc_frequency = QAccessible::queryAccessibleInterface(bottomLeft->child("radiogroup")->child("frequency"));
+
+ QAccessibleInterface *acc_bottomRight = QAccessible::queryAccessibleInterface(bottomRight);
QVERIFY(acc_toplevel);
QVERIFY(acc_topLeft);
@@ -768,49 +767,49 @@ void tst_QAccessibility::relationTo()
// hierachy relations
QCOMPARE(acc_toplevel->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Self);
+ QAccessible::Self);
QCOMPARE(acc_toplevel->relationTo(1, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
+ QAccessible::Child);
QCOMPARE(acc_toplevel->relationTo(0, acc_toplevel, 1) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
+ QAccessible::Ancestor);
QCOMPARE(acc_toplevel->relationTo(0, acc_topLeft, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
+ QAccessible::Ancestor);
QCOMPARE(acc_toplevel->relationTo(0, acc_topRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
+ QAccessible::Ancestor);
QCOMPARE(acc_toplevel->relationTo(0, acc_bottomLeft, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
+ QAccessible::Ancestor);
QCOMPARE(acc_toplevel->relationTo(0, acc_bottomRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
+ QAccessible::Ancestor);
QCOMPARE(acc_toplevel->relationTo(0, acc_group1, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
+ QAccessible::Ancestor);
QCOMPARE(acc_toplevel->relationTo(0, acc_page1, 0) & QAccessible::HierarchyMask,
- QAccessible::Ancestor);
+ QAccessible::Ancestor);
QCOMPARE(acc_group1->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Descendent);
+ QAccessible::Descendent);
QCOMPARE(acc_stack->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Descendent);
+ QAccessible::Descendent);
QCOMPARE(acc_page1->relationTo(0, acc_stack, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
+ QAccessible::Child);
QCOMPARE(acc_page1->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Descendent);
+ QAccessible::Descendent);
QCOMPARE(acc_topLeft->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
+ QAccessible::Child);
QCOMPARE(acc_topRight->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
+ QAccessible::Child);
QCOMPARE(acc_bottomLeft->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
+ QAccessible::Child);
QCOMPARE(acc_bottomRight->relationTo(0, acc_toplevel, 0) & QAccessible::HierarchyMask,
- QAccessible::Child);
+ QAccessible::Child);
QCOMPARE(acc_topLeft->relationTo(0, acc_topRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Sibling);
+ QAccessible::Sibling);
QCOMPARE(acc_topLeft->relationTo(0, acc_bottomLeft, 0) & QAccessible::HierarchyMask,
- QAccessible::Sibling);
+ QAccessible::Sibling);
QCOMPARE(acc_topLeft->relationTo(0, acc_bottomRight, 0) & QAccessible::HierarchyMask,
- QAccessible::Sibling);
+ QAccessible::Sibling);
QCOMPARE(acc_pb1->relationTo(0, acc_pb2, 0), QAccessible::Unrelated);
@@ -835,25 +834,25 @@ void tst_QAccessibility::relationTo()
// logical relations - focus
QCOMPARE(acc_radioAM->relationTo(0, acc_radioFM, 0) & QAccessible::FocusChild,
- QAccessible::Unrelated);
+ QAccessible::Unrelated);
QCOMPARE(acc_radioAM->relationTo(0, acc_radiogroup, 0) & QAccessible::FocusChild,
- QAccessible::FocusChild);
+ QAccessible::FocusChild);
QCOMPARE(acc_radioAM->relationTo(0, acc_bottomLeft, 0) & QAccessible::FocusChild,
- QAccessible::FocusChild);
+ QAccessible::FocusChild);
QCOMPARE(acc_radioAM->relationTo(0, acc_topLeft, 0) & QAccessible::FocusChild,
- QAccessible::Unrelated);
+ QAccessible::Unrelated);
QCOMPARE(acc_radioAM->relationTo(0, acc_toplevel, 0) & QAccessible::FocusChild,
- QAccessible::FocusChild);
+ QAccessible::FocusChild);
// logical relations - labels
QCOMPARE(acc_label->relationTo(0, acc_lineedit, 0) & QAccessible::LogicalMask,
- QAccessible::Label);
+ QAccessible::Label);
QCOMPARE(acc_lineedit->relationTo(0, acc_label, 0) & QAccessible::LogicalMask,
- QAccessible::Labelled);
+ QAccessible::Labelled);
QCOMPARE(acc_label->relationTo(0, acc_radiogroup, 0) & QAccessible::LogicalMask,
- QAccessible::Unrelated);
+ QAccessible::Unrelated);
QCOMPARE(acc_lineedit->relationTo(0, acc_lineedit, 0) & QAccessible::LogicalMask,
- QAccessible::Unrelated);
+ QAccessible::Unrelated);
QEXPECT_FAIL("", "Make me accessible", Continue);
QCOMPARE(acc_radiogroup->relationTo(0, acc_radioAM, 0) & QAccessible::LogicalMask,
@@ -865,21 +864,21 @@ void tst_QAccessibility::relationTo()
QCOMPARE(acc_radiogroup->relationTo(0, acc_radioSW, 0) & QAccessible::LogicalMask,
QAccessible::Label | QAccessible::Controlled);
QCOMPARE(acc_radiogroup->relationTo(0, acc_frequency, 0) & QAccessible::LogicalMask,
- QAccessible::Label);
+ QAccessible::Label);
QCOMPARE(acc_frequency->relationTo(0, acc_radiogroup, 0) & QAccessible::LogicalMask,
- QAccessible::Labelled);
+ QAccessible::Labelled);
QCOMPARE(acc_radiogroup->relationTo(0, acc_lineedit, 0) & QAccessible::LogicalMask,
- QAccessible::Unrelated);
+ QAccessible::Unrelated);
// logical relations - controller
QCOMPARE(acc_pbOk->relationTo(0, acc_toplevel, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
+ QAccessible::Controller);
QCOMPARE(acc_slider->relationTo(0, acc_sliderLcd, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
+ QAccessible::Controller);
QCOMPARE(acc_spinBox->relationTo(0, acc_slider, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
+ QAccessible::Controller);
QCOMPARE(acc_lineedit->relationTo(0, acc_label2, 0) & QAccessible::LogicalMask,
- QAccessible::Controller);
+ QAccessible::Controller);
delete acc_toplevel;
delete acc_topLeft;
@@ -910,7 +909,7 @@ void tst_QAccessibility::relationTo()
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // !QT3_SUPPORT
}
@@ -933,8 +932,8 @@ void tst_QAccessibility::navigateGeometric()
QtTestAccessibleWidget *aw = 0;
int i;
for (i = 0; i < 360; i += skip) {
- aw = new QtTestAccessibleWidget(w, QString::number(i).toLatin1());
- aw->move( int(200.0 + 100.0 * sin(step * (double)i)), int(200.0 + 100.0 * cos(step * (double)i)) );
+ aw = new QtTestAccessibleWidget(w, QString::number(i).toLatin1());
+ aw->move( int(200.0 + 100.0 * sin(step * (double)i)), int(200.0 + 100.0 * cos(step * (double)i)) );
}
aw = new QtTestAccessibleWidget(w, "Earth");
@@ -949,25 +948,24 @@ void tst_QAccessibility::navigateGeometric()
QTest::qWait(100);
#endif
-
// let one widget rotate around center
for (i = 0; i < 360; i+=skip) {
- aw->move( int(200.0 + 75.0 * sin(step * (double)i)), int(200.0 + 75.0 * cos(step * (double)i)) );
-
- if (i < 45 || i > 315) {
- QCOMPARE(iface->navigate(QAccessible::Down, 0, &target), 0);
- } else if ( i < 135 ) {
- QCOMPARE(iface->navigate(QAccessible::Right, 0, &target), 0);
- } else if ( i < 225 ) {
- QCOMPARE(iface->navigate(QAccessible::Up, 0, &target), 0);
- } else {
- QCOMPARE(iface->navigate(QAccessible::Left, 0, &target), 0);
+ aw->move( int(200.0 + 75.0 * sin(step * (double)i)), int(200.0 + 75.0 * cos(step * (double)i)) );
+
+ if (i < 45 || i > 315) {
+ QCOMPARE(iface->navigate(QAccessible::Down, 0, &target), 0);
+ } else if ( i < 135 ) {
+ QCOMPARE(iface->navigate(QAccessible::Right, 0, &target), 0);
+ } else if ( i < 225 ) {
+ QCOMPARE(iface->navigate(QAccessible::Up, 0, &target), 0);
+ } else {
+ QCOMPARE(iface->navigate(QAccessible::Left, 0, &target), 0);
}
- QVERIFY(target);
- QVERIFY(target->isValid());
- QVERIFY(target->object());
- QCOMPARE(target->object()->objectName(), aw->objectName());
+ QVERIFY(target);
+ QVERIFY(target->isValid());
+ QVERIFY(target->object());
+ QCOMPARE(target->object()->objectName(), aw->objectName());
delete target; target = 0;
}
@@ -1015,7 +1013,7 @@ void tst_QAccessibility::navigateGeometric()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1049,7 +1047,7 @@ void tst_QAccessibility::navigateSlider()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1091,43 +1089,43 @@ void tst_QAccessibility::navigateCovered()
QVERIFY(iface3 == 0);
for (int loop = 0; loop < 2; ++loop) {
- for (int x = 0; x < w->width(); ++x) {
- for (int y = 0; y < w->height(); ++y) {
- w1->move(x, y);
- if (w1->geometry().intersects(w2->geometry())) {
- QVERIFY(iface1->relationTo(0, iface2, 0) & QAccessible::Covers);
- QVERIFY(iface2->relationTo(0, iface1, 0) & QAccessible::Covered);
- QCOMPARE(iface1->navigate(QAccessible::Covered, 1, &iface3), 0);
- QVERIFY(iface3 != 0);
- QVERIFY(iface3->isValid());
- QCOMPARE(iface3->object(), iface2->object());
+ for (int x = 0; x < w->width(); ++x) {
+ for (int y = 0; y < w->height(); ++y) {
+ w1->move(x, y);
+ if (w1->geometry().intersects(w2->geometry())) {
+ QVERIFY(iface1->relationTo(0, iface2, 0) & QAccessible::Covers);
+ QVERIFY(iface2->relationTo(0, iface1, 0) & QAccessible::Covered);
+ QCOMPARE(iface1->navigate(QAccessible::Covered, 1, &iface3), 0);
+ QVERIFY(iface3 != 0);
+ QVERIFY(iface3->isValid());
+ QCOMPARE(iface3->object(), iface2->object());
delete iface3; iface3 = 0;
- QCOMPARE(iface2->navigate(QAccessible::Covers, 1, &iface3), 0);
- QVERIFY(iface3 != 0);
- QVERIFY(iface3->isValid());
- QCOMPARE(iface3->object(), iface1->object());
+ QCOMPARE(iface2->navigate(QAccessible::Covers, 1, &iface3), 0);
+ QVERIFY(iface3 != 0);
+ QVERIFY(iface3->isValid());
+ QCOMPARE(iface3->object(), iface1->object());
delete iface3; iface3 = 0;
- } else {
- QVERIFY(!(iface1->relationTo(0, iface2, 0) & QAccessible::Covers));
- QVERIFY(!(iface2->relationTo(0, iface1, 0) & QAccessible::Covered));
- QCOMPARE(iface1->navigate(QAccessible::Covered, 1, &iface3), -1);
- QVERIFY(iface3 == 0);
- QCOMPARE(iface1->navigate(QAccessible::Covers, 1, &iface3), -1);
- QVERIFY(iface3 == 0);
- QCOMPARE(iface2->navigate(QAccessible::Covered, 1, &iface3), -1);
- QVERIFY(iface3 == 0);
- QCOMPARE(iface2->navigate(QAccessible::Covers, 1, &iface3), -1);
- QVERIFY(iface3 == 0);
- }
- }
- }
- if (!loop) {
- // switch children for second loop
- w2->raise();
- QAccessibleInterface *temp = iface1;
- iface1 = iface2;
- iface2 = temp;
- }
+ } else {
+ QVERIFY(!(iface1->relationTo(0, iface2, 0) & QAccessible::Covers));
+ QVERIFY(!(iface2->relationTo(0, iface1, 0) & QAccessible::Covered));
+ QCOMPARE(iface1->navigate(QAccessible::Covered, 1, &iface3), -1);
+ QVERIFY(iface3 == 0);
+ QCOMPARE(iface1->navigate(QAccessible::Covers, 1, &iface3), -1);
+ QVERIFY(iface3 == 0);
+ QCOMPARE(iface2->navigate(QAccessible::Covered, 1, &iface3), -1);
+ QVERIFY(iface3 == 0);
+ QCOMPARE(iface2->navigate(QAccessible::Covers, 1, &iface3), -1);
+ QVERIFY(iface3 == 0);
+ }
+ }
+ }
+ if (!loop) {
+ // switch children for second loop
+ w2->raise();
+ QAccessibleInterface *temp = iface1;
+ iface1 = iface2;
+ iface2 = temp;
+ }
}
delete iface1; iface1 = 0;
delete iface2; iface2 = 0;
@@ -1159,7 +1157,7 @@ void tst_QAccessibility::navigateCovered()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1262,7 +1260,7 @@ void tst_QAccessibility::navigateHierarchy()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1277,11 +1275,11 @@ void tst_QAccessibility::navigateControllers()
#ifdef QTEST_ACCESSIBILITY
{
Q3VBox vbox;
- QSlider slider(&vbox);
- QSpinBox spinBox(&vbox);
- QLCDNumber lcd1(&vbox);
- QLCDNumber lcd2(&vbox);
- QLabel label(&vbox);
+ QSlider slider(&vbox);
+ QSpinBox spinBox(&vbox);
+ QLCDNumber lcd1(&vbox);
+ QLCDNumber lcd2(&vbox);
+ QLabel label(&vbox);
vbox.show();
slider.setObjectName("slider");
@@ -1358,7 +1356,7 @@ void tst_QAccessibility::navigateControllers()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // !QT3_SUPPORT
}
@@ -1373,24 +1371,24 @@ void tst_QAccessibility::navigateLabels()
Q3VBox vbox;
Q3HBox hbox(&vbox);
- QLabel label(&hbox);
+ QLabel label(&hbox);
label.setText("This is a lineedit:");
- QLineEdit lineedit(&hbox);
+ QLineEdit lineedit(&hbox);
label.setBuddy(&lineedit);
Q3VButtonGroup groupbox(&vbox);
groupbox.setTitle("Be my children!");
QRadioButton radio(&groupbox);
- QLabel label2(&groupbox);
+ QLabel label2(&groupbox);
label2.setText("Another lineedit:");
- QLineEdit lineedit2(&groupbox);
+ QLineEdit lineedit2(&groupbox);
label2.setBuddy(&lineedit2);
Q3GroupBox groupbox2(&groupbox);
groupbox2.setTitle("Some grand-children");
- QLineEdit grandchild(&groupbox2);
+ QLineEdit grandchild(&groupbox2);
Q3GroupBox border(&vbox);
- QLineEdit lineedit3(&border);
+ QLineEdit lineedit3(&border);
vbox.show();
QTestAccessibility::clearEvents();
@@ -1491,7 +1489,7 @@ void tst_QAccessibility::navigateLabels()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // !QT3_SUPPORT
}
@@ -1570,7 +1568,7 @@ void tst_QAccessibility::accessibleName()
delete toplevel;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1677,7 +1675,7 @@ void tst_QAccessibility::text()
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // !QT3_SUPPORT
}
@@ -1713,7 +1711,7 @@ void tst_QAccessibility::setText()
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif //QT3_SUPPORT
}
@@ -1748,7 +1746,7 @@ void tst_QAccessibility::hideShowTest()
delete window;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1785,7 +1783,7 @@ void tst_QAccessibility::userActionCount()
QCOMPARE(test->userActionCount(-1), 0);
delete test; test = 0;
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1810,7 +1808,7 @@ void tst_QAccessibility::actionText()
delete test; test = 0;
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -1819,7 +1817,7 @@ void tst_QAccessibility::doAction()
#ifdef QTEST_ACCESSIBILITY
QSKIP("TODO: Implement me", SkipAll);
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2006,7 +2004,7 @@ void tst_QAccessibility::buttonTest()
QTestAccessibility::clearEvents();
#else
-// QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+// QSKIP("Test needs accessibility support.", SkipAll);
QSKIP("No action interface in Qt 4 yet.", SkipAll);
#endif
}
@@ -2206,7 +2204,7 @@ void tst_QAccessibility::sliderTest()
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif //!QT3_SUPPORT
}
@@ -2304,7 +2302,7 @@ void tst_QAccessibility::scrollBarTest()
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2348,7 +2346,7 @@ void tst_QAccessibility::tabTest()
delete interface;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2536,8 +2534,6 @@ void tst_QAccessibility::menuTest()
}
delete iface;
-
-
// "New" item
entry = interface->navigate(QAccessible::Child, 1, &iface);
QCOMPARE(entry, 0);
@@ -2568,11 +2564,6 @@ void tst_QAccessibility::menuTest()
delete iface;
-
-
-#if QT_VERSION < 0x040102
- QEXPECT_FAIL("", "Submenus don't open, task 99301", Continue);
-#endif
// move mouse pointer away, since that might influence the
// subsequent tests
QTest::mouseMove(&mw, QPoint(-1, -1));
@@ -2582,9 +2573,6 @@ void tst_QAccessibility::menuTest()
interface->doAction(QAccessible::DefaultAction, 1);
QTestEventLoop::instance().enterLoop(2);
-#if defined (Q_OS_WIN) && QT_VERSION < 0x040300 && !defined(Q_OS_WINCE)
- QEXPECT_FAIL("", "Don't expect the File menu to be visible in 4.2", Continue);
-#endif
QVERIFY(file->isVisible());
QVERIFY(fileNew->isVisible());
QVERIFY(!edit->isVisible());
@@ -2592,8 +2580,8 @@ void tst_QAccessibility::menuTest()
QTestAccessibility::clearEvents();
mw.hide();
-
-
+
+
// Do not crash if the menu don't have a parent
QMenu *menu = new QMenu;
menu->addAction(QLatin1String("one"));
@@ -2607,7 +2595,7 @@ void tst_QAccessibility::menuTest()
delete iface2;
delete iface;
delete menu;
-
+
}
QTestAccessibility::clearEvents();
#else
@@ -2638,7 +2626,7 @@ void tst_QAccessibility::spinBoxTest()
delete spinBox;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2665,7 +2653,7 @@ void tst_QAccessibility::doubleSpinBoxTest()
delete doubleSpinBox;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2687,7 +2675,7 @@ void tst_QAccessibility::textEditTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2711,7 +2699,7 @@ void tst_QAccessibility::textBrowserTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2784,7 +2772,7 @@ void tst_QAccessibility::listViewTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2841,7 +2829,7 @@ void tst_QAccessibility::mdiAreaTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -2971,7 +2959,7 @@ void tst_QAccessibility::mdiSubWindowTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3036,7 +3024,7 @@ void tst_QAccessibility::lineEditTest()
delete toplevel;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3097,7 +3085,7 @@ void tst_QAccessibility::workspaceTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3217,7 +3205,7 @@ void tst_QAccessibility::dialogButtonBoxTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3266,7 +3254,7 @@ void tst_QAccessibility::dialTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3280,7 +3268,7 @@ void tst_QAccessibility::rubberBandTest()
delete interface;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3445,7 +3433,7 @@ void tst_QAccessibility::abstractScrollAreaTest()
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3466,7 +3454,7 @@ void tst_QAccessibility::scrollAreaTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3511,7 +3499,7 @@ void tst_QAccessibility::tableWidgetTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3629,7 +3617,7 @@ void tst_QAccessibility::tableViewTest()
QCOMPARE(client->role(0), QAccessible::Client);
QRect globalRect = client->rect(0);
QVERIFY(globalRect.isValid());
- // make sure we don't hit the vertical header #####
+ // make sure we don't hit the vertical header #####
QPoint p = globalRect.topLeft() + QPoint(8, 8);
p.ry() += 50 * (y - 1);
p.rx() += 100 * (x - 1);
@@ -3677,7 +3665,7 @@ void tst_QAccessibility::tableViewTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3778,7 +3766,7 @@ void tst_QAccessibility::calendarWidgetTest()
}
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // QT_NO_CALENDARWIDGET
}
@@ -3856,7 +3844,7 @@ void tst_QAccessibility::dockWidgetTest()
delete mw;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif // QT_NO_DOCKWIDGET
}
@@ -3902,7 +3890,7 @@ void tst_QAccessibility::pushButtonTest()
delete toplevel;
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
#endif //QT3_SUPPORT
}
@@ -3949,7 +3937,7 @@ void tst_QAccessibility::comboBoxTest()
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -3988,13 +3976,12 @@ void tst_QAccessibility::treeWidgetTest()
QCOMPARE(entry, 0);
QCOMPARE(accTreeItem2->text(QAccessible::Name, 0), QLatin1String("row: 1"));
-
- // test selected/focused state
+ // test selected/focused state
QItemSelectionModel *selModel = tree->selectionModel();
QVERIFY(selModel);
selModel->select(QItemSelection(tree->model()->index(0, 0), tree->model()->index(3, 0)), QItemSelectionModel::Select);
selModel->setCurrentIndex(tree->model()->index(1, 0), QItemSelectionModel::Current);
-
+
for (int i = 1; i < 10 ; ++i) {
QAccessible::State expected;
if (i <= 5 && i >= 2)
@@ -4014,10 +4001,9 @@ void tst_QAccessibility::treeWidgetTest()
delete acc;
delete w;
-
QTestAccessibility::clearEvents();
#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+ QSKIP("Test needs accessibility support.", SkipAll);
#endif
}
@@ -4046,6 +4032,45 @@ void tst_QAccessibility::labelTest()
#endif
}
+void tst_QAccessibility::accelerators()
+{
+#ifdef QTEST_ACCESSIBILITY
+ QWidget *window = new QWidget;
+ QHBoxLayout *lay = new QHBoxLayout(window);
+ QLabel *label = new QLabel(tr("&Line edit"), window);
+ QLineEdit *le = new QLineEdit(window);
+ lay->addWidget(label);
+ lay->addWidget(le);
+ label->setBuddy(le);
+
+ window->show();
+
+ QAccessibleInterface *accLineEdit = QAccessible::queryAccessibleInterface(le);
+ QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString() + QLatin1String("L"));
+ label->setText(tr("Q &"));
+ QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString());
+ label->setText(tr("Q &&"));
+ QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString());
+ label->setText(tr("Q && A"));
+ QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString());
+ label->setText(tr("Q &&&A"));
+ QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString() + QLatin1String("A"));
+ label->setText(tr("Q &&A"));
+ QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString());
+ label->setText(tr("Q &A&B"));
+ QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString() + QLatin1String("A"));
+
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(window);
+#endif
+ QTest::qWait(100);
+ delete window;
+ QTestAccessibility::clearEvents();
+#else
+ QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
+#endif
+}
+
QTEST_MAIN(tst_QAccessibility)
diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp
index 9c2fa50e5a..423cf69f33 100644
--- a/tests/auto/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp
@@ -574,10 +574,8 @@ void tst_QAlgorithms::test_qLowerBound()
QCOMPARE(qLowerBound(data.constBegin(), data.constEnd(), resultValue), data.constBegin() + resultIndex);
QCOMPARE(qLowerBound(data.begin(), data.end(), resultValue), data.begin() + resultIndex);
-#if QT_VERSION >= 0x040200
QCOMPARE(qLowerBound(data, resultValue), data.constBegin() + resultIndex);
QCOMPARE(qLowerBound(data.constBegin(), data.constEnd(), resultValue, qLess<int>()), data.constBegin() + resultIndex);
-#endif
}
void tst_QAlgorithms::test_qUpperBound_data()
@@ -597,10 +595,8 @@ void tst_QAlgorithms::test_qUpperBound()
QCOMPARE(qUpperBound(data.constBegin(), data.constEnd(), resultValue), data.constBegin() + resultIndex);
QCOMPARE(qUpperBound(data.begin(), data.end(), resultValue), data.begin() + resultIndex);
-#if QT_VERSION >= 0x040200
QCOMPARE(qUpperBound(data, resultValue), data.constBegin() + resultIndex);
QCOMPARE(qUpperBound(data.constBegin(), data.constEnd(), resultValue, qLess<int>()), data.constBegin() + resultIndex);
-#endif
}
void tst_QAlgorithms::test_qBinaryFind_data()
@@ -618,10 +614,8 @@ void tst_QAlgorithms::test_qBinaryFind()
QCOMPARE(*qBinaryFind(data.constBegin(), data.constEnd(), resultValue), resultValue);
QCOMPARE(*qBinaryFind(data.begin(), data.end(), resultValue), resultValue);
-#if QT_VERSION >= 0x040200
QCOMPARE(*qBinaryFind(data, resultValue), resultValue);
QCOMPARE(*qBinaryFind(data.constBegin(), data.constEnd(), resultValue, qLess<int>()), resultValue);
-#endif
}
void tst_QAlgorithms::qBinaryFindOneEntry()
@@ -802,7 +796,6 @@ void tst_QAlgorithms::stableSortCorrectnessTest()
void tst_QAlgorithms::convenienceAPI()
{
// Compile-test for QAlgorithm convenience functions.
-#if QT_VERSION >= 0x040200
QList<int> list, list2;
qCopy(list.begin(), list.end(), list2.begin());
@@ -844,7 +837,6 @@ void tst_QAlgorithms::convenienceAPI()
QList<int *> pointerList;
qDeleteAll(pointerList);
qDeleteAll(pointerList.begin(), pointerList.end());
-#endif
}
template <typename DataType>
diff --git a/tests/auto/qbitarray/tst_qbitarray.cpp b/tests/auto/qbitarray/tst_qbitarray.cpp
index 10a4144f73..12fbdc3ce6 100644
--- a/tests/auto/qbitarray/tst_qbitarray.cpp
+++ b/tests/auto/qbitarray/tst_qbitarray.cpp
@@ -211,10 +211,8 @@ void tst_QBitArray::countBits()
}
QCOMPARE(bits.count(), numBits);
-#if QT_VERSION >= 0x040100
QCOMPARE(bits.count(true), onBits);
QCOMPARE(bits.count(false), numBits - onBits);
-#endif
}
void tst_QBitArray::countBits2()
@@ -313,7 +311,7 @@ void tst_QBitArray::toggleBit_data()
}
void tst_QBitArray::toggleBit()
-{
+{
QFETCH(int,index);
QFETCH(QBitArray, input);
QFETCH(QBitArray, res);
@@ -321,7 +319,6 @@ void tst_QBitArray::toggleBit()
input.toggleBit(index);
QCOMPARE(input, res);
-
}
void tst_QBitArray::operator_andeq_data()
@@ -330,33 +327,33 @@ void tst_QBitArray::operator_andeq_data()
QTest::addColumn<QBitArray>("input2");
QTest::addColumn<QBitArray>("res");
- QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("00101100"));
- QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("00001000"));
- QTest::newRow( "data2" ) << QStringToQBitArray(QString("11011011111"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data2" ) << QStringToQBitArray(QString("11011011111"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("00001000000"));
- QTest::newRow( "data3" ) << QStringToQBitArray(QString("11011011"))
- << QStringToQBitArray(QString("00101100111"))
+ QTest::newRow( "data3" ) << QStringToQBitArray(QString("11011011"))
+ << QStringToQBitArray(QString("00101100111"))
<< QStringToQBitArray(QString("00001000000"));
- QTest::newRow( "data4" ) << QStringToQBitArray(QString())
- << QStringToQBitArray(QString("00101100111"))
+ QTest::newRow( "data4" ) << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString("00101100111"))
<< QStringToQBitArray(QString("00000000000"));
- QTest::newRow( "data5" ) << QStringToQBitArray(QString("00101100111"))
- << QStringToQBitArray(QString())
+ QTest::newRow( "data5" ) << QStringToQBitArray(QString("00101100111"))
+ << QStringToQBitArray(QString())
<< QStringToQBitArray(QString("00000000000"));
- QTest::newRow( "data6" ) << QStringToQBitArray(QString())
- << QStringToQBitArray(QString())
+ QTest::newRow( "data6" ) << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString())
<< QStringToQBitArray(QString());
}
@@ -369,7 +366,6 @@ void tst_QBitArray::operator_andeq()
input1&=input2;
QCOMPARE(input1, res);
-
}
void tst_QBitArray::operator_oreq_data()
@@ -378,37 +374,37 @@ void tst_QBitArray::operator_oreq_data()
QTest::addColumn<QBitArray>("input2");
QTest::addColumn<QBitArray>("res");
- QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("11111111"));
- QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("11111111"));
- QTest::newRow( "data2" ) << QStringToQBitArray(QString("01000010"))
- << QStringToQBitArray(QString("10100001"))
+ QTest::newRow( "data2" ) << QStringToQBitArray(QString("01000010"))
+ << QStringToQBitArray(QString("10100001"))
<< QStringToQBitArray(QString("11100011"));
- QTest::newRow( "data3" ) << QStringToQBitArray(QString("11011011"))
- << QStringToQBitArray(QString("00101100000"))
+ QTest::newRow( "data3" ) << QStringToQBitArray(QString("11011011"))
+ << QStringToQBitArray(QString("00101100000"))
<< QStringToQBitArray(QString("11111111000"));
- QTest::newRow( "data4" ) << QStringToQBitArray(QString("11011011111"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data4" ) << QStringToQBitArray(QString("11011011111"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("11111111111"));
- QTest::newRow( "data5" ) << QStringToQBitArray(QString())
- << QStringToQBitArray(QString("00101100111"))
+ QTest::newRow( "data5" ) << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString("00101100111"))
<< QStringToQBitArray(QString("00101100111"));
- QTest::newRow( "data6" ) << QStringToQBitArray(QString("00101100111"))
- << QStringToQBitArray(QString())
+ QTest::newRow( "data6" ) << QStringToQBitArray(QString("00101100111"))
+ << QStringToQBitArray(QString())
<< QStringToQBitArray(QString("00101100111"));
-
- QTest::newRow( "data7" ) << QStringToQBitArray(QString())
- << QStringToQBitArray(QString())
+
+ QTest::newRow( "data7" ) << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString())
<< QStringToQBitArray(QString());
}
@@ -421,7 +417,6 @@ void tst_QBitArray::operator_oreq()
input1|=input2;
QCOMPARE(input1, res);
-
}
void tst_QBitArray::operator_xoreq_data()
@@ -429,36 +424,36 @@ void tst_QBitArray::operator_xoreq_data()
QTest::addColumn<QBitArray>("input1");
QTest::addColumn<QBitArray>("input2");
QTest::addColumn<QBitArray>("res");
- QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("11010011"));
- QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
+ << QStringToQBitArray(QString("00101100"))
<< QStringToQBitArray(QString("11110111"));
- QTest::newRow( "data2" ) << QStringToQBitArray(QString("01000010"))
- << QStringToQBitArray(QString("10100001"))
+ QTest::newRow( "data2" ) << QStringToQBitArray(QString("01000010"))
+ << QStringToQBitArray(QString("10100001"))
<< QStringToQBitArray(QString("11100011"));
- QTest::newRow( "data3" ) << QStringToQBitArray(QString("01000010"))
- << QStringToQBitArray(QString("10100001101"))
+ QTest::newRow( "data3" ) << QStringToQBitArray(QString("01000010"))
+ << QStringToQBitArray(QString("10100001101"))
<< QStringToQBitArray(QString("11100011101"));
- QTest::newRow( "data4" ) << QStringToQBitArray(QString("01000010111"))
- << QStringToQBitArray(QString("101000011"))
+ QTest::newRow( "data4" ) << QStringToQBitArray(QString("01000010111"))
+ << QStringToQBitArray(QString("101000011"))
<< QStringToQBitArray(QString("11100011011"));
- QTest::newRow( "data5" ) << QStringToQBitArray(QString())
- << QStringToQBitArray(QString("00101100111"))
+ QTest::newRow( "data5" ) << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString("00101100111"))
<< QStringToQBitArray(QString("00101100111"));
- QTest::newRow( "data6" ) << QStringToQBitArray(QString("00101100111"))
- << QStringToQBitArray(QString())
+ QTest::newRow( "data6" ) << QStringToQBitArray(QString("00101100111"))
+ << QStringToQBitArray(QString())
<< QStringToQBitArray(QString("00101100111"));
-
- QTest::newRow( "data7" ) << QStringToQBitArray(QString())
- << QStringToQBitArray(QString())
+
+ QTest::newRow( "data7" ) << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString())
<< QStringToQBitArray(QString());
}
@@ -471,7 +466,6 @@ void tst_QBitArray::operator_xoreq()
input1^=input2;
QCOMPARE(input1, res);
-
}
@@ -480,37 +474,37 @@ void tst_QBitArray::operator_neg_data()
QTest::addColumn<QBitArray>("input");
QTest::addColumn<QBitArray>("res");
- QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
+ QTest::newRow( "data0" ) << QStringToQBitArray(QString("11111111"))
<< QStringToQBitArray(QString("00000000"));
- QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
+ QTest::newRow( "data1" ) << QStringToQBitArray(QString("11011011"))
<< QStringToQBitArray(QString("00100100"));
- QTest::newRow( "data2" ) << QStringToQBitArray(QString("00000000"))
+ QTest::newRow( "data2" ) << QStringToQBitArray(QString("00000000"))
<< QStringToQBitArray(QString("11111111"));
- QTest::newRow( "data3" ) << QStringToQBitArray(QString())
+ QTest::newRow( "data3" ) << QStringToQBitArray(QString())
<< QStringToQBitArray(QString());
- QTest::newRow( "data4" ) << QStringToQBitArray("1")
+ QTest::newRow( "data4" ) << QStringToQBitArray("1")
<< QStringToQBitArray("0");
- QTest::newRow( "data5" ) << QStringToQBitArray("0")
+ QTest::newRow( "data5" ) << QStringToQBitArray("0")
<< QStringToQBitArray("1");
- QTest::newRow( "data6" ) << QStringToQBitArray("01")
+ QTest::newRow( "data6" ) << QStringToQBitArray("01")
<< QStringToQBitArray("10");
- QTest::newRow( "data7" ) << QStringToQBitArray("1110101")
+ QTest::newRow( "data7" ) << QStringToQBitArray("1110101")
<< QStringToQBitArray("0001010");
- QTest::newRow( "data8" ) << QStringToQBitArray("01110101")
+ QTest::newRow( "data8" ) << QStringToQBitArray("01110101")
<< QStringToQBitArray("10001010");
- QTest::newRow( "data9" ) << QStringToQBitArray("011101010")
+ QTest::newRow( "data9" ) << QStringToQBitArray("011101010")
<< QStringToQBitArray("100010101");
- QTest::newRow( "data10" ) << QStringToQBitArray("0111010101111010")
+ QTest::newRow( "data10" ) << QStringToQBitArray("0111010101111010")
<< QStringToQBitArray("1000101010000101");
}
@@ -520,9 +514,8 @@ void tst_QBitArray::operator_neg()
QFETCH(QBitArray, res);
input = ~input;
-
- QCOMPARE(input, res);
+ QCOMPARE(input, res);
}
void tst_QBitArray::datastream_data()
@@ -553,7 +546,7 @@ void tst_QBitArray::datastream()
QFETCH(QString, bitField);
QFETCH(int, numBits);
QFETCH(int, onBits);
-
+
QBuffer buffer;
QVERIFY(buffer.open(QBuffer::ReadWrite));
QDataStream stream(&buffer);
@@ -565,11 +558,9 @@ void tst_QBitArray::datastream()
}
QCOMPARE(bits.count(), numBits);
-#if QT_VERSION >= 0x040100
QCOMPARE(bits.count(true), onBits);
QCOMPARE(bits.count(false), numBits - onBits);
-#endif
-
+
stream << bits << bits << bits;
buffer.close();
@@ -582,10 +573,8 @@ void tst_QBitArray::datastream()
stream2 >> array1 >> array2 >> array3;
QCOMPARE(array1.count(), numBits);
-#if QT_VERSION >= 0x040100
QCOMPARE(array1.count(true), onBits);
QCOMPARE(array1.count(false), numBits - onBits);
-#endif
QCOMPARE(array1, bits);
QCOMPARE(array2, bits);
@@ -594,7 +583,7 @@ void tst_QBitArray::datastream()
void tst_QBitArray::invertOnNull() const
{
- QBitArray a;
+ QBitArray a;
QCOMPARE(a = ~a, QBitArray());
}
@@ -604,28 +593,28 @@ void tst_QBitArray::operator_noteq_data()
QTest::addColumn<QBitArray>("input2");
QTest::addColumn<bool>("res");
- QTest::newRow("data0") << QStringToQBitArray(QString("11111111"))
- << QStringToQBitArray(QString("00101100"))
+ QTest::newRow("data0") << QStringToQBitArray(QString("11111111"))
+ << QStringToQBitArray(QString("00101100"))
<< true;
- QTest::newRow("data1") << QStringToQBitArray(QString("11011011"))
- << QStringToQBitArray(QString("11011011"))
+ QTest::newRow("data1") << QStringToQBitArray(QString("11011011"))
+ << QStringToQBitArray(QString("11011011"))
<< false;
- QTest::newRow("data2") << QStringToQBitArray(QString())
- << QStringToQBitArray(QString("00101100111"))
+ QTest::newRow("data2") << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString("00101100111"))
<< true;
- QTest::newRow("data3") << QStringToQBitArray(QString())
- << QStringToQBitArray(QString())
+ QTest::newRow("data3") << QStringToQBitArray(QString())
+ << QStringToQBitArray(QString())
<< false;
- QTest::newRow("data4") << QStringToQBitArray(QString("00101100"))
- << QStringToQBitArray(QString("11111111"))
+ QTest::newRow("data4") << QStringToQBitArray(QString("00101100"))
+ << QStringToQBitArray(QString("11111111"))
<< true;
- QTest::newRow("data5") << QStringToQBitArray(QString("00101100111"))
- << QStringToQBitArray(QString())
+ QTest::newRow("data5") << QStringToQBitArray(QString("00101100111"))
+ << QStringToQBitArray(QString())
<< true;
}
diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
index c38fb66747..15cca56ff6 100644
--- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp
@@ -95,10 +95,7 @@ private slots:
void checkedButton();
- // fixed for Qt 4.2.0
-#if QT_VERSION >= 0x040200
void task106609();
-#endif
void task209485_removeFromGroupInEventHandler_data();
void task209485_removeFromGroupInEventHandler();
@@ -211,7 +208,6 @@ void tst_QButtonGroup::arrowKeyNavigation()
void tst_QButtonGroup::exclusiveWithActions()
{
-#if QT_VERSION > 0x040100
QDialog dlg(0);
QHBoxLayout layout(&dlg);
QAction *action1 = new QAction("Action 1", &dlg);
@@ -235,7 +231,7 @@ void tst_QButtonGroup::exclusiveWithActions()
buttonGroup->addButton(toolButton2, 2);
buttonGroup->addButton(toolButton3, 3);
dlg.show();
-
+
QTest::mouseClick(toolButton1, Qt::LeftButton);
QVERIFY(toolButton1->isChecked());
QVERIFY(action1->isChecked());
@@ -251,7 +247,7 @@ void tst_QButtonGroup::exclusiveWithActions()
QVERIFY(!toolButton3->isChecked());
QVERIFY(!action1->isChecked());
QVERIFY(!action3->isChecked());
-
+
QTest::mouseClick(toolButton3, Qt::LeftButton);
QVERIFY(toolButton3->isChecked());
QVERIFY(action3->isChecked());
@@ -259,7 +255,7 @@ void tst_QButtonGroup::exclusiveWithActions()
QVERIFY(!toolButton2->isChecked());
QVERIFY(!action1->isChecked());
QVERIFY(!action2->isChecked());
-
+
QTest::mouseClick(toolButton2, Qt::LeftButton);
QVERIFY(toolButton2->isChecked());
QVERIFY(action2->isChecked());
@@ -267,7 +263,6 @@ void tst_QButtonGroup::exclusiveWithActions()
QVERIFY(!toolButton3->isChecked());
QVERIFY(!action1->isChecked());
QVERIFY(!action3->isChecked());
-#endif
}
void tst_QButtonGroup::exclusive()
@@ -289,7 +284,7 @@ void tst_QButtonGroup::exclusive()
buttonGroup->addButton(pushButton2, 2);
buttonGroup->addButton(pushButton3, 3);
dlg.show();
-
+
QTest::mouseClick(pushButton1, Qt::LeftButton);
QVERIFY(pushButton1->isChecked());
QVERIFY(!pushButton2->isChecked());
@@ -299,12 +294,12 @@ void tst_QButtonGroup::exclusive()
QVERIFY(pushButton2->isChecked());
QVERIFY(!pushButton1->isChecked());
QVERIFY(!pushButton3->isChecked());
-
+
QTest::mouseClick(pushButton3, Qt::LeftButton);
QVERIFY(pushButton3->isChecked());
QVERIFY(!pushButton1->isChecked());
QVERIFY(!pushButton2->isChecked());
-
+
QTest::mouseClick(pushButton2, Qt::LeftButton);
QVERIFY(pushButton2->isChecked());
QVERIFY(!pushButton1->isChecked());
@@ -363,7 +358,6 @@ void tst_QButtonGroup::testSignals()
QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == 23);
}
-#if QT_VERSION >= 0x040200
void tst_QButtonGroup::task106609()
{
// task is:
@@ -403,7 +397,6 @@ void tst_QButtonGroup::task106609()
QCOMPARE(spy2.count(), 2);
QCOMPARE(spy1.count(), 2);
}
-#endif
void tst_QButtonGroup::checkedButton()
{
diff --git a/tests/auto/qbytearraymatcher/qbytearraymatcher.pro b/tests/auto/qbytearraymatcher/qbytearraymatcher.pro
new file mode 100644
index 0000000000..1618c3e18e
--- /dev/null
+++ b/tests/auto/qbytearraymatcher/qbytearraymatcher.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+SOURCES += tst_qbytearraymatcher.cpp
+
+QT = core
diff --git a/tests/auto/qbytearraymatcher/tst_qbytearraymatcher.cpp b/tests/auto/qbytearraymatcher/tst_qbytearraymatcher.cpp
new file mode 100644
index 0000000000..c3f2fd97aa
--- /dev/null
+++ b/tests/auto/qbytearraymatcher/tst_qbytearraymatcher.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qbytearraymatcher.h>
+
+class tst_QByteArrayMatcher : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void interface();
+ void task251958();
+};
+
+static QByteArrayMatcher matcher1;
+
+void tst_QByteArrayMatcher::interface()
+{
+ const char needle[] = "abc123";
+ QByteArray haystack(500, 'a');
+ haystack.insert(6, "123");
+ haystack.insert(31, "abc");
+ haystack.insert(42, "abc123");
+ haystack.insert(84, "abc123");
+
+ matcher1 = QByteArrayMatcher(QByteArray(needle));
+ QByteArrayMatcher matcher2;
+ matcher2.setPattern(QByteArray(needle));
+
+ QByteArrayMatcher matcher3 = QByteArrayMatcher(QByteArray(needle));
+ QByteArrayMatcher matcher4(needle, sizeof(needle - 1));
+ QByteArrayMatcher matcher5(matcher2);
+ QByteArrayMatcher matcher6;
+ matcher6 = matcher3;
+
+ QCOMPARE(matcher1.indexIn(haystack), 42);
+ QCOMPARE(matcher2.indexIn(haystack), 42);
+ QCOMPARE(matcher3.indexIn(haystack), 42);
+ QCOMPARE(matcher4.indexIn(haystack), 42);
+ QCOMPARE(matcher5.indexIn(haystack), 42);
+ QCOMPARE(matcher6.indexIn(haystack), 42);
+
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length()), 42);
+
+ QCOMPARE(matcher1.indexIn(haystack, 43), 84);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 43), 84);
+ QCOMPARE(matcher1.indexIn(haystack, 85), -1);
+ QCOMPARE(matcher1.indexIn(haystack.constData(), haystack.length(), 85), -1);
+
+ QByteArrayMatcher matcher7(QByteArray("123"));
+ QCOMPARE(matcher7.indexIn(haystack), 6);
+
+ matcher7 = QByteArrayMatcher(QByteArray("abc"));
+ QCOMPARE(matcher7.indexIn(haystack), 31);
+
+ matcher7.setPattern(matcher4.pattern());
+ QCOMPARE(matcher7.indexIn(haystack), 42);
+}
+
+
+static QByteArrayMatcher matcher;
+
+void tst_QByteArrayMatcher::task251958()
+{
+ const char p_data[] = { 0x0, 0x0, 0x1 };
+ QByteArray pattern(p_data, sizeof(p_data));
+
+ QByteArray haystack(8, '\0');
+ haystack[7] = 0x1;
+
+ matcher = QByteArrayMatcher(pattern);
+ QCOMPARE(matcher.indexIn(haystack, 0), 5);
+ QCOMPARE(matcher.indexIn(haystack, 1), 5);
+ QCOMPARE(matcher.indexIn(haystack, 2), 5);
+
+ matcher.setPattern(pattern);
+ QCOMPARE(matcher.indexIn(haystack, 0), 5);
+ QCOMPARE(matcher.indexIn(haystack, 1), 5);
+ QCOMPARE(matcher.indexIn(haystack, 2), 5);
+}
+
+QTEST_APPLESS_MAIN(tst_QByteArrayMatcher)
+#include "tst_qbytearraymatcher.moc"
diff --git a/tests/auto/qcache/tst_qcache.cpp b/tests/auto/qcache/tst_qcache.cpp
index f0d045450b..2b61467ff5 100644
--- a/tests/auto/qcache/tst_qcache.cpp
+++ b/tests/auto/qcache/tst_qcache.cpp
@@ -39,10 +39,8 @@
**
****************************************************************************/
-
#include <QtTest/QtTest>
-
#include <qcache.h>
//TESTED_CLASS=
@@ -56,7 +54,6 @@ public:
tst_QCache();
virtual ~tst_QCache();
-
public slots:
void initTestCase();
void cleanupTestCase();
@@ -344,7 +341,7 @@ void tst_QCache::remove()
QCOMPARE(cache.totalCost(), 20);
}
- cache.setMaxCost(1);
+ cache.setMaxCost(1);
QCOMPARE(cache.size(), 0);
cache.remove("beta");
QCOMPARE(cache.size(), 0);
@@ -377,7 +374,7 @@ void tst_QCache::take()
QCOMPARE(cache.size(), 1);
QCOMPARE(cache.totalCost(), 20);
- cache.setMaxCost(1);
+ cache.setMaxCost(1);
QCOMPARE(cache.size(), 0);
QCOMPARE(cache.take("beta"), (Foo*)0);
QCOMPARE(cache.size(), 0);
@@ -389,15 +386,8 @@ struct KeyType
KeyType(int x) : foo(x) {}
- /*
- Qt 4.0 and 4.1 require a default ctor and an operator=().
- */
-#if QT_VERSION < 0x040200
- KeyType() : foo(0) {}
-#else
private:
KeyType &operator=(const KeyType &);
-#endif
};
struct ValueType
diff --git a/tests/auto/qcheckbox/tst_qcheckbox.cpp b/tests/auto/qcheckbox/tst_qcheckbox.cpp
index be1095a2a1..9ffeb07043 100644
--- a/tests/auto/qcheckbox/tst_qcheckbox.cpp
+++ b/tests/auto/qcheckbox/tst_qcheckbox.cpp
@@ -377,10 +377,8 @@ void tst_QCheckBox::onStateChanged( int state )
void tst_QCheckBox::stateChanged()
{
-#if QT_VERSION > 0x040101
QSignalSpy stateChangedSpy(testWidget, SIGNAL(stateChanged(int)));
-#endif
- connect(testWidget, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
+ connect(testWidget, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
cur_state = -1;
testWidget->setChecked( TRUE );
qApp->processEvents();
@@ -396,12 +394,10 @@ void tst_QCheckBox::stateChanged()
qApp->processEvents();
QCOMPARE( cur_state, (int)1 );
-#if QT_VERSION > 0x040101
QCOMPARE(stateChangedSpy.count(), 3);
testWidget->setCheckState(Qt::PartiallyChecked);
qApp->processEvents();
QCOMPARE(stateChangedSpy.count(), 3);
-#endif
}
void tst_QCheckBox::isToggleButton()
diff --git a/tests/auto/qcolordialog/tst_qcolordialog.cpp b/tests/auto/qcolordialog/tst_qcolordialog.cpp
index e51dfcc4c5..1b5babb632 100644
--- a/tests/auto/qcolordialog/tst_qcolordialog.cpp
+++ b/tests/auto/qcolordialog/tst_qcolordialog.cpp
@@ -108,7 +108,7 @@ void tst_QColorDialog::native_activeModalWidget()
// color dialog when it is executing, even when using a native
// dialog:
TestNativeDialog d;
- QTimer::singleShot(100, &d, SLOT(hide()));
+ QTimer::singleShot(1000, &d, SLOT(hide()));
d.exec();
QVERIFY(&d == d.m_activeModalWidget);
}
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 223f4bc49f..e8814969ee 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -56,6 +56,7 @@
#include <qlistwidget.h>
#include <qtreewidget.h>
#include <qtablewidget.h>
+#include <qscrollbar.h>
#ifdef Q_WS_MAC
#include <qmacstyle_mac.h>
#elif defined Q_WS_X11
@@ -138,6 +139,8 @@ private slots:
void task248169_popupWithMinimalSize();
void task247863_keyBoardSelection();
void setModelColumn();
+ void noScrollbar_data();
+ void noScrollbar();
protected slots:
void onEditTextChanged( const QString &newString );
@@ -280,13 +283,9 @@ void tst_QComboBox::getSetCheck()
QLineEdit *var8 = new QLineEdit(0);
obj1.setLineEdit(var8);
QCOMPARE(var8, obj1.lineEdit());
-#if QT_VERSION >= 0x040200
- // QComboBox in Qt < 4.2 have asserts for this, but handles the situation by ignoring it.
- // Qt >= 4.2 should handle this gracefully (no asserts, but define behavior as keeping current)
QTest::ignoreMessage(QtWarningMsg, "QComboBox::setLineEdit: cannot set a 0 line edit");
obj1.setLineEdit((QLineEdit *)0);
QCOMPARE(var8, obj1.lineEdit());
-#endif
// delete var8; // No delete, since QComboBox takes ownership
// const QValidator * QComboBox::validator()
@@ -303,13 +302,9 @@ void tst_QComboBox::getSetCheck()
MyAbstractItemDelegate *var10 = new MyAbstractItemDelegate;
obj1.setItemDelegate(var10);
QCOMPARE(obj1.itemDelegate(), (QAbstractItemDelegate *)var10);
-#if QT_VERSION >= 0x040200
- // QComboBox in Qt < 4.2 have asserts for this, but handles the situation by ignoring it.
- // Qt >= 4.2 should handle this gracefully (no asserts, but define behavior as keeping current)
QTest::ignoreMessage(QtWarningMsg, "QComboBox::setItemDelegate: cannot set a 0 delegate");
obj1.setItemDelegate((QAbstractItemDelegate *)0);
QCOMPARE(obj1.itemDelegate(), (QAbstractItemDelegate *)var10);
-#endif
// delete var10; // No delete, since QComboBox takes ownership
// QAbstractItemModel * QComboBox::model()
@@ -317,13 +312,9 @@ void tst_QComboBox::getSetCheck()
MyAbstractItemModel *var11 = new MyAbstractItemModel;
obj1.setModel(var11);
QCOMPARE(obj1.model(), (QAbstractItemModel *)var11);
-#if QT_VERSION >= 0x040200
- // QComboBox in Qt < 4.2 have asserts for this, but handles the situation by ignoring it.
- // Qt >= 4.2 should handle this gracefully (no asserts, but define behavior as keeping current)
QTest::ignoreMessage(QtWarningMsg, "QComboBox::setModel: cannot set a 0 model");
obj1.setModel((QAbstractItemModel *)0);
QCOMPARE(obj1.model(), (QAbstractItemModel *)var11);
-#endif
delete var11;
obj1.model();
@@ -342,13 +333,9 @@ void tst_QComboBox::getSetCheck()
MyAbstractItemView *var13 = new MyAbstractItemView;
obj1.setView(var13);
QCOMPARE(obj1.view(), (QAbstractItemView *)var13);
-#if QT_VERSION >= 0x040200
- // QComboBox in Qt < 4.2 have asserts for this
- // Qt >= 4.2 should handle this gracefully (no asserts, but define behavior as keeping current view)
QTest::ignoreMessage(QtWarningMsg, "QComboBox::setView: cannot set a 0 view");
obj1.setView((QAbstractItemView *)0);
QCOMPARE(obj1.view(), (QAbstractItemView *)var13);
-#endif
delete var13;
// int QComboBox::currentIndex()
@@ -509,13 +496,9 @@ void tst_QComboBox::sizeAdjustPolicy()
testWidget->addItem("small");
QCOMPARE(testWidget->sizeHint(), content);
testWidget->addItem("looooooooooooooooooooooong item");
-#if QT_VERSION >= 0x040200
// minimumContentsLength() > sizeof("looooooooooooooooooooooong item"), so the sizeHint()
// stays the same
QCOMPARE(testWidget->sizeHint(), content);
-#else
- QVERIFY(testWidget->sizeHint().width() > content.width());
-#endif
// over 60 characters (cf. setMinimumContentsLength() call above)
testWidget->addItem("loooooooooooooooooooooooooooooooooooooooooooooo"
"ooooooooooooooooooooooooooooooooooooooooooooooo"
@@ -532,10 +515,8 @@ void tst_QComboBox::sizeAdjustPolicy()
content = testWidget->sizeHint();
while (testWidget->count())
testWidget->removeItem(0);
-#if QT_VERSION >= 0x040200
QCOMPARE(testWidget->sizeHint(), content);
testWidget->setMinimumContentsLength(0);
-#endif
QVERIFY(testWidget->sizeHint().width() < content.width());
}
@@ -828,13 +809,9 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
QTest::keyClick(testWidget->lineEdit(), Qt::Key_B);
qApp->processEvents();
-#if QT_VERSION < 0x040200
- // autocompletions are case-preserving in < 4.2
- QCOMPARE(testWidget->currentText(), QString("aBCDEF"));
-#else
// autocompletions preserve userkey-case from 4.2
QCOMPARE(testWidget->currentText(), QString("abCDEF"));
-#endif
+
QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
qApp->processEvents();
QCOMPARE(testWidget->currentText(), QString("aBCDEF")); // case restored to item's case
@@ -2132,7 +2109,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize()
QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&comboBox);
QVERIFY(container);
- QVERIFY(desktop.availableGeometry().contains(container->geometry()));
+ QVERIFY(desktop.screenGeometry(container).contains(container->geometry()));
}
void tst_QComboBox::task247863_keyBoardSelection()
@@ -2181,5 +2158,56 @@ void tst_QComboBox::setModelColumn()
QCOMPARE(box.currentText(), QString("zero"));
}
+void tst_QComboBox::noScrollbar_data()
+{
+ QTest::addColumn<QString>("stylesheet");
+
+ QTest::newRow("normal") << QString();
+ QTest::newRow("border") << QString::fromLatin1("QAbstractItemView { border: 12px solid blue;}");
+ QTest::newRow("margin") << QString::fromLatin1("QAbstractItemView { margin: 12px 15px 13px 10px; }");
+ QTest::newRow("padding") << QString::fromLatin1("QAbstractItemView { padding: 12px 15px 13px 10px;}");
+ QTest::newRow("everything") << QString::fromLatin1("QAbstractItemView { border: 12px solid blue; "
+ " padding: 12px 15px 13px 10px; margin: 12px 15px 13px 10px; }");
+ QTest::newRow("everything and more") << QString::fromLatin1("QAbstractItemView { border: 1px 3px 5px 1px solid blue; "
+ " padding: 2px 5px 3px 1px; margin: 2px 5px 3px 1px; } "
+ " QAbstractItemView::item { border: 2px solid green; "
+ " padding: 1px 1px 2px 2px margin: 1px; } " );
+}
+
+void tst_QComboBox::noScrollbar()
+{
+ QStringList initialContent;
+ initialContent << "foo" << "bar" << "foobar" << "moo";
+ QFETCH(QString, stylesheet);
+
+ {
+ QComboBox comboBox;
+ comboBox.setStyleSheet(stylesheet);
+ comboBox.addItems(initialContent);
+ comboBox.show();
+ comboBox.resize(200, comboBox.height());
+ QTest::qWait(100);
+ comboBox.showPopup();
+ QTest::qWait(100);
+ QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
+ QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
+ }
+
+ {
+ QTableWidget *table = new QTableWidget(2,2);
+ QComboBox comboBox;
+ comboBox.setStyleSheet(stylesheet);
+ comboBox.setView(table);
+ comboBox.setModel(table->model());
+ comboBox.show();
+ QTest::qWait(100);
+ comboBox.resize(200, comboBox.height());
+ comboBox.showPopup();
+ QTest::qWait(100);
+ QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
+ QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
+ }
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
index 5665e6e60e..45a430185e 100644
--- a/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+++ b/tests/auto/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
@@ -211,11 +211,7 @@ void tst_QCommandLinkButton::setAutoRepeat()
QVERIFY( !testWidget->isCheckable() );
// verify autorepeat is off by default.
-#if QT_VERSION < 0x040000
- QButton tmp( 0 );
-#else
QCommandLinkButton tmp( 0 );
-#endif
tmp.setObjectName("tmp");
QVERIFY( !tmp.autoRepeat() );
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 3daa3a0130..f6f1a074e0 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -140,6 +140,8 @@ private slots:
// task-specific tests below me
void task178797_activatedOnReturn();
void task189564_omitNonSelectableItems();
+ void task246056_setCompletionPrefix();
+ void task250064_lostFocus();
private:
void filter();
@@ -1096,5 +1098,94 @@ void tst_QCompleter::task189564_omitNonSelectableItems()
QVERIFY(matches2.isEmpty());
}
+class task246056_ComboBox : public QComboBox
+{
+ Q_OBJECT
+public:
+ task246056_ComboBox()
+ {
+ setEditable(true);
+ setInsertPolicy(NoInsert);
+ Q_ASSERT(completer());
+ completer()->setCompletionMode(QCompleter::PopupCompletion);
+ completer()->setCompletionRole(Qt::DisplayRole);
+ connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
+ }
+private slots:
+ void setCompletionPrefix() { completer()->setCompletionPrefix(lineEdit()->text()); }
+};
+
+void tst_QCompleter::task246056_setCompletionPrefix()
+{
+ task246056_ComboBox *comboBox = new task246056_ComboBox;
+ comboBox->addItem("");
+ comboBox->addItem("a1");
+ comboBox->addItem("a2");
+ comboBox->show();
+ comboBox->setFocus();
+ QTest::qWait(100);
+ QTest::keyPress(comboBox, 'a');
+ QTest::keyPress(comboBox->completer()->popup(), Qt::Key_Down);
+ QTest::keyPress(comboBox->completer()->popup(), Qt::Key_Down);
+ QTest::keyPress(comboBox->completer()->popup(), Qt::Key_Enter); // don't crash!
+}
+
+class task250064_TextEdit : public QTextEdit
+{
+public:
+ QCompleter *completer;
+
+ task250064_TextEdit()
+ {
+ completer = new QCompleter;
+ completer->setWidget(this);
+ }
+
+ void keyPressEvent (QKeyEvent *e)
+ {
+ completer->popup();
+ QTextEdit::keyPressEvent(e);
+ }
+};
+
+class task250064_Widget : public QWidget
+{
+ Q_OBJECT
+public:
+ task250064_TextEdit *textEdit;
+
+ task250064_Widget(task250064_TextEdit *textEdit)
+ : textEdit(textEdit)
+ {
+ QTabWidget *tabWidget = new QTabWidget;
+ tabWidget->setFocusPolicy(Qt::ClickFocus);
+ tabWidget->addTab(textEdit, "untitled");
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(tabWidget);
+
+ textEdit->setPlainText("bla bla bla");
+ textEdit->setFocus();
+ }
+
+ void setCompletionModel()
+ {
+ textEdit->completer->setModel(0);
+ }
+};
+
+void tst_QCompleter::task250064_lostFocus()
+{
+ task250064_TextEdit *textEdit = new task250064_TextEdit;
+ task250064_Widget *widget = new task250064_Widget(textEdit);
+ widget->show();
+ QTest::qWait(100);
+ QTest::keyPress(textEdit, 'a');
+ Qt::FocusPolicy origPolicy = textEdit->focusPolicy();
+ QVERIFY(origPolicy != Qt::NoFocus);
+ widget->setCompletionModel();
+ QCOMPARE(textEdit->focusPolicy(), origPolicy);
+}
+
QTEST_MAIN(tst_QCompleter)
#include "tst_qcompleter.moc"
diff --git a/tests/auto/qcssparser/tst_cssparser.cpp b/tests/auto/qcssparser/tst_cssparser.cpp
index 10a17de981..c3397ea1be 100644
--- a/tests/auto/qcssparser/tst_cssparser.cpp
+++ b/tests/auto/qcssparser/tst_cssparser.cpp
@@ -44,7 +44,6 @@
//TESTED_CLASS=QCss
//TESTED_FILES=gui/text/qcssparser.cpp gui/text/qcssparser_p.h
-#if QT_VERSION >= 0x040200
#include "private/qcssparser_p.h"
class tst_CssParser : public QObject
@@ -272,7 +271,7 @@ void tst_CssParser::term_data()
val.variant = QVariant(QColor("#ffbb00"));
QTest::newRow("hexcolor2") << true << "#fb0" << val;
- QTest::ignoreMessage(QtWarningMsg, "QColor::setNamedColor: Could not parse color '#cafebabe'");
+ QTest::ignoreMessage(QtWarningMsg, "QCssParser::parseHexColor: Unknown color name '#cafebabe'");
QTest::newRow("hexcolor_failure") << false << "#cafebabe" << val;
val.type = QCss::Value::Uri;
@@ -1592,13 +1591,13 @@ void tst_CssParser::quotedAndUnquotedIdentifiers()
QCss::Parser parser("foo { font-style: \"italic\"; font-weight: bold }");
QCss::StyleSheet sheet;
QVERIFY(parser.parse(&sheet));
-
+
QCOMPARE(sheet.styleRules.count() + sheet.nameIndex.count(), 1);
QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
sheet.styleRules.at(0) : *sheet.nameIndex.begin();
const QVector<QCss::Declaration> decls = rule.declarations;
QCOMPARE(decls.size(), 2);
-
+
QCOMPARE(decls.at(0).d->values.first().type, QCss::Value::String);
QCOMPARE(decls.at(0).d->property, QLatin1String("font-style"));
QCOMPARE(decls.at(0).d->values.first().toString(), QLatin1String("italic"));
@@ -1610,6 +1609,3 @@ void tst_CssParser::quotedAndUnquotedIdentifiers()
QTEST_MAIN(tst_CssParser)
#include "tst_cssparser.moc"
-#else
-QTEST_NOOP_MAIN
-#endif
diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp
index 2ee4277d60..544c8c314e 100644
--- a/tests/auto/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/qdatastream/tst_qdatastream.cpp
@@ -170,10 +170,8 @@ private slots:
void setVersion_data();
void setVersion();
-#if QT_VERSION >= 0x040100
void skipRawData_data();
void skipRawData();
-#endif
void status_qint8_data();
void status_qint8();
@@ -2442,7 +2440,6 @@ private:
int offset;
};
-#if QT_VERSION >= 0x040100
void tst_QDataStream::skipRawData_data()
{
QTest::addColumn<QString>("deviceType");
@@ -2493,7 +2490,6 @@ void tst_QDataStream::skipRawData()
delete dev;
}
-#endif
#define TEST_qint(T, UT) \
void tst_QDataStream::status_##T() \
diff --git a/tests/auto/qdate/tst_qdate.cpp b/tests/auto/qdate/tst_qdate.cpp
index 121167a2db..d4273d0e67 100644
--- a/tests/auto/qdate/tst_qdate.cpp
+++ b/tests/auto/qdate/tst_qdate.cpp
@@ -143,10 +143,8 @@ void tst_QDate::isValid_data()
QTest::newRow("century leap") << 2100 << 2 << 29 << 0U << false;
QTest::newRow("400-years leap") << 2000 << 2 << 29 << 2451604U << true;
QTest::newRow("400-years leap 2") << 2400 << 2 << 29 << 2597701U << true;
-#if QT_VERSION >= 0x040200
QTest::newRow("400-years leap 3") << 1600 << 2 << 29 << 2305507U << true;
QTest::newRow("year 0") << 0 << 2 << 27 << 0U << false;
-#endif
// test the number of days in months:
QTest::newRow("jan") << 2000 << 1 << 31 << 2451575U << true;
@@ -177,7 +175,6 @@ void tst_QDate::isValid_data()
QTest::newRow("idec") << 2000 << 12 << 32 << 0U << false;
// the beginning of the Julian Day calendar:
-#if QT_VERSION >= 0x040200
QTest::newRow("jd negative1") << -4714 << 1 << 1 << 0U << false;
QTest::newRow("jd negative2") << -4713 << 1 << 1 << 0U << false;
QTest::newRow("jd negative3") << -4713 << 1 << 2 << 1U << true;
@@ -185,7 +182,6 @@ void tst_QDate::isValid_data()
QTest::newRow("jd 0") << -4713 << 1 << 1 << 0U << false;
QTest::newRow("jd 1") << -4713 << 1 << 2 << 1U << true;
QTest::newRow("imminent overflow") << 11754508 << 12 << 13 << 4294967295U << true;
-#endif
}
void tst_QDate::isValid()
@@ -243,17 +239,12 @@ void tst_QDate::weekNumber_data()
QTest::newRow( "data4" ) << 1 << 2001 << 2001 << 1 << 1;
QTest::newRow( "data5" ) << 53 << 1998 << 1998 << 12 << 31;
QTest::newRow( "data6" ) << 1 << 1985 << 1984 << 12 << 31;
-#if QT_VERSION >= 0x030300
- // This is a bug that was fixed for 3.3
QTest::newRow( "data7" ) << 52 << 2006 << 2006 << 12 << 31;
-#endif
}
void tst_QDate::weekNumber()
{
-#if QT_VERSION >= 0x030100
int yearNumber;
-// int weekNumber;
QFETCH( int, year );
QFETCH( int, month );
QFETCH( int, day );
@@ -262,9 +253,6 @@ void tst_QDate::weekNumber()
QDate dt1( year, month, day );
QCOMPARE( dt1.weekNumber( &yearNumber ), expectedWeekNum );
QCOMPARE( yearNumber, expectedYearNum );
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-#endif
}
void tst_QDate::weekNumber_invalid_data()
@@ -281,14 +269,9 @@ void tst_QDate::weekNumber_invalid_data()
void tst_QDate::weekNumber_invalid()
{
-#if QT_VERSION >= 0x030100
QDate dt;
int yearNumber;
-// int weekNumber;
QCOMPARE( dt.weekNumber( &yearNumber ), 0 );
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-#endif
}
void tst_QDate::addDays()
@@ -616,14 +599,12 @@ void tst_QDate::fromString_data()
QDate d( 1999, 11, 14 );
QTest::newRow( "data2" ) << d.toString( Qt::TextDate ) << d.toString( Qt::ISODate ) << d;
-#if QT_VERSION >= 0x040200
QTest::newRow( "data3" ) << QString("xxx Jan 1 0999") << QString("0999-01-01") << QDate(999, 1, 1);
QTest::newRow( "data3b" ) << QString("xxx Jan 1 999") << QString("0999-01-01") << QDate(999, 1, 1);
QTest::newRow( "data4" ) << QString("xxx Jan 1 12345") << QString() << QDate(12345, 1, 1);
QTest::newRow( "data5" ) << QString("xxx Jan 1 -0001") << QString() << QDate(-1, 1, 1);
QTest::newRow( "data6" ) << QString("xxx Jan 1 -4712") << QString() << QDate(-4712, 1, 1);
QTest::newRow( "data7" ) << QString("xxx Nov 25 -4713") << QString() << QDate(-4713, 11, 25);
-#endif
}
void tst_QDate::fromString()
@@ -647,9 +628,7 @@ void tst_QDate::toString_format_data()
QTest::newRow( "data1" ) << QDate(2002,12,17) << QString("dd-MM-yyyy") << QString("17-12-2002");
QTest::newRow( "data2" ) << QDate(1995,5,20) << QString("M-yy") << QString("5-95");
QTest::newRow( "data3" ) << QDate(2002,12,17) << QString("dd") << QString("17");
-#if (QT_VERSION-0 >= 0x030200)
QTest::newRow( "data4" ) << QDate() << QString("dd-mm-yyyy") << QString();
-#endif
}
void tst_QDate::toString_format()
diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp
index 2e60aaa4e2..2f01d19a47 100644
--- a/tests/auto/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/qdatetime/tst_qdatetime.cpp
@@ -220,18 +220,10 @@ void tst_QDateTime::isNull()
dt1.setDate(QDate(2004, 1, 2));
QVERIFY(!dt1.isNull());
-#if QT_VERSION < 0x040100
- dt1.setDate(QDate());
- QVERIFY(dt1.isNull());
-#endif
dt1.setTime(QTime(12, 34, 56));
QVERIFY(!dt1.isNull());
dt1.setTime(QTime());
-#if QT_VERSION >= 0x040100
QVERIFY(!dt1.isNull());
-#else
- QVERIFY(dt1.isNull());
-#endif
}
void tst_QDateTime::isValid()
@@ -1010,15 +1002,10 @@ void tst_QDateTime::toString_strformat_data()
void tst_QDateTime::toString_strformat()
{
-#if (QT_VERSION-0 >= 0x030200)
QFETCH( QDateTime, dt );
QFETCH( QString, format );
QFETCH( QString, str );
QCOMPARE( dt.toString( format ), str );
-#else
- QSKIP( "No test implemented for < 3.2 yet", SkipAll);
-#endif
-
}
void tst_QDateTime::fromStringTextDate_data()
@@ -1068,7 +1055,6 @@ void tst_QDateTime::fromStringTextDate_data()
<< 28 << 6 << 2005 << 7 << 57 << 30 << 110
<< int(Qt::LocalTime);
-#if QT_VERSION >= 0x040200
QTest::newRow("Year 0999") << QString("Tue Jun 17 08:00:10 0999")
<< int(Qt::TextDate)
<< 17 << 6 << 999 << 8 << 0 << 10 << 0
@@ -1088,7 +1074,6 @@ void tst_QDateTime::fromStringTextDate_data()
<< int(Qt::TextDate)
<< 1 << 1 << -4712 << 0 << 01 << 02 << 0
<< int(Qt::LocalTime);
-#endif
}
void tst_QDateTime::fromStringTextDate()
diff --git a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp
index f1838b9792..467ae666e4 100644
--- a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp
+++ b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp
@@ -41,9 +41,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
#include <QStandardItemModel>
#include <qdebug.h>
#include <qdesktopservices.h>
@@ -375,5 +372,3 @@ void tst_qdesktopservices::storageLocationDoesNotEndWithSlash()
QTEST_MAIN(tst_qdesktopservices)
#include "tst_qdesktopservices.moc"
-#endif
-
diff --git a/tests/auto/qdialog/tst_qdialog.cpp b/tests/auto/qdialog/tst_qdialog.cpp
index e77167eb6f..a1cf1c1eb8 100644
--- a/tests/auto/qdialog/tst_qdialog.cpp
+++ b/tests/auto/qdialog/tst_qdialog.cpp
@@ -375,14 +375,11 @@ void tst_QDialog::showAsTool()
testWidget->activateWindow();
dialog.exec();
QTest::qWait(100);
- if (testWidget->style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, testWidget)) {
-#if defined(Q_WS_QWS) && QT_VERSION < 0x040400
- QEXPECT_FAIL(0, "Qtopia Core has messed up WStyle_Tool (task 126435)", Continue);
-#endif
- QCOMPARE(dialog.wasActive(), true);
- } else {
- QCOMPARE(dialog.wasActive(), false);
- }
+ if (testWidget->style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, testWidget)) {
+ QCOMPARE(dialog.wasActive(), true);
+ } else {
+ QCOMPARE(dialog.wasActive(), false);
+ }
}
// Verify that pos() returns the same before and after show()
@@ -392,10 +389,10 @@ void tst_QDialog::toolDialogPosition()
#if defined(Q_OS_WINCE)
QSKIP("No real support for Qt::Tool on WinCE", SkipAll);
#endif
- QDialog dialog(0, Qt::Tool);
- dialog.move(QPoint(100,100));
+ QDialog dialog(0, Qt::Tool);
+ dialog.move(QPoint(100,100));
const QPoint beforeShowPosition = dialog.pos();
- dialog.show();
+ dialog.show();
const QPoint afterShowPosition = dialog.pos();
QCOMPARE(afterShowPosition, beforeShowPosition);
}
@@ -445,7 +442,7 @@ public slots:
void tst_QDialog::throwInExec()
{
#ifdef Q_WS_MAC
- QSKIP("Qt/Mac: Throwing exceptions in excec() is not supported.", SkipAll);
+ QSKIP("Qt/Mac: Throwing exceptions in exec() is not supported.", SkipAll);
#endif
int caughtExceptions = 0;
try {
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp
index 7a33f4abce..19fee409fe 100644
--- a/tests/auto/qdir/tst_qdir.cpp
+++ b/tests/auto/qdir/tst_qdir.cpp
@@ -848,9 +848,7 @@ void tst_QDir::cd_data()
#endif
QTest::newRow("non existant") << "." << "../anonexistingdir" << false << QDir::currentPath();
QTest::newRow("self") << "." << (QString("../") + QFileInfo(QDir::currentPath()).fileName()) << true << QDir::currentPath();
-#if QT_VERSION > 0x040100
QTest::newRow("file") << "." << "qdir.pro" << false << "";
-#endif
}
void tst_QDir::cd()
@@ -888,10 +886,8 @@ void tst_QDir::setNameFilters_data()
<< QString("foo. bar,foo.bar").split(",");
QTest::newRow("files1") << appPath + "testdir/dir" << QString("*r.cpp *.pro").split(" ")
<< QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(",");
-#if QT_VERSION >= 0x040000
QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data")
<< QString("file1.data,file2.data,file3.data").split(',');
-#endif
}
void tst_QDir::setNameFilters()
diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp
index 567ec9e883..c4ff046183 100644
--- a/tests/auto/qdirmodel/tst_qdirmodel.cpp
+++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp
@@ -628,7 +628,6 @@ void tst_QDirModel::task196768_sorting()
QCOMPARE(index.data(), index2.data());
}
-#if QT_VERSION >= 0x040102
void tst_QDirModel::filter()
{
QDirModel model;
@@ -639,7 +638,6 @@ void tst_QDirModel::filter()
Q_ASSERT(!index2.isValid());
Q_ASSERT(model.rowCount(index) == 0);
}
-#endif
void tst_QDirModel::task244669_remove()
{
diff --git a/tests/auto/qfile/rename-fallback.qrc b/tests/auto/qfile/rename-fallback.qrc
new file mode 100644
index 0000000000..c8a894a61d
--- /dev/null
+++ b/tests/auto/qfile/rename-fallback.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>rename-fallback.qrc</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro
index e9f8d7cc1b..b51eff6d7b 100644
--- a/tests/auto/qfile/test/test.pro
+++ b/tests/auto/qfile/test/test.pro
@@ -23,7 +23,7 @@ wince*:{
DEFINES += SRCDIR=\\\"$$PWD/../\\\"
}
-RESOURCES += ../qfile.qrc
+RESOURCES += ../qfile.qrc ../rename-fallback.qrc
TARGET = ../tst_qfile
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 8f0e3f6d50..483e978406 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -79,10 +79,6 @@
# define SRCDIR ""
#endif
-#if QT_VERSION < 0x040200
-#define symLinkTarget readLink
-#endif
-
Q_DECLARE_METATYPE(QFile::FileError)
//TESTED_CLASS=
@@ -172,6 +168,8 @@ private slots:
void rename_data();
void rename();
void renameWithAtEndSpecialFile() const;
+ void renameFallback();
+ void renameMultiple();
void appendAndRead();
void miscWithUncPathAsCurrentDir();
void standarderror();
@@ -217,6 +215,14 @@ void tst_QFile::cleanup()
{
// TODO: Add cleanup code here.
// This will be executed immediately after each test is run.
+
+ // for renameFallback()
+ QFile::remove("file-rename-destination.txt");
+
+ // for renameMultiple()
+ QFile::remove("file-to-be-renamed.txt");
+ QFile::remove("file-renamed-once.txt");
+ QFile::remove("file-renamed-twice.txt");
}
void tst_QFile::initTestCase()
@@ -994,12 +1000,8 @@ void tst_QFile::link()
#ifdef Q_OS_WIN // on windows links are always absolute
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#else
-#if QT_VERSION < 0x040101
- QCOMPARE(info2.symLinkTarget(), info1.filePath());
-#else
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#endif
-#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath());
@@ -1075,19 +1077,12 @@ void tst_QFile::readBrokenLink()
#ifdef Q_OS_WIN // on windows links are alway absolute
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#else
-#if QT_VERSION < 0x040101
- QCOMPARE(info2.symLinkTarget(), info1.filePath());
-#else
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#endif
-#endif
QVERIFY(QFile::remove(info2.absoluteFilePath()));
-
-#if QT_VERSION >= 0x040101 && !defined(Q_OS_SYMBIAN)
QVERIFY(QFile::link("ole/..", "myLink2.lnk"));
QCOMPARE(QFileInfo("myLink2.lnk").symLinkTarget(), QDir::currentPath());
-#endif
}
void tst_QFile::readTextFile_data()
@@ -1295,10 +1290,6 @@ void tst_QFile::bufferedRead()
QCOMPARE(file.pos(), qlonglong(2));
}
-#if QT_VERSION <= 0x040100
- QCOMPARE(int(ftell(stdFile)), 2);
-#endif
-
fclose(stdFile);
}
@@ -1618,12 +1609,7 @@ void tst_QFile::longFileName()
}
{
QFile file(fileName);
-#if QT_VERSION < 0x040100
-# ifdef Q_OS_WIN
- QEXPECT_FAIL("244 chars", "Fixed in 4.1", Continue);
- QEXPECT_FAIL("244 chars to absolutepath", "Fixed in 4.1", Continue);
-# endif
-#elif defined(Q_WS_WIN)
+#if defined(Q_WS_WIN)
#if !defined(Q_OS_WINCE)
QT_WA({ if (false) ; }, {
QEXPECT_FAIL("244 chars", "Full pathname must be less than 260 chars", Abort);
@@ -1852,10 +1838,6 @@ void tst_QFile::removeOpenFile()
void tst_QFile::fullDisk()
{
-#if QT_VERSION < 0x040102
- QSKIP("Fixed for 4.1.2", SkipAll);
-#endif
-
QFile file("/dev/full");
if (!file.exists())
QSKIP("/dev/full doesn't exist on this system", SkipAll);
@@ -1999,9 +1981,7 @@ void tst_QFile::virtualFile()
// read all:
data = f.readAll();
QVERIFY(f.pos() != 0);
-#if QT_VERSION >= 0x040200
QVERIFY(!data.isEmpty());
-#endif
// seeking
QVERIFY(f.seek(1));
@@ -2119,6 +2099,42 @@ void tst_QFile::renameWithAtEndSpecialFile() const
QVERIFY(QFile::rename(newName, originalName));
}
+void tst_QFile::renameFallback()
+{
+ // Using a resource file both to trigger QFile::rename's fallback handling
+ // and as a *read-only* source whose move should fail.
+ QFile file(":/rename-fallback.qrc");
+ QVERIFY(file.exists() && "(test-precondition)");
+ QFile::remove("file-rename-destination.txt");
+
+ QVERIFY(!file.rename("file-rename-destination.txt"));
+ QVERIFY(!QFile::exists("file-rename-destination.txt"));
+}
+
+void tst_QFile::renameMultiple()
+{
+ // create the file if it doesn't exist
+ QFile file("file-to-be-renamed.txt");
+ QVERIFY(file.open(QIODevice::ReadWrite) && "(test-precondition)");
+
+ // any stale files from previous test failures?
+ QFile::remove("file-renamed-once.txt");
+ QFile::remove("file-renamed-twice.txt");
+
+ // begin testing
+ QVERIFY(file.rename("file-renamed-once.txt"));
+ QCOMPARE(file.fileName(), QString("file-renamed-once.txt"));
+ QVERIFY(file.rename("file-renamed-twice.txt"));
+ QCOMPARE(file.fileName(), QString("file-renamed-twice.txt"));
+
+ QVERIFY(!QFile::exists("file-to-be-renamed.txt"));
+ QVERIFY(!QFile::exists("file-renamed-once.txt"));
+ QVERIFY(QFile::exists("file-renamed-twice.txt"));
+
+ file.remove();
+ QVERIFY(!QFile::exists("file-renamed-twice.txt"));
+}
+
void tst_QFile::appendAndRead()
{
QFile writeFile(QLatin1String("appendfile.txt"));
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index 4424ade36f..f554b6f192 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -157,6 +157,8 @@ private slots:
void task228844_ensurePreviousSorting();
void task239706_editableFilterCombo();
void task218353_relativePaths();
+ void task251321_sideBarHiddenEntries();
+ void task251341_sideBarRemoveEntries();
private:
QByteArray userSettings;
@@ -685,6 +687,22 @@ void tst_QFiledialog::filters()
for (int i = views.at(0)->currentIndex(); i < views.at(0)->count(); ++i)
views.at(0)->setCurrentIndex(i);
QCOMPARE(spyFilterSelected.count(), 0);
+
+ //Let check if filters with whitespaces
+ QNonNativeFileDialog fd2;
+ QStringList expected;
+ expected << "C++ Source Files(*.cpp)";
+ expected << "Any(*.*)";
+ fd2.setFilter("C++ Source Files(*.cpp);;Any(*.*)");
+ QCOMPARE(expected, fd2.filters());
+ fd2.setFilter("C++ Source Files(*.cpp) ;;Any(*.*)");
+ QCOMPARE(expected, fd2.filters());
+ fd2.setFilter("C++ Source Files(*.cpp);; Any(*.*)");
+ QCOMPARE(expected, fd2.filters());
+ fd2.setFilter(" C++ Source Files(*.cpp);; Any(*.*)");
+ QCOMPARE(expected, fd2.filters());
+ fd2.setFilter("C++ Source Files(*.cpp) ;; Any(*.*)");
+ QCOMPARE(expected, fd2.filters());
}
void tst_QFiledialog::selectFilter()
@@ -1533,6 +1551,42 @@ private:
};
+class sortProxy : public QSortFilterProxyModel
+{
+public:
+ sortProxy(QObject *parent) : QSortFilterProxyModel(parent)
+ {
+ }
+protected:
+ virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
+ {
+ QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel());
+ const QFileInfo leftInfo(model->fileInfo(left));
+ const QFileInfo rightInfo(model->fileInfo(right));
+
+ if (leftInfo.isDir() == rightInfo.isDir())
+ return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0);
+ else if (leftInfo.isDir())
+ return(false);
+ else
+ return(true);
+ }
+};
+
+class CrashDialog : public QNonNativeFileDialog
+{
+ Q_OBJECT
+
+public:
+ CrashDialog(QWidget *parent, const QString &caption, const
+QString &dir, const QString &filter)
+ : QNonNativeFileDialog(parent, caption, dir, filter)
+ {
+ sortProxy *proxyModel = new sortProxy(this);
+ setProxyModel(proxyModel);
+ }
+};
+
void tst_QFiledialog::task227304_proxyOnFileDialog()
{
QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0);
@@ -1544,6 +1598,17 @@ void tst_QFiledialog::task227304_proxyOnFileDialog()
QTest::keyClick(edit, Qt::Key_S);
QTest::qWait(200);
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
+
+ CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
+ dialog->setFileMode(QFileDialog::ExistingFile);
+ dialog->show();
+
+ QListView *list = qFindChild<QListView*>(dialog, "listView");
+ QTest::qWait(200);
+ QTest::keyClick(list, Qt::Key_Down);
+ QTest::keyClick(list, Qt::Key_Return);
+ QTest::qWait(200);
+
}
void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior()
@@ -1799,5 +1864,119 @@ void tst_QFiledialog::task218353_relativePaths()
appDir.rmdir("test");
}
+void tst_QFiledialog::task251321_sideBarHiddenEntries()
+{
+ QNonNativeFileDialog fd;
+
+ QDir current = QDir::currentPath();
+ current.mkdir(".hidden");
+ QDir hiddenDir = QDir(".hidden");
+ hiddenDir.mkdir("subdir");
+ QDir hiddenSubDir = QDir(".hidden/subdir");
+ hiddenSubDir.mkdir("happy");
+ hiddenSubDir.mkdir("happy2");
+
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
+ fd.setSidebarUrls(urls);
+ fd.show();
+ QTest::qWait(250);
+
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ sidebar->setFocus();
+ sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
+ QTest::qWait(250);
+
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2);
+
+ hiddenSubDir.rmdir("happy2");
+ hiddenSubDir.rmdir("happy");
+ hiddenDir.rmdir("subdir");
+ current.rmdir(".hidden");
+}
+
+class MyQSideBar : public QSidebar
+{
+public :
+ MyQSideBar(QWidget *parent = 0) : QSidebar(parent)
+ {}
+
+ void removeSelection() {
+ QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
+ QList<QPersistentModelIndex> indexes;
+ for (int i = 0; i < idxs.count(); i++)
+ indexes.append(idxs.at(i));
+
+ for (int i = 0; i < indexes.count(); ++i)
+ if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty())
+ model()->removeRow(indexes.at(i).row());
+ }
+};
+
+void tst_QFiledialog::task251341_sideBarRemoveEntries()
+{
+ QNonNativeFileDialog fd;
+
+ QDir current = QDir::currentPath();
+ current.mkdir("testDir");
+ QDir testSubDir = QDir("testDir");
+
+ QList<QUrl> urls;
+ urls << QUrl::fromLocalFile(testSubDir.absolutePath());
+ urls << QUrl::fromLocalFile("NotFound");
+ fd.setSidebarUrls(urls);
+ fd.show();
+ QTest::qWait(250);
+
+ QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar");
+ sidebar->setFocus();
+ //We enter in the first bookmark
+ sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
+ QTest::qWait(250);
+
+ QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
+ //There is no file
+ QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
+ //Icon is not enabled QUrlModel::EnabledRole
+ QVariant value = sidebar->model()->index(0, 0).data(Qt::UserRole + 2);
+ QCOMPARE(qvariant_cast<bool>(value), true);
+
+ sidebar->setFocus();
+ //We enter in the second bookmark which is invalid
+ sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
+ QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
+ QTest::qWait(250);
+
+ //We fallback to root because the entry in the bookmark is invalid
+ QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
+ //Icon is not enabled QUrlModel::EnabledRole
+ value = sidebar->model()->index(1, 0).data(Qt::UserRole + 2);
+ QCOMPARE(qvariant_cast<bool>(value), false);
+
+ MyQSideBar mySideBar;
+ mySideBar.init(model, urls);
+ mySideBar.show();
+ mySideBar.selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
+ QTest::qWait(1000);
+ mySideBar.removeSelection();
+
+ //We remove the first entry
+ QList<QUrl> expected;
+ expected << QUrl::fromLocalFile("NotFound");
+ QCOMPARE(mySideBar.urls(), expected);
+
+ mySideBar.selectUrl(QUrl::fromLocalFile("NotFound"));
+ mySideBar.removeSelection();
+
+ //We remove the second entry
+ expected.clear();
+ QCOMPARE(mySideBar.urls(), expected);
+
+ current.rmdir("testDir");
+}
+
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 6ec782dbfe..963fccc954 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -45,6 +45,7 @@
#include <QFileIconProvider>
#include "../../shared/util.h"
#include <QTime>
+#include <QStyle>
#include <QtGlobal>
#if defined(Q_OS_SYMBIAN)
# include <f32file.h>
@@ -312,6 +313,33 @@ void tst_QFileSystemModel::readOnly()
QVERIFY(model->flags(model->index(file.fileName())) & Qt::ItemIsEditable);
}
+class CustomFileIconProvider : public QFileIconProvider
+{
+public:
+ CustomFileIconProvider() : QFileIconProvider() {
+ mb = qApp->style()->standardIcon(QStyle::SP_MessageBoxCritical);
+ dvd = qApp->style()->standardIcon(QStyle::SP_DriveDVDIcon);
+ }
+
+ virtual QIcon icon(const QFileInfo &info) const
+ {
+ if (info.isDir())
+ return mb;
+
+ return QFileIconProvider::icon(info);
+ }
+ virtual QIcon icon(IconType type) const
+ {
+ if (type == QFileIconProvider::Folder)
+ return dvd;
+
+ return QFileIconProvider::icon(type);
+ }
+private:
+ QIcon mb;
+ QIcon dvd;
+};
+
void tst_QFileSystemModel::iconProvider()
{
QVERIFY(model->iconProvider());
@@ -320,6 +348,19 @@ void tst_QFileSystemModel::iconProvider()
QCOMPARE(model->iconProvider(), p);
model->setIconProvider(0);
delete p;
+
+ QFileSystemModel *myModel = new QFileSystemModel();
+ myModel->setRootPath(QDir::homePath());
+ //Let's wait to populate the model
+ QTest::qWait(250);
+ //We change the provider, icons must me updated
+ CustomFileIconProvider *custom = new CustomFileIconProvider();
+ myModel->setIconProvider(custom);
+
+ QPixmap mb = qApp->style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(50, 50);
+ QCOMPARE(myModel->fileIcon(myModel->index(QDir::homePath())).pixmap(50, 50), mb);
+ delete myModel;
+ delete custom;
}
bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount, const QStringList &initial_dirs, const QString &dir)
diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index 231ef06edd..9df483a874 100644
--- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -42,10 +42,6 @@
#include <QCoreApplication>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <QFileSystemWatcher>
#ifdef Q_OS_LINUX
@@ -406,5 +402,3 @@ void tst_QFileSystemWatcher::removePaths()
QTEST_MAIN(tst_QFileSystemWatcher)
#include "tst_qfilesystemwatcher.moc"
-
-#endif
diff --git a/tests/auto/qfont/tst_qfont.cpp b/tests/auto/qfont/tst_qfont.cpp
index 58e837ef62..e3a5ffc388 100644
--- a/tests/auto/qfont/tst_qfont.cpp
+++ b/tests/auto/qfont/tst_qfont.cpp
@@ -537,9 +537,6 @@ void tst_QFont::insertAndRemoveSubstitutions()
QStringList moreFonts;
moreFonts << "Bar" << "Baz";
QFont::insertSubstitutions("BogusFontFamily", moreFonts);
-#if (QT_VERSION <= 0x040102)
- QEXPECT_FAIL("", "Uppercase/Lowercase issues fixed in 4.1.3 and beyond", Abort);
-#endif
QCOMPARE(QFont::substitutes("BogusFontFamily").count(), 3);
QCOMPARE(QFont::substitutes("bogusfontfamily").count(), 3);
diff --git a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
index 01d97afb78..a006462422 100644
--- a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp
@@ -149,9 +149,7 @@ void tst_QFontDatabase::fixedPitch()
if (!fdb.families().contains(font))
QSKIP( "Font not installed", SkipSingle);
-#if QT_VERSION >= 0x030200
QCOMPARE(fdb.isFixedPitch(font), fixedPitch);
-#endif
QFont qfont(font);
QFontInfo fi(qfont);
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 0f2d6713e2..77b7948301 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -42,10 +42,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <private/qtextcontrol_p.h>
#include <private/qgraphicsitem_p.h>
#include <QAbstractTextDocumentLayout>
@@ -162,6 +158,8 @@ private slots:
void mapFromToParent();
void mapFromToScene();
void mapFromToItem();
+ void mapRectFromToParent_data();
+ void mapRectFromToParent();
void isAncestorOf();
void commonAncestorItem();
void data();
@@ -216,10 +214,12 @@ private slots:
void tabChangesFocus();
void tabChangesFocus_data();
void cacheMode();
+ void updateCachedItemAfterMove();
// task specific tests below me
void task141694_textItemEnsureVisible();
void task128696_textItemEnsureMovable();
+ void ensureUpdateOnTextItem();
void task177918_lineItemUndetected();
void task240400_clickOnTextItem_data();
void task240400_clickOnTextItem();
@@ -2515,6 +2515,87 @@ void tst_QGraphicsItem::mapFromToItem()
delete item4;
}
+void tst_QGraphicsItem::mapRectFromToParent_data()
+{
+ QTest::addColumn<bool>("parent");
+ QTest::addColumn<QPointF>("parentPos");
+ QTest::addColumn<QTransform>("parentTransform");
+ QTest::addColumn<QPointF>("pos");
+ QTest::addColumn<QTransform>("transform");
+ QTest::addColumn<QRectF>("inputRect");
+ QTest::addColumn<QRectF>("outputRect");
+
+ QTest::newRow("nil") << false << QPointF() << QTransform() << QPointF() << QTransform() << QRectF() << QRectF();
+ QTest::newRow("simple") << false << QPointF() << QTransform() << QPointF() << QTransform()
+ << QRectF(0, 0, 10, 10) << QRectF(0, 0, 10, 10);
+ QTest::newRow("simple w/parent") << true
+ << QPointF() << QTransform()
+ << QPointF() << QTransform()
+ << QRectF(0, 0, 10, 10) << QRectF(0, 0, 10, 10);
+ QTest::newRow("simple w/parent parentPos") << true
+ << QPointF(50, 50) << QTransform()
+ << QPointF() << QTransform()
+ << QRectF(0, 0, 10, 10) << QRectF(0, 0, 10, 10);
+ QTest::newRow("simple w/parent parentPos parentRotation") << true
+ << QPointF(50, 50) << QTransform().rotate(45)
+ << QPointF() << QTransform()
+ << QRectF(0, 0, 10, 10) << QRectF(0, 0, 10, 10);
+ QTest::newRow("pos w/parent") << true
+ << QPointF() << QTransform()
+ << QPointF(50, 50) << QTransform()
+ << QRectF(0, 0, 10, 10) << QRectF(50, 50, 10, 10);
+ QTest::newRow("rotation w/parent") << true
+ << QPointF() << QTransform()
+ << QPointF() << QTransform().rotate(90)
+ << QRectF(0, 0, 10, 10) << QRectF(-10, 0, 10, 10);
+ QTest::newRow("pos rotation w/parent") << true
+ << QPointF() << QTransform()
+ << QPointF(50, 50) << QTransform().rotate(90)
+ << QRectF(0, 0, 10, 10) << QRectF(40, 50, 10, 10);
+ QTest::newRow("pos rotation w/parent parentPos parentRotation") << true
+ << QPointF(-170, -190) << QTransform().rotate(90)
+ << QPointF(50, 50) << QTransform().rotate(90)
+ << QRectF(0, 0, 10, 10) << QRectF(40, 50, 10, 10);
+}
+
+void tst_QGraphicsItem::mapRectFromToParent()
+{
+ QFETCH(bool, parent);
+ QFETCH(QPointF, parentPos);
+ QFETCH(QTransform, parentTransform);
+ QFETCH(QPointF, pos);
+ QFETCH(QTransform, transform);
+ QFETCH(QRectF, inputRect);
+ QFETCH(QRectF, outputRect);
+
+ QGraphicsRectItem *rect = new QGraphicsRectItem;
+ rect->setPos(pos);
+ rect->setTransform(transform);
+
+ if (parent) {
+ QGraphicsRectItem *rectParent = new QGraphicsRectItem;
+ rect->setParentItem(rectParent);
+ rectParent->setPos(parentPos);
+ rectParent->setTransform(parentTransform);
+ }
+
+ // Make sure we use non-destructive transform operations (e.g., 90 degree
+ // rotations).
+ QCOMPARE(rect->mapRectToParent(inputRect), outputRect);
+ QCOMPARE(rect->mapRectFromParent(outputRect), inputRect);
+ QCOMPARE(rect->itemTransform(rect->parentItem()).mapRect(inputRect), outputRect);
+ QCOMPARE(rect->mapToParent(inputRect).boundingRect(), outputRect);
+ QCOMPARE(rect->mapToParent(QPolygonF(inputRect)).boundingRect(), outputRect);
+ QCOMPARE(rect->mapFromParent(outputRect).boundingRect(), inputRect);
+ QCOMPARE(rect->mapFromParent(QPolygonF(outputRect)).boundingRect(), inputRect);
+ QPainterPath inputPath;
+ inputPath.addRect(inputRect);
+ QPainterPath outputPath;
+ outputPath.addRect(outputRect);
+ QCOMPARE(rect->mapToParent(inputPath).boundingRect(), outputPath.boundingRect());
+ QCOMPARE(rect->mapFromParent(outputPath).boundingRect(), inputPath.boundingRect());
+}
+
void tst_QGraphicsItem::isAncestorOf()
{
QGraphicsItem *grandPa = new QGraphicsRectItem;
@@ -3574,6 +3655,8 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsEllipseItem()
class ItemChangeTester : public QGraphicsRectItem
{
public:
+ ItemChangeTester(){}
+ ItemChangeTester(QGraphicsItem *parent) : QGraphicsRectItem(parent) {}
QVariant itemChangeReturnValue;
QGraphicsScene *itemSceneChangeTargetScene;
@@ -3848,6 +3931,39 @@ void tst_QGraphicsItem::itemChange()
QCOMPARE(tester.changes.size(), ++changeCount);
QCOMPARE(tester.changes.last(), QGraphicsItem::ItemChildRemovedChange);
QCOMPARE(qVariantValue<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper);
+
+ // ItemChildRemovedChange 1
+ ItemChangeTester *test = new ItemChangeTester;
+ test->itemSceneChangeTargetScene = 0;
+ int count = 0;
+ QGraphicsScene *scene = new QGraphicsScene;
+ scene->addItem(test);
+ count = test->changes.size();
+ //We test here the fact that when a child is deleted the parent receive only one ItemChildRemovedChange
+ QGraphicsRectItem *child = new QGraphicsRectItem(test);
+ //We received ItemChildAddedChange
+ QCOMPARE(test->changes.size(), ++count);
+ QCOMPARE(test->changes.last(), QGraphicsItem::ItemChildAddedChange);
+ delete child;
+ child = 0;
+ QCOMPARE(test->changes.size(), ++count);
+ QCOMPARE(test->changes.last(), QGraphicsItem::ItemChildRemovedChange);
+
+ ItemChangeTester *childTester = new ItemChangeTester(test);
+ //Changes contains all sceneHasChanged and so on, we don't want to test that
+ int childCount = childTester->changes.size();
+ //We received ItemChildAddedChange
+ QCOMPARE(test->changes.size(), ++count);
+ child = new QGraphicsRectItem(childTester);
+ //We received ItemChildAddedChange
+ QCOMPARE(childTester->changes.size(), ++childCount);
+ QCOMPARE(childTester->changes.last(), QGraphicsItem::ItemChildAddedChange);
+ //Delete the child of the top level with all its children
+ delete childTester;
+ //Only one removal
+ QCOMPARE(test->changes.size(), ++count);
+ QCOMPARE(test->changes.last(), QGraphicsItem::ItemChildRemovedChange);
+ delete scene;
}
{
// ItemChildRemovedChange 2
@@ -3934,8 +4050,26 @@ void tst_QGraphicsItem::itemChange()
tester.itemSceneChangeTargetScene = 0;
tester.itemChangeReturnValue = QVariant();
scene.removeItem(&tester);
+ ++changeCount; // ItemSceneChange
+ ++changeCount; // ItemSceneHasChanged
QCOMPARE(tester.scene(), (QGraphicsScene *)0);
}
+ {
+ // ItemToolTipChange/ItemToolTipHasChanged
+ const QString toolTip(QLatin1String("I'm soo cool"));
+ const QString overridenToolTip(QLatin1String("No, you are not soo cool"));
+ tester.itemChangeReturnValue = overridenToolTip;
+ tester.setToolTip(toolTip);
+ ++changeCount; // ItemToolTipChange
+ ++changeCount; // ItemToolTipHasChanged
+ QCOMPARE(tester.changes.size(), changeCount);
+ QCOMPARE(tester.changes.at(changeCount - 2), QGraphicsItem::ItemToolTipChange);
+ QCOMPARE(tester.values.at(changeCount - 2).toString(), toolTip);
+ QCOMPARE(tester.changes.at(changeCount - 1), QGraphicsItem::ItemToolTipHasChanged);
+ QCOMPARE(tester.values.at(changeCount - 1).toString(), overridenToolTip);
+ QCOMPARE(tester.toolTip(), overridenToolTip);
+ tester.itemChangeReturnValue = QVariant();
+ }
}
class EventFilterTesterItem : public QGraphicsLineItem
@@ -4019,6 +4153,25 @@ void tst_QGraphicsItem::sceneEventFilter()
QCOMPARE(tester->filteredEventReceivers.at(6), static_cast<QGraphicsItem *>(text2));
QVERIFY(text2->hasFocus());
+
+ //Let check if the items are correctly removed from the sceneEventFilters array
+ //to avoid stale pointers.
+ QGraphicsView gv;
+ QGraphicsScene *anotherScene = new QGraphicsScene;
+ QGraphicsTextItem *ti = anotherScene->addText("This is a test #1");
+ ti->moveBy(50, 50);
+ QGraphicsTextItem *ti2 = anotherScene->addText("This is a test #2");
+ QGraphicsTextItem *ti3 = anotherScene->addText("This is a test #3");
+ gv.setScene(anotherScene);
+ gv.show();
+ QTest::qWait(250);
+ ti->installSceneEventFilter(ti2);
+ ti3->installSceneEventFilter(ti);
+ delete ti2;
+ //we souldn't crash
+ QTest::mouseMove(gv.viewport(), gv.mapFromScene(ti->scenePos()));
+ QTest::qWait(250);
+ delete ti;
}
class GeometryChanger : public QGraphicsItem
@@ -5152,6 +5305,39 @@ void tst_QGraphicsItem::task240400_clickOnTextItem()
QCOMPARE(item->textCursor().columnNumber(), 0);
}
+class TextItem : public QGraphicsSimpleTextItem
+{
+public:
+ TextItem(const QString& text) : QGraphicsSimpleTextItem(text)
+ {
+ updates = 0;
+ }
+
+ void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
+ {
+ updates++;
+ QGraphicsSimpleTextItem::paint(painter, option, widget);
+ }
+
+ int updates;
+};
+
+void tst_QGraphicsItem::ensureUpdateOnTextItem()
+{
+ QGraphicsScene scene;
+ TextItem *text1 = new TextItem(QLatin1String("123"));
+ scene.addItem(text1);
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWait(250);
+ QCOMPARE(text1->updates,1);
+
+ //same bouding rect but we have to update
+ text1->setText(QLatin1String("321"));
+ QTest::qWait(250);
+ QCOMPARE(text1->updates,2);
+}
+
void tst_QGraphicsItem::task243707_addChildBeforeParent()
{
// Task reports that adding the child before the parent leads to an
@@ -5888,6 +6074,46 @@ void tst_QGraphicsItem::cacheMode()
QCOMPARE(testerChild2->repaints, 6);
}
+void tst_QGraphicsItem::updateCachedItemAfterMove()
+{
+ // A simple item that uses ItemCoordinateCache
+ EventTester *tester = new EventTester;
+ tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
+
+ // Add to a scene, show in a view, ensure it's painted and reset its
+ // repaint counter.
+ QGraphicsScene scene;
+ scene.addItem(tester);
+ QGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(125);
+ tester->repaints = 0;
+
+ // Move the item, should not cause repaints
+ tester->setPos(10, 0);
+ QTest::qWait(125);
+ QCOMPARE(tester->repaints, 0);
+
+ // Move then update, should cause one repaint
+ tester->setPos(20, 0);
+ tester->update();
+ QTest::qWait(125);
+ QCOMPARE(tester->repaints, 1);
+
+ // Hiding the item doesn't cause a repaint
+ tester->hide();
+ QTest::qWait(125);
+ QCOMPARE(tester->repaints, 1);
+
+ // Moving a hidden item doesn't cause a repaint
+ tester->setPos(30, 0);
+ tester->update();
+ QTest::qWait(125);
+ QCOMPARE(tester->repaints, 1);
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
-#endif
diff --git a/tests/auto/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
index d43d0ae440..6d2071683e 100644
--- a/tests/auto/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
+++ b/tests/auto/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
@@ -42,12 +42,7 @@
#include <QtTest/QtTest>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <qgraphicsitemanimation.h>
-
#include <QtCore/qtimeline.h>
#include <QtGui/qmatrix.h>
@@ -195,4 +190,3 @@ void tst_QGraphicsItemAnimation::setTimeLine()
QTEST_MAIN(tst_QGraphicsItemAnimation)
#include "tst_qgraphicsitemanimation.moc"
-#endif
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index d1d18571ee..b99f111f6f 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -1475,7 +1475,7 @@ void tst_QGraphicsProxyWidget::scrollUpdate()
view.paintEventRegion = QRegion();
view.npaints = 0;
QTimer::singleShot(0, widget, SLOT(updateScroll()));
- QTest::qWait(500);
+ QTest::qWait(500);
QCOMPARE(view.npaints, 2);
// QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2)
// QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2),
@@ -2582,7 +2582,7 @@ void tst_QGraphicsProxyWidget::childPos()
{
#ifdef Q_OS_IRIX
QSKIP("This test is not reliable on IRIX.", SkipAll);
-#endif
+#endif
QFETCH(bool, moveCombo);
QFETCH(QPoint, comboPos);
QFETCH(QPointF, proxyPos);
@@ -2797,6 +2797,7 @@ void tst_QGraphicsProxyWidget::palettePropagation()
void tst_QGraphicsProxyWidget::fontPropagation()
{
// Construct a font with an unlikely setup
+ QGraphicsScene scene;
QFont lineEditFont = QApplication::font("QLineEdit");
QFont font = lineEditFont;
font.setPointSize(43);
@@ -2805,6 +2806,7 @@ void tst_QGraphicsProxyWidget::fontPropagation()
QGraphicsProxyWidget proxy;
proxy.setWidget(edit);
+ scene.addItem(&proxy);
EventSpy editSpy(edit);
EventSpy proxySpy(&proxy);
@@ -2825,6 +2827,7 @@ void tst_QGraphicsProxyWidget::fontPropagation()
// Proxy to widget
proxy.setFont(font);
+ QApplication::processEvents(); // wait for QEvent::Polish
QVERIFY(proxy.testAttribute(Qt::WA_SetFont));
QCOMPARE(editSpy.counts[QEvent::FontChange], 3);
QCOMPARE(proxySpy.counts[QEvent::FontChange], 1);
@@ -2893,7 +2896,7 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
edit2->setText("QLineEdit 2");
QCheckBox *checkbox = new QCheckBox("QCheckBox");
QVBoxLayout *vlayout = new QVBoxLayout;
-
+
vlayout->addWidget(edit1);
vlayout->addWidget(edit2);
vlayout->addWidget(checkbox);
@@ -2916,7 +2919,7 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
QVERIFY(window.graphicsProxyWidget() == 0);
QVERIFY(checkbox->graphicsProxyWidget() == 0);
-
+
QGraphicsProxyWidget *windowProxy = scene.addWidget(&window);
QGraphicsView view(&scene);
view.show();
@@ -2946,10 +2949,10 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
QVERIFY(boxProxy->size() == box->size());
QTest::qWait(10);
-
+
QSignalSpy spy(checkbox, SIGNAL(clicked()));
-
+
QTest::mousePress(view.viewport(), Qt::LeftButton, 0,
view.mapFromScene(checkboxProxy->mapToScene(QPointF(8,8))));
QTRY_COMPARE(spy.count(), 0);
@@ -2958,7 +2961,7 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
QTRY_COMPARE(spy.count(), 1);
-
+
boxProxy->setWidget(0);
QVERIFY(checkbox->graphicsProxyWidget() == 0);
@@ -3006,10 +3009,10 @@ void tst_QGraphicsProxyWidget::actionsContextMenu()
widget->addAction(new QAction("item 2", widget));
widget->addAction(new QAction("item 3", widget));
widget->setContextMenuPolicy(Qt::ActionsContextMenu);
-
+
QGraphicsScene scene;
scene.addWidget(widget);
-
+
QGraphicsView view(&scene);
view.show();
#ifdef Q_WS_X11
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index c166dc8d49..b741da6a30 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -45,10 +45,6 @@
#include <ceconfig.h>
#endif
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <QtGui>
#include <math.h>
@@ -253,6 +249,7 @@ private slots:
void task139782_containsItemBoundingRect();
void task176178_itemIndexMethodBreaksSceneRect();
void task160653_selectionChanged();
+ void task250680_childClip();
};
void tst_QGraphicsScene::initTestCase()
@@ -3394,6 +3391,31 @@ void tst_QGraphicsScene::task160653_selectionChanged()
QCOMPARE(spy.count(), 1);
}
+void tst_QGraphicsScene::task250680_childClip()
+{
+ QGraphicsRectItem *clipper = new QGraphicsRectItem;
+ clipper->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ clipper->setPen(QPen(Qt::green));
+ clipper->setRect(200, 200, 640, 480);
+
+ QGraphicsRectItem *rect = new QGraphicsRectItem(clipper);
+ rect->setPen(QPen(Qt::red));
+ rect->setBrush(QBrush(QColor(255, 0, 0, 75)));
+ rect->setPos(320, 240);
+ rect->setRect(-25, -25, 50, 50);
+
+ QGraphicsScene scene;
+ scene.addItem(clipper);
+
+ QPainterPath path;
+ path.addRect(-25, -25, 50, 50);
+ QCOMPARE(rect->clipPath(), path);
+
+ QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2);
+ rect->rotate(45);
+ QCOMPARE(scene.items(QRectF(320, 240, 5, 5)).size(), 2);
+}
+
void tst_QGraphicsScene::sorting_data()
{
QTest::addColumn<bool>("cache");
@@ -3573,4 +3595,3 @@ void tst_QGraphicsScene::stickyFocus()
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
-#endif
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index f3708b53ab..7934781c68 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -42,10 +42,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <qgraphicsitem.h>
#include <qgraphicsscene.h>
#include <qgraphicssceneevent.h>
@@ -155,6 +151,8 @@ private slots:
void fitInView();
void itemsAtPoint();
void itemsInRect();
+ void itemsInRect_cosmeticAdjust_data();
+ void itemsInRect_cosmeticAdjust();
void itemsInPoly();
void itemsInPath();
void itemAt();
@@ -1310,6 +1308,65 @@ void tst_QGraphicsView::itemsInRect()
QCOMPARE(items.takeFirst()->zValue(), qreal(3));
}
+class CountPaintItem : public QGraphicsRectItem
+{
+public:
+ int numPaints;
+
+ CountPaintItem(const QRectF &rect)
+ : QGraphicsRectItem(rect), numPaints(0)
+ { }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
+ {
+ ++numPaints;
+ QGraphicsRectItem::paint(painter, option, widget);
+ }
+};
+
+void tst_QGraphicsView::itemsInRect_cosmeticAdjust_data()
+{
+ QTest::addColumn<QRect>("updateRect");
+ QTest::addColumn<int>("numPaints");
+
+ QTest::newRow("nil") << QRect() << 1;
+ QTest::newRow("0, 0, 300, 100") << QRect(0, 0, 300, 100) << 1;
+ QTest::newRow("0, 0, 100, 300") << QRect(0, 0, 100, 300) << 1;
+ QTest::newRow("200, 0, 100, 300") << QRect(200, 0, 100, 300) << 1;
+ QTest::newRow("0, 200, 300, 100") << QRect(0, 200, 300, 100) << 1;
+ QTest::newRow("0, 0, 300, 99") << QRect(0, 0, 300, 99) << 0;
+ QTest::newRow("0, 0, 99, 300") << QRect(0, 0, 99, 300) << 0;
+ QTest::newRow("201, 0, 99, 300") << QRect(201, 0, 99, 300) << 0;
+ QTest::newRow("0, 201, 300, 99") << QRect(0, 201, 300, 99) << 0;
+}
+
+void tst_QGraphicsView::itemsInRect_cosmeticAdjust()
+{
+ QFETCH(QRect, updateRect);
+ QFETCH(int, numPaints);
+
+ QGraphicsScene scene(-100, -100, 200, 200);
+ CountPaintItem *rect = new CountPaintItem(QRectF(-50, -50, 100, 100));
+ scene.addItem(rect);
+
+ QGraphicsView view(&scene);
+ view.setFrameStyle(0);
+ view.resize(300, 300);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(125);
+
+ rect->numPaints = 0;
+ if (updateRect.isNull())
+ view.viewport()->update();
+ else
+ view.viewport()->update(updateRect);
+ qApp->processEvents();
+ QCOMPARE(rect->numPaints, numPaints);
+}
+
void tst_QGraphicsView::itemsInPoly()
{
QGraphicsScene scene;
@@ -2993,4 +3050,3 @@ void tst_QGraphicsView::centerOnDirtyItem()
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"
-#endif
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 86d1acbc48..f25a079dad 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -259,6 +259,35 @@ void tst_QGraphicsWidget::cleanup()
{
}
+class SizeHinter : public QGraphicsWidget
+{
+public:
+ SizeHinter(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0,
+ const QSizeF &min = QSizeF(5,5),
+ const QSizeF &pref = QSizeF(50, 50),
+ const QSizeF &max = QSizeF(500, 500))
+ : QGraphicsWidget(parent, wFlags)
+ {
+ m_sizes[Qt::MinimumSize] = min;
+ m_sizes[Qt::PreferredSize] = pref;
+ m_sizes[Qt::MaximumSize] = max;
+
+ }
+ void setSizeHint(Qt::SizeHint which, const QSizeF &newSizeHint)
+ {
+ m_sizes[which] = newSizeHint;
+ }
+
+protected:
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const
+ {
+ Q_UNUSED(constraint);
+ return m_sizes[which];
+ }
+private:
+ QSizeF m_sizes[4];
+};
+
void tst_QGraphicsWidget::qgraphicswidget()
{
SubQGraphicsWidget widget;
@@ -282,6 +311,12 @@ void tst_QGraphicsWidget::qgraphicswidget()
QCOMPARE(widget.type(), (int)QGraphicsWidget::Type);
QCOMPARE(widget.call_propertyChange(QString(), QVariant()), QVariant());
widget.call_sizeHint(Qt::PreferredSize, QSizeF());
+
+ QGraphicsScene scene;
+ QGraphicsWidget *parent = new QGraphicsWidget;
+ SizeHinter *child = new SizeHinter(parent);
+
+ QCOMPARE(child->minimumSize(), QSizeF(5, 5));
}
void tst_QGraphicsWidget::activation()
@@ -1516,35 +1551,6 @@ enum WhichSize {
None,
};
-class SizeHinter : public QGraphicsWidget
-{
-public:
- SizeHinter(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0,
- const QSizeF &min = QSizeF(5,5),
- const QSizeF &pref = QSizeF(50, 50),
- const QSizeF &max = QSizeF(500, 500))
- : QGraphicsWidget(parent, wFlags)
- {
- m_sizes[Qt::MinimumSize] = min;
- m_sizes[Qt::PreferredSize] = pref;
- m_sizes[Qt::MaximumSize] = max;
-
- }
- void setSizeHint(Qt::SizeHint which, const QSizeF &newSizeHint)
- {
- m_sizes[which] = newSizeHint;
- }
-
-protected:
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const
- {
- Q_UNUSED(constraint);
- return m_sizes[which];
- }
-private:
- QSizeF m_sizes[4];
-};
-
typedef QPair<int, QVariant> Inst;
Q_DECLARE_METATYPE(Inst)
diff --git a/tests/auto/qhash/tst_qhash.cpp b/tests/auto/qhash/tst_qhash.cpp
index 73dfe07526..5d6b91a53d 100644
--- a/tests/auto/qhash/tst_qhash.cpp
+++ b/tests/auto/qhash/tst_qhash.cpp
@@ -39,16 +39,10 @@
**
****************************************************************************/
-
#include <QtTest/QtTest>
-
-#if QT_VERSION >= 0x040000
#include <qhash.h>
#include <qmap.h>
-#endif
-
-
//TESTED_CLASS=
//TESTED_FILES=
@@ -80,9 +74,7 @@ private slots:
void qmultihash_specific();
void compare();
-#if QT_VERSION > 0x040100
void compare2();
-#endif // QT_VERSION
void iterators(); // sligthly modified from tst_QMap
void keys_values_uniqueKeys(); // slightly modified from tst_QMap
void noNeedlessRehashes();
@@ -799,7 +791,6 @@ void tst_QHash::compare()
QVERIFY(hash1 != hash2);
}
-#if QT_VERSION > 0x040100
void tst_QHash::compare2()
{
QHash<int, int> a;
@@ -838,7 +829,6 @@ void tst_QHash::compare2()
QVERIFY(!(a == b));
QVERIFY(!(b == a));
}
-#endif // QT_VERSION
//sligthly modified from tst_QMap
void tst_QHash::iterators()
@@ -996,9 +986,6 @@ void tst_QHash::rehash_isnt_quadratic()
class Bar
{
public:
-#if QT_VERSION < 0x040100
- Bar() : j(0) {}
-#endif
Bar(int i) : j(i) {}
int j;
@@ -1180,37 +1167,27 @@ QList<T> sorted(const QList<T> &list)
void tst_QHash::keys_values_uniqueKeys()
{
QHash<QString, int> hash;
-#if QT_VERSION >= 0x040200
QVERIFY(hash.uniqueKeys().isEmpty());
-#endif
QVERIFY(hash.keys().isEmpty());
QVERIFY(hash.values().isEmpty());
hash.insertMulti("alpha", 1);
QVERIFY(sorted(hash.keys()) == (QList<QString>() << "alpha"));
-#if QT_VERSION >= 0x040200
QVERIFY(hash.keys() == hash.uniqueKeys());
-#endif
QVERIFY(hash.values() == (QList<int>() << 1));
hash.insertMulti("beta", -2);
QVERIFY(sorted(hash.keys()) == (QList<QString>() << "alpha" << "beta"));
-#if QT_VERSION >= 0x040200
QVERIFY(hash.keys() == hash.uniqueKeys());
-#endif
QVERIFY(sorted(hash.values()) == sorted(QList<int>() << 1 << -2));
hash.insertMulti("alpha", 2);
-#if QT_VERSION >= 0x040200
QVERIFY(sorted(hash.uniqueKeys()) == (QList<QString>() << "alpha" << "beta"));
-#endif
QVERIFY(sorted(hash.keys()) == (QList<QString>() << "alpha" << "alpha" << "beta"));
QVERIFY(sorted(hash.values()) == sorted(QList<int>() << 2 << 1 << -2));
hash.insertMulti("beta", 4);
-#if QT_VERSION >= 0x040200
QVERIFY(sorted(hash.uniqueKeys()) == (QList<QString>() << "alpha" << "beta"));
-#endif
QVERIFY(sorted(hash.keys()) == (QList<QString>() << "alpha" << "alpha" << "beta" << "beta"));
QVERIFY(sorted(hash.values()) == sorted(QList<int>() << 2 << 1 << 4 << -2));
}
diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp
index 0867e48a2b..6478854def 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -187,6 +187,7 @@ private slots:
void emptySectionSpan();
void task236450_hidden_data();
void task236450_hidden();
+ void task248050_hideRow();
protected:
QHeaderView *view;
@@ -1919,5 +1920,28 @@ void tst_QHeaderView::task236450_hidden()
}
+void tst_QHeaderView::task248050_hideRow()
+{
+ //this is the sequence of events that make the task fail
+ protected_QHeaderView header(Qt::Vertical);
+ QStandardItemModel model(0, 1);
+ header.setStretchLastSection(false);
+ header.setDefaultSectionSize(17);
+ header.setModel(&model);
+ header.doItemsLayout();
+
+ model.setRowCount(3);
+
+ QCOMPARE(header.sectionPosition(2), 17*2);
+
+ header.hideSection(1);
+ QCOMPARE(header.sectionPosition(2), 17);
+
+ QTest::qWait(100);
+ //the size of the section shouldn't have changed
+ QCOMPARE(header.sectionPosition(2), 17);
+}
+
+
QTEST_MAIN(tst_QHeaderView)
#include "tst_qheaderview.moc"
diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp
index ad426a2976..093bc1e4f3 100644
--- a/tests/auto/qhttp/tst_qhttp.cpp
+++ b/tests/auto/qhttp/tst_qhttp.cpp
@@ -265,11 +265,9 @@ void tst_QHttp::constructing()
}
-#if QT_VERSION >= 0x040102
{
QHttpResponseHeader header(200);
}
-#endif
}
void tst_QHttp::invalidRequests()
diff --git a/tests/auto/qicoimageformat/tst_qticoimageformat.cpp b/tests/auto/qicoimageformat/tst_qticoimageformat.cpp
index 114ecb5be0..89a0505bbd 100644
--- a/tests/auto/qicoimageformat/tst_qticoimageformat.cpp
+++ b/tests/auto/qicoimageformat/tst_qticoimageformat.cpp
@@ -270,42 +270,35 @@ void tst_QtIcoImageFormat::nextImageDelay_data()
{
QTest::addColumn<QString>("fileName");
QTest::addColumn<int>("count");
- QTest::addColumn<int>("delay");
-
- QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2 << 0;
- QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6 << 0;
- QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1 << 0;
- QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9 << 0;
- QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3 << 0;
- QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2 << 0;
- QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3 << 0;
- QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3 << 0;
- QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1 << -1;
- QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9 << 0;
+
+ QTest::newRow("floppy (16px,32px - 16 colors)") << "valid/35FLOPPY.ICO" << 2;
+ QTest::newRow("16px,32px,48px - 256,16M colors") << "valid/abcardWindow.ico" << 6;
+ QTest::newRow("16px - 16 colors") << "valid/App.ico" << 1;
+ QTest::newRow("16px,32px,48px - 16,256,16M colors") << "valid/Obj_N2_Internal_Mem.ico" << 9;
+ QTest::newRow("16px - 16,256,16M colors") << "valid/Status_Play.ico" << 3;
+ QTest::newRow("16px,32px - 16 colors") << "valid/TIMER01.ICO" << 2;
+ QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3;
+ QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3;
+ QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1;
+ QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9;
}
void tst_QtIcoImageFormat::nextImageDelay()
{
QFETCH(QString, fileName);
QFETCH(int, count);
- QFETCH(int, delay);
-
-#if QT_VERSION > 0x040001
- delay = 0;
-#endif
QImageReader reader(m_IconPath + "/" + fileName);
if (count == -1) {
- QCOMPARE(reader.nextImageDelay(), delay);
-
+ QCOMPARE(reader.nextImageDelay(), 0);
} else {
int i;
for (i = 0; i < count; i++) {
-
QVERIFY(reader.jumpToImage(i));
- QCOMPARE(reader.nextImageDelay(), delay);
+ QCOMPARE(reader.nextImageDelay(), 0);
}
}
}
+
QTEST_MAIN(tst_QtIcoImageFormat)
#include "tst_qticoimageformat.moc"
diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp
index a92232790c..c7bee475dc 100644
--- a/tests/auto/qicon/tst_qicon.cpp
+++ b/tests/auto/qicon/tst_qicon.cpp
@@ -188,10 +188,8 @@ void tst_QIcon::actualSize2()
QFETCH(QSize, argument);
QFETCH(QSize, result);
-#if QT_VERSION >= 0x040200
QCOMPARE(icon.actualSize(argument), result);
QCOMPARE(icon.pixmap(argument).size(), result);
-#endif
}
void tst_QIcon::svgActualSize()
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index fcf99abf5e..3b04d56d09 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -99,9 +99,8 @@ private slots:
void rotate_data();
void rotate();
-#if QT_VERSION >= 0x040102
void copy();
-#endif
+
void setPixel_data();
void setPixel();
@@ -980,7 +979,6 @@ void tst_QImage::rotate()
QCOMPARE(original, dest);
}
-#if QT_VERSION >= 0x040102
void tst_QImage::copy()
{
// Task 99250
@@ -989,7 +987,6 @@ void tst_QImage::copy()
img.copy(QRect(1000,1,1,1));
}
}
-#endif
void tst_QImage::setPixel_data()
{
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 20dd77f609..3da79f3cae 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -128,30 +128,22 @@ private slots:
void physicalDpi_data();
void physicalDpi();
-#if QT_VERSION > 0x040100
void sizeBeforeRead_data();
void sizeBeforeRead();
-#endif
-#if QT_VERSION > 0x040400
void imageFormatBeforeRead_data();
void imageFormatBeforeRead();
-#endif
#if defined QTEST_HAVE_GIF
void gifHandlerBugs();
#endif
-#if QT_VERSION >= 0x040200
void readCorruptImage_data();
void readCorruptImage();
-#endif
void readCorruptBmp();
-#if QT_VERSION >= 0x040200
void supportsOption_data();
void supportsOption();
-#endif
#if defined QTEST_HAVE_TIFF
void tiffCompression_data();
@@ -210,9 +202,7 @@ void tst_QImageReader::readImage_data()
QTest::newRow("BMP: 4bpp RLE") << QString("4bpp-rle.bmp") << true << QByteArray("bmp");
QTest::newRow("BMP: 4bpp uncompressed") << QString("tst7.bmp") << true << QByteArray("bmp");
QTest::newRow("BMP: 16bpp") << QString("16bpp.bmp") << true << QByteArray("bmp");
-#if QT_VERSION >= 0x040200
QTest::newRow("BMP: negative height") << QString("negativeheight.bmp") << true << QByteArray("bmp");
-#endif
QTest::newRow("XPM: marble") << QString("marble.xpm") << true << QByteArray("xpm");
QTest::newRow("PNG: kollada") << QString("kollada.png") << true << QByteArray("png");
QTest::newRow("PPM: teapot") << QString("teapot.ppm") << true << QByteArray("ppm");
@@ -604,7 +594,6 @@ void tst_QImageReader::supportsAnimation()
QCOMPARE(io.supportsAnimation(), success);
}
-#if QT_VERSION > 0x040100
void tst_QImageReader::sizeBeforeRead_data()
{
imageFormat_data();
@@ -627,9 +616,7 @@ void tst_QImageReader::sizeBeforeRead()
QVERIFY(!image.isNull());
QCOMPARE(size, image.size());
}
-#endif // QT_VERSION
-#if QT_VERSION > 0x040400
void tst_QImageReader::imageFormatBeforeRead_data()
{
imageFormat_data();
@@ -649,7 +636,6 @@ void tst_QImageReader::imageFormatBeforeRead()
QCOMPARE(image.format(), fileFormat);
}
}
-#endif
#if defined QTEST_HAVE_GIF
void tst_QImageReader::gifHandlerBugs()
@@ -662,7 +648,6 @@ void tst_QImageReader::gifHandlerBugs()
QVERIFY(count == 34);
}
-#if QT_VERSION >= 0x040102
// Task 95166
{
QImageReader io1("images/bat1.gif");
@@ -675,9 +660,7 @@ void tst_QImageReader::gifHandlerBugs()
QVERIFY(!im2.isNull());
QCOMPARE(im1, im2);
}
-#endif
-#if QT_VERSION >= 0x040104
// Task 9994
{
QImageReader io1("images/noclearcode.gif");
@@ -687,7 +670,6 @@ void tst_QImageReader::gifHandlerBugs()
QVERIFY(!im1.isNull()); QVERIFY(!im2.isNull());
QCOMPARE(im1.convertToFormat(QImage::Format_ARGB32), im2.convertToFormat(QImage::Format_ARGB32));
}
-#endif
}
#endif
@@ -874,11 +856,7 @@ void tst_QImageReader::readFromFileAfterJunk()
QVERIFY(!imageData.isNull());
int iterations = 10;
-#if QT_VERSION < 0x040200
- if (format == "ppm" || format == "pbm" || format == "pgm" || format == "xpm" || format == "jpeg")
-#else
if (format == "ppm" || format == "pbm" || format == "pgm")
-#endif
iterations = 1;
if (format == "mng" || !QImageWriter::supportedImageFormats().contains(format)) {
@@ -1177,7 +1155,6 @@ void tst_QImageReader::readFromResources()
QCOMPARE(QImageReader(fileName).read(), QImageReader(":/" + fileName).read());
}
-#if QT_VERSION >= 0x040200
void tst_QImageReader::readCorruptImage_data()
{
QTest::addColumn<QString>("fileName");
@@ -1205,6 +1182,7 @@ void tst_QImageReader::readCorruptImage_data()
QTest::newRow("corrupt tiff") << QString("images/corrupt-data.tif") << true << QString("");
#endif
}
+
void tst_QImageReader::readCorruptImage()
{
QFETCH(QString, fileName);
@@ -1216,14 +1194,12 @@ void tst_QImageReader::readCorruptImage()
QVERIFY(reader.canRead());
QCOMPARE(reader.read().isNull(), shouldFail);
}
-#endif // QT_VERSION
void tst_QImageReader::readCorruptBmp()
{
QCOMPARE(QImage("images/tst7.bmp").convertToFormat(QImage::Format_ARGB32_Premultiplied), QImage("images/tst7.png").convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
-#if QT_VERSION >= 0x040200
void tst_QImageReader::supportsOption_data()
{
QTest::addColumn<QString>("fileName");
@@ -1266,7 +1242,6 @@ void tst_QImageReader::supportsOption()
foreach (QImageIOHandler::ImageOption option, allOptions)
QVERIFY(!reader.supportsOption(option));
}
-#endif
#if defined QTEST_HAVE_TIFF
void tst_QImageReader::tiffCompression_data()
diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp
index e338db9b26..f55c6592c2 100644
--- a/tests/auto/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/qiodevice/tst_qiodevice.cpp
@@ -71,9 +71,7 @@ private slots:
void constructing_QFile();
void read_QByteArray();
void unget();
-#if QT_VERSION >= 0x040100
void peek();
-#endif // QT_VERSION
void getch();
void putch();
@@ -315,7 +313,6 @@ void tst_QIODevice::unget()
}
//--------------------------------------------------------------------
-#if QT_VERSION >= 0x040100
void tst_QIODevice::peek()
{
QBuffer buffer;
@@ -353,7 +350,6 @@ void tst_QIODevice::peek()
}
QFile::remove("peektestfile");
}
-#endif // QT_VERSION
void tst_QIODevice::getch()
{
@@ -446,7 +442,6 @@ void tst_QIODevice::readLine()
result = buffer.readLine(line.data(), linelen + 1);
QCOMPARE(result, linelen);
-#if QT_VERSION >= 0x0402000
// try with a line length limit
QVERIFY(buffer.seek(0));
line = buffer.readLine(linelen + 100);
@@ -456,7 +451,6 @@ void tst_QIODevice::readLine()
QVERIFY(buffer.seek(0));
line = buffer.readLine();
QCOMPARE(line.size(), linelen);
-#endif
}
QTEST_MAIN(tst_QIODevice)
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index befe0eb176..27741e08fd 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -777,6 +777,7 @@ void tst_QItemDelegate::dateTimeEditor()
QCOMPARE(timeEditor->time(), time);
widget.clearFocus();
+ qApp->setActiveWindow(&widget);
widget.setFocus();
widget.editItem(item2);
diff --git a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp
index c12c583746..aa6939de21 100644
--- a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp
+++ b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp
@@ -61,9 +61,6 @@ void tst_QItemEditorFactory::createEditor()
void tst_QItemEditorFactory::createCustomEditor()
{
-#if QT_VERSION < 0x040200
- QSKIP("Needs Qt >= 4.2", SkipAll);
-#else
QItemEditorFactory editorFactory;
QItemEditorCreatorBase *creator = new QStandardItemEditorCreator<QDoubleSpinBox>();
@@ -76,7 +73,6 @@ void tst_QItemEditorFactory::createCustomEditor()
QCOMPARE(w->metaObject()->userProperty().type(), QVariant::Double);
delete creator;
-#endif
}
QTEST_MAIN(tst_QItemEditorFactory)
diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp
index 61fc4800f9..2cd6048254 100644
--- a/tests/auto/qitemmodel/modelstotest.cpp
+++ b/tests/auto/qitemmodel/modelstotest.cpp
@@ -117,13 +117,8 @@ ModelsToTest::ModelsToTest()
tests.append(test("QTableModel", ReadWrite, HasData));
tests.append(test("QTableModelEmpty", ReadWrite, Empty));
-#if QT_VERSION >= 0x040200
-#define TABLEFEATURE ReadWrite
-#else
-#define TABLEFEATURE ReadOnly
-#endif
- tests.append(test("QTreeModel", TABLEFEATURE, HasData));
- tests.append(test("QTreeModelEmpty", TABLEFEATURE, Empty));
+ tests.append(test("QTreeModel", ReadWrite, HasData));
+ tests.append(test("QTreeModelEmpty", ReadWrite, Empty));
tests.append(test("QSqlQueryModel", ReadOnly, HasData));
tests.append(test("QSqlQueryModelEmpty", ReadOnly, Empty));
diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp
index 41d7df5935..1b02873bbd 100644
--- a/tests/auto/qitemview/tst_qitemview.cpp
+++ b/tests/auto/qitemview/tst_qitemview.cpp
@@ -230,19 +230,15 @@ void tst_QItemView::setupWithNoTestData()
ViewsToTest testViews;
QTest::addColumn<QString>("viewType");
QTest::addColumn<bool>("displays");
-#if QT_VERSION >= 0x040200
QTest::addColumn<int>("vscroll");
QTest::addColumn<int>("hscroll");
-#endif
for (int i = 0; i < testViews.tests.size(); ++i) {
QString view = testViews.tests.at(i).viewType;
QString test = view + " ScrollPerPixel";
bool displayIndexes = (testViews.tests.at(i).display == ViewsToTest::DisplayRoot);
QTest::newRow(test.toLatin1().data()) << view << displayIndexes
-#if QT_VERSION >= 0x040200
<< (int)QAbstractItemView::ScrollPerPixel
<< (int)QAbstractItemView::ScrollPerPixel
-#endif
;
}
for (int i = 0; i < testViews.tests.size(); ++i) {
@@ -250,10 +246,8 @@ void tst_QItemView::setupWithNoTestData()
QString test = view + " ScrollPerItem";
bool displayIndexes = (testViews.tests.at(i).display == ViewsToTest::DisplayRoot);
QTest::newRow(test.toLatin1().data()) << view << displayIndexes
-#if QT_VERSION >= 0x040200
<< (int)QAbstractItemView::ScrollPerItem
<< (int)QAbstractItemView::ScrollPerItem
-#endif
;
}
}
@@ -296,19 +290,17 @@ void tst_QItemView::nonDestructiveBasicTest()
#ifdef Q_OS_IRIX
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
-
+
#ifdef Q_OS_WINCE
QTest::qWait(400);
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
-#if QT_VERSION >= 0x040200
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
-#endif
// setSelectionModel() will assert
//view->setSelectionModel(0);
@@ -462,12 +454,10 @@ void tst_QItemView::spider()
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
-#if QT_VERSION >= 0x040200
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
-#endif
view->setModel(treeModel);
view->show();
#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
@@ -499,12 +489,10 @@ void tst_QItemView::resize()
// doesn't really catch theproblem.
QFETCH(QString, viewType);
view = testViews->createView(viewType);
-#if QT_VERSION >= 0x040200
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
-#endif
view->setModel(treeModel);
view->show();
@@ -529,12 +517,10 @@ void tst_QItemView::visualRect()
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
-#if QT_VERSION >= 0x040200
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
-#endif
QCOMPARE(view->visualRect(QModelIndex()), QRect());
// Add model
@@ -665,12 +651,10 @@ void tst_QItemView::indexAt()
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
-#if QT_VERSION >= 0x040200
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
-#endif
view->show();
view->setModel(treeModel);
#if 0
@@ -701,12 +685,10 @@ void tst_QItemView::scrollTo()
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
-#if QT_VERSION >= 0x040200
QFETCH(int, vscroll);
QFETCH(int, hscroll);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
-#endif
view->setModel(treeModel);
view->show();
diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp
index 2a5017ddc4..943f0e1076 100644
--- a/tests/auto/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp
@@ -181,9 +181,7 @@ void tst_QKeySequence::operatorQString_data()
#ifndef Q_WS_MAC
QTest::newRow( "Ctrl+Left" ) << int(Qt::CTRL) << int(Qt::Key_Left) << QString( "Ctrl+Left" );
-#if QT_VERSION > 0x040100
QTest::newRow( "Ctrl+," ) << int(Qt::CTRL) << int(Qt::Key_Comma) << QString( "Ctrl+," );
-#endif
QTest::newRow( "Alt+Left" ) << int(Qt::ALT) << int(Qt::Key_Left) << QString( "Alt+Left" );
QTest::newRow( "Alt+Shift+Left" ) << int(Qt::ALT | Qt::SHIFT) << int(Qt::Key_Left) << QString( "Alt+Shift+Left" );
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString( "Ctrl+\x0c5" );
@@ -192,9 +190,7 @@ void tst_QKeySequence::operatorQString_data()
QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString( "Meta+\x0c5" );
#else
QTest::newRow( "Ctrl+Left" ) << int(Qt::CTRL) << int(Qt::Key_Left) << MacCtrl + macSymbolForQtKey(Qt::Key_Left);
-#if QT_VERSION > 0x040100
QTest::newRow( "Ctrl+," ) << int(Qt::CTRL) << int(Qt::Key_Comma) << MacCtrl + ",";
-#endif
QTest::newRow( "Alt+Left" ) << int(Qt::ALT) << int(Qt::Key_Left) << MacAlt + macSymbolForQtKey(Qt::Key_Left);
QTest::newRow( "Alt+Shift+Left" ) << int(Qt::ALT | Qt::SHIFT) << int(Qt::Key_Left) << MacAlt + MacShift + macSymbolForQtKey(Qt::Key_Left);
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacCtrl + "\x0c5";
@@ -385,10 +381,8 @@ void tst_QKeySequence::toString_data()
QTest::newRow("Shift") << QString("Shift+\x0c5") << QString("Shift+\x0c5") << QString("Shift+\x0c5");
QTest::newRow("Meta") << QString("Meta+\x0c5") << QString("Meta+\x0c5") << QString("Meta+\x0c5");
QTest::newRow("Ctrl+Plus") << QString("Ctrl++") << QString("Ctrl++") << QString("Ctrl++");
-#if QT_VERSION > 0x040100
QTest::newRow("Ctrl+,") << QString("Ctrl+,") << QString("Ctrl+,") << QString("Ctrl+,");
QTest::newRow("Ctrl+,,Ctrl+,") << QString("Ctrl+,,Ctrl+,") << QString("Ctrl+,, Ctrl+,") << QString("Ctrl+,, Ctrl+,");
-#endif
QTest::newRow("MultiKey") << QString("Alt+X, Ctrl+Y, Z") << QString("Alt+X, Ctrl+Y, Z")
<< QString("Alt+X, Ctrl+Y, Z");
@@ -406,10 +400,8 @@ void tst_QKeySequence::toString_data()
QTest::newRow("Shift") << MacShift + "\x0c5" << QString("Shift+\x0c5") << MacShift + "\x0c5";
QTest::newRow("Meta") << MacMeta + "\x0c5" << QString("Meta+\x0c5") << MacMeta + "\x0c5";
QTest::newRow("Ctrl+Plus") << MacCtrl + "+" << QString("Ctrl++") << MacCtrl + "+";
-#if QT_VERSION > 0x040100
QTest::newRow("Ctrl+,") << MacCtrl + "," << QString("Ctrl+,") << MacCtrl + ",";
QTest::newRow("Ctrl+,,Ctrl+,") << MacCtrl + ",, " + MacCtrl + "," << QString("Ctrl+,, Ctrl+,") << MacCtrl + ",, " + MacCtrl + ",";
-#endif
QTest::newRow("MultiKey") << MacAlt + "X, " + MacCtrl + "Y, Z" << QString("Alt+X, Ctrl+Y, Z")
<< MacAlt + "X, " + MacCtrl + "Y, Z";
QTest::newRow("Invalid") << QString("Ctrly") << QString("") << QString("");
diff --git a/tests/auto/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp
index 5a46bf7359..6dc1aebbce 100644
--- a/tests/auto/qlabel/tst_qlabel.cpp
+++ b/tests/auto/qlabel/tst_qlabel.cpp
@@ -266,10 +266,8 @@ void tst_QLabel::setTextFormat()
testWidget->setTextFormat( Qt::RichText );
QVERIFY( testWidget->textFormat() == Qt::RichText );
-#if QT_VERSION >= 0x030100
testWidget->setTextFormat( Qt::LogText );
QVERIFY( testWidget->textFormat() == Qt::LogText );
-#endif
testWidget->setTextFormat( Qt::AutoText );
QVERIFY( testWidget->textFormat() == Qt::AutoText );
diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp
index e588d3f581..bf326be8c0 100644
--- a/tests/auto/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/qlibrary/tst_qlibrary.cpp
@@ -191,7 +191,7 @@ void tst_QLibrary::version()
QFETCH( int, loadversion );
QFETCH( int, resultversion );
-#if QT_VERSION >= 0x040200 && !defined(Q_OS_AIX) && !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN)
+#if !defined(Q_OS_AIX) && !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN)
QString currDir = QDir::currentPath();
QLibrary library( currDir + QLatin1Char('/') + lib, loadversion );
bool ok = library.load();
@@ -226,7 +226,6 @@ void tst_QLibrary::load_data()
QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<(bool)true;
#endif
-#if QT_VERSION >= 0x040103
# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << (bool)true;
QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << (bool)true;
@@ -236,7 +235,6 @@ void tst_QLibrary::load_data()
QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << (bool)true;
QTest::newRow( "ok03 (with non-standard suffix)" ) << currDir + "/system.trolltech.test.mylib.so" << (bool)true;
# endif // Q_OS_UNIX
-#endif // QT_VERSION
}
void tst_QLibrary::load()
@@ -478,7 +476,7 @@ void tst_QLibrary::loadHints_data()
QTest::addColumn<bool>("result");
QLibrary::LoadHints lh;
-#if QT_VERSION >= 0x040300 && defined(Q_OS_AIX)
+#if defined(Q_OS_AIX)
if (QFile::exists("/usr/lib/libGL.a") || QFile::exists("/usr/X11R6/lib/libGL.a")) {
# if QT_POINTER_SIZE == 4
QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr.o)" << int(QLibrary::LoadArchiveMemberHint) << (bool)TRUE;
@@ -486,9 +484,7 @@ void tst_QLibrary::loadHints_data()
QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr_64.o)" << int(QLibrary::LoadArchiveMemberHint) << (bool)TRUE;
#endif
}
-#endif // QT_VERSION
-
-#if QT_VERSION >= 0x040103
+#endif
#if defined(Q_OS_SYMBIAN)
QString currDir;
@@ -506,8 +502,6 @@ void tst_QLibrary::loadHints_data()
QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << (bool)TRUE;
QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << int(lh) << (bool)TRUE;
# endif // Q_OS_UNIX
-#endif // QT_VERSION
-
}
void tst_QLibrary::loadHints()
diff --git a/tests/auto/qline/tst_qline.cpp b/tests/auto/qline/tst_qline.cpp
index 53be2e8c14..ab0bd9bbbe 100644
--- a/tests/auto/qline/tst_qline.cpp
+++ b/tests/auto/qline/tst_qline.cpp
@@ -201,8 +201,8 @@ void tst_QLine::testIntersection_data()
b = b.translated(1, 1);
QTest::newRow(qPrintable(QString::fromLatin1("rotation-%0").arg(i)))
- << double(a.x1()) << double(a.y1()) << double(a.x2()) << double(a.y2())
- << double(b.x1()) << double(b.y1()) << double(b.x2()) << double(b.y2())
+ << (double)a.x1() << (double)a.y1() << (double)a.x2() << (double)a.y2()
+ << (double)b.x1() << (double)b.y1() << (double)b.x2() << (double)b.y2()
<< int(QLineF::BoundedIntersection)
<< 1.0
<< 1.0;
@@ -232,8 +232,8 @@ void tst_QLine::testIntersection()
QCOMPARE(int(itype), type);
if (type != QLineF::NoIntersection) {
- QCOMPARE(ip.x(), qreal(ix));
- QCOMPARE(ip.y(), qreal(iy));
+ QVERIFY(qAbs(ip.x() - ix) < epsilon);
+ QVERIFY(qAbs(ip.y() - iy) < epsilon);
}
}
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 4042df6c36..d9005180f5 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -1466,14 +1466,10 @@ void tst_QLineEdit::textMask_data()
void tst_QLineEdit::textMask()
{
-#if (QT_VERSION-0 >= 0x030303)
QFETCH( QString, insertString );
testWidget->setInputMask( "#" );
testWidget->setText( insertString );
QCOMPARE( testWidget->text(), insertString );
-#else
- QSKIP( "This test function tests a problem with masks that was fixed in 3.3", SkipAll);
-#endif
}
void tst_QLineEdit::setText()
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 2bde2c334c..97b14939a5 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -599,6 +599,17 @@ void tst_QLocale::long_long_conversion_data()
QTest::newRow("de_DE 12345.67") << QString("de_DE") << "12345.67"<< false << (qlonglong) 0;
QTest::newRow("de_DE 123456.7") << QString("de_DE") << "123456.7"<< false << (qlonglong) 0;
QTest::newRow("de_DE 1.234.567") << QString("de_DE")<< "1.234.567"<< true << (qlonglong) 1234567;
+ QTest::newRow("de_DE 1.234.567 ldspcs") << QString("de_DE")<< " 1.234.567" << true << (qlonglong) 1234567;
+ QTest::newRow("de_DE 1.234.567 trspcs") << QString("de_DE")<< "1.234.567 "<< true << (qlonglong) 1234567;
+ QTest::newRow("de_DE 1.234.567 ldtrspcs") << QString("de_DE")<< " 1.234.567 "<< true << (qlonglong) 1234567;
+
+ // test that space is also accepted whenever QLocale::groupSeparator() == 0xa0 (which looks like space).
+ QTest::newRow("nb_NO 123 groupsep") << QString("nb_NO")<< QString("1")+QChar(0xa0)+QString("234") << true << (qlonglong) 1234;
+ QTest::newRow("nb_NO 123 groupsep_space") << QString("nb_NO")<< QString("1")+QChar(0x20)+QString("234") << true << (qlonglong) 1234;
+
+ QTest::newRow("nb_NO 123 ldspcs") << QString("nb_NO")<< " 123" << true << (qlonglong) 123;
+ QTest::newRow("nb_NO 123 trspcs") << QString("nb_NO")<< "123 "<< true << (qlonglong) 123;
+ QTest::newRow("nb_NO 123 ldtrspcs") << QString("nb_NO")<< " 123 "<< true << (qlonglong) 123;
QTest::newRow("C 1234") << QString("C") << " 1234" << true << (qlonglong) 1234;
QTest::newRow("C 1234 ") << QString("C") << "1234 " << true << (qlonglong) 1234;
diff --git a/tests/auto/qlocalsocket/test/test.pro b/tests/auto/qlocalsocket/test/test.pro
index 1d55fc9dd8..c58bfeee4b 100644
--- a/tests/auto/qlocalsocket/test/test.pro
+++ b/tests/auto/qlocalsocket/test/test.pro
@@ -1,7 +1,5 @@
load(qttest_p4)
-include(../src/src.pri)
-
DEFINES += QLOCALSERVER_DEBUG
DEFINES += QLOCALSOCKET_DEBUG
@@ -17,14 +15,16 @@ symbian* {
QT = core network
SOURCES += ../tst_qlocalsocket.cpp
-TARGET = ../tst_qlocalsocket
-win32 {
+TARGET = tst_qlocalsocket
+CONFIG(debug_and_release) {
CONFIG(debug, debug|release) {
- TARGET = ../../debug/tst_qlocalsocket
-} else {
- TARGET = ../../release/tst_qlocalsocket
+ DESTDIR = ../debug
+ } else {
+ DESTDIR = ../release
}
+} else {
+ DESTDIR = ..
}
wince* | symbian* {
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index 031cc5093c..c289c245cc 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -100,6 +100,7 @@ private slots:
void longPath();
void waitForDisconnect();
+ void waitForDisconnectByServer();
void removeServer();
@@ -121,6 +122,8 @@ tst_QLocalSocket::tst_QLocalSocket()
#endif
))
qWarning() << "lackey executable doesn't exists!";
+
+ QLocalServer::removeServer("tst_localsocket");
}
tst_QLocalSocket::~tst_QLocalSocket()
@@ -820,6 +823,25 @@ void tst_QLocalSocket::waitForDisconnect()
QVERIFY(timer.elapsed() < 2000);
}
+void tst_QLocalSocket::waitForDisconnectByServer()
+{
+ QString name = "tst_localsocket";
+ LocalServer server;
+ QVERIFY(server.listen(name));
+ LocalSocket socket;
+ QSignalSpy spy(&socket, SIGNAL(disconnected()));
+ QVERIFY(spy.isValid());
+ socket.connectToServer(name);
+ QVERIFY(socket.waitForConnected(3000));
+ QVERIFY(server.waitForNewConnection(3000));
+ QLocalSocket *serverSocket = server.nextPendingConnection();
+ QVERIFY(serverSocket);
+ serverSocket->close();
+ QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState);
+ QVERIFY(socket.waitForDisconnected(3000));
+ QCOMPARE(spy.count(), 1);
+}
+
void tst_QLocalSocket::removeServer()
{
// this is a hostile takeover, but recovering from a crash results in the same
diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp
index 4529bd53ef..b16a62af89 100644
--- a/tests/auto/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp
@@ -1039,11 +1039,6 @@ void tst_QMainWindow::toolBarArea()
QMainWindow mw;
QToolBar tb(&mw);
-#if QT_VERSION <= 0x040103
- // this would assert in previous versions
- QCOMPARE(mw.toolBarArea(&tb), Qt::ToolBarArea(0));
-#endif
-
for (int j = 0; j < areaCount; ++j) {
Qt::ToolBarArea otherArea = areas[j];
@@ -1205,11 +1200,6 @@ void tst_QMainWindow::dockWidgetArea()
QMainWindow mw;
QDockWidget dw(&mw);
-#if QT_VERSION <= 0x040103
- // this would assert in previous versions
- QCOMPARE(mw.dockWidgetArea(&dw), Qt::DockWidgetArea(0));
-#endif
-
for (int j = 0; j < areaCount; ++j) {
Qt::DockWidgetArea otherArea = areas[i];
diff --git a/tests/auto/qmake/qmake.pro b/tests/auto/qmake/qmake.pro
index 59cc2bef86..8cae6bec56 100644
--- a/tests/auto/qmake/qmake.pro
+++ b/tests/auto/qmake/qmake.pro
@@ -2,8 +2,6 @@ load(qttest_p4)
HEADERS += testcompiler.h
SOURCES += tst_qmake.cpp testcompiler.cpp
-contains(QT_CONFIG, qt3support): QT += qt3support
-
cross_compile: DEFINES += QMAKE_CROSS_COMPILED
diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp
index bfc8905fa9..122a2b8217 100644
--- a/tests/auto/qmake/testcompiler.cpp
+++ b/tests/auto/qmake/testcompiler.cpp
@@ -39,49 +39,37 @@
**
****************************************************************************/
-
#include "testcompiler.h"
-#include <stdlib.h>
-#include <qapplication.h>
-
-#ifdef QT3_SUPPORT
-
-#include <q3process.h>
-#include <qtimer.h>
-#ifdef Q_OS_WIN32
-# include <windows.h>
-#endif
-#include <QtTest/QtTest>
+#include <QProcess>
+#include <QDir>
-#undef SHOW_QDEBUG
-#undef SHOW_COMPLETENESS
-
-QString targetName( BuildType buildMode, const QString& target, const QString& version )
+static QString targetName( BuildType buildMode, const QString& target, const QString& version )
{
+ Q_UNUSED(version);
QString targetName = target;
#if defined (Q_OS_WIN32)
switch (buildMode)
{
case Exe: // app
- targetName.append(".exe");
- break;
+ targetName.append(".exe");
+ break;
case Dll: // dll
- if (version != "") {
- QStringList ver = QStringList::split(".", version);
- targetName.append(ver.first());
- }
+ if (version != "") {
+ QStringList ver = QStringList::split(".", version);
+ targetName.append(ver.first());
+ }
targetName.append(".dll");
- break;
+ break;
case Lib: // lib
#ifdef Q_CC_GNU
targetName.prepend("lib");
targetName.append(".a");
#else
- targetName.append(".lib");
+ targetName.append(".lib");
#endif
- break;
+ break;
case Plain:
// no conversion
break;
@@ -90,16 +78,16 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v
switch (buildMode)
{
case Exe: // app
- targetName += ".app/Contents/MacOS/" + target.section('/', -1);
- break;
+ targetName += ".app/Contents/MacOS/" + target.section('/', -1);
+ break;
case Dll: // dll
- targetName.prepend("lib");
+ targetName.prepend("lib");
targetName.append("." + version + ".dylib");
- break;
+ break;
case Lib: // lib
- targetName.prepend("lib");
- targetName.append(".a");
- break;
+ targetName.prepend("lib");
+ targetName.append(".a");
+ break;
case Plain:
// no conversion
break;
@@ -108,9 +96,9 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v
switch (buildMode)
{
case Exe: // app
- break;
+ break;
case Dll: // dll
- targetName.prepend("lib");
+ targetName.prepend("lib");
#if defined (Q_OS_HPUX) && !defined (__ia64)
targetName.append(".sl");
#elif defined (Q_OS_AIX)
@@ -118,11 +106,11 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v
#else
targetName.append(".so");
#endif
- break;
+ break;
case Lib: // lib
- targetName.prepend("lib");
- targetName.append(".a");
- break;
+ targetName.prepend("lib");
+ targetName.append(".a");
+ break;
case Plain:
// no conversion
break;
@@ -131,223 +119,119 @@ QString targetName( BuildType buildMode, const QString& target, const QString& v
return targetName;
}
-
-
TestCompiler::TestCompiler()
{
- exit_ok = FALSE;
- childProc = 0;
- setBaseCommands( "", "", FALSE );
+ setBaseCommands( "", "" );
}
TestCompiler::~TestCompiler()
{
- if (childProc)
- delete childProc;
}
-bool TestCompiler::runChild( bool showOutput, QStringList argList, QStringList *envList )
+bool TestCompiler::runCommand( QString cmdline )
{
- //qDebug() << "executing" << argList;
- exit_ok = FALSE;
- if (childProc)
- delete childProc;
+ testOutput_.append("Running command: " + cmdline);
- child_show = showOutput;
- if ( showOutput ) {
+ QProcess child;
+ if (!environment_.empty())
+ child.setEnvironment(QProcess::systemEnvironment() + environment_);
- QString S = argList.join(" ");
- addMakeResult( S );
+ child.start(cmdline);
+ if (!child.waitForStarted(-1)) {
+ testOutput_.append( "Unable to start child process." );
+ return false;
}
- childProc = new Q3Process(argList, this, argList.join(" ").latin1());
- Q_ASSERT(childProc);
-
- connect(childProc,SIGNAL(readyReadStdout()),this,SLOT(childHasData()));
- connect(childProc,SIGNAL(processExited()),this,SLOT(childReady()));
-
- if (!childProc->start( envList )) {
-
- addMakeResult( "Error executing '" + argList[0] + "'." );
- childReady();
- return FALSE;
+ bool failed = false;
+ child.setReadChannel(QProcess::StandardError);
+ while (QProcess::Running == child.state()) {
+ if (child.waitForReadyRead(1000)) {
+ QString output = child.readAllStandardError();
+ testOutput_.append(output);
+
+ output.prepend('\n');
+ if (output.contains("\nProject MESSAGE: FAILED"))
+ failed = true;
+ }
}
- while (childProc != 0 && childProc->isRunning()) {
- qApp->processEvents();
- }
-
- childReady();
-
- return exit_ok;
-}
+ child.waitForFinished(-1);
-void TestCompiler::childReady()
-{
- if (childProc != 0) {
- childHasData();
-
- QString S;
- int pos;
- while (childProc->canReadLineStderr()) {
- S = childProc->readLineStderr();
- do {
- pos = S.find("\t");
- if (pos >= 0) {
- S.remove(pos,1);
- S.insert(pos," ");
- }
- } while (pos >= 0);
-
- if (child_show)
- addMakeResult( S );
- }
-
- exit_ok = childProc->normalExit() && childProc->exitStatus() == 0;
- delete childProc;
- }
- childProc = 0;
+ return failed
+ ? false
+ : (child.exitStatus() == QProcess::NormalExit)
+ && (child.exitCode() == 0);
}
-void TestCompiler::childHasData()
+void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd )
{
- QString S;
- int pos;
- while (childProc->canReadLineStderr()) {
-
- S = childProc->readLineStderr();
- do {
- pos = S.find("\t");
- if (pos >= 0) {
- S.remove(pos,1);
- S.insert(pos," ");
- }
-
- } while (pos >= 0);
-
- if ( S.startsWith("Project MESSAGE: FAILED") )
- QTest::qFail( S, __FILE__, __LINE__ );
- else if ( S.startsWith("Project MESSAGE: SKIPPED") )
- QTest::qSkip( S, QTest::SkipSingle, __FILE__, __LINE__ );
- else if (child_show)
- addMakeResult( S );
- }
+ makeCmd_ = makeCmd;
+ qmakeCmd_ = qmakeCmd;
}
-void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd, bool qwsMode )
+void TestCompiler::resetEnvironment()
{
- qws_mode = qwsMode;
- make_cmd = makeCmd;
-
- // not sure if i need this, but it doesn't hurt
- if (make_cmd.startsWith("\""))
- make_cmd = make_cmd.remove(0,1);
- if (make_cmd.endsWith("\""))
- make_cmd = make_cmd.remove(make_cmd.length()-1,1);
-
- qmake_cmd = qmakeCmd;
- // also not sure if i need this, but it doesn't hurt...
- if(qmake_cmd.length() >= 2 && (qmake_cmd.at(0) == '"' || qmake_cmd.at(0) == '\'') && qmake_cmd.at(qmake_cmd.length()-1) == qmake_cmd.at(0))
- qmake_cmd = qmake_cmd.mid(1, qmake_cmd.length()-2);
+ environment_.clear();
}
-bool TestCompiler::cleanAll( const QString &workPath, const QString &destPath, const QString &exeName, const QString &exeExt )
+void TestCompiler::addToEnvironment( QString varAssignment )
{
- QDir D(workPath);
- if (!D.exists()) {
-
- addMakeResult( "Directory '" + workPath + "' doesn't exist" );
- return FALSE;
- }
-
- D.setCurrent(workPath);
- // must delete at least the executable file to be able to easily and safely
- // verify that the compilation was a success.
- D.remove( destPath + "/" + exeName + exeExt );
- D.remove( workPath + "/Makefile");
- QFileInfo Fi( workPath + "/Makefile");
- if (Fi.exists()) {
-
- // Run make clean
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- args.append("clean");
-
- return runChild( FALSE, args, 0 );
- }
-
- return TRUE;
+ environment_.push_back(varAssignment);
}
bool TestCompiler::makeClean( const QString &workPath )
{
QDir D;
if (!D.exists(workPath)) {
-
- addMakeResult( "Directory '" + workPath + "' doesn't exist" );
- return FALSE;
+ testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
+ return false;
}
D.setCurrent(workPath);
QFileInfo Fi( workPath + "/Makefile");
- if (Fi.exists()) {
-
- // Run make clean
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- args.append("clean");
+ if (Fi.exists())
+ // Run make clean
+ return runCommand( makeCmd_ + " clean" );
- return runChild( FALSE, args, 0 );
- }
-
- return TRUE;
+ return true;
}
bool TestCompiler::makeDistClean( const QString &workPath )
{
QDir D;
if (!D.exists(workPath)) {
- addMakeResult( "Directory '" + workPath + "' doesn't exist" );
- return FALSE;
+ testOutput_.append( "Directory '" + workPath + "' doesn't exist" );
+ return false;
}
D.setCurrent(workPath);
QFileInfo Fi( workPath + "/Makefile");
- if (Fi.exists()) {
- // Run make distclean
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- args.append("distclean");
-
- return runChild( FALSE, args, 0 );
- }
+ if (Fi.exists())
+ // Run make distclean
+ return runCommand( makeCmd_ + " distclean" );
- return TRUE;
+ return true;
}
bool TestCompiler::qmake( const QString &workDir, const QString &proName, const QString &buildDir )
{
- // Now start qmake and generate the makefile
-
- QDir D( workDir );
- // Make sure we start in the right directory
+ QDir D;
D.setCurrent( workDir );
if (D.exists("Makefile"))
- D.remove("Makefile");
-
- QStringList args;
- args = QStringList::split( " ", qmake_cmd );
+ D.remove("Makefile");
- QString project_fname = workDir + "/" + proName + ".pro";
- QString makefile_fname = (buildDir.isNull()?QString():(buildDir + "/")) + "Makefile";
+ QString projectFile = proName;
+ QString makeFile = buildDir;
+ if (!projectFile.endsWith(".pro"))
+ projectFile += ".pro";
+ if (!makeFile.isEmpty() && !makeFile.endsWith('/'))
+ makeFile += '/';
+ makeFile += "Makefile";
- args.append( project_fname );
- args.append( "-o" );
- args.append( makefile_fname );
-
- return runChild( TRUE, args, 0 );
+ // Now start qmake and generate the makefile
+ return runCommand( qmakeCmd_ + " " + projectFile + " -o " + makeFile );
}
bool TestCompiler::make( const QString &workPath, const QString &target )
@@ -355,14 +239,13 @@ bool TestCompiler::make( const QString &workPath, const QString &target )
QDir D;
D.setCurrent( workPath );
- QStringList args;
- args = QStringList::split( " ", make_cmd );
- if ( make_cmd.lower().find("nmake") >= 0)
- args.append("/NOLOGO");
- if ( !target.isNull() )
- args.append(target);
+ QString cmdline = makeCmd_;
+ if ( cmdline.contains("nmake", Qt::CaseInsensitive) )
+ cmdline.append(" /NOLOGO");
+ if ( !target.isEmpty() )
+ cmdline += " " + target;
- return runChild( TRUE, args, 0 );
+ return runCommand( cmdline );
}
bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version )
@@ -371,20 +254,12 @@ bool TestCompiler::exists( const QString &destDir, const QString &exeName, Build
return f.exists();
}
-void TestCompiler::addMakeResult( const QString &result )
-{
- make_result.append( result );
-}
-
bool TestCompiler::removeMakefile( const QString &workPath )
{
QDir D;
D.setCurrent( workPath );
if ( D.exists( "Makefile" ) )
- return D.remove( "Makefile" );
+ return D.remove( "Makefile" );
else
- return TRUE;
+ return true;
}
-
-#endif //QT3_SUPPORT
-
diff --git a/tests/auto/qmake/testcompiler.h b/tests/auto/qmake/testcompiler.h
index 597d440e08..41e51774f4 100644
--- a/tests/auto/qmake/testcompiler.h
+++ b/tests/auto/qmake/testcompiler.h
@@ -41,33 +41,22 @@
#ifndef TESTCOMPILER_H
#define TESTCOMPILER_H
-
-#ifdef QT3_SUPPORT
-
-#include <qobject.h>
-#include <qstringlist.h>
-
-QT_FORWARD_DECLARE_CLASS(Q3Process)
-
-#define COMPILE_ERROR "Compile error"
-#define COMPILE_SUCCESS "Compile successfull"
-#define COMPILE_NOT_AVAIL "Binary not available for testing"
-#define SELF_TEST "self-test"
+#include <QObject>
+#include <QStringList>
enum BuildType { Exe, Dll, Lib, Plain };
class TestCompiler : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
TestCompiler();
virtual ~TestCompiler();
- void setBaseCommands( QString makeCmd, QString qmakeCmd, bool qwsMode );
-
- // builds a complete project, e.g. qmake, make clean, make and exists.
- bool buildProject( const QString &project, BuildType buildType, const QString &targetName, const QString &destPath, const QString &version );
+ void setBaseCommands( QString makeCmd, QString qmakeCmd );
+ void resetEnvironment();
+ void addToEnvironment( QString varAssignment );
// executes a make clean in the specified workPath
bool makeClean( const QString &workPath );
@@ -77,34 +66,20 @@ public:
bool qmake( const QString &workDir, const QString &proName, const QString &buildDir = QString() );
// executes a make in the specified workPath, with an optional target (eg. install)
bool make( const QString &workPath, const QString &target = QString() );
- // executes a make clean and then deletes the makefile in workpath + deletes the executable
- // in destPath.
- bool cleanAll( const QString &workPath, const QString &destPath, const QString &exeName, const QString &exeExt );
// checks if the executable exists in destDir
bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version );
// removes the makefile
bool removeMakefile( const QString &workPath );
private:
- QString make_cmd;
- QString qmake_cmd;
-
- Q3Process *childProc;
- QStringList env_list;
+ bool runCommand( QString cmdLine );
- bool child_show;
- bool qws_mode;
- bool exit_ok;
-
-private:
- bool runChild( bool showOutput, QStringList argList, QStringList *envList );
- void addMakeResult( const QString &result );
- QStringList make_result;
+ QString makeCmd_;
+ QString qmakeCmd_;
+ QStringList environment_;
-private slots:
- void childReady();
- void childHasData();
+ // need to make this available somewhere
+ QStringList testOutput_;
};
-#endif // QT3_SUPPORT
#endif // TESTCOMPILER_H
diff --git a/tests/auto/qmake/testdata/functions/functions.pro b/tests/auto/qmake/testdata/functions/functions.pro
index 5ee5f51cd2..9ed92f960f 100644
--- a/tests/auto/qmake/testdata/functions/functions.pro
+++ b/tests/auto/qmake/testdata/functions/functions.pro
@@ -51,15 +51,11 @@ include( infiletest.pro )
message( "FAILED: include function: $$DEFINES" )
}
-lessThan(QT_VERSION, 40200) {
- message( "SKIPPED: replace function only in 4.2" )
-} else {
- #replace
- VERSION=1.0.0
- VERSION_replaced=$$replace(VERSION,\.,_)
- !isEqual(VERSION_replaced, 1_0_0) {
- message( "FAILED: replace function: $$VERSION_replaced" )
- }
+#replace
+VERSION=1.0.0
+VERSION_replaced=$$replace(VERSION,\.,_)
+!isEqual(VERSION_replaced, 1_0_0) {
+ message( "FAILED: replace function: $$VERSION_replaced" )
}
#test functions
diff --git a/tests/auto/qmake/testdata/shadow_files_build/README b/tests/auto/qmake/testdata/shadow_files_build/README
index 46017fc43e..15e48c043e 100644
--- a/tests/auto/qmake/testdata/shadow_files_build/README
+++ b/tests/auto/qmake/testdata/shadow_files_build/README
@@ -1 +1 @@
-Here to ensure include_dir_build exists
+Here to ensure shadow_files_build exists, used by the shadow_files test.
diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp
index facf0bb666..70f1f3c6e1 100644
--- a/tests/auto/qmake/tst_qmake.cpp
+++ b/tests/auto/qmake/tst_qmake.cpp
@@ -39,21 +39,13 @@
**
****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#if !defined(QMAKE_CROSS_COMPILED) && defined(QT3_SUPPORT)
-
-#include <qdir.h>
-#include <qprocess.h>
-
+#if !defined(QMAKE_CROSS_COMPILED)
#include "testcompiler.h"
-#include <stdlib.h>
-
-//TESTED_CLASS=
-//TESTED_FILES=corelib/tools/qlocale.h corelib/tools/qlocale.cpp
+#include <QObject>
+#include <QDir>
+#include <QtTest/QtTest>
class tst_qmake : public QObject
{
@@ -63,12 +55,12 @@ public:
tst_qmake();
virtual ~tst_qmake();
-
public slots:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
+
private slots:
void simple_app();
void simple_lib();
@@ -104,16 +96,16 @@ tst_qmake::tst_qmake()
{
QString cmd = QString("qmake \"QT_VERSION=%1\"").arg(QT_VERSION);
#ifdef Q_CC_MSVC
- test_compiler.setBaseCommands( "nmake", cmd, FALSE );
+ test_compiler.setBaseCommands( "nmake", cmd );
#elif defined(Q_CC_MINGW)
- test_compiler.setBaseCommands( "mingw32-make", cmd, FALSE );
+ test_compiler.setBaseCommands( "mingw32-make", cmd );
#elif defined(Q_OS_WIN) && defined(Q_CC_GNU)
- test_compiler.setBaseCommands( "mmmake", cmd, FALSE );
+ test_compiler.setBaseCommands( "mmmake", cmd );
#else
- test_compiler.setBaseCommands( "make", cmd, FALSE );
+ test_compiler.setBaseCommands( "make", cmd );
#endif
QDir dir;
- base_path = dir.currentDirPath();
+ base_path = dir.currentPath();
}
tst_qmake::~tst_qmake()
@@ -255,10 +247,10 @@ void tst_qmake::duplicateLibraryEntries()
void tst_qmake::export_across_file_boundaries()
{
// This relies on features so we need to set the QMAKEFEATURES environment variable
- putenv("QMAKEFEATURES=.");
+ test_compiler.addToEnvironment("QMAKEFEATURES=.");
QString workDir = base_path + "/testdata/export_across_file_boundaries";
QVERIFY( test_compiler.qmake( workDir, "foo" ));
- putenv("QMAKEFEATURES=");
+ test_compiler.resetEnvironment();
}
void tst_qmake::include_dir()
@@ -406,7 +398,7 @@ void tst_qmake::bundle_spaces()
// make (-n).
TestCompiler local_tc;
- local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++", FALSE);
+ local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++");
QVERIFY( local_tc.qmake(workDir, "bundle-spaces") );
diff --git a/tests/auto/qmap/tst_qmap.cpp b/tests/auto/qmap/tst_qmap.cpp
index ce413c5781..99efc80dc3 100644
--- a/tests/auto/qmap/tst_qmap.cpp
+++ b/tests/auto/qmap/tst_qmap.cpp
@@ -728,37 +728,27 @@ void tst_QMap::iterators()
void tst_QMap::keys_values_uniqueKeys()
{
QMap<QString, int> map;
-#if QT_VERSION >= 0x040200
QVERIFY(map.uniqueKeys().isEmpty());
-#endif
QVERIFY(map.keys().isEmpty());
QVERIFY(map.values().isEmpty());
map.insertMulti("alpha", 1);
QVERIFY(map.keys() == (QList<QString>() << "alpha"));
-#if QT_VERSION >= 0x040200
QVERIFY(map.uniqueKeys() == map.keys());
-#endif
QVERIFY(map.values() == (QList<int>() << 1));
map.insertMulti("beta", -2);
QVERIFY(map.keys() == (QList<QString>() << "alpha" << "beta"));
-#if QT_VERSION >= 0x040200
QVERIFY(map.keys() == map.uniqueKeys());
-#endif
QVERIFY(map.values() == (QList<int>() << 1 << -2));
map.insertMulti("alpha", 2);
-#if QT_VERSION >= 0x040200
QVERIFY(map.uniqueKeys() == (QList<QString>() << "alpha" << "beta"));
-#endif
QVERIFY(map.keys() == (QList<QString>() << "alpha" << "alpha" << "beta"));
QVERIFY(map.values() == (QList<int>() << 2 << 1 << -2));
map.insertMulti("beta", 4);
-#if QT_VERSION >= 0x040200
QVERIFY(map.uniqueKeys() == (QList<QString>() << "alpha" << "beta"));
-#endif
QVERIFY(map.keys() == (QList<QString>() << "alpha" << "alpha" << "beta" << "beta"));
QVERIFY(map.values() == (QList<int>() << 2 << 1 << 4 << -2));
}
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 44a0ca7323..2ca04d1ceb 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -92,6 +92,7 @@ private slots:
void activeSubMenuPosition();
void task242454_sizeHint();
void task176201_clear();
+ void task250673_activeMutliColumnSubMenuPosition();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -685,6 +686,39 @@ void tst_QMenu::task176201_clear()
QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center());
}
+void tst_QMenu::task250673_activeMutliColumnSubMenuPosition()
+{
+ class MyMenu : public QMenu
+ {
+ public:
+ int columnCount() const { return QMenu::columnCount(); }
+ };
+
+ QMenu sub;
+ sub.addAction("Sub-Item1");
+ QAction *subAction = sub.addAction("Sub-Item2");
+
+ MyMenu main;
+ main.addAction("Item 1");
+ QAction *menuAction = main.addMenu(&sub);
+ main.popup(QPoint(200,200));
+
+ uint i = 2;
+ while (main.columnCount() < 2) {
+ main.addAction(QString("Item %1").arg(i));
+ ++i;
+ Q_ASSERT(i<1000);
+ }
+ main.setActiveAction(menuAction);
+ sub.setActiveAction(subAction);
+ QVERIFY(main.isVisible());
+ QCOMPARE(main.activeAction(), menuAction);
+ QVERIFY(sub.isVisible());
+ QVERIFY(sub.pos().x() > main.pos().x());
+
+ const int subMenuOffset = main.style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, &main);
+ QVERIFY((sub.geometry().left() - subMenuOffset + 5) < main.geometry().right());
+}
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"
diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index 4c458826d6..2b3e5e39fd 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -457,8 +457,8 @@ void tst_QMenuBar::accel()
void tst_QMenuBar::accel_noQt3()
{
-#ifdef Q_WS_MAC
- QSKIP("On Mac, native key events are needed to test menu action activation", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("On Mac/WinCE, native key events are needed to test menu action activation", SkipAll);
#endif
#ifdef Q_OS_SYMBIAN
QSKIP("On Symbian OS, native key events are needed to test menu action activation", SkipAll);
@@ -490,8 +490,8 @@ void tst_QMenuBar::activatedCount()
void tst_QMenuBar::activatedCount_noQt3()
{
-#ifdef Q_WS_MAC
- QSKIP("On Mac, native key events are needed to test menu action activation", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("On Mac/WinCE, native key events are needed to test menu action activation", SkipAll);
#endif
// create a popup menu with menu items set the accelerators later...
initSimpleMenubar_noQt3();
@@ -892,8 +892,8 @@ void tst_QMenuBar::insertItem_QString_QObject_noQt3()
void tst_QMenuBar::check_accelKeys()
{
-#ifdef Q_WS_MAC
- QSKIP("On Mac, native key events are needed to test menu action activation", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("On Mac/WinCE, native key events are needed to test menu action activation", SkipAll);
#endif
#ifdef QT3_SUPPORT
initComplexMenubar();
@@ -965,8 +965,8 @@ void tst_QMenuBar::check_accelKeys()
void tst_QMenuBar::check_cursorKeys1()
{
-#ifdef Q_WS_MAC
- QSKIP("Qt/Mac does not use the native popups/menubar", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
#ifdef QT3_SUPPORT
@@ -1000,8 +1000,8 @@ void tst_QMenuBar::check_cursorKeys1()
void tst_QMenuBar::check_cursorKeys2()
{
-#ifdef Q_WS_MAC
- QSKIP("Qt/Mac does not use the native popups/menubar", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
#ifdef QT3_SUPPORT
@@ -1034,8 +1034,8 @@ void tst_QMenuBar::check_cursorKeys2()
*/
void tst_QMenuBar::check_cursorKeys3()
{
-#ifdef Q_WS_MAC
- QSKIP("Qt/Mac does not use the native popups/menubar", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
#ifdef QT3_SUPPORT
@@ -1190,8 +1190,8 @@ void tst_QMenuBar::check_escKey()
void tst_QMenuBar::check_escKey_noQt3()
{
-#ifdef Q_WS_MAC
- QSKIP("Qt/Mac does not use the native popups/menubar", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
initComplexMenubar_noQt3();
@@ -1333,7 +1333,7 @@ void tst_QMenuBar::check_escKey_noQt3()
void
tst_QMenuBar::allowActiveAndDisabled()
{
-#ifndef Q_WS_MAC
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
mb->hide();
mb->clear();
@@ -1341,7 +1341,6 @@ tst_QMenuBar::allowActiveAndDisabled()
// disabled menu items are added
QMenu fileMenu("&File");
- QAction disabledAction() ;
// Task 241043 : check that second menu is activated
// if all items are disabled
QAction *act = fileMenu.addAction("Disabled");
@@ -1398,8 +1397,8 @@ void tst_QMenuBar::check_altPress()
void tst_QMenuBar::check_shortcutPress()
{
-#ifdef Q_WS_MAC
- QSKIP("Qt/Mac does not use the native popups/menubar", SkipAll);
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM)
+ QSKIP("Qt/Mac,WinCE does not use the native popups/menubar", SkipAll);
#endif
#ifdef QT3_SUPPORT
@@ -1434,7 +1433,7 @@ void tst_QMenuBar::check_menuPosition()
#ifdef Q_WS_MAC
QSKIP("Qt/Mac does not use the native popups/menubar", SkipAll);
#endif
-#ifdef Q_OS_WINCE
+#ifdef Q_OS_WINCE_WM
QSKIP("Qt/CE uses native menubar", SkipAll);
#endif
QMenu menu;
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index b3b7f33f53..3d04a0f8f5 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -257,11 +257,7 @@ private slots:
void on_child1_destroyed() { ++invokeCount2; }
};
-#if QT_VERSION >= 0x040200
#define FUNCTION(x) "QMetaObject::" x ": "
-#else
-#define FUNCTION(x) "QMetaObject::" x "(): "
-#endif
void tst_QMetaObject::connectSlotsByName()
{
diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp
index eccf7e6399..d71f470b10 100644
--- a/tests/auto/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/qmetatype/tst_qmetatype.cpp
@@ -127,7 +127,6 @@ protected:
void tst_QMetaType::threadSafety()
{
-#if QT_VERSION >= 0x040100
MetaTypeTorturer t1;
MetaTypeTorturer t2;
MetaTypeTorturer t3;
@@ -139,7 +138,6 @@ void tst_QMetaType::threadSafety()
QVERIFY(t1.wait());
QVERIFY(t2.wait());
QVERIFY(t3.wait());
-#endif
}
namespace TestSpace
diff --git a/tests/auto/qmovie/tst_qmovie.cpp b/tests/auto/qmovie/tst_qmovie.cpp
index dd24f97efb..23b057b075 100644
--- a/tests/auto/qmovie/tst_qmovie.cpp
+++ b/tests/auto/qmovie/tst_qmovie.cpp
@@ -71,9 +71,7 @@ private slots:
void playMovie();
void jumpToFrame_data();
void jumpToFrame();
-#if QT_VERSION >= 0x040101
void changeMovieFile();
-#endif // QT_VERSION
};
// Testing get/set functions
@@ -201,7 +199,6 @@ void tst_QMovie::jumpToFrame()
QVERIFY(movie.currentFrameNumber() == 0);
}
-#if QT_VERSION >= 0x040101
void tst_QMovie::changeMovieFile()
{
QMovie movie("animations/comicsecard.gif");
@@ -211,7 +208,5 @@ void tst_QMovie::changeMovieFile()
QVERIFY(movie.currentFrameNumber() == -1);
}
-#endif // QT_VERSION
-
QTEST_MAIN(tst_QMovie)
#include "tst_qmovie.moc"
diff --git a/tests/auto/qmutexlocker/tst_qmutexlocker.cpp b/tests/auto/qmutexlocker/tst_qmutexlocker.cpp
index cb5112dc5a..cc3e1442b1 100644
--- a/tests/auto/qmutexlocker/tst_qmutexlocker.cpp
+++ b/tests/auto/qmutexlocker/tst_qmutexlocker.cpp
@@ -194,9 +194,6 @@ void tst_QMutexLocker::unlockAndRelockTest()
void tst_QMutexLocker::lockerStateTest()
{
-#if QT_VERSION < 0x040200
- QSKIP("QMutexLocker doesn't keep state in Qt < 4.2", SkipAll);
-#else
class LockerStateThread : public tst_QMutexLockerThread
{
public:
@@ -233,7 +230,6 @@ void tst_QMutexLocker::lockerStateTest()
delete thread;
thread = 0;
-#endif
}
QTEST_MAIN(tst_QMutexLocker)
diff --git a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
index 337425744e..146bc7b3f7 100644
--- a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
+++ b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
@@ -42,8 +42,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION >= 0x040100
-
#ifdef Q_OS_WIN
#include <winsock2.h>
#endif
@@ -707,7 +705,3 @@ void tst_QNativeSocketEngine::receiveUrgentData()
QTEST_MAIN(tst_QNativeSocketEngine)
#include "tst_qnativesocketengine.moc"
-
-#else // QT_VERSION
-QTEST_NOOP_MAIN
-#endif
diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
index 9010db41ee..36a4b458dd 100644
--- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -286,8 +286,263 @@ void tst_QNetworkCookie::parseSingleCookie_data()
QTest::newRow("expiration3") << "a=b; expires=Wednesday, 09-Nov-1999 23:12:40 GMT " << cookie;
QTest::newRow("expiration-utc") << "a=b;expires=Wednesday, 09-Nov-1999 23:12:40 UTC" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC));
+ QTest::newRow("time-0") << "a=b;expires=14 Apr 89 03:20" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 0), Qt::UTC));
+ QTest::newRow("time-1") << "a=b;expires=14 Apr 89 03:20:12" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC));
+ QTest::newRow("time-2") << "a=b;expires=14 Apr 89 03:20:12.88" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC));
+ QTest::newRow("time-3") << "a=b;expires=14 Apr 89 03:20:12.88am" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC));
+ QTest::newRow("time-4") << "a=b;expires=14 Apr 89 03:20:12.88pm" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC));
+ QTest::newRow("time-5") << "a=b;expires=14 Apr 89 03:20:12.88 Am" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC));
+ QTest::newRow("time-6") << "a=b;expires=14 Apr 89 03:20:12.88 PM" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC));
+ QTest::newRow("time-7") << "a=b;expires=14 Apr 89 3:20:12.88 PM" << cookie;
+
+ // normal months
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-1") << "a=b;expires=Jan 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 2, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-2") << "a=b;expires=Feb 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 3, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-3") << "a=b;expires=mar 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-4") << "a=b;expires=Apr 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 5, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-5") << "a=b;expires=May 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 6, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-6") << "a=b;expires=Jun 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 7, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-7") << "a=b;expires=Jul 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 8, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-8") << "a=b;expires=Aug 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 9, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-9") << "a=b;expires=Sep 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 10, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-10") << "a=b;expires=Oct 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 11, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-11") << "a=b;expires=Nov 1 89 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-12") << "a=b;expires=Dec 1 89 1:1" << cookie;
+
+ // extra months
+ cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-13") << "a=b;expires=December 1 89 1:1" << cookie;
+ QTest::newRow("months-14") << "a=b;expires=1 89 1:1 Dec" << cookie;
+ //cookie.setExpirationDate(QDateTime());
+ //QTest::newRow("months-15") << "a=b;expires=1 89 1:1 De" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-16") << "a=b;expires=2024 29 Feb 1:1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC));
+ QTest::newRow("months-17") << "a=b;expires=Fri, 29-Feb-2024 01:01:00 GMT" << cookie;
+ QTest::newRow("months-18") << "a=b;expires=2024 29 Feb 1:1 GMT" << cookie;
+
+ // normal offsets
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-0") << "a=b;expires=Jan 1 89 8:0 PST" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-1") << "a=b;expires=Jan 1 89 8:0 PDT" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-2") << "a=b;expires=Jan 1 89 7:0 MST" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-3") << "a=b;expires=Jan 1 89 7:0 MDT" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-4") << "a=b;expires=Jan 1 89 6:0 CST" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-5") << "a=b;expires=Jan 1 89 6:0 CDT" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-6") << "a=b;expires=Jan 1 89 5:0 EST" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-7") << "a=b;expires=Jan 1 89 5:0 EDT" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-8") << "a=b;expires=Jan 1 89 4:0 AST" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-9") << "a=b;expires=Jan 1 89 3:0 NST" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-10") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-11") << "a=b;expires=Jan 1 89 0:0 BST" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-12") << "a=b;expires=Jan 1 89 23:0 MET" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-13") << "a=b;expires=Jan 1 89 22:0 EET" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST" << cookie;
+
+ // extra offsets
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST+1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-15") << "a=b;expires=Jan 1 89 0:0 GMT+1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-15b") << "a=b;expires=Jan 1 89 1:0 GMT-1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-16") << "a=b;expires=Jan 1 89 0:0 GMT+01" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 5), Qt::UTC));
+ QTest::newRow("zoneoffset-17") << "a=b;expires=Jan 1 89 0:0 GMT+0105" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-18") << "a=b;expires=Jan 1 89 0:0 GMT+015" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-19") << "a=b;expires=Jan 1 89 0:0 GM" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-19b") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie;
+
+ // offsets from gmt
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-20") << "a=b;expires=Jan 1 89 0:0 +1" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-21") << "a=b;expires=Jan 1 89 0:0 +01" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC));
+ QTest::newRow("zoneoffset-22") << "a=b;expires=Jan 1 89 0:0 +0101" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("zoneoffset-23") << "a=b;expires=Jan 1 89 1:0 -1" << cookie;
+
+ // Y2k
+ cookie.setExpirationDate(QDateTime(QDate(2000, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("year-0") << "a=b;expires=Jan 1 00 0:0" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("year-1") << "a=b;expires=Jan 1 70 0:0" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1971, 1, 1), QTime(0, 0), Qt::UTC));
+ QTest::newRow("year-2") << "a=b;expires=Jan 1 71 0:0" << cookie;
+
+ // Day, month, year
+ cookie.setExpirationDate(QDateTime(QDate(2013, 1, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("date-0") << "a=b;expires=Jan 2 13 0:0" << cookie;
+ QTest::newRow("date-1") << "a=b;expires=1-2-13 0:0" << cookie;
+ QTest::newRow("date-2") << "a=b;expires=1/2/13 0:0" << cookie;
+ QTest::newRow("date-3") << "a=b;expires=Jan 2 13 0:0" << cookie;
+ QTest::newRow("date-4") << "a=b;expires=Jan 2, 13 0:0" << cookie;
+ QTest::newRow("date-5") << "a=b;expires=1-2-13 0:0" << cookie;
+ QTest::newRow("date-6") << "a=b;expires=1/2/13 0:0" << cookie;
+
+ // Known Year, determine month and day
+ cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC));
+ QTest::newRow("knownyear-0") << "a=b;expires=13/1/95 0:0" << cookie;
+ QTest::newRow("knownyear-1") << "a=b;expires=95/13/1 0:0" << cookie;
+ QTest::newRow("knownyear-2") << "a=b;expires=1995/1/13 0:0" << cookie;
+ QTest::newRow("knownyear-3") << "a=b;expires=1995/13/1 0:0" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(1995, 1, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("knownyear-4") << "a=b;expires=1/2/95 0:0" << cookie;
+ QTest::newRow("knownyear-5") << "a=b;expires=95/1/2 0:0" << cookie;
+
+ // Known Year, Known day, determining month
+ cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC));
+ QTest::newRow("knownYD-0") << "a=b;expires=13/1/95 0:0" << cookie;
+ QTest::newRow("knownYD-1") << "a=b;expires=1/13/95 0:0" << cookie;
+ QTest::newRow("knownYD-2") << "a=b;expires=95/13/1 0:0" << cookie;
+ QTest::newRow("knownYD-3") << "a=b;expires=95/1/13 0:0" << cookie;
+
+ // Month comes before Year
+ cookie.setExpirationDate(QDateTime(QDate(2021, 03, 26), QTime(0, 0), Qt::UTC));
+ QTest::newRow("month-0") << "a=b;expires=26/03/21 0:0" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(2015, 12, 30), QTime(16, 25, 0, 0), Qt::UTC));
+ QTest::newRow("month-1") << "a=b;expires=wed 16:25pm December 2015 30" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(2031, 11, 11), QTime(16, 25, 0, 0), Qt::UTC));
+ QTest::newRow("month-2") << "a=b;expires=16:25 11 31 11" << cookie;
+
+ // The very ambiguous cases
+ // Matching Firefox's behavior of guessing month, day, year in those cases
+ cookie.setExpirationDate(QDateTime(QDate(2013, 10, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("ambiguousd-0") << "a=b;expires=10/2/13 0:0" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(2013, 2, 10), QTime(0, 0), Qt::UTC));
+ QTest::newRow("ambiguousd-1") << "a=b;expires=2/10/13 0:0" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(2010, 2, 3), QTime(0, 0), Qt::UTC));
+ QTest::newRow("ambiguousd-2") << "a=b;expires=2/3/10 0:0" << cookie;
+
+ // FYI If you try these in Firefox it wont set a cookie for the following two string
+ // because 03 is turned into the year at which point it is expired
+ cookie.setExpirationDate(QDateTime(QDate(2003, 2, 10), QTime(0, 0), Qt::UTC));
+ QTest::newRow("ambiguousd-3") << "a=b;expires=2/10/3 0:0" << cookie;
+ cookie.setExpirationDate(QDateTime(QDate(2003, 10, 2), QTime(0, 0), Qt::UTC));
+ QTest::newRow("ambiguousd-4") << "a=b;expires=10/2/3 0:0" << cookie;
+
+ // These are the cookies that firefox's source says it can parse
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-0") << "a=b;expires=14 Apr 89 03:20" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-1") << "a=b;expires=14 Apr 89 03:20 GMT" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 33, 0), Qt::UTC));
+ QTest::newRow("firefox-2") << "a=b;expires=Fri, 17 Mar 89 4:01:33" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-3") << "a=b;expires=Fri, 17 Mar 89 4:01 GMT" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(16-8, 12, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-4") << "a=b;expires=Mon Jan 16 16:12 PDT 1989" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(17, 42, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-5") << "a=b;expires=Mon Jan 16 16:12 +0130 1989" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1992, 5, 6), QTime(16-9, 41, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-6") << "a=b;expires=6 May 1992 16:41-JST (Wednesday)" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(10, 59, 12, 82), Qt::UTC));
+ QTest::newRow("firefox-7") << "a=b;expires=22-AUG-1993 10:59:12.82" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(22, 59, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-8") << "a=b;expires=22-AUG-1993 10:59pm" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-9") << "a=b;expires=22-AUG-1993 12:59am" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-10") << "a=b;expires=22-AUG-1993 12:59 PM" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1995, 8, 4), QTime(15, 54, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-11") << "a=b;expires=Friday, August 04, 1995 3:54 PM" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1995, 6, 21), QTime(16, 24, 34, 0), Qt::UTC));
+ QTest::newRow("firefox-12") << "a=b;expires=06/21/95 04:24:34 PM" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1995, 6, 20), QTime(21, 7, 0, 0), Qt::UTC));
+ QTest::newRow("firefox-13") << "a=b;expires=20/06/95 21:07" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(1995, 6, 8), QTime(19-5, 32, 48, 0), Qt::UTC));
+ QTest::newRow("firefox-14") << "a=b;expires=95-06-08 19:32:48 EDT" << cookie;
+
+ // Edge cases caught by fuzzing
+ // These are about the default cause creates dates that don't exits
+ cookie.setExpirationDate(QDateTime(QDate(2030, 2, 25), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-0") << "a=b; expires=30 -000002 1:1 25;" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(2031, 11, 20), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-1") << "a=b; expires=31 11 20 1:1;" << cookie;
+
+ // April only has 30 days
+ cookie.setExpirationDate(QDateTime(QDate(2031, 4, 30), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-2") << "a=b; expires=31 30 4 1:1" << cookie;
+
+ // 9 must be the month so 31 can't be the day
+ cookie.setExpirationDate(QDateTime(QDate(2031, 9, 21), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-3") << "a=b; expires=31 21 9 1:1" << cookie;
+
+ // Year is known, then fallback to defaults of filling in month and day
+ cookie.setExpirationDate(QDateTime(QDate(2031, 11, 1), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-4") << "a=b; expires=31 11 01 1:1" << cookie;
+
+ // 2 must be the month so 30 can't be the day
+ cookie.setExpirationDate(QDateTime(QDate(2030, 2, 20), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-5") << "a=b; expires=30 02 20 1:1" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(2021, 12, 22), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-6") << "a=b; expires=2021 12 22 1:1" << cookie;
+
+ cookie.setExpirationDate(QDateTime(QDate(2029, 2, 23), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-7") << "a=b; expires=29 23 Feb 1:1" << cookie;
+
+ // 11 and 6 don't have 31 days
+ cookie.setExpirationDate(QDateTime(QDate(2031, 11, 06), QTime(1, 1, 0, 0), Qt::UTC));
+ QTest::newRow("fuzz-8") << "a=b; expires=31 11 06 1:1" << cookie;
+
// two-digit years:
// from 70 until 99, we assume 20th century
+ cookie.setExpirationDate(QDateTime(QDate(1999, 11, 9), QTime(23, 12, 40), Qt::UTC));
QTest::newRow("expiration-2digit1") << "a=b; expires=Wednesday, 09-Nov-99 23:12:40 GMT " << cookie;
cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(23, 12, 40), Qt::UTC));
QTest::newRow("expiration-2digit2") << "a=b; expires=Thursday, 01-Jan-70 23:12:40 GMT " << cookie;
@@ -315,6 +570,9 @@ void tst_QNetworkCookie::parseSingleCookie_data()
cookie.setExpirationDate(QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59), Qt::UTC));
QTest::newRow("network2") << "__siteid=1; expires=Fri, 31-Dec-9999 23:59:59 GMT; path=/" << cookie;
+ cookie = QNetworkCookie("YM.LC", "v=2&m=9993_262838_159_1558_1063_0_5649_4012_3776161073,9426_260205_549_1295_1336_0_5141_4738_3922731647,6733_258196_952_1364_643_0_3560_-1_0,3677_237633_1294_1294_19267_0_3244_29483_4102206176,1315_235149_1693_1541_941_0_3224_1691_1861378060,1858_214311_2100_1298_19538_0_2873_30900_716411652,6258_212007_2506_1285_1017_0_2868_3606_4288540264,3743_207884_2895_1362_2759_0_2545_7114_3388520216,2654_205253_3257_1297_1332_0_2504_4682_3048534803,1891_184881_3660_1291_19079_0_978_29178_2592538685&f=1&n=20&s=date&o=down&e=1196548712&b=Inbox&u=removed");
+ cookie.setPath("/");
+ cookie.setDomain("mail.yahoo.com");
QTest::newRow("network3") << "YM.LC=v=2&m=9993_262838_159_1558_1063_0_5649_4012_3776161073,9426_260205_549_1295_1336_0_5141_4738_3922731647,6733_258196_952_1364_643_0_3560_-1_0,3677_237633_1294_1294_19267_0_3244_29483_4102206176,1315_235149_1693_1541_941_0_3224_1691_1861378060,1858_214311_2100_1298_19538_0_2873_30900_716411652,6258_212007_2506_1285_1017_0_2868_3606_4288540264,3743_207884_2895_1362_2759_0_2545_7114_3388520216,2654_205253_3257_1297_1332_0_2504_4682_3048534803,1891_184881_3660_1291_19079_0_978_29178_2592538685&f=1&n=20&s=date&o=down&e=1196548712&b=Inbox&u=removed; path=/; domain=mail.yahoo.com" << cookie;
cookie = QNetworkCookie("__ac", "c2hhdXNtYW46U2FTYW80Wm8%3D");
@@ -330,13 +588,22 @@ void tst_QNetworkCookie::parseSingleCookie()
QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toLatin1());
- QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort);
- QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort);
+ //QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort);
QCOMPARE(result.count(), 1);
+ QEXPECT_FAIL("network3", "Cookie value contains commas, violating the HTTP spec", Abort);
QCOMPARE(result.at(0), expectedCookie);
result = QNetworkCookie::parseCookies(result.at(0).toRawForm());
QCOMPARE(result.count(), 1);
+
+ // Drop any millisecond information, if there's any
+ QDateTime dt = expectedCookie.expirationDate();
+ if (dt.isValid()) {
+ QTime t = dt.time();
+ dt.setTime(t.addMSecs(-t.msec()));
+ expectedCookie.setExpirationDate(dt);
+ }
+
QCOMPARE(result.at(0), expectedCookie);
}
@@ -358,9 +625,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
// reason: malformed NAME=VALUE pair
QTest::newRow("invalid-05") << "foo" << list;
QTest::newRow("invalid-06") << "=b" << list;
- QTest::newRow("invalid-08") << "a=b,foo" << list;
QTest::newRow("invalid-09") << "foo,a=b" << list;
- QTest::newRow("invalid-10") << "a=b,=b" << list;
QTest::newRow("invalid-11") << ";path=/" << list;
// reason: malformed expiration date string
@@ -369,8 +634,6 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
QTest::newRow("invalid-14") << "a=b;expires=foobar, abc" << list;
QTest::newRow("invalid-15") << "a=b;expires=foobar, dd-mmm-yyyy hh:mm:ss GMT; path=/" << list;
QTest::newRow("invalid-16") << "a=b;expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list;
- QTest::newRow("invalid-17") << "a=b,c=d;expires=" << list;
- QTest::newRow("invalid-18") << "a=b, c=d; expires=foobar, 32-Caz-1999 24:01:60 GMT; path=/" << list;
QNetworkCookie cookie;
cookie.setName("a");
@@ -417,6 +680,26 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
list << cookie;
QTest::newRow("network1") << "id=51706646077999719 bb=\"K14144t\"_AAQ\"ototrK_A_ttot44AQ4KwoRQtoto| adv=; Domain=.bluestreak.com; expires=Tuesday 05-Dec-2017 09:11:07 GMT; path=/;" << list;
+ QNetworkCookie cookieA;
+ cookieA.setName("a");
+ cookieA.setValue("b");
+
+ QNetworkCookie cookieB;
+ cookieB.setName("c");
+ cookieB.setValue("d");
+
+ // NewLine
+ cookieA.setExpirationDate(QDateTime(QDate(2009, 3, 10), QTime(7, 0, 0, 0), Qt::UTC));
+ cookieB.setExpirationDate(QDateTime(QDate(2009, 3, 20), QTime(7, 0, 0, 0), Qt::UTC));
+ list = QList<QNetworkCookie>() << cookieA << cookieB;
+ QTest::newRow("real-0") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
+ QTest::newRow("real-1") << "a=b; expires=Tue Mar 10 07:00:00 2009 GMT\n\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
+ QTest::newRow("real-2") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
+
+ // Match firefox's behavior
+ cookieA.setPath("/foo");
+ list = QList<QNetworkCookie>() << cookieA << cookieB;
+ QTest::newRow("real-3") << "a=b; expires=Mar 10 07:00:00 2009 GMT, Tue; path=/foo\nc=d; expires=Fri Mar 20 07:00:00 2009 GMT" << list;
}
void tst_QNetworkCookie::parseMultipleCookies()
diff --git a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
index a87b9afdfe..a1bb573d1c 100644
--- a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -42,10 +42,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <qcoreapplication.h>
#include <qnetworkinterface.h>
#include <qtcpsocket.h>
@@ -217,5 +213,3 @@ void tst_QNetworkInterface::copyInvalidInterface()
QTEST_MAIN(tst_QNetworkInterface)
#include "tst_qnetworkinterface.moc"
-
-#endif
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 2d4bc61639..d7faa7351a 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -2267,9 +2267,6 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket_data()
void tst_QNetworkReply::ioPutToFileFromLocalSocket()
{
-#if defined(Q_OS_WINCE) && QT_VERSION < 0x040500
- QSKIP("No local sockets on Windows CE for Qt 4.4", SkipAll);
-#else
QString socketname = "networkreplytest";
QLocalServer server;
if (!server.listen(socketname)) {
@@ -2307,7 +2304,6 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket()
QCOMPARE(file.size(), qint64(data.size()));
QByteArray contents = file.readAll();
QCOMPARE(contents, data);
-#endif
}
void tst_QNetworkReply::ioPutToFileFromProcess_data()
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index dd65579884..ada4fcbd55 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -264,13 +264,9 @@ void tst_QObject::disconnect()
QCOMPARE( r1->called(1), FALSE );
r1->reset();
-#if QT_VERSION >= 0x030100
QCOMPARE( ret, TRUE );
-#endif
ret = QObject::disconnect( s, SIGNAL( signal1() ), r1, SLOT( slot1() ) );
-#if QT_VERSION >= 0x030100
QCOMPARE( ret, FALSE );
-#endif
// disconnect all signals from s from all slots from r1
QObject::disconnect( s, 0, r1, 0 );
@@ -702,12 +698,10 @@ void tst_QObject::connectDisconnectNotify()
QCOMPARE( s->org_signal, s->nw_signal );
QCOMPARE( s->org_signal.toLatin1(), QMetaObject::normalizedSignature(a_signal.toLatin1().constData()) );
-#if QT_VERSION > 0x040101
// Reconnect
connect( (SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1() );
// Test disconnectNotify for a complete disconnect
((SenderObject*)s)->disconnect((ReceiverObject*)r);
-#endif
delete s;
delete r;
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 12f0113243..0cb8346f08 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -207,6 +207,10 @@ private slots:
void drawImage_task217400_data();
void drawImage_task217400();
void drawRect_task215378();
+ void drawRect_task247505();
+
+ void drawImage_data();
+ void drawImage();
void clippedImage();
@@ -2572,23 +2576,6 @@ void tst_QPainter::setOpacity()
p.fillRect(imageRect, QColor(127, 127, 127));
p.end();
-#if defined(Q_WS_QWS) && (QT_VERSION < 0x040500)
- // embedded has an optimized implementation in 4.4
- if ((dest.format() == QImage::Format_ARGB8555_Premultiplied ||
- dest.format() == QImage::Format_RGB555 ||
- dest.format() == QImage::Format_RGB666 ||
- dest.format() == QImage::Format_RGB888 ||
- dest.format() == QImage::Format_ARGB8565_Premultiplied) &&
- src.format() != QImage::Format_RGB32)
- {
- QColor c1 = expected.pixel(1, 1);
- QColor c2 = dest.pixel(1, 1);
- QVERIFY(qAbs(c1.red() - c2.red()) < 2);
- QVERIFY(qAbs(c1.green() - c2.green()) < 2);
- QVERIFY(qAbs(c1.blue() - c2.blue()) < 2);
- QVERIFY(qAbs(c1.alpha() - c2.alpha()) < 2);
- } else
-#endif
QCOMPARE(dest, expected);
}
@@ -3589,6 +3576,97 @@ void tst_QPainter::drawRect_task215378()
QVERIFY(img.pixel(0, 0) != img.pixel(1, 1));
}
+void tst_QPainter::drawRect_task247505()
+{
+ QImage a(10, 10, QImage::Format_ARGB32_Premultiplied);
+ a.fill(0);
+ QImage b = a;
+
+ QPainter p(&a);
+ p.setPen(Qt::NoPen);
+ p.setBrush(Qt::black);
+ p.drawRect(QRectF(10, 0, -10, 10));
+ p.end();
+ p.begin(&b);
+ p.setPen(Qt::NoPen);
+ p.setBrush(Qt::black);
+ p.drawRect(QRectF(0, 0, 10, 10));
+ p.end();
+
+ QCOMPARE(a, b);
+}
+
+void tst_QPainter::drawImage_data()
+{
+ QTest::addColumn<int>("x");
+ QTest::addColumn<int>("y");
+ QTest::addColumn<int>("w");
+ QTest::addColumn<int>("h");
+ QTest::addColumn<QImage::Format>("srcFormat");
+ QTest::addColumn<QImage::Format>("dstFormat");
+
+ for (int srcFormat = QImage::Format_Mono; srcFormat < QImage::NImageFormats; ++srcFormat) {
+ for (int dstFormat = QImage::Format_Mono; dstFormat < QImage::NImageFormats; ++dstFormat) {
+ if (dstFormat == QImage::Format_Indexed8)
+ continue;
+ for (int odd_x = 0; odd_x <= 1; ++odd_x) {
+ for (int odd_width = 0; odd_width <= 1; ++odd_width) {
+ QString description =
+ QString("srcFormat %1, dstFormat %2, odd x: %3, odd width: %4")
+ .arg(srcFormat).arg(dstFormat).arg(odd_x).arg(odd_width);
+
+ QTest::newRow(qPrintable(description)) << (10 + odd_x) << 10 << (20 + odd_width) << 20
+ << QImage::Format(srcFormat)
+ << QImage::Format(dstFormat);
+ }
+ }
+ }
+ }
+}
+
+bool verifyImage(const QImage &img, int x, int y, int w, int h, uint background)
+{
+ int imgWidth = img.width();
+ int imgHeight = img.height();
+ for (int i = 0; i < imgHeight; ++i) {
+ for (int j = 0; j < imgWidth; ++j) {
+ uint pixel = img.pixel(j, i);
+ bool outside = j < x || j >= (x + w) || i < y || i >= (y + h);
+ if (outside != (pixel == background)) {
+ //printf("%d %d, expected %x, got %x, outside: %d\n", x, y, background, pixel, outside);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+void tst_QPainter::drawImage()
+{
+ QFETCH(int, x);
+ QFETCH(int, y);
+ QFETCH(int, w);
+ QFETCH(int, h);
+ QFETCH(QImage::Format, srcFormat);
+ QFETCH(QImage::Format, dstFormat);
+
+ QImage dst(40, 40, QImage::Format_RGB32);
+ dst.fill(0xffffffff);
+
+ dst = dst.convertToFormat(dstFormat);
+ uint background = dst.pixel(0, 0);
+
+ QImage src(w, h, QImage::Format_RGB32);
+ src.fill(0xff000000);
+ src = src.convertToFormat(srcFormat);
+
+ QPainter p(&dst);
+ p.drawImage(x, y, src);
+ p.end();
+
+ QVERIFY(verifyImage(dst, x, y, w, h, background));
+}
void tst_QPainter::imageCoordinateLimit()
{
@@ -3717,8 +3795,11 @@ void tst_QPainter::imageBlending()
void tst_QPainter::paintOnNullPixmap()
{
+ QPixmap pix(16, 16);
+
QPixmap textPixmap;
QPainter p(&textPixmap);
+ p.drawPixmap(10, 10, pix);
p.end();
QPixmap textPixmap2(16,16);
diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp
index cff84e9f95..3d77f5ec19 100644
--- a/tests/auto/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp
@@ -84,11 +84,9 @@ private slots:
void testOperatorEquals_fuzzy();
void testOperatorDatastream();
-#if QT_VERSION >= 0x040200
void testArcMoveTo_data();
void testArcMoveTo();
void setElementPositionAt();
-#endif
void testOnPath_data();
void testOnPath();
@@ -819,7 +817,6 @@ void tst_QPainterPath::closing()
}
}
-#if QT_VERSION >= 0x040200
void tst_QPainterPath::testArcMoveTo_data()
{
QTest::addColumn<QRectF>("rect");
@@ -1170,8 +1167,6 @@ void tst_QPainterPath::connectPathDuplicatePoint()
QCOMPARE(c, a);
}
-#endif
-
QTEST_APPLESS_MAIN(tst_QPainterPath)
#include "tst_qpainterpath.moc"
diff --git a/tests/auto/qpicture/tst_qpicture.cpp b/tests/auto/qpicture/tst_qpicture.cpp
index 43559e57fe..954be235fc 100644
--- a/tests/auto/qpicture/tst_qpicture.cpp
+++ b/tests/auto/qpicture/tst_qpicture.cpp
@@ -121,12 +121,10 @@ void tst_QPicture::boundingRect()
// default value
QVERIFY( !p1.boundingRect().isValid() );
-#if QT_VERSION >= 0x030100
QRect r1( 20, 30, 5, 15 );
p1.setBoundingRect( r1 );
QCOMPARE( p1.boundingRect(), r1 );
p1.setBoundingRect(QRect());
-#endif
QPainter pt( &p1 );
pt.drawLine( 10, 20, 110, 80 );
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index b8f3ca2f96..493333bd0a 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -105,6 +105,7 @@ private slots:
void grabWidget();
void grabWindow();
void isNull();
+ void task_246446();
#ifdef Q_WS_QWS
void convertFromImageNoDetach();
@@ -1028,5 +1029,20 @@ void tst_QPixmap::fromData()
QCOMPARE(img.pixel(0, 1), QRgb(0xff000000));
}
+void tst_QPixmap::task_246446()
+{
+ // This crashed without the bugfix in 246446
+ QPixmap pm(10, 10);
+ pm.fill(Qt::transparent); // force 32-bit depth
+ QBitmap bm;
+ pm.setMask(bm);
+ {
+ QPixmap pm2(pm);
+ }
+ QVERIFY(pm.width() == 10);
+ QVERIFY(pm.mask().isNull());
+}
+
+
QTEST_MAIN(tst_QPixmap)
#include "tst_qpixmap.moc"
diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp
index 0febb87358..a598bfc2b1 100644
--- a/tests/auto/qprinter/tst_qprinter.cpp
+++ b/tests/auto/qprinter/tst_qprinter.cpp
@@ -121,9 +121,6 @@ void tst_QPrinter::getSetCheck()
obj1.setCollateCopies(false);
QCOMPARE(false, obj1.collateCopies());
obj1.setCollateCopies(true);
-#if !defined(Q_OS_UNIX) && QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Apparently only the Unix (ps) printer supports collate at the moment", Continue);
-#endif
QCOMPARE(true, obj1.collateCopies());
obj1.setColorMode(QPrinter::GrayScale);
@@ -185,9 +182,6 @@ void tst_QPrinter::getSetCheck()
obj1.setFontEmbeddingEnabled(false);
QCOMPARE(false, obj1.fontEmbeddingEnabled());
obj1.setFontEmbeddingEnabled(true);
-#if !defined(Q_OS_UNIX) && QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Apparently only the Unix (ps) printer supports font embedding at the moment", Continue);
-#endif
QCOMPARE(true, obj1.fontEmbeddingEnabled());
// PageSize QPrinter::pageSize()
@@ -255,20 +249,13 @@ void tst_QPrinter::cleanup()
void tst_QPrinter::testPageSetupDialog()
{
-#if QT_VERSION < 0x040102
- QSKIP("QPrinter::OutputFormat doesn't exist in Qt 4.0.x and test crashes on < 4.1.2");
-#else
-
// Make sure this doesn't crash at least
{
QPrinter printer;
QPageSetupDialog dialog(&printer);
}
-#endif
}
-
-
void tst_QPrinter::testPageSize()
{
#if defined (Q_WS_WIN)
@@ -332,10 +319,6 @@ void tst_QPrinter::testPageRectAndPaperRect_data()
void tst_QPrinter::testPageRectAndPaperRect()
{
-#if QT_VERSION <= 0x040100
- QEXPECT_FAIL("", "Fixed in Qt 4.1.1", Continue);
-#endif
-
QFETCH(bool, withPainter);
QFETCH(int, orientation);
QFETCH(int, resolution);
@@ -529,9 +512,6 @@ void tst_QPrinter::testMulitpleSets()
QPrinter::PageSize printerPageSize = QPrinter::PageSize(pageSize);
QPrinter printer(mode);
printer.setFullPage(true);
-#if QT_VERSION < 0x040103
- QEXPECT_FAIL("", "Fixed in Qt 4.1.3", SkipAll);
-#endif
int paperWidth, paperHeight;
//const int Tolerance = 2;
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index 428cf41a0d..2610af9394 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -143,6 +143,8 @@ private slots:
void switchReadChannels();
void setWorkingDirectory();
void startFinishStartFinish();
+ void invalidProgramString_data();
+ void invalidProgramString();
// keep these at the end, since they use lots of processes and sometimes
// caused obscure failures to occur in tests that followed them (esp. on the Mac)
@@ -276,11 +278,9 @@ void tst_QProcess::simpleStart()
//-----------------------------------------------------------------------------
void tst_QProcess::startDetached()
{
-#if QT_VERSION >= 0x040200
QProcess proc;
QVERIFY(proc.startDetached("testProcessNormal/testProcessNormal",
QStringList() << "arg1" << "arg2"));
-#endif
QCOMPARE(QProcess::startDetached("nonexistingexe"), false);
}
@@ -2219,5 +2219,29 @@ void tst_QProcess::startFinishStartFinish()
}
}
+//-----------------------------------------------------------------------------
+void tst_QProcess::invalidProgramString_data()
+{
+ QTest::addColumn<QString>("programString");
+ QTest::newRow("null string") << QString();
+ QTest::newRow("empty string") << QString("");
+ QTest::newRow("only blank string") << QString(" ");
+}
+
+void tst_QProcess::invalidProgramString()
+{
+ QFETCH(QString, programString);
+ QProcess process;
+
+ qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
+ QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError)));
+
+ process.start(programString);
+ QCOMPARE(process.error(), QProcess::FailedToStart);
+ QCOMPARE(spy.count(), 1);
+
+ QVERIFY(!QProcess::startDetached(programString));
+}
+
QTEST_MAIN(tst_QProcess)
#include "tst_qprocess.moc"
diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp
index 34dd313225..27dec9d327 100644
--- a/tests/auto/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp
@@ -206,11 +206,7 @@ void tst_QPushButton::setAutoRepeat()
QVERIFY( !testWidget->isCheckable() );
// verify autorepeat is off by default.
-#if QT_VERSION < 0x040000
- QButton tmp( 0 );
-#else
QPushButton tmp( 0 );
-#endif
tmp.setObjectName("tmp");
QVERIFY( !tmp.autoRepeat() );
diff --git a/tests/auto/qreadlocker/tst_qreadlocker.cpp b/tests/auto/qreadlocker/tst_qreadlocker.cpp
index c650ff510e..a37f93ca0a 100644
--- a/tests/auto/qreadlocker/tst_qreadlocker.cpp
+++ b/tests/auto/qreadlocker/tst_qreadlocker.cpp
@@ -189,9 +189,6 @@ void tst_QReadLocker::unlockAndRelockTest()
void tst_QReadLocker::lockerStateTest()
{
-#if QT_VERSION < 0x040200
- QSKIP("QReadLocker doesn't keep state in Qt < 4.2", SkipAll);
-#else
class LockerStateThread : public tst_QReadLockerThread
{
public:
@@ -228,7 +225,6 @@ void tst_QReadLocker::lockerStateTest()
delete thread;
thread = 0;
-#endif
}
QTEST_MAIN(tst_QReadLocker)
diff --git a/tests/auto/qrect/tst_qrect.cpp b/tests/auto/qrect/tst_qrect.cpp
index a459b7dd8e..51ef169c8d 100644
--- a/tests/auto/qrect/tst_qrect.cpp
+++ b/tests/auto/qrect/tst_qrect.cpp
@@ -432,14 +432,12 @@ void tst_QRect::normalized_data()
QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << QRect( -10, -10, 5, 5 );
QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << getQRectCase( NullQRect );
QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << getQRectCase( EmptyQRect );
-#if QT_VERSION > 0x040001
QTest::newRow( "Task80908") << QRect(100, 200, 100, 0) << QRect(100, 200, 100, 0);
// Since "NegativeSizeQRect passes, I expect both of these to pass too.
// This passes, since height() returns -1 before normalization
QTest::newRow( "Task85023") << QRect(QPoint(100,201), QPoint(199,199)) << QRect(QPoint(100,199), QPoint(199,201));
// This, on the other hand height() returns 0 before normalization.
QTest::newRow( "Task85023.1") << QRect(QPoint(100,200), QPoint(199,199)) << QRect(QPoint(100,199), QPoint(199,200));
-#endif
QTest::newRow( "Task188109" ) << QRect(QPoint(263, 113), QPoint(136, 112)) << QRect(QPoint(136, 113), QPoint(263, 112));
}
@@ -1733,14 +1731,12 @@ void tst_QRect::newSetTopLeft_data()
void tst_QRect::newSetTopLeft()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( QPoint, topLeft );
QFETCH( QRect, nr );
r.setTopLeft( topLeft );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::newSetBottomRight_data()
@@ -1961,7 +1957,6 @@ void tst_QRect::newSetBottomRight_data()
void tst_QRect::newSetBottomRight()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( QPoint, bottomRight );
QFETCH( QRect, nr );
@@ -1969,7 +1964,6 @@ void tst_QRect::newSetBottomRight()
r.setBottomRight( bottomRight );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::newSetTopRight_data()
@@ -2190,7 +2184,6 @@ void tst_QRect::newSetTopRight_data()
void tst_QRect::newSetTopRight()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( QPoint, topRight );
QFETCH( QRect, nr );
@@ -2198,7 +2191,6 @@ void tst_QRect::newSetTopRight()
r.setTopRight( topRight );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::newSetBottomLeft_data()
@@ -2419,7 +2411,6 @@ void tst_QRect::newSetBottomLeft_data()
void tst_QRect::newSetBottomLeft()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( QPoint, bottomLeft );
QFETCH( QRect, nr );
@@ -2427,7 +2418,6 @@ void tst_QRect::newSetBottomLeft()
r.setBottomLeft( bottomLeft );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::topLeft_data()
@@ -2787,7 +2777,6 @@ void tst_QRect::newMoveLeft_data()
void tst_QRect::newMoveLeft()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( int, left );
QFETCH( QRect, nr );
@@ -2795,7 +2784,6 @@ void tst_QRect::newMoveLeft()
r.moveLeft( left );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::newMoveTop_data()
@@ -2958,7 +2946,6 @@ void tst_QRect::newMoveTop_data()
void tst_QRect::newMoveTop()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( int, top );
QFETCH( QRect, nr );
@@ -2966,7 +2953,6 @@ void tst_QRect::newMoveTop()
r.moveTop( top );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::newMoveRight_data()
@@ -3114,7 +3100,6 @@ void tst_QRect::newMoveRight_data()
void tst_QRect::newMoveRight()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( int, right );
QFETCH( QRect, nr );
@@ -3122,7 +3107,6 @@ void tst_QRect::newMoveRight()
r.moveRight( right );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::newMoveBottom_data()
@@ -3270,7 +3254,6 @@ void tst_QRect::newMoveBottom_data()
void tst_QRect::newMoveBottom()
{
-#if QT_VERSION >= 0x030100
QFETCH( QRect, r );
QFETCH( int, bottom );
QFETCH( QRect, nr );
@@ -3278,7 +3261,6 @@ void tst_QRect::newMoveBottom()
r.moveBottom( bottom );
QCOMPARE( r, nr );
-#endif
}
void tst_QRect::newMoveTopLeft_data()
@@ -3468,7 +3450,6 @@ void tst_QRect::newMoveTopLeft_data()
void tst_QRect::newMoveTopLeft()
{
-#if QT_VERSION >= 0x030100
QFETCH(QRect,r);
QFETCH(QPoint,topLeft);
QFETCH(QRect,nr);
@@ -3476,7 +3457,6 @@ void tst_QRect::newMoveTopLeft()
r.moveTopLeft(topLeft);
QCOMPARE(r,nr);
-#endif
}
void tst_QRect::newMoveBottomRight_data()
@@ -3666,7 +3646,6 @@ void tst_QRect::newMoveBottomRight_data()
void tst_QRect::newMoveBottomRight()
{
-#if QT_VERSION >= 0x030100
QFETCH(QRect,r);
QFETCH(QPoint,bottomRight);
QFETCH(QRect,nr);
@@ -3674,11 +3653,9 @@ void tst_QRect::newMoveBottomRight()
r.moveBottomRight(bottomRight);
QCOMPARE(r,nr);
-#endif
}
-
void tst_QRect::translate_data()
{
QTest::addColumn<QRect>("r");
@@ -3720,10 +3697,8 @@ void tst_QRect::translate()
}
-
void tst_QRect::moveTop()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 10, 10, 100, 100 );
r.moveTop( 3 );
@@ -3742,12 +3717,10 @@ void tst_QRect::moveTop()
r.moveTop( -22 );
QCOMPARE( r, QRectF(10, -22, 100, 100) );
}
-#endif
}
void tst_QRect::moveBottom()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 10, -22, 100, 100 );
r.moveBottom( 104 );
@@ -3758,12 +3731,10 @@ void tst_QRect::moveBottom()
r.moveBottom( 104 );
QCOMPARE( r, QRectF(10, 4, 100, 100) );
}
-#endif
}
void tst_QRect::moveLeft()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 10, 5, 100, 100 );
r.moveLeft( 11 );
@@ -3774,12 +3745,10 @@ void tst_QRect::moveLeft()
r.moveLeft( 11 );
QCOMPARE( r, QRectF(11, 5, 100, 100) );
}
-#endif
}
void tst_QRect::moveRight()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 11, 5, 100, 100 );
r.moveRight( 106 );
@@ -3790,7 +3759,6 @@ void tst_QRect::moveRight()
r.moveRight( 106 );
QCOMPARE( r, QRectF(6, 5, 100, 100) );
}
-#endif
}
void tst_QRect::moveTopLeft()
@@ -3851,7 +3819,6 @@ void tst_QRect::moveBottomRight()
void tst_QRect::setTopLeft()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 20, 10, 200, 100 );
r.setTopLeft( QPoint(5, 7) );
@@ -3862,12 +3829,10 @@ void tst_QRect::setTopLeft()
r.setTopLeft( QPoint(5, 7) );
QCOMPARE( r, QRectF(5, 7, 215, 103) );
}
-#endif
}
void tst_QRect::setTopRight()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 20, 10, 200, 100 );
r.setTopRight( QPoint(225, 7) );
@@ -3878,12 +3843,10 @@ void tst_QRect::setTopRight()
r.setTopRight( QPoint(225, 7) );
QCOMPARE( r, QRectF(20, 7, 205, 103) );
}
-#endif
}
void tst_QRect::setBottomLeft()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 20, 10, 200, 100 );
r.setBottomLeft( QPoint(5, 117) );
@@ -3894,12 +3857,10 @@ void tst_QRect::setBottomLeft()
r.setBottomLeft( QPoint(5, 117) );
QCOMPARE( r, QRectF(5, 10, 215, 107) );
}
-#endif
}
void tst_QRect::setBottomRight()
{
-#if QT_VERSION >= 0x030100
{
QRect r( 20, 10, 200, 100 );
r.setBottomRight( QPoint(225, 117) );
@@ -3910,7 +3871,6 @@ void tst_QRect::setBottomRight()
r.setBottomRight( QPoint(225, 117) );
QCOMPARE( r, QRectF(20, 10, 205, 107) );
}
-#endif
}
void tst_QRect::operator_amp()
diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp
index 647fe6d6a6..efafbe466f 100644
--- a/tests/auto/qregexp/tst_qregexp.cpp
+++ b/tests/auto/qregexp/tst_qregexp.cpp
@@ -557,7 +557,6 @@ void tst_QRegExp::setMinimal()
void tst_QRegExp::exactMatch()
{
-#if QT_VERSION >= 0x030100
QRegExp rx_d( "\\d" );
QRegExp rx_s( "\\s" );
QRegExp rx_w( "\\w" );
@@ -570,9 +569,7 @@ void tst_QRegExp::exactMatch()
bool is_d = ( ch.category() == QChar::Number_DecimalDigit );
bool is_s = ch.isSpace();
bool is_w = ( ch.isLetterOrNumber()
-#if QT_VERSION >= 0x040200
|| ch.isMark()
-#endif
|| ch == '_' );
QVERIFY( rx_d.exactMatch(QString(ch)) == is_d );
@@ -582,7 +579,6 @@ void tst_QRegExp::exactMatch()
QVERIFY( rx_S.exactMatch(QString(ch)) != is_s );
QVERIFY( rx_W.exactMatch(QString(ch)) != is_w );
}
-#endif
}
void tst_QRegExp::capturedTexts()
@@ -593,13 +589,11 @@ void tst_QRegExp::capturedTexts()
QCOMPARE(rx1.cap(0), QString("aaa"));
QCOMPARE(rx1.cap(1), QString("aaa"));
-#if QT_VERSION >= 0x040200
QRegExp rx2("a*(a*)", Qt::CaseSensitive, QRegExp::RegExp2);
rx2.exactMatch("aaa");
QCOMPARE(rx2.matchedLength(), 3);
QCOMPARE(rx2.cap(0), QString("aaa"));
QCOMPARE(rx2.cap(1), QString(""));
-#endif
QRegExp rx3("(?:a|aa)(a*)", Qt::CaseSensitive, QRegExp::RegExp);
rx3.exactMatch("aaa");
@@ -607,13 +601,11 @@ void tst_QRegExp::capturedTexts()
QCOMPARE(rx3.cap(0), QString("aaa"));
QCOMPARE(rx3.cap(1), QString("aa"));
-#if QT_VERSION >= 0x040200
QRegExp rx4("(?:a|aa)(a*)", Qt::CaseSensitive, QRegExp::RegExp2);
rx4.exactMatch("aaa");
QCOMPARE(rx4.matchedLength(), 3);
QCOMPARE(rx4.cap(0), QString("aaa"));
QCOMPARE(rx4.cap(1), QString("a"));
-#endif
QRegExp rx5("(a)*(a*)", Qt::CaseSensitive, QRegExp::RegExp);
rx5.exactMatch("aaa");
@@ -622,14 +614,12 @@ void tst_QRegExp::capturedTexts()
QCOMPARE(rx5.cap(1), QString("a"));
QCOMPARE(rx5.cap(2), QString("aa"));
-#if QT_VERSION >= 0x040200
QRegExp rx6("(a)*(a*)", Qt::CaseSensitive, QRegExp::RegExp2);
rx6.exactMatch("aaa");
QCOMPARE(rx6.matchedLength(), 3);
QCOMPARE(rx6.cap(0), QString("aaa"));
QCOMPARE(rx6.cap(1), QString("a"));
QCOMPARE(rx6.cap(2), QString(""));
-#endif
QRegExp rx7("([A-Za-z_])([A-Za-z_0-9]*)");
rx7.setCaseSensitivity(Qt::CaseSensitive);
@@ -689,7 +679,6 @@ void tst_QRegExp::indexIn()
}
}
-#if QT_VERSION >= 0x040200
// same as above, but with RegExp2
{
QRegExp rx( regexpStr, Qt::CaseSensitive, QRegExp::RegExp2 );
@@ -707,7 +696,6 @@ void tst_QRegExp::indexIn()
QCOMPARE( mycaps[i], caps[i] );
}
}
-#endif
}
void tst_QRegExp::lastIndexIn()
@@ -746,7 +734,6 @@ void tst_QRegExp::lastIndexIn()
}
}
-#if QT_VERSION >= 0x040200
{
QRegExp rx( regexpStr, Qt::CaseSensitive, QRegExp::RegExp2 );
QVERIFY( rx.isValid() );
@@ -766,7 +753,6 @@ void tst_QRegExp::lastIndexIn()
}
}
}
-#endif
}
void tst_QRegExp::matchedLength()
@@ -1161,10 +1147,8 @@ void tst_QRegExp::prepareEngineOptimization()
QRegExp rx4("foo", Qt::CaseInsensitive, QRegExp::RegExp);
QVERIFY(rx4.isValid());
-#if QT_VERSION >= 0x040200
QRegExp rx5("foo", Qt::CaseInsensitive, QRegExp::RegExp2);
QVERIFY(rx5.isValid());
-#endif
QRegExp rx6("foo", Qt::CaseInsensitive, QRegExp::FixedString);
QVERIFY(rx6.isValid());
@@ -1175,10 +1159,8 @@ void tst_QRegExp::prepareEngineOptimization()
QRegExp rx8("][", Qt::CaseInsensitive, QRegExp::RegExp);
QVERIFY(!rx8.isValid());
-#if QT_VERSION >= 0x040200
QRegExp rx9("][", Qt::CaseInsensitive, QRegExp::RegExp2);
QVERIFY(!rx9.isValid());
-#endif
QRegExp rx10("][", Qt::CaseInsensitive, QRegExp::Wildcard);
QVERIFY(!rx10.isValid());
diff --git a/tests/auto/qregion/tst_qregion.cpp b/tests/auto/qregion/tst_qregion.cpp
index 2afeaedc06..003619b2ed 100644
--- a/tests/auto/qregion/tst_qregion.cpp
+++ b/tests/auto/qregion/tst_qregion.cpp
@@ -145,12 +145,7 @@ void tst_QRegion::rects()
{
QRect rect( 10, -20, 30, 40 );
QRegion region( rect );
-#if QT_VERSION < 0x040000
- QCOMPARE( region.rects().count(), (uint)1 );
-#else
QCOMPARE( region.rects().count(), 1 );
-#endif
-
QCOMPARE( region.rects()[0], rect );
}
{
@@ -200,11 +195,7 @@ void tst_QRegion::setRects()
QRegion region;
QRect rect( 10, -20, 30, 40 );
region.setRects( &rect, 1 );
-#if QT_VERSION < 0x040000
- QCOMPARE( region.rects().count(), (uint)1 );
-#else
QCOMPARE( region.rects().count(), 1 );
-#endif
QCOMPARE( region.rects()[0], rect );
}
}
@@ -374,9 +365,7 @@ void tst_QRegion::bitmapRegion()
QVERIFY( region.contains( QPoint( 0, 10 ) ) ); // Mid-left
QVERIFY( region.contains( QPoint( 10, 0 ) ) ); // Mid-top
-#if ( QT_VERSION >= 0x030100 )
QVERIFY( region.contains( QPoint( 19, 10 ) ) ); // Mid-right
-#endif
QVERIFY( region.contains( QPoint( 10, 19 ) ) ); // Mid-bottom
}
}
@@ -627,11 +616,9 @@ void tst_QRegion::operator_minus_data()
QTest::addColumn<QRegion>("subtract");
QTest::addColumn<QRegion>("expected");
-#if !defined(Q_WS_X11) || QT_VERSION >= 0x040300
QTest::newRow("empty 0") << QRegion() << QRegion() << QRegion();
QTest::newRow("empty 1") << QRegion() << QRegion(QRect(10, 10, 10, 10))
<< QRegion();
-#endif
QTest::newRow("empty 2") << QRegion(QRect(10, 10, 10, 10)) << QRegion()
<< QRegion(QRect(10, 10, 10, 10));
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 0c359def0a..cd797d949c 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -1187,6 +1187,16 @@ static void fooFromScriptValue(const QScriptValue &value, Foo &foo)
foo.y = value.property("y").toInt32();
}
+static QScriptValue fooToScriptValueV2(QScriptEngine *eng, const Foo &foo)
+{
+ return QScriptValue(eng, foo.x);
+}
+
+static void fooFromScriptValueV2(const QScriptValue &value, Foo &foo)
+{
+ foo.x = value.toInt32();
+}
+
Q_DECLARE_METATYPE(QLinkedList<QString>)
Q_DECLARE_METATYPE(QList<Foo>)
Q_DECLARE_METATYPE(QVector<QChar>)
@@ -1427,6 +1437,24 @@ void tst_QScriptEngine::valueConversion()
QVERIFY(val.isVariant());
QCOMPARE(val.toVariant(), var);
}
+
+ // task 248802
+ qScriptRegisterMetaType<Foo>(&eng, fooToScriptValueV2, fooFromScriptValueV2);
+ {
+ QScriptValue num(&eng, 123);
+ Foo foo = qScriptValueToValue<Foo>(num);
+ QCOMPARE(foo.x, 123);
+ }
+ {
+ QScriptValue num(123);
+ Foo foo = qScriptValueToValue<Foo>(num);
+ QCOMPARE(foo.x, -1);
+ }
+ {
+ QScriptValue str(&eng, "123");
+ Foo foo = qScriptValueToValue<Foo>(str);
+ QCOMPARE(foo.x, 123);
+ }
}
static QScriptValue __import__(QScriptContext *ctx, QScriptEngine *eng)
diff --git a/tests/auto/qset/tst_qset.cpp b/tests/auto/qset/tst_qset.cpp
index 7afcd8457f..5601656ab2 100644
--- a/tests/auto/qset/tst_qset.cpp
+++ b/tests/auto/qset/tst_qset.cpp
@@ -619,9 +619,6 @@ void tst_QSet::stlIterator()
void tst_QSet::stlMutableIterator()
{
-#if QT_VERSION < 0x040200
- QSKIP("Needs Qt >= 4.2", SkipAll);
-#else
QSet<QString> set1;
for (int i = 0; i < 25000; ++i)
set1.insert(QString::number(i));
@@ -679,7 +676,6 @@ void tst_QSet::stlMutableIterator()
#endif
QVERIFY(*i == "foo");
}
-#endif
}
void tst_QSet::javaIterator()
@@ -768,9 +764,6 @@ void tst_QSet::javaIterator()
void tst_QSet::javaMutableIterator()
{
-#if QT_VERSION < 0x040200
- QSKIP("Needs Qt >= 4.2", SkipAll);
-#else
QSet<QString> set1;
for (int k = 0; k < 25000; ++k)
set1.insert(QString::number(k));
@@ -856,7 +849,6 @@ void tst_QSet::javaMutableIterator()
QVERIFY(set2.isEmpty());
QVERIFY(set3.isEmpty());
}
-#endif
}
void tst_QSet::makeSureTheComfortFunctionsCompile()
diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp
index cb49d17a13..bc2416adce 100644
--- a/tests/auto/qsettings/tst_qsettings.cpp
+++ b/tests/auto/qsettings/tst_qsettings.cpp
@@ -242,7 +242,6 @@ static QString settingsPath(const char *path = "")
return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path));
}
-#if QT_VERSION >= 0x040100
static bool readCustom1File(QIODevice &device, QSettings::SettingsMap &map)
{
QDataStream in(&device);
@@ -299,7 +298,6 @@ static bool writeCustom3File(QIODevice &device, const QSettings::SettingsMap &ma
out << "OK";
return true;
}
-#endif
static void populateWithFormats()
{
@@ -307,15 +305,12 @@ static void populateWithFormats()
QTest::newRow("native") << QSettings::NativeFormat;
QTest::newRow("ini") << QSettings::IniFormat;
-#if QT_VERSION >= 0x040100
QTest::newRow("custom1") << QSettings::CustomFormat1;
QTest::newRow("custom2") << QSettings::CustomFormat2;
-#endif
}
tst_QSettings::tst_QSettings()
{
-#if QT_VERSION >= 0x040100
QSettings::Format custom1 = QSettings::registerFormat("custom1", readCustom1File, writeCustom1File);
QSettings::Format custom2 = QSettings::registerFormat("custom2", readCustom2File, writeCustom2File
#ifndef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
@@ -324,7 +319,6 @@ tst_QSettings::tst_QSettings()
);
QVERIFY(custom1 == QSettings::CustomFormat1);
QVERIFY(custom2 == QSettings::CustomFormat2);
-#endif
}
void tst_QSettings::init()
@@ -1144,9 +1138,9 @@ void tst_QSettings::testVariantTypes()
l4 << QVariant(m2) << QVariant(l2) << QVariant(l3);
testVal("key13", l4, QVariantList, List);
- // With Qt 4.2 we store key sequences as strings instead of binary variant blob, for improved
+ // We store key sequences as strings instead of binary variant blob, for improved
// readability in the resulting format.
- if (format >= QSettings::InvalidFormat || QT_VERSION < 0x040200) {
+ if (format >= QSettings::InvalidFormat) {
testVal("keysequence", QKeySequence(Qt::ControlModifier + Qt::Key_F1), QKeySequence, KeySequence);
} else {
testVal("keysequence", QKeySequence(Qt::ControlModifier + Qt::Key_F1), QString, String);
@@ -2643,14 +2637,12 @@ void tst_QSettings::testCaseSensitivity()
case QSettings::IniFormat:
cs = false;
break;
-#if QT_VERSION >= 0x040100
case QSettings::CustomFormat1:
cs = true;
break;
case QSettings::CustomFormat2:
cs = false;
break;
-#endif
default:
;
}
@@ -3549,7 +3541,6 @@ void tst_QSettings::allKeys()
}
}
-#if QT_VERSION >= 0x040100
void tst_QSettings::registerFormat()
{
QSettings settings1(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP");
@@ -3647,7 +3638,6 @@ void tst_QSettings::setPath()
TEST_PATH(i == 0, "custom2", CustomFormat2, SystemScope, "iota")
}
}
-#endif
void tst_QSettings::setDefaultFormat()
{
diff --git a/tests/auto/qsidebar/tst_qsidebar.cpp b/tests/auto/qsidebar/tst_qsidebar.cpp
index 7a262e6b1b..705e2227f1 100644
--- a/tests/auto/qsidebar/tst_qsidebar.cpp
+++ b/tests/auto/qsidebar/tst_qsidebar.cpp
@@ -176,6 +176,32 @@ void tst_QSidebar::addUrls()
qsidebar.addUrls(urls, -1);
qsidebar.addUrls(moreUrls, -1);
QCOMPARE(qsidebar.urls()[0], urls[0]);
+
+ QList<QUrl> doubleUrls;
+ //tow exact same paths, we have only one entry
+ doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
+ doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
+ qsidebar.setUrls(emptyUrls);
+ qsidebar.addUrls(doubleUrls, 1);
+ QCOMPARE(qsidebar.urls().size(), 1);
+
+#if defined(Q_OS_WIN)
+ //Windows is case insensitive so no duplicate entries in that case
+ doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
+ doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath().toUpper());
+ qsidebar.setUrls(emptyUrls);
+ qsidebar.addUrls(doubleUrls, 1);
+ QCOMPARE(qsidebar.urls().size(), 1);
+#else
+ //Two different paths we should have two entries
+ doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath());
+ doubleUrls << QUrl::fromLocalFile(QDir::home().absolutePath().toUpper());
+ qsidebar.setUrls(emptyUrls);
+ qsidebar.addUrls(doubleUrls, 1);
+ QCOMPARE(qsidebar.urls().size(), 2);
+#endif
+
+
}
void tst_QSidebar::goToUrl()
diff --git a/tests/auto/qsizef/tst_qsizef.cpp b/tests/auto/qsizef/tst_qsizef.cpp
index 7668491c48..c1a827b0e5 100644
--- a/tests/auto/qsizef/tst_qsizef.cpp
+++ b/tests/auto/qsizef/tst_qsizef.cpp
@@ -72,29 +72,6 @@ private slots:
void transpose();
};
-#if QT_VERSION < 0x040100
-namespace QTest
-{
- // Qt < 4.1 didn't do fuzzy comparisons
- template<>
- inline bool compare(QSizeF const &t1, QSizeF const &t2, const char *file, int line)
- {
- char msg[1024];
- msg[0] = '\0';
- bool isOk = true;
- if ((qAbs(t1.width() - t2.width()) > 0.000000000001) || (qAbs(t1.height() - t2.height()) > 0.000000000001)) {
- qt_snprintf(msg, 1024, "Compared values of type QSizeF are not the same (fuzzy compare).\n"
- " Actual : w: %lf h: %lf \n"
- " Expected: w: %lf h: %lf", t1.width(), t1.height(), t2.width(), t2.height());
- isOk = false;
- } else {
- qt_snprintf(msg, 1024, "QCOMPARE('%lf %lf', QSizeF)", t1.width(), t1.height());
- }
- return compare_helper(isOk, msg, file, line);
- }
-}
-#endif
-
tst_QSizeF::tst_QSizeF() {
}
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 9f92c37540..18aa5fca1a 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -129,6 +129,10 @@ private slots:
void task236755_hiddenColumns();
void task247867_insertRowsSort();
+ void task248868_staticSorting();
+ void task248868_dynamicSorting();
+ void task250023_fetchMore();
+ void task251296_hiddenChildren();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -1505,9 +1509,6 @@ void tst_QSortFilterProxyModel::insertAfterSelect()
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p);
QVERIFY(view.selectionModel()->selectedIndexes().size() > 0);
model.insertRows(5, 1, QModelIndex());
-#if QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Selections are not kept in versions < 4.2", Abort);
-#endif
QVERIFY(view.selectionModel()->selectedIndexes().size() > 0); // Should still have a selection
}
@@ -1529,9 +1530,6 @@ void tst_QSortFilterProxyModel::removeAfterSelect()
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, p);
QVERIFY(view.selectionModel()->selectedIndexes().size() > 0);
model.removeRows(5, 1, QModelIndex());
-#if QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Selections are not kept in versions < 4.2", Abort);
-#endif
QVERIFY(view.selectionModel()->selectedIndexes().size() > 0); // Should still have a selection
}
@@ -2479,5 +2477,246 @@ void tst_QSortFilterProxyModel::task247867_insertRowsSort()
QCOMPARE(proxyModel.sortColumn(), 0);
}
+void tst_QSortFilterProxyModel::task248868_staticSorting()
+{
+ QStandardItemModel model(0, 1);
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ proxy.setDynamicSortFilter(false);
+ QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(" ");
+
+ // prepare model
+ QStandardItem *root = model.invisibleRootItem ();
+ QList<QStandardItem *> items;
+ for (int i = 0; i < initial.count(); ++i) {
+ items.append(new QStandardItem(initial.at(i)));
+ }
+ root->insertRows(0, items);
+ QCOMPARE(model.rowCount(QModelIndex()), initial.count());
+ QCOMPARE(model.columnCount(QModelIndex()), 1);
+
+ // make sure the proxy is unsorted
+ QCOMPARE(proxy.columnCount(QModelIndex()), 1);
+ QCOMPARE(proxy.rowCount(QModelIndex()), initial.count());
+ for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy.index(row, 0, QModelIndex());
+ QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initial.at(row));
+ }
+
+ // sort
+ proxy.sort(0);
+
+ QStringList expected = initial;
+ expected.sort();
+ // make sure the proxy is sorted
+ for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy.index(row, 0, QModelIndex());
+ QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expected.at(row));
+ }
+
+ //update one item.
+ model.setItem(0, 0, new QStandardItem("girafe"));
+
+ // make sure the proxy is updated but not sorted
+ expected.replaceInStrings("bateau", "girafe");
+ for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy.index(row, 0, QModelIndex());
+ QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expected.at(row));
+ }
+
+ // sort again
+ proxy.sort(0);
+ expected.sort();
+
+ // make sure the proxy is sorted
+ for (int row = 0; row < proxy.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy.index(row, 0, QModelIndex());
+ QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expected.at(row));
+ }
+
+}
+
+void tst_QSortFilterProxyModel::task248868_dynamicSorting()
+{
+ QStringListModel model1;
+ const QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(" ");
+ model1.setStringList(initial);
+ QSortFilterProxyModel proxy1;
+ proxy1.sort(0);
+ proxy1.setSourceModel(&model1);
+
+ QCOMPARE(proxy1.columnCount(QModelIndex()), 1);
+ //the model should not be sorted because sorting has not been set to dynamic yet.
+ QCOMPARE(proxy1.rowCount(QModelIndex()), initial.count());
+ for (int row = 0; row < proxy1.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy1.index(row, 0, QModelIndex());
+ QCOMPARE(proxy1.data(index, Qt::DisplayRole).toString(), initial.at(row));
+ }
+
+ proxy1.setDynamicSortFilter(true);
+
+ //now the model should be sorted.
+ QStringList expected = initial;
+ expected.sort();
+ for (int row = 0; row < proxy1.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy1.index(row, 0, QModelIndex());
+ QCOMPARE(proxy1.data(index, Qt::DisplayRole).toString(), expected.at(row));
+ }
+
+ QStringList initial2 = initial;
+ initial2.replaceInStrings("bateau", "girafe");
+ model1.setStringList(initial2); //this will cause a reset
+
+ QStringList expected2 = initial2;
+ expected2.sort();
+
+ //now the model should still be sorted.
+ for (int row = 0; row < proxy1.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy1.index(row, 0, QModelIndex());
+ QCOMPARE(proxy1.data(index, Qt::DisplayRole).toString(), expected2.at(row));
+ }
+
+ QStringListModel model2(initial);
+ proxy1.setSourceModel(&model2);
+
+ //the model should again be sorted
+ for (int row = 0; row < proxy1.rowCount(QModelIndex()); ++row) {
+ QModelIndex index = proxy1.index(row, 0, QModelIndex());
+ QCOMPARE(proxy1.data(index, Qt::DisplayRole).toString(), expected.at(row));
+ }
+}
+
+class QtTestModel: public QAbstractItemModel
+{
+ public:
+ QtTestModel(int _rows, int _cols, QObject *parent = 0): QAbstractItemModel(parent),
+ rows(_rows), cols(_cols), wrongIndex(false) { }
+
+ bool canFetchMore(const QModelIndex &idx) const {
+ return !fetched.contains(idx);
+ }
+
+ void fetchMore(const QModelIndex &idx) {
+ if (fetched.contains(idx))
+ return;
+ beginInsertRows(idx, 0, rows-1);
+ fetched.insert(idx);
+ endInsertRows();
+ }
+
+ bool hasChildren(const QModelIndex & = QModelIndex()) const {
+ return true;
+ }
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const {
+ return fetched.contains(parent) ? rows : 0;
+ }
+ int columnCount(const QModelIndex& parent = QModelIndex()) const {
+ return cols;
+ }
+
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
+ {
+ if (row < 0 || column < 0 || column >= cols || row >= rows) {
+ return QModelIndex();
+ }
+ QModelIndex i = createIndex(row, column, int(parent.internalId() + 1));
+ parentHash[i] = parent;
+ return i;
+ }
+
+ QModelIndex parent(const QModelIndex &index) const
+ {
+ if (!parentHash.contains(index))
+ return QModelIndex();
+ return parentHash[index];
+ }
+
+ QVariant data(const QModelIndex &idx, int role) const
+ {
+ if (!idx.isValid())
+ return QVariant();
+
+ if (role == Qt::DisplayRole) {
+ if (idx.row() < 0 || idx.column() < 0 || idx.column() >= cols || idx.row() >= rows) {
+ wrongIndex = true;
+ qWarning("Invalid modelIndex [%d,%d,%p]", idx.row(), idx.column(),
+ idx.internalPointer());
+ }
+ return QString("[%1,%2]").arg(idx.row()).arg(idx.column());
+ }
+ return QVariant();
+ }
+
+ QSet<QModelIndex> fetched;
+ int rows, cols;
+ mutable bool wrongIndex;
+ mutable QMap<QModelIndex,QModelIndex> parentHash;
+};
+
+void tst_QSortFilterProxyModel::task250023_fetchMore()
+{
+ QtTestModel model(10,10);
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ QVERIFY(proxy.canFetchMore(QModelIndex()));
+ QVERIFY(proxy.hasChildren());
+ while (proxy.canFetchMore(QModelIndex()))
+ proxy.fetchMore(QModelIndex());
+ QCOMPARE(proxy.rowCount(), 10);
+ QCOMPARE(proxy.columnCount(), 10);
+
+ QModelIndex idx = proxy.index(1,1);
+ QVERIFY(idx.isValid());
+ QVERIFY(proxy.canFetchMore(idx));
+ QVERIFY(proxy.hasChildren(idx));
+ while (proxy.canFetchMore(idx))
+ proxy.fetchMore(idx);
+ QCOMPARE(proxy.rowCount(idx), 10);
+ QCOMPARE(proxy.columnCount(idx), 10);
+}
+
+void tst_QSortFilterProxyModel::task251296_hiddenChildren()
+{
+ QStandardItemModel model;
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ proxy.setDynamicSortFilter(true);
+
+ QStandardItem *itemA = new QStandardItem("A VISIBLE");
+ model.appendRow(itemA);
+ QStandardItem *itemB = new QStandardItem("B VISIBLE");
+ itemA->appendRow(itemB);
+ QStandardItem *itemC = new QStandardItem("C");
+ itemA->appendRow(itemC);
+ proxy.setFilterRegExp("VISIBLE");
+
+ QCOMPARE(proxy.rowCount(QModelIndex()) , 1);
+ QPersistentModelIndex indexA = proxy.index(0,0);
+ QCOMPARE(proxy.data(indexA).toString(), QString::fromLatin1("A VISIBLE"));
+
+ QCOMPARE(proxy.rowCount(indexA) , 1);
+ QPersistentModelIndex indexB = proxy.index(0, 0, indexA);
+ QCOMPARE(proxy.data(indexB).toString(), QString::fromLatin1("B VISIBLE"));
+
+ itemA->setText("A");
+ QCOMPARE(proxy.rowCount(QModelIndex()), 0);
+ QVERIFY(!indexA.isValid());
+ QVERIFY(!indexB.isValid());
+
+ itemB->setText("B");
+ itemA->setText("A VISIBLE");
+ itemC->setText("C VISIBLE");
+
+ QCOMPARE(proxy.rowCount(QModelIndex()), 1);
+ indexA = proxy.index(0,0);
+ QCOMPARE(proxy.data(indexA).toString(), QString::fromLatin1("A VISIBLE"));
+
+ QCOMPARE(proxy.rowCount(indexA) , 1);
+ QModelIndex indexC = proxy.index(0, 0, indexA);
+ QCOMPARE(proxy.data(indexC).toString(), QString::fromLatin1("C VISIBLE"));
+}
+
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h
index b529b7e652..ef51285667 100644
--- a/tests/auto/qsqldatabase/tst_databases.h
+++ b/tests/auto/qsqldatabase/tst_databases.h
@@ -105,10 +105,7 @@ inline static QString qTableName( const QString& prefix, QSqlDriver* driver = 0
inline static bool testWhiteSpaceNames( const QString &name )
{
- return name.startsWith( "QPSQL" )
- || name.startsWith( "QODBC" )
- || name.startsWith( "QSQLITE" )
- || name.startsWith( "QMYSQL" );
+ return name != QLatin1String("QTDS7");
}
inline static QString toHex( const QString& binary )
@@ -203,7 +200,7 @@ public:
{
// addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/pony.troll.no", "scott", "tiger" ); // Oracle 9i on horsehead
// addDb( "QOCI8", "//horsehead.nokia.troll.no:1521/ustest.troll.no", "scott", "tiger", "" ); // Oracle 9i on horsehead
-// addDb( "QOCI8", "ICE", "scott", "tiger", "" ); // Oracle 8 on iceblink
+// addDb( "QOCI8", "//iceblink.nokia.troll.no:1521/ice.troll.no", "scott", "tiger", "" ); // Oracle 8 on iceblink (not currently working)
// addDb( "QOCI", "//silence.nokia.troll.no:1521/testdb", "scott", "tiger" ); // Oracle 10g on silence
// addDb( "QOCI", "//oracle10g-nokia.trolltech.com.au:1521/XE", "scott", "tiger" ); // Oracle 10gexpress on xen
@@ -231,7 +228,7 @@ public:
// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "postgres74-nokia.trolltech.com.au" ); // Version 7.4.19-1.el4_6.1
// addDb( "QPSQL7", "testdb", "testuser", "Ee4Gabf6_", "postgres81-nokia.trolltech.com.au" ); // Version 8.1.11-1.el5_1.1
-// addDb( "QDB2", "testdb", "troll", "trond", "silence" ); // DB2 v9.1 on silence
+// addDb( "QDB2", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // DB2 v9.1 on silence
// yes - interbase really wants the physical path on the host machine.
// addDb( "QIBASE", "/opt/interbase/qttest.gdb", "SYSDBA", "masterkey", "horsehead.nokia.troll.no" );
@@ -240,10 +237,6 @@ public:
// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird1-nokia.trolltech.com.au" ); // Firebird 1.5.5
// addDb( "QIBASE", "/opt/firebird/databases/testdb.fdb", "testuser", "Ee4Gabf6_", "firebird2-nokia.trolltech.com.au" ); // Firebird 2.1.1
-// Anders' local Firebird and InterBase test databases
-// addDb("QIBASE", "localhost:c:\\Firebird\\Firebird_2_0\\TESTDB.FDB", "SYSDBA", "masterkey", ""); // FireBird 2.0
-// addDb("QIBASE", "localhost:c:\\Borland\\InterBase\\TESTDB_UTF8.IB", "SYSDBA", "masterkey", ""); // InterBase 2007 Developer
-
// use in-memory database to prevent local files
// addDb("QSQLITE", ":memory:");
addDb( "QSQLITE", QDir::toNativeSeparators(QDir::tempPath()+"/foo.db") );
@@ -251,6 +244,10 @@ public:
// addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=iceblink.nokia.troll.no\\ICEBLINK", "troll", "trond", "" );
// addDb( "QODBC3", "DRIVER={SQL Native Client};SERVER=silence.nokia.troll.no\\SQLEXPRESS", "troll", "trond", "" );
+// addDb( "QODBC", "DRIVER={MySQL ODBC 3.51 Driver};SERVER=mysql5-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" );
+// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=horsehead.nokia.troll.no;DATABASE=testdb;PORT=4101;UID=troll;PWD=trondk", "troll", "trondk", "" );
+// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=silence.nokia.troll.no;DATABASE=testdb;PORT=2392;UID=troll;PWD=trond", "troll", "trond", "" );
+
}
void open()
@@ -312,20 +309,28 @@ public:
// drop a table only if it exists to prevent warnings
static void safeDropTables( QSqlDatabase db, const QStringList& tableNames )
{
- int wasDropped = true;
+ bool wasDropped;
QSqlQuery q( db );
QStringList dbtables=db.tables();
- foreach(QString tableName, tableNames)
+ foreach(const QString &tableName, tableNames)
{
-
- if ( dbtables.contains( tableName, Qt::CaseSensitive ) )
- wasDropped = q.exec( "drop table " + db.driver()->escapeIdentifier( tableName, QSqlDriver::TableName ) );
- else if ( dbtables.contains( tableName, Qt::CaseInsensitive ) )
- wasDropped = q.exec( "drop table " + tableName );
+ wasDropped = true;
+ QString table=tableName;
+ if ( db.driver()->isIdentifierEscaped(table, QSqlDriver::TableName))
+ table = db.driver()->stripDelimiters(table, QSqlDriver::TableName);
+
+ foreach(const QString dbtablesName, dbtables) {
+ if(dbtablesName.toUpper() == table.toUpper()) {
+ dbtables.removeAll(dbtablesName);
+ wasDropped = q.exec("drop table " + db.driver()->escapeIdentifier( dbtablesName, QSqlDriver::TableName ));
+ if(!wasDropped)
+ wasDropped = q.exec("drop table " + dbtablesName);
+ }
+ }
if ( !wasDropped )
- qWarning() << "unable to drop table" << tableName << ':' << q.lastError().text();
+ qWarning() << dbToString(db) << "unable to drop table" << tableName << ':' << q.lastError().text() << "tables:" << dbtables;
}
}
@@ -396,12 +401,26 @@ public:
static QByteArray printError( const QSqlError& err )
{
- return QString( "'" + err.driverText() + "' || '" + err.databaseText() + "'" ).toLocal8Bit();
+ QString result;
+ if(err.number() > 0)
+ result += '(' + QString::number(err.number()) + ") ";
+ result += '\'';
+ if(!err.driverText().isEmpty())
+ result += err.driverText() + "' || '";
+ result += err.databaseText() + "'";
+ return result.toLocal8Bit();
}
static QByteArray printError( const QSqlError& err, const QSqlDatabase& db )
{
- return QString( db.driverName() + ": '" + err.driverText() + "' || '" + err.databaseText() + "'" ).toLocal8Bit();
+ QString result(dbToString(db) + ": ");
+ if(err.number() > 0)
+ result += '(' + QString::number(err.number()) + ") ";
+ result += '\'';
+ if(!err.driverText().isEmpty())
+ result += err.driverText() + "' || '";
+ result += err.databaseText() + "'";
+ return result.toLocal8Bit();
}
static bool isSqlServer( QSqlDatabase db )
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index 28c9e8ecc0..665cfde3b3 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -93,28 +93,28 @@ private slots:
void addDatabase();
//database specific tests
- void recordMySQL_data();
+ void recordMySQL_data() { generic_data("QMYSQL"); }
void recordMySQL();
- void recordPSQL_data();
+ void recordPSQL_data() { generic_data("QPSQL"); }
void recordPSQL();
- void recordOCI_data();
+ void recordOCI_data() { generic_data("QOCI"); }
void recordOCI();
- void recordTDS_data();
+ void recordTDS_data() { generic_data("QTDS"); }
void recordTDS();
- void recordDB2_data();
+ void recordDB2_data() { generic_data("QDB2"); }
void recordDB2();
- void recordSQLite_data();
+ void recordSQLite_data() { generic_data("QSQLITE"); }
void recordSQLite();
- void recordAccess_data();
+ void recordAccess_data() { generic_data("QODBC"); }
void recordAccess();
- void recordSQLServer_data();
+ void recordSQLServer_data() { generic_data("QODBC"); }
void recordSQLServer();
- void recordIBase_data();
+ void recordIBase_data() {generic_data("QIBASE"); }
void recordIBase();
- void eventNotificationIBase_data() { generic_data(); }
+ void eventNotificationIBase_data() { generic_data("QIBASE"); }
void eventNotificationIBase();
- void eventNotificationPSQL_data() { generic_data(); }
+ void eventNotificationPSQL_data() { generic_data("QPSQL"); }
void eventNotificationPSQL();
//database specific 64 bit integer test
@@ -141,59 +141,65 @@ private slots:
void precisionPolicy_data() { generic_data(); }
void precisionPolicy();
- void db2_valueCacheUpdate_data() { generic_data(); }
+ void db2_valueCacheUpdate_data() { generic_data("QDB2"); }
void db2_valueCacheUpdate();
- void psql_schemas_data();
+ void psql_schemas_data() { generic_data("QPSQL"); }
void psql_schemas();
- void psql_escapedIdentifiers_data(){ psql_schemas_data(); }
+ void psql_escapedIdentifiers_data() { generic_data("QPSQL"); }
void psql_escapedIdentifiers();
- void psql_escapeBytea_data() { generic_data(); }
+ void psql_escapeBytea_data() { generic_data("QPSQL"); }
void psql_escapeBytea();
+ void bug_249059_data() { generic_data("QPSQL"); }
+ void bug_249059();
void mysqlOdbc_unsignedIntegers_data() { generic_data(); }
void mysqlOdbc_unsignedIntegers();
- void mysql_multiselect_data() { generic_data(); }
+ void mysql_multiselect_data() { generic_data("QMYSQL"); }
void mysql_multiselect(); // For task 144331
void accessOdbc_strings_data() { generic_data(); }
void accessOdbc_strings();
- void ibase_numericFields_data() { generic_data(); }
+ void ibase_numericFields_data() { generic_data("QIBASE"); }
void ibase_numericFields(); // For task 125053
- void ibase_fetchBlobs_data() { generic_data(); }
+ void ibase_fetchBlobs_data() { generic_data("QIBASE"); }
void ibase_fetchBlobs(); // For task 143471
- void ibase_useCustomCharset_data() { generic_data(); }
+ void ibase_useCustomCharset_data() { generic_data("QIBASE"); }
void ibase_useCustomCharset(); // For task 134608
- void ibase_procWithoutReturnValues_data() { generic_data(); } // For task 165423
+ void ibase_procWithoutReturnValues_data() { generic_data("QIBASE"); } // For task 165423
void ibase_procWithoutReturnValues();
- void ibase_procWithReturnValues_data() { generic_data(); } // For task 177530
+ void ibase_procWithReturnValues_data() { generic_data("QIBASE"); } // For task 177530
void ibase_procWithReturnValues();
- void odbc_reopenDatabase_data() { generic_data(); }
+ void odbc_reopenDatabase_data() { generic_data("QODBC"); }
void odbc_reopenDatabase();
- void odbc_uniqueidentifier_data() { generic_data(); }
+ void odbc_uniqueidentifier_data() { generic_data("QODBC"); }
void odbc_uniqueidentifier(); // For task 141822
- void odbc_uintfield_data() { generic_data(); }
+ void odbc_uintfield_data() { generic_data("QODBC"); }
void odbc_uintfield();
- void odbc_bindBoolean_data() { generic_data(); }
+ void odbc_bindBoolean_data() { generic_data("QODBC"); }
void odbc_bindBoolean();
- void oci_serverDetach_data() { generic_data(); }
+ void oci_serverDetach_data() { generic_data("QOCI"); }
void oci_serverDetach(); // For task 154518
- void oci_xmltypeSupport_data() { generic_data(); }
+ void oci_xmltypeSupport_data() { generic_data("QOCI"); }
void oci_xmltypeSupport();
- void oci_fieldLength_data() { generic_data(); }
+ void oci_fieldLength_data() { generic_data("QOCI"); }
void oci_fieldLength();
- void sqlite_bindAndFetchUInt_data() { generic_data(); }
+ void sqlite_bindAndFetchUInt_data() { generic_data("QSQLITE3"); }
void sqlite_bindAndFetchUInt();
+ void sqlStatementUseIsNull_189093_data() { generic_data(); }
+ void sqlStatementUseIsNull_189093();
+
+
private:
void createTestTables(QSqlDatabase db);
void dropTestTables(QSqlDatabase db);
void populateTestTables(QSqlDatabase db);
- void generic_data();
+ void generic_data(const QString &engine=QString());
#ifdef QT3_SUPPORT
void testRecordInfo(const FieldDef fieldDefs[], const Q3SqlRecordInfo& inf);
@@ -337,7 +343,8 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
<< qTableName("qtestBindBool")
<< qTableName("qtest_sqlguid")
<< qTableName("uint_table")
- << qTableName("uint_test");
+ << qTableName("uint_test")
+ << qTableName("bug_249059");
QSqlQuery q(0, db);
if (db.driverName().startsWith("QPSQL"))
@@ -360,6 +367,7 @@ void tst_QSqlDatabase::populateTestTables(QSqlDatabase db)
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (1, 'VarChar1', 'Char1', 2.2)"));
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (2, 'VarChar2', 'Char2', 3.3)"));
QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (3, 'VarChar3', 'Char3', 4.4)"));
+ QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (4, 'VarChar4', NULL, NULL)"));
}
void tst_QSqlDatabase::initTestCase()
@@ -394,70 +402,14 @@ void tst_QSqlDatabase::cleanup()
{
}
-void tst_QSqlDatabase::recordOCI_data()
-{
- if (dbs.fillTestTable("QOCI") == 0)
- QSKIP("No Oracle database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordPSQL_data()
-{
- if (dbs.fillTestTable("QPSQL") == 0)
- QSKIP("No PostgreSQL database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordMySQL_data()
-{
- if (dbs.fillTestTable("QMYSQL") == 0)
- QSKIP("No MySQL database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordTDS_data()
-{
- if (dbs.fillTestTable("QTDS") == 0)
- QSKIP("No TDS database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordDB2_data()
+void tst_QSqlDatabase::generic_data(const QString& engine)
{
- if (dbs.fillTestTable("QDB2") == 0)
- QSKIP("No DB2 database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordSQLite_data()
-{
- if (dbs.fillTestTable("QSQLITE") == 0)
- QSKIP("No SQLite database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordAccess_data()
-{
- if (dbs.fillTestTable("QODBC") == 0)
- QSKIP("No ODBC database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordSQLServer_data()
-{
- if (dbs.fillTestTable("QODBC") == 0)
- QSKIP("No ODBC database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::recordIBase_data()
-{
- if (dbs.fillTestTable("QIBASE") == 0)
- QSKIP("No Interbase database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::psql_schemas_data()
-{
- if (dbs.fillTestTable("QPSQL") == 0)
- QSKIP("No Postgres database drivers are available in this Qt configuration", SkipAll);
-}
-
-void tst_QSqlDatabase::generic_data()
-{
- if (dbs.fillTestTable() == 0)
- QSKIP("No database drivers are available in this Qt configuration", SkipAll);
+ if ( dbs.fillTestTable(engine) == 0 ) {
+ if(engine.isEmpty())
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ else
+ QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
+ }
}
void tst_QSqlDatabase::addDatabase()
@@ -885,7 +837,6 @@ void tst_QSqlDatabase::recordTDS()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QTDS");
static const FieldDef fieldDefs[] = {
FieldDef("tinyint", QVariant::Int, 255),
@@ -934,7 +885,6 @@ void tst_QSqlDatabase::recordOCI()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QOCI");
// runtime check for Oracle version since V8 doesn't support TIMESTAMPs
if (tst_Databases::getOraVersion(db) >= 9) {
@@ -1010,7 +960,6 @@ void tst_QSqlDatabase::recordPSQL()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QPSQL");
FieldDef byteadef;
if (db.driver()->hasFeature(QSqlDriver::BLOB))
@@ -1095,13 +1044,13 @@ void tst_QSqlDatabase::recordMySQL()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QMYSQL");
FieldDef bin10, varbin10;
int major = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt();
int minor = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 1, 1 ).toInt();
int revision = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 2, 2 ).toInt();
+#ifdef QT3_SUPPORT
/* The below is broken in mysql below 5.0.15
see http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html
specifically: Before MySQL 5.0.15, the pad value is space. Values are right-padded
@@ -1176,7 +1125,6 @@ void tst_QSqlDatabase::recordDB2()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QDB2");
static const FieldDef fieldDefs[] = {
FieldDef("char(20)", QVariant::String, QString("Blah1")),
@@ -1222,7 +1170,6 @@ void tst_QSqlDatabase::recordIBase()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QIBASE");
static const FieldDef fieldDefs[] = {
FieldDef("char(20)", QVariant::String, QString("Blah1"), false),
@@ -1253,7 +1200,6 @@ void tst_QSqlDatabase::recordSQLite()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QSQLITE");
static const FieldDef fieldDefs[] = {
// The affinity of these fields are TEXT so SQLite should give us strings, not ints or doubles.
@@ -1596,7 +1542,6 @@ void tst_QSqlDatabase::psql_escapeBytea()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QPSQL");
const char dta[4] = {'\x71', '\x14', '\x32', '\x81'};
QByteArray ba(dta, 4);
@@ -1623,6 +1568,38 @@ void tst_QSqlDatabase::psql_escapeBytea()
QCOMPARE(i, 4);
}
+void tst_QSqlDatabase::bug_249059()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlQuery q(db);
+ QString tableName = qTableName("bug_249059");
+ QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName)));
+
+ QSqlQuery iq(db);
+ QVERIFY_SQL(iq, prepare(QString("INSERT INTO %1 VALUES (?, ?)").arg(tableName)));
+ iq.bindValue(0, QVariant(QString("2001-09-09 04:05:06.789 -5:00")));
+ iq.bindValue(1, QVariant(QString("04:05:06.789 -5:00")));
+ QVERIFY_SQL(iq, exec());
+ iq.bindValue(0, QVariant(QString("2001-09-09 04:05:06.789 +5:00")));
+ iq.bindValue(1, QVariant(QString("04:05:06.789 +5:00")));
+ QVERIFY_SQL(iq, exec());
+
+ QVERIFY_SQL(q, exec(QString("SELECT dt, t FROM %1").arg(tableName)));
+ QVERIFY_SQL(q, next());
+ QDateTime dt1=q.value(0).toDateTime();
+ QTime t1=q.value(1).toTime();
+ QVERIFY_SQL(q, next());
+ QDateTime dt2=q.value(0).toDateTime();
+ QTime t2=q.value(1).toTime();
+
+ // These will fail when timezone support is added, when that's the case, set the second record to 14:05:06.789 and it should work correctly
+ QCOMPARE(dt1, dt2);
+ QCOMPARE(t1, t2);
+}
+
// This test should be rewritten to work with Oracle as well - or the Oracle driver
// should be fixed to make this test pass (handle overflows)
void tst_QSqlDatabase::precisionPolicy()
@@ -1769,7 +1746,6 @@ void tst_QSqlDatabase::ibase_numericFields()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QIBASE");
QSqlQuery q(db);
QString tableName = qTableName("numericfields");
@@ -1843,7 +1819,6 @@ void tst_QSqlDatabase::ibase_fetchBlobs()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QIBASE");
QString tableName = qTableName("qtest_ibaseblobs");
QSqlQuery q(db);
@@ -1876,7 +1851,6 @@ void tst_QSqlDatabase::ibase_procWithoutReturnValues()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QIBASE");
QSqlQuery q(db);
QString procName = qTableName("qtest_proc1");
@@ -1957,11 +1931,6 @@ void tst_QSqlDatabase::odbc_reopenDatabase()
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- if (!tst_Databases::isSqlServer(db)) {
- QSKIP("SQL Server (ODBC) specific test", SkipSingle);
- return;
- }
-
QSqlQuery q(db);
QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest")));
QVERIFY_SQL(q, next());
@@ -1976,7 +1945,6 @@ void tst_QSqlDatabase::odbc_bindBoolean()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QODBC");
QSqlQuery q(db);
QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool") + "(id int, boolvalue bit)"));
@@ -2005,7 +1973,6 @@ void tst_QSqlDatabase::mysql_multiselect()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QMYSQL");
QSqlQuery q(db);
QVERIFY_SQL(q, exec("select version()"));
@@ -2027,7 +1994,6 @@ void tst_QSqlDatabase::ibase_useCustomCharset()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QIBASE");
QString nonlatin1string("��");
db.close();
@@ -2051,7 +2017,6 @@ void tst_QSqlDatabase::oci_serverDetach()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QOCI");
for (int i = 0; i < 2; i++) {
db.close();
@@ -2072,7 +2037,6 @@ void tst_QSqlDatabase::oci_xmltypeSupport()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QOCI");
QString tableName = qTableName("qtest_xmltype");
QString xml("<?xml version=\"1.0\"?><TABLE_NAME>MY_TABLE</TABLE_NAME>");
@@ -2101,7 +2065,6 @@ void tst_QSqlDatabase::oci_fieldLength()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QOCI");
QString tableName = qTableName("qtest");
QSqlQuery q(db);
@@ -2166,7 +2129,6 @@ void tst_QSqlDatabase::odbc_uintfield()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QODBC");
QString tableName = qTableName("uint_table");
unsigned int val = 4294967295U;
@@ -2228,7 +2190,6 @@ void tst_QSqlDatabase::eventNotificationIBase()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QIBASE");
QString procedureName = qTableName("posteventProc");
QSqlDriver *driver=db.driver();
@@ -2258,7 +2219,6 @@ void tst_QSqlDatabase::eventNotificationPSQL()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QPSQL");
QSqlQuery query(db);
QString procedureName = qTableName("posteventProc");
@@ -2279,7 +2239,6 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QSQLITE3");
QSqlQuery q(db);
QString tableName = qTableName("uint_test");
@@ -2301,7 +2260,6 @@ void tst_QSqlDatabase::db2_valueCacheUpdate()
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QDB2");
QString tableName = qTableName("qtest");
QSqlQuery q(db);
@@ -2317,5 +2275,28 @@ void tst_QSqlDatabase::db2_valueCacheUpdate()
QCOMPARE(c1.toString(), q.value(0).toString());
}
+void tst_QSqlDatabase::sqlStatementUseIsNull_189093()
+{
+ // NULL = NULL is unknow, the sqlStatment must use IS NULL
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ // select a record with NULL value
+ QSqlQuery q(QString::null, db);
+ QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 4"));
+ QVERIFY_SQL(q, next());
+
+ QSqlDriver *driver = db.driver();
+ QVERIFY(driver);
+
+ QString preparedStatment = driver->sqlStatement(QSqlDriver::WhereStatement, QString("qtest"), q.record(), true);
+ QCOMPARE(preparedStatment.count("IS NULL", Qt::CaseInsensitive), 2);
+
+ QString statment = driver->sqlStatement(QSqlDriver::WhereStatement, QString("qtest"), q.record(), false);
+ QCOMPARE(statment.count("IS NULL", Qt::CaseInsensitive), 2);
+}
+
+
QTEST_MAIN(tst_QSqlDatabase)
#include "tst_qsqldatabase.moc"
diff --git a/tests/auto/qsqldriver/qsqldriver.pro b/tests/auto/qsqldriver/qsqldriver.pro
new file mode 100644
index 0000000000..0024841e12
--- /dev/null
+++ b/tests/auto/qsqldriver/qsqldriver.pro
@@ -0,0 +1,16 @@
+load(qttest_p4)
+SOURCES += tst_qsqldriver.cpp
+
+QT += sql
+
+wince*: {
+ plugFiles.sources = ../../../plugins/sqldrivers
+ plugFiles.path = .
+ DEPLOYMENT += plugFiles
+} else {
+ win32-g++ {
+ LIBS += -lws2_32
+ } else:win32 {
+ LIBS += ws2_32.lib
+ }
+}
diff --git a/tests/auto/qsqldriver/tst_qsqldriver.cpp b/tests/auto/qsqldriver/tst_qsqldriver.cpp
new file mode 100644
index 0000000000..bbd7483212
--- /dev/null
+++ b/tests/auto/qsqldriver/tst_qsqldriver.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtSql/QtSql>
+
+#include "../qsqldatabase/tst_databases.h"
+
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QSqlDriver : public QObject
+{
+ Q_OBJECT
+
+public:
+ void recreateTestTables(QSqlDatabase);
+
+ tst_Databases dbs;
+
+public slots:
+ void initTestCase_data();
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void record();
+ void primaryIndex();
+};
+
+
+void tst_QSqlDriver::initTestCase_data()
+{
+ dbs.open();
+ if (dbs.fillTestTable() == 0) {
+ qWarning("NO DATABASES");
+ QSKIP("No database drivers are available in this Qt configuration", SkipAll);
+ }
+}
+
+void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
+{
+ QSqlQuery q(db);
+
+ QStringList tableNames;
+ tableNames << qTableName( "relTEST1" );
+ tst_Databases::safeDropTables( db, tableNames );
+
+ QVERIFY_SQL( q, exec("create table " + qTableName("relTEST1") +
+ " (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(1, 'harry', 1, 2)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(2, 'trond', 2, 1)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(3, 'vohi', 1, 2)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(4, 'boris', 2, 2)"));
+}
+
+void tst_QSqlDriver::initTestCase()
+{
+ foreach (const QString &dbname, dbs.dbNames)
+ recreateTestTables(QSqlDatabase::database(dbname));
+}
+
+void tst_QSqlDriver::cleanupTestCase()
+{
+ QStringList tableNames;
+ tableNames << qTableName( "relTEST1" );
+ foreach (const QString &dbName, dbs.dbNames) {
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ tst_Databases::safeDropTables( db, tableNames );
+ }
+ dbs.close();
+}
+
+void tst_QSqlDriver::init()
+{
+}
+
+void tst_QSqlDriver::cleanup()
+{
+}
+
+void tst_QSqlDriver::record()
+{
+ QFETCH_GLOBAL(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QString tablename = qTableName("relTEST1");
+ QStringList fields;
+ fields << "id" << "name" << "title_key" << "another_title_key";
+
+ //check we can get records using an unquoted mixed case table name
+ QSqlRecord rec = db.driver()->record(tablename);
+ QCOMPARE(rec.count(), 4);
+
+ if (db.driverName().startsWith("QIBASE")|| db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ for(int i = 0; i < fields.count(); ++i)
+ fields[i] = fields[i].toUpper();
+
+ for (int i = 0; i < fields.count(); ++i)
+ QCOMPARE(rec.fieldName(i), fields[i]);
+
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ tablename = tablename.toUpper();
+ else if (db.driverName().startsWith("QPSQL"))
+ tablename = tablename.toLower();
+
+ //check we can get records using a properly quoted table name
+ rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName));
+ QCOMPARE(rec.count(), 4);
+
+ for (int i = 0; i < fields.count(); ++i)
+ QCOMPARE(rec.fieldName(i), fields[i]);
+
+ if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ tablename = tablename.toLower();
+ else if (db.driverName().startsWith("QPSQL"))
+ tablename = tablename.toUpper();
+
+ //check that we can't get records using incorrect tablename casing that's been quoted
+ rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName));
+ if (db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS"))
+ QCOMPARE(rec.count(), 4); //mysql, sqlite and tds will match
+ else
+ QCOMPARE(rec.count(), 0);
+
+}
+
+void tst_QSqlDriver::primaryIndex()
+{
+ QFETCH_GLOBAL(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QString tablename = qTableName("relTEST1");
+ //check that we can get primary index using unquoted mixed case table name
+ QSqlIndex index = db.driver()->primaryIndex(tablename);
+ QCOMPARE(index.count(), 1);
+
+ if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ QCOMPARE(index.fieldName(0), QString::fromLatin1("ID"));
+ else
+ QCOMPARE(index.fieldName(0), QString::fromLatin1("id"));
+
+
+ //check that we can get the primary index using a quoted tablename
+ if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ tablename = tablename.toUpper();
+ else if (db.driverName().startsWith("QPSQL"))
+ tablename = tablename.toLower();
+
+ index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName));
+ QCOMPARE(index.count(), 1);
+ if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ QCOMPARE(index.fieldName(0), QString::fromLatin1("ID"));
+ else
+ QCOMPARE(index.fieldName(0), QString::fromLatin1("id"));
+
+
+
+ //check that we can not get the primary index using a quoted but incorrect table name casing
+ if( db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
+ tablename = tablename.toLower();
+ else if (db.driverName().startsWith("QPSQL"))
+ tablename = tablename.toUpper();
+
+ index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName));
+ if (db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS"))
+ QCOMPARE(index.count(), 1); //mysql will always find the table name regardless of casing
+ else
+ QCOMPARE(index.count(), 0);
+}
+
+QTEST_MAIN(tst_QSqlDriver)
+#include "tst_qsqldriver.moc"
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 684d6ac94a..074f16fab4 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -93,7 +93,7 @@ private slots:
void transaction();
void record_data() { generic_data(); }
void record();
- void record_sqlite_data() { generic_data(); }
+ void record_sqlite_data() { generic_data("QSQLITE"); }
void record_sqlite();
void finish_data() { generic_data(); }
void finish();
@@ -107,13 +107,13 @@ private slots:
void forwardOnly();
// bug specific tests
- void bitField_data();
+ void bitField_data() {generic_data("QTDS"); }
void bitField();
- void nullBlob_data();
+ void nullBlob_data() { generic_data("QOCI"); }
void nullBlob();
void blob_data() { generic_data(); }
void blob();
- void rawField_data();
+ void rawField_data() { generic_data("QOCI"); }
void rawField();
void precision_data() { generic_data(); }
void precision();
@@ -129,19 +129,19 @@ private slots:
void char1SelectUnicode();
void synonyms_data() { generic_data(); }
void synonyms();
- void oraOutValues_data();
+ void oraOutValues_data() { generic_data("QOCI"); }
void oraOutValues();
- void mysqlOutValues_data();
+ void mysqlOutValues_data() { generic_data("QMYSQL"); }
void mysqlOutValues();
- void oraClob_data() { oraOutValues_data(); }
+ void oraClob_data() { generic_data("QOCI"); }
void oraClob();
- void oraLong_data() { oraOutValues_data(); }
+ void oraLong_data() { generic_data("QOCI"); }
void oraLong();
- void outValuesDB2_data();
+ void outValuesDB2_data() { generic_data("QDB2"); }
void outValuesDB2();
- void storedProceduresIBase_data();
+ void storedProceduresIBase_data() {generic_data("QIBASE"); }
void storedProceduresIBase();
- void oraRowId_data();
+ void oraRowId_data() { generic_data("QOCI"); }
void oraRowId();
void prepare_bind_exec_data() { generic_data(); }
void prepare_bind_exec();
@@ -175,13 +175,17 @@ private slots:
void emptyTableNavigate();
#ifdef NOT_READY_YET
- void bug217003_data() { generic_data(); }
- void bug217003();
+ void task_217003_data() { generic_data(); }
+ void task_217003();
#endif
+ void task_250026_data() { generic_data("QODBC"); }
+ void task_250026();
+
+
private:
// returns all database connections
- void generic_data();
+ void generic_data(const QString &engine=QString());
void dropTestTables( QSqlDatabase db );
void createTestTables( QSqlDatabase db );
void populateTestTables( QSqlDatabase db );
@@ -247,28 +251,14 @@ void tst_QSqlQuery::cleanup()
}
}
-void tst_QSqlQuery::bitField_data()
-{
- if ( dbs.fillTestTable( "QTDS" ) == 0 )
- QSKIP( "No TDS database drivers are available in this Qt configuration", SkipAll );
-}
-
-void tst_QSqlQuery::nullBlob_data()
-{
- if ( dbs.fillTestTable( "QOCI" ) == 0 )
- QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll );
-}
-
-void tst_QSqlQuery::rawField_data()
-{
- if ( dbs.fillTestTable( "QOCI" ) == 0 )
- QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll );
-}
-
-void tst_QSqlQuery::generic_data()
+void tst_QSqlQuery::generic_data(const QString& engine)
{
- if ( dbs.fillTestTable() == 0 )
- QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ if ( dbs.fillTestTable(engine) == 0 ) {
+ if(engine.isEmpty())
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ else
+ QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
+ }
}
void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
@@ -307,6 +297,7 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
#ifdef NOT_READY_YET
tablenames << qTableName( "Planet" );
#endif
+ tablenames << qTableName( "task_250026" );
tst_Databases::safeDropTables( db, tablenames );
}
@@ -421,12 +412,6 @@ void tst_QSqlQuery::char1SelectUnicode()
QSKIP( "Database not unicode capable", SkipSingle );
}
-void tst_QSqlQuery::oraRowId_data()
-{
- if ( dbs.fillTestTable( "QOCI" ) == 0 )
- QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll );
-}
-
void tst_QSqlQuery::oraRowId()
{
QFETCH( QString, dbName );
@@ -461,12 +446,6 @@ void tst_QSqlQuery::oraRowId()
QCOMPARE( q.value( 0 ).toString(), QString( "b" ) );
}
-void tst_QSqlQuery::mysqlOutValues_data()
-{
- if ( dbs.fillTestTable( "QMYSQL" ) == 0 )
- QSKIP( "No MySQL database drivers are available in this Qt configuration", SkipAll );
-}
-
void tst_QSqlQuery::mysqlOutValues()
{
QFETCH( QString, dbName );
@@ -517,12 +496,6 @@ void tst_QSqlQuery::mysqlOutValues()
QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) );
}
-void tst_QSqlQuery::oraOutValues_data()
-{
- if ( dbs.fillTestTable( "QOCI" ) == 0 )
- QSKIP( "No Oracle database drivers are available in this Qt configuration", SkipAll );
-}
-
void tst_QSqlQuery::oraOutValues()
{
QFETCH( QString, dbName );
@@ -670,18 +643,11 @@ void tst_QSqlQuery::oraClob()
QVERIFY( q.value( 1 ).toByteArray() == loong.toLatin1() );
}
-void tst_QSqlQuery::storedProceduresIBase_data()
-{
- if ( dbs.fillTestTable( "QIBASE" ) == 0 )
- QSKIP( "No Interbase database drivers are available in this Qt configuration", SkipAll );
-}
-
void tst_QSqlQuery::storedProceduresIBase()
{
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- DBMS_SPECIFIC( db, "QIBASE" );
QSqlQuery q( db );
q.exec( "drop procedure " + qTableName( "TESTPROC" ) );
@@ -713,12 +679,6 @@ void tst_QSqlQuery::storedProceduresIBase()
q.exec( "drop procedure " + qTableName( "TestProc" ) );
}
-void tst_QSqlQuery::outValuesDB2_data()
-{
- if ( dbs.fillTestTable( "QDB2" ) == 0 )
- QSKIP( "No DB2 database drivers are available in this Qt configuration", SkipAll );
-}
-
void tst_QSqlQuery::outValuesDB2()
{
QFETCH( QString, dbName );
@@ -1355,7 +1315,6 @@ void tst_QSqlQuery::nullBlob()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- DBMS_SPECIFIC( db, "QOCI" );
QSqlQuery q( db );
QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_nullblob" ) + " (id int primary key, bb blob)" ) );
@@ -1385,7 +1344,6 @@ void tst_QSqlQuery::rawField()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- DBMS_SPECIFIC( db, "QOCI" );
QSqlQuery q( db );
q.setForwardOnly( true );
@@ -2103,7 +2061,6 @@ void tst_QSqlQuery::record_sqlite()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- DBMS_SPECIFIC( db, "QSQLITE" );
QSqlQuery q( db );
@@ -2131,7 +2088,6 @@ void tst_QSqlQuery::oraLong()
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
- DBMS_SPECIFIC( db, "QOCI" );
QSqlQuery q( db );
@@ -2158,7 +2114,7 @@ void tst_QSqlQuery::execErrorRecovery()
QSqlQuery q( db );
- QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int primary key)" ) );
+ QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int not null primary key)" ) );
QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr" ) + " values (?)" ) );
q.addBindValue( 1 );
@@ -2698,7 +2654,7 @@ void tst_QSqlQuery::emptyTableNavigate()
}
#ifdef NOT_READY_YET
-void tst_QSqlQuery::bug217003()
+void tst_QSqlQuery::task_217003()
{
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
@@ -2726,5 +2682,34 @@ void tst_QSqlQuery::bug217003()
}
#endif
+void tst_QSqlQuery::task_250026()
+{
+ QString data258, data1026;
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database( dbName );
+ CHECK_DATABASE( db );
+ QSqlQuery q( db );
+
+ QString tableName = qTableName( "task_250026" );
+
+ if ( !q.exec( "create table " + tableName + " (longfield varchar(1100))" ) ) {
+ qDebug() << "Error" << q.lastError();
+ QSKIP( "Db doesn't support \"1100\" as a size for fields", SkipSingle );
+ }
+
+ data258.fill( 'A', 258 );
+ data1026.fill( 'A', 1026 );
+ QVERIFY_SQL( q, prepare( "insert into " + tableName + "(longfield) VALUES (:longfield)" ) );
+ q.bindValue( "longfield", data258 );
+ QVERIFY_SQL( q, exec() );
+ q.bindValue( "longfield", data1026 );
+ QVERIFY_SQL( q, exec() );
+ QVERIFY_SQL( q, exec( "select * from " + tableName ) );
+ QVERIFY_SQL( q, next() );
+ QCOMPARE( q.value( 0 ).toString().length(), data258.length() );
+ QVERIFY_SQL( q, next() );
+ QCOMPARE( q.value( 0 ).toString().length(), data1026.length() );
+}
+
QTEST_MAIN( tst_QSqlQuery )
#include "tst_qsqlquery.moc"
diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
index 63202f8b44..88b5770572 100644
--- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
+++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp
@@ -95,7 +95,7 @@ private slots:
void setQueryWithNoRowsInResultSet();
private:
- void generic_data();
+ void generic_data(const QString &engine=QString());
void dropTestTables(QSqlDatabase db);
void createTestTables(QSqlDatabase db);
void populateTestTables(QSqlDatabase db);
@@ -202,10 +202,14 @@ void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db)
tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp") << qTableName("test3tmp"));
}
-void tst_QSqlQueryModel::generic_data()
+void tst_QSqlQueryModel::generic_data(const QString& engine)
{
- if (dbs.fillTestTable() == 0)
- QSKIP("No database drivers are available in this Qt configuration", SkipAll);
+ if ( dbs.fillTestTable(engine) == 0 ) {
+ if(engine.isEmpty())
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ else
+ QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
+ }
}
void tst_QSqlQueryModel::init()
diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 76785c339a..bb2cdddd52 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -82,6 +82,10 @@ private slots:
void insertRecordDuplicateFieldNames();
void invalidData();
void relationModel();
+ void casing();
+ void escapedRelations();
+ void escapedTableName();
+ void whiteSpaceInIdentifiers();
};
@@ -103,7 +107,9 @@ void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db)
<< qTableName( "reltest2" )
<< qTableName( "reltest3" )
<< qTableName( "reltest4" )
- << qTableName( "reltest5" );
+ << qTableName( "reltest5" )
+ << db.driver()->escapeIdentifier(qTableName( "rel test6" ), QSqlDriver::TableName)
+ << db.driver()->escapeIdentifier(qTableName( "rel test7" ), QSqlDriver::TableName);
tst_Databases::safeDropTables( db, tableNames );
QVERIFY_SQL( q, exec("create table " + qTableName("reltest1") +
@@ -128,6 +134,19 @@ void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db)
QVERIFY_SQL( q, exec("create table " + qTableName("reltest5") + " (title varchar(20) not null primary key, abbrev varchar(20))"));
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('herr', 'Hr')"));
QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('mister', 'Mr')"));
+
+ if (testWhiteSpaceNames(db.driverName())) {
+ QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName);
+ QVERIFY_SQL( q, exec("create table " + reltest6 + " (id int not null primary key, " + db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName) +
+ " int, " + db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName) + " int)"));
+ QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(1, 1,9)"));
+ QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(2, 2,8)"));
+
+ QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName);
+ QVERIFY_SQL( q, exec("create table " + reltest7 + " (" + db.driver()->escapeIdentifier("city id", QSqlDriver::TableName) + " int not null primary key, " + db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName) + " varchar(20))"));
+ QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(1, 'New York')"));
+ QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(2, 'Washington')"));
+ }
}
void tst_QSqlRelationalTableModel::initTestCase()
@@ -142,10 +161,14 @@ void tst_QSqlRelationalTableModel::cleanupTestCase()
tableNames << qTableName( "reltest1" )
<< qTableName( "reltest2" )
<< qTableName( "reltest3" )
- << qTableName( "reltest4" );
+ << qTableName( "reltest4" )
+ << qTableName( "reltest5" );
foreach (const QString &dbName, dbs.dbNames) {
QSqlDatabase db = QSqlDatabase::database(dbName);
- tst_Databases::safeDropTables( db, tableNames );
+ QStringList tables = tableNames;
+ tables << db.driver()->escapeIdentifier(qTableName( "rel test6" ), QSqlDriver::TableName)
+ << db.driver()->escapeIdentifier(qTableName( "rel test7" ), QSqlDriver::TableName);
+ tst_Databases::safeDropTables( db, tables );
}
dbs.close();
}
@@ -273,7 +296,12 @@ void tst_QSqlRelationalTableModel::setData()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+
+ //sybase doesn't allow tables with the same alias used twice as col names
+ //so don't set up an identical relation when using the tds driver
+ if (!db.driverName().startsWith("QTDS"))
+ model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
model.setSort(0, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
@@ -284,7 +312,10 @@ void tst_QSqlRelationalTableModel::setData()
QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi2"));
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
+ else
+ QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
QVERIFY_SQL(model, submitAll());
}
@@ -299,10 +330,15 @@ void tst_QSqlRelationalTableModel::setData()
QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ if (!db.driverName().startsWith("QTDS"))
+ model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
+
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
+ else
+ QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
}
//check setting of data when the relational key is a non-integer type
@@ -336,7 +372,8 @@ void tst_QSqlRelationalTableModel::multipleRelation()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name"));
+ model.setSort(0, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(2, 0)).toInt(), 3);
@@ -344,7 +381,7 @@ void tst_QSqlRelationalTableModel::multipleRelation()
QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(0, 3)).toString(), QString("mister"));
+ QCOMPARE(model.data(model.index(0, 3)).toString(), QString("Trondheim"));
}
void tst_QSqlRelationalTableModel::insertRecord()
@@ -357,6 +394,7 @@ void tst_QSqlRelationalTableModel::insertRecord()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ model.setSort(0, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
QSqlRecord rec;
@@ -398,6 +436,7 @@ void tst_QSqlRelationalTableModel::setRecord()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ model.setSort(0, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
QSqlRecord rec;
@@ -450,13 +489,18 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+
+ if (!db.driverName().startsWith("QTDS"))
+ model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
QVERIFY_SQL(model, select());
QCOMPARE(model.data(model.index(0,0)).toInt(), 1);
QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
+ else
+ QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
model.insertRows(0, 1);
model.setData(model.index(0, 0), 1011);
@@ -467,12 +511,20 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(0,0)).toInt(), 1011);
QCOMPARE(model.data(model.index(0,1)).toString(), QString("test"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister"));
- QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
+ else
+ QCOMPARE(model.data(model.index(0,3)).toInt(), 1);
QCOMPARE(model.data(model.index(1,0)).toInt(), 1);
QCOMPARE(model.data(model.index(1,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(1,2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(1,3)).toString(), QString("mister"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(1,3)).toString(), QString("mister"));
+ else
+ QCOMPARE(model.data(model.index(1,3)).toInt(), 2);
+
+
QVERIFY_SQL(model, submitAll());
@@ -481,9 +533,16 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(0,0)).toInt(), 1);
QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
- model.setData(model.index(0,3),1);
- QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
+
+ if (!db.driverName().startsWith("QTDS")) {
+ QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
+ model.setData(model.index(0,3),1);
+ QCOMPARE(model.data(model.index(0,3)).toString(), QString("herr"));
+ } else {
+ QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
+ model.setData(model.index(0,3),1);
+ QCOMPARE(model.data(model.index(0,3)).toInt(), 1);
+ }
model.insertRows(0, 2);
model.setData(model.index(0, 0), 1012);
@@ -499,17 +558,27 @@ void tst_QSqlRelationalTableModel::insertWithStrategies()
QCOMPARE(model.data(model.index(0,0)).toInt(),1012);
QCOMPARE(model.data(model.index(0,1)).toString(), QString("george"));
QCOMPARE(model.data(model.index(0,2)).toString(), QString("mister"));
- QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(0,3)).toString(), QString("mister"));
+ else
+ QCOMPARE(model.data(model.index(0,3)).toInt(), 2);
+
QCOMPARE(model.data(model.index(1,0)).toInt(),1013);
QCOMPARE(model.data(model.index(1,1)).toString(), QString("kramer"));
QCOMPARE(model.data(model.index(1,2)).toString(), QString("mister"));
- QCOMPARE(model.data(model.index(1,3)).toString(), QString("herr"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(1,3)).toString(), QString("herr"));
+ else
+ QCOMPARE(model.data(model.index(1,3)).toInt(), 1);
QCOMPARE(model.data(model.index(2,0)).toInt(), 1);
QCOMPARE(model.data(model.index(2,1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(2,2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(2,3)).toString(), QString("herr"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(2,3)).toString(), QString("herr"));
+ else
+ QCOMPARE(model.data(model.index(2,3)).toInt(), 1);
QVERIFY_SQL(model, submitAll());
}
@@ -574,7 +643,8 @@ void tst_QSqlRelationalTableModel::sort()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ if (!db.driverName().startsWith("QTDS"))
+ model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
model.setSort(2, Qt::DescendingOrder);
QVERIFY_SQL(model, select());
@@ -589,11 +659,19 @@ void tst_QSqlRelationalTableModel::sort()
model.setSort(3, Qt::AscendingOrder);
QVERIFY_SQL(model, select());
- QCOMPARE(model.rowCount(), 4);
- QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(1, 3)).toString(), QString("mister"));
- QCOMPARE(model.data(model.index(2, 3)).toString(), QString("mister"));
- QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister"));
+ if (!db.driverName().startsWith("QTDS")) {
+ QCOMPARE(model.rowCount(), 4);
+ QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
+ QCOMPARE(model.data(model.index(1, 3)).toString(), QString("mister"));
+ QCOMPARE(model.data(model.index(2, 3)).toString(), QString("mister"));
+ QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister"));
+ } else {
+ QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
+ QCOMPARE(model.data(model.index(1, 3)).toInt(), 2);
+ QCOMPARE(model.data(model.index(2, 3)).toInt(), 2);
+ QCOMPARE(model.data(model.index(3, 3)).toInt(), 2);
+ }
+
}
static void testRevert(QSqlRelationalTableModel &model)
@@ -663,7 +741,7 @@ void tst_QSqlRelationalTableModel::revert()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name"));
model.setSort(0, Qt::AscendingOrder);
@@ -689,7 +767,9 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
model.setTable(qTableName("reltest1"));
model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+
+ if (!db.driverName().startsWith("QTDS"))
+ model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
model.setSort(1, Qt::AscendingOrder);
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
@@ -698,7 +778,10 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
QCOMPARE(model.data(model.index(3, 0)).toInt(), 3);
QCOMPARE(model.data(model.index(3, 1)).toString(), QString("vohi"));
QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(3, 3)).toString(), QString("mister"));
+ else
+ QCOMPARE(model.data(model.index(3, 3)).toInt(), 2 );
model.insertRow(model.rowCount());
QVERIFY(model.setData(model.index(4, 0), 5, Qt::EditRole));
@@ -710,11 +793,18 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache()
QCOMPARE(model.data(model.index(0, 0)).toInt(), 5);
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("anders"));
QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(0, 3)).toString(), QString("herr"));
+ else
+ QCOMPARE(model.data(model.index(0, 3)).toInt(), 1);
+
QCOMPARE(model.data(model.index(4, 0)).toInt(), 3);
QCOMPARE(model.data(model.index(4, 1)).toString(), QString("vohi"));
QCOMPARE(model.data(model.index(4, 2)).toString(), QString("herr"));
- QCOMPARE(model.data(model.index(4, 3)).toString(), QString("mister"));
+ if (!db.driverName().startsWith("QTDS"))
+ QCOMPARE(model.data(model.index(4, 3)).toString(), QString("mister"));
+ else
+ QCOMPARE(model.data(model.index(4, 3)).toInt(), 2);
}
// For task 140782 and 176374: If the main table and the the related tables uses the same
@@ -729,27 +819,38 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames()
QSqlRelationalTableModel model(0, db);
model.setTable(qTableName("reltest3"));
model.setEditStrategy(QSqlTableModel::OnManualSubmit);
+ model.setSort(0, Qt::AscendingOrder);
// Duplication of "name", used in both reltest3 and reltest4.
model.setRelation(2, QSqlRelation(qTableName("reltest4"), "id", "name"));
QVERIFY_SQL(model, select());
- QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name"))).toString(),
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name")).toUpper()).toString(),
+ QString("Trondheim"));
+ } else {
+ QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name"))).toString(),
QString("Trondheim"));
+ }
QSqlRecord rec = model.record();
rec.setValue(0, 3);
rec.setValue(1, "Berge");
rec.setValue(2, 1); // Must insert the key value
- QCOMPARE(rec.fieldName(0), QLatin1String("id"));
- QCOMPARE(rec.fieldName(1), QLatin1String("name")); // This comes from main table
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ QCOMPARE(rec.fieldName(0), QLatin1String("ID"));
+ QCOMPARE(rec.fieldName(1), QLatin1String("NAME")); // This comes from main table
+ } else {
+ QCOMPARE(rec.fieldName(0), QLatin1String("id"));
+ QCOMPARE(rec.fieldName(1), QLatin1String("name"));
+ }
// The duplicate field names is aliased because it's comes from the relation's display column.
- if(!db.driverName().startsWith("QIBASE"))
- QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name")));
- else
+ if(db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name"))).toUpper());
+ else
+ QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name")));
QVERIFY(model.insertRecord(-1, rec));
QCOMPARE(model.data(model.index(2, 2)).toString(), QString("Oslo"));
@@ -793,7 +894,7 @@ void tst_QSqlRelationalTableModel::relationModel()
QVERIFY(model.relationModel(3) == NULL);
QVERIFY(model.relationModel(4) == NULL);
- model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name"));
QVERIFY_SQL(model, select());
QVERIFY(model.relationModel(0) == NULL);
@@ -806,5 +907,285 @@ void tst_QSqlRelationalTableModel::relationModel()
QCOMPARE(rel_model->data(rel_model->index(0,1)).toString(), QString("herr"));
}
+void tst_QSqlRelationalTableModel::casing()
+{
+ QFETCH_GLOBAL(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ if (db.driverName().startsWith("QSQLITE"))
+ QSKIP("The casing test for SQLITE is irrelevant since SQLITE is case insensitive", SkipAll);
+
+ QStringList tableNames;
+ tableNames << qTableName("CASETEST1", db.driver()).toUpper();
+ tableNames << qTableName("casetest1", db.driver());
+ tst_Databases::safeDropTables(db, tableNames);
+
+ QSqlQuery q(db);
+ QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db.driver()).toUpper() +
+ " (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(1, 'harry', 1, 2)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(2, 'trond', 2, 1)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(3, 'vohi', 1, 2)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(4, 'boris', 2, 2)"));
+
+ QVERIFY_SQL( q, exec("create table " + qTableName("casetest1", db.driver()) +
+ " (ident int not null primary key, name varchar(20), title_key int)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(1, 'jerry', 1)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(2, 'george', 2)"));
+ QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(4, 'kramer', 2)"));
+
+ if (db.driverName().startsWith("QOCI")) {
+ //try an owner that doesn't exist
+ QSqlRecord rec = db.driver()->record("doug." + qTableName("CASETEST1", db.driver()).toUpper());
+ QCOMPARE( rec.count(), 0);
+
+ //try an owner that does exist
+ rec = db.driver()->record(db.userName() + "." + qTableName("CASETEST1", db.driver()).toUpper());
+ QCOMPARE( rec.count(), 4);
+ }
+ QSqlRecord rec = db.driver()->record(qTableName("CASETEST1", db.driver()).toUpper());
+ QCOMPARE( rec.count(), 4);
+
+ rec = db.driver()->record(qTableName("casetest1", db.driver()));
+ QCOMPARE( rec.count(), 3);
+
+ QSqlTableModel upperCaseModel(0, db);
+ upperCaseModel.setTable(qTableName("CASETEST1", db.driver()).toUpper());
+
+ QCOMPARE(upperCaseModel.tableName(),qTableName("CASETEST1",db.driver()).toUpper());
+
+ QVERIFY_SQL(upperCaseModel, select());
+
+ QCOMPARE(upperCaseModel.rowCount(), 4);
+
+ QSqlTableModel lowerCaseModel(0, db);
+ lowerCaseModel.setTable(qTableName("casetest1", db.driver()));
+ QCOMPARE(lowerCaseModel.tableName(), qTableName("casetest1",db.driver()));
+ QVERIFY_SQL(lowerCaseModel, select());
+
+ QCOMPARE(lowerCaseModel.rowCount(), 3);
+
+ QSqlRelationalTableModel model(0, db);
+ model.setTable(qTableName("CASETEST1", db.driver()).toUpper());
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ QVERIFY_SQL(model, select());
+
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
+
+ tst_Databases::safeDropTables(db, tableNames);
+}
+
+void tst_QSqlRelationalTableModel::escapedRelations()
+{
+ QFETCH_GLOBAL(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+ recreateTestTables(db);
+
+ QSqlRelationalTableModel model(0, db);
+ model.setTable(qTableName("reltest1"));
+
+ //try with relation table name quoted
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2").toUpper(),QSqlDriver::TableName),
+ "tid",
+ "title"));
+ } else {
+ model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2"),QSqlDriver::TableName),
+ "tid",
+ "title"));
+
+ }
+ QVERIFY_SQL(model, select());
+
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
+
+ //try with index column quoted
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"),
+ db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName).toUpper(),
+ "title"));
+ } else {
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"),
+ db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName),
+ "title"));
+ }
+ QVERIFY_SQL(model, select());
+
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
+
+ //try with display column quoted
+
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"),
+ "tid",
+ db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper()));
+ } else {
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"),
+ "tid",
+ db.driver()->escapeIdentifier("title", QSqlDriver::FieldName)));
+ }
+
+ QVERIFY_SQL(model, select());
+
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
+
+ //try with tablename and index and display columns quoted in the relation
+
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"),
+ "tid",
+ db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper()));
+ } else {
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"),
+ "tid",
+ db.driver()->escapeIdentifier("title", QSqlDriver::FieldName)));
+ }
+ QVERIFY_SQL(model, select());
+
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 1);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr"));
+}
+
+void tst_QSqlRelationalTableModel::escapedTableName()
+{
+ QFETCH_GLOBAL(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ // set the values using OnRowChange Strategy with an escaped tablename
+ {
+ QSqlRelationalTableModel model(0, db);
+
+ if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) {
+ model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1").toUpper(), QSqlDriver::TableName));
+ } else {
+ model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1"), QSqlDriver::TableName));
+ }
+ model.setSort(0, Qt::AscendingOrder);
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ QVERIFY_SQL(model, select());
+
+ QVERIFY(model.setData(model.index(0, 1), QString("harry2")));
+ QVERIFY(model.setData(model.index(0, 2), 2));
+
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry2"));
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
+
+ model.submit();
+
+ QVERIFY(model.setData(model.index(3,1), QString("boris2")));
+ QVERIFY(model.setData(model.index(3, 2), 1));
+
+ QCOMPARE(model.data(model.index(3,1)).toString(), QString("boris2"));
+ QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr"));
+
+ model.submit();
+ }
+ { //verify values
+ QSqlRelationalTableModel model(0, db);
+ model.setTable(qTableName("reltest1"));
+ model.setSort(0, Qt::AscendingOrder);
+ QVERIFY_SQL(model, select());
+
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry2"));
+ QCOMPARE(model.data(model.index(0, 2)).toInt(), 2);
+ QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2"));
+ QCOMPARE(model.data(model.index(3, 2)).toInt(), 1);
+
+ model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title"));
+ QVERIFY_SQL(model, select());
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister"));
+ QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr"));
+
+ }
+}
+
+void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() {
+
+ QFETCH_GLOBAL(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ if (!testWhiteSpaceNames(db.driverName()))
+ QSKIP("White space test irrelevant for driver", SkipAll);
+ QSqlRelationalTableModel model(0, db);
+ model.setTable(db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName));
+ model.setSort(0, Qt::DescendingOrder);
+ model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName),
+ db.driver()->escapeIdentifier("city id", QSqlDriver::FieldName),
+ db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName)));
+ QVERIFY_SQL(model, select());
+
+ QCOMPARE(model.data(model.index(0,1)).toString(), QString("Washington"));
+ QCOMPARE(model.data(model.index(1,1)).toString(), QString("New York"));
+
+ QSqlRecord rec;
+ QSqlField f1("id", QVariant::Int);
+ QSqlField f2(db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName), QVariant::Int);
+ QSqlField f3(db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName), QVariant::Int);
+
+ f1.setValue(3);
+ f2.setValue(2);
+ f3.setValue(7);
+
+ f1.setGenerated(true);
+ f2.setGenerated(true);
+ f3.setGenerated(true);
+
+ rec.append(f1);
+ rec.append(f2);
+ rec.append(f3);
+
+ QVERIFY_SQL(model, insertRecord(-1, rec));
+ model.submitAll();
+
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 3);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("Washington"));
+ QCOMPARE(model.data(model.index(0, 2)).toInt(), 7);
+
+ //TODO: For some reson setting a record using manual submit fails
+ //model.setEditStrategy(QSqlTableModel::OnManualSubmit);
+
+ QSqlRecord recNew;
+ QSqlField f1New("id", QVariant::Int);
+ QSqlField f2New(db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName), QVariant::Int);
+ QSqlField f3New(db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName), QVariant::Int);
+
+ f1New.setValue(4);
+ f2New.setValue(1);
+ f3New.setValue(6);
+
+ f1New.setGenerated(true);
+ f2New.setGenerated(true);
+ f3New.setGenerated(true);
+
+ recNew.append(f1New);
+ recNew.append(f2New);
+ recNew.append(f3New);
+
+ QVERIFY_SQL(model, setRecord(0, recNew));
+
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 4);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("New York"));
+ QCOMPARE(model.data(model.index(0, 2)).toInt(), 6);
+
+ QVERIFY_SQL(model, submitAll());
+ QCOMPARE(model.data(model.index(0, 0)).toInt(), 4);
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("New York"));
+ QCOMPARE(model.data(model.index(0, 2)).toInt(), 6);
+}
+
QTEST_MAIN(tst_QSqlRelationalTableModel)
#include "tst_qsqlrelationaltablemodel.moc"
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index 6015d1c2ee..0e7355e71d 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -66,38 +66,59 @@ public:
tst_Databases dbs;
public slots:
- void initTestCase_data();
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
private slots:
+ void select_data() { generic_data(); }
void select();
+ void submitAll_data() { generic_data(); }
void submitAll();
- void setRecord_data();
+ void setRecord_data() { generic_data(); }
void setRecord();
+ void insertRow_data() { generic_data(); }
void insertRow();
+ void insertRecord_data() { generic_data(); }
void insertRecord();
+ void insertMultiRecords_data() { generic_data(); }
void insertMultiRecords();
+ void removeRow_data() { generic_data(); }
void removeRow();
+ void removeRows_data() { generic_data(); }
void removeRows();
+ void removeInsertedRow_data() { generic_data(); }
void removeInsertedRow();
+ void setFilter_data() { generic_data(); }
void setFilter();
+ void setInvalidFilter_data() { generic_data(); }
void setInvalidFilter();
+ void emptyTable_data() { generic_data(); }
void emptyTable();
+ void tablesAndSchemas_data() { generic_data("QPSQL"); }
void tablesAndSchemas();
+ void whitespaceInIdentifiers_data() { generic_data(); }
void whitespaceInIdentifiers();
+ void primaryKeyOrder_data() { generic_data("QSQLITE"); }
void primaryKeyOrder();
+ void sqlite_bigTable_data() { generic_data("QSQLITE"); }
void sqlite_bigTable();
// bug specific tests
+ void insertRecordBeforeSelect_data() { generic_data(); }
void insertRecordBeforeSelect();
+ void submitAllOnInvalidTable_data() { generic_data(); }
void submitAllOnInvalidTable();
+ void insertRecordsInLoop_data() { generic_data(); }
void insertRecordsInLoop();
+ void sqlite_attachedDatabase_data() { generic_data("QSQLITE"); }
void sqlite_attachedDatabase(); // For task 130799
+
+private:
+ void generic_data(const QString& engine=QString());
};
tst_QSqlTableModel::tst_QSqlTableModel()
@@ -121,9 +142,10 @@ void tst_QSqlTableModel::dropTestTables()
<< qTableName("test2")
<< qTableName("test3")
<< qTableName("emptytable")
- << qTableName("bigtable");
+ << qTableName("bigtable")
+ << qTableName("foo");
if (testWhiteSpaceNames(db.driverName()))
- tableNames << qTableName("qtestw hitespace");
+ tableNames << qTableName("qtestw hitespace", db.driver());
tst_Databases::safeDropTables(db, tableNames);
@@ -160,16 +182,16 @@ void tst_QSqlTableModel::repopulateTestTables()
QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i));
QSqlQuery q(db);
- QVERIFY_SQL( q, exec("delete from " + qTableName("test")));
+ q.exec("delete from " + qTableName("test"));
QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(3, 'vohi', 3)"));
- QVERIFY_SQL( q, exec("delete from " + qTableName("test2")));
+ q.exec("delete from " + qTableName("test2"));
QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(1, 'herr')"));
QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(2, 'mister')"));
- QVERIFY_SQL( q, exec("delete from " + qTableName("test3")));
+ q.exec("delete from " + qTableName("test3"));
QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(1, 'foo', 'bar')"));
QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(2, 'baz', 'joe')"));
}
@@ -182,11 +204,13 @@ void tst_QSqlTableModel::recreateTestTables()
repopulateTestTables();
}
-void tst_QSqlTableModel::initTestCase_data()
+void tst_QSqlTableModel::generic_data(const QString &engine)
{
- if (dbs.fillTestTable() == 0) {
- qWarning("NO DATABASES");
- QSKIP("No database drivers are available in this Qt configuration", SkipAll);
+ if ( dbs.fillTestTable(engine) == 0 ) {
+ if(engine.isEmpty())
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ else
+ QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
}
}
@@ -212,7 +236,7 @@ void tst_QSqlTableModel::cleanup()
void tst_QSqlTableModel::select()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -245,58 +269,56 @@ void tst_QSqlTableModel::select()
QCOMPARE(model.data(model.index(3, 3)), QVariant());
}
-void tst_QSqlTableModel::setRecord_data()
-{
- QTest::addColumn<uint>("submitpolicy");
- QTest::newRow("OnFieldChange") << (uint)QSqlTableModel::OnFieldChange;
- QTest::newRow("OnRowChange") << (uint)QSqlTableModel::OnRowChange;
- QTest::newRow("OnManualSubmit") << (uint)QSqlTableModel::OnManualSubmit;
-}
-
void tst_QSqlTableModel::setRecord()
{
- // This needs to be tested with ODBC, which requires a manual change to qsqldatabase\tst_databases.h
- // to ensure an ODBC db is added
-
- QFETCH_GLOBAL(QString, dbName);
- QFETCH(uint, submitpolicy);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- QSqlTableModel model(0, db);
- model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy);
- model.setTable(qTableName("test3"));
- model.setSort(0, Qt::AscendingOrder);
- QVERIFY_SQL(model, select());
+ QList<QSqlTableModel::EditStrategy> policies = QList<QSqlTableModel::EditStrategy>() << QSqlTableModel::OnFieldChange << QSqlTableModel::OnRowChange << QSqlTableModel::OnManualSubmit;
+
+ QString Xsuffix;
+ foreach( QSqlTableModel::EditStrategy submitpolicy, policies) {
- for (int i = 0; i < model.rowCount(); ++i) {
- QSignalSpy spy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
-
- QSqlRecord rec = model.record(i);
- rec.setValue(1, rec.value(1).toString() + 'X');
- rec.setValue(2, rec.value(2).toString() + 'X');
- QVERIFY(model.setRecord(i, rec));
-
- if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit)
- QVERIFY(model.submitAll());
- else {
- // dataChanged() is not emitted when submitAll() is called
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(0).count(), 2);
- QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1));
- QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1));
+ QSqlTableModel model(0, db);
+ model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy);
+ model.setTable(qTableName("test3"));
+ model.setSort(0, Qt::AscendingOrder);
+ QVERIFY_SQL(model, select());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QSignalSpy spy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
+
+ QSqlRecord rec = model.record(i);
+ rec.setValue(1, rec.value(1).toString() + 'X');
+ rec.setValue(2, rec.value(2).toString() + 'X');
+ QVERIFY(model.setRecord(i, rec));
+
+ if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnManualSubmit)
+ QVERIFY(model.submitAll());
+ else if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnRowChange && i == model.rowCount() -1)
+ model.submit();
+ else {
+ // dataChanged() is not emitted when submitAll() is called
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.at(0).count(), 2);
+ QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1));
+ QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1));
+ }
}
- }
- QCOMPARE(model.data(model.index(0, 1)).toString(), QString("fooX"));
- QCOMPARE(model.data(model.index(0, 2)).toString(), QString("barX"));
- QCOMPARE(model.data(model.index(1, 1)).toString(), QString("bazX"));
- QCOMPARE(model.data(model.index(1, 2)).toString(), QString("joeX"));
+ Xsuffix.append('X');
+
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("foo").append(Xsuffix));
+ QCOMPARE(model.data(model.index(0, 2)).toString(), QString("bar").append(Xsuffix));
+ QCOMPARE(model.data(model.index(1, 1)).toString(), QString("baz").append(Xsuffix));
+ QCOMPARE(model.data(model.index(1, 2)).toString(), QString("joe").append(Xsuffix));
+ }
}
void tst_QSqlTableModel::insertRow()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -321,7 +343,7 @@ void tst_QSqlTableModel::insertRow()
void tst_QSqlTableModel::insertRecord()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -354,7 +376,7 @@ void tst_QSqlTableModel::insertRecord()
void tst_QSqlTableModel::insertMultiRecords()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -403,7 +425,7 @@ void tst_QSqlTableModel::insertMultiRecords()
void tst_QSqlTableModel::submitAll()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -438,7 +460,7 @@ void tst_QSqlTableModel::submitAll()
void tst_QSqlTableModel::removeRow()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -484,7 +506,7 @@ void tst_QSqlTableModel::removeRow()
void tst_QSqlTableModel::removeRows()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -533,7 +555,7 @@ void tst_QSqlTableModel::removeRows()
void tst_QSqlTableModel::removeInsertedRow()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -565,7 +587,7 @@ void tst_QSqlTableModel::removeInsertedRow()
void tst_QSqlTableModel::emptyTable()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -584,12 +606,10 @@ void tst_QSqlTableModel::emptyTable()
void tst_QSqlTableModel::tablesAndSchemas()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QPSQL");
-
QSqlQuery q(db);
q.exec("DROP SCHEMA " + qTableName("testschema") + " CASCADE");
QVERIFY_SQL( q, exec("create schema " + qTableName("testschema")));
@@ -607,7 +627,7 @@ void tst_QSqlTableModel::tablesAndSchemas()
void tst_QSqlTableModel::whitespaceInIdentifiers()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -623,16 +643,16 @@ void tst_QSqlTableModel::whitespaceInIdentifiers()
void tst_QSqlTableModel::primaryKeyOrder()
{
- QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "primaryKeyOrderTest");
- db.setDatabaseName(":memory:");
- QVERIFY_SQL(db, open());
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
QSqlQuery q(db);
- QVERIFY_SQL( q, exec("create table foo(a varchar(20), id int primary key, b varchar(20))"));
+ QVERIFY_SQL( q, exec("create table "+qTableName("foo")+"(a varchar(20), id int not null primary key, b varchar(20))"));
QSqlTableModel model(0, db);
- model.setTable("foo");
+ model.setTable(qTableName("foo"));
QSqlIndex pk = model.primaryKey();
QCOMPARE(pk.count(), 1);
@@ -652,7 +672,7 @@ void tst_QSqlTableModel::primaryKeyOrder()
void tst_QSqlTableModel::setInvalidFilter()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -671,7 +691,7 @@ void tst_QSqlTableModel::setInvalidFilter()
void tst_QSqlTableModel::setFilter()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -724,12 +744,10 @@ void tst_QSqlTableModel::setFilter()
void tst_QSqlTableModel::sqlite_bigTable()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QSQLITE");
-
bool hasTransactions = db.driver()->hasFeature(QSqlDriver::Transactions);
if (hasTransactions) QVERIFY(db.transaction());
QSqlQuery q(db);
@@ -763,7 +781,7 @@ void tst_QSqlTableModel::sqlite_bigTable()
// had first been called.
void tst_QSqlTableModel::insertRecordBeforeSelect()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -796,7 +814,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect()
// are inserted and submitted on a non-existing table.
void tst_QSqlTableModel::submitAllOnInvalidTable()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -828,7 +846,7 @@ void tst_QSqlTableModel::submitAllOnInvalidTable()
// For task 147575: the rowsRemoved signal emitted from the model was lying
void tst_QSqlTableModel::insertRecordsInLoop()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
@@ -866,12 +884,10 @@ void tst_QSqlTableModel::insertRecordsInLoop()
void tst_QSqlTableModel::sqlite_attachedDatabase()
{
- QFETCH_GLOBAL(QString, dbName);
+ QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
- DBMS_SPECIFIC(db, "QSQLITE");
-
QSqlDatabase attachedDb = QSqlDatabase::cloneDatabase(db, db.driverName() + QLatin1String("attached"));
attachedDb.setDatabaseName(db.databaseName()+QLatin1String("attached.dat"));
QVERIFY_SQL(attachedDb, open());
diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp
index 94e0f9845c..8b8fc6516f 100644
--- a/tests/auto/qsqlthread/tst_qsqlthread.cpp
+++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp
@@ -70,7 +70,7 @@ public:
void recreateTestTables();
void repopulateTestTables();
- void generic_data();
+ void generic_data(const QString &engine=QString());
tst_Databases dbs;
public slots:
@@ -286,10 +286,14 @@ tst_QSqlThread::~tst_QSqlThread()
{
}
-void tst_QSqlThread::generic_data()
+void tst_QSqlThread::generic_data(const QString& engine)
{
- if (dbs.fillTestTable() == 0)
- QSKIP("No database drivers are available in this Qt configuration", SkipAll);
+ if ( dbs.fillTestTable(engine) == 0 ) {
+ if(engine.isEmpty())
+ QSKIP( "No database drivers are available in this Qt configuration", SkipAll );
+ else
+ QSKIP( (QString("No database drivers of type %1 are available in this Qt configuration").arg(engine)).toLocal8Bit(), SkipAll );
+ }
}
void tst_QSqlThread::dropTestTables()
diff --git a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
index ec27e96b77..a53032365d 100644
--- a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -115,7 +115,6 @@ private slots:
void checkChildren();
void data();
void clear();
-#if QT_VERSION >= 0x040200
void sort_data();
void sort();
void sortRole_data();
@@ -133,10 +132,9 @@ private slots:
void useCase1();
void useCase2();
void useCase3();
-#endif
void rootItemFlags();
- void treeDragAndDrop();
+ void treeDragAndDrop();
private:
QAbstractItemModel *m_model;
@@ -144,7 +142,7 @@ private:
QVector<QModelIndex> rcParent;
QVector<int> rcFirst;
QVector<int> rcLast;
-
+
//return true if models have the same structure, and all child have the same text
bool compareModels(QStandardItemModel *model1, QStandardItemModel *model2);
//return true if models have the same structure, and all child have the same text
@@ -154,9 +152,7 @@ private:
static const int defaultSize = 3;
Q_DECLARE_METATYPE(QModelIndex)
-#if QT_VERSION >= 0x040200
Q_DECLARE_METATYPE(QStandardItem*)
-#endif
Q_DECLARE_METATYPE(Qt::Orientation)
Q_DECLARE_METATYPE(QVariantList)
@@ -181,9 +177,7 @@ tst_QStandardItemModel::~tst_QStandardItemModel()
void tst_QStandardItemModel::init()
{
qRegisterMetaType<QModelIndex>("QModelIndex");
-#if QT_VERSION >= 0x040200
qRegisterMetaType<QStandardItem*>("QStandardItem*");
-#endif
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
m_model = new QStandardItemModel(defaultSize, defaultSize);
@@ -768,7 +762,6 @@ void tst_QStandardItemModel::clear()
QCOMPARE(model.hasChildren(), false);
}
-#if QT_VERSION >= 0x040200
void tst_QStandardItemModel::sort_data()
{
QTest::addColumn<int>("sortOrder");
@@ -1383,8 +1376,6 @@ void tst_QStandardItemModel::useCase3()
delete childItem;
}
-#endif // QT_VERSION >= 0x040200
-
void tst_QStandardItemModel::rootItemFlags()
{
QStandardItemModel model(6, 4);
@@ -1428,7 +1419,7 @@ bool tst_QStandardItemModel::compareItems(QStandardItem *item1, QStandardItem *i
}
for (int row = 0; row < item1->columnCount(); row++)
for (int col = 0; col < item1->columnCount(); col++) {
-
+
if (!compareItems(item1->child(row, col), item2->child(row, col)))
return false;
}
@@ -1440,19 +1431,19 @@ static QStandardItem *itemFromText(QStandardItem *parent, const QString &text)
QStandardItem *item = 0;
for(int i = 0; i < parent->columnCount(); i++)
for(int j = 0; j < parent->rowCount(); j++) {
-
+
QStandardItem *child = parent->child(j, i);
-
+
if(!child)
continue;
-
+
if (child->text() == text) {
if (item) {
return 0;
}
item = child;
}
-
+
QStandardItem *candidate = itemFromText(child, text);
if(candidate) {
if (item) {
@@ -1472,9 +1463,9 @@ static QModelIndex indexFromText(QStandardItemModel *model, const QString &text)
}
-struct FriendlyTreeView : public QTreeView
+struct FriendlyTreeView : public QTreeView
{
- friend class tst_QStandardItemModel;
+ friend class tst_QStandardItemModel;
Q_DECLARE_PRIVATE(QTreeView)
};
@@ -1482,7 +1473,7 @@ void tst_QStandardItemModel::treeDragAndDrop()
{
const int nRow = 5;
const int nCol = 3;
-
+
QStandardItemModel model;
QStandardItemModel checkModel;
@@ -1491,13 +1482,13 @@ void tst_QStandardItemModel::treeDragAndDrop()
for (int c = 0 ; c < nCol; c ++)
colItems1 << new QStandardItem(QString("item %1 - %0").arg(c).arg(i));
model.appendRow(colItems1);
-
+
for (int j = 0; j < nRow; ++j) {
QList<QStandardItem *> colItems2;
for (int c = 0 ; c < nCol; c ++)
colItems2 << new QStandardItem(QString("item %1/%2 - %0").arg(c).arg(i).arg(j));
colItems1.at(0)->appendRow(colItems2);
-
+
for (int k = 0; k < nRow; ++k) {
QList<QStandardItem *> colItems3;
for (int c = 0 ; c < nCol; c ++)
@@ -1506,21 +1497,19 @@ void tst_QStandardItemModel::treeDragAndDrop()
}
}
}
-
-
-
+
for (int i = 0; i < nRow; ++i) {
QList<QStandardItem *> colItems1;
for (int c = 0 ; c < nCol; c ++)
colItems1 << new QStandardItem(QString("item %1 - %0").arg(c).arg(i));
checkModel.appendRow(colItems1);
-
+
for (int j = 0; j < nRow; ++j) {
QList<QStandardItem *> colItems2;
for (int c = 0 ; c < nCol; c ++)
colItems2 << new QStandardItem(QString("item %1/%2 - %0").arg(c).arg(i).arg(j));
colItems1.at(0)->appendRow(colItems2);
-
+
for (int k = 0; k < nRow; ++k) {
QList<QStandardItem *> colItems3;
for (int c = 0 ; c < nCol; c ++)
@@ -1529,9 +1518,9 @@ void tst_QStandardItemModel::treeDragAndDrop()
}
}
}
-
+
QVERIFY(compareModels(&model, &checkModel));
-
+
FriendlyTreeView view;
view.setModel(&model);
view.expandAll();
@@ -1560,7 +1549,7 @@ void tst_QStandardItemModel::treeDragAndDrop()
if(model.dropMimeData(data, Qt::MoveAction, 0, 0, indexFromText(&model, "item 4 - 0")))
view.d_func()->clearOrRemove();
delete data;
-
+
QVERIFY(!compareModels(&model, &checkModel)); //the model must be different at this point
QStandardItem *item4 = itemFromText(checkModel.invisibleRootItem(), "item 4 - 0");
item4->insertRow(0, checkModel.takeRow(1));
@@ -1568,7 +1557,6 @@ void tst_QStandardItemModel::treeDragAndDrop()
QVERIFY(compareModels(&model, &checkModel));
}
-
//
// step2 drag "item 3" and "item 3/0" into "item 4"
//
@@ -1576,10 +1564,10 @@ void tst_QStandardItemModel::treeDragAndDrop()
selection->clear();
selection->select(QItemSelection(indexFromText(&model, QString("item 3 - 0")),
indexFromText(&model, QString("item 3 - %0").arg(nCol-1))), QItemSelectionModel::Select);
-
+
selection->select(QItemSelection(indexFromText(&model, QString("item 3/0 - 0")),
indexFromText(&model, QString("item 3/0 - %0").arg(nCol-1))), QItemSelectionModel::Select);
-
+
//code based from QAbstractItemView::startDrag and QAbstractItemView::dropEvent
QModelIndexList indexes = view.selectedIndexes();
QMimeData *data = model.mimeData(indexes);
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index e777a399a8..e9c12c64cc 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -432,6 +432,10 @@ void tst_QString::replace_uint_uint_data()
QTest::newRow( "rep09" ) << QString("ACABCAB") << 4 << 2 << QString("XX") << QString("ACABXXB");
QTest::newRow( "rep10" ) << QString("ACABCAB") << 5 << 2 << QString("XX") << QString("ACABCXX");
QTest::newRow( "rep10" ) << QString("ACABCAB") << 6 << 2 << QString("XX") << QString("ACABCAXX");
+ QTest::newRow( "rep12" ) << QString() << 0 << 10 << QString("X") << QString("X");
+ QTest::newRow( "rep13" ) << QString("short") << 0 << 10 << QString("X") << QString("X");
+ QTest::newRow( "rep14" ) << QString() << 0 << 10 << QString("XX") << QString("XX");
+ QTest::newRow( "rep15" ) << QString("short") << 0 << 10 << QString("XX") << QString("XX");
}
void tst_QString::replace_string_data()
diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp
index c84218673a..e020f9e5b6 100644
--- a/tests/auto/qstyle/tst_qstyle.cpp
+++ b/tests/auto/qstyle/tst_qstyle.cpp
@@ -74,9 +74,7 @@
#define SRCDIR "."
#endif
-#if QT_VERSION >= 0x040200
#include <QCleanlooksStyle>
-#endif
#ifdef Q_WS_MAC
#include <QMacStyle>
@@ -362,7 +360,7 @@ void tst_QStyle::testPlastiqueStyle()
void tst_QStyle::testCleanlooksStyle()
{
-#if QT_VERSION >= 0x040200 && !defined(QT_NO_STYLE_CLEANLOOKS)
+#if !defined(QT_NO_STYLE_CLEANLOOKS)
QCleanlooksStyle cstyle;
testAllFunctions(&cstyle);
lineUpLayoutTest(&cstyle);
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 7954d0062c..aa63753d88 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -94,6 +94,7 @@ private slots:
void embeddedFonts();
void opaquePaintEvent_data();
void opaquePaintEvent();
+ void task188195_baseBackground();
//at the end because it mess with the style.
void widgetStyle();
@@ -1354,6 +1355,28 @@ void tst_QStyleSheetStyle::opaquePaintEvent()
QCOMPARE(cl.autoFillBackground(), !styled );
}
+void tst_QStyleSheetStyle::task188195_baseBackground()
+{
+ QTreeView tree;
+ tree.setStyleSheet( "QTreeView:disabled { background-color:#ab1251; }" );
+ tree.show();
+ QTest::qWait(20);
+ QImage image(tree.width(), tree.height(), QImage::Format_ARGB32);
+
+ tree.render(&image);
+ QVERIFY(testForColors(image, tree.palette().base().color()));
+ QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51)));
+
+ tree.setEnabled(false);
+ tree.render(&image);
+ QVERIFY(testForColors(image, QColor(0xab, 0x12, 0x51)));
+
+ tree.setEnabled(true);
+ tree.render(&image);
+ QVERIFY(testForColors(image, tree.palette().base().color()));
+ QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51)));
+}
+
QTEST_MAIN(tst_QStyleSheetStyle)
diff --git a/tests/auto/qsvgdevice/tst_qsvgdevice.cpp b/tests/auto/qsvgdevice/tst_qsvgdevice.cpp
index 713b3faf4e..4f16e7e62e 100644
--- a/tests/auto/qsvgdevice/tst_qsvgdevice.cpp
+++ b/tests/auto/qsvgdevice/tst_qsvgdevice.cpp
@@ -332,11 +332,7 @@ void tst_QSvgDevice::playPaint( QPainter *p, const QString &type )
qDrawShadePanel(p,4000,5000,4000,2000,palette.active(),false,200,&br);
qDrawShadeRect(p,2000,2000,4000,2000,palette.active(),true,100,0,&br);
}
- }
-#if !defined (Q_WS_WIN) && (QT_VERSION < 0x030200)
- // This will fail on X11 with 3.1, fixed in 3.2
-#else
- else if (type=="clipRect") {
+ } else if (type=="clipRect") {
p->setClipRect(15,25,10,10);
p->drawEllipse(10,20,50,70);
} else if (type=="multipleClipRects") {
@@ -344,9 +340,7 @@ void tst_QSvgDevice::playPaint( QPainter *p, const QString &type )
p->drawEllipse(10,20,50,70);
p->setClipRect(100,200,20,20);
p->drawEllipse(110,220,50,70);
- }
-#endif
- else if (type == "qsimplerichtext") {
+ } else if (type == "qsimplerichtext") {
p->setPen(QColor(0,0,0));
p->setBrush(Qt::NoBrush);
QRect rect1(10, 10, 100, 50);
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index 4a170312c1..4da99da7f5 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -534,16 +534,42 @@ void tst_QSvgRenderer::gradientStops() const
QCOMPARE(image, refImage);
}
+ const char *svgs[] = {
+ "<svg>"
+ "<defs>"
+ "<linearGradient id=\"gradient\">"
+ "<stop offset=\"0\" stop-color=\"red\" stop-opacity=\"0\"/>"
+ "<stop offset=\"1\" stop-color=\"blue\"/>"
+ "</linearGradient>"
+ "</defs>"
+ "<rect fill=\"url(#gradient)\" height=\"8\" width=\"256\" x=\"0\" y=\"0\"/>"
+ "</svg>",
+ "<svg>"
+ "<defs>"
+ "<linearGradient id=\"gradient\" xlink:href=\"#gradient0\">"
+ "</linearGradient>"
+ "<linearGradient id=\"gradient0\">"
+ "<stop offset=\"0\" stop-color=\"red\" stop-opacity=\"0\"/>"
+ "<stop offset=\"1\" stop-color=\"blue\"/>"
+ "</linearGradient>"
+ "</defs>"
+ "<rect fill=\"url(#gradient)\" height=\"8\" width=\"256\" x=\"0\" y=\"0\"/>"
+ "</svg>",
+ "<svg>"
+ "<defs>"
+ "<linearGradient id=\"gradient0\">"
+ "<stop offset=\"0\" stop-color=\"red\" stop-opacity=\"0\"/>"
+ "<stop offset=\"1\" stop-color=\"blue\"/>"
+ "</linearGradient>"
+ "<linearGradient id=\"gradient\" xlink:href=\"#gradient0\">"
+ "</linearGradient>"
+ "</defs>"
+ "<rect fill=\"url(#gradient)\" height=\"8\" width=\"256\" x=\"0\" y=\"0\"/>"
+ "</svg>"
+ };
+ for (int i = 0 ; i < sizeof(svgs) / sizeof(svgs[0]) ; ++i)
{
- QByteArray data("<svg>"
- "<defs>"
- "<linearGradient id=\"gradient\">"
- "<stop offset=\"0\" stop-color=\"red\" stop-opacity=\"0\"/>"
- "<stop offset=\"1\" stop-color=\"blue\"/>"
- "</linearGradient>"
- "</defs>"
- "<rect fill=\"url(#gradient)\" height=\"8\" width=\"256\" x=\"0\" y=\"0\"/>"
- "</svg>");
+ QByteArray data = svgs[i];
QSvgRenderer renderer(data);
QImage image(256, 8, QImage::Format_ARGB32_Premultiplied);
diff --git a/tests/auto/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/qsystemtrayicon/tst_qsystemtrayicon.cpp
index 7ce30aac66..8c5da7b2b7 100644
--- a/tests/auto/qsystemtrayicon/tst_qsystemtrayicon.cpp
+++ b/tests/auto/qsystemtrayicon/tst_qsystemtrayicon.cpp
@@ -42,10 +42,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <qcoreapplication.h>
#include <qdebug.h>
#include <qsystemtrayicon.h>
@@ -150,4 +146,3 @@ void tst_QSystemTrayIcon::lastWindowClosed()
QTEST_MAIN(tst_QSystemTrayIcon)
#include "tst_qsystemtrayicon.moc"
-#endif
diff --git a/tests/auto/qtabbar/tst_qtabbar.cpp b/tests/auto/qtabbar/tst_qtabbar.cpp
index 13a33d351b..7cf708cac3 100644
--- a/tests/auto/qtabbar/tst_qtabbar.cpp
+++ b/tests/auto/qtabbar/tst_qtabbar.cpp
@@ -92,6 +92,8 @@ private slots:
void moveTab_data();
void moveTab();
+
+ void task251184_removeTab();
};
// Testing get/set functions
@@ -503,5 +505,35 @@ void tst_QTabBar::moveTab()
bar.callMoveTab(from, to);
}
+
+class MyTabBar : public QTabBar
+{
+ Q_OBJECT
+public slots:
+ void onCurrentChanged()
+ {
+ //we just want this to be done once
+ disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(onCurrentChanged()));
+ removeTab(0);
+ }
+};
+
+void tst_QTabBar::task251184_removeTab()
+{
+ MyTabBar bar;
+ bar.addTab("bar1");
+ bar.addTab("bar2");
+ QCOMPARE(bar.count(), 2);
+ QCOMPARE(bar.currentIndex(), 0);
+
+ bar.connect(&bar, SIGNAL(currentChanged(int)), SLOT(onCurrentChanged()));
+ bar.setCurrentIndex(1);
+
+ QCOMPARE(bar.count(), 1);
+ QCOMPARE(bar.currentIndex(), 0);
+ QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2"));
+}
+
+
QTEST_MAIN(tst_QTabBar)
#include "tst_qtabbar.moc"
diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
index 9b78cefefa..c5afe0478a 100644
--- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -77,6 +77,7 @@ private slots:
void resize();
void openOnRootDrives();
void stressTest();
+ void rename();
public:
};
@@ -143,7 +144,6 @@ void tst_QTemporaryFile::fileTemplate_data()
void tst_QTemporaryFile::fileTemplate()
{
-#if QT_VERSION >= 0x040200
QFETCH(QString, constructorTemplate);
QFETCH(QString, suffix);
QFETCH(QString, fileTemplate);
@@ -156,7 +156,6 @@ void tst_QTemporaryFile::fileTemplate()
QCOMPARE(file.fileName().right(suffix.length()), suffix);
file.close();
-#endif
}
@@ -233,9 +232,6 @@ void tst_QTemporaryFile::write()
void tst_QTemporaryFile::openCloseOpenClose()
{
-#if QT_VERSION < 0x040101
- QSKIP("Until Qt 4.1.1, QTemporaryFile would create a new name every time open() was called.", SkipSingle);
-#endif
QString fileName;
{
// Create a temp file
@@ -335,5 +331,30 @@ void tst_QTemporaryFile::stressTest()
}
}
+void tst_QTemporaryFile::rename()
+{
+ // This test checks that the temporary file is deleted, even after a
+ // rename.
+
+ QDir dir;
+ QVERIFY(!dir.exists("temporary-file.txt"));
+
+ QString tempname;
+ {
+ QTemporaryFile file(dir.filePath("temporary-file.XXXXXX"));
+
+ QVERIFY(file.open());
+ tempname = file.fileName();
+ QVERIFY(dir.exists(tempname));
+
+ QVERIFY(file.rename("temporary-file.txt"));
+ QVERIFY(!dir.exists(tempname));
+ QVERIFY(dir.exists("temporary-file.txt"));
+ }
+
+ QVERIFY(!dir.exists(tempname));
+ QVERIFY(!dir.exists("temporary-file.txt"));
+}
+
QTEST_MAIN(tst_QTemporaryFile)
#include "tst_qtemporaryfile.moc"
diff --git a/tests/auto/qtextcodec/test/test.pro b/tests/auto/qtextcodec/test/test.pro
index d7373c643c..69cd1dd5d0 100644
--- a/tests/auto/qtextcodec/test/test.pro
+++ b/tests/auto/qtextcodec/test/test.pro
@@ -5,6 +5,7 @@ wince*|symbian {
addFiles.sources = ../*.txt
addFiles.path = .
DEPLOYMENT += addFiles
+ DEPLOYMENT_PLUGIN += qcncodecs qjpcodecs qkrcodecs qtwcodecs
}
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index c7e39a8fcc..ff4b4bbefc 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -69,6 +69,8 @@ private slots:
void flagEFBFBF() const;
void decode0D() const;
void codecForIndex() const;
+ void aliasForUTF16() const;
+ void mibForTSCII() const;
void utf8Codec_data();
void utf8Codec();
@@ -453,6 +455,16 @@ void tst_QTextCodec::codecForIndex() const
{
}
+void tst_QTextCodec::aliasForUTF16() const
+{
+ QVERIFY(QTextCodec::codecForName("UTF-16")->aliases().isEmpty());
+}
+
+void tst_QTextCodec::mibForTSCII() const
+{
+ QCOMPARE(QTextCodec::codecForName("TSCII")->mibEnum(), 2107);
+}
+
static QString fromInvalidUtf8Sequence(const QByteArray &ba)
{
return QString().fill(QChar::ReplacementCharacter, ba.size());
diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp
index 48212a462b..86b253f254 100644
--- a/tests/auto/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp
@@ -124,9 +124,7 @@ private slots:
void selectWordWithSeparators_data();
void selectWordWithSeparators();
void startOfWord();
-#if QT_VERSION >= 0x040100
void selectBlock();
-#endif
void selectVisually();
void insertText();
@@ -1228,13 +1226,9 @@ void tst_QTextCursor::selectWord()
cursor.movePosition(QTextCursor::EndOfBlock);
cursor.select(QTextCursor::WordUnderCursor);
-#if QT_VERSION < 0x040200
- QVERIFY(!cursor.hasSelection());
-#else
QVERIFY(cursor.hasSelection());
QCOMPARE(cursor.selectionStart(), 17);
QCOMPARE(cursor.selectionEnd(), 22);
-#endif
}
void tst_QTextCursor::selectWordWithSeparators_data()
@@ -1269,7 +1263,6 @@ void tst_QTextCursor::startOfWord()
QCOMPARE(cursor.position(), 0);
}
-#if QT_VERSION >= 0x040100
void tst_QTextCursor::selectBlock()
{
cursor.insertText("foobar");
@@ -1295,7 +1288,6 @@ void tst_QTextCursor::selectBlock()
QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter);
QCOMPARE(cursor.block().text(), QString("blah"));
}
-#endif
void tst_QTextCursor::selectVisually()
{
@@ -1551,7 +1543,6 @@ void tst_QTextCursor::update()
void tst_QTextCursor::disallowSettingObjectIndicesOnCharFormats()
{
-#if QT_VERSION >= 0x040200
QTextCharFormat fmt;
fmt.setObjectIndex(42);
cursor.insertText("Hey", fmt);
@@ -1581,7 +1572,6 @@ void tst_QTextCursor::disallowSettingObjectIndicesOnCharFormats()
cursor = table->cellAt(0, 0).firstCursorPosition();
QVERIFY(!cursor.isNull());
QCOMPARE(cursor.blockCharFormat().objectIndex(), table->objectIndex());
-#endif
}
void tst_QTextCursor::blockAndColumnNumber()
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 58cc019ca8..4ef5299a04 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -193,14 +193,9 @@ void tst_QTextDocument::getSetCheck()
QPointer<MyAbstractTextDocumentLayout> var1 = new MyAbstractTextDocumentLayout(0);
obj1.setDocumentLayout(var1);
QCOMPARE(static_cast<QAbstractTextDocumentLayout *>(var1), obj1.documentLayout());
-#if QT_VERSION >= 0x040200
- // QTextDocument in Qt < 4.2 crashes on this. Qt >= 4.2 should handle this gracefully
obj1.setDocumentLayout((QAbstractTextDocumentLayout *)0);
QVERIFY(var1.isNull());
QVERIFY(obj1.documentLayout());
-#else
- delete var1;
-#endif
// bool QTextDocument::useDesignMetrics()
// void QTextDocument::setUseDesignMetrics(bool)
@@ -672,18 +667,6 @@ void tst_QTextDocument::toHtml_data()
<< QString("<p DEFAULTBLOCKSTYLE><span style=\" font-size:40pt;\">Blah</span></p>");
}
-#if QT_VERSION < 0x040200
- {
- CREATE_DOC_AND_CURSOR();
-
- QTextCharFormat fmt;
- fmt.setProperty(QTextFormat::FontSizeIncrement, 2);
- cursor.insertText("Blah", fmt);
-
- QTest::newRow("logical-font-size") << QTextDocumentFragment(&doc)
- << QString("<p DEFAULTBLOCKSTYLE><font size=\"5\">Blah</font></p>");
- }
-#else
{
CREATE_DOC_AND_CURSOR();
@@ -694,7 +677,6 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("logical-font-size") << QTextDocumentFragment(&doc)
<< QString("<p DEFAULTBLOCKSTYLE><span style=\" font-size:x-large;\">Blah</span></p>");
}
-#endif
{
CREATE_DOC_AND_CURSOR();
@@ -892,13 +874,8 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("simpletable") << QTextDocumentFragment(&doc)
<< QString("<table border=\"1\" cellspacing=\"2\">"
-#if QT_VERSION >= 0x040200
"\n<tr>\n<td></td>\n<td></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr>"
-#else
- "<tr><td></td><td></td></tr>"
- "<tr><td></td><td></td></tr>"
-#endif
"</table>");
}
@@ -911,11 +888,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("tablespans") << QTextDocumentFragment(&doc)
<< QString("<table border=\"1\" cellspacing=\"2\">"
-#if QT_VERSION >= 0x040200
"\n<tr>\n<td colspan=\"2\"></td>\n<td colspan=\"2\"></td></tr>"
-#else
- "<tr><td colspan=\"2\"></td><td colspan=\"2\"></td></tr>"
-#endif
"</table>");
}
@@ -961,7 +934,6 @@ void tst_QTextDocument::toHtml_data()
"</table>");
}
-#if QT_VERSION >= 0x040200
{
CREATE_DOC_AND_CURSOR();
@@ -977,7 +949,6 @@ void tst_QTextDocument::toHtml_data()
"\n<tr>\n<td></td>\n<td></td></tr>"
"</table>");
}
-#endif
{
CREATE_DOC_AND_CURSOR();
@@ -988,13 +959,8 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("nestedtable") << QTextDocumentFragment(&doc)
<< QString("<table border=\"1\" cellspacing=\"2\">"
-#if QT_VERSION >= 0x040200
"\n<tr>\n<td></td>\n<td>\n<table border=\"1\" cellspacing=\"2\">\n<tr>\n<td>\n<p DEFAULTBLOCKSTYLE>Hey</p></td></tr></table></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr>"
-#else
- "<tr><td></td><td><table border=\"1\" cellspacing=\"2\"><tr><td><p DEFAULTBLOCKSTYLE>Hey</p></td></tr></table></td></tr>"
- "<tr><td></td><td></td></tr>"
-#endif
"</table>");
}
@@ -1011,11 +977,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("colwidths") << QTextDocumentFragment(&doc)
<< QString("<table border=\"1\" cellspacing=\"2\">"
-#if QT_VERSION >= 0x040200
"\n<tr>\n<td></td>\n<td width=\"30%\"></td>\n<td width=\"40\"></td></tr>"
-#else
- "<tr><td></td><td width=\"30%\"></td><td width=\"40\"></td></tr>"
-#endif
"</table>");
}
@@ -1032,11 +994,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("cellproperties") << QTextDocumentFragment(&doc)
<< QString("<table border=\"1\" cellspacing=\"2\">"
-#if QT_VERSION >= 0x040200
"\n<tr>\n<td bgcolor=\"#ffffff\"></td></tr>"
-#else
- "<tr><td bgcolor=\"#ffffff\"></td></tr>"
-#endif
"</table>");
}
@@ -1111,9 +1069,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("blockmargins") << QTextDocumentFragment(&doc)
<<
-#if QT_VERSION >= 0x040100
QString("EMPTYBLOCK") +
-#endif
QString("<p style=\" margin-top:10px; margin-bottom:20px; margin-left:30px; margin-right:40px; -qt-block-indent:0; text-indent:0px;\">Blah</p>");
}
@@ -1129,11 +1085,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("lists") << QTextDocumentFragment(&doc)
<<
QString("EMPTYBLOCK") +
-#if QT_VERSION >= 0x040200
QString("<ul style=\"-qt-list-indent: 1;\"><li DEFAULTBLOCKSTYLE>Blubb</li>\n<li DEFAULTBLOCKSTYLE>Blah</li></ul>");
-#else
- QString("<ul style=\"-qt-list-indent: 1;\"><li DEFAULTBLOCKSTYLE>Blubb<li DEFAULTBLOCKSTYLE>Blah</ul>");
-#endif
}
{
@@ -1156,11 +1108,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("charfmt-for-list-item") << QTextDocumentFragment(&doc)
<<
QString("EMPTYBLOCK") +
-#if QT_VERSION >= 0x040200
QString("<ul style=\"-qt-list-indent: 1;\"><li DEFAULTBLOCKSTYLE>Blubb</li>\n<li style=\" color:#0000ff;\" DEFAULTBLOCKSTYLE><span style=\" color:#ff0000;\">Blah</span></li></ul>");
-#else
- QString("<ul style=\"-qt-list-indent: 1;\"><li DEFAULTBLOCKSTYLE>Blubb<li style=\" color:#0000ff;\" DEFAULTBLOCKSTYLE><span style=\" color:#ff0000;\">Blah</span></ul>");
-#endif
}
{
@@ -1174,9 +1122,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("block-indent") << QTextDocumentFragment(&doc)
<<
-#if QT_VERSION >= 0x040100
QString("EMPTYBLOCK") +
-#endif
QString("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:3; text-indent:30px;\">Test</p>");
}
@@ -1192,11 +1138,7 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("list-indent") << QTextDocumentFragment(&doc)
<<
QString("EMPTYBLOCK") +
-#if QT_VERSION >= 0x040200
QString("<ul style=\"-qt-list-indent: 4;\"><li DEFAULTBLOCKSTYLE>Blah</li></ul>");
-#else
- QString("<ul style=\"-qt-list-indent: 4;\"><li DEFAULTBLOCKSTYLE>Blah</ul>");
-#endif
}
{
@@ -1217,11 +1159,7 @@ void tst_QTextDocument::toHtml_data()
// if you press enter twice in an empty textedit and then insert 'Test'
// you actually get three visible paragraphs, two empty leading ones and
// a third with the actual text. the corresponding html representation
- // therefore should also contain three paragraphs. that only works in >= 4.1,
- // 4.0.x needs this additional block.
-#if QT_VERSION < 0x040100
- cursor.insertBlock();
-#endif
+ // therefore should also contain three paragraphs.
cursor.insertBlock();
QTextCharFormat fmt;
@@ -1232,16 +1170,10 @@ void tst_QTextDocument::toHtml_data()
fmt.setProperty(QTextFormat::FontSizeIncrement, 2);
cursor.insertText("Test", fmt);
-#if QT_VERSION < 0x040200
- QTest::newRow("blockcharfmt") << QTextDocumentFragment(&doc)
- << QString("EMPTYBLOCK<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; color:#00ff00;\"><font size=\"4\"><font size=\"5\">Test</font></font></p>");
-#else
QTest::newRow("blockcharfmt") << QTextDocumentFragment(&doc)
<< QString("EMPTYBLOCK<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:x-large; color:#00ff00;\">Test</span></p>");
-#endif
}
-#if QT_VERSION >= 0x040100
{
CREATE_DOC_AND_CURSOR();
@@ -1254,7 +1186,6 @@ void tst_QTextDocument::toHtml_data()
QTest::newRow("blockcharfmt2") << QTextDocumentFragment(&doc)
<< QString("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" color:#0000ff;\">Test</span></p>");
}
-#endif
{
QTest::newRow("horizontal-ruler") << QTextDocumentFragment::fromHtml("<hr />")
@@ -1285,11 +1216,7 @@ void tst_QTextDocument::toHtml_data()
cursor = mainFrame->lastCursorPosition();
QTest::newRow("frame") << QTextDocumentFragment(&doc)
-#if QT_VERSION >= 0x040200
<< QString("<table border=\"1\" style=\"-qt-table-type: frame; float: right; margin-top:2px; margin-bottom:2px; margin-left:2px; margin-right:2px;\" width=\"100\" height=\"50\" bgcolor=\"#00ff00\">\n<tr>\n<td style=\"border: none;\">\n<p DEFAULTBLOCKSTYLE>Hello World</p></td></tr></table>");
-#else
- << QString("<table border=\"1\" style=\"-qt-table-type: frame; float: right; margin-top:2px; margin-bottom:2px; margin-left:2px; margin-right:2px;\" width=\"100\" height=\"50\" bgcolor=\"#00ff00\"><tr><td style=\"border: none;\"><p DEFAULTBLOCKSTYLE>Hello World</p></td></tr></table>");
-#endif
}
{
@@ -1993,11 +1920,7 @@ void tst_QTextDocument::resolvedFontInEmptyFormat()
void tst_QTextDocument::defaultRootFrameMargin()
{
-#if QT_VERSION >= 0x040200 && QT_VERSION <= 0x040400
- QCOMPARE(doc->rootFrame()->frameFormat().margin(), 2.0);
-#else
QCOMPARE(doc->rootFrame()->frameFormat().margin(), 4.0);
-#endif
}
class TestDocument : public QTextDocument
@@ -2415,7 +2338,6 @@ void tst_QTextDocument::documentCleanup()
void tst_QTextDocument::characterAt()
{
-#if QT_VERSION >= 0x040500
QTextDocument doc;
QTextCursor cursor(&doc);
QString text("12345\n67890");
@@ -2432,7 +2354,6 @@ void tst_QTextDocument::characterAt()
c = QChar(QChar::ParagraphSeparator);
QCOMPARE(doc.characterAt(i), c);
}
-#endif
}
void tst_QTextDocument::revisions()
diff --git a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index bace7b4e9d..46f5f0c5ac 100644
--- a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -2217,9 +2217,6 @@ void tst_QTextDocumentFragment::defaultFont()
void tst_QTextDocumentFragment::html_spanBackgroundColor()
{
setHtml("<span style=\"background-color: blue\">Foo</span>");
-#if QT_VERSION <= 0x040100
- QEXPECT_FAIL("", "Fixed in >= 4.1.1", Continue);
-#endif
QVERIFY(doc->begin().begin().fragment().charFormat().background().color() == QColor(Qt::blue));
}
@@ -2251,9 +2248,6 @@ void tst_QTextDocumentFragment::html_brokenTitle()
void tst_QTextDocumentFragment::html_blockVsInline()
{
-#if QT_VERSION <= 0x040100
- QEXPECT_FAIL("", "Fixed in >= 4.1.1", Abort);
-#endif
{
setHtml("<html><body><div><b>Foo<div>Bar");
QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold);
@@ -2314,15 +2308,8 @@ void tst_QTextDocumentFragment::html_tbody()
QTextTable *table = cursor.currentTable();
QVERIFY(table);
QCOMPARE(table->columns(), 1);
-#if QT_VERSION <= 0x040100
- QEXPECT_FAIL("", "Fixed in >= 4.1.1", Abort);
-#endif
QCOMPARE(table->rows(), 2);
-
-#if QT_VERISON >= 0x040200
- QVERIFY(table->format().headerRowCount(), 1);
-#endif
-
+ QCOMPARE(table->format().headerRowCount(), 1);
QCOMPARE(table->cellAt(0, 0).firstCursorPosition().block().text(), QString("First Cell"));
QCOMPARE(table->cellAt(1, 0).firstCursorPosition().block().text(), QString("Second Cell"));
}
@@ -2380,7 +2367,6 @@ void tst_QTextDocumentFragment::html_nestedTables()
void tst_QTextDocumentFragment::html_rowSpans()
{
-#if QT_VERSION > 0x040100
setHtml(""
"<table border=\"1\" width=\"100%\">"
" <tr>"
@@ -2413,7 +2399,6 @@ void tst_QTextDocumentFragment::html_rowSpans()
QCOMPARE(table->cellAt(3, 0).firstCursorPosition().block().text(), QString("blubb"));
QCOMPARE(table->cellAt(3, 1).firstCursorPosition().block().text(), QString("baz"));
-#endif
}
void tst_QTextDocumentFragment::html_rowSpans2()
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index 534c7b04dc..4ea3e2f38d 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -182,9 +182,6 @@ void tst_QTextLayout::init()
testFont.setFamily("__Qt__Box__Engine__");
testFont.setPixelSize(TESTFONT_SIZE);
testFont.setWeight(QFont::Normal);
-#if defined(Q_WS_MAC) && QT_VERSION < 0x040200
- QSKIP("QTestFontEngine is not supported on the mac right now", SkipAll);
-#endif
QCOMPARE(QFontMetrics(testFont).width('a'), testFont.pixelSize());
}
diff --git a/tests/auto/qtextobject/tst_qtextobject.cpp b/tests/auto/qtextobject/tst_qtextobject.cpp
index 4fbc155a12..4d1d4b20fd 100644
--- a/tests/auto/qtextobject/tst_qtextobject.cpp
+++ b/tests/auto/qtextobject/tst_qtextobject.cpp
@@ -62,6 +62,7 @@ public:
private slots:
void getSetCheck();
+ void testStandAloneTextObject();
};
tst_QTextObject::tst_QTextObject()
@@ -105,5 +106,23 @@ void tst_QTextObject::getSetCheck()
QCOMPARE(INT_MAX, obj2.userState());
}
+class TestTextObject : public QTextObject
+{
+public:
+ TestTextObject(QTextDocument *document) : QTextObject(document) {}
+};
+
+void tst_QTextObject::testStandAloneTextObject()
+{
+ QTextDocument document;
+ TestTextObject textObject(&document);
+
+ QCOMPARE(textObject.document(), &document);
+ // don't crash
+ textObject.format();
+ textObject.formatIndex();
+ QCOMPARE(textObject.objectIndex(), -1);
+}
+
QTEST_MAIN(tst_QTextObject)
#include "tst_qtextobject.moc"
diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
index f70082d8cf..c60e0bf7e8 100644
--- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -533,7 +533,7 @@ void tst_QScriptEngine::bengali()
void tst_QScriptEngine::gurmukhi()
{
-#if QT_VERSION >= 0x040001 && defined(Q_WS_X11)
+#if defined(Q_WS_X11)
{
if (QFontDatabase().families(QFontDatabase::Gurmukhi).contains("Lohit Punjabi")) {
QFont f("Lohit Punjabi");
diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp
index fa1eda621d..d70f6780f6 100644
--- a/tests/auto/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/qtextstream/tst_qtextstream.cpp
@@ -60,6 +60,8 @@
#include <QTextCodec>
#include <QProcess>
+#include "../network-settings.h"
+
static const char *TestFileName = "testfile";
Q_DECLARE_METATYPE(qlonglong)
@@ -102,10 +104,8 @@ private slots:
void readLineFromTextDevice_data();
void readLineFromTextDevice();
void readLineUntilNull();
-#if QT_VERSION >= 0x040103
void readLineMaxlen_data();
void readLineMaxlen();
-#endif
void readLinesFromBufferCRCR();
// all
@@ -222,13 +222,11 @@ private slots:
void utf8IncompleteAtBufferBoundary_data();
void utf8IncompleteAtBufferBoundary();
-#if QT_VERSION >= 0x040100
// status
void status_real_read_data();
void status_real_read();
void status_integer_read();
void status_word_read();
-#endif
// use case tests
void useCase1();
@@ -1233,7 +1231,7 @@ void tst_QTextStream::stillOpenWhenAtEnd()
QSKIP("Qt/CE: Cannot test network on emulator", SkipAll);
#endif
QTcpSocket socket;
- socket.connectToHost(FTP_TEST_SERVER_NAME_1, 21);
+ socket.connectToHost(QtNetworkSettings::serverName(), 143);
#if defined(Q_OS_SYMBIAN)
QVERIFY(socket.waitForReadyRead(30000));
#else
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp
index e2624b72dd..239328e518 100644
--- a/tests/auto/qthread/tst_qthread.cpp
+++ b/tests/auto/qthread/tst_qthread.cpp
@@ -326,10 +326,6 @@ void tst_QThread::isRunning()
void tst_QThread::setPriority()
{
-#if QT_VERSION < 0x040100
- QSKIP("QThread::setPriority() was introduced in 4.1.0, you are testing " QT_VERSION_STR,
- SkipAll);
-#else
Simple_Thread thread;
// cannot change the priority, since the thread is not running
@@ -401,7 +397,6 @@ void tst_QThread::setPriority()
QTest::ignoreMessage(QtWarningMsg, "QThread::setPriority: Cannot set priority, thread is not running");
thread.setPriority(QThread::TimeCriticalPriority);
QCOMPARE(thread.priority(), QThread::InheritPriority);
-#endif
}
void tst_QThread::priority()
diff --git a/tests/auto/qtime/tst_qtime.cpp b/tests/auto/qtime/tst_qtime.cpp
index ea4700dd7e..cc91e9db4d 100644
--- a/tests/auto/qtime/tst_qtime.cpp
+++ b/tests/auto/qtime/tst_qtime.cpp
@@ -254,11 +254,7 @@ void tst_QTime::isNull()
QTime t1;
QVERIFY( t1.isNull() );
QTime t2(0,0,0);
-#if QT_VERSION >= 0x040100
QVERIFY( !t2.isNull() );
-#else
- QVERIFY( t2.isNull() );
-#endif
QTime t3(0,0,1);
QVERIFY( !t3.isNull() );
QTime t4(0,0,0,1);
@@ -270,11 +266,7 @@ void tst_QTime::isNull()
void tst_QTime::isValid()
{
QTime t1;
-#if QT_VERSION >= 0x040100
QVERIFY( !t1.isValid() );
-#else
- QVERIFY( t1.isValid() );
-#endif
QTime t2(24,0,0,0);
QVERIFY( !t2.isValid() );
QTime t3(23,60,0,0);
@@ -599,11 +591,7 @@ void tst_QTime::fromString_data()
QTest::newRow( "data0" ) << QString("00:00:00") << QTime(0,0,0,0) << QTime(0,0,0,0);
QTest::newRow( "data1" ) << QString("10:12:34") << QTime(10,12,34,0) << QTime(10,12,34,0);
QTest::newRow( "data2" ) << QString("19:03:54.998601") << QTime(19, 3, 54, 999) << QTime(19, 3, 54, 999);
-#if QT_VERSION >= 0x040200
QTest::newRow( "data3" ) << QString("19:03:54.999601") << QTime(19, 3, 54, 999) << QTime(19, 3, 54, 999);
-#else
- QTest::newRow( "data3" ) << QString("19:03:54.999601") << QTime() << QTime();
-#endif
}
void tst_QTime::fromString()
@@ -671,9 +659,7 @@ void tst_QTime::toString_format_data()
QTest::newRow( "data2" ) << QTime(10,12,34,45) << QString("hh:m:ss:z") << QString("10:12:34:45");
QTest::newRow( "data3" ) << QTime(10,12,34,45) << QString("hh:ss ap") << QString("10:34 am");
QTest::newRow( "data4" ) << QTime(22,12,34,45) << QString("hh:zzz AP") << QString("10:045 PM");
-#if (QT_VERSION-0 >= 0x030200)
QTest::newRow( "data5" ) << QTime(230,230,230,230) << QString("hh:mm:ss") << QString();
-#endif
}
void tst_QTime::toString_format()
diff --git a/tests/auto/qtimeline/tst_qtimeline.cpp b/tests/auto/qtimeline/tst_qtimeline.cpp
index e35f4066b7..957619377d 100644
--- a/tests/auto/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/qtimeline/tst_qtimeline.cpp
@@ -42,10 +42,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION < 0x040200
-QTEST_NOOP_MAIN
-#else
-
#include <qtimeline.h>
//TESTED_CLASS=
@@ -705,5 +701,3 @@ void tst_QTimeLine::resume()
QTEST_MAIN(tst_QTimeLine)
#include "tst_qtimeline.moc"
-
-#endif //QT_VERSION
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index d962301286..cde2765a3b 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -83,6 +83,7 @@ private slots:
void recurringTimer();
void deleteLaterOnQTimer(); // long name, don't want to shadow QObject::deleteLater()
void moveToThread();
+ void restartedTimerFiresTooSoon();
};
class TimerHelper : public QObject
@@ -416,5 +417,69 @@ void tst_QTimer::moveToThread()
QVERIFY((ti3.timerId() & 0xffffff) != (ti1.timerId() & 0xffffff));
}
+class RestartedTimerFiresTooSoonObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ QBasicTimer m_timer;
+
+ int m_interval;
+ QTime m_startedTime;
+ QEventLoop eventLoop;
+
+ inline RestartedTimerFiresTooSoonObject()
+ : QObject(), m_interval(0)
+ { }
+
+ void timerFired()
+ {
+ static int interval = 1000;
+
+ m_interval = interval;
+ m_startedTime.start();
+ m_timer.start(interval, this);
+
+ // alternate between single-shot and 1 sec
+ interval = interval ? 0 : 1000;
+ }
+
+ void timerEvent(QTimerEvent* ev)
+ {
+ if (ev->timerId() != m_timer.timerId())
+ return;
+
+ m_timer.stop();
+
+ QTime now = QTime::currentTime();
+ int elapsed = m_startedTime.elapsed();
+
+ if (elapsed < m_interval / 2) {
+ // severely too early!
+ m_timer.stop();
+ eventLoop.exit(-1);
+ return;
+ }
+
+ timerFired();
+
+ // don't do this forever
+ static int count = 0;
+ if (count++ > 20) {
+ m_timer.stop();
+ eventLoop.quit();
+ return;
+ }
+ }
+};
+
+void tst_QTimer::restartedTimerFiresTooSoon()
+{
+ RestartedTimerFiresTooSoonObject object;
+ object.timerFired();
+ QVERIFY(object.eventLoop.exec() == 0);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"
+\
diff --git a/tests/auto/qtransform/tst_qtransform.cpp b/tests/auto/qtransform/tst_qtransform.cpp
index 8516ddb200..74c405e1b8 100644
--- a/tests/auto/qtransform/tst_qtransform.cpp
+++ b/tests/auto/qtransform/tst_qtransform.cpp
@@ -593,6 +593,16 @@ void tst_QTransform::types()
m3.translate(5.0f, 5.0f);
QCOMPARE(m3.type(), QTransform::TxScale);
QCOMPARE(m3.inverted().type(), QTransform::TxScale);
+
+ m3.setMatrix(1.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 2.0f);
+ QCOMPARE(m3.type(), QTransform::TxProject);
+
+ m3.setMatrix(0.0f, 2.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 2.0f);
+ QCOMPARE(m3.type(), QTransform::TxProject);
}
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 0e22a895b5..3612f2e495 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -213,6 +213,8 @@ private slots:
void indexRowSizeHint();
void addRowsWhileSectionsAreHidden();
+ void filterProxyModelCrash();
+
// task-specific tests:
void task174627_moveLeftToRoot();
void task171902_expandWith1stColHidden();
@@ -478,11 +480,7 @@ void tst_QTreeView::construction()
QCOMPARE(view.iconSize(), QSize());
QCOMPARE(view.indexAt(QPoint()), QModelIndex());
QVERIFY(!view.indexWidget(QModelIndex()));
-#if QT_VERSION >= 0x040400
QVERIFY(qobject_cast<QStyledItemDelegate *>(view.itemDelegate()));
-#else
- QVERIFY(qobject_cast<QItemDelegate *>(view.itemDelegate()));
-#endif
QVERIFY(!view.itemDelegateForColumn(-1));
QVERIFY(!view.itemDelegateForColumn(0));
QVERIFY(!view.itemDelegateForColumn(1));
@@ -1011,11 +1009,7 @@ void tst_QTreeView::itemDelegate()
{
QTreeView view;
-#if QT_VERSION >= 0x040400
QVERIFY(qobject_cast<QStyledItemDelegate *>(view.itemDelegate()));
-#else
- QVERIFY(qobject_cast<QItemDelegate *>(view.itemDelegate()));
-#endif
QPointer<QAbstractItemDelegate> oldDelegate = view.itemDelegate();
otherItemDelegate = new QItemDelegate;
@@ -1690,9 +1684,16 @@ void tst_QTreeView::moveCursor()
view.setColumnHidden(0, true);
QVERIFY(view.isColumnHidden(0));
view.show();
+ qApp->setActiveWindow(&view);
- QModelIndex actual = view.moveCursor(PublicView::MoveDown, Qt::NoModifier);
+ //here the first visible index should be selected
+ //because the view got the focus
QModelIndex expected = model.index(1, 1, QModelIndex());
+ QCOMPARE(view.currentIndex(), expected);
+
+ //then pressing down should go to the next line
+ QModelIndex actual = view.moveCursor(PublicView::MoveDown, Qt::NoModifier);
+ expected = model.index(2, 1, QModelIndex());
QCOMPARE(actual, expected);
view.setRowHidden(0, QModelIndex(), false);
@@ -1872,14 +1873,8 @@ void tst_QTreeView::indexBelow()
i = view.indexBelow(i);
QVERIFY(i.isValid());
QCOMPARE(i.row(), 1);
-#if QT_VERSION >= 0x040100
i = view.indexBelow(i);
QVERIFY(!i.isValid());
-#else
- // Qt 4.0.x returns the bottom index
- i = view.indexBelow(i);
- QVERIFY(i.isValid());
-#endif
}
void tst_QTreeView::clicked()
@@ -2839,6 +2834,29 @@ void tst_QTreeView::indexRowSizeHint()
QCOMPARE(view.indexRowSizeHint(index), w->sizeHint().height());
}
+void tst_QTreeView::filterProxyModelCrash()
+{
+ QStandardItemModel model;
+ QList<QStandardItem *> items;
+ for (int i = 0; i < 100; i++)
+ items << new QStandardItem(QString::fromLatin1("item %1").arg(i));
+ model.appendColumn(items);
+
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+
+ QTreeView view;
+ view.setModel(&proxy);
+ view.show();
+ QTest::qWait(30);
+ proxy.invalidate();
+ view.verticalScrollBar()->setValue(15);
+ QTest::qWait(20);
+
+ proxy.invalidate();
+ view.repaint(); //used to crash
+}
+
class task174627_TreeView : public QTreeView
{
Q_OBJECT
@@ -3264,6 +3282,5 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
QVERIFY(o.count > 0);
}
-
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp
index b21b240910..c3595c2c46 100644
--- a/tests/auto/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp
@@ -1555,9 +1555,6 @@ void tst_QTreeWidget::keyboardNavigation()
void tst_QTreeWidget::scrollToItem()
{
-#if QT_VERSION < 0x040100
- QSKIP("This behaviour will be merged from main in 4.1.0.", SkipAll);
-#else
// Check if all parent nodes of the item found are expanded.
// Reported in task #78761
QTreeWidgetItem *bar;
@@ -1586,7 +1583,6 @@ void tst_QTreeWidget::scrollToItem()
QVERIFY(testWidget->isItemExpanded(bar));
bar = bar->parent();
QVERIFY(testWidget->isItemExpanded(bar));
-#endif
}
// From task #85413
@@ -2087,7 +2083,6 @@ void tst_QTreeWidget::itemWidget()
}
}
-#if QT_VERSION >= 0x040200
void tst_QTreeWidget::insertItemsWithSorting_data()
{
QTest::addColumn<int>("sortOrder");
@@ -2259,8 +2254,6 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting_data()
<< (QStringList() << "h" << "g" << "f" << "e");
}
-
-
// From Task 134978
void tst_QTreeWidget::insertExpandedItemsWithSorting()
{
@@ -2421,7 +2414,6 @@ void tst_QTreeWidget::changeDataWithSorting()
QCOMPARE(dataChangedSpy.count(), 1);
QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0);
}
-#endif // QT_VERSION
void tst_QTreeWidget::itemOperatorLessThan()
{
@@ -2599,7 +2591,6 @@ void tst_QTreeWidget::removeSelectedItem()
QCOMPARE(selModel->isSelected(w->model()->index(0,0)), false);
delete w;
-
}
class AnotherTreeWidget : public QTreeWidget
diff --git a/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
index ec05b49882..fa16c9d8b4 100644
--- a/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
+++ b/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
@@ -42,8 +42,6 @@
#include <QtTest/QtTest>
-#if QT_VERSION >= 0x040100
-
#include <qtreewidget.h>
#include <qtreewidgetitemiterator.h>
#include <qapplication.h>
@@ -61,7 +59,6 @@ public:
tst_QTreeWidgetItemIterator();
~tst_QTreeWidgetItemIterator();
-
public slots:
void initTestCase();
void cleanupTestCase();
@@ -136,7 +133,7 @@ void tst_QTreeWidgetItemIterator::initTestCase()
case 9: top->setFlags(Qt::ItemIsEnabled);break;
case 10: top->setFlags(Qt::ItemIsEnabled);break;
- case 11:
+ case 11:
top->setFlags(0);
break;
@@ -982,7 +979,6 @@ void tst_QTreeWidgetItemIterator::postdecrement()
}
-
void tst_QTreeWidgetItemIterator::plus_eq_data()
{
QTest::addColumn<int>("start");
@@ -1146,9 +1142,9 @@ void tst_QTreeWidgetItemIterator::updateIteratorAfterDeletedItem_and_ContinueIte
QTest::addColumn<int>("grandChildItems"); // Populate the tree data
// we have one iterator pointing to an item in the tree.
// This iterator will be updated if we delete the item it is pointing to.
- //
+ //
QTest::addColumn<int>("removeindex"); // The index of the node we want to remove
- QTest::addColumn<int>("iterator_initial_index"); // The new expected index of
+ QTest::addColumn<int>("iterator_initial_index"); // The new expected index of
QTest::addColumn<int>("iterator_advance_after_removal");
QTest::addColumn<QString>("iterator_new_value"); // The new current item value of the iterator
QTest::newRow("Remove 13, it points to 25, it-=1. We should get top0,child2,grandchild2") << 3 << 3 << 3 << 13 << 25 << -1 << QString("top0,child2,grandchild2");
@@ -1245,7 +1241,3 @@ void tst_QTreeWidgetItemIterator::initializeIterator()
QTEST_MAIN(tst_QTreeWidgetItemIterator)
#include "tst_qtreewidgetitemiterator.moc"
-
-#else
-QTEST_NOOP_MAIN
-#endif
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index 88bb345d97..a8dffe9f53 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -537,9 +537,6 @@ void tst_QUdpSocket::bindMode()
#endif
}
-#if QT_VERSION < 0x040100
- QSKIP("QUdpSocket::BindMode was added in Qt 4.1.", SkipAll);
-#else
QUdpSocket socket;
QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData());
QUdpSocket socket2;
@@ -607,7 +604,6 @@ void tst_QUdpSocket::bindMode()
QVERIFY(!socket2.bind(socket.localPort()));
QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
#endif
-#endif
}
void tst_QUdpSocket::writeDatagramToNonExistingPeer_data()
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 3b938f2b47..5a797927a8 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -1129,11 +1129,7 @@ void tst_QUrl::setUrl()
check("host",ulong.host(),"swww.gad.de");
check("path",ulong.path(),"/servlet/CookieAccepted");
-#if QT_VERSION < 300
- qt_set_locale_codec( KGlobal::charsets()->codecForName( "iso-8859-1" ) );
-#else
QTextCodec::setCodecForLocale( KGlobal::charsets()->codecForName( "iso-8859-1" ) );
-#endif
// UTF8 tests
KURL uloc("/home/dfaure/konqtests/Matériel");
check("locale8bit",uloc.url().latin1(),"file:/home/dfaure/konqtests/Mat%E9riel"); // escaping the letter would be correct too
@@ -1155,11 +1151,7 @@ void tst_QUrl::setUrl()
uloc = KURL::fromPathOrURL( "" );
check("fromPathOrURL url", uloc.isValid()?"valid":"malformed", "malformed");
-#if QT_VERSION < 300
- qt_set_locale_codec( KGlobal::charsets()->codecForName( "koi8-r" ) );
-#else
QTextCodec::setCodecForLocale( KGlobal::charsets()->codecForName( "koi8-r" ) );
-#endif
baseURL = "file:/home/coolo";
KURL russian = baseURL.directory(false, true) + QString::fromLocal8Bit( "ÆÇÎ7" );
check( "russian", russian.url(), "file:/home/%C6%C7%CE7" );
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 78d597e423..d15f9c819b 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2414,13 +2414,9 @@ void tst_QVariant::url()
void tst_QVariant::globalColor()
{
-#if QT_VERSION >= 0x040200
QVariant variant(Qt::blue);
QVERIFY(variant.type() == QVariant::Color);
QVERIFY(qVariantValue<QColor>(variant) == QColor(Qt::blue));
-#else
- QSKIP("Implemented/fixed in 4.2", SkipSingle);
-#endif
}
void tst_QVariant::variantMap()
diff --git a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp
index ab3c65effa..ce3ac1ec6e 100644
--- a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp
+++ b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp
@@ -167,9 +167,6 @@ public:
void tst_QWaitCondition::wait_QMutex()
{
-#if defined(Q_OS_WIN32) && QT_VERSION < 0x030200
- QSKIP("Known race-conditions cause sporadic failures", SkipAll);
-#else
int x;
for (int i = 0; i < iterations; ++i) {
{
@@ -246,7 +243,6 @@ void tst_QWaitCondition::wait_QMutex()
}
}
}
-#endif
}
void tst_QWaitCondition::wait_QReadWriteLock()
@@ -457,9 +453,6 @@ int wake_Thread_2::count = 0;
void tst_QWaitCondition::wakeOne()
{
-#if defined(Q_OS_WIN32) && QT_VERSION < 0x030200
- QSKIP("Known race-conditions cause sporadic failures", SkipAll);
-#else
int x;
// wake up threads, one at a time
for (int i = 0; i < iterations; ++i) {
@@ -606,9 +599,9 @@ void tst_QWaitCondition::wakeOne()
QCOMPARE(wake_Thread::count, 0);
- // QReadWriteLock
- QReadWriteLock readWriteLock;
- wake_Thread_2 rwthread[ThreadCount];
+ // QReadWriteLock
+ QReadWriteLock readWriteLock;
+ wake_Thread_2 rwthread[ThreadCount];
readWriteLock.lockForWrite();
for (x = 0; x < ThreadCount; ++x) {
@@ -652,14 +645,10 @@ void tst_QWaitCondition::wakeOne()
QCOMPARE(wake_Thread_2::count, 0);
}
-#endif
}
void tst_QWaitCondition::wakeAll()
{
-#if defined(Q_OS_WIN32) && QT_VERSION < 0x030200
- QSKIP("Known race-conditions cause sporadic failures", SkipAll);
-#else
int x;
for (int i = 0; i < iterations; ++i) {
QMutex mutex;
@@ -726,7 +715,6 @@ void tst_QWaitCondition::wakeAll()
QCOMPARE(exited, ThreadCount);
QCOMPARE(wake_Thread_2::count, 0);
}
-#endif
}
class wait_RaceConditionThread : public QThread
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 9fb5fa3952..d493219309 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -350,6 +350,7 @@ private slots:
void paintOutsidePaintEvent();
#endif
void updateOnDestroyedSignal();
+ void toplevelLineEditFocus();
private:
bool ensureScreenSize(int width, int height);
@@ -2584,9 +2585,6 @@ void tst_QWidget::setGeometry()
void tst_QWidget::windowOpacity()
{
-#if defined(Q_WS_X11) && QT_VERSION < 0x040200
- QSKIP("QWidget::windowOpacity is broken in Qt < 4.2 on X11", SkipAll);
-#else
#ifdef Q_OS_WINCE
QSKIP( "Windows CE does not support windowOpacity", SkipAll);
#endif
@@ -2596,43 +2594,27 @@ void tst_QWidget::windowOpacity()
// Initial value should be 1.0
QCOMPARE(widget.windowOpacity(), 1.0);
// children should always return 1.0
-#if QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Prior to 4.2, all children widgets returned 0.0", Continue);
-#endif
QCOMPARE(child.windowOpacity(), 1.0);
widget.setWindowOpacity(0.0);
QCOMPARE(widget.windowOpacity(), 0.0);
child.setWindowOpacity(0.0);
-#if QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Prior to 4.2, all children widgets returned 0.0", Continue);
-#endif
QCOMPARE(child.windowOpacity(), 1.0);
widget.setWindowOpacity(1.0);
QCOMPARE(widget.windowOpacity(), 1.0);
child.setWindowOpacity(1.0);
-#if QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Prior to 4.2, all children widgets returned 0.0", Continue);
-#endif
QCOMPARE(child.windowOpacity(), 1.0);
widget.setWindowOpacity(2.0);
QCOMPARE(widget.windowOpacity(), 1.0);
child.setWindowOpacity(2.0);
-#if QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Prior to 4.2, all children widgets returned 0.0", Continue);
-#endif
QCOMPARE(child.windowOpacity(), 1.0);
widget.setWindowOpacity(-1.0);
QCOMPARE(widget.windowOpacity(), 0.0);
child.setWindowOpacity(-1.0);
-#if QT_VERSION < 0x040200
- QEXPECT_FAIL("", "Prior to 4.2, all children widgets returned 0.0", Continue);
-#endif
QCOMPARE(child.windowOpacity(), 1.0);
-#endif
}
class UpdateWidget : public QWidget
@@ -5385,7 +5367,7 @@ void tst_QWidget::subtractOpaqueSiblings()
{
#ifdef QT_MAC_USE_COCOA
QSKIP("Cocoa only has rect granularity.", SkipAll);
-#elif defined(Q_WIDGET_USE_DIRTYLIST) || (QT_VERSION >= 0x040400)
+#else
QWidget w;
w.setGeometry(50, 50, 300, 300);
@@ -8797,5 +8779,20 @@ void tst_QWidget::updateOnDestroyedSignal()
QTest::qWait(200);
}
+void tst_QWidget::toplevelLineEditFocus()
+{
+ testWidget->hide();
+
+ QLineEdit w;
+ w.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&w);
+#endif
+ QTest::qWait(200);
+
+ QCOMPARE(QApplication::activeWindow(), &w);
+ QCOMPARE(QApplication::focusWidget(), &w);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/qwmatrix/tst_qwmatrix.cpp b/tests/auto/qwmatrix/tst_qwmatrix.cpp
index 47fd41f105..4a816a8731 100644
--- a/tests/auto/qwmatrix/tst_qwmatrix.cpp
+++ b/tests/auto/qwmatrix/tst_qwmatrix.cpp
@@ -299,16 +299,12 @@ void tst_QWMatrix::mapping_data()
void tst_QWMatrix::mapRect()
{
-#if QT_VERSION >= 0x030100
QFETCH( QMatrix, matrix );
QFETCH( QRect, src );
// qDebug( "got src: %d/%d (%d/%d), matrix=[ %f %f %f %f %f %f ]",
-// src.x(), src.y(), src.width(), src.height(),
-// matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), matrix.dx(), matrix.dy() );
+// src.x(), src.y(), src.width(), src.height(),
+// matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(), matrix.dx(), matrix.dy() );
QTEST( QPolygon( matrix.mapRect(src) ), "res" );
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-#endif
}
void tst_QWMatrix::operator_star_qrect()
@@ -349,7 +345,6 @@ void tst_QWMatrix::operator_star_qwmatrix()
void tst_QWMatrix::assignments()
{
-#if QT_VERSION >= 0x040000
QMatrix m;
m.scale(2, 3);
m.rotate(45);
@@ -371,24 +366,16 @@ void tst_QWMatrix::assignments()
QCOMPARE(m.m22(), c2.m22());
QCOMPARE(m.dx(), c2.dx());
QCOMPARE(m.dy(), c2.dy());
-#else
- QSKIP( "Not tested with Qt versions < 4.0", SkipAll);
-#endif
}
void tst_QWMatrix::mapToPolygon()
{
-#if QT_VERSION >= 0x030100
QFETCH( QMatrix, matrix );
QFETCH( QRect, src );
QFETCH( QPolygon, res );
QCOMPARE( matrix.mapToPolygon( src ), res );
-#else
- QSKIP( "Not tested with Qt versions < 3.1", SkipAll);
-// qDebug("passing test; transformations are broken in 3.0.x" );
-#endif
}
diff --git a/tests/auto/qwritelocker/tst_qwritelocker.cpp b/tests/auto/qwritelocker/tst_qwritelocker.cpp
index 21bfa8a7e2..258309d06b 100644
--- a/tests/auto/qwritelocker/tst_qwritelocker.cpp
+++ b/tests/auto/qwritelocker/tst_qwritelocker.cpp
@@ -189,9 +189,6 @@ void tst_QWriteLocker::unlockAndRelockTest()
void tst_QWriteLocker::lockerStateTest()
{
-#if QT_VERSION < 0x040200
- QSKIP("QWriteLocker doesn't keep state in Qt < 4.2", SkipAll);
-#else
class LockerStateThread : public tst_QWriteLockerThread
{
public:
@@ -228,7 +225,6 @@ void tst_QWriteLocker::lockerStateTest()
delete thread;
thread = 0;
-#endif
}
QTEST_MAIN(tst_QWriteLocker)
diff --git a/tests/auto/rcc/tst_rcc.cpp b/tests/auto/rcc/tst_rcc.cpp
index 3297b2b118..57649b481a 100644
--- a/tests/auto/rcc/tst_rcc.cpp
+++ b/tests/auto/rcc/tst_rcc.cpp
@@ -59,8 +59,6 @@ public:
private slots:
void rcc_data();
void rcc();
-
-private:
};
@@ -68,18 +66,9 @@ QString findExpectedFile(const QString &base)
{
QString expectedrccfile = base;
- if (QT_VERSION >= 0x040500 && QFileInfo(expectedrccfile + QLatin1String(".450")).exists())
+ // Must be updated with each minor release.
+ if (QFileInfo(expectedrccfile + QLatin1String(".450")).exists())
expectedrccfile += QLatin1String(".450");
- else if (QT_VERSION >= 0x040400 && QFileInfo(expectedrccfile + QLatin1String(".440")).exists())
- expectedrccfile += QLatin1String(".440");
- else if (QT_VERSION >= 0x040300 && QFileInfo(expectedrccfile + QLatin1String(".430")).exists())
- expectedrccfile += QLatin1String(".430");
- else if (QT_VERSION >= 0x040200 && QFileInfo(expectedrccfile + QLatin1String(".420")).exists())
- expectedrccfile += QLatin1String(".420");
- else if (QT_VERSION >= 0x040100 && QFileInfo(expectedrccfile + QLatin1String(".410")).exists())
- expectedrccfile += QLatin1String(".410");
- else if (QT_VERSION >= 0x040000 && QFileInfo(expectedrccfile + QLatin1String(".400")).exists())
- expectedrccfile += QLatin1String(".400");
return expectedrccfile;
}
diff --git a/tests/auto/selftests/alive/alive.pro b/tests/auto/selftests/alive/alive.pro
index 4a6b788dc7..08cf358036 100644
--- a/tests/auto/selftests/alive/alive.pro
+++ b/tests/auto/selftests/alive/alive.pro
@@ -5,3 +5,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = alive
diff --git a/tests/auto/selftests/assert/assert.pro b/tests/auto/selftests/assert/assert.pro
index 87513d479c..0e48375784 100644
--- a/tests/auto/selftests/assert/assert.pro
+++ b/tests/auto/selftests/assert/assert.pro
@@ -8,3 +8,4 @@ CONFIG -= debug_and_release_target
!win32:CONFIG += debug
+TARGET = assert
diff --git a/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro b/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro
index 34a43d0c0a..c9ec7e237f 100644
--- a/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro
+++ b/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = benchlibcallgrind
diff --git a/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro b/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro
index 41e090ef91..44b02953b4 100644
--- a/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro
+++ b/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = benchlibeventcounter
diff --git a/tests/auto/selftests/benchliboptions/benchliboptions.pro b/tests/auto/selftests/benchliboptions/benchliboptions.pro
index 2f02eef0c8..4dee69fa5a 100644
--- a/tests/auto/selftests/benchliboptions/benchliboptions.pro
+++ b/tests/auto/selftests/benchliboptions/benchliboptions.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = benchliboptions
diff --git a/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro b/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro
index 3d8cbfa9e2..3621449862 100644
--- a/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro
+++ b/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = benchlibtickcounter
diff --git a/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro b/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro
index 364e80b74f..f4694b59ad 100644
--- a/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro
+++ b/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = benchlibwalltime
diff --git a/tests/auto/selftests/cmptest/cmptest.pro b/tests/auto/selftests/cmptest/cmptest.pro
index c19a77a941..8b2df1c923 100644
--- a/tests/auto/selftests/cmptest/cmptest.pro
+++ b/tests/auto/selftests/cmptest/cmptest.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = cmptest
diff --git a/tests/auto/selftests/commandlinedata/commandlinedata.pro b/tests/auto/selftests/commandlinedata/commandlinedata.pro
index c900fc8ea4..96bfa5b9d3 100644
--- a/tests/auto/selftests/commandlinedata/commandlinedata.pro
+++ b/tests/auto/selftests/commandlinedata/commandlinedata.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = commandlinedata
diff --git a/tests/auto/selftests/crashes/crashes.pro b/tests/auto/selftests/crashes/crashes.pro
index 57eb4c71c6..7eec6eacb1 100644
--- a/tests/auto/selftests/crashes/crashes.pro
+++ b/tests/auto/selftests/crashes/crashes.pro
@@ -7,3 +7,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = crashes
diff --git a/tests/auto/selftests/datatable/datatable.pro b/tests/auto/selftests/datatable/datatable.pro
index 69aed7a8b0..98f04d6864 100644
--- a/tests/auto/selftests/datatable/datatable.pro
+++ b/tests/auto/selftests/datatable/datatable.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = datatable
diff --git a/tests/auto/selftests/datetime/datetime.pro b/tests/auto/selftests/datetime/datetime.pro
index 489e5cbc51..b015661371 100644
--- a/tests/auto/selftests/datetime/datetime.pro
+++ b/tests/auto/selftests/datetime/datetime.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = datetime
diff --git a/tests/auto/selftests/differentexec/differentexec.pro b/tests/auto/selftests/differentexec/differentexec.pro
index e78964927a..c11b0d3608 100644
--- a/tests/auto/selftests/differentexec/differentexec.pro
+++ b/tests/auto/selftests/differentexec/differentexec.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = differentexec
diff --git a/tests/auto/selftests/exception/exception.pro b/tests/auto/selftests/exception/exception.pro
index 14d8c7fe27..65705c685d 100644
--- a/tests/auto/selftests/exception/exception.pro
+++ b/tests/auto/selftests/exception/exception.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = exception
diff --git a/tests/auto/selftests/expectfail/expectfail.pro b/tests/auto/selftests/expectfail/expectfail.pro
index c4111992f7..97a35607ef 100644
--- a/tests/auto/selftests/expectfail/expectfail.pro
+++ b/tests/auto/selftests/expectfail/expectfail.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = expectfail
diff --git a/tests/auto/selftests/failinit/failinit.pro b/tests/auto/selftests/failinit/failinit.pro
index 729cf74fb0..e3d54c860c 100644
--- a/tests/auto/selftests/failinit/failinit.pro
+++ b/tests/auto/selftests/failinit/failinit.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = failinit
diff --git a/tests/auto/selftests/failinitdata/failinitdata.pro b/tests/auto/selftests/failinitdata/failinitdata.pro
index 6b48af115d..1ff96f74eb 100644
--- a/tests/auto/selftests/failinitdata/failinitdata.pro
+++ b/tests/auto/selftests/failinitdata/failinitdata.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = failinitdata
diff --git a/tests/auto/selftests/fetchbogus/fetchbogus.pro b/tests/auto/selftests/fetchbogus/fetchbogus.pro
index badb6369e5..3a5d13b78e 100644
--- a/tests/auto/selftests/fetchbogus/fetchbogus.pro
+++ b/tests/auto/selftests/fetchbogus/fetchbogus.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = fetchbogus
diff --git a/tests/auto/selftests/globaldata/globaldata.pro b/tests/auto/selftests/globaldata/globaldata.pro
index eb3b4548f5..1bdcf07890 100644
--- a/tests/auto/selftests/globaldata/globaldata.pro
+++ b/tests/auto/selftests/globaldata/globaldata.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = globaldata
diff --git a/tests/auto/selftests/maxwarnings/maxwarnings.pro b/tests/auto/selftests/maxwarnings/maxwarnings.pro
index b43affecb2..393a96464c 100644
--- a/tests/auto/selftests/maxwarnings/maxwarnings.pro
+++ b/tests/auto/selftests/maxwarnings/maxwarnings.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = maxwarnings
diff --git a/tests/auto/selftests/multiexec/multiexec.pro b/tests/auto/selftests/multiexec/multiexec.pro
index 723f56f250..639b9b8e5f 100644
--- a/tests/auto/selftests/multiexec/multiexec.pro
+++ b/tests/auto/selftests/multiexec/multiexec.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = multiexec
diff --git a/tests/auto/selftests/qexecstringlist/qexecstringlist.pro b/tests/auto/selftests/qexecstringlist/qexecstringlist.pro
index 27afcb2550..73bdaca06e 100644
--- a/tests/auto/selftests/qexecstringlist/qexecstringlist.pro
+++ b/tests/auto/selftests/qexecstringlist/qexecstringlist.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = qexecstringlist
diff --git a/tests/auto/selftests/singleskip/singleskip.pro b/tests/auto/selftests/singleskip/singleskip.pro
index 0d66f6813f..9762c97a09 100644
--- a/tests/auto/selftests/singleskip/singleskip.pro
+++ b/tests/auto/selftests/singleskip/singleskip.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = singleskip
diff --git a/tests/auto/selftests/skip/skip.pro b/tests/auto/selftests/skip/skip.pro
index 545a579f7f..989fdeb627 100644
--- a/tests/auto/selftests/skip/skip.pro
+++ b/tests/auto/selftests/skip/skip.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = skip
diff --git a/tests/auto/selftests/skipglobal/skipglobal.pro b/tests/auto/selftests/skipglobal/skipglobal.pro
index 97553c6551..0205a88e2f 100644
--- a/tests/auto/selftests/skipglobal/skipglobal.pro
+++ b/tests/auto/selftests/skipglobal/skipglobal.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = skipglobal
diff --git a/tests/auto/selftests/skipinit/skipinit.pro b/tests/auto/selftests/skipinit/skipinit.pro
index d8ee13ec8f..691218312b 100644
--- a/tests/auto/selftests/skipinit/skipinit.pro
+++ b/tests/auto/selftests/skipinit/skipinit.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = skipinit
diff --git a/tests/auto/selftests/skipinitdata/skipinitdata.pro b/tests/auto/selftests/skipinitdata/skipinitdata.pro
index 8da653ea3b..206ed11f73 100644
--- a/tests/auto/selftests/skipinitdata/skipinitdata.pro
+++ b/tests/auto/selftests/skipinitdata/skipinitdata.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = skipinitdata
diff --git a/tests/auto/selftests/sleep/sleep.pro b/tests/auto/selftests/sleep/sleep.pro
index 7b28ccc983..0bd322549f 100644
--- a/tests/auto/selftests/sleep/sleep.pro
+++ b/tests/auto/selftests/sleep/sleep.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = sleep
diff --git a/tests/auto/selftests/strcmp/strcmp.pro b/tests/auto/selftests/strcmp/strcmp.pro
index 489211c5b7..3121c25a1b 100644
--- a/tests/auto/selftests/strcmp/strcmp.pro
+++ b/tests/auto/selftests/strcmp/strcmp.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = strcmp
diff --git a/tests/auto/selftests/subtest/subtest.pro b/tests/auto/selftests/subtest/subtest.pro
index 4d258eeaa9..fe3cafa14a 100644
--- a/tests/auto/selftests/subtest/subtest.pro
+++ b/tests/auto/selftests/subtest/subtest.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = subtest
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index 4243612b0e..103fd79bbc 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -195,7 +195,7 @@ void tst_Selftests::runSubTest()
QProcess proc;
proc.setEnvironment(QStringList(""));
- proc.start(subdir + "/tst_" + subdir, arguments);
+ proc.start(subdir + "/" + subdir, arguments);
QVERIFY(proc.waitForFinished());
const QByteArray out(proc.readAllStandardOutput());
@@ -309,7 +309,7 @@ void tst_Selftests::checkXML() const
QProcess proc;
proc.setEnvironment(QStringList(""));
- proc.start(subdir + "/tst_" + subdir, arguments);
+ proc.start(subdir + "/" + subdir, arguments);
QVERIFY(proc.waitForFinished());
QByteArray out(proc.readAllStandardOutput());
diff --git a/tests/auto/selftests/updateBaselines.sh b/tests/auto/selftests/updateBaselines.sh
deleted file mode 100755
index a0f22e666d..0000000000
--- a/tests/auto/selftests/updateBaselines.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-# Be *really* sure that your fix is right, before running this script.
-
-tests=" \
- cmptest \
- cmptest \
- cmptest \
- datatable \
- datetime \
- expectfail \
- expectfail \
- globaldata \
- globaldata \
- maxwarnings \
- multiexec \
- singleskip \
- qexecstringlist \
- differentexec \
- skip \
- skip \
- skipglobal \
- sleep \
- strcmp \
- subtest \
- warnings"
-
-for test in $tests; do
- echo "Updating $test"
- cd $test
- baseline="../expected_"$test".txt"
- p4 edit $baseline
- ./tst_$test > ../expected_"$test".txt
- p4 revert -a $baseline
- cd ..
-done
diff --git a/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro b/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro
index 8cdf7cc144..cf3098ddcf 100644
--- a/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro
+++ b/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = waitwithoutgui
diff --git a/tests/auto/selftests/warnings/warnings.pro b/tests/auto/selftests/warnings/warnings.pro
index 9ae22d31ab..eaf06b41d8 100644
--- a/tests/auto/selftests/warnings/warnings.pro
+++ b/tests/auto/selftests/warnings/warnings.pro
@@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle
CONFIG -= debug_and_release_target
+TARGET = warnings