From 49babe02f0a00fe2baff3950fbdcb725ce20d772 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 17 May 2011 13:43:30 +1000 Subject: Remove autotest code for Qt3Support library. This commit deals with the simple cases -- mostly just removing blocks of code enclosed in #ifdef QT3_SUPPORT. Later commits will deal with the trickier cases. Change-Id: I280dea25b3754be175efe62fc7e5e4e7c304e658 Task-number: QTBUG-19325 Reviewed-by: Rohan McGovern --- tests/auto/collections/tst_collections.cpp | 58 - tests/auto/moc/no-keywords.h | 3 - tests/auto/qdir/tst_qdir.cpp | 65 - tests/auto/qfileinfo/tst_qfileinfo.cpp | 7 - tests/auto/qfocusevent/tst_qfocusevent.cpp | 33 - tests/auto/qimage/tst_qimage.cpp | 27 - tests/auto/qiodevice/tst_qiodevice.cpp | 43 - tests/auto/qlayout/tst_qlayout.cpp | 18 - tests/auto/qlineedit/tst_qlineedit.cpp | 76 - tests/auto/qmenu/tst_qmenu.cpp | 47 - tests/auto/qmessagebox/tst_qmessagebox.cpp | 36 - tests/auto/qmouseevent/tst_qmouseevent.cpp | 60 - tests/auto/qmutex/tst_qmutex.cpp | 17 - tests/auto/qobject/tst_qobject.cpp | 11 - tests/auto/qpainter/tst_qpainter.cpp | 37 - tests/auto/qpixmap/tst_qpixmap.cpp | 52 - tests/auto/qprinter/tst_qprinter.cpp | 23 - tests/auto/qsettings/tst_qsettings.cpp | 697 --------- tests/auto/qsql/tst_qsql.cpp | 44 - tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 298 ---- tests/auto/qsqlrecord/tst_qsqlrecord.cpp | 86 -- tests/auto/qstring/tst_qstring.cpp | 16 +- tests/auto/qstyle/tst_qstyle.cpp | 7 - tests/auto/qstyleoption/tst_qstyleoption.cpp | 3 - .../auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 6 - tests/auto/qtabwidget/tst_qtabwidget.cpp | 20 +- tests/auto/qtcpsocket/stressTest/Test.cpp | 94 -- tests/auto/qtcpsocket/stressTest/Test.h | 42 - tests/auto/qtcpsocket/stressTest/main.cpp | 8 +- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 10 +- tests/auto/qtextedit/tst_qtextedit.cpp | 17 - tests/auto/qtextstream/tst_qtextstream.cpp | 1540 -------------------- tests/auto/qtoolbutton/tst_qtoolbutton.cpp | 7 - tests/auto/qurl/tst_qurl.cpp | 11 - tests/auto/qvariant/tst_qvariant.cpp | 276 +--- tests/auto/qwidget/tst_qwidget.cpp | 131 +- tests/auto/qworkspace/tst_qworkspace.cpp | 58 - 37 files changed, 45 insertions(+), 3939 deletions(-) (limited to 'tests') diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index b1ea32629b..18a32fd486 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -100,10 +100,6 @@ void foo() #include "qvector.h" #include "qqueue.h" -#ifdef QT3_SUPPORT -#include "q3cleanuphandler.h" -#endif - template class QList; //TESTED_FILES= @@ -133,7 +129,6 @@ private slots: void cache(); void regexp(); void pair(); - void cleanupHandler(); void sharableQList(); void sharableQLinkedList(); void sharableQVector(); @@ -2191,14 +2186,7 @@ void tst_Collections::qstring() QVERIFY(s.toLatin1() == "first"); s = "second"; QVERIFY(s.toLatin1() == "second"); -#ifdef QT3_SUPPORT - const char* cache = s.latin1(); - QVERIFY(cache == s.latin1()); -#endif s.clear(); -#ifdef QT3_SUPPORT - QVERIFY(*s.latin1() == '\0'); -#endif QVERIFY(s.isNull()); QVERIFY(s.toLatin1().size() == 0); QVERIFY(s.toLatin1().isEmpty()); @@ -2208,14 +2196,7 @@ void tst_Collections::qstring() QVERIFY(s.toUtf8() == "first-utf8"); s = "second-utf8"; QVERIFY(s.toUtf8() == "second-utf8"); -#ifdef QT3_SUPPORT - cache = s.utf8(); - QVERIFY(cache == s.utf8()); -#endif s.clear(); -#ifdef QT3_SUPPORT - QVERIFY(*s.utf8() == '\0'); -#endif QVERIFY(s.isNull()); QVERIFY(s.toUtf8().size() == 0); QVERIFY(s.toUtf8().isEmpty()); @@ -2225,14 +2206,7 @@ void tst_Collections::qstring() QVERIFY(s.toUtf8() == "first-utf8"); s = "second-utf8"; QVERIFY(s.toUtf8() == "second-utf8"); -#ifdef QT3_SUPPORT - cache = s.utf8(); - QVERIFY(cache == s.utf8()); -#endif s.clear(); -#ifdef QT3_SUPPORT - QVERIFY(*s.utf8() == '\0'); -#endif QVERIFY(s.isNull()); QVERIFY(s.toUtf8().size() == 0); QVERIFY(s.toUtf8().isEmpty()); @@ -2242,14 +2216,7 @@ void tst_Collections::qstring() QVERIFY(s.toLocal8Bit() == "first-local8Bit"); s = "second-local8Bit"; QVERIFY(s.toLocal8Bit() == "second-local8Bit"); -#ifdef QT3_SUPPORT - cache = s.local8Bit(); - QVERIFY(cache == s.local8Bit()); -#endif s.clear(); -#ifdef QT3_SUPPORT - QVERIFY(*s.local8Bit() == '\0'); -#endif QVERIFY(s.isNull()); QVERIFY(s.toLocal8Bit().size() == 0); QVERIFY(s.toLocal8Bit().isEmpty()); @@ -2258,14 +2225,7 @@ void tst_Collections::qstring() QVERIFY(s.toAscii() == "first-ascii"); s = "second-ascii"; QVERIFY(s.toAscii() == "second-ascii"); -#ifdef QT3_SUPPORT - cache = s.ascii(); - QVERIFY(cache == s.ascii()); -#endif s.clear(); -#ifdef QT3_SUPPORT - QVERIFY(*s.ascii() == '\0'); -#endif QVERIFY(s.isNull()); QVERIFY(s.toAscii().size() == 0); QVERIFY(s.toAscii().isEmpty()); @@ -2508,24 +2468,6 @@ void tst_Collections::pair() QVERIFY(!(a > a || b > b || c > c || d > d || e > e)); } -void tst_Collections::cleanupHandler() -{ -#ifdef QT3_SUPPORT - LargeStatic * f1 = 0; - LargeStatic * f2 = 0; - { - Q3CleanupHandler cleanup; - f1 = new LargeStatic; - f2 = new LargeStatic; - cleanup.add(&f1); - cleanup.add(&f2); - } - QVERIFY(f1 == 0 && f2 == 0); -#else - QSKIP("No Qt3 support", SkipAll); -#endif -} - /* These test that Java-style mutable iterators don't trash shared copy (the setSharable() mechanism). diff --git a/tests/auto/moc/no-keywords.h b/tests/auto/moc/no-keywords.h index 1ebc4062c2..bec39a1512 100644 --- a/tests/auto/moc/no-keywords.h +++ b/tests/auto/moc/no-keywords.h @@ -52,9 +52,6 @@ #include #include //#include -#if defined(QT3_SUPPORT) -#include -#endif #if defined(WITH_DBUS) #include #endif diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 8112814e35..bc5c6872ee 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -158,9 +158,6 @@ private slots: void operator_eq(); void dotAndDotDot(); -#ifdef QT3_SUPPORT - void matchAllDirs(); -#endif void homePath(); void tempPath(); void rootPath(); @@ -193,10 +190,6 @@ private slots: void arrayOperator(); -#ifdef QT3_SUPPORT - void setNameFilter(); -#endif - void equalityOperator_data(); void equalityOperator(); @@ -553,17 +546,6 @@ void tst_QDir::entryList_data() QTest::newRow("QDir::AllDirs | QDir::NoSymLinks") << SRCDIR "entrylist/" << QStringList("*") << int(QDir::AllDirs | QDir::NoSymLinks) << int(QDir::Name) << filterLinks(QString(".,..,directory").split(',')); -#ifdef QT3_SUPPORT - QTest::newRow("QDir::All | QDir::Hidden | QDir::System") << SRCDIR "entrylist/" << QStringList("*") - << int(QDir::All | QDir::Hidden | QDir::System) << int(QDir::Name) - << filterLinks(QString(".,..,brokenlink.lnk,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::All | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*") - << int(QDir::All | QDir::Readable) << int(QDir::Name) - << filterLinks(QString(".,..,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); - QTest::newRow("QDir::All | QDir::Writable") << SRCDIR "entrylist/" << QStringList("*") - << int(QDir::All | QDir::Writable) << int(QDir::Name) - << filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(',')); -#else QTest::newRow("QDir::AllEntries | QDir::Hidden | QDir::System") << SRCDIR "entrylist/" << QStringList("*") << int(QDir::AllEntries | QDir::Hidden | QDir::System) << int(QDir::Name) << filterLinks(QString(".,..,brokenlink.lnk,directory,file,linktodirectory.lnk,linktofile.lnk,writable").split(',')); @@ -573,7 +555,6 @@ void tst_QDir::entryList_data() QTest::newRow("QDir::AllEntries | QDir::Writable") << SRCDIR "entrylist/" << QStringList("*") << int(QDir::AllEntries | QDir::Writable) << int(QDir::Name) << filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(',')); -#endif QTest::newRow("QDir::Files | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*") << int(QDir::Files | QDir::Readable) << int(QDir::Name) << filterLinks(QString("file,linktofile.lnk,writable").split(',')); @@ -1346,26 +1327,6 @@ void tst_QDir::dotAndDotDot() #endif } -#ifdef QT3_SUPPORT -/* - Tets that the setMatchAllDirs setting survies a call to setFilter. -*/ -void tst_QDir::matchAllDirs() -{ - QDir dir("/"); - dir.setMatchAllDirs(true); - dir.setNameFilters(QStringList() << "*.foo"); - dir.setFilter(QDir::Hidden); - QVERIFY(dir.matchAllDirs()); - QVERIFY(dir.entryList().count() > 0); - dir.setMatchAllDirs(false); - dir.setFilter(QDir::Hidden); - QVERIFY(dir.matchAllDirs() == false); - QCOMPARE(dir.entryList().count(), 0); - -} -#endif - void tst_QDir::homePath() { QDir homeDir = QDir::home(); @@ -1890,32 +1851,6 @@ void tst_QDir::arrayOperator() } } -#ifdef QT3_SUPPORT -void tst_QDir::setNameFilter() -{ - QStringList filters; - filters << "*.jpg" << "*.png" << "*.gif"; - QStringList filters2; - filters2 << "*.cpp" << "*.h" << "*.c"; - - QDir dir(SRCDIR "entrylist/"); - - dir.setNameFilter(filters.join(";")); - QCOMPARE(filters, dir.nameFilters()); - QCOMPARE(filters, dir.nameFilter().split(';')); - - dir.setNameFilters(filters2); - QCOMPARE(filters2, dir.nameFilter().split(';')); - - dir.setNameFilter(filters.join(" ")); - QCOMPARE(filters, dir.nameFilters()); - QCOMPARE(filters, dir.nameFilter().split(' ')); - - dir.setNameFilters(filters2); - QCOMPARE(filters2, dir.nameFilter().split(' ')); -} -#endif - void tst_QDir::equalityOperator_data() { QTest::addColumn("leftPath"); diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 7d628f50a0..1d0afccbd0 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -42,7 +42,6 @@ #include - #include #include #include @@ -726,15 +725,9 @@ void tst_QFileInfo::dir() if (absPath) { QCOMPARE(fi.absolutePath(), expected); QCOMPARE(fi.absoluteDir().path(), expected); -#ifdef QT3_SUPPORT - QCOMPARE(fi.dir(true).path(), expected); -#endif } else { QCOMPARE(fi.path(), expected); QCOMPARE(fi.dir().path(), expected); -#ifdef QT3_SUPPORT - QCOMPARE(fi.dir(false).path(), expected); -#endif } } diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp index 401f4a7075..e79153412a 100644 --- a/tests/auto/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp @@ -43,13 +43,7 @@ #include #include #include - -#if defined (QT3_SUPPORT) -#include -#else #include -#endif - #include #include #include @@ -264,32 +258,6 @@ void tst_QFocusEvent::checkReason_Popup() initWidget(); // Now test the popup reason -#if defined (QT3_SUPPORT) - Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget ); - popupMenu->insertItem( "Test" ); - popupMenu->popup( QPoint(0,0) ); - QTest::qWait(50); - - QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); - - QVERIFY( childFocusWidgetOne->hasFocus() ); - QVERIFY( !childFocusWidgetOne->focusInEventRecieved ); - QVERIFY( childFocusWidgetOne->focusOutEventRecieved ); - QVERIFY( !childFocusWidgetTwo->focusInEventRecieved ); - QVERIFY( !childFocusWidgetTwo->focusOutEventRecieved ); - QCOMPARE( childFocusWidgetOne->focusOutEventReason, int(Qt::PopupFocusReason)); - - popupMenu->hide(); - - QVERIFY(childFocusWidgetOne->focusInEventRecieved); - QVERIFY(childFocusWidgetOne->focusInEventGotFocus); - - QVERIFY( childFocusWidgetOne->hasFocus() ); - QVERIFY( childFocusWidgetOne->focusInEventRecieved ); - QVERIFY( childFocusWidgetOne->focusOutEventRecieved ); - QVERIFY( !childFocusWidgetTwo->focusInEventRecieved ); - QVERIFY( !childFocusWidgetTwo->focusOutEventRecieved ); -#else QMenu* popupMenu = new QMenu( testFocusWidget ); popupMenu->addMenu( "Test" ); popupMenu->popup( QPoint(0,0) ); @@ -314,7 +282,6 @@ void tst_QFocusEvent::checkReason_Popup() QVERIFY( childFocusWidgetOne->focusOutEventRecieved ); QVERIFY( !childFocusWidgetTwo->focusInEventRecieved ); QVERIFY( !childFocusWidgetTwo->focusOutEventRecieved ); -#endif } #ifdef Q_WS_MAC diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index ad85bf5cce..49acb98a6a 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -73,7 +73,6 @@ private slots: void create(); void createInvalidXPM(); void createFromUChar(); - void convertBitOrder(); void formatHandlersInput_data(); void formatHandlersInput(); @@ -265,32 +264,6 @@ void tst_QImage::createFromUChar() QCOMPARE(i4.pixel(0,0), 6U); } -void tst_QImage::convertBitOrder() -{ -#if !defined(QT3_SUPPORT) - QSKIP("Qt compiled without Qt3Support", SkipAll); -#else - QImage i(9,5,1,2,QImage::LittleEndian); - qMemSet(i.bits(), 0, i.byteCount()); - - i.setDotsPerMeterX(9); - i.setDotsPerMeterY(5); - i.fill(0x12345678); - QVERIFY(!i.isNull()); - - QImage ni = i.convertBitOrder(QImage::BigEndian); - QVERIFY(!ni.isNull()); - QVERIFY(ni.bitOrder() == QImage::BigEndian); - - // A bunch of verifies to make sure that nothing was lost - QVERIFY(i.dotsPerMeterX() == ni.dotsPerMeterX()); - QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY()); - QVERIFY(i.depth() == ni.depth()); - QVERIFY(i.size() == ni.size()); - QVERIFY(i.colorCount() == ni.colorCount()); -#endif -} - void tst_QImage::formatHandlersInput_data() { QTest::addColumn("testFormat"); diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 50abffe1f0..65ef9c65b3 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -73,8 +73,6 @@ private slots: void unget(); void peek(); void peekAndRead(); - void getch(); - void putch(); void readLine_data(); void readLine(); @@ -382,47 +380,6 @@ void tst_QIODevice::peekAndRead() QFile::remove("peektestfile"); } -void tst_QIODevice::getch() -{ -#ifdef QT3_SUPPORT - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - buffer.write("\xff\x7f\x80\x00", 4); - buffer.reset(); - QCOMPARE(buffer.getch(), 0xff); - QCOMPARE(buffer.getch(), 0x7f); - QCOMPARE(buffer.getch(), 0x80); - QCOMPARE(buffer.getch(), 0x00); - - buffer.ungetch(0x00); - buffer.ungetch(0x80); - buffer.ungetch(0x7f); - buffer.ungetch(0xff); - - QCOMPARE(buffer.getch(), 0xff); - QCOMPARE(buffer.getch(), 0x7f); - QCOMPARE(buffer.getch(), 0x80); - QCOMPARE(buffer.getch(), 0x00); -#endif -} - -void tst_QIODevice::putch() -{ -#ifdef QT3_SUPPORT - QBuffer buffer; - buffer.open(QBuffer::ReadWrite); - buffer.putch(0xff); - buffer.putch(0x7f); - buffer.putch(0x80); - buffer.putch(0x00); - buffer.reset(); - QCOMPARE(buffer.getch(), 0xff); - QCOMPARE(buffer.getch(), 0x7f); - QCOMPARE(buffer.getch(), 0x80); - QCOMPARE(buffer.getch(), 0x00); -#endif -} - void tst_QIODevice::readLine_data() { QTest::addColumn("data"); diff --git a/tests/auto/qlayout/tst_qlayout.cpp b/tests/auto/qlayout/tst_qlayout.cpp index 3090ebb684..2777c91e2b 100644 --- a/tests/auto/qlayout/tst_qlayout.cpp +++ b/tests/auto/qlayout/tst_qlayout.cpp @@ -76,9 +76,6 @@ private slots: void geometry(); void smartMaxSize(); void setLayoutBugs(); -#ifdef QT3_SUPPORT - void task193350_sizeGrip(); -#endif void setContentsMargins(); void layoutItemRect(); void warnIfWrongParent(); @@ -235,21 +232,6 @@ void tst_QLayout::setLayoutBugs() QVERIFY(containerWidget.layout() == hBoxLayout); } -#ifdef QT3_SUPPORT -void tst_QLayout::task193350_sizeGrip() -{ - QDialog dialog; - dialog.setSizeGripEnabled(true); - - QVBoxLayout* layout = new QVBoxLayout(&dialog); - layout->setAutoAdd(true); - new QLabel("Label", &dialog); - - dialog.show(); - QCOMPARE(layout->indexOf(qFindChild(&dialog)),-1); -} -#endif - class MyLayout : public QLayout { public: diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index d5d9029b12..a7a5bd7b4b 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -277,11 +277,6 @@ private slots: void QTBUG697_paletteCurrentColorGroup(); void QTBUG13520_textNotVisible(); -#ifdef QT3_SUPPORT - void validateAndSet_data(); - void validateAndSet(); -#endif - void bidiVisualMovement_data(); void bidiVisualMovement(); @@ -289,9 +284,6 @@ private slots: void bidiLogicalMovement(); protected slots: -#ifdef QT3_SUPPORT - void lostFocus(); -#endif void editingFinished(); void onTextChanged( const QString &newString ); @@ -360,9 +352,6 @@ void tst_QLineEdit::initTestCase() connect(testWidget, SIGNAL(returnPressed()), this, SLOT(onReturnPressed())); connect(testWidget, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(testWidget, SIGNAL(editingFinished()), this, SLOT(editingFinished())); -#ifdef QT3_SUPPORT - connect(testWidget, SIGNAL(lostFocus()), this, SLOT(lostFocus())); -#endif testWidget->resize(200,50); testWidget->show(); @@ -1498,40 +1487,6 @@ void tst_QLineEdit::clear() QCOMPARE(testWidget->text(), QString("I am Legend")); } -#ifdef QT3_SUPPORT -void tst_QLineEdit::lostFocus() -{ - editingFinished(); -} - -void tst_QLineEdit::validateAndSet_data() -{ - QTest::addColumn("newText"); - QTest::addColumn("newPos"); - QTest::addColumn("newMarkAnchor"); - QTest::addColumn("newMarkDrag"); - - QTest::newRow("1") << QString("Hello World") << 3 << 3 << 5; - QTest::newRow("2") << QString("Hello World") << 5 << 3 << 5; -} - -void tst_QLineEdit::validateAndSet() -{ - QFETCH(QString, newText); - QFETCH(int, newPos); - QFETCH(int, newMarkAnchor); - QFETCH(int, newMarkDrag); - - QLineEdit e; - e.validateAndSet(newText, newPos, newMarkAnchor, newMarkDrag); - QCOMPARE(e.text(), newText); - QCOMPARE(e.cursorPosition(), newPos); - QCOMPARE(e.selectedText(), newText.mid(newMarkAnchor, newMarkDrag-newMarkAnchor)); -} - - - -#endif void tst_QLineEdit::editingFinished() { if (testWidget->hasAcceptableInput()) @@ -2660,16 +2615,6 @@ void tst_QLineEdit::setAlignment() #endif QVERIFY(testWidget->alignment() == Qt::AlignLeft); -#ifdef QT3_SUPPORT - testWidget->setText("auto"); - testWidget->setAlignment(Qt::AlignAuto); -#ifndef NO_PIXMAP_TESTS -#if defined Q_WS_WIN - QTEST(testWidget, "auto"); -#endif -#endif -#endif - testWidget->setText("hcenter"); testWidget->setAlignment(Qt::AlignHCenter); #ifndef NO_PIXMAP_TESTS @@ -2679,16 +2624,6 @@ void tst_QLineEdit::setAlignment() #endif QVERIFY(testWidget->alignment() == Qt::AlignHCenter); -#ifdef QT3_SUPPORT - testWidget->setText("auto"); - testWidget->setAlignment(Qt::AlignAuto); -#ifndef NO_PIXMAP_TESTS -#if defined Q_WS_WIN - QTEST(testWidget, "auto"); -#endif -#endif -#endif - testWidget->setText("right"); testWidget->setAlignment(Qt::AlignRight); #ifndef NO_PIXMAP_TESTS @@ -2698,17 +2633,6 @@ void tst_QLineEdit::setAlignment() #endif QVERIFY(testWidget->alignment() == Qt::AlignRight); -#ifdef QT3_SUPPORT - testWidget->setText("auto"); - testWidget->setAlignment(Qt::AlignAuto); -#ifndef NO_PIXMAP_TESTS -#if defined Q_WS_WIN - QTEST(testWidget, "auto"); -#endif -#endif - QVERIFY(testWidget->alignment() == Qt::AlignAuto); -#endif - testWidget->setAlignment(Qt::AlignTop); QVERIFY(testWidget->alignment() == Qt::AlignTop); diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index c31361d60a..4845077cde 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -90,10 +90,6 @@ private slots: void tearOff(); void layoutDirection(); -#if defined(QT3_SUPPORT) - void indexBasedInsertion_data(); - void indexBasedInsertion(); -#endif void task208001_stylesheet(); void activeSubMenuPosition(); void task242454_sizeHint(); @@ -641,49 +637,6 @@ void tst_QMenu::layoutDirection() QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); } - - -#if defined(QT3_SUPPORT) -void tst_QMenu::indexBasedInsertion_data() -{ - QTest::addColumn("indexForInsertion"); - QTest::addColumn("expectedIndex"); - - QTest::newRow("negative-index-appends") << -1 << 1; - QTest::newRow("prepend") << 0 << 0; - QTest::newRow("append") << 1 << 1; -} - -void tst_QMenu::indexBasedInsertion() -{ - // test the compat'ed index based insertion - - QFETCH(int, indexForInsertion); - QFETCH(int, expectedIndex); - - { - QMenu menu; - menu.addAction("Regular Item"); - - menu.insertItem("New Item", -1 /*id*/, indexForInsertion); - - QAction *act = menu.actions().value(expectedIndex); - QVERIFY(act); - QCOMPARE(act->text(), QString("New Item")); - } - { - QMenu menu; - menu.addAction("Regular Item"); - - menu.insertSeparator(indexForInsertion); - - QAction *act = menu.actions().value(expectedIndex); - QVERIFY(act); - QVERIFY(act->isSeparator()); - } -} -#endif - void tst_QMenu::task208001_stylesheet() { //test if it crash diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp index ed121cebff..23897838ab 100644 --- a/tests/auto/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp @@ -657,42 +657,6 @@ void tst_QMessageBox::testSymbols() QSize sizeHint = mb1.sizeHint(); QVERIFY(sizeHint.width() > 20 && sizeHint.height() > 20); -#ifdef QT3_SUPPORT - //test QT3_SUPPORT stuff - - QMessageBox mb4("title", "text", icon, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default, - QMessageBox::Cancel, &mb1, "name", true, Qt::Dialog); - QMessageBox mb5(&mb1, "name"); - - QPixmap pm = QMessageBox::standardIcon(QMessageBox::Question, Qt::GUIStyle(1)); - QPixmap pm2 = QMessageBox::standardIcon(QMessageBox::Question); - - QVERIFY(pm.toImage() == iconPixmap.toImage()); - QVERIFY(pm2.toImage() == iconPixmap.toImage()); - - int ret1 = QMessageBox::message("title", "text"); - int ret2 = QMessageBox::message("title", "text", "OK"); - int ret3 = QMessageBox::message("title", "text", "OK", &mb1); - int ret4 = QMessageBox::message("title", "text", "OK", &mb1, "name"); - qDebug("%d %d %d %d", ret1, ret2, ret3, ret4); - - bool ret5 = QMessageBox::query("title", "text"); - bool ret6 = QMessageBox::query("title", "text", "Ja"); - bool ret7 = QMessageBox::query("title", "text", "Ja", "Nein"); - bool ret8 = QMessageBox::query("title", "text", "Ja", "Nein", &mb1); - bool ret9 = QMessageBox::query("title", "text", "Ja", "Nein", &mb1, "name"); - qDebug("%d %d %d %d %d", ret5, ret6, ret7, ret8, ret9); - - Q_UNUSED(ret1); - Q_UNUSED(ret5); - - QPixmap pm3 = QMessageBox::standardIcon(QMessageBox::NoIcon); - QVERIFY(pm3.isNull()); - - pm3 = QMessageBox::standardIcon(QMessageBox::Information); - QVERIFY(!pm3.isNull()); -#endif //QT3_SUPPORT - QMessageBox::about(&mb1, "title", "text"); QMessageBox::aboutQt(&mb1); QMessageBox::aboutQt(&mb1, "title"); diff --git a/tests/auto/qmouseevent/tst_qmouseevent.cpp b/tests/auto/qmouseevent/tst_qmouseevent.cpp index 9d61e7d396..d86c5cc8b2 100644 --- a/tests/auto/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/qmouseevent/tst_qmouseevent.cpp @@ -62,17 +62,9 @@ public: } bool mousePressEventRecieved; bool mouseReleaseEventRecieved; -#ifdef QT3_SUPPORT - int mousePressStateBefore; - int mousePressStateAfter; -#endif int mousePressButton; int mousePressButtons; int mousePressModifiers; -#ifdef QT3_SUPPORT - int mouseReleaseStateBefore; - int mouseReleaseStateAfter; -#endif int mouseReleaseButton; int mouseReleaseButtons; int mouseReleaseModifiers; @@ -80,10 +72,6 @@ protected: void mousePressEvent(QMouseEvent *e) { QWidget::mousePressEvent(e); -#ifdef QT3_SUPPORT - mousePressStateBefore = e->state(); - mousePressStateAfter = e->stateAfter(); -#endif mousePressButton = e->button(); mousePressButtons = e->buttons(); mousePressModifiers = e->modifiers(); @@ -93,10 +81,6 @@ protected: void mouseReleaseEvent(QMouseEvent *e) { QWidget::mouseReleaseEvent(e); -#ifdef QT3_SUPPORT - mouseReleaseStateBefore = e->state(); - mouseReleaseStateAfter = e->stateAfter(); -#endif mouseReleaseButton = e->button(); mouseReleaseButtons = e->buttons(); mouseReleaseModifiers = e->modifiers(); @@ -125,8 +109,6 @@ private slots: void checkMouseReleaseEvent_data(); void checkMouseReleaseEvent(); - void qt3supportConstructors(); - private: MouseEventWidget* testMouseWidget; }; @@ -157,12 +139,6 @@ void tst_QMouseEvent::init() { testMouseWidget->mousePressEventRecieved = FALSE; testMouseWidget->mouseReleaseEventRecieved = FALSE; -#ifdef QT3_SUPPORT - testMouseWidget->mousePressStateBefore = 0; - testMouseWidget->mousePressStateAfter = 0; - testMouseWidget->mouseReleaseStateBefore = 0; - testMouseWidget->mouseReleaseStateAfter = 0; -#endif testMouseWidget->mousePressButton = 0; testMouseWidget->mousePressButtons = 0; testMouseWidget->mousePressModifiers = 0; @@ -210,13 +186,6 @@ void tst_QMouseEvent::checkMousePressEvent() QCOMPARE(testMouseWidget->mousePressButton, button); QCOMPARE(testMouseWidget->mousePressButtons, buttons); QCOMPARE(testMouseWidget->mousePressModifiers, modifiers); -#ifdef QT3_SUPPORT - int stateAfter = buttons|modifiers; - int stateBefore = stateAfter & ~button; - - QCOMPARE(testMouseWidget->mousePressStateBefore, stateBefore); - QCOMPARE(testMouseWidget->mousePressStateAfter, stateAfter); -#endif QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonPressed), Qt::KeyboardModifiers(keyPressed)); } @@ -256,35 +225,6 @@ void tst_QMouseEvent::checkMouseReleaseEvent() QCOMPARE(testMouseWidget->mouseReleaseButton, button); QCOMPARE(testMouseWidget->mouseReleaseButtons, buttons); QCOMPARE(testMouseWidget->mouseReleaseModifiers, modifiers); -#ifdef QT3_SUPPORT - int stateAfter = buttons|modifiers; - int stateBefore = stateAfter|button; - - QCOMPARE(testMouseWidget->mouseReleaseStateBefore, stateBefore); - QCOMPARE(testMouseWidget->mouseReleaseStateAfter, stateAfter); -#endif -} - -void tst_QMouseEvent::qt3supportConstructors() -{ -#if !defined(QT3_SUPPORT) - QSKIP( "No Qt3Support present", SkipAll); -#else - // make sure the state() and stateAfter() functions return the - // same thing they did in Qt 3 when using these constructors - - { - QMouseEvent e(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, 0); - QCOMPARE(e.state(), Qt::ButtonState(Qt::NoButton)); - QCOMPARE(e.stateAfter(), Qt::ButtonState(Qt::LeftButton)); - } - - { - QMouseEvent e(QEvent::MouseButtonPress, QPoint(0, 0), QPoint(0, 0), Qt::LeftButton, 0); - QCOMPARE(e.state(), Qt::ButtonState(Qt::NoButton)); - QCOMPARE(e.stateAfter(), Qt::ButtonState(Qt::LeftButton)); - } -#endif } QTEST_MAIN(tst_QMouseEvent) diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp index c3b3575bf8..0f2d982843 100644 --- a/tests/auto/qmutex/tst_qmutex.cpp +++ b/tests/auto/qmutex/tst_qmutex.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include #include @@ -49,8 +48,6 @@ #include #include - - //TESTED_CLASS= //TESTED_FILES= @@ -372,14 +369,6 @@ public: } }; -#ifdef QT3_SUPPORT -#define VERIFY_LOCKED(x) QVERIFY((x).locked()) -#define VERIFY_NLOCKED(x) QVERIFY(!(x).locked()) -#else -#define VERIFY_LOCKED(x) -#define VERIFY_NLOCKED(x) -#endif // QT3_SUPPORT - void tst_QMutex::lock_unlock_locked_tryLock() { // normal mutex @@ -391,7 +380,6 @@ void tst_QMutex::lock_unlock_locked_tryLock() for (int i = 0; i < iterations; ++i) { // normal mutex - VERIFY_NLOCKED(mutex); QVERIFY(mutex.tryLock()); mutex.unlock(); @@ -400,7 +388,6 @@ void tst_QMutex::lock_unlock_locked_tryLock() for (int j = 0; j < iterations; ++j) { QVERIFY(thread.cond.wait(&thread.mutex, 10000)); - VERIFY_LOCKED(mutex); QVERIFY(!mutex.tryLock()); thread.cond.wakeOne(); @@ -409,13 +396,11 @@ void tst_QMutex::lock_unlock_locked_tryLock() thread.mutex.unlock(); QVERIFY(thread.wait(10000)); - VERIFY_NLOCKED(mutex); QVERIFY(mutex.tryLock()); mutex.unlock(); // recursive mutex - VERIFY_NLOCKED(rmutex); QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock()); @@ -431,7 +416,6 @@ void tst_QMutex::lock_unlock_locked_tryLock() for (int k = 0; k < iterations; ++k) { QVERIFY(rthread.cond.wait(&rthread.mutex, 10000)); - VERIFY_LOCKED(rmutex); QVERIFY(!rmutex.tryLock()); rthread.cond.wakeOne(); @@ -440,7 +424,6 @@ void tst_QMutex::lock_unlock_locked_tryLock() rthread.mutex.unlock(); QVERIFY(rthread.wait(10000)); - VERIFY_NLOCKED(rmutex); QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock()); diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index a7e8d79345..5e0b970f9b 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -40,10 +40,8 @@ ****************************************************************************/ -#define QT3_SUPPORT #include - #include #include @@ -2834,11 +2832,6 @@ void tst_QObject::compatibilityChildInsertedEvents() expected = EventSpy::EventList() -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&object, QEvent::ChildInsertedRequest) - << qMakePair(&object, QEvent::ChildInserted) - << qMakePair(&object, QEvent::ChildInserted) -#endif << qMakePair(&object, QEvent::Type(QEvent::User + 1)) << qMakePair(&object, QEvent::Type(QEvent::User + 2)); QCOMPARE(spy.eventList(), expected); @@ -2872,10 +2865,6 @@ void tst_QObject::compatibilityChildInsertedEvents() expected = EventSpy::EventList() -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&object, QEvent::ChildInsertedRequest) - << qMakePair(&object, QEvent::ChildInserted) -#endif << qMakePair(&object, QEvent::Type(QEvent::User + 1)) << qMakePair(&object, QEvent::Type(QEvent::User + 2)); QCOMPARE(spy.eventList(), expected); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 984443490f..25e58b41de 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -54,9 +54,6 @@ #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) #include #include -#ifdef QT3_SUPPORT -#include -#endif #endif #include #include @@ -1271,24 +1268,6 @@ void tst_QPainter::drawRect() QCOMPARE(painted.width(), rect.width() + increment); QCOMPARE(painted.height(), rect.height() + increment); } - -#ifdef QT3_SUPPORT - { - if (usePen && (rect.width() < 2 || rect.height() < 2)) - return; - pixmap.fill(Qt::white); - Q3Painter p(&pixmap); - p.setPen(usePen ? QPen(Qt::black) : QPen(Qt::NoPen)); - p.setBrush(Qt::black); - p.drawRect(rect); - p.end(); - - const QRect painted = getPaintedSize(pixmap, Qt::white); - - QCOMPARE(painted.width(), rect.width()); - QCOMPARE(painted.height(), rect.height()); - } -#endif } void tst_QPainter::drawRect2() @@ -1696,22 +1675,6 @@ void tst_QPainter::drawRoundRect() QCOMPARE(painted.width(), rect.width() + increment); QCOMPARE(painted.height(), rect.height() + increment); } - -#ifdef QT3_SUPPORT - { - pixmap.fill(Qt::white); - Q3Painter p(&pixmap); - p.setPen(usePen ? QPen(Qt::black) : QPen(Qt::NoPen)); - p.setBrush(Qt::black); - p.drawRoundRect(rect); - p.end(); - - const QRect painted = getPaintedSize(pixmap, Qt::white); - - QCOMPARE(painted.width(), rect.width()); - QCOMPARE(painted.height(), rect.height()); - } -#endif } Q_DECLARE_METATYPE(QImage::Format) diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 2cd9b133ac..216ca9b7c8 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -164,11 +164,6 @@ private slots: void copy(); void depthOfNullObjects(); -#ifdef QT3_SUPPORT - void resize(); - void resizePreserveMask(); -#endif - void transformed(); void transformed2(); @@ -1427,53 +1422,6 @@ void tst_QPixmap::copy() QVERIFY(pixmapsAreEqual(&trans, &transCopy)); } -#ifdef QT3_SUPPORT -void tst_QPixmap::resize() -{ - QPixmap p1(10, 10); - p1.fill(Qt::red); - - QPixmap p2 = p1; - QPixmap p3(50, 50); - p3.fill(Qt::red); - - p1.resize(p3.size()); - p1.resize(p2.size()); - p3.resize(p2.size()); - QCOMPARE(p1.toImage(), p2.toImage()); - QCOMPARE(p1.toImage(), p3.toImage()); - - QBitmap b1; - b1.resize(10, 10); - QVERIFY(b1.depth() == 1); - QPixmap p4; - p4.resize(10, 10); - QVERIFY(p4.depth() != 0); -} - -void tst_QPixmap::resizePreserveMask() -{ - QPixmap pm(100, 100); - pm.fill(Qt::transparent); - QPainter p(&pm); - p.fillRect(10, 10, 80, 80, Qt::red); - p.drawRect(0, 0, 99, 99); - p.end(); - - QBitmap mask = pm.mask(); - pm.resize(50, 50); - - QCOMPARE(pm.mask().toImage(), mask.toImage().copy(0, 0, 50, 50)); - - pm = QPixmap(100, 100); - pm.fill(Qt::red); - pm.setMask(mask); - pm.resize(50, 50); - - QCOMPARE(pm.mask().toImage(), mask.toImage().copy(0, 0, 50, 50)); -} -#endif - void tst_QPixmap::depthOfNullObjects() { QBitmap b1; diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp index 96765a478e..6da7597938 100644 --- a/tests/auto/qprinter/tst_qprinter.cpp +++ b/tests/auto/qprinter/tst_qprinter.cpp @@ -39,19 +39,13 @@ ** ****************************************************************************/ - #include - - #include #include #include #include #include -#ifdef QT3_SUPPORT -#include -#endif #include #include #include @@ -421,23 +415,6 @@ void tst_QPrinter::testMargins() if (withPainter) painter = new QPainter(&printer); -#ifdef QT3_SUPPORT - Q3PaintDeviceMetrics metrics(&printer); - int pwidth = metrics.width(); - int pheight = metrics.height(); - - if (orientation == QPrinter::Portrait) { - QVERIFY(pheight >= pwidth); - } else { - QVERIFY(pwidth >= pheight); - } - - if (fullpage) { - QCOMPARE(metrics.widthMM(), width); - QCOMPARE(metrics.heightMM(), height); - } -#endif - if (painter) delete painter; } diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index 8974b2576b..bd16aad8f8 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -101,7 +101,6 @@ private slots: void testArrays_data(); void testArrays(); void testEscapes(); - void testCompatFunctions(); void testCaseSensitivity_data(); void testCaseSensitivity(); void testErrorHandling_data(); @@ -136,52 +135,11 @@ private slots: void qtbug_13249(); #endif - /* - These tests were developed for the Qt 3 QSettings class. - */ -#ifdef QT3_SUPPORT - void oldWriteEntryIni_data(); - void oldWriteEntryIni(); - void oldReadEntryIni_data(); - void oldReadEntryIni(); - void oldBeginGroup_data(); - void oldBeginGroup(); - void oldEndGroup_data(); - void oldEndGroup(); - void oldResetGroup_data(); - void oldResetGroup(); - void oldEntryList_data(); - void oldEntryList(); - void oldWriteEntry_QString_bool_data(); - void oldWriteEntry_QString_bool(); - void oldWriteEntry_QString_double_data(); - void oldWriteEntry_QString_double(); - void oldWriteEntry_QString_int_data(); - void oldWriteEntry_QString_int(); - void oldWriteEntry_QString_QString_data(); - void oldWriteEntry_QString_QString(); - void oldWriteEntry_QString_QStringList_data(); - void oldWriteEntry_QString_QStringList(); - void oldWriteEntry_QString_QStringList_QChar_data(); - void oldWriteEntry_QString_QStringList_QChar(); - void oldReadListEntry_QString(); - void oldReadListEntry_QString_QChar(); - void oldReadEntry(); - void oldReadNumEntry(); - void oldReadDoubleEntry(); - void oldReadBoolEntry(); - void oldGlobalVersusLocal(); - void oldRemoveEntry(); -#endif - void testVariantTypes_data(); void testVariantTypes(); void rainersSyncBugOnMac_data(); void rainersSyncBugOnMac(); void recursionBug(); -#ifdef QT3_SUPPORT - void setPathBug(); -#endif void testByteArray_data(); void testByteArray(); @@ -2529,104 +2487,6 @@ void tst_QSettings::testEscapes() #endif } -void tst_QSettings::testCompatFunctions() -{ -#ifdef QT3_SUPPORT - QSettings settings1("software.org", "KillerAPP"); - - bool ok; - ok = settings1.writeEntry("/root/bool", true); - QVERIFY(ok); - ok = settings1.writeEntry("/root/double", 1.4); - QVERIFY(ok); - ok = settings1.writeEntry("/root/int", 66666); - QVERIFY(ok); - ok = settings1.writeEntry("/root/const char */1", "Hello"); - QVERIFY(ok); - ok = settings1.writeEntry("/root/const char */2", ""); - QVERIFY(ok); - ok = settings1.writeEntry("/root/const char */3", (const char *)0); - QVERIFY(ok); - ok = settings1.writeEntry("/root/QString/1", QString("Hello")); - QVERIFY(ok); - ok = settings1.writeEntry("/root/QString/2", QString("")); - QVERIFY(ok); - ok = settings1.writeEntry("/root/QString/3", QString()); - QVERIFY(ok); - ok = settings1.writeEntry("/root/QStringList/1", QStringList()); - QVERIFY(ok); - ok = settings1.writeEntry("/root/QStringList/2", QStringList() << ""); - QVERIFY(ok); - ok = settings1.writeEntry("/root/QStringList/3", QStringList() << "a" << "" << "b"); - QVERIFY(ok); - ok = settings1.writeEntry("/root/QStringList/4", QStringList() << "a" << "" << "b", ':'); - QVERIFY(ok); - - QCOMPARE(settings1.readBoolEntry("/root/bool"), true); - QCOMPARE(settings1.readDoubleEntry("/root/double"), 1.4); - QCOMPARE(settings1.readNumEntry("/root/int"), 66666); - QCOMPARE(settings1.readEntry("/root/const char */1"), QString("Hello")); - QCOMPARE(settings1.readEntry("/root/const char */2"), QString("")); - QCOMPARE(settings1.readEntry("/root/const char */3"), QString()); - QCOMPARE(settings1.readEntry("/root/QString/1"), QString("Hello")); - QCOMPARE(settings1.readEntry("/root/QString/2"), QString("")); - QCOMPARE(settings1.readEntry("/root/QString/3"), QString()); - QCOMPARE(settings1.readListEntry("/root/QStringList/1"), QStringList()); - QCOMPARE(settings1.readListEntry("/root/QStringList/2"), QStringList() << ""); - QCOMPARE(settings1.readListEntry("/root/QStringList/3"), QStringList() << "a" << "" << "b"); - QCOMPARE(settings1.readListEntry("/root/QStringList/4", ':'), QStringList() << "a" << "" << "b"); - QCOMPARE(settings1.readEntry("/root/QStringList/4"), QString("a::b")); - - QStringList actual, expectedSubKey, expectedEntry; - - settings1.clear(); - QStringList initialKeys = settings1.allKeys(); - settings1.setValue("/alpha/beta", 5); - settings1.setValue("/alpha/beta/gamma", 5); - settings1.setValue("/alpha/beta/delta", 5); - settings1.setValue("/alpha/epsilon/zeta/eta", 5); - settings1.setValue("/alpha/theta", 5); - - settings1.beginGroup("/alpha"); - QCOMPARE(settings1.group(), QString("alpha")); - - actual = settings1.entryList(""); - actual.sort(); - expectedEntry = QStringList() << "beta" << "theta"; - QCOMPARE(actual, expectedEntry); - - actual = settings1.subkeyList(""); - actual.sort(); - expectedSubKey = QStringList() << "beta" << "epsilon"; - QCOMPARE(actual, expectedSubKey); - - settings1.endGroup(); - - actual = settings1.entryList("alpha"); - actual.sort(); - QCOMPARE(actual, expectedEntry); - - actual = settings1.subkeyList("alpha"); - actual.sort(); - QCOMPARE(actual, expectedSubKey); - - actual = settings1.entryList(""); - QVERIFY(containsSubList(initialKeys, actual)); - - actual = settings1.subkeyList(""); - QVERIFY(actual.contains("alpha")); - - actual = settings1.subkeyList("foo/bar/baz"); - QVERIFY(actual.isEmpty()); - - actual = settings1.subkeyList("alpha/epsilon"); - expectedSubKey = QStringList() << "zeta"; - QCOMPARE(actual, expectedSubKey); -#else - QSKIP("Compiled without Qt3Support", SkipAll); -#endif -} - void tst_QSettings::testCaseSensitivity_data() { populateWithFormats(); @@ -2711,550 +2571,6 @@ void tst_QSettings::testCaseSensitivity() } } -#ifdef QT3_SUPPORT -void tst_QSettings::oldEntryList_data() -{ - oldWriteEntry_data(); -} - -void tst_QSettings::oldReadEntryIni_data() -{ - oldWriteEntry_data(); -} - -void tst_QSettings::oldWriteEntryIni_data() -{ - oldWriteEntry_data(); -} - -void tst_QSettings::oldReadEntry_data() -{ - oldWriteEntry_data(); -} - -void tst_QSettings::oldWriteEntry_data() -{ - // define the test elements we're going to use - QTest::addColumn("string"); - QTest::addColumn("empty"); - QTest::addColumn("unicode"); - QTest::addColumn("integer"); - QTest::addColumn("boolean"); - QTest::addColumn("floating"); - QTest::addColumn("list"); - - QStringList list0; - list0 << "elem1"; - list0 << "elem2"; - list0 << "elem3"; - list0 << "elem4"; - - QTest::newRow( "data0") << QString("blah") << QString("") << QString( QChar(0x0E12) ) << 99 << TRUE << 3.1415 << list0; - - QStringList list1; - list1 << " elem1"; - list1 << "elem2 "; - list1 << QString(); - list1 << ""; - list1 << "elem3"; - QTest::newRow( "data1") << QString("foo") << QString("") << QString( QChar(0xFEFC) ) << -150 << FALSE << 0.0 << list1; -} - -void tst_QSettings::oldWriteEntryHelper( QSettings &settings ) -{ - QFETCH( QString, string ); - QFETCH( QString, empty ); - QFETCH( QString, unicode ); - QFETCH( int, integer ); - QFETCH( bool, boolean ); - QFETCH( double, floating ); - QFETCH( QStringList, list ); - - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting", string ) ); - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/String", string ) ); - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Empty", empty ) ); - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Unicode", unicode ) ); - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Integer", integer ) ); - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Boolean", boolean ) ); - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/Floating", floating ) ); - QVERIFY( settings.writeEntry( "/Trolltech/QSettingsTesting/List", list ) ); -} - -void tst_QSettings::oldReadEntryHelper( QSettings &settings ) -{ - bool ok; - - QFETCH( QString, string ); - QFETCH( QString, empty ); - QFETCH( QString, unicode ); - QFETCH( int, integer ); - QFETCH( bool, boolean ); - QFETCH( double, floating ); - QFETCH( QStringList, list ); - - QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting", QString::null, &ok ), string ); - QVERIFY( ok ); - QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting/String", QString::null, &ok ), string ); - QVERIFY( ok ); - QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting/Empty", QString::null, &ok ), empty ); - QVERIFY( ok ); - QCOMPARE( settings.readEntry( "/Trolltech/QSettingsTesting/Unicode", QString::null, &ok ), unicode ); - QVERIFY( ok ); - QCOMPARE( settings.readNumEntry( "/Trolltech/QSettingsTesting/Integer", 0, &ok ), integer ); - QVERIFY( ok ); - QCOMPARE( settings.readBoolEntry( "/Trolltech/QSettingsTesting/Boolean", 0, &ok ), boolean ); - QVERIFY( ok ); - QCOMPARE( settings.readDoubleEntry( "/Trolltech/QSettingsTesting/Floating", 0, &ok ), floating ); - QVERIFY( ok ); - QCOMPARE( settings.readListEntry( "/Trolltech/QSettingsTesting/List", &ok ), list ); - QVERIFY( ok ); - - settings.readListEntry( "/Trolltech/QSettingsTesting/NonExistingValue", &ok ); - QVERIFY( !ok ); -} - -void tst_QSettings::oldWriteEntryIni() -{ - QSettings settings(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP"); - oldWriteEntryHelper(settings); -} - -void tst_QSettings::oldReadEntryIni() -{ - { - QSettings writeSettings(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP"); - oldWriteEntryHelper( writeSettings ); - } - { - QSettings readSettings(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP"); - oldReadEntryHelper( readSettings ); - } -} - - -void tst_QSettings::oldEndGroup_data() -{ - oldBeginGroup_data(); -} - -void tst_QSettings::oldResetGroup_data() -{ - oldBeginGroup_data(); -} - -void tst_QSettings::oldBeginGroup_data() -{ - // define the test elements we're going to use - QTest::addColumn("group"); - QTest::addColumn("value"); - - QTest::newRow( "data0") << QString("blah") << "value"; - QTest::newRow( "data1") << QString("") << "first/value"; - QTest::newRow( "data2") << QString("first/second") << "value"; - QTest::newRow( "data3") << QString("first/second/third") << "value"; - QTest::newRow( "data4") << QString("first/second/third") << "value"; -} - -void tst_QSettings::oldBeginGroup() -{ - bool ok; - - QFETCH( QString, group ); - QFETCH( QString, value ); - - QSettings settings("software.org", "KillerAPP"); - - QCOMPARE(settings.group(), QString()); - settings.beginGroup( group ); - QCOMPARE(settings.group(), group); - - QVERIFY( settings.writeEntry( "/" + value, value ) ); - QCOMPARE( settings.readEntry( "/" + value ), value ); - settings.endGroup(); - QCOMPARE( settings.readEntry( group + "/" + value, QString::null, &ok ), value ); - QVERIFY( ok ); -} - -void tst_QSettings::oldEndGroup() -{ - QFETCH( QString, group ); - - QSettings settings("software.org", "KillerAPP"); - QCOMPARE( settings.group(), QString() ); - - settings.beginGroup( group ); - settings.endGroup(); - QCOMPARE( settings.group(), QString() ); - - settings.beginGroup( group ); - settings.beginGroup( group ); - settings.endGroup(); - QCOMPARE( settings.group(), group ); - settings.endGroup(); - QCOMPARE( settings.group(), QString() ); - - QTest::ignoreMessage(QtWarningMsg, "QSettings::endGroup: No matching beginGroup()"); - settings.endGroup(); - QCOMPARE( settings.group(), QString() ); -} - -void tst_QSettings::oldResetGroup() -{ - QFETCH( QString, group ); - - QSettings settings("software.org", "KillerAPP"); - settings.beginGroup( group ); - - settings.resetGroup(); - QCOMPARE( settings.group(), QString() ); -} - -void tst_QSettings::oldEntryList() -{ - { - QSettings writeSettings("software.org", "KillerAPP"); - oldWriteEntryHelper( writeSettings ); - } - - QStringList entryKeys; - entryKeys << "String" << "Empty" << "Unicode" << "Integer" << "Boolean" << "Floating" << "List"; - - QSettings readSettings("software.org", "KillerAPP"); - QStringList entryList = readSettings.entryList( "/Trolltech/QSettingsTesting/" ); - entryKeys.sort(); - entryList.sort(); - QCOMPARE( entryKeys, entryList ); -} - -void tst_QSettings::oldWriteEntry_QString_bool_data() -{ - QTest::addColumn("b"); - QTest::newRow( "false" ) << bool(FALSE); - QTest::newRow( "true" ) << bool(TRUE); -} - -void tst_QSettings::oldWriteEntry_QString_bool() -{ - { - QSettings writeSettings("software.org", "KillerAPP"); - QFETCH( bool, b ); - QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/Boolean", b ) ); - } - - { - QSettings readSettings("software.org", "KillerAPP"); - QFETCH( bool, b ); - bool ok = FALSE; - QCOMPARE( readSettings.readBoolEntry( "/Trolltech/QSettingsTesting/Boolean", 0, &ok ), b ); - QVERIFY( ok ); - } -} - -void tst_QSettings::oldWriteEntry_QString_double_data() -{ - QTest::addColumn("f"); - QTest::newRow( "data0" ) << 3.1415; - QTest::newRow( "data1" ) << 0.0; - QTest::newRow( "data2" ) << 0.0000000000000000000000000001; -} - -void tst_QSettings::oldWriteEntry_QString_double() -{ - { - QSettings writeSettings("software.org", "KillerAPP"); - QFETCH( double, f ); - QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/Floating", f ) ); - } - { - QSettings readSettings("software.org", "KillerAPP"); - QFETCH( double, f ); - bool ok = FALSE; - QCOMPARE( readSettings.readDoubleEntry( "/Trolltech/QSettingsTesting/Floating", 0, &ok ), f ); - QVERIFY( ok ); - } -} - -void tst_QSettings::oldWriteEntry_QString_int_data() -{ - QTest::addColumn("i"); - QTest::newRow( "data0" ) << int(0); - QTest::newRow( "data1" ) << int(1); - QTest::newRow( "data2" ) << int(11); - QTest::newRow( "data3" ) << int(111); - QTest::newRow( "data4" ) << int(1111); - QTest::newRow( "data5" ) << int(11111); - QTest::newRow( "data6" ) << int(-1); - QTest::newRow( "data7" ) << int(-11); - QTest::newRow( "data8" ) << int(-111); - QTest::newRow( "data9" ) << int(-1111); - QTest::newRow( "data10" ) << int(-11111); -} - -void tst_QSettings::oldWriteEntry_QString_int() -{ - { - QSettings writeSettings("software.org", "KillerAPP"); - QFETCH( int, i ); - QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/Integer", i ) ); - } - { - QSettings readSettings("software.org", "KillerAPP"); - QFETCH( int, i ); - bool ok = FALSE; - QCOMPARE( readSettings.readNumEntry( "/Trolltech/QSettingsTesting/Integer", 0, &ok ), i ); - QVERIFY( ok ); - } -} - -void tst_QSettings::oldWriteEntry_QString_QString_data() -{ - QTest::addColumn("s"); - QTest::newRow( "data0" ) << QString( "blah" ); - QTest::newRow( "data1" ) << QString( "" ); - QTest::newRow( "data2" ) << QString( QChar(0x0E12) ); // unicode - QTest::newRow( "data3" ) << QString("foo"); -// QTest::newRow( "data4" ) << QString::null; // nul string (not supported on Windows!) - QTest::newRow( "data5" ) << QString( QChar(0xFEFC) ); // more unicode - QTest::newRow( "data6" ) << QString( "This is s short string" ); - QTest::newRow( "data7" ) << QString( "This is a string with a cr\nand some text on the second line" ); - QTest::newRow( "data8" ) << QString( "\n" ); - QTest::newRow( "data9" ) << QString( "01234567890, abcdefghijklmnopqrestuvxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()_+=-[{]}\\|'\":;/?.>,<" ); -} - -void tst_QSettings::oldWriteEntry_QString_QString() -{ - { - QSettings writeSettings("software.org", "KillerAPP"); - QFETCH( QString, s ); - QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/String", s ) ); - } - { - QSettings readSettings("software.org", "KillerAPP"); - QFETCH( QString, s ); - bool ok = FALSE; - QCOMPARE( readSettings.readEntry( "/Trolltech/QSettingsTesting/String", QString::null, &ok ), s ); - QVERIFY( ok ); - } -} - -void tst_QSettings::oldWriteEntry_QString_QStringList_data() -{ - QTest::addColumn("l"); - QStringList list0; - list0 << "elem1"; - list0 << "elem2"; - list0 << "elem3"; - list0 << "elem4"; - - QTest::newRow( "data0") << list0; - - QStringList list1; - list1 << " elem1"; - list1 << "elem2 "; - list1 << QString(); - list1 << ""; - list1 << "elem3"; - QTest::newRow( "data1") << list1; - - QStringList list2; - list2 << " elem1"; - list2 << "elem2 bla bla bla, yada yada, 01234567890, abcdefghijklmnopqrestuvxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()_+=-[{]}\\|'\":;/?.>,<"; - list1 << QString(); - list2 << "\n"; - list2 << "elem3\nand another line"; - QTest::newRow( "data2") << list2; -} - -void tst_QSettings::oldWriteEntry_QString_QStringList() -{ - { - QSettings writeSettings("software.org", "KillerAPP"); - QFETCH( QStringList, l ); - QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/List", l ) ); - } - { - QSettings readSettings("software.org", "KillerAPP"); - QFETCH( QStringList, l ); - bool ok = FALSE; - QCOMPARE( readSettings.readListEntry( "/Trolltech/QSettingsTesting/List", &ok ), l ); - QVERIFY( ok ); - } -} - -void tst_QSettings::oldWriteEntry_QString_QStringList_QChar_data() -{ - QTest::addColumn("l"); - QTest::addColumn("sep"); - - QStringList list0; - list0 << "elem1"; - list0 << "elem2"; - list0 << "elem3"; - list0 << "elem4"; - - QTest::newRow( "data00") << list0 << "\\"; - QTest::newRow( "data01") << list0 << "/"; - QTest::newRow( "data02") << list0 << " "; - - QStringList list1; - list1 << " elem1"; - list1 << "elem2 "; - list1 << "elem3"; - QTest::newRow( "data10") << list1 << "\\"; - QTest::newRow( "data11") << list1 << "/"; - QTest::newRow( "data12") << list1 << "&"; - - QStringList list2; - list2 << " elem1"; - list2 << "elem2 bla bla bla, yada yada, 01234567890, abcdefghijklmnopqrestuvxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^*()_+=-[{]}\\|/'\":;?.>,<"; - list2 << "\n"; - list2 << "elem3\nand another line"; - QTest::newRow( "data20") << list2 << "&"; - - // an empty stringlist should be stored as an empty string (and return an empty stringlist?) - QStringList list3; - QTest::newRow( "data30") << list3 << "/"; -} - -void tst_QSettings::oldWriteEntry_QString_QStringList_QChar() -{ - // edba: - // data10, data11, data12, data20, data21 and data22 currently fail. - // This is because the list DOES contain the separator which is a fail IMO, so i - // expect the writeEntry to return FALSE (but it doesn't). - // If my interpretation of the doc is wrong, then the separators should be deleted from - // data10 .. data22. - { - QSettings writeSettings("software.org", "KillerAPP"); - QFETCH( QStringList, l ); - QFETCH( QString, sep ); - QVERIFY( writeSettings.writeEntry( "/Trolltech/QSettingsTesting/List", l, QChar(sep[0]) ) ); - } - { - QSettings readSettings("software.org", "KillerAPP"); - QFETCH( QStringList, l ); - QFETCH( QString, sep ); - bool ok = FALSE; - QStringList actual; - actual = readSettings.readListEntry( "/Trolltech/QSettingsTesting/List", QChar(sep[0]), &ok ); - QVERIFY2( ok, "Read the stringlist from the settings" ); - QCOMPARE( actual, l ); - } -} - -void tst_QSettings::oldReadListEntry_QString() -{ - DEPENDS_ON( "writeEntry_QString_QStringList" ); -} - -void tst_QSettings::oldReadListEntry_QString_QChar() -{ - DEPENDS_ON( "writeEntry_QString_QStringList_QChar" ); -} - -void tst_QSettings::oldReadEntry() -{ - DEPENDS_ON( "writeEntry_QString_QString" ); -} - -void tst_QSettings::oldReadNumEntry() -{ - DEPENDS_ON( "writeEntry_QString_int" ); -} - -void tst_QSettings::oldReadDoubleEntry() -{ - DEPENDS_ON( "writeEntry_QString_double" ); -} - -void tst_QSettings::oldReadBoolEntry() -{ - DEPENDS_ON( "writeEntry_QString_bool" ); -} - -void tst_QSettings::oldRemoveEntry() -{ - // we'll use this one later - QSettings firstSettings("software.org", "KillerAPP"); - - // first write a key - { - QSettings writeSettings("software.org", "KillerAPP"); - writeSettings.writeEntry( "/Trolltech/QSettingsTesting/removeEntry", "foobar" ); - } - - // check that the key exists - { - QSettings readSettings("software.org", "KillerAPP"); - bool ok = FALSE; - QString foo = readSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok ); - QVERIFY( ok ); - QVERIFY( foo == "foobar" ); - - // and remove it - QVERIFY( readSettings.removeEntry( "/Trolltech/QSettingsTesting/removeEntry") ); - - // check that it is gone - QString foo2 = readSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok ); - QVERIFY( ok == FALSE ); - QVERIFY( foo2 == "" ); - } - - // Take another chance with a fresh instance - { - QSettings readSettings("software.org", "KillerAPP"); - bool ok = FALSE; - QString foo = readSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok ); - QVERIFY( ok == FALSE ); - QVERIFY( foo == "" ); - } - - // and another chance with an instance that existed already - { - bool ok = FALSE; - QString foo = firstSettings.readEntry( "/Trolltech/QSettingsTesting/removeEntry", QString::null, &ok ); - QVERIFY( ok == FALSE ); - QVERIFY( foo == "" ); - } -} - -void tst_QSettings::oldGlobalVersusLocal() -{ - { //write global - QSettings settings("foo"); - settings.setPath("software.org", "KillerAPP", QSettings::Global); - settings.writeEntry("/vs/just_global/", "from Global"); - settings.writeEntry("/vs/local_and_global/", "from Global"); - } - { //write local - QSettings settings("bar"); - settings.setPath("software.org", "KillerAPP", QSettings::User); - settings.writeEntry("/vs/local_and_global/", "from User"); - } - bool ok; - { - QSettings settings("baz"); - settings.setPath("software.org", "KillerAPP", QSettings::User); - QString just_global = settings.readEntry("/vs/just_global/", "not_available", &ok); - QVERIFY(ok); - QCOMPARE(just_global, QString("from Global")); - QString local_and_global = settings.readEntry("/vs/local_and_global/", "not_available", &ok); - QVERIFY(ok); - QCOMPARE(local_and_global, QString("from User")); - } - { - QSettings settings("bat"); - settings.setPath("software.org", "KillerAPP", QSettings::Global); - QString just_global = settings.readEntry("/vs/just_global/", "not_available", &ok); - QVERIFY(ok); - QCOMPARE(just_global, QString("from Global")); - QString local_and_global = settings.readEntry("/vs/local_and_global/", "not_available", &ok); - QVERIFY(ok); - QCOMPARE(local_and_global, QString("from Global")); - } -} -#endif // QT3_SUPPORT - void tst_QSettings::fileName() { #ifdef Q_OS_MAC @@ -3792,19 +3108,6 @@ void tst_QSettings::recursionBug() } } -#ifdef QT3_SUPPORT -void tst_QSettings::setPathBug() -{ - QSettings settings("software.org", "KillerAPP", this); - settings.setPath("foo.org", "Bar", QSettings::User); - QVERIFY(settings.parent() == this); - settings.setValue("blah", "BAZ"); - settings.setPath("bar.org", "Baz", QSettings::User); - settings.setValue("blah", "BAZ"); - QVERIFY(settings.parent() == this); -} -#endif - #if defined(Q_OS_WIN) static DWORD readKeyType(HKEY handle, const QString &rSubKey) diff --git a/tests/auto/qsql/tst_qsql.cpp b/tests/auto/qsql/tst_qsql.cpp index c34f94cf43..fe8af9dd9c 100644 --- a/tests/auto/qsql/tst_qsql.cpp +++ b/tests/auto/qsql/tst_qsql.cpp @@ -45,9 +45,6 @@ #include #include #include -#ifdef QT3_SUPPORT -#include -#endif #include #include #include @@ -149,47 +146,6 @@ void tst_QSql::basicDriverTest() QCOMPARE( rInf.count(), 2 ); QCOMPARE( rInf.fieldName( 0 ).toLower(), QString( "id" ) ); QCOMPARE( rInf.fieldName( 1 ).toLower(), QString( "name" ) ); - -#ifdef QT3_SUPPORT - QSqlRecord* rec = 0; - Q3SqlCursor cur( tableName, true, db ); - QVERIFY_SQL( cur, select() ); - QCOMPARE( cur.count(), 2 ); - QCOMPARE( cur.fieldName( 0 ).lower(), QString( "id" ) ); - QCOMPARE( cur.fieldName( 1 ).lower(), QString( "name" ) ); - - rec = cur.primeDelete(); - rec->setGenerated( 0, false ); - rec->setGenerated( 1, false ); - QVERIFY_SQL( cur, del() ); - QVERIFY_SQL( cur, select() ); - QCOMPARE( cur.at(), int( QSql::BeforeFirst ) ); - QVERIFY( !cur.next() ); - rec = cur.primeInsert(); - rec->setValue( 0, 1 ); - rec->setValue( 1, QString( "Harry" ) ); - QVERIFY_SQL( cur, insert( false ) ); - rec = cur.primeInsert(); - rec->setValue( 0, 2 ); - rec->setValue( 1, QString( "Trond" ) ); - QVERIFY_SQL( cur, insert( true ) ); - QVERIFY_SQL( cur, select( cur.index( QString( "id" ) ) ) ); - QVERIFY_SQL( cur, next() ); - QCOMPARE( cur.value( 0 ).toInt(), 1 ); - QCOMPARE( cur.value( 1 ).toString().stripWhiteSpace(), QString( "Harry" ) ); - QVERIFY_SQL( cur, next() ); - QCOMPARE( cur.value( 0 ).toInt(), 2 ); - QCOMPARE( cur.value( 1 ).toString().stripWhiteSpace(), QString( "Trond" ) ); - QVERIFY( !cur.next() ); - QVERIFY_SQL( cur, first() ); - rec = cur.primeUpdate(); - rec->setValue( 1, QString( "Vohi" ) ); - QVERIFY_SQL( cur, update( true ) ); - QVERIFY_SQL( cur, select( "id = 1" ) ); - QVERIFY_SQL( cur, next() ); - QCOMPARE( cur.value( 0 ).toInt(), 1 ); - QCOMPARE( cur.value( 1 ).toString().stripWhiteSpace(), QString( "Vohi" ) ); -#endif } dbs.close(); diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 185e046518..900eab7161 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -44,11 +44,6 @@ #include #include #include -#ifdef QT3_SUPPORT -#include -#include -#include -#endif #include #include #include @@ -130,8 +125,6 @@ private slots: //problem specific tests void alterTable_data() { generic_data(); } void alterTable(); - void recordNonSelect_data() { generic_data(); } - void recordNonSelect(); void caseSensivity_data() { generic_data(); } void caseSensivity(); void noEscapedFieldNamesInRecord_data() { generic_data(); } @@ -211,13 +204,8 @@ private: void populateTestTables(QSqlDatabase db); void generic_data(const QString &engine=QString()); -#ifdef QT3_SUPPORT - void testRecordInfo(const FieldDef fieldDefs[], const Q3SqlRecordInfo& inf); -#endif void testRecord(const FieldDef fieldDefs[], const QSqlRecord& inf, QSqlDatabase db); void commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase, const int); - void checkValues(const FieldDef fieldDefs[], QSqlDatabase db); - void checkNullValues(const FieldDef fieldDefs[], QSqlDatabase db); tst_Databases dbs; }; @@ -238,11 +226,7 @@ struct FieldDef { { QString rt = typeName; rt.replace(QRegExp("\\s"), QString("_")); -#ifdef QT3_SUPPORT - int i = rt.find("("); -#else int i = rt.indexOf("("); -#endif if (i == -1) i = rt.length(); if (i > 20) @@ -482,31 +466,6 @@ void tst_QSqlDatabase::open() } } -void tst_QSqlDatabase::recordNonSelect() -{ -#ifdef QT3_SUPPORT - QFETCH(QString, dbName); - QSqlDatabase db = QSqlDatabase::database(dbName); - CHECK_DATABASE(db); - - QSqlQuery q(db); - - // nothing should happen on an empty query - QSqlRecord rec = db.record(q); - QVERIFY(rec.isEmpty()); - Q3SqlRecordInfo rInf = db.recordInfo(q); - QVERIFY(rInf.isEmpty()); - - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_temp", __FILE__) + " (id int)")); - - // query without result set should return empty record - rec = db.record(q); - QVERIFY(rec.isEmpty()); - rInf = db.recordInfo(q); - QVERIFY(rInf.isEmpty()); -#endif -} - void tst_QSqlDatabase::tables() { QFETCH(QString, dbName); @@ -612,18 +571,10 @@ void tst_QSqlDatabase::alterTable() QVERIFY_SQL(q, exec("create table " + qtestalter + " (F1 char(20), F2 char(20), F3 char(20))")); QSqlRecord rec = db.record(qtestalter); QCOMPARE((int)rec.count(), 3); -#ifdef QT3_SUPPORT - Q3SqlRecordInfo rinf = db.recordInfo(qtestalter); - QCOMPARE((int)rinf.count(), 3); -#endif - int i; for (i = 0; i < 3; ++i) { QCOMPARE(rec.field(i).name().toUpper(), QString("F%1").arg(i + 1)); -#ifdef QT3_SUPPORT - QCOMPARE(rinf[ i ].name().upper(), QString("F%1").arg(i + 1)); -#endif } if (!q.exec("alter table " + qtestalter + " drop column F2")) { @@ -631,36 +582,13 @@ void tst_QSqlDatabase::alterTable() } rec = db.record(qtestalter); -#ifdef QT3_SUPPORT - rinf = db.recordInfo(qtestalter); -#endif QCOMPARE((int)rec.count(), 2); -#ifdef QT3_SUPPORT - QCOMPARE((int)rinf.count(), 2); -#endif QCOMPARE(rec.field(0).name().toUpper(), QString("F1")); QCOMPARE(rec.field(1).name().toUpper(), QString("F3")); -#ifdef QT3_SUPPORT - QCOMPARE(rinf[ 0 ].name().upper(), QString("F1")); - QCOMPARE(rinf[ 1 ].name().upper(), QString("F3")); -#endif q.exec("select * from " + qtestalter); - -#ifdef QT3_SUPPORT - rec = db.record(q); - rinf = db.recordInfo(q); - - QCOMPARE((int)rec.count(), 2); - QCOMPARE((int)rinf.count(), 2); - - QCOMPARE(rec.field(0).name().upper(), QString("F1")); - QCOMPARE(rec.field(1).name().upper(), QString("F3")); - QCOMPARE(rinf[ 0 ].name().upper(), QString("F1")); - QCOMPARE(rinf[ 1 ].name().upper(), QString("F3")); -#endif } #if 0 @@ -684,27 +612,7 @@ void tst_QSqlDatabase::record() const int fieldCount = createFieldTable(fieldDefs, db); QVERIFY(fieldCount > 0); -// doesn't work with oracle: checkNullValues(fieldDefs, db); commonFieldTest(fieldDefs, db, fieldCount); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } -} -#endif - -#ifdef QT3_SUPPORT -void tst_QSqlDatabase::testRecordInfo(const FieldDef fieldDefs[], const Q3SqlRecordInfo& inf) -{ - int i = 0; - for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { - QCOMPARE(inf[i+1].name().upper(), fieldDefs[ i ].fieldName().upper()); - if (inf[i+1].type() != fieldDefs[ i ].type) { - QFAIL(QString(" Expected: '%1' Received: '%2' for field %3 in testRecordInfo").arg( - QVariant::typeToName(fieldDefs[ i ].type)).arg( - QVariant::typeToName(inf[i+1].type())).arg( - fieldDefs[ i ].fieldName())); - } - } } #endif @@ -732,126 +640,12 @@ void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase { CHECK_DATABASE(db); - // check whether recordInfo returns the right types -#ifdef QT3_SUPPORT - Q3SqlRecordInfo inf = db.recordInfo(qTableName("qtestfields", __FILE__)); - QCOMPARE((int)inf.count(), fieldCount+1); - testRecordInfo(fieldDefs, inf); -#endif - QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__)); QCOMPARE((int)rec.count(), fieldCount+1); testRecord(fieldDefs, rec, db); QSqlQuery q(db); QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__))); - -#ifdef QT3_SUPPORT - inf = db.recordInfo(q); - QCOMPARE((int)inf.count(), fieldCount+1); - testRecordInfo(fieldDefs, inf); - - rec = db.record(q); - QCOMPARE((int)rec.count(), fieldCount+1); - testRecord(fieldDefs, rec, db); -#endif -} - -// inserts testdata into the testtable, fetches and compares them -void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db) -{ - Q_UNUSED(fieldDefs); -#ifdef QT3_SUPPORT - CHECK_DATABASE(db); - - Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); - QVERIFY_SQL(cur, select()); - QSqlRecord* rec = cur.primeInsert(); - QVERIFY(rec); - rec->setValue("id", pkey++); - int i = 0; - for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { - rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val); -// qDebug(QString("inserting %1 into %2").arg(fieldDefs[ i ].val.toString()).arg(fieldDefs[ i ].fieldName())); - } - QVERIFY_SQL(cur, insert()); - cur.setForwardOnly(true); - QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1))); - QVERIFY_SQL(cur, next()); - - for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { - bool ok = false; - QVariant val1 = cur.value(fieldDefs[ i ].fieldName()); - QVariant val2 = fieldDefs[ i ].val; - if (val1.type() == QVariant::String) - //TDS Workaround - val1 = val1.toString().stripWhiteSpace(); - if (fieldDefs[ i ].fieldName() == "t_real") { - // strip precision - val1 = (float)val1.toDouble(); - val2 = (float)val2.toDouble(); - } - if (val1.canCast(QVariant::Double) && val2.type() == QVariant::Double) { - // we don't care about precision here, we just want to know whether - // we can insert/fetch the right values - ok = (val1.toDouble() - val2.toDouble() < 0.00001); - } else if (val1.type() == val2.type()) { - ok = (val1 == val2); - } else { - ok = (val1.toString() == val2.toString()); - } - if (!ok) { - if (val2.type() == QVariant::DateTime || val2.type() == QVariant::Time) - qDebug("Expected Time: " + val2.toTime().toString("hh:mm:ss.zzz")); - if (val1.type() == QVariant::DateTime || val1.type() == QVariant::Time) - qDebug("Received Time: " + val1.toTime().toString("hh:mm:ss.zzz")); - QFAIL(QString(" Expected: '%1' Received: '%2' for field %3 (etype %4 rtype %5) in checkValues").arg( - val2.type() == QVariant::ByteArray ? val2.toByteArray().toHex() : val2.toString()).arg( - val1.type() == QVariant::ByteArray ? val1.toByteArray().toHex() : val1.toString()).arg( - fieldDefs[ i ].fieldName()).arg( - val2.typeName()).arg( - val1.typeName()) - ); - } - } -#endif -} - -// inserts a NULL value for each nullable field in testdata, fetches and checks whether -// we get back NULL -void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase db) -{ - Q_UNUSED(fieldDefs); -#ifdef QT3_SUPPORT - CHECK_DATABASE(db); - - Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); - QVERIFY_SQL(cur, select()); - QSqlRecord* rec = cur.primeInsert(); - QVERIFY(rec); - rec->setValue("id", pkey++); - int i = 0; - for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { - if (fieldDefs[ i ].fieldName(), fieldDefs[ i ].nullable) - rec->setNull(fieldDefs[ i ].fieldName()); - else - rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val); - } - QVERIFY_SQL(cur, insert()); - cur.setForwardOnly(true); - QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1))); - QVERIFY_SQL(cur, next()); - - for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { - if (fieldDefs[ i ].nullable == false) - continue; - // multiple inheritance sucks so much - QVERIFY2(((QSqlQuery)cur).isNull(i + 1), "Check whether '" + fieldDefs[ i ].fieldName() + "' is null in QSqlQuery"); - QVERIFY2(((QSqlRecord)cur).isNull(fieldDefs[ i ].fieldName()), "Check whether '" + fieldDefs[ i ].fieldName() + "' is null in QSqlRecord"); - if (!cur.value(fieldDefs[ i ].fieldName()).isNull()) - qDebug(QString("QVariant is not null for NULL-Value in Field '%1'").arg(fieldDefs[ i ].fieldName())); - } -#endif } void tst_QSqlDatabase::recordTDS() @@ -880,11 +674,6 @@ void tst_QSqlDatabase::recordTDS() FieldDef("nchar(20)", QVariant::String, "blah3"), FieldDef("nvarchar(20)", QVariant::String, "blah4"), FieldDef("text", QVariant::String, "blah5"), -#ifdef QT3_SUPPORT - FieldDef("binary(20)", QVariant::ByteArray, Q3CString("blah6")), - FieldDef("varbinary(20)", QVariant::ByteArray, Q3CString("blah7")), - FieldDef("image", QVariant::ByteArray, Q3CString("blah8")), -#endif FieldDef("bit", QVariant::Int, 1, false), FieldDef() @@ -894,10 +683,6 @@ void tst_QSqlDatabase::recordTDS() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } } void tst_QSqlDatabase::recordOCI() @@ -954,9 +739,6 @@ void tst_QSqlDatabase::recordOCI() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) - checkValues(fieldDefs, db); // some additional tests QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__)); @@ -978,18 +760,11 @@ void tst_QSqlDatabase::recordPSQL() FieldDef byteadef; if (db.driver()->hasFeature(QSqlDriver::BLOB)) -#ifdef QT3_SUPPORT - byteadef = FieldDef("bytea", QVariant::ByteArray, QByteArray(Q3CString("bl\\ah"))); -#else byteadef = FieldDef("bytea", QVariant::ByteArray, QByteArray("bl\\ah")); -#endif static FieldDef fieldDefs[] = { FieldDef("bigint", QVariant::LongLong, Q_INT64_C(9223372036854775807)), FieldDef("bigserial", QVariant::LongLong, 100, false), FieldDef("bit", QVariant::String, "1"), // a bit in postgres is a bit-string -#ifdef QT3_SUPPORT - FieldDef("boolean", QVariant::Bool, QVariant(bool(true), 0)), -#endif FieldDef("box", QVariant::String, "(5,6),(1,2)"), FieldDef("char(20)", QVariant::String, "blah5678901234567890"), FieldDef("varchar(20)", QVariant::String, "blah5678901234567890"), @@ -1038,7 +813,6 @@ void tst_QSqlDatabase::recordPSQL() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); for (int i = 0; i < ITERATION_COUNT; ++i) { // increase serial values for (int i2 = 0; !fieldDefs[ i2 ].typeName.isNull(); ++i2) { @@ -1046,15 +820,10 @@ void tst_QSqlDatabase::recordPSQL() fieldDefs[ i2 ].typeName == "bigserial") { FieldDef def = fieldDefs[ i2 ]; -#ifdef QT3_SUPPORT - def.val = def.val.asInt() + 1; -#else def.val = def.val.toInt() + 1; -#endif fieldDefs[ i2 ] = def; } } - checkValues(fieldDefs, db); } } @@ -1076,13 +845,8 @@ void tst_QSqlDatabase::recordMySQL() with space on insert, and trailing spaces are removed on select. */ if( vernum >= ((5 << 16) + 15) ) { -#ifdef QT3_SUPPORT - bin10 = FieldDef("binary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abc "))); - varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abcv "))); -#else bin10 = FieldDef("binary(10)", QVariant::ByteArray, QString("123abc ")); varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QString("123abcv ")); -#endif } static QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0)); @@ -1108,20 +872,10 @@ void tst_QSqlDatabase::recordMySQL() FieldDef("year", QVariant::Int, 2003), FieldDef("char(20)", QVariant::String, "Blah"), FieldDef("varchar(20)", QVariant::String, "BlahBlah"), -#ifdef QT3_SUPPORT - FieldDef("tinyblob", QVariant::ByteArray, QByteArray(Q3CString("blah1"))), - FieldDef("blob", QVariant::ByteArray, QByteArray(Q3CString("blah2"))), - FieldDef("mediumblob", QVariant::ByteArray,QByteArray(Q3CString("blah3"))), - FieldDef("longblob", QVariant::ByteArray, QByteArray(Q3CString("blah4"))), -#endif FieldDef("tinytext", QVariant::String, QString("blah5")), FieldDef("text", QVariant::String, QString("blah6")), FieldDef("mediumtext", QVariant::String, QString("blah7")), FieldDef("longtext", QVariant::String, QString("blah8")), -#ifdef QT3_SUPPORT - bin10, - varbin10, -#endif // SET OF? FieldDef() @@ -1131,10 +885,6 @@ void tst_QSqlDatabase::recordMySQL() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } QSqlQuery q(db); QVERIFY_SQL(q, exec("SELECT DATE_SUB(CURDATE(), INTERVAL 2 DAY)")); @@ -1168,11 +918,6 @@ void tst_QSqlDatabase::recordDB2() // FieldDef("graphic(20)", QVariant::String, QString("Blah4")), // FieldDef("vargraphic(20)", QVariant::String, QString("Blah5")), // FieldDef("long vargraphic", QVariant::String, QString("Blah6")), -#ifdef QT3_SUPPORT -// FieldDef("clob(20)", QVariant::CString, QString("Blah7")), -// FieldDef("dbclob(20)", QVariant::CString, QString("Blah8")), -// FieldDef("blob(20)", QVariant::ByteArray, QByteArray(Q3CString("Blah9"))), -#endif //X FieldDef("datalink", QVariant::String, QString("DLVALUE('Blah10')")), FieldDef() }; @@ -1181,10 +926,6 @@ void tst_QSqlDatabase::recordDB2() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } } void tst_QSqlDatabase::recordIBase() @@ -1211,10 +952,6 @@ void tst_QSqlDatabase::recordIBase() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } } void tst_QSqlDatabase::recordSQLite() @@ -1241,10 +978,6 @@ void tst_QSqlDatabase::recordSQLite() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } } void tst_QSqlDatabase::recordSQLServer() @@ -1264,9 +997,6 @@ void tst_QSqlDatabase::recordSQLServer() FieldDef("bigint", QVariant::LongLong, 12345), FieldDef("int", QVariant::Int, 123456), FieldDef("tinyint", QVariant::UInt, 255), -#ifdef QT3_SUPPORT - FieldDef("image", QVariant::ByteArray, Q3CString("Blah1")), -#endif FieldDef("float", QVariant::Double, 1.12345), FieldDef("numeric(5,2)", QVariant::Double, 123.45), FieldDef("uniqueidentifier", QVariant::String, @@ -1279,10 +1009,6 @@ void tst_QSqlDatabase::recordSQLServer() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } } void tst_QSqlDatabase::recordAccess() @@ -1306,9 +1032,6 @@ void tst_QSqlDatabase::recordAccess() FieldDef("single", QVariant::Double, 1.12345), FieldDef("double", QVariant::Double, 1.123456), FieldDef("byte", QVariant::UInt, 255), -#ifdef QT3_SUPPORT - FieldDef("binary(5)", QVariant::ByteArray, Q3CString("Blah2")), -#endif FieldDef("long", QVariant::Int, 2147483647), FieldDef("memo", QVariant::String, memo), FieldDef() @@ -1318,10 +1041,6 @@ void tst_QSqlDatabase::recordAccess() QVERIFY(fieldCount > 0); commonFieldTest(fieldDefs, db, fieldCount); - checkNullValues(fieldDefs, db); - for (int i = 0; i < ITERATION_COUNT; ++i) { - checkValues(fieldDefs, db); - } } void tst_QSqlDatabase::transaction() @@ -1462,17 +1181,6 @@ void tst_QSqlDatabase::caseSensivity() QVERIFY((int)rec.count() > 0); } -#ifdef QT3_SUPPORT - Q3SqlRecordInfo rInf = db.recordInfo(qTableName("qtest", __FILE__)); - QVERIFY((int)rInf.count() > 0); - if (!cs) { - rInf = db.recordInfo(qTableName("QTEST", __FILE__).upper()); - QVERIFY((int)rInf.count() > 0); - rInf = db.recordInfo(qTableName("qTesT", __FILE__)); - QVERIFY((int)rInf.count() > 0); - } -#endif - rec = db.primaryIndex(qTableName("qtest", __FILE__)); QVERIFY((int)rec.count() > 0); if (!cs) { @@ -1526,12 +1234,6 @@ void tst_QSqlDatabase::psql_schemas() QCOMPARE(rec.fieldName(0), QString("id")); QCOMPARE(rec.fieldName(1), QString("name")); -#ifdef QT3_SUPPORT - rec = db.record(QSqlQuery("select * from " + table, db)); - QCOMPARE(rec.count(), 2); - QCOMPARE(rec.fieldName(0), QString("id")); - QCOMPARE(rec.fieldName(1), QString("name")); -#endif QSqlIndex idx = db.primaryIndex(table); QCOMPARE(idx.count(), 1); QCOMPARE(idx.fieldName(0), QString("id")); diff --git a/tests/auto/qsqlrecord/tst_qsqlrecord.cpp b/tests/auto/qsqlrecord/tst_qsqlrecord.cpp index 431dfbf3fe..41c4e3b1cf 100644 --- a/tests/auto/qsqlrecord/tst_qsqlrecord.cpp +++ b/tests/auto/qsqlrecord/tst_qsqlrecord.cpp @@ -70,12 +70,6 @@ public slots: void cleanup(); private slots: void value(); -#ifdef QT3_SUPPORT - void toStringList_data(); - void toStringList(); - void toString_data(); - void toString(); -#endif // QT3_SUPPORT void setValue_data(); void setValue(); void setNull(); @@ -166,12 +160,6 @@ void tst_QSqlRecord::append() QCOMPARE( rec->indexOf( "int" ), 1 ); QCOMPARE( rec->indexOf( "double" ), 2 ); QCOMPARE( rec->indexOf( "bool" ), 3 ); -#ifdef QT3_SUPPORT - QCOMPARE( rec->position( "string" ), 0 ); - QCOMPARE( rec->position( "int" ), 1 ); - QCOMPARE( rec->position( "double" ), 2 ); - QCOMPARE( rec->position( "bool" ), 3 ); -#endif } void tst_QSqlRecord::clear() @@ -181,10 +169,6 @@ void tst_QSqlRecord::clear() rec->clear(); QCOMPARE( (int)rec->count(), 0 ); QVERIFY( rec->isEmpty() ); -#ifdef QT3_SUPPORT - QVERIFY( rec->fieldPtr( 0 ) == 0 ); - QVERIFY( rec->fieldPtr( "_This should give a warning!_" ) == 0 ); -#endif QVERIFY( !rec->contains( fields[0]->name() ) ); } @@ -236,12 +220,6 @@ void tst_QSqlRecord::clearValues() QCOMPARE( rec->indexOf( "int" ), 1 ); QCOMPARE( rec->indexOf( "double" ), 2 ); QCOMPARE( rec->indexOf( "bool" ), 3 ); -#ifdef QT3_SUPPORT - QCOMPARE( rec->position( "string" ), 0 ); - QCOMPARE( rec->position( "int" ), 1 ); - QCOMPARE( rec->position( "double" ), 2 ); - QCOMPARE( rec->position( "bool" ), 3 ); -#endif for ( i = 0; i < 4; ++i ) rec->setNull( i ); @@ -287,9 +265,6 @@ void tst_QSqlRecord::field() int i; for ( i = 0; i < NUM_FIELDS; ++i ) QVERIFY( rec->field( i ) == *fields[ i ] ); -#ifdef QT3_SUPPORT - QVERIFY( rec->fieldPtr( NUM_FIELDS ) == 0 ); -#endif for ( i = 0; i < NUM_FIELDS; ++i ) QVERIFY( rec->field( (fields[ i ] )->name() ) == *( fields[ i ] ) ); @@ -438,9 +413,6 @@ void tst_QSqlRecord::position() int i; for ( i = 0; i < NUM_FIELDS; ++i ) { QCOMPARE( rec->indexOf( fields[ i ]->name() ), i ); -#ifdef QT3_SUPPORT - QCOMPARE( rec->position( fields[ i ]->name() ), i ); -#endif } } @@ -499,12 +471,6 @@ void tst_QSqlRecord::setValue() QCOMPARE( rec->indexOf( "int" ), 1 ); QCOMPARE( rec->indexOf( "double" ), 2 ); QCOMPARE( rec->indexOf( "bool" ), 3 ); -#ifdef QT3_SUPPORT - QCOMPARE( rec->position( "string" ), 0 ); - QCOMPARE( rec->position( "int" ), 1 ); - QCOMPARE( rec->position( "double" ), 2 ); - QCOMPARE( rec->position( "bool" ), 3 ); -#endif QFETCH( int, ival ); QFETCH( QString, sval ); @@ -543,58 +509,6 @@ void tst_QSqlRecord::setValue() QCOMPARE( rec->value( 3 ), QVariant(bval) ); } -#ifdef QT3_SUPPORT -void tst_QSqlRecord::toString_data() -{ - clearValues_data( t ); -} - -void tst_QSqlRecord::toString() -{ - createTestRecord(); - QString result; - QFETCH( QString, prefix ); - QFETCH( QString, sep ); - rec->setGenerated( 1, false ); - for (int i = 0; i < NUM_FIELDS; ++i ) { - if ( i == 1 ) - continue; - if ( prefix.isEmpty() ) { - result += fields[ i ]->name(); - } else { - result += prefix + '.' + fields[ i ]->name(); - } - if ( i != NUM_FIELDS - 1 ) - result += sep + ' '; - } - QCOMPARE( rec->toString( prefix, sep ), result ); -} - -void tst_QSqlRecord::toStringList_data() -{ - clearValues_data( t ); -} - -void tst_QSqlRecord::toStringList() -{ - createTestRecord(); - QStringList result; - QFETCH( QString, prefix ); - rec->setGenerated( 1, false ); - for (int i = 0; i < NUM_FIELDS; ++i ) { - if ( i == 1 ) - continue; - if ( prefix.isEmpty() ) { - result << fields[ i ]->name(); - } else { - result << ( prefix + '.' + fields[ i ]->name() ); - } - } - QCOMPARE(rec->toStringList( prefix ), result); -} - -#endif // QT3_SUPPORT - void tst_QSqlRecord::value() { // this test is already covered in setValue() diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index 37a899c250..641888613d 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -151,7 +151,6 @@ private slots: void indexOf3_data(); // void indexOf3(); void sprintf(); - void copy(); void fill(); void truncate(); void constructor(); @@ -904,19 +903,6 @@ void tst_QString::fill() QCOMPARE(f,(QString)"FFF"); } -void tst_QString::copy() -{ -#ifdef QT3_SUPPORT - QString e; - e = "String E"; - QString ce = e.copy(); - QCOMPARE(ce,(QString)"String E"); - e = "XXX"; - QCOMPARE(ce,(QString)"String E"); - QCOMPARE(e,(QString)"XXX"); -#endif -} - void tst_QString::sprintf() { QString a; @@ -3364,7 +3350,7 @@ void tst_QString::local8Bit_data() /* QString::local8Bit() called on a null QString returns an _empty_ - QByteArray. This is the correct behavior since Qt 3.1. + QByteArray. */ QTest::newRow("nullString") << QString() << QByteArray(""); QTest::newRow("emptyString") << QString("") << QByteArray(""); diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp index 5c319f0a9e..0e66597d16 100644 --- a/tests/auto/qstyle/tst_qstyle.cpp +++ b/tests/auto/qstyle/tst_qstyle.cpp @@ -337,9 +337,6 @@ void tst_QStyle::testAllFunctions(QStyle *style) copt6.init(testWidget); QStyleOptionToolButton copt7; copt7.init(testWidget); - QStyleOptionQ3ListView copt8; - copt8.init(testWidget); - copt8.items << QStyleOptionQ3ListViewItem(); QStyleOptionComplex copt9; copt9.initFrom(testWidget); @@ -351,10 +348,6 @@ void tst_QStyle::testAllFunctions(QStyle *style) style->drawComplexControl(QStyle::CC_TitleBar, &copt6, &painter, 0); style->drawComplexControl(QStyle::CC_GroupBox, &copt2, &painter, 0); style->drawComplexControl(QStyle::CC_Dial, &copt4, &painter, 0); -#ifdef QT3_SUPPORT - style->drawComplexControl(QStyle::CC_Q3ListView, &copt8, &painter, 0); - style->drawComplexControl(QStyle::CC_MdiControls, &copt9, &painter, 0); -#endif } //Check standard pixmaps/icons diff --git a/tests/auto/qstyleoption/tst_qstyleoption.cpp b/tests/auto/qstyleoption/tst_qstyleoption.cpp index 52297248a1..70402fec5d 100644 --- a/tests/auto/qstyleoption/tst_qstyleoption.cpp +++ b/tests/auto/qstyleoption/tst_qstyleoption.cpp @@ -92,9 +92,6 @@ void tst_QStyleOption::qstyleoptioncast_data() QTest::newRow("optionHeader") << stylePtr(new QStyleOptionHeader) << false << int(QStyleOption::SO_Header); QTest::newRow("optionMenuItem") << stylePtr(new QStyleOptionMenuItem) << false << int(QStyleOption::SO_MenuItem); QTest::newRow("optionProgressBar") << stylePtr(new QStyleOptionProgressBar) << false << int(QStyleOption::SO_ProgressBar); - QTest::newRow("optionQ3DockWindow") << stylePtr(new QStyleOptionQ3DockWindow) << false << int(QStyleOption::SO_Q3DockWindow); - QTest::newRow("optionQ3ListView") << stylePtr(new QStyleOptionQ3ListView) << true << int(QStyleOption::SO_Q3ListView); - QTest::newRow("optionQ3ListViewItem") << stylePtr(new QStyleOptionQ3ListViewItem) << false << int(QStyleOption::SO_Q3ListViewItem); QTest::newRow("optionSlider") << stylePtr(new QStyleOptionSlider) << true << int(QStyleOption::SO_Slider); QTest::newRow("optionSpinBox") << stylePtr(new QStyleOptionSpinBox) << true << int(QStyleOption::SO_SpinBox); QTest::newRow("optionTab") << stylePtr(new QStyleOptionTab) << false << int(QStyleOption::SO_Tab); diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 83adf49fa4..cb51c3dfdd 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -43,9 +43,6 @@ #include #include #include -#ifdef QT3_SUPPORT -#include -#endif #include #include "../platformquirks.h" @@ -1291,9 +1288,6 @@ void tst_QStyleSheetStyle::emptyStyleSheet() QWidget w; QHBoxLayout layout(&w); w.setLayout(&layout); -#ifdef QT3_SUPPORT - layout.addWidget(new Q3ProgressBar(&w)); //task 231137 -#endif layout.addWidget(new QPushButton("push", &w)); layout.addWidget(new QToolButton(&w)); QLabel label("toto", &w); diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp index 252450cc71..c305150af4 100644 --- a/tests/auto/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp @@ -381,9 +381,6 @@ void tst_QTabWidget::currentIndex() { // Test bad arguments QSignalSpy spy(tw, SIGNAL(currentChanged(int))); -#ifdef QT3_SUPPORT - QSignalSpy spySupport(tw, SIGNAL(currentChanged(QWidget *))); -#endif QCOMPARE(tw->currentIndex(), -1); tw->setCurrentIndex(-1); QCOMPARE(tw->currentIndex(), -1); @@ -395,10 +392,7 @@ void tst_QTabWidget::currentIndex() QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toInt() == firstIndex); -#ifdef QT3_SUPPORT - QCOMPARE(spySupport.count(), 1); -#endif - + int index = addPage(); QCOMPARE(tw->currentIndex(), firstIndex); tw->setCurrentIndex(index); @@ -406,28 +400,18 @@ void tst_QTabWidget::currentIndex() QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toInt() == index); -#ifdef QT3_SUPPORT - QCOMPARE(spySupport.count(), 2); -#endif - + removePage(index); QCOMPARE(tw->currentIndex(), firstIndex); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toInt() == firstIndex); -#ifdef QT3_SUPPORT - QCOMPARE(spySupport.count(), 3); -#endif removePage(firstIndex); QCOMPARE(tw->currentIndex(), -1); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toInt() == -1); -#ifdef QT3_SUPPORT - QCOMPARE(spySupport.count(), 4); -#endif - } void tst_QTabWidget::cornerWidget() diff --git a/tests/auto/qtcpsocket/stressTest/Test.cpp b/tests/auto/qtcpsocket/stressTest/Test.cpp index 80b4c398f7..4304131352 100644 --- a/tests/auto/qtcpsocket/stressTest/Test.cpp +++ b/tests/auto/qtcpsocket/stressTest/Test.cpp @@ -47,87 +47,6 @@ // Test #include "Test.h" -#ifdef QT3_SUPPORT -//------------------------------------------------------------------------------ -My3Socket::My3Socket(QObject *parent) - : Q3Socket(parent), safeShutDown(false) -{ - connect(this, SIGNAL(readyRead()), this, SLOT(read())); - connect(this, SIGNAL(delayedCloseFinished()), this, SLOT(closed())); - connect(this, SIGNAL(connectionClosed()), this, SLOT(closed())); -} - -//------------------------------------------------------------------------------ -void My3Socket::read() -{ - QDataStream in(this); - - quint32 num, reply; - - while (bytesAvailable()) { - in >> num; - if (num == 42) { - qDebug("SUCCESS"); - safeShutDown = true; - QCoreApplication::instance()->quit(); - return; - } - reply = num + 1; - if (reply == 42) - ++reply; - } - - // Reply with a bigger number - sendTest(reply); -} - -//------------------------------------------------------------------------------ -void My3Socket::closed() -{ - if (!safeShutDown) - qDebug("FAILED"); - QCoreApplication::instance()->quit(); -} - -//------------------------------------------------------------------------------ -void My3Socket::sendTest(quint32 num) -{ - QByteArray block; - QDataStream out(&block, QIODevice::WriteOnly); - out << num; - writeBlock(block, block.size()); -} - -//------------------------------------------------------------------------------ -My3Server::My3Server(QObject *parent) - : Q3ServerSocket(7700, 1, parent), m_socket(0) -{ - if (ok()) - qDebug("qt3server"); - - QTimer::singleShot(5000, this, SLOT(stopServer())); -} - -//------------------------------------------------------------------------------ -void My3Server::newConnection(int socketId) -{ - m_socket = new My3Socket(this); - m_socket->setSocket(socketId); -} - -//------------------------------------------------------------------------------ -void My3Server::stopServer() -{ - if (m_socket) { - qDebug("SUCCESS"); - m_socket->safeShutDown = true; - m_socket->sendTest(42); - } else { - QCoreApplication::instance()->quit(); - } -} -#endif - //------------------------------------------------------------------------------ My4Socket::My4Socket(QObject *parent) : QTcpSocket(parent), safeShutDown(false) @@ -210,19 +129,6 @@ void My4Server::stopServer() Test::Test(Type type) { switch (type) { -#ifdef QT3_SUPPORT - case Qt3Server: { - new My3Server(this); - break; - } - case Qt3Client: { - qDebug("qt3client"); - My3Socket *s = new My3Socket(this); - s->connectToHost("localhost", 7700); - s->sendTest(1); - break; - } -#endif case Qt4Client: { qDebug("qt4client"); My4Socket *s = new My4Socket(this); diff --git a/tests/auto/qtcpsocket/stressTest/Test.h b/tests/auto/qtcpsocket/stressTest/Test.h index f74eda3c79..1aa4d709c2 100644 --- a/tests/auto/qtcpsocket/stressTest/Test.h +++ b/tests/auto/qtcpsocket/stressTest/Test.h @@ -42,48 +42,10 @@ #define TEST_H //------------------------------------------------------------------------------ -// Qt -#ifdef QT3_SUPPORT -#include -#include -#endif #include #include -//------------------------------------------------------------------------------ -#ifdef QT3_SUPPORT -class My3Socket : public Q3Socket -{ - Q_OBJECT -public: - My3Socket(QObject *parent); - - void sendTest(Q_UINT32 num); - bool safeShutDown; - -private slots: - void read(); - void closed(); -}; - -//------------------------------------------------------------------------------ -class My3Server : public Q3ServerSocket -{ - Q_OBJECT -public: - My3Server(QObject *parent = 0); - - void newConnection(int socket); - -private slots: - void stopServer(); - -private: - My3Socket *m_socket; -}; -#endif - //------------------------------------------------------------------------------ class My4Socket : public QTcpSocket { @@ -125,10 +87,6 @@ public: enum Type { Qt4Client, Qt4Server, -#ifdef QT3_SUPPORT - Qt3Client, - Qt3Server -#endif }; Test(Type type); }; diff --git a/tests/auto/qtcpsocket/stressTest/main.cpp b/tests/auto/qtcpsocket/stressTest/main.cpp index 83d175da28..6cff356910 100644 --- a/tests/auto/qtcpsocket/stressTest/main.cpp +++ b/tests/auto/qtcpsocket/stressTest/main.cpp @@ -56,14 +56,8 @@ int main(int argc, char **argv) type = Test::Qt4Client; else if (arg == QLatin1String("qt4server")) type = Test::Qt4Server; -#ifdef QT3_SUPPORT - else if (arg == QLatin1String("qt3client")) - type = Test::Qt3Client; - else if (arg == QLatin1String("qt3server")) - type = Test::Qt3Server; -#endif else { - qDebug("usage: ./stressTest "); + qDebug("usage: ./stressTest "); return 0; } diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index f83c4cf99c..2e664935be 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -2167,20 +2167,12 @@ void tst_QTcpSocket::suddenRemoteDisconnect_data() QTest::addColumn("client"); QTest::addColumn("server"); -#ifdef QT3_SUPPORT - QTest::newRow("Qt3 Client <-> Qt3 Server") << QString::fromLatin1("qt3client") << QString::fromLatin1("qt3server"); - QTest::newRow("Qt3 Client <-> Qt4 Server") << QString::fromLatin1("qt3client") << QString::fromLatin1("qt4server"); - QTest::newRow("Qt4 Client <-> Qt3 Server") << QString::fromLatin1("qt4client") << QString::fromLatin1("qt3server"); -#endif - QTest::newRow("Qt4 Client <-> Qt4 Server") << QString::fromLatin1("qt4client") << QString::fromLatin1("qt4server"); } void tst_QTcpSocket::suddenRemoteDisconnect() { -#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS) - QSKIP("stressTest subprocess needs Qt3Support", SkipAll); -#elif defined( Q_OS_SYMBIAN ) +#if defined( Q_OS_SYMBIAN ) QSKIP("Symbian: QProcess IO is not yet supported, fix when supported", SkipAll); #else QFETCH(QString, client); diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 6b9a541bf2..5c1ba114f4 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -76,7 +76,6 @@ Q_DECLARE_METATYPE(QList); #if defined(Q_OS_SYMBIAN) # define SRCDIR "" -#undef QT3_SUPPORT #endif @@ -134,9 +133,6 @@ private slots: void mergeCurrentBlockCharFormat(); void emptyAppend(); void appendOnEmptyDocumentShouldReuseInitialParagraph(); -#ifdef QT3_SUPPORT - void textSemantics(); -#endif void cursorPositionChanged(); void setTextCursor(); #ifndef QT_NO_CLIPBOARD @@ -705,19 +701,6 @@ void tst_QTextEdit::appendOnEmptyDocumentShouldReuseInitialParagraph() QCOMPARE(blockCount(), 1); } -#ifdef QT3_SUPPORT -void tst_QTextEdit::textSemantics() -{ - ed->setTextFormat(Qt::AutoText); - - ed->setPlainText("Hello World"); - QVERIFY(!Qt::mightBeRichText(ed->text())); - - ed->setHtml("Hey"); - QVERIFY(Qt::mightBeRichText(ed->text())); -} -#endif - class CursorPositionChangedRecorder : public QObject { Q_OBJECT diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index 2d7c24d238..8ffab143c2 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -243,45 +243,6 @@ private slots: void generateBOM(); void readBomSeekBackReadBomAgain(); - // old tests -#ifdef QT3_SUPPORT - void qt3_operator_shiftleft_data(); - void qt3_operator_shiftleft(); - void qt3_operator_shiftright_data(); - void qt3_operator_shiftright(); - void qt3_operator_shift_QChar_data(); - void qt3_operator_shift_QChar(); - void qt3_operator_shift_char_data(); - void qt3_operator_shift_char(); - void qt3_operator_shift_short_data(); - void qt3_operator_shift_short(); - void qt3_operator_shift_ushort_data(); - void qt3_operator_shift_ushort(); - void qt3_operator_shift_int_data(); - void qt3_operator_shift_int(); - void qt3_operator_shift_uint_data(); - void qt3_operator_shift_uint(); - void qt3_operator_shift_long_data(); - void qt3_operator_shift_long(); - void qt3_operator_shift_ulong_data(); - void qt3_operator_shift_ulong(); - void qt3_operator_shift_float_data(); - void qt3_operator_shift_float(); - void qt3_operator_shift_double_data(); - void qt3_operator_shift_double(); - void qt3_operator_shift_QString_data(); - void qt3_operator_shift_QString(); - void qt3_operator_shift_QByteArray_data(); - void qt3_operator_shift_QByteArray(); - - void qt3_writeDataToFileReadAsLines_data(); - void qt3_writeDataToFileReadAsLines(); - void qt3_writeDataToQStringReadAsLines_data(); - void qt3_writeDataToQStringReadAsLines(); - - void qt3_readLineFromString(); -#endif - // task-specific tests void task180679_alignAccountingStyle(); void task178772_setCodec(); @@ -294,54 +255,6 @@ private: void generateRealNumbersData(bool for_QString); void generateStringData(bool for_QString); void generateRealNumbersDataWrite(); - - // Qt 3 privates -#ifdef QT3_SUPPORT - void qt3_createWriteStream( QTextStream *&os ); - void qt3_closeWriteStream( QTextStream *os ); - void qt3_createReadStream( QTextStream *&is ); - void qt3_closeReadStream( QTextStream *is ); - void qt3_read_QChar( QTextStream *s ); - void qt3_write_QChar( QTextStream *s ); - void qt3_read_char( QTextStream *s ); - void qt3_write_char( QTextStream *s ); - void qt3_read_short( QTextStream *s ); - void qt3_write_short( QTextStream *s ); - void qt3_read_ushort( QTextStream *s ); - void qt3_write_ushort( QTextStream *s ); - void qt3_read_int( QTextStream *s ); - void qt3_write_int( QTextStream *s ); - void qt3_read_uint( QTextStream *s ); - void qt3_write_uint( QTextStream *s ); - void qt3_read_long( QTextStream *s ); - void qt3_write_long( QTextStream *s ); - void qt3_read_ulong( QTextStream *s ); - void qt3_write_ulong( QTextStream *s ); - void qt3_read_float( QTextStream *s ); - void qt3_write_float( QTextStream *s ); - void qt3_read_double( QTextStream *s ); - void qt3_write_double( QTextStream *s ); - void qt3_read_QString( QTextStream *s ); - void qt3_write_QString( QTextStream *s ); - void qt3_read_QByteArray( QTextStream *s ); - void qt3_write_QByteArray( QTextStream *s ); - void qt3_operatorShift_data( QIODevice::OpenMode ); - void qt3_do_shiftleft( QTextStream *ts ); - QTextStream::Encoding qt3_toEncoding( const QString& ); - QString qt3_decodeString( QByteArray array, const QString& encoding ); -#endif - - // Qt 3 data - QTextStream *os; - QTextStream *is; - QTextStream *ts; - QFile *inFile; - QFile *inResource; - QFile *outFile; - QByteArray *inArray; - QBuffer *inBuffer; - QString *inString; - bool file_is_empty; }; // Testing get/set functions @@ -465,18 +378,6 @@ void tst_QTextStream::getSetCheck() tst_QTextStream::tst_QTextStream() { - // Initialize Qt 3 data - ts = 0; - os = 0; - is = 0; - outFile = 0; - inFile = 0; - inResource = 0; - inArray = 0; - inBuffer = 0; - inString = 0; - file_is_empty = FALSE; - Q_SET_DEFAULT_IAP } @@ -486,41 +387,10 @@ tst_QTextStream::~tst_QTextStream() void tst_QTextStream::init() { - // Initialize Qt 3 data - ts = 0; - os = 0; - is = 0; - inFile = 0; - inResource = 0; - outFile = 0; - inArray = 0; - inBuffer = 0; - inString = 0; - file_is_empty = FALSE; } void tst_QTextStream::cleanup() { - // Clean up Qt 3 data - delete ts; - ts = 0; - delete os; - os = 0; - delete is; - is = 0; - delete inResource; - inResource = 0; - delete inFile; - inFile = 0; - delete outFile; - outFile = 0; - delete inArray; - inArray = 0; - delete inBuffer; - inBuffer = 0; - delete inString; - inString = 0; - QCoreApplication::instance()->processEvents(); } @@ -2724,1416 +2594,6 @@ void tst_QTextStream::readBomSeekBackReadBomAgain() QCOMPARE(Andreas, QString("Andreas")); } -// ------------------------------------------------------------------------------ -// QT 3 tests -// ------------------------------------------------------------------------------ -#ifdef QT3_SUPPORT - -void tst_QTextStream::qt3_readLineFromString() -{ - QString data = "line 1e\nline 2e\nline 3e"; - QStringList list; - QTextStream stream(&data, QIODevice::ReadOnly); - stream.setCodec(QTextCodec::codecForName("ISO-8859-1")); - stream.setAutoDetectUnicode(true); - - while (!stream.atEnd()) { - QString line = stream.readLine(); - QCOMPARE(QChar(line[line.size()-1]), QChar('e')); - list << line; - } - QVERIFY(list.count() == 3); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shiftright_data() -{ - qt3_operatorShift_data( QIODevice::ReadOnly ); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shiftleft_data() -{ - qt3_operatorShift_data( QIODevice::WriteOnly ); -} - -static const double doubleDummy = 567.89; -static const int intDummy = 1234; -static const QString stringDummy = "ABCD"; - -struct tst_IODevice { - char *n; - QIODevice::OpenModeFlag modes; - QString name() const { return QString::fromLatin1(n); } -} devices[] = { - { "file", QIODevice::ReadWrite }, - { "bytearray", QIODevice::ReadWrite }, - { "buffer", QIODevice::ReadWrite }, - { "string", QIODevice::ReadWrite }, - { "resource", QIODevice::ReadOnly }, //See discussion (resources) below - { 0, (QIODevice::OpenModeFlag)0 } -}; - -/* Resources: - - This will test QTextStream's ability to interact with resources, - however the trouble is the resources must be created correctly and - built into the executable (but this executable also creates the - resource files). So there is a chicken and egg problem, to create - resources (if the file formats change at all): - - 1) p4 edit resources/... - - 2) Change QIODevice::ReadOnly above in the devices[] for "resource" - to QIODevice::WriteOnly - - 3) run the test - - 4) revert this file, qmake, make, and run again. - - 5) Enjoy. -*/ - -static inline QString resourceDir() -{ - QString ret = "resources/"; - if(QSysInfo::ByteOrder == QSysInfo::BigEndian) - ret += "big_endian/"; - else - ret += "little_endian/"; - return ret; -} - -static const char *const encodings[] = { - "Locale", - "Latin1", - "Unicode", - "UnicodeNetworkOrder", - "UnicodeReverse", - "RawUnicode", - "UnicodeUTF8", - 0 -}; - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operatorShift_data( QIODevice::OpenMode mode ) -{ - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("type"); - QTest::addColumn("doubleVal"); - QTest::addColumn("intVal"); - QTest::addColumn("stringVal"); - QTest::addColumn("encoded"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - if(!(device->modes & mode)) - continue; - - /* - We first test each type at least once. - */ - QTest::newRow( device->name() + "0" ) << device->name() << QString("UnicodeUTF8") << QString("QChar") - << doubleDummy << (int) 'Z' << stringDummy - << QByteArray( QByteArray("Z") ); - QTest::newRow( device->name() + "1" ) << device->name() << QString("UnicodeUTF8") << QString("char") - << doubleDummy << (int) 'Z' << stringDummy - << QByteArray( QByteArray("Z") ); - QTest::newRow( device->name() + "2" ) << device->name() << QString("UnicodeUTF8") << QString("signed short") - << doubleDummy << 12345 << stringDummy - << QByteArray( QByteArray("12345") ); - QTest::newRow( device->name() + "3" ) << device->name() << QString("UnicodeUTF8") << QString("unsigned short") - << doubleDummy << 12345 << stringDummy - << QByteArray( QByteArray("12345") ); - QTest::newRow( device->name() + "4" ) << device->name() << QString("UnicodeUTF8") << QString("signed int") - << doubleDummy << 12345 << stringDummy - << QByteArray( QByteArray("12345") ); - QTest::newRow( device->name() + "5" ) << device->name() << QString("UnicodeUTF8") << QString("unsigned int") - << doubleDummy << 12345 << stringDummy - << QByteArray( QByteArray("12345") ); - QTest::newRow( device->name() + "6" ) << device->name() << QString("UnicodeUTF8") << QString("signed long") - << doubleDummy << 12345 << stringDummy - << QByteArray( QByteArray("12345") ); - QTest::newRow( device->name() + "7" ) << device->name() << QString("UnicodeUTF8") << QString("unsigned long") - << doubleDummy << 12345 << stringDummy - << QByteArray( QByteArray("12345") ); - QTest::newRow( device->name() + "8" ) << device->name() << QString("UnicodeUTF8") << QString("float") - << (double)3.1415f << intDummy << stringDummy - << QByteArray( QByteArray("3.1415") ); - QTest::newRow( device->name() + "9" ) << device->name() << QString("UnicodeUTF8") << QString("double") - << 3.1415 << intDummy << stringDummy - << QByteArray( QByteArray("3.1415") ); - QTest::newRow( device->name() + "10" ) << device->name() << QString("UnicodeUTF8") << QString("char *") - << doubleDummy << intDummy << QString("I-am-a-string") - << QByteArray( QByteArray("I-am-a-string") ); - QTest::newRow( device->name() + "11" ) << device->name() << QString("UnicodeUTF8") << QString("QString") - << doubleDummy << intDummy << QString("I-am-a-string") - << QByteArray( QByteArray("I-am-a-string") ); - QTest::newRow( device->name() + "12" ) << device->name() << QString("UnicodeUTF8") << QString("QByteArray") - << doubleDummy << intDummy << QString("I-am-a-string") - << QByteArray( QByteArray("I-am-a-string") ); - - /* - Then we test some special cases that have caused problems in the past. - */ - QTest::newRow( device->name() + "20" ) << device->name() << QString("UnicodeUTF8") << QString("QChar") - << doubleDummy << 0xff8c << stringDummy - << QByteArray( QByteArray("\xef\xbe\x8c") ); - QTest::newRow( device->name() + "21" ) << device->name() << QString("UnicodeUTF8") << QString("QChar") - << doubleDummy << 0x8cff << stringDummy - << QByteArray( QByteArray("\xe8\xb3\xbf") ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_do_shiftleft( QTextStream *ts ) -{ - QFETCH( QString, encoding ); - QFETCH( QString, type ); - QFETCH( double, doubleVal ); - QFETCH( int, intVal ); - QFETCH( QString, stringVal ); - - ts->setEncoding( qt3_toEncoding(encoding) ); - - if ( type == "QChar" ) { - if ( intVal >= 0 && intVal <= 0xffff ) - *ts << QChar( intVal ); - } else if ( type == "char" ) { - *ts << (char) intVal; - } else if ( type == "signed short" ) { - *ts << (signed short) intVal; - } else if ( type == "unsigned short" ) { - *ts << (unsigned short) intVal; - } else if ( type == "signed int" ) { - *ts << (signed int) intVal; - } else if ( type == "unsigned int" ) { - *ts << (unsigned int) intVal; - } else if ( type == "signed long" ) { - *ts << (signed long) intVal; - } else if ( type == "unsigned long" ) { - *ts << (unsigned long) intVal; - } else if ( type == "float" ) { - *ts << (float) doubleVal; - } else if ( type == "double" ) { - *ts << (double) doubleVal; - } else if ( type == "char *" ) { - *ts << stringVal.latin1(); - } else if ( type == "QString" ) { - *ts << stringVal; - } else if ( type == "QByteArray" ) { - *ts << QByteArray( stringVal.latin1() ); - } else { - QWARN( "Unknown type: %s" + type ); - } - - ts->flush(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shiftleft() -{ - QFETCH( QString, device ); - QFETCH( QString, encoding ); - QFETCH( QByteArray, encoded ); - - if ( device == "file" ) { - QFile outFile( "qtextstream.out" ); - QVERIFY( outFile.open( QIODevice::WriteOnly ) ); - QTextStream ts( &outFile ); - - qt3_do_shiftleft( &ts ); - outFile.close(); - - QFile inFile( "qtextstream.out" ); - QVERIFY( inFile.open( QIODevice::ReadOnly ) ); - QCOMPARE( inFile.readAll().constData(), encoded.constData() ); - } else if(device == "resource" ) { //ONLY TO CREATE THE RESOURCE!! NOT A TEST! - QFile outFile( resourceDir() + "operator_shiftright_" + QTest::currentDataTag() + ".data" ); - QVERIFY( outFile.open( QIODevice::WriteOnly ) ); - QTextStream ts( &outFile ); - qt3_do_shiftleft( &ts ); - outFile.close(); - } else if ( device == "bytearray" ) { - QByteArray outArray; - QTextStream ts(&outArray, QIODevice::WriteOnly ); - - qt3_do_shiftleft( &ts ); - - QVERIFY( outArray == encoded ); - } else if ( device == "buffer" ) { - QByteArray outArray; - QBuffer outBuffer(&outArray); - QVERIFY( outBuffer.open(QIODevice::WriteOnly) ); - QTextStream ts( &outBuffer ); - - qt3_do_shiftleft( &ts ); - - QCOMPARE( outArray, encoded ); - } else if ( device == "string" ) { - QString outString; - QTextStream ts( &outString, QIODevice::WriteOnly ); - - qt3_do_shiftleft( &ts ); - - QString decodedString = qt3_decodeString( encoded, encoding ); - QCOMPARE( outString, decodedString ); - } else { - QWARN( "Unknown device type: " + device ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shiftright() -{ - QFETCH( QString, device ); - QFETCH( QString, encoding ); - QFETCH( QString, type ); - QFETCH( double, doubleVal ); - QFETCH( int, intVal ); - QFETCH( QString, stringVal ); - QFETCH( QByteArray, encoded ); - - if ( device == "file" ) { - QFile outFile( "qtextstream.out" ); - QVERIFY( outFile.open( QIODevice::WriteOnly ) ); - QVERIFY( (int) outFile.write(encoded) == (int) encoded.size() ); - outFile.close(); - - inFile = new QFile( "qtextstream.out" ); - QVERIFY( inFile->open( QIODevice::ReadOnly ) ); - ts = new QTextStream( inFile ); - } else if(device == "resource" ) { - inResource = new QFile( ":/tst_textstream/" + resourceDir() + "operator_shiftright_" + QTest::currentDataTag() + ".data" ); - QVERIFY( inResource->open( QIODevice::ReadOnly ) ); - ts = new QTextStream( inResource ); - } else if ( device == "bytearray" ) { - ts = new QTextStream(&encoded, QIODevice::ReadOnly); - } else if ( device == "buffer" ) { - inBuffer = new QBuffer(&encoded); - QVERIFY( inBuffer->open(QIODevice::ReadOnly) ); - ts = new QTextStream( inBuffer ); - } else if ( device == "string" ) { - inString = new QString( qt3_decodeString(encoded, encoding) ); - ts = new QTextStream(inString, QIODevice::ReadOnly); - } else { - QWARN( "Unknown device type: " + device ); - } - - ts->setEncoding( qt3_toEncoding(encoding) ); - - if ( type == "QChar" ) { - QChar c; - if ( intVal >= 0 && intVal <= 0xffff ) - *ts >> c; - QCOMPARE( c.toLatin1(), QChar(intVal).toLatin1() ); - } else if ( type == "char" ) { - char c; - *ts >> c; - QCOMPARE( c, (char) intVal ); - } else if ( type == "signed short" ) { - signed short h; - *ts >> h; - QCOMPARE( h, (signed short) intVal ); - } else if ( type == "unsigned short" ) { - unsigned short h; - *ts >> h; - QCOMPARE( h, (unsigned short) intVal ); - } else if ( type == "signed int" ) { - signed int i; - *ts >> i; - QCOMPARE( i, (signed int) intVal ); - } else if ( type == "unsigned int" ) { - unsigned int i; - *ts >> i; - QCOMPARE( i, (unsigned int) intVal ); - } else if ( type == "signed long" ) { - signed long ell; - *ts >> ell; - QCOMPARE( ell, (signed long) intVal ); - } else if ( type == "unsigned long" ) { - unsigned long ell; - *ts >> ell; - QCOMPARE( ell, (unsigned long) intVal ); - } else if ( type == "float" ) { - float f; - *ts >> f; - QCOMPARE( f, (float) doubleVal ); - } else if ( type == "double" ) { - double d; - *ts >> d; - QCOMPARE( d, (double) doubleVal ); - } else if ( type == "char *" ) { - char *cp = new char[2048]; - *ts >> cp; - QVERIFY( qstrcmp(cp, stringVal.latin1()) == 0 ); - delete[] cp; - } else if ( type == "QString" ) { - QString s; - *ts >> s; - QCOMPARE( s, stringVal ); - } else if ( type == "QByteArray" ) { - QByteArray s; - *ts >> s; - QCOMPARE( QString::fromLatin1(s), stringVal ); - } else { - QWARN( "Unknown type: %s" + type ); - } -} - -// ------------------------------------------------------------------------------ -QTextStream::Encoding tst_QTextStream::qt3_toEncoding( const QString &str ) -{ - if ( str == "Locale" ) - return QTextStream::Locale; - else if ( str == "Latin1" ) - return QTextStream::Latin1; - else if ( str == "Unicode" ) - return QTextStream::Unicode; - else if ( str == "UnicodeNetworkOrder" ) - return QTextStream::UnicodeNetworkOrder; - else if ( str == "UnicodeReverse" ) - return QTextStream::UnicodeReverse; - else if ( str == "RawUnicode" ) - return QTextStream::RawUnicode; - else if ( str == "UnicodeUTF8" ) - return QTextStream::UnicodeUTF8; - - QWARN( "No such encoding " + str ); - return QTextStream::Latin1; -} - -// ------------------------------------------------------------------------------ -QString tst_QTextStream::qt3_decodeString( QByteArray array, const QString& encoding ) -{ - switch ( qt3_toEncoding(encoding) ) { - case QTextStream::Locale: - return QString::fromLocal8Bit( array.data(), array.size() ); - case QTextStream::Latin1: - return QString::fromLatin1( array.data(), array.size() ); - case QTextStream::Unicode: - case QTextStream::UnicodeNetworkOrder: - case QTextStream::UnicodeReverse: - case QTextStream::RawUnicode: - QWARN( "Unicode not implemented ###" ); - return QString(); - case QTextStream::UnicodeUTF8: - return QString::fromUtf8( array.data(), array.size() ); - default: - QWARN( "Unhandled encoding" ); - return QString(); - } -} - -// ************************************************ - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_createWriteStream( QTextStream *&os ) -{ - QFETCH( QString, device ); - - if ( device == "file" ) { - outFile = new QFile( "qtextstream.out" ); - QVERIFY( outFile->open( QIODevice::WriteOnly ) ); - os = new QTextStream( outFile ); - os->setCodec(QTextCodec::codecForName("ISO-8859-1")); - os->setAutoDetectUnicode(true); - } else if(device == "resource" ) { //ONLY TO CREATE THE RESOURCE!! NOT A TEST! - outFile = new QFile( resourceDir() + - QTest::currentTestFunction() + - "_" + QTest::currentDataTag() + ".data" ); - QVERIFY( outFile->open( QIODevice::WriteOnly ) ); - os = new QTextStream( outFile ); - os->setCodec(QTextCodec::codecForName("ISO-8859-1")); - os->setAutoDetectUnicode(true); - } else if ( device == "bytearray" ) { - inArray = new QByteArray; - os = new QTextStream(inArray, QIODevice::WriteOnly); - os->setCodec(QTextCodec::codecForName("ISO-8859-1")); - os->setAutoDetectUnicode(true); - } else if ( device == "buffer" ) { - inBuffer = new QBuffer; - QVERIFY( inBuffer->open(QIODevice::WriteOnly) ); - os = new QTextStream( inBuffer ); - os->setCodec(QTextCodec::codecForName("ISO-8859-1")); - os->setAutoDetectUnicode(true); - } else if ( device == "string" ) { - inString = new QString; - os = new QTextStream( inString, QIODevice::WriteOnly ); - os->setCodec(QTextCodec::codecForName("ISO-8859-1")); - os->setAutoDetectUnicode(true); - } else { - QWARN( "Error creating write stream: Unknown device type '" + device + "'" ); - } - - QFETCH( QString, encoding ); - os->setEncoding( qt3_toEncoding( encoding )); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_closeWriteStream( QTextStream *os ) -{ - QFETCH( QString, device ); - - os->flush(); - if ( os->device() ) - os->device()->close(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_createReadStream( QTextStream *&is ) -{ - QFETCH( QString, device ); - - if ( device == "file" ) { - inFile = new QFile( "qtextstream.out" ); - is = new QTextStream( inFile ); - is->setCodec(QTextCodec::codecForName("ISO-8859-1")); - is->setAutoDetectUnicode(true); - QVERIFY( inFile->open( QIODevice::ReadOnly ) ); - } else if(device == "resource") { - inResource = new QFile( ":/tst_textstream/" + resourceDir() + - QTest::currentTestFunction() + - "_" + QTest::currentDataTag() + ".data" ); - is = new QTextStream( inResource ); - is->setCodec(QTextCodec::codecForName("ISO-8859-1")); - is->setAutoDetectUnicode(true); - QVERIFY( inResource->open( QIODevice::ReadOnly ) ); - } else if ( device == "bytearray" ) { - is = new QTextStream(inArray, QIODevice::ReadOnly); - is->setCodec(QTextCodec::codecForName("ISO-8859-1")); - is->setAutoDetectUnicode(true); - } else if ( device == "buffer" ) { - QVERIFY( inBuffer->open(QIODevice::ReadOnly) ); - is = new QTextStream( inBuffer ); - is->setCodec(QTextCodec::codecForName("ISO-8859-1")); - is->setAutoDetectUnicode(true); - } else if ( device == "string" ) { - is = new QTextStream( inString, QIODevice::ReadOnly ); - is->setCodec(QTextCodec::codecForName("ISO-8859-1")); - is->setAutoDetectUnicode(true); - } else { - QWARN( "Error creating read stream: Unknown device type '" + device + "'" ); - } - - QFETCH( QString, encoding ); - is->setEncoding( qt3_toEncoding( encoding )); - - if (!file_is_empty) { - QVERIFY( !is->atEnd() ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_closeReadStream( QTextStream *is ) -{ - QVERIFY( is->atEnd() ); - - if ( is->device() ) - is->device()->close(); -} - -// **************** QChar **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_QChar_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("qchar"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << QChar( 'A' ).unicode(); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << QChar( 'B' ).unicode(); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << QChar( 'Z' ).unicode(); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << QChar( 'z' ).unicode(); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << QChar( '@' ).unicode(); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_QChar() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_QChar( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_QChar( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_QChar( QTextStream *s ) -{ - QFETCH( ushort, qchar ); - QChar expected( qchar ); - QChar actual; - *s >> actual; - QCOMPARE( actual, expected ); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_QChar( QTextStream *s ) -{ - QFETCH( ushort, qchar ); - QChar actual( qchar ); - *s << actual; -} - -// **************** char **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_char_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("ch"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << int('A'); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << int('B'); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << int('Z'); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << int(14); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << int('0'); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_char() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_char( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_char( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_char( QTextStream *s ) -{ - QFETCH( int, ch ); - char c(ch); - char exp; - *s >> exp; - QCOMPARE( exp, c ); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_char( QTextStream *s ) -{ - QFETCH( int, ch ); - char c(ch); - *s << c; -} - -// **************** short **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_short_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("ss"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << short(0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << short(-1); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << short(1); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << short(255); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << short(-254); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_short() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_short( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_short( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_short( QTextStream *s ) -{ - QFETCH( short, ss ); - short exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, ss ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_short( QTextStream *s ) -{ - QFETCH( short, ss ); - *s << " A " << ss << " B "; -} - -// **************** ushort **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_ushort_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("us"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << ushort(0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << ushort(1); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << ushort(10); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << ushort(255); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << ushort(512); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_ushort() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_ushort( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_ushort( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_ushort( QTextStream *s ) -{ - QFETCH( ushort, us ); - ushort exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, us ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_ushort( QTextStream *s ) -{ - QFETCH( ushort, us ); - *s << " A " << us << " B "; -} - -// **************** int **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_int_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("si"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << int(0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << int(1); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << int(10); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << int(255); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << int(512); - QTest::newRow( tag + "5" ) << device->modes << device->name() << encoding << int(-1); - QTest::newRow( tag + "6" ) << device->modes << device->name() << encoding << int(-10); - QTest::newRow( tag + "7" ) << device->modes << device->name() << encoding << int(-255); - QTest::newRow( tag + "8" ) << device->modes << device->name() << encoding << int(-512); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_int() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_int( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_int( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_int( QTextStream *s ) -{ - QFETCH( int, si ); - int exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, si ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_int( QTextStream *s ) -{ - QFETCH( int, si ); - *s << " A " << si << " B "; -} - -// **************** uint **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_uint_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("ui"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << uint(0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << uint(1); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << uint(10); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << uint(255); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << uint(512); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_uint() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_uint( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_uint( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_uint( QTextStream *s ) -{ - QFETCH( uint, ui ); - uint exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, ui ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_uint( QTextStream *s ) -{ - QFETCH( uint, ui ); - *s << " A " << ui << " B "; -} - -// **************** long **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_long_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("sl"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << long(0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << long(1); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << long(10); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << long(255); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << long(65535); - QTest::newRow( tag + "5" ) << device->modes << device->name() << encoding << long(-1); - QTest::newRow( tag + "6" ) << device->modes << device->name() << encoding << long(-10); - QTest::newRow( tag + "7" ) << device->modes << device->name() << encoding << long(-255); - QTest::newRow( tag + "8" ) << device->modes << device->name() << encoding << long(-65534); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_long() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_long( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_long( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_long( QTextStream *s ) -{ - QFETCH( long, sl ); - long exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, sl ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_long( QTextStream *s ) -{ - QFETCH( long, sl ); - *s << " A " << sl << " B "; -} - -// **************** long **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_ulong_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("ul"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << ulong(0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << ulong(1); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << ulong(10); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << ulong(255); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << ulong(65535); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_ulong() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_ulong( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_ulong( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_ulong( QTextStream *s ) -{ - QFETCH( ulong, ul ); - ulong exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, ul ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_ulong( QTextStream *s ) -{ - QFETCH( ulong, ul ); - *s << " A " << ul << " B "; -} - -// **************** float **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_float_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("f"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << float(0.0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << float(0.0001); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << float(-0.0001); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << float(3.45678); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << float(-3.45678); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_float() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_float( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_float( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_float( QTextStream *s ) -{ - QFETCH( float, f ); - float exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, f ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_float( QTextStream *s ) -{ - QFETCH( float, f ); - *s << " A " << f << " B "; -} - -// **************** double **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_double_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("d"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << double(0.0); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << double(0.0001); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << double(-0.0001); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << double(3.45678); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << double(-3.45678); - QTest::newRow( tag + "5" ) << device->modes << device->name() << encoding << double(1.23456789); - QTest::newRow( tag + "6" ) << device->modes << device->name() << encoding << double(-1.23456789); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_double() -{ - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - os->precision( 10 ); - qt3_write_double( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - is->precision( 10 ); - qt3_read_double( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_double( QTextStream *s ) -{ - QFETCH( double, d ); - double exp; - QString A, B; - *s >> A >> exp >> B; - QCOMPARE( A, QString("A") ); - QCOMPARE( B, QString("B") ); - QCOMPARE( exp, d ); - s->skipWhiteSpace(); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_double( QTextStream *s ) -{ - QFETCH( double, d ); - *s << " A " << d << " B "; -} - -// **************** QString **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_QString_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("str"); - QTest::addColumn("multi_str"); - QTest::addColumn("zero_length"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << QString("") << bool(FALSE) << bool(TRUE); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << QString() << bool(FALSE) << bool(TRUE); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << QString("foo") << bool(FALSE) << bool(FALSE); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << QString("foo\nbar") << bool(TRUE) << bool(FALSE); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << QString("cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv") << bool(TRUE) << bool(FALSE); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_QString() -{ - QFETCH( bool, zero_length ); - file_is_empty = zero_length; - - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_QString( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_QString( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_QString( QTextStream *s ) -{ - QString exp; - QFETCH( QString, str ); - if (str.isNull()) - str = ""; - - QFETCH( bool, multi_str ); - if (!multi_str) { - *s >> exp; - QCOMPARE( exp, str ); - } else { - QStringList l; - l = QStringList::split( " ", str ); - if (l.count() < 2) - l = QStringList::split( "\n", str ); - for (int i=0; i> exp; - QCOMPARE( exp, l[i] ); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_QString( QTextStream *s ) -{ - QFETCH( QString, str ); - *s << str; -} - -// **************** QByteArray **************** - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_QByteArray_data() -{ - QTest::addColumn("modes"); - QTest::addColumn("device"); - QTest::addColumn("encoding"); - QTest::addColumn("cs"); - QTest::addColumn("multi_str"); - QTest::addColumn("zero_length"); - - for ( int i=0; !devices[i].name().isNull(); i++ ) { - tst_IODevice *device = devices+i; - for ( int e=0; encodings[e] != 0; e++ ) { - QString encoding = encodings[e]; - - QString tag = device->name() + "_" + encoding + "_"; - QTest::newRow( tag + "0" ) << device->modes << device->name() << encoding << QByteArray("") << bool(FALSE) << bool(TRUE); - QTest::newRow( tag + "1" ) << device->modes << device->name() << encoding << QByteArray(0) << bool(FALSE) << bool(TRUE); - QTest::newRow( tag + "2" ) << device->modes << device->name() << encoding << QByteArray("foo") << bool(FALSE) << bool(FALSE); - QTest::newRow( tag + "3" ) << device->modes << device->name() << encoding << QByteArray("foo\nbar") << bool(TRUE) << bool(FALSE); - QTest::newRow( tag + "4" ) << device->modes << device->name() << encoding << QByteArray("cjacka ckha cka ckah ckac kahckadhcbkgdk vkzdfbvajef vkahv") << bool(TRUE) << bool(FALSE); - } - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_operator_shift_QByteArray() -{ - QFETCH( bool, zero_length ); - file_is_empty = zero_length; - - QFETCH( int, modes ); - if(modes & QIODevice::WriteOnly) { - qt3_createWriteStream( os ); - qt3_write_QByteArray( os ); - qt3_closeWriteStream( os ); - } - if(modes & QIODevice::ReadOnly) { - qt3_createReadStream( is ); - qt3_read_QByteArray( is ); - qt3_closeReadStream( is ); - } -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_read_QByteArray( QTextStream *s ) -{ -/* - QFETCH( QByteArray, cs ); - QByteArray exp; - *s >> exp; - QCOMPARE( exp, cs ); -*/ - QByteArray exp; - QFETCH( QByteArray, cs ); - if (cs.isNull()) - cs = ""; - - QFETCH( bool, multi_str ); - if (!multi_str) { - *s >> exp; - QCOMPARE( exp.constData(), cs.constData() ); - } else { - QStringList l; - l = QStringList::split( " ", cs ); - if (l.count() < 2) - l = QStringList::split( "\n", cs ); - for (int i=0; i> exp; - QCOMPARE( exp, QByteArray(l[i].toAscii()) ); - } - } -} - -// ------------------------------------------------------------------------------ -static void qt3_generateLineData( bool for_QString ) -{ - QTest::addColumn("input"); - QTest::addColumn("output"); - - QTest::newRow("emptyer") << QByteArray() << QStringList(); - QTest::newRow("lf") << QByteArray("\n") << (QStringList() << ""); - QTest::newRow("crlf") << QByteArray("\r\n") << (QStringList() << ""); - QTest::newRow("oneline/nothing") << QByteArray("ole") << (QStringList() << "ole"); - QTest::newRow("oneline/lf") << QByteArray("ole\n") << (QStringList() << "ole"); - QTest::newRow("oneline/crlf") << QByteArray("ole\r\n") << (QStringList() << "ole"); - QTest::newRow("twolines/lf/lf") << QByteArray("ole\ndole\n") << (QStringList() << "ole" << "dole"); - QTest::newRow("twolines/crlf/crlf") << QByteArray("ole\r\ndole\r\n") << (QStringList() << "ole" << "dole"); - QTest::newRow("twolines/lf/crlf") << QByteArray("ole\ndole\r\n") << (QStringList() << "ole" << "dole"); - QTest::newRow("twolines/lf/nothing") << QByteArray("ole\ndole") << (QStringList() << "ole" << "dole"); - QTest::newRow("twolines/crlf/nothing") << QByteArray("ole\r\ndole") << (QStringList() << "ole" << "dole"); - QTest::newRow("threelines/lf/lf/lf") << QByteArray("ole\ndole\ndoffen\n") << (QStringList() << "ole" << "dole" << "doffen"); - QTest::newRow("threelines/crlf/crlf/crlf") << QByteArray("ole\r\ndole\r\ndoffen\r\n") << (QStringList() << "ole" << "dole" << "doffen"); - QTest::newRow("threelines/crlf/crlf/nothing") << QByteArray("ole\r\ndole\r\ndoffen") << (QStringList() << "ole" << "dole" << "doffen"); - - if (!for_QString) { - QTest::newRow("unicode/nothing") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65", 8) << (QStringList() << "\345ge"); - QTest::newRow("unicode-little/nothing") << QByteArray("\xff\xfe\xe5\x00\x67\x00\x65\x00", 8) << (QStringList() << "\345ge"); - QTest::newRow("unicode/lf") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << (QStringList() << "\345ge"); - QTest::newRow("unicode-little/lf") << QByteArray("\xff\xfe\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << (QStringList() << "\345ge"); - - QTest::newRow("unicode/twolines") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0a\x00\xe5\x00\x67\x00\x65\x00\x0a", 18) << (QStringList() << "\345ge" << "\345ge"); - QTest::newRow("unicode-little/twolines") << QByteArray("\xff\xfe\xe5\x00\x67\x00\x65\x00\x0a\x00\xe5\x00\x67\x00\x65\x00\x0a\x00", 18) << (QStringList() << "\345ge" << "\345ge"); - - QTest::newRow("unicode/threelines") - << QByteArray("\xfe\xff" - "\x00\xe5\x00\x67\x00\x65\x00\x0a" - "\x00\xe5\x00\x67\x00\x65\x00\x0a" - "\x00\xe5\x00\x67\x00\x65\x00\x0a", 26) - << (QStringList() << "\345ge" << "\345ge" << "\345ge"); - QTest::newRow("unicode-little/threelines") - << QByteArray("\xff\xfe" - "\xe5\x00\x67\x00\x65\x00\x0a\x00" - "\xe5\x00\x67\x00\x65\x00\x0a\x00" - "\xe5\x00\x67\x00\x65\x00\x0a\x00", 26) - << (QStringList() << "\345ge" << "\345ge" << "\345ge"); - } - - // partials - QTest::newRow("cr") << QByteArray("\r") << (QStringList() << ""); - QTest::newRow("oneline/cr") << QByteArray("ole\r") << (QStringList() << "ole"); - if (!for_QString) - QTest::newRow("unicode/cr") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0d", 10) << (QStringList() << "\345ge"); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_writeDataToFileReadAsLines_data() -{ - qt3_generateLineData(false); -} - -// ------------------------------------------------------------------------------ -QByteArray pretty(const QString &input) -{ - QByteArray data; - - QByteArray arr = input.toLatin1(); - for (int i = 0; i < arr.size(); ++i) { - char buf[64]; - memset(buf, 0, sizeof(buf)); - char ch = arr.at(i); - sprintf(buf, "\\%2hhx", ch); - data += buf; - } - - return data; -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_writeDataToFileReadAsLines() -{ - QFETCH(QByteArray, input); - QFETCH(QStringList, output); - - QFile::remove("eoltest"); - - // Create the file - QFile writer("eoltest"); - QVERIFY2(writer.open(QFile::WriteOnly | QFile::Truncate), ("When creating a file: " + writer.errorString()).latin1()); - QCOMPARE(writer.write(input), qlonglong(input.size())); - writer.close(); - - // Read from it using QTextStream - QVERIFY2(writer.open(QFile::ReadOnly), ("When reading a file: " + writer.errorString()).latin1()); - QTextStream stream(&writer); - QStringList tmp; - - while (!stream.atEnd()) - tmp << stream.readLine(); - - QCOMPARE(tmp, output); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_writeDataToQStringReadAsLines_data() -{ - qt3_generateLineData(true); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_writeDataToQStringReadAsLines() -{ - QFETCH(QByteArray, input); - QFETCH(QStringList, output); - - QString s = input; - QTextStream stream(&s, QIODevice::ReadOnly); - - QStringList tmp; - while (!stream.atEnd()) - tmp << stream.readLine(); - - QCOMPARE(tmp, output); -} - -// ------------------------------------------------------------------------------ -void tst_QTextStream::qt3_write_QByteArray( QTextStream *s ) -{ - QFETCH( QByteArray, cs ); - *s << cs; -} -#endif - // ------------------------------------------------------------------------------ void tst_QTextStream::status_real_read_data() { diff --git a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp index 8495a04ab1..9da319faa2 100644 --- a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp @@ -119,13 +119,6 @@ void tst_QToolButton::getSetCheck() obj1.setDefaultAction((QAction *)0); QCOMPARE((QAction *)0, obj1.defaultAction()); delete var4; - -#ifdef QT_HAS_QT3SUPPORT - //ensure that popup delay is not reset on style change - obj1.setPopupDelay(5); - obj1.setStyle(new QWindowsStyle); - QCOMPARE(obj1.popupDelay(), 5); -#endif } Q_DECLARE_METATYPE(QAction*) diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 336ee36584..053e3b35bb 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -198,10 +198,6 @@ private slots: void task_240612(); void taskQTBUG_6962(); void taskQTBUG_8701(); - -#ifdef QT3_SUPPORT - void dirPath(); -#endif }; // Testing get/set functions @@ -3933,13 +3929,6 @@ void tst_QUrl::task_240612() QCOMPARE(url.toEncoded().constData(), "//example.com/test.txt"); } -#ifdef QT3_SUPPORT -void tst_QUrl::dirPath() -{ - QCOMPARE(QUrl("http://www.vg.no/test/file.txt").dirPath(), QString("/test")); -} -#endif - void tst_QUrl::resolvedWithAbsoluteSchemes() const { QFETCH(QUrl, base); diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 492d0dfc3d..c541119744 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -50,9 +50,6 @@ #include #include #include -#ifdef QT3_SUPPORT -# include -#endif #include #include #include @@ -141,18 +138,12 @@ private slots: void toULongLong_data(); void toULongLong(); - void asType_data(); - void asType(); - void toByteArray_data(); void toByteArray(); void toString_data(); void toString(); - void toCString_data(); - void toCString(); - void toDate_data(); void toDate(); @@ -231,8 +222,6 @@ private slots: void podUserType(); - void nullAsType(); - void data_(); // data is virtual function in QtTestCase void constData(); @@ -243,7 +232,6 @@ private slots: void variantMap(); void variantHash(); - void invalidAsByteArray(); void convertToQUint8() const; void invalidQColor() const; void comparePointers() const; @@ -283,9 +271,6 @@ Q_DECLARE_METATYPE(QDate) Q_DECLARE_METATYPE(QTime) Q_DECLARE_METATYPE(QDateTime) Q_DECLARE_METATYPE(QVariant) -#ifdef QT3_SUPPORT -Q_DECLARE_METATYPE(Q3CString) -#endif const qlonglong intMax1 = (qlonglong)INT_MAX + 1; const qulonglong uintMax1 = (qulonglong)UINT_MAX + 1; @@ -369,9 +354,6 @@ void tst_QVariant::isNull() QVariant varLL( (qlonglong)0 ); QVERIFY( !varLL.isNull() ); QVariant var7(QString::null); -#ifdef QT3_SUPPORT - QCOMPARE(var7.asInt(), 0); -#endif QVERIFY(var7.isNull()); } @@ -442,30 +424,15 @@ void tst_QVariant::canConvert_data() var = qVariantFromValue(QBitmap()); QTest::newRow("Bitmap") << var << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N; -#ifdef QT3_SUPPORT - var = QVariant(true, 0); - QTest::newRow("Bool") - << var << N << N << Y << N << Y << Y << N << N << N << N << N << Y << N << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; -#endif var = qVariantFromValue(QBrush()); QTest::newRow("Brush") << var << N << N << N << Y << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N; var = QVariant(QByteArray()); QTest::newRow("ByteArray") << var << N << N << Y << N << Y << Y << Y << N << N << N << N << Y << N << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; -#ifdef QT3_SUPPORT - var = QVariant(Q3CString("cstring")); - QTest::newRow("CString") - << var << N << N << Y << N << Y << Y << Y << N << N << N << N << Y << N << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; -#endif var = qVariantFromValue(QColor()); QTest::newRow("Color") << var << N << N << N << Y << Y << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; -#ifdef QT3_SUPPORT - var = qVariantFromValue(QColorGroup()); - QTest::newRow("ColorGroup") - << var << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; -#endif #ifndef QT_NO_CURSOR var = qVariantFromValue(QCursor()); QTest::newRow("Cursor") @@ -661,9 +628,6 @@ void tst_QVariant::toInt_data() QTest::newRow( "double" ) << QVariant( 3.1415927 ) << 3 << true; QTest::newRow( "float" ) << QVariant( 3.1415927f ) << 3 << true; QTest::newRow( "uint" ) << QVariant( 123u ) << 123 << true; -#ifdef QT3_SUPPORT - QTest::newRow( "bool" ) << QVariant( true, 42 ) << 1 << true; -#endif QTest::newRow( "int-string" ) << QVariant( QString("123") ) << 123 << true; QTest::newRow( "string" ) << QVariant( QString("Unicode String") ) << 0 << false; QTest::newRow( "longlong0" ) << QVariant( (qlonglong)34 ) << 34 << true; @@ -714,9 +678,6 @@ void tst_QVariant::toUInt_data() QTest::newRow( "double" ) << QVariant( 3.1415927 ) << (uint)3 << true; QTest::newRow( "float" ) << QVariant( 3.1415927f ) << (uint)3 << true; QTest::newRow( "uint" ) << QVariant( 123u ) << (uint)123 << true; -#ifdef QT3_SUPPORT - QTest::newRow( "bool" ) << QVariant( true, 42 ) << (uint)1 << true; -#endif QTest::newRow( "int-string" ) << QVariant( QString("123") ) << (uint)123 << true; QTest::newRow( "string" ) << QVariant( QString("Unicode String") ) << (uint)0 << false; QTest::newRow( "string2" ) << QVariant( QString("4") ) << (uint)4 << true; @@ -911,10 +872,6 @@ void tst_QVariant::toBool_data() QTest::newRow( "float0" ) << QVariant( 0.0f ) << false; QTest::newRow( "double1" ) << QVariant( 3.1415927 ) << true; QTest::newRow( "float1" ) << QVariant( 3.1415927f ) << true; -#ifdef QT3_SUPPORT - QTest::newRow( "bool0" ) << QVariant( false, 42 ) << false; - QTest::newRow( "bool1" ) << QVariant( true, 42 ) << true; -#endif QTest::newRow( "string0" ) << QVariant( QString("3") ) << true; QTest::newRow( "string1" ) << QVariant( QString("true") ) << true; QTest::newRow( "string2" ) << QVariant( QString("0") ) << false; @@ -1142,9 +1099,6 @@ void tst_QVariant::toLongLong_data() QTest::newRow( "double" ) << QVariant( 3.1415927 ) << (qlonglong)3 << true; QTest::newRow( "float" ) << QVariant( 3.1415927f ) << (qlonglong)3 << true; QTest::newRow( "uint" ) << QVariant( 123u ) << (qlonglong)123 << true; -#ifdef QT3_SUPPORT - QTest::newRow( "bool" ) << QVariant( true, 42 ) << (qlonglong)1 << true; -#endif QTest::newRow( "int-string" ) << QVariant( QString("123") ) << (qlonglong)123 << true; QTest::newRow( "string" ) << QVariant( QString("Unicode fun") ) << (qlonglong)0 @@ -1183,9 +1137,6 @@ void tst_QVariant::toULongLong_data() QTest::newRow( "double" ) << QVariant( 3.1415927 ) << (qulonglong)3 << true; QTest::newRow( "float" ) << QVariant( 3.1415927f ) << (qulonglong)3 << true; QTest::newRow( "uint" ) << QVariant( 123u ) << (qulonglong)123 << true; -#ifdef QT3_SUPPORT - QTest::newRow( "bool" ) << QVariant( true, 42 ) << (qulonglong)1 << true; -#endif QTest::newRow( "int-string" ) << QVariant( QString("123") ) << (qulonglong)123 << true; QTest::newRow( "string" ) << QVariant( QString("Unicode fun") ) << (qulonglong)0 @@ -1220,38 +1171,6 @@ void tst_QVariant::toULongLong() QVERIFY( ok == valueOK ); } -void tst_QVariant::asType_data() -{ - QTest::addColumn("value"); - - QTest::newRow( "string" ) << QVariant( QString( "1.0" ) ); -} - -void tst_QVariant::asType() -{ -#ifndef QT3_SUPPORT - QSKIP("Qt compiled without Qt3Support", SkipAll); -#else - QFETCH( QVariant, value ); - QVariant::Type type = value.type(); - - QVariant copy = value; - copy.asDouble(); - QCOMPARE( value.type(), type ); - - copy = value; - copy.asList(); - QCOMPARE( value.type(), type ); - - copy = value; - copy.asMap(); - QCOMPARE( value.type(), type ); - - copy = value; - QCOMPARE( value.type(), type ); -#endif -} - void tst_QVariant::toByteArray_data() { QTest::addColumn("value"); @@ -1297,11 +1216,7 @@ void tst_QVariant::toString_data() QTest::newRow( "uint" ) << QVariant( (uint)123 ) << QString( "123" ); QTest::newRow( "double" ) << QVariant( 123.456 ) << QString( "123.456" ); QTest::newRow( "float" ) << QVariant( 123.456f ) << QString( "123.456" ); -#ifdef QT3_SUPPORT - QTest::newRow( "bool" ) << QVariant( true, 0 ) << QString( "true" ); -#else QTest::newRow( "bool" ) << QVariant( true ) << QString( "true" ); -#endif QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" ); QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" ); QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" ); @@ -1329,32 +1244,6 @@ void tst_QVariant::toString() QCOMPARE( str, result ); } -void tst_QVariant::toCString_data() -{ -#ifdef QT3_SUPPORT - QTest::addColumn("value"); - QTest::addColumn("result"); - - QTest::newRow( "qstring" ) << QVariant( Q3CString( "Test" ) ) << Q3CString( "Test" ); - QTest::newRow( "qcstring") << QVariant( Q3CString( "Test\0" ) ) << Q3CString( "Test" ); -#endif -} - -void tst_QVariant::toCString() -{ -#ifdef QT3_SUPPORT - QFETCH( QVariant, value ); - QFETCH( Q3CString, result ); - QVERIFY( value.isValid() ); - - Q3CString str = value.toCString(); - - QCOMPARE( str, result ); -#else - QSKIP("Qt not build with Qt3Support", SkipAll); -#endif -} - void tst_QVariant::toDate_data() { QTest::addColumn("value"); @@ -1558,14 +1447,8 @@ void tst_QVariant::writeToReadFromDataStream_data() QTest::newRow( "bitmap_valid" ) << qVariantFromValue( bitmap ) << false; QTest::newRow( "brush_valid" ) << qVariantFromValue( QBrush( Qt::red ) ) << false; QTest::newRow( "color_valid" ) << qVariantFromValue( QColor( Qt::red ) ) << false; -#ifdef QT3_SUPPORT - QTest::newRow( "colorgroup_valid" ) << qVariantFromValue(QPalette(QColor("turquoise")).active()) << false; -#endif #ifndef QT_NO_CURSOR QTest::newRow( "cursor_valid" ) << qVariantFromValue( QCursor( Qt::PointingHandCursor ) ) << false; -#endif -#ifdef QT3_SUPPORT - QTest::newRow( "bool_valid" ) << QVariant( true, 0 ) << false; #endif QTest::newRow( "date_invalid" ) << QVariant( QDate() ) << true; QTest::newRow( "date_valid" ) << QVariant( QDate( 2002, 07, 06 ) ) << false; @@ -1578,16 +1461,8 @@ void tst_QVariant::writeToReadFromDataStream_data() QPixmap pixmap( 10, 10 ); pixmap.fill( Qt::red ); QTest::newRow( "pixmap_valid" ) << qVariantFromValue( pixmap ) << false; -#ifdef QT3_SUPPORT - QTest::newRow( "iconset_invalid" ) << qVariantFromValue( QIcon() ) << true; -#endif // QTest::newRow( "iconset_valid" ) << QVariant( QIcon( pixmap ) ) << false; QTest::newRow( "image_invalid" ) << qVariantFromValue( QImage() ) << true; -#ifdef QT3_SUPPORT - QImage image( 10, 10, 32 ); - image.fill( QColor( Qt::red ).pixel() ); - QTest::newRow( "image_valid" ) << qVariantFromValue( image ) << false; -#endif QTest::newRow( "keysequence_valid" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false; QTest::newRow( "int_valid" ) << QVariant( -123 ) << false; typedef QList variantsList; @@ -1616,10 +1491,6 @@ void tst_QVariant::writeToReadFromDataStream_data() QTest::newRow( "size_valid" ) << QVariant( QSize( 10, 10 ) ) << false; QTest::newRow( "string_invalid" ) << QVariant( QString() ) << true; QTest::newRow( "string_valid" ) << QVariant( QString( "Test" ) ) << false; -#ifdef QT3_SUPPORT - QTest::newRow( "cstring_invalid" ) << QVariant( Q3CString() ) << true; - QTest::newRow( "cstring_valid" ) << QVariant( Q3CString( "Test" ) ) << false; -#endif QStringList stringlist; stringlist << "One" << "Two" << "Three"; QTest::newRow( "stringlist_valid" ) << QVariant( stringlist ) << false; @@ -1674,13 +1545,8 @@ void tst_QVariant::writeToReadFromDataStream() // Since only a few won't match since the serial numbers are different // I won't bother adding another bool in the data test. QVariant::Type writeType = writeVariant.type(); -#ifdef QT3_SUPPORT - if ( writeType != QVariant::Invalid && writeType != QVariant::Bitmap && writeType != QVariant::Pixmap - && writeType != QVariant::Image && writeType != QVariant::IconSet ) { -#else if ( writeType != QVariant::Invalid && writeType != QVariant::Bitmap && writeType != QVariant::Pixmap && writeType != QVariant::Image) { -#endif switch (writeType) { default: QCOMPARE( readVariant, writeVariant ); @@ -1805,11 +1671,7 @@ void tst_QVariant::operator_eq_eq_data() QVariant mULongLongString(QByteArray("42")); QVariant mULongLongQString(QString("42")); -#ifdef QT3_SUPPORT - QVariant mBool(false, 0); -#else QVariant mBool(false); -#endif QVariant mBoolString(QByteArray("false")); QVariant mBoolQString(QString("false")); @@ -2028,49 +1890,45 @@ void tst_QVariant::typeName_data() QTest::newRow("9") << int(QVariant::Size) << QByteArray("QSize"); QTest::newRow("10") << int(QVariant::Color) << QByteArray("QColor"); QTest::newRow("11") << int(QVariant::Palette) << QByteArray("QPalette"); -#ifdef QT3_SUPPORT - QTest::newRow("12") << int(QVariant::ColorGroup) << QByteArray("QColorGroup"); - QTest::newRow("13") << int(QVariant::IconSet) << QByteArray("QIcon"); -#endif - QTest::newRow("14") << int(QVariant::Point) << QByteArray("QPoint"); - QTest::newRow("15") << int(QVariant::Image) << QByteArray("QImage"); - QTest::newRow("16") << int(QVariant::Int) << QByteArray("int"); - QTest::newRow("17") << int(QVariant::UInt) << QByteArray("uint"); - QTest::newRow("18") << int(QVariant::Bool) << QByteArray("bool"); - QTest::newRow("19") << int(QVariant::Double) << QByteArray("double"); - QTest::newRow("20") << int(QMetaType::Float) << QByteArray("float"); - QTest::newRow("21") << int(QVariant::Polygon) << QByteArray("QPolygon"); - QTest::newRow("22") << int(QVariant::Region) << QByteArray("QRegion"); - QTest::newRow("23") << int(QVariant::Bitmap) << QByteArray("QBitmap"); - QTest::newRow("24") << int(QVariant::Cursor) << QByteArray("QCursor"); - QTest::newRow("25") << int(QVariant::SizePolicy) << QByteArray("QSizePolicy"); - QTest::newRow("26") << int(QVariant::Date) << QByteArray("QDate"); - QTest::newRow("27") << int(QVariant::Time) << QByteArray("QTime"); - QTest::newRow("28") << int(QVariant::DateTime) << QByteArray("QDateTime"); - QTest::newRow("29") << int(QVariant::ByteArray) << QByteArray("QByteArray"); - QTest::newRow("30") << int(QVariant::BitArray) << QByteArray("QBitArray"); - QTest::newRow("31") << int(QVariant::KeySequence) << QByteArray("QKeySequence"); - QTest::newRow("32") << int(QVariant::Pen) << QByteArray("QPen"); - QTest::newRow("33") << int(QVariant::LongLong) << QByteArray("qlonglong"); - QTest::newRow("34") << int(QVariant::ULongLong) << QByteArray("qulonglong"); - QTest::newRow("35") << int(QVariant::Char) << QByteArray("QChar"); - QTest::newRow("36") << int(QVariant::Url) << QByteArray("QUrl"); - QTest::newRow("37") << int(QVariant::TextLength) << QByteArray("QTextLength"); - QTest::newRow("38") << int(QVariant::TextFormat) << QByteArray("QTextFormat"); - QTest::newRow("39") << int(QVariant::Locale) << QByteArray("QLocale"); - QTest::newRow("40") << int(QVariant::LineF) << QByteArray("QLineF"); - QTest::newRow("41") << int(QVariant::RectF) << QByteArray("QRectF"); - QTest::newRow("42") << int(QVariant::PointF) << QByteArray("QPointF"); - QTest::newRow("43") << int(QVariant::RegExp) << QByteArray("QRegExp"); - QTest::newRow("44") << int(QVariant::UserType) << QByteArray("UserType"); - QTest::newRow("45") << int(QVariant::Matrix) << QByteArray("QMatrix"); - QTest::newRow("46") << int(QVariant::Transform) << QByteArray("QTransform"); - QTest::newRow("47") << int(QVariant::Hash) << QByteArray("QVariantHash"); - QTest::newRow("48") << int(QVariant::Matrix4x4) << QByteArray("QMatrix4x4"); - QTest::newRow("49") << int(QVariant::Vector2D) << QByteArray("QVector2D"); - QTest::newRow("50") << int(QVariant::Vector3D) << QByteArray("QVector3D"); - QTest::newRow("51") << int(QVariant::Vector4D) << QByteArray("QVector4D"); - QTest::newRow("52") << int(QVariant::Quaternion) << QByteArray("QQuaternion"); + QTest::newRow("12") << int(QVariant::Point) << QByteArray("QPoint"); + QTest::newRow("13") << int(QVariant::Image) << QByteArray("QImage"); + QTest::newRow("14") << int(QVariant::Int) << QByteArray("int"); + QTest::newRow("15") << int(QVariant::UInt) << QByteArray("uint"); + QTest::newRow("16") << int(QVariant::Bool) << QByteArray("bool"); + QTest::newRow("17") << int(QVariant::Double) << QByteArray("double"); + QTest::newRow("18") << int(QMetaType::Float) << QByteArray("float"); + QTest::newRow("19") << int(QVariant::Polygon) << QByteArray("QPolygon"); + QTest::newRow("20") << int(QVariant::Region) << QByteArray("QRegion"); + QTest::newRow("21") << int(QVariant::Bitmap) << QByteArray("QBitmap"); + QTest::newRow("22") << int(QVariant::Cursor) << QByteArray("QCursor"); + QTest::newRow("23") << int(QVariant::SizePolicy) << QByteArray("QSizePolicy"); + QTest::newRow("24") << int(QVariant::Date) << QByteArray("QDate"); + QTest::newRow("25") << int(QVariant::Time) << QByteArray("QTime"); + QTest::newRow("26") << int(QVariant::DateTime) << QByteArray("QDateTime"); + QTest::newRow("27") << int(QVariant::ByteArray) << QByteArray("QByteArray"); + QTest::newRow("28") << int(QVariant::BitArray) << QByteArray("QBitArray"); + QTest::newRow("29") << int(QVariant::KeySequence) << QByteArray("QKeySequence"); + QTest::newRow("30") << int(QVariant::Pen) << QByteArray("QPen"); + QTest::newRow("31") << int(QVariant::LongLong) << QByteArray("qlonglong"); + QTest::newRow("32") << int(QVariant::ULongLong) << QByteArray("qulonglong"); + QTest::newRow("33") << int(QVariant::Char) << QByteArray("QChar"); + QTest::newRow("34") << int(QVariant::Url) << QByteArray("QUrl"); + QTest::newRow("35") << int(QVariant::TextLength) << QByteArray("QTextLength"); + QTest::newRow("36") << int(QVariant::TextFormat) << QByteArray("QTextFormat"); + QTest::newRow("37") << int(QVariant::Locale) << QByteArray("QLocale"); + QTest::newRow("38") << int(QVariant::LineF) << QByteArray("QLineF"); + QTest::newRow("39") << int(QVariant::RectF) << QByteArray("QRectF"); + QTest::newRow("40") << int(QVariant::PointF) << QByteArray("QPointF"); + QTest::newRow("41") << int(QVariant::RegExp) << QByteArray("QRegExp"); + QTest::newRow("42") << int(QVariant::UserType) << QByteArray("UserType"); + QTest::newRow("43") << int(QVariant::Matrix) << QByteArray("QMatrix"); + QTest::newRow("44") << int(QVariant::Transform) << QByteArray("QTransform"); + QTest::newRow("45") << int(QVariant::Hash) << QByteArray("QVariantHash"); + QTest::newRow("46") << int(QVariant::Matrix4x4) << QByteArray("QMatrix4x4"); + QTest::newRow("47") << int(QVariant::Vector2D) << QByteArray("QVector2D"); + QTest::newRow("48") << int(QVariant::Vector3D) << QByteArray("QVector3D"); + QTest::newRow("49") << int(QVariant::Vector4D) << QByteArray("QVector4D"); + QTest::newRow("50") << int(QVariant::Quaternion) << QByteArray("QQuaternion"); } void tst_QVariant::typeName() @@ -2105,9 +1963,6 @@ void tst_QVariant::typeToName() QVERIFY( QVariant::nameToType( "" ) == QVariant::Invalid ); QVERIFY( QVariant::nameToType( "foo" ) == QVariant::Invalid ); QCOMPARE(QVariant::nameToType("QIconSet"), QVariant::Icon); -#ifdef QT3_SUPPORT - QCOMPARE(QVariant::nameToType("Q3CString"), QVariant::ByteArray); -#endif } void tst_QVariant::streamInvalidVariant() @@ -2138,45 +1993,6 @@ void tst_QVariant::streamInvalidVariant() QVERIFY( readY == writeY ); } -void tst_QVariant::nullAsType() -{ -#ifdef QT3_SUPPORT - QVariant null; - QVERIFY(null.isNull()); - - null.asInt(); - QVERIFY(null.isNull()); - - null = QVariant(QString::null); - QVERIFY(null.isNull()); - - null.asInt(); - QVERIFY(null.isNull()); - - int type = QVariant::Invalid; - while (type < (int)QVariant::ULongLong) { - null = QVariant(); - QVERIFY(null.isNull()); - - type++; - if (type == 20) - continue; - if (type == QVariant::Size) - // QSize has its own ideas of ::isNull - continue; - - if (!null.convert((QVariant::Type)type)) - continue; - QCOMPARE((int)null.type(), type); - - QVERIFY2(null.isNull(), qPrintable(QString("'null.isNull()' failed for type: %1").arg(null.typeName()))); - } - - null = QVariant(QLatin1String(static_cast(0))); - QVERIFY(null.isNull()); -#endif -} - static int instanceCount = 0; struct MyType @@ -2633,20 +2449,6 @@ void tst_QVariant::variantHash() QCOMPARE(qvariant_cast(v3).value("test").toInt(), 42); } -void tst_QVariant::invalidAsByteArray() -{ -#ifdef QT3_SUPPORT - QVariant v; - QByteArray &a = v.asByteArray(); - a.resize(2); - a[0] = 'a'; - a[1] = 'b'; - QCOMPARE(v, QVariant(QByteArray("ab"))); -#else - QSKIP("Qt compiled without Qt3Support",SkipAll); -#endif -} - void tst_QVariant::invalidQColor() const { QVariant va("An invalid QColor::name() value."); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index e9cb480b9b..8bafd4d8ee 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -40,10 +40,6 @@ ****************************************************************************/ -#if defined(QT3_SUPPORT) -#include -#include -#endif #include #include #include @@ -169,7 +165,6 @@ public: tst_QWidget(); virtual ~tst_QWidget(); - public slots: void initTestCase(); void cleanupTestCase(); @@ -189,10 +184,8 @@ private slots: void isVisibleTo(); void isHidden(); void fonts(); - void mapToGlobal(); void mapFromAndTo_data(); void mapFromAndTo(); - void checkFocus(); void focusChainOnHide(); void focusChainOnReparent(); void setTabOrder(); @@ -650,9 +643,6 @@ void tst_QWidget::initTestCase() // Create the test class testWidget = new BezierViewer( 0, "testObject"); testWidget->resize(200,200); -#ifdef QT3_SUPPORT - qApp->setMainWidget(testWidget); -#endif testWidget->show(); QTest::qWaitForWindowShown(testWidget); QTest::qWait(50); @@ -1343,27 +1333,6 @@ void tst_QWidget::fonts() QVERIFY( cleanTestWidget->font() == originalFont ); } -void tst_QWidget::mapToGlobal() -{ -#if !defined(QT3_SUPPORT) - QSKIP("No Qt3 Support", SkipAll); -#else - QPoint vis = testWidget->mapToGlobal(QPoint(0,0)); - testWidget->hide(); - QCOMPARE(testWidget->mapToGlobal(QPoint(0,0)), vis); - testWidget->show(); - - // test in a layout and witha move - Q3HBox * qhb = new Q3HBox(testWidget); - QWidget * qw = new QWidget(qhb); - qw->move(6,12); - QPoint wVis = qw->mapToGlobal(QPoint(0,0)); - qw->hide(); - QCOMPARE(qw->mapToGlobal(QPoint(0,0)), wVis); - delete qhb; -#endif // QT3_SUPPORT -} - void tst_QWidget::mapFromAndTo_data() { QTest::addColumn("windowHidden"); @@ -1654,36 +1623,6 @@ void tst_QWidget::focusChainOnHide() testWidget->show(); //don't disturb later tests } -void tst_QWidget::checkFocus() -{ -#if !defined(QT3_SUPPORT) - QSKIP("No Qt3 Support", SkipAll); -#else - // This is a very specific test for a specific bug, the bug was - // that when setEnabled(FALSE) then setEnabled(TRUE) was called on - // the parent of a child widget which had focus while hidden, then - // when the widget was shown, the focus would be in the wrong place. - - Q3HBox widget; - QLineEdit *focusWidget = new QLineEdit( &widget ); - new QLineEdit( &widget ); - new QPushButton( &widget ); - focusWidget->setFocus(); - widget.setEnabled( FALSE ); - widget.setEnabled( TRUE ); - widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif - QTest::qWait( 100 ); - widget.activateWindow(); - // next call is necessary since the window manager may not give the focus to the widget when - // it is shown, which causes the QVERIFY to fail - QApplication::setActiveWindow(&widget); - QVERIFY( qApp->focusWidget() == focusWidget ); -#endif // QT3_SUPPORT -} - class Container : public QWidget { public: @@ -2014,28 +1953,6 @@ void tst_QWidget::showMaximized() widget.showMaximized(); QTRY_VERIFY(widget.size().width() > 20 && widget.size().height() > 20); } - -#ifdef QT3_SUPPORT -#if !defined(Q_WS_QWS) -//embedded respects max/min sizes by design -- maybe wrong design, but that's the way it is now. - { - Q3HBox box; - QWidget widget(&box); - widget.setMinimumSize(500, 500); - box.showMaximized(); - QVERIFY(box.isMaximized()); - } - - { - Q3HBox box; - QWidget widget(&box); - widget.setMaximumSize(500, 500); - - box.showMaximized(); - QVERIFY(box.isMaximized()); - } -#endif -#endif // QT3_SUPPORT } void tst_QWidget::showFullScreen() @@ -2107,28 +2024,6 @@ void tst_QWidget::showFullScreen() widget.showFullScreen(); QVERIFY(widget.isFullScreen()); } - -#ifdef QT3_SUPPORT -#if !defined(Q_WS_QWS) -//embedded respects max/min sizes by design -- maybe wrong design, but that's the way it is now. - { - Q3HBox box; - QWidget widget(&box); - widget.setMinimumSize(500, 500); - box.showFullScreen(); - QVERIFY(box.isFullScreen()); - } - - { - Q3HBox box; - QWidget widget(&box); - widget.setMaximumSize(500, 500); - - box.showFullScreen(); - QVERIFY(box.isFullScreen()); - } -#endif -#endif // QT3_SUPPORT } class ResizeWidget : public QWidget { @@ -6374,11 +6269,6 @@ void tst_QWidget::compatibilityChildInsertedEvents() QCoreApplication::sendPostedEvents(); expected = EventRecorder::EventList() -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&widget, QEvent::ChildInsertedRequest) - << qMakePair(&widget, QEvent::ChildInserted) - << qMakePair(&widget, QEvent::ChildInserted) -#endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Polish) << qMakePair(&widget, QEvent::ChildPolished) @@ -6414,10 +6304,6 @@ void tst_QWidget::compatibilityChildInsertedEvents() EventRecorder::EventList() << qMakePair(&widget, QEvent::WinIdChange) << qMakePair(&widget, QEvent::Polish) -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&widget, QEvent::ChildInserted) - << qMakePair(&widget, QEvent::ChildInserted) -#endif << qMakePair(&widget, QEvent::ChildPolished) << qMakePair(&widget, QEvent::ChildPolished) << qMakePair(&widget, QEvent::Move) @@ -6433,9 +6319,6 @@ void tst_QWidget::compatibilityChildInsertedEvents() QCoreApplication::sendPostedEvents(); expected = EventRecorder::EventList() -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&widget, QEvent::ChildInsertedRequest) -#endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)); @@ -6476,10 +6359,6 @@ void tst_QWidget::compatibilityChildInsertedEvents() QCoreApplication::sendPostedEvents(); expected = EventRecorder::EventList() -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&widget, QEvent::ChildInsertedRequest) - << qMakePair(&widget, QEvent::ChildInserted) -#endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Polish) << qMakePair(&widget, QEvent::ChildPolished) @@ -6516,9 +6395,6 @@ void tst_QWidget::compatibilityChildInsertedEvents() EventRecorder::EventList() << qMakePair(&widget, QEvent::WinIdChange) << qMakePair(&widget, QEvent::Polish) -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&widget, QEvent::ChildInserted) -#endif << qMakePair(&widget, QEvent::ChildPolished) << qMakePair(&widget, QEvent::Move) << qMakePair(&widget, QEvent::Resize) @@ -6533,9 +6409,6 @@ void tst_QWidget::compatibilityChildInsertedEvents() QCoreApplication::sendPostedEvents(); expected = EventRecorder::EventList() -#ifdef QT_HAS_QT3SUPPORT - << qMakePair(&widget, QEvent::ChildInsertedRequest) -#endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)); @@ -6996,9 +6869,7 @@ void tst_QWidget::renderWithPainter() void tst_QWidget::render_task188133() { QMainWindow mainWindow; -#if defined(QT3_SUPPORT) - mainWindow.setCentralWidget(new Q3TextEdit); -#endif + // Make sure QWidget::render does not trigger QWidget::repaint/update // and asserts for Qt::WA_WState_Created. QPixmap pixmap = QPixmap::grabWidget(&mainWindow); diff --git a/tests/auto/qworkspace/tst_qworkspace.cpp b/tests/auto/qworkspace/tst_qworkspace.cpp index ca12f3e259..191c150004 100644 --- a/tests/auto/qworkspace/tst_qworkspace.cpp +++ b/tests/auto/qworkspace/tst_qworkspace.cpp @@ -45,10 +45,6 @@ #include #include #include -#if defined(QT3_SUPPORT) -#include -#include -#endif //TESTED_CLASS= //TESTED_FILES= @@ -75,7 +71,6 @@ private slots: void getSetCheck(); void windowActivated_data(); void windowActivated(); - void accelPropagation(); void windowActivatedWithMinimize(); void showWindows(); void changeWindowTitle(); @@ -314,59 +309,6 @@ void tst_QWorkspace::accelActivated() accelPressed = TRUE; } -void tst_QWorkspace::accelPropagation() -{ -#if defined (QT3_SUPPORT) - QSKIP( "Until QTest::keyPress() sends the events via the OS, this will skip", SkipAll); - // See #13987 for details of bug report related to this - - QMainWindow mw(0, Qt::X11BypassWindowManagerHint) ; - mw.menuBar(); - QWorkspace *workspace = new QWorkspace(&mw); - workspace->setObjectName("testWidget"); - mw.setCentralWidget(workspace); - connect( workspace, SIGNAL(windowActivated(QWidget*)), this, SLOT(activeChanged(QWidget*)) ); - mw.show(); - qApp->setActiveWindow(&mw); - - QMainWindow* mainWindow = new QMainWindow( workspace ); - - // The popup menu has to have no parent, this is vital in the - // original case of reproducing the bug - - Q3PopupMenu* popup = new Q3PopupMenu; - popup->insertItem("First"); - mainWindow->menuBar()->insertItem("Menu", popup); - - Q3Accel* accel = new Q3Accel(mainWindow); - accel->connectItem(accel->insertItem(Qt::Key_Escape), this, SLOT(accelActivated()) ); - - mainWindow->show(); - - QTest::keyPress( mainWindow, Qt::Key_Escape ); - QVERIFY( accelPressed ); - accelPressed = FALSE; - - QTest::mousePress( mainWindow->menuBar(), Qt::LeftButton, 0, QPoint( 5, 5 ) ); - - // Check the popup menu did appear to be sure - QVERIFY( qApp->activePopupWidget() == popup ); - - QTest::mouseClick( popup, Qt::LeftButton, 0, QPoint( 5, 25 ) ); - - // Check we did actually cause the popup menu to be closed - QVERIFY( !popup->isVisible() ); - - // Now we check that the accelarator still works - QTest::keyPress( mainWindow, Qt::Key_Escape ); - QVERIFY( accelPressed ); - delete popup; -#else - QSKIP( "No Qt3Support. Skipping.", SkipAll); -#endif - -} - void tst_QWorkspace::showWindows() { QWorkspace *ws = new QWorkspace( 0 ); -- cgit v1.2.3 From 871e8fe8dc562b77e759ac876f1c7d17cac1a81f Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 18 May 2011 12:04:14 +1000 Subject: Remove Q_ASSERT's from qdbustype autotest Change-Id: I276750d8acda3744ee8a9c424b2da0a08e8c7461 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qdbustype/tst_qdbustype.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/qdbustype/tst_qdbustype.cpp b/tests/auto/qdbustype/tst_qdbustype.cpp index 676a9040be..2a10fe1886 100644 --- a/tests/auto/qdbustype/tst_qdbustype.cpp +++ b/tests/auto/qdbustype/tst_qdbustype.cpp @@ -185,8 +185,8 @@ void tst_QDBusType::isValidFixedType() QFETCH(QString, data); QFETCH(bool, result); QFETCH(bool, isValid); - Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types"); - Q_ASSERT(isValid || (!isValid && !result)); + QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types"); + QVERIFY(isValid || (!isValid && !result)); int type = data.at(0).unicode(); if (isValid) @@ -207,8 +207,8 @@ void tst_QDBusType::isValidBasicType() QFETCH(QString, data); QFETCH(bool, result); QFETCH(bool, isValid); - Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types"); - Q_ASSERT(isValid || (!isValid && !result)); + QVERIFY2(data.length() == 1, "Test is malformed, this function must test only one-letter types"); + QVERIFY(isValid || (!isValid && !result)); int type = data.at(0).unicode(); if (isValid) -- cgit v1.2.3 From 9a6a58a95af31816627550c573c1b2ac39fc404e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 19 May 2011 10:00:47 +1000 Subject: tests: fixed compilation of tst_qtextstream Compilation of this autotest was broken by a strange qmake bug, QTBUG-19393. Work around it by putting a space between two string literals. Change-Id: I494c486dd11858eeaf98d7a04021c74fcf3cbba7 --- tests/auto/qtextstream/tst_qtextstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index 8ffab143c2..b086a213c8 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -2580,7 +2580,7 @@ void tst_QTextStream::readBomSeekBackReadBomAgain() QFile::remove("utf8bom"); QFile file("utf8bom"); QVERIFY(file.open(QFile::ReadWrite)); - file.write("\xef\xbb\xbf""Andreas"); + file.write("\xef\xbb\xbf" "Andreas"); file.seek(0); QCOMPARE(file.pos(), qint64(0)); -- cgit v1.2.3