From 272a144ed06a4c11e058404f872609f0b43b4dd6 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 31 Dec 2010 11:44:38 +1000 Subject: tst_networkselftest: add checks for echo, daytime --- tests/auto/networkselftest/tst_networkselftest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 5e9c50e..90387d0 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -398,6 +398,8 @@ void tst_NetworkSelfTest::serverReachability() void tst_NetworkSelfTest::remotePortsOpen_data() { QTest::addColumn("portNumber"); + QTest::newRow("echo") << 7; + QTest::newRow("daytime") << 13; QTest::newRow("ftp") << 21; QTest::newRow("ssh") << 22; QTest::newRow("imap") << 143; -- cgit v0.12 From e6286c54bd66c2db06687127fea69fcc398ffbde Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 4 Jan 2011 14:30:19 +1000 Subject: Remove garbage empty test. --- tests/auto/gui.pro | 1 - tests/auto/qtwidgets/.gitignore | 1 - tests/auto/qtwidgets/advanced.ui | 319 --------- tests/auto/qtwidgets/icons/big.png | Bin 1323 -> 0 bytes tests/auto/qtwidgets/icons/folder.png | Bin 4069 -> 0 bytes tests/auto/qtwidgets/icons/icon.bmp | Bin 246 -> 0 bytes tests/auto/qtwidgets/icons/icon.png | Bin 344 -> 0 bytes tests/auto/qtwidgets/mainwindow.cpp | 314 --------- tests/auto/qtwidgets/mainwindow.h | 80 --- tests/auto/qtwidgets/qtstyles.qrc | 8 - tests/auto/qtwidgets/qtwidgets.pro | 10 - tests/auto/qtwidgets/standard.ui | 1207 -------------------------------- tests/auto/qtwidgets/system.ui | 658 ----------------- tests/auto/qtwidgets/tst_qtwidgets.cpp | 112 --- 14 files changed, 2710 deletions(-) delete mode 100644 tests/auto/qtwidgets/.gitignore delete mode 100644 tests/auto/qtwidgets/advanced.ui delete mode 100644 tests/auto/qtwidgets/icons/big.png delete mode 100644 tests/auto/qtwidgets/icons/folder.png delete mode 100644 tests/auto/qtwidgets/icons/icon.bmp delete mode 100644 tests/auto/qtwidgets/icons/icon.png delete mode 100644 tests/auto/qtwidgets/mainwindow.cpp delete mode 100644 tests/auto/qtwidgets/mainwindow.h delete mode 100644 tests/auto/qtwidgets/qtstyles.qrc delete mode 100644 tests/auto/qtwidgets/qtwidgets.pro delete mode 100644 tests/auto/qtwidgets/standard.ui delete mode 100644 tests/auto/qtwidgets/system.ui delete mode 100644 tests/auto/qtwidgets/tst_qtwidgets.cpp diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index 2d9ea93..802e74a 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -197,7 +197,6 @@ SUBDIRS=\ qtreeview \ qtreewidget \ qtreewidgetitemiterator \ - qtwidgets \ qudpsocket \ qundogroup \ qundostack \ diff --git a/tests/auto/qtwidgets/.gitignore b/tests/auto/qtwidgets/.gitignore deleted file mode 100644 index d8e55c3..0000000 --- a/tests/auto/qtwidgets/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qtwidgets diff --git a/tests/auto/qtwidgets/advanced.ui b/tests/auto/qtwidgets/advanced.ui deleted file mode 100644 index ce27374..0000000 --- a/tests/auto/qtwidgets/advanced.ui +++ /dev/null @@ -1,319 +0,0 @@ - - - - - Advanced - - - Advanced - - - - 0 - 0 - 400 - 300 - - - - - - - - 9 - - - 6 - - - - - - - - 1 - - - 6 - - - - - pushButton - - - - 1 - 1 - 80 - 23 - - - - - - - - - - - pushButton_2 - - - - 87 - 1 - 80 - 23 - - - - Text - - - - - - - checkBox - - - - 173 - 6 - 23 - 13 - - - - - - - - - - - - - - radioButton - - - - 202 - 6 - 22 - 12 - - - - - - - - - - - - - - checkBox_2 - - - - 230 - 3 - 44 - 18 - - - - Text - - - - - - - radioButton_2 - - - - 280 - 3 - 43 - 18 - - - - Text - - - - - - - - - - - - 1 - - - 6 - - - - - listWidget - - - - 1 - 1 - 186 - 91 - - - - - - - - listWidget_3 - - - - 193 - 96 - 188 - 60 - - - - - - - - treeWidget_2 - - - - 1 - 96 - 186 - 60 - - - - - - - - - - - 1 - - - 6 - - - - - listWidget_2 - - - - 1 - 1 - 186 - 43 - - - - - - - - treeWidget - - - - 1 - 48 - 186 - 43 - - - - - - - - - - - - tabWidget - - - - 9 - 201 - 382 - 90 - - - - - 0 - 90 - - - - QTabWidget::North - - - QTabWidget::Rounded - - - - widget - - - - 0 - 0 - 380 - 63 - - - - Tab Page 1 - - - - - widget - - - - 0 - 0 - 459 - 66 - - - - Tab Page 2 - - - - - - - - - diff --git a/tests/auto/qtwidgets/icons/big.png b/tests/auto/qtwidgets/icons/big.png deleted file mode 100644 index 6032804..0000000 Binary files a/tests/auto/qtwidgets/icons/big.png and /dev/null differ diff --git a/tests/auto/qtwidgets/icons/folder.png b/tests/auto/qtwidgets/icons/folder.png deleted file mode 100644 index 981a25d..0000000 Binary files a/tests/auto/qtwidgets/icons/folder.png and /dev/null differ diff --git a/tests/auto/qtwidgets/icons/icon.bmp b/tests/auto/qtwidgets/icons/icon.bmp deleted file mode 100644 index 196de6a..0000000 Binary files a/tests/auto/qtwidgets/icons/icon.bmp and /dev/null differ diff --git a/tests/auto/qtwidgets/icons/icon.png b/tests/auto/qtwidgets/icons/icon.png deleted file mode 100644 index 8f9c562..0000000 Binary files a/tests/auto/qtwidgets/icons/icon.png and /dev/null differ diff --git a/tests/auto/qtwidgets/mainwindow.cpp b/tests/auto/qtwidgets/mainwindow.cpp deleted file mode 100644 index 341c416..0000000 --- a/tests/auto/qtwidgets/mainwindow.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include "mainwindow.h" -#include -#include - -StyleWidget::StyleWidget(QWidget *parent, Qt::WFlags f) - : QWidget(parent, f) -{ - QHBoxLayout *hbox = new QHBoxLayout(this); - QSplitter *spl = new QSplitter(this); - - // standard widgets - QWidget *leftWidget = new QWidget(this); - m_staWidget.setupUi(leftWidget); - - // advanced/system widgets - QGroupBox *rightWidget = new QGroupBox("Advanced", this); - QVBoxLayout *vbox = new QVBoxLayout(rightWidget); - QWidget *adv = new QWidget(rightWidget); - m_advWidget.setupUi(adv); - QWidget *sys = new QWidget(rightWidget); - m_sysWidget.setupUi(sys); - vbox->addWidget(adv); - vbox->addWidget(sys); - - spl->addWidget(leftWidget); - spl->addWidget(rightWidget); - - hbox->setMargin(4); - hbox->addWidget(spl); - - m_small1 = QIcon(":/icons/icon.bmp"); - m_small2 = QIcon(":/icons/icon.png"); - m_big = QIcon(":/icons/big.png"); - - addComboBoxItems(); - addTreeItems(); - addTreeListItems(); - addListItems(); - addTextEdit(); - setupOtherWidgets(); - setupButtons(); - - foreach(QWidget *w, qFindChildren(parentWidget())) - w->setWhatsThis(w->metaObject()->className()); -} - -StyleWidget::~StyleWidget() -{ - -} - -void StyleWidget::addTextEdit() -{ - m_staWidget.textEdit->setPlainText( - "Some Text\nSome Text\nSome Text\nSome Text\nSome Text\nSome Text\nSome Text\nSome Text"); - m_staWidget.textEdit_2->setPlainText( - "Some Text, Some Text, Some Text, Some Text, Some Text, Some Text, Some Text, Some Text"); - m_staWidget.textEdit_3->setPlainText( - "Some Text, Some Text, Some Text, Some Text, Some Text, Some Text, Some Text, Some Text" \ - "Some Text\nSome Text\nSome Text\nSome Text\nSome Text\nSome Text\nSome Text\nSome Text\n"); -} - -void StyleWidget::addComboBoxItems() -{ - m_staWidget.comboBox->addItem("Item 1"); - m_staWidget.comboBox->addItem("Item 2"); - m_staWidget.comboBox->addItem("Item 3"); - m_staWidget.comboBox->addItem("Item 4"); - m_staWidget.comboBox->addItem("Item 5"); -} - -void StyleWidget::addListItems() -{ - m_staWidget.listWidget->addItem("Item 1"); - m_staWidget.listWidget->addItem("Item 2"); - m_staWidget.listWidget->addItem("Item 3"); - m_staWidget.listWidget->addItem("Item 4"); - m_staWidget.listWidget->addItem("Item 5"); - - QListWidgetItem *tmp = new QListWidgetItem("Item 1", m_staWidget.listWidget_2); - tmp->setCheckState(Qt::Checked); - tmp = new QListWidgetItem("Item 2", m_staWidget.listWidget_2); - tmp->setCheckState(Qt::Checked); - tmp = new QListWidgetItem("Item 3", m_staWidget.listWidget_2); - tmp->setCheckState(Qt::Checked); - tmp = new QListWidgetItem("Item 4", m_staWidget.listWidget_2); - tmp->setCheckState(Qt::Checked); - tmp = new QListWidgetItem("Item 5", m_staWidget.listWidget_2); - tmp->setCheckState(Qt::Checked); - - tmp = new QListWidgetItem("Item 1", m_advWidget.listWidget_3); - tmp->setCheckState(Qt::Checked); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 2", m_advWidget.listWidget_3); - tmp->setCheckState(Qt::Checked); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 3", m_advWidget.listWidget_3); - tmp->setCheckState(Qt::Checked); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 4", m_advWidget.listWidget_3); - tmp->setCheckState(Qt::Checked); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 5", m_advWidget.listWidget_3); - tmp->setCheckState(Qt::Checked); - tmp->setIcon(m_small1); - - m_advWidget.listWidget->setViewMode(QListView::IconMode); - QIcon folder(":/icons/folder.png"); - tmp = new QListWidgetItem("Item 1", m_advWidget.listWidget); - tmp->setIcon(folder); - tmp = new QListWidgetItem("Item 2", m_advWidget.listWidget); - tmp->setIcon(folder); - tmp = new QListWidgetItem("Item 3", m_advWidget.listWidget); - tmp->setIcon(folder); - tmp = new QListWidgetItem("Item 4", m_advWidget.listWidget); - tmp->setIcon(folder); - tmp = new QListWidgetItem("Item 5", m_advWidget.listWidget); - tmp->setIcon(folder); - - tmp = new QListWidgetItem("Item 1", m_advWidget.listWidget_2); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 2", m_advWidget.listWidget_2); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 3", m_advWidget.listWidget_2); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 4", m_advWidget.listWidget_2); - tmp->setIcon(m_small1); - tmp = new QListWidgetItem("Item 5", m_advWidget.listWidget_2); - tmp->setIcon(m_small1); -} - -void StyleWidget::setupOtherWidgets() -{ - m_sysWidget.tableWidget->setRowCount(100); - m_sysWidget.tableWidget->setColumnCount(100); -} - -void StyleWidget::addTreeItems() -{ - //standard tree - m_staWidget.treeWidget_2->setColumnCount(1); - m_staWidget.treeWidget_2->header()->hide(); - - QTreeWidgetItem *tmp; - QTreeWidgetItem *subtmp; - QTreeWidgetItem *root1 = new QTreeWidgetItem(m_staWidget.treeWidget_2); - root1->setText(0, "Root 1"); - QTreeWidgetItem *root2 = new QTreeWidgetItem(m_staWidget.treeWidget_2); - root2->setText(0, "Root 2"); - - for (int i=1; i<=10; ++i) - { - tmp = new QTreeWidgetItem(root1); - tmp->setText(0, QString("Item %1").arg(i)); - for (int j=1; j<=5; ++j) - { - subtmp = new QTreeWidgetItem(tmp); - subtmp->setText(0, QString("Sub Item %1").arg(j)); - } - } - - // standard checked tree - m_staWidget.treeWidget_4->setColumnCount(1); - m_staWidget.treeWidget_4->header()->hide(); - - root1 = new QTreeWidgetItem(m_staWidget.treeWidget_4); - root1->setText(0, "Root 1"); - root1->setCheckState(0, Qt::Checked); - root2 = new QTreeWidgetItem(m_staWidget.treeWidget_4); - root2->setText(0, "Root 2"); - root2->setCheckState(0, Qt::Checked); - - for (int i=1; i<=10; ++i) - { - tmp = new QTreeWidgetItem(root1); - tmp->setText(0, QString("Item %1").arg(i)); - tmp->setCheckState(0, Qt::Checked); - for (int j=1; j<=5; ++j) - { - subtmp = new QTreeWidgetItem(tmp); - subtmp->setText(0, QString("Sub Item %1").arg(j)); - subtmp->setCheckState(0, Qt::Checked); - } - } - - // advanced (images) tree - m_advWidget.treeWidget_2->setColumnCount(1); - m_advWidget.treeWidget_2->header()->hide(); - - root1 = new QTreeWidgetItem(m_advWidget.treeWidget_2); - root1->setText(0, "Root 1"); - root1->setIcon(0, m_small1); - root2 = new QTreeWidgetItem(m_advWidget.treeWidget_2); - root2->setText(0, "Root 2"); - root2->setIcon(0, m_small1); - - for (int i=1; i<=10; ++i) - { - tmp = new QTreeWidgetItem(root1); - tmp->setText(0, QString("Item %1").arg(i)); - tmp->setIcon(0, m_small2); - for (int j=1; j<=5; ++j) - { - subtmp = new QTreeWidgetItem(tmp); - subtmp->setText(0, QString("Sub Item %1").arg(j)); - tmp->setIcon(0, m_small1); - } - } - -} - -void StyleWidget::addTreeListItems() -{ - //standard list - QTreeWidgetItem *tmp; - m_staWidget.treeWidget->setColumnCount(3); - m_staWidget.treeWidget->headerItem()->setText(0, "Col1"); - m_staWidget.treeWidget->headerItem()->setText(1, "Col2"); - m_staWidget.treeWidget->headerItem()->setText(2, "Col3"); - - for (int i=1; i<10; ++i) - { - tmp = new QTreeWidgetItem(m_staWidget.treeWidget); - tmp->setText(0, QString("Item%1").arg(i)); - tmp->setText(1, QString("Item%11").arg(i)); - tmp->setText(2, QString("Item%12").arg(i)); - } - - //standard checked list - m_staWidget.treeWidget_3->setColumnCount(3); - m_staWidget.treeWidget_3->headerItem()->setText(0, "Col1"); - m_staWidget.treeWidget_3->headerItem()->setText(1, "Col2"); - m_staWidget.treeWidget_3->headerItem()->setText(2, "Col3"); - - for (int i=1; i<10; ++i) - { - tmp = new QTreeWidgetItem(m_staWidget.treeWidget_3); - tmp->setText(0, QString("Item%1").arg(i)); - tmp->setCheckState(0, Qt::Checked); - tmp->setText(1, QString("Item%11").arg(i)); - tmp->setText(2, QString("Item%12").arg(i)); - } - - //with images - m_advWidget.treeWidget->setColumnCount(2); - m_advWidget.treeWidget->headerItem()->setText(0, "Col1"); - m_advWidget.treeWidget->headerItem()->setIcon(0, m_small2); - m_advWidget.treeWidget->headerItem()->setText(1, "Col2"); - m_advWidget.treeWidget->headerItem()->setIcon(1, m_small2); - - for (int i=1; i<10; ++i) - { - tmp = new QTreeWidgetItem(m_advWidget.treeWidget); - tmp->setText(0, QString("Item%1").arg(i)); - tmp->setIcon(0, m_small1); - tmp->setText(1, QString("Item%11").arg(i)); - } -} - -void StyleWidget::setupButtons() -{ - m_advWidget.pushButton->setIcon(m_small1); - m_advWidget.pushButton_2->setIcon(m_small1); - m_advWidget.checkBox->setIcon(m_small2); - m_advWidget.checkBox_2->setIcon(m_small2); - m_advWidget.radioButton->setIcon(m_small2); - m_advWidget.radioButton_2->setIcon(m_small2); - - // tab page images - m_advWidget.tabWidget->setTabIcon(0, m_small2); - m_advWidget.tabWidget->setTabIcon(1, m_small2); -} diff --git a/tests/auto/qtwidgets/mainwindow.h b/tests/auto/qtwidgets/mainwindow.h deleted file mode 100644 index 8a4521a..0000000 --- a/tests/auto/qtwidgets/mainwindow.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include "ui_standard.h" -#include "ui_advanced.h" -#include "ui_system.h" - -class StyleWidget : public QWidget -{ - Q_OBJECT - -public: - StyleWidget(QWidget *parent = 0, Qt::WFlags f = 0); - ~StyleWidget(); - -public slots: - void onWhatsThis() { QWhatsThis::enterWhatsThisMode(); } - -private: - void addComboBoxItems(); - void addListItems(); - void addTextEdit(); - void setupOtherWidgets(); - void setupButtons(); - void addTreeItems(); - void addTreeListItems(); - - Ui::Standard m_staWidget; - Ui::Advanced m_advWidget; - Ui::System m_sysWidget; - - QIcon m_small1; - QIcon m_small2; - QIcon m_big; -}; - -#endif //MAINWINDOW_H - diff --git a/tests/auto/qtwidgets/qtstyles.qrc b/tests/auto/qtwidgets/qtstyles.qrc deleted file mode 100644 index 772891d..0000000 --- a/tests/auto/qtwidgets/qtstyles.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - ./icons/icon.png - ./icons/icon.bmp - ./icons/big.png - ./icons/folder.png - - diff --git a/tests/auto/qtwidgets/qtwidgets.pro b/tests/auto/qtwidgets/qtwidgets.pro deleted file mode 100644 index 9c33cd1..0000000 --- a/tests/auto/qtwidgets/qtwidgets.pro +++ /dev/null @@ -1,10 +0,0 @@ -load(qttest_p4) -symbian:TARGET.EPOCHEAPSIZE=0x200000 0xa00000 - -SOURCES += tst_qtwidgets.cpp mainwindow.cpp -HEADERS += mainwindow.h -QT += network -RESOURCES = qtstyles.qrc -FORMS += advanced.ui system.ui standard.ui - - diff --git a/tests/auto/qtwidgets/standard.ui b/tests/auto/qtwidgets/standard.ui deleted file mode 100644 index 9764a66..0000000 --- a/tests/auto/qtwidgets/standard.ui +++ /dev/null @@ -1,1207 +0,0 @@ - - - - - Standard - - - Standard - - - - 0 - 0 - 400 - 300 - - - - - - - - 0 - - - 0 - - - - - groupBox - - - - 0 - 0 - 400 - 300 - - - - Standard - - - - - - - 9 - - - 6 - - - - - - - - 1 - - - 6 - - - - - - - - 1 - - - 6 - - - - - - - - 1 - - - 6 - - - - - checkBox - - - - 1 - 1 - 114 - 3 - - - - Enabled &CheckBox - - - - - - - checkBox_2 - - - false - - - - 121 - 1 - 116 - 3 - - - - Disabled Check&Box - - - - - - - - - - - 243 - 1 - 80 - 3 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 1 - - - 6 - - - - - comboBox - - - - 1 - 1 - 41 - 3 - - - - - - - - comboBox_2 - - - - 48 - 1 - 41 - 3 - - - - - - - - comboBox_3 - - - false - - - - 95 - 1 - 41 - 3 - - - - - - - - - - - - - 1 - - - 6 - - - - - pushButton - - - - 1 - 1 - 80 - 3 - - - - &Enabled - - - - - - - pushButton_2 - - - false - - - - 87 - 1 - 80 - 3 - - - - Di&sabled - - - - - - - - - - - 173 - 1 - 150 - 3 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 1 - - - 6 - - - - - label - - - - 1 - 1 - 99 - 3 - - - - QFrame::NoFrame - - - QFrame::Plain - - - Label with some text. - - - Qt::AutoText - - - - - - - label_2 - - - false - - - - 106 - 1 - 139 - 3 - - - - QFrame::NoFrame - - - QFrame::Plain - - - Disabled label with some text. - - - Qt::AutoText - - - - - - - - - - - 251 - 1 - 72 - 3 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 1 - - - 6 - - - - - lineEdit - - - - 1 - 1 - 135 - 3 - - - - Enabled - - - QLineEdit::Normal - - - - - - - lineEdit_2 - - - false - - - - 142 - 1 - 134 - 3 - - - - Disabled - - - QLineEdit::Normal - - - - - - - spinBox - - - - 282 - 1 - 41 - 3 - - - - QAbstractSpinBox::UpDownArrows - - - - - - - - - - - - 1 - - - 6 - - - - - radioButton - - - - 1 - 1 - 123 - 3 - - - - Enabled RadioButton - - - - - - - radioButton_2 - - - false - - - - 130 - 1 - 125 - 3 - - - - Disabled RadioButton - - - - - - - - - - - 261 - 1 - 62 - 3 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 1 - - - 6 - - - - - horizontalScrollBar - - - - 1 - 1 - 90 - 3 - - - - - 0 - 0 - 0 - 0 - - - - - 90 - 0 - - - - Qt::Horizontal - - - - - - - horizontalScrollBar_2 - - - - 97 - 1 - 30 - 3 - - - - Qt::Horizontal - - - - - - - - - - - verticalScrollBar - - - - 333 - 1 - 17 - 37 - - - - - 0 - 1 - 0 - 0 - - - - Qt::Vertical - - - - - - - slider - - - - 356 - 1 - 21 - 37 - - - - - 0 - 1 - 0 - 0 - - - - Qt::Vertical - - - QSlider::TicksBelow - - - 0 - - - - - - - - - - - - 1 - - - 6 - - - - - slider_2 - - - - 1 - 6 - 90 - 16 - - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - slider_3 - - - - 97 - 3 - 89 - 21 - - - - Qt::Horizontal - - - QSlider::TicksBelow - - - - - - - slider_4 - - - - 192 - 3 - 90 - 21 - - - - Qt::Horizontal - - - QSlider::TicksAbove - - - - - - - slider_5 - - - - 288 - 1 - 89 - 26 - - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - - - - - - - - - - 1 - - - 6 - - - - - textEdit - - - - 1 - 1 - 89 - 37 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - - - - - textEdit_2 - - - - 96 - 1 - 90 - 37 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOn - - - - - - - textEdit_3 - - - - 192 - 1 - 89 - 100 - - - - - 0 - 100 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOn - - - - - - - textEdit_4 - - - - 287 - 1 - 90 - 37 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAsNeeded - - - - - - - - - groupBox_2 - - - - 11 - 132 - 378 - 39 - - - - GroupBox - - - - - - - 9 - - - 6 - - - - - progressBar - - - - 11 - 20 - 356 - 8 - - - - 50 - - - false - - - - - - - - - - - - - 1 - - - 6 - - - - - listWidget - - - - 1 - 1 - 107 - 37 - - - - - - - - listWidget_2 - - - - 114 - 1 - 107 - 37 - - - - - - - - tabWidget - - - - 227 - 1 - 150 - 37 - - - - - 150 - 0 - - - - QTabWidget::North - - - QTabWidget::Rounded - - - - - - - - 0 - 0 - 148 - 10 - - - - Tab Page 1 - - - - - - - - - 0 - 0 - 116 - 56 - - - - Tab Page 2 - - - - - widget - - - - 0 - 0 - 116 - 56 - - - - Tab Page 3 - - - - - widget - - - - 0 - 0 - 146 - 36 - - - - Tab Page 4 - - - - - - - - - - tabWidget_2 - - - - 11 - 214 - 378 - 90 - - - - - 0 - 90 - - - - QTabWidget::North - - - QTabWidget::Rounded - - - - widget - - - - 0 - 0 - 376 - 63 - - - - Tab Page 1 - - - - - widget - - - - 0 - 0 - 424 - 66 - - - - Tab Page 2 - - - - - - - - - - - 1 - - - 6 - - - - - treeWidget_2 - - - - 192 - 1 - 185 - 18 - - - - - - - - treeWidget_3 - - - - 1 - 20 - 185 - 18 - - - - - - - - treeWidget - - - - 1 - 1 - 185 - 18 - - - - - - - - treeWidget_4 - - - - 192 - 20 - 185 - 18 - - - - - - - - - - - - - - diff --git a/tests/auto/qtwidgets/system.ui b/tests/auto/qtwidgets/system.ui deleted file mode 100644 index a641e0e..0000000 --- a/tests/auto/qtwidgets/system.ui +++ /dev/null @@ -1,658 +0,0 @@ - - - - - System - - - System - - - - 0 - 0 - 400 - 604 - - - - - - - - 9 - - - 6 - - - - - - - - 1 - - - 6 - - - - - toolButton - - - - 340 - 138 - 15 - 19 - - - - ... - - - - - - - horizontalLine - - - - 1 - 146 - 333 - 3 - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - verticalLine - - - - 361 - 1 - 3 - 131 - - - - QFrame::VLine - - - QFrame::Sunken - - - - - - - - - - 1 - - - 6 - - - - - dateTimeEdit_2 - - - false - - - - 1 - 108 - 113 - 20 - - - - QAbstractSpinBox::UpDownArrows - - - - - - - dateTimeEdit - - - - 1 - 41 - 113 - 20 - - - - QAbstractSpinBox::UpDownArrows - - - - - - - dial - - - - 120 - 1 - 114 - 100 - - - - Qt::Horizontal - - - - - - - lcdNumber - - - - 120 - 107 - 114 - 23 - - - - QFrame::Box - - - QFrame::Raised - - - QLCDNumber::Dec - - - QLCDNumber::Outline - - - - - - - lcdNumber_2 - - - false - - - - 240 - 107 - 113 - 23 - - - - QFrame::Box - - - QFrame::Raised - - - QLCDNumber::Dec - - - QLCDNumber::Outline - - - - - - - dial_2 - - - false - - - - 240 - 1 - 113 - 100 - - - - Qt::Horizontal - - - - - - - - - - - - - - 1 - - - 6 - - - - - tableWidget - - - - 1 - 1 - 256 - 193 - - - - - - - - toolBox - - - - 263 - 1 - 118 - 193 - - - - QFrame::Box - - - QFrame::Plain - - - 0 - - - - widget - - - - 0 - 0 - 98 - 119 - - - - Tool Page 1 - - - - - widget - - - - 0 - 0 - 115 - 56 - - - - Tool Page 2 - - - - - - - - - - tabWidget - - - - 9 - 375 - 382 - 220 - - - - QTabWidget::Rounded - - - - widget - - - - 0 - 0 - 378 - 196 - - - - Tab Page 1 - - - - - - - 9 - - - 6 - - - - - - - - 1 - - - 6 - - - - - comboBox_3 - - - - 1 - 1 - 332 - 20 - - - - - - - - - - - 1 - - - 6 - - - - - pushButton_5 - - - - 1 - 1 - 80 - 23 - - - - &Enabled - - - - - - - pushButton_6 - - - - 87 - 1 - 80 - 23 - - - - Di&sabled - - - - - - - - - - - 173 - 1 - 158 - 23 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 1 - - - 6 - - - - - radioButton_3 - - - - 1 - 2 - 123 - 18 - - - - Enabled RadioButton - - - - - - - radioButton_4 - - - - 130 - 2 - 125 - 18 - - - - Disabled RadioButton - - - - - - - - - - - 261 - 1 - 70 - 20 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - progressBar - - - - 1 - 86 - 332 - 22 - - - - 24 - - - - - - - horizontalScrollBar - - - - 1 - 114 - 332 - 17 - - - - Qt::Horizontal - - - - - - - - - verticalScrollBar - - - - 349 - 9 - 17 - 132 - - - - - 0 - 1 - 0 - 0 - - - - Qt::Vertical - - - - - - - - - - - 9 - 147 - 334 - 40 - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - widget - - - - 0 - 0 - 377 - 187 - - - - Tab Page 2 - - - - - - - - - diff --git a/tests/auto/qtwidgets/tst_qtwidgets.cpp b/tests/auto/qtwidgets/tst_qtwidgets.cpp deleted file mode 100644 index 501402b..0000000 --- a/tests/auto/qtwidgets/tst_qtwidgets.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include - -#include - - -#include "mainwindow.h" -#include "../network-settings.h" - -class tst_QtWidgets: public QObject -{ - Q_OBJECT - -public: - tst_QtWidgets(); - virtual ~tst_QtWidgets(); - -private slots: - void snapshot(); -}; - -tst_QtWidgets::tst_QtWidgets() -{ - Q_SET_DEFAULT_IAP -} - -tst_QtWidgets::~tst_QtWidgets() -{ -} - -void tst_QtWidgets::snapshot() -{ - QSKIP("Jesper will fix this test when he has time.", SkipAll); -#if 0 - StyleWidget widget(0, Qt::X11BypassWindowManagerHint); - widget.show(); - - QPixmap pix = QPixmap::grabWidget(&widget); - - QVERIFY(!pix.isNull()); - - QBuffer buf; - pix.save(&buf, "PNG"); - QVERIFY(buf.size() > 0); - - QString filename = "qtwidgets_" + QHostInfo::localHostName() + "_" + QDateTime::currentDateTime().toString("yyyy.MM.dd_hh.mm.ss") + ".png"; - - QFtp ftp; - ftp.connectToHost("qt-test-server.qt-test-net"); - ftp.login("ftptest", "password"); - ftp.cd("qtest/pics"); - ftp.put(buf.data(), filename, QFtp::Binary); - ftp.close(); - - int i = 0; - while (i < 100 && ftp.hasPendingCommands()) { - QCoreApplication::instance()->processEvents(); - QTest::qWait(250); - ++i; - } - QVERIFY2(ftp.error() == QFtp::NoError, ftp.errorString().toLocal8Bit().constData()); - QVERIFY(!ftp.hasPendingCommands()); -#endif -} - - - -QTEST_MAIN(tst_QtWidgets) - -#include "tst_qtwidgets.moc" -- cgit v0.12 From 026a24855ec16626ab101007719a836f5a4e3c47 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 6 Jan 2011 13:39:14 +1000 Subject: network tests: make IMAP, FTP testdata more flexible. Move all hardcoded IMAP/FTP fixtures into network-settings.h. Make it work with new and old network test server. Reviewed-by: Markus Goetz Task: QTBUG-15114 --- tests/auto/network-settings.h | 79 ++++++++++++++++---- .../qhttpsocketengine/tst_qhttpsocketengine.cpp | 10 +-- .../tst_qnativesocketengine.cpp | 2 +- .../tst_qsocks5socketengine.cpp | 12 +-- tests/auto/qsslsocket/tst_qsslsocket.cpp | 3 +- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 87 ++++++++++++++++------ 6 files changed, 142 insertions(+), 51 deletions(-) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 6730946..0cb8e3a 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -64,6 +64,7 @@ //#define SYMBIAN_WINSOCK_CONNECTIVITY #endif // Q_CC_NOKIAX86 +// FIXME: any reason we do this for symbian only, and not other platforms? class QtNetworkSettingsRecord { public: QtNetworkSettingsRecord() { } @@ -128,7 +129,6 @@ public: static QString wildcardServerName() { return "qt-test-server.wildcard.dev." + serverDomainName(); - //return "qttest.wildcard.dev." + serverDomainName(); } #ifdef QT_NETWORK_LIB @@ -149,8 +149,10 @@ public: } #endif - static QByteArray expectedReplyIMAP() + static bool compareReplyIMAP(QByteArray const& actual) { + QList expected; + #ifdef Q_OS_SYMBIAN loadTestSettings(); @@ -160,17 +162,35 @@ public: imapExpectedReply = entry->recordValue().toAscii(); imapExpectedReply.append('\r').append('\n'); } - return imapExpectedReply.data(); + expected << imapExpectedReply.data(); } #endif - QByteArray expected( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " ); - expected = expected.append(QtNetworkSettings::serverName().toAscii()); - expected = expected.append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - return expected; + + // Mandriva; old test server + expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " ) + .append(QtNetworkSettings::serverName().toAscii()) + .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + + // Ubuntu 10.04; new test server + expected << QByteArray( "* OK " ) + .append(QtNetworkSettings::serverLocalName().toAscii()) + .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); + + // Feel free to add more as needed + + Q_FOREACH (QByteArray const& ba, expected) { + if (ba == actual) { + return true; + } + } + + return false; } - static QByteArray expectedReplySSL() + static bool compareReplyIMAPSSL(QByteArray const& actual) { + QList expected; + #ifdef Q_OS_SYMBIAN loadTestSettings(); @@ -180,19 +200,46 @@ public: imapExpectedReplySsl = entry->recordValue().toAscii(); imapExpectedReplySsl.append('\r').append('\n'); } - return imapExpectedReplySsl.data(); + expected << imapExpectedReplySsl.data(); } #endif - QByteArray expected( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " ); - expected = expected.append(QtNetworkSettings::serverName().toAscii()); - expected = expected.append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - return expected; + // Mandriva; old test server + expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " ) + .append(QtNetworkSettings::serverName().toAscii()) + .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + + // Ubuntu 10.04; new test server + expected << QByteArray( "* OK " ) + .append(QtNetworkSettings::serverLocalName().toAscii()) + .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); + + // Feel free to add more as needed + + Q_FOREACH (QByteArray const& ba, expected) { + if (ba == actual) { + return true; + } + } + + return false; } - static QByteArray expectedReplyFtp() + static bool compareReplyFtp(QByteArray const& actual) { - QByteArray expected( "220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n" ); - return expected; + QList expected; + + // A few different vsFTPd versions. + // Feel free to add more as needed + expected << QByteArray( "220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n" ); + expected << QByteArray( "220 (vsFTPd 2.2.2)\r\n221 Goodbye.\r\n" ); + + Q_FOREACH (QByteArray const& ba, expected) { + if (ba == actual) { + return true; + } + } + + return false; } #ifdef Q_OS_SYMBIAN diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp index f86ba63..972185b 100644 --- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -325,7 +325,7 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message @@ -455,7 +455,7 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() // Read greeting QVERIFY(socket.waitForReadyRead(5000)); QString s = socket.readLine(); - QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), qPrintable(s)); // Write NOOP QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8); @@ -530,8 +530,8 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() // Read greeting QVERIFY(!tcpSocketNonBlocking_data.isEmpty()); - QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(), - QtNetworkSettings::expectedReplyIMAP().constData()); + QByteArray data = tcpSocketNonBlocking_data.at(0).toLatin1(); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(data), data.constData()); tcpSocketNonBlocking_data.clear(); @@ -713,7 +713,7 @@ void tst_QHttpSocketEngine::passwordAuth() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message diff --git a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp index 2b0b632..782c2f0 100644 --- a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp +++ b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp @@ -173,7 +173,7 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "ZZZ LOGOUT\r\n"; diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index 8f0cbc3..9da7197 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -336,7 +336,7 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; @@ -596,7 +596,7 @@ void tst_QSocks5SocketEngine::tcpSocketBlockingTest() // Read greeting QVERIFY(socket.waitForReadyRead(5000)); QString s = socket.readLine(); - QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), s.toLatin1().constData()); // Write NOOP QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8); @@ -671,8 +671,8 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() // Read greeting QVERIFY(!tcpSocketNonBlocking_data.isEmpty()); - QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(), - QtNetworkSettings::expectedReplyIMAP().constData()); + QByteArray data = tcpSocketNonBlocking_data.at(0).toLatin1(); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(data), data.constData()); tcpSocketNonBlocking_data.clear(); @@ -859,7 +859,7 @@ void tst_QSocks5SocketEngine::passwordAuth() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; @@ -927,7 +927,7 @@ void tst_QSocks5SocketEngine::passwordAuth2() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index d6a7a01..3223006 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -502,8 +502,9 @@ void tst_QSslSocket::simpleConnectWithIgnore() if (!socket.canReadLine()) enterLoop(10); - QCOMPARE(socket.readAll(), QtNetworkSettings::expectedReplySSL()); + QByteArray data = socket.readAll(); socket.disconnectFromHost(); + QVERIFY2(QtNetworkSettings::compareReplyIMAPSSL(data), data.constData()); } void tst_QSslSocket::sslErrors_data() diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 2dbe5b7..86069cd 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -95,6 +95,7 @@ #include "private/qhostinfo_p.h" #include "../network-settings.h" +#include "../../shared/util.h" Q_DECLARE_METATYPE(QAbstractSocket::SocketError) Q_DECLARE_METATYPE(QAbstractSocket::SocketState) @@ -222,6 +223,8 @@ protected slots: void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth); private: + QByteArray expectedReplyIMAP(); + void fetchExpectedReplyIMAP(); QTcpSocket *newSocket() const; QTcpSocket *nonBlockingIMAP_socket; QStringList nonBlockingIMAP_data; @@ -233,6 +236,8 @@ private: bool readingBody; QTime timer; + QByteArray expectedReplyIMAP_cached; + mutable int proxyAuthCalled; bool gotClosedSignal; @@ -658,8 +663,6 @@ void tst_QTcpSocket::nonBlockingIMAP() // Read greeting QVERIFY(!nonBlockingIMAP_data.isEmpty()); -// QCOMPARE(nonBlockingIMAP_data.at(0).toLatin1().constData(), -// "* OK fluke Cyrus IMAP4 v2.2.12 server ready\r\n"); QCOMPARE(nonBlockingIMAP_data.at(0).left(4).toLatin1().constData(), "* OK"); nonBlockingIMAP_data.clear(); @@ -787,6 +790,36 @@ void tst_QTcpSocket::delayedClose() delete socket; } + +//---------------------------------------------------------------------------------- + +QByteArray tst_QTcpSocket::expectedReplyIMAP() +{ + if (expectedReplyIMAP_cached.isEmpty()) { + fetchExpectedReplyIMAP(); + } + + return expectedReplyIMAP_cached; +} + +// Figure out how the current IMAP server responds +void tst_QTcpSocket::fetchExpectedReplyIMAP() +{ + QTcpSocket *socket = newSocket(); + socket->connectToHost(QtNetworkSettings::serverName(), 143); + QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); + QVERIFY2(socket->state() == QTcpSocket::ConnectedState, qPrintable(socket->errorString())); + + QTRY_VERIFY(socket->canReadLine()); + + QByteArray greeting = socket->readLine(); + delete socket; + + QVERIFY2(QtNetworkSettings::compareReplyIMAP(greeting), greeting.constData()); + + expectedReplyIMAP_cached = greeting; +} + //---------------------------------------------------------------------------------- void tst_QTcpSocket::partialRead() @@ -797,8 +830,8 @@ void tst_QTcpSocket::partialRead() QVERIFY(socket->state() == QTcpSocket::ConnectedState); char buf[512]; -// QByteArray greeting = "* OK fluke Cyrus IMAP4 v2.2.12 server ready"; - QByteArray greeting = "* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE"; + QByteArray greeting = expectedReplyIMAP(); + QVERIFY(!greeting.isEmpty()); for (int i = 0; i < 10; i += 2) { while (socket->bytesAvailable() < 2) @@ -821,8 +854,8 @@ void tst_QTcpSocket::unget() QVERIFY(socket->state() == QTcpSocket::ConnectedState); char buf[512]; -// QByteArray greeting = "* OK fluke Cyrus IMAP4 v2.2.12 server ready"; - QByteArray greeting = "* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE"; + QByteArray greeting = expectedReplyIMAP(); + QVERIFY(!greeting.isEmpty()); for (int i = 0; i < 10; i += 2) { while (socket->bytesAvailable() < 2) @@ -1244,13 +1277,17 @@ void tst_QTcpSocket::readLine() QVERIFY(socket->waitForReadyRead(10000)); char buffer[1024]; - int expectedReplySize = QtNetworkSettings::expectedReplyIMAP().size(); - Q_ASSERT(expectedReplySize >= 3); - QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(expectedReplySize)); - QCOMPARE((int) buffer[expectedReplySize-2], (int) '\r'); - QCOMPARE((int) buffer[expectedReplySize-1], (int) '\n'); - QCOMPARE((int) buffer[expectedReplySize], (int) '\0'); + qint64 linelen = socket->readLine(buffer, sizeof(buffer)); + QVERIFY(linelen >= 3); + QVERIFY(linelen < 1024); + + QByteArray reply = QByteArray::fromRawData(buffer, linelen); + QCOMPARE((int) buffer[linelen-2], (int) '\r'); + QCOMPARE((int) buffer[linelen-1], (int) '\n'); + QCOMPARE((int) buffer[linelen], (int) '\0'); + + QVERIFY2(QtNetworkSettings::compareReplyIMAP(reply), reply.constData()); QCOMPARE(socket->write("1 NOOP\r\n"), qint64(8)); @@ -1282,13 +1319,11 @@ void tst_QTcpSocket::readLine() void tst_QTcpSocket::readLineString() { QTcpSocket *socket = newSocket(); -// QByteArray expected("* OK fluke Cyrus IMAP4 v2.2.12 server ready\r\n"); - QByteArray expected("* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); socket->connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket->waitForReadyRead(10000)); QByteArray arr = socket->readLine(); - QCOMPARE(arr, QtNetworkSettings::expectedReplyIMAP()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(arr), arr.constData()); delete socket; } @@ -1456,8 +1491,11 @@ void tst_QTcpSocket::atEnd() QVERIFY(!stream.atEnd()); QString greeting = stream.readLine(); QVERIFY(stream.atEnd()); -// QCOMPARE(greeting, QString("220 (vsFTPd 2.0.4)")); - QCOMPARE(greeting, QString("220 (vsFTPd 2.0.5)")); + + // Test server must use some vsFTPd 2.x.x version + QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting)); + QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting)); + QVERIFY2(greeting.endsWith(")"), qPrintable(greeting)); delete socket; } @@ -1522,7 +1560,8 @@ void tst_QTcpSocket::socketInAThread() TestThread thread; thread.start(); QVERIFY(thread.wait(15000)); - QCOMPARE(thread.data(), QtNetworkSettings::expectedReplyFtp()); + QByteArray data = thread.data(); + QVERIFY2(QtNetworkSettings::compareReplyFtp(data), data.constData()); } } @@ -1542,9 +1581,13 @@ void tst_QTcpSocket::socketsInThreads() QVERIFY(thread3.wait(15000)); QVERIFY(thread1.wait(15000)); - QCOMPARE(thread1.data(),QtNetworkSettings::expectedReplyFtp()); - QCOMPARE(thread2.data(),QtNetworkSettings::expectedReplyFtp()); - QCOMPARE(thread3.data(),QtNetworkSettings::expectedReplyFtp()); + QByteArray data1 = thread1.data(); + QByteArray data2 = thread2.data(); + QByteArray data3 = thread3.data(); + + QVERIFY2(QtNetworkSettings::compareReplyFtp(data1), data1.constData()); + QVERIFY2(QtNetworkSettings::compareReplyFtp(data2), data2.constData()); + QVERIFY2(QtNetworkSettings::compareReplyFtp(data3), data3.constData()); } } @@ -1846,7 +1889,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() QCOMPARE(readyReadSpy.count(), 1); QString s = socket->readLine(); - QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), s.toLatin1().constData()); QCOMPARE(socket->bytesAvailable(), qint64(0)); QCoreApplication::instance()->processEvents(); -- cgit v0.12