summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-13 14:27:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-13 16:08:01 +0200
commitff334fd57414be90ab6b40f91e16f0bdb1835762 (patch)
treebb74d8217781394163870cb3399f0984136498c8 /tests/auto
parentec4c93a852ddc1d1437232241de492ad20d4cbb1 (diff)
parentb5552bab40f2e165cf7196993ffc83785f4d8264 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp47
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp15
-rw-r--r--tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp71
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp4
-rw-r--r--tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp6
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp45
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp29
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp148
-rw-r--r--tests/auto/widgets/styles/styles.pro2
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp34
10 files changed, 333 insertions, 68 deletions
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index 53aef40df0..59c951332e 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -192,6 +192,8 @@ private slots:
void QTBUG28998_linkColor();
+ void textCursorUsageWithinContentsChange();
+
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -3021,5 +3023,50 @@ void tst_QTextDocument::QTBUG28998_linkColor()
QCOMPARE(format.foreground(), pal.link());
}
+class ContentsChangeHandler : public QObject
+{
+ Q_OBJECT
+public:
+ ContentsChangeHandler(QTextDocument *doc)
+ : verticalMovementX(-1)
+ , doc(doc)
+ {
+ connect(doc, SIGNAL(contentsChange(int,int,int)),
+ this, SLOT(saveModifiedText(int, int, int)));
+ }
+
+private slots:
+ void saveModifiedText(int from, int /*charsRemoved*/, int charsAdded)
+ {
+ QTextCursor tmp(doc);
+ tmp.setPosition(from);
+ tmp.setPosition(from + charsAdded, QTextCursor::KeepAnchor);
+ text = tmp.selectedText();
+ verticalMovementX = tmp.verticalMovementX();
+ }
+
+public:
+ QString text;
+ int verticalMovementX;
+private:
+ QTextDocument *doc;
+};
+
+void tst_QTextDocument::textCursorUsageWithinContentsChange()
+{
+ // force creation of layout
+ doc->documentLayout();
+
+ QTextCursor cursor(doc);
+ cursor.insertText("initial text");
+
+ ContentsChangeHandler handler(doc);
+
+ cursor.insertText("new text");
+
+ QCOMPARE(handler.text, QString("new text"));
+ QCOMPARE(handler.verticalMovementX, -1);
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index d0482d77e2..26eaec0470 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -122,6 +122,7 @@ private slots:
void boundingRectForUnsetLineWidth();
void boundingRectForSetLineWidth();
void glyphLessItems();
+ void justifyTrailingSpaces();
// QTextLine stuff
void setNumColumnsWrapAtWordBoundaryOrAnywhere();
@@ -1996,5 +1997,19 @@ void tst_QTextLayout::cursorInNonStopChars()
QVERIFY(line.cursorToX(2) == line.cursorToX(3));
}
+void tst_QTextLayout::justifyTrailingSpaces()
+{
+ QTextLayout layout(QStringLiteral(" t"), testFont);
+ layout.setTextOption(QTextOption(Qt::AlignJustify));
+ layout.beginLayout();
+
+ QTextLine line = layout.createLine();
+ line.setLineWidth(5);
+
+ layout.endLayout();
+
+ QVERIFY(qFuzzyIsNull(layout.lineAt(0).cursorToX(0)));
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"
diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
index e3151ba862..f98cde51f9 100644
--- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
@@ -81,6 +81,7 @@ private slots:
void emptyConstructor();
void constructor_data();
void constructor();
+ void constructor_device();
void constructingGarbage();
void copyAndAssign_data();
void copyAndAssign();
@@ -111,6 +112,8 @@ private slots:
void verify();
void extensions();
void threadSafeConstMethods();
+ void version_data();
+ void version();
// helper for verbose test failure messages
QString toString(const QList<QSslError>&);
@@ -226,6 +229,47 @@ void tst_QSslCertificate::constructor()
QVERIFY(!certificate.isNull());
}
+void tst_QSslCertificate::constructor_device()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QFile f(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
+ bool ok = f.open(QIODevice::ReadOnly);
+ QVERIFY(ok);
+
+ QSslCertificate cert(&f);
+ QVERIFY(!cert.isNull());
+ f.close();
+
+ // Check opening a DER as a PEM fails
+ QFile f2(testDataDir + "/certificates/cert.der");
+ ok = f2.open(QIODevice::ReadOnly);
+ QVERIFY(ok);
+
+ QSslCertificate cert2(&f2);
+ QVERIFY(cert2.isNull());
+ f2.close();
+
+ // Check opening a DER as a DER works
+ QFile f3(testDataDir + "/certificates/cert.der");
+ ok = f3.open(QIODevice::ReadOnly);
+ QVERIFY(ok);
+
+ QSslCertificate cert3(&f3, QSsl::Der);
+ QVERIFY(!cert3.isNull());
+ f3.close();
+
+ // Check opening a PEM as a DER fails
+ QFile f4(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
+ ok = f4.open(QIODevice::ReadOnly);
+ QVERIFY(ok);
+
+ QSslCertificate cert4(&f4, QSsl::Der);
+ QVERIFY(cert4.isNull());
+ f4.close();
+}
+
void tst_QSslCertificate::constructingGarbage()
{
if (!QSslSocket::supportsSsl())
@@ -1158,6 +1202,33 @@ void tst_QSslCertificate::threadSafeConstMethods()
}
+void tst_QSslCertificate::version_data()
+{
+ QTest::addColumn<QSslCertificate>("certificate");
+ QTest::addColumn<QByteArray>("result");
+
+ QTest::newRow("null certificate") << QSslCertificate() << QByteArray();
+
+ QList<QSslCertificate> certs;
+ certs << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-ocsp-good-cert.pem");
+
+ QTest::newRow("v3 certificate") << certs.first() << QByteArrayLiteral("3");
+
+ certs.clear();
+ certs << QSslCertificate::fromPath(testDataDir + "/certificates/cert.pem");
+ QTest::newRow("v1 certificate") << certs.first() << QByteArrayLiteral("1");
+}
+
+void tst_QSslCertificate::version()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QFETCH(QSslCertificate, certificate);
+ QFETCH(QByteArray, result);
+ QCOMPARE(certificate.version(), result);
+}
+
#endif // QT_NO_SSL
QTEST_MAIN(tst_QSslCertificate)
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 10ccebfec2..9715375e95 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1935,7 +1935,7 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(iface->state().movable);
QVERIFY(iface->state().focusable);
QVERIFY(iface->state().selectable);
- QVERIFY(iface->state().hasPopup);
+ QVERIFY(!iface->state().hasPopup);
QCOMPARE(bool(iface->state().focused), le->hasFocus());
QString secret(QLatin1String("secret"));
@@ -1963,7 +1963,7 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(!(iface->state().movable));
QVERIFY(iface->state().focusable);
QVERIFY(iface->state().selectable);
- QVERIFY(iface->state().hasPopup);
+ QVERIFY(!iface->state().hasPopup);
QCOMPARE(bool(iface->state().focused), le->hasFocus());
QLineEdit *le2 = new QLineEdit(toplevel);
diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp
index e85c64db8e..881f2b5c7c 100644
--- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp
+++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp
@@ -50,7 +50,7 @@
#include "qdebug.h"
#ifdef Q_OS_LINUX
-#include <pthread.h>
+#include <sched.h>
#endif
const QString qtest(qTableName("qtest", __FILE__, QSqlDatabase()));
@@ -159,7 +159,7 @@ public:
q.bindValue(2, 10);
QVERIFY_SQL(q, exec());
#ifdef Q_OS_LINUX
- pthread_yield();
+ sched_yield();
#endif
}
}
@@ -197,7 +197,7 @@ public:
q1.clear();
QVERIFY_SQL(q2, exec());
#ifdef Q_OS_LINUX
- pthread_yield();
+ sched_yield();
#endif
}
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 047df0d3f2..096658ae02 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -171,6 +171,7 @@ private slots:
void tildeExpansion();
#endif // QT_BUILD_INTERNAL
#endif
+ void getFileUrl();
private:
QByteArray userSettings;
@@ -1429,5 +1430,49 @@ void tst_QFiledialog::tildeExpansion()
#endif // QT_BUILD_INTERNAL
#endif
+class DialogRejecter : public QObject
+{
+ Q_OBJECT
+public:
+ DialogRejecter()
+ {
+ QTimer *timer = new QTimer(this);
+ timer->setInterval(1000);
+ connect(timer, &QTimer::timeout, this, &DialogRejecter::rejectFileDialog);
+ timer->start();
+ }
+
+public slots:
+ void rejectFileDialog()
+ {
+ if (QWidget *w = QApplication::activeModalWidget())
+ if (QDialog *d = qobject_cast<QDialog *>(w))
+ d->reject();
+ }
+};
+
+void tst_QFiledialog::getFileUrl()
+{
+ // QTBUG-38672 , static functions should return empty Urls
+ const QFileDialog::Options options = QFileDialog::DontUseNativeDialog;
+ DialogRejecter dr;
+
+ QUrl url = QFileDialog::getOpenFileUrl(0, QStringLiteral("getOpenFileUrl"),
+ QUrl(), QString(), Q_NULLPTR, options);
+ QVERIFY(url.isEmpty());
+ QVERIFY(!url.isValid());
+
+ url = QFileDialog::getExistingDirectoryUrl(0, QStringLiteral("getExistingDirectoryUrl"),
+ QUrl(), options | QFileDialog::ShowDirsOnly);
+ QVERIFY(url.isEmpty());
+ QVERIFY(!url.isValid());
+
+ url = QFileDialog::getSaveFileUrl(0, QStringLiteral("getSaveFileUrl"),
+ QUrl(), QString(), Q_NULLPTR, options);
+ QVERIFY(url.isEmpty());
+ QVERIFY(!url.isValid());
+
+}
+
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 77690cc27a..d12fb06daa 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -261,6 +261,7 @@ private slots:
void taskQTBUG_18539_emitLayoutChanged();
void taskQTBUG_8176_emitOnExpandAll();
void taskQTBUG_34717_collapseAtBottom();
+ void taskQTBUG_37813_crash();
void testInitialFocus();
};
@@ -4327,5 +4328,31 @@ void tst_QTreeView::quickExpandCollapse()
}
#endif
+void tst_QTreeView::taskQTBUG_37813_crash()
+{
+ // QTBUG_37813: Crash in visual / logical index mapping in QTreeViewPrivate::adjustViewOptionsForIndex()
+ // when hiding/moving columns. It is reproduceable with a QTreeWidget only.
+#ifdef QT_BUILD_INTERNAL
+ QTreeWidget treeWidget;
+ treeWidget.setDragEnabled(true);
+ treeWidget.setColumnCount(2);
+ QList<QTreeWidgetItem *> items;
+ for (int r = 0; r < 2; ++r) {
+ QTreeWidgetItem *item = new QTreeWidgetItem();
+ for (int c = 0; c < treeWidget.columnCount(); ++c)
+ item->setText(c, QString::fromLatin1("Row %1 Column %2").arg(r).arg(c));
+ items.append(item);
+ }
+ treeWidget.addTopLevelItems(items);
+ treeWidget.setColumnHidden(0, true);
+ treeWidget.header()->moveSection(0, 1);
+ QItemSelection sel(treeWidget.model()->index(0, 0), treeWidget.model()->index(0, 1));
+ QRect rect;
+ QAbstractItemViewPrivate *av = static_cast<QAbstractItemViewPrivate*>(qt_widget_private(&treeWidget));
+ const QPixmap pixmap = av->renderToPixmap(sel.indexes(), &rect);
+ QVERIFY(pixmap.size().isValid());
+#endif // QT_BUILD_INTERNAL
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 5a36ffc671..14d59d3630 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -49,6 +49,12 @@
#include "../../../qtest-config.h"
+static inline void centerOnScreen(QWidget *w)
+{
+ const QPoint offset = QPoint(w->width() / 2, w->height() / 2);
+ w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
+}
+
class tst_QStyleSheetStyle : public QObject
{
Q_OBJECT
@@ -142,6 +148,8 @@ tst_QStyleSheetStyle::~tst_QStyleSheetStyle()
void tst_QStyleSheetStyle::numinstances()
{
QWidget w;
+ w.resize(200, 200);
+ centerOnScreen(&w);
QCommonStyle *style = new QCommonStyle;
style->setParent(&w);
QWidget c(&w);
@@ -531,7 +539,14 @@ void tst_QStyleSheetStyle::dynamicProperty()
qApp->setStyleSheet(QString());
QString appStyle = qApp->style()->metaObject()->className();
- QPushButton pb1, pb2;
+ QPushButton pb1(QStringLiteral("dynamicProperty_pb1"));
+ pb1.setMinimumWidth(160);
+ pb1.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100));
+
+ QPushButton pb2(QStringLiteral("dynamicProperty_pb2"));
+ pb2.setMinimumWidth(160);
+ pb2.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 200));
+
pb1.setProperty("type", "critical");
qApp->setStyleSheet("*[class~=\"QPushButton\"] { color: red; } *[type=\"critical\"] { background: white; }");
QVERIFY(COLOR(pb1) == Qt::red);
@@ -675,6 +690,8 @@ void tst_QStyleSheetStyle::onWidgetDestroyed()
void tst_QStyleSheetStyle::fontPrecedence()
{
QLineEdit edit;
+ edit.setMinimumWidth(200);
+ centerOnScreen(&edit);
edit.show();
QFont font;
QVERIFY(FONTSIZE(edit) != 22); // Sanity check to make sure this test makes sense.
@@ -737,8 +754,9 @@ void tst_QStyleSheetStyle::focusColors()
// ten pixels of the right color requires quite a many characters, as the
// majority of the pixels will have slightly different colors due to the
// anti-aliasing effect.
-#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) && !(defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL))
- QSKIP("This is a fragile test which fails on many esoteric platforms because of focus problems. "
+#if !defined(Q_OS_WIN32) && !(defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL))
+ QSKIP("This is a fragile test which fails on many esoteric platforms because of focus problems"
+ " (for example, QTBUG-33959)."
"That doesn't mean that the feature doesn't work in practice.");
#endif
QList<QWidget *> widgets;
@@ -768,6 +786,7 @@ void tst_QStyleSheetStyle::focusColors()
layout->addWidget(widget);
frame.setLayout(layout);
+ centerOnScreen(&frame);
frame.show();
QApplication::setActiveWindow(&frame);
QVERIFY(QTest::qWaitForWindowActive(&frame));
@@ -795,6 +814,9 @@ void tst_QStyleSheetStyle::focusColors()
#ifndef QTEST_NO_CURSOR
void tst_QStyleSheetStyle::hoverColors()
{
+#ifdef Q_OS_OSX
+ QSKIP("This test is fragile on Mac, most likely due to QTBUG-33959.");
+#endif
QList<QWidget *> widgets;
widgets << new QPushButton("TESTING TESTING");
widgets << new QLineEdit("TESTING TESTING");
@@ -822,31 +844,22 @@ void tst_QStyleSheetStyle::hoverColors()
layout->addWidget(widget);
frame.setLayout(layout);
+ centerOnScreen(&frame);
frame.show();
QApplication::setActiveWindow(&frame);
QVERIFY(QTest::qWaitForWindowActive(&frame));
//move the mouse inside the widget, it should be colored
QTest::mouseMove ( widget, QPoint(6,6));
- QTest::qWait(60);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "Numerous failures related to Qt::WA_UnderMouse, see QTBUGT-23685", Continue);
-#endif
- QVERIFY(widget->testAttribute(Qt::WA_UnderMouse));
+ QTRY_VERIFY(widget->testAttribute(Qt::WA_UnderMouse));
QImage image(frame.width(), frame.height(), QImage::Format_ARGB32);
frame.render(&image);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "Numerous failures related to Qt::WA_UnderMouse, see QTBUGT-23685", Continue);
-#endif
QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)),
(QString::fromLatin1(widget->metaObject()->className())
+ " did not contain background color #e8ff66").toLocal8Bit().constData());
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "Numerous failures related to Qt::WA_UnderMouse, see QTBUGT-23685", Continue);
-#endif
QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
(QString::fromLatin1(widget->metaObject()->className())
+ " did not contain text color #ff0084").toLocal8Bit().constData());
@@ -866,9 +879,7 @@ void tst_QStyleSheetStyle::hoverColors()
//move the mouse again inside the widget, it should be colored
QTest::mouseMove (widget, QPoint(5,5));
- QTest::qWait(60);
-
- QVERIFY(widget->testAttribute(Qt::WA_UnderMouse));
+ QTRY_VERIFY(widget->testAttribute(Qt::WA_UnderMouse));
frame.render(&image);
@@ -904,35 +915,47 @@ public:
void tst_QStyleSheetStyle::background()
{
- const int number = 4;
- QWidget* widgets[number];
+ typedef QSharedPointer<QWidget> WidgetPtr;
+
+ const QString styleSheet = QStringLiteral("* { background-color: #e8ff66; }");
+ QVector<WidgetPtr> widgets;
+ const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
// Testing inheritance styling of QDialog.
- widgets[0] = new SingleInheritanceDialog;
- widgets[0]->setStyleSheet("* { background-color: #e8ff66; }");
- widgets[1] = new DoubleInheritanceDialog;
- widgets[1]->setStyleSheet("* { background-color: #e8ff66; }");
+ WidgetPtr toplevel(new SingleInheritanceDialog);
+ toplevel->resize(200, 200);
+ toplevel->move(topLeft + QPoint(20, 20));
+ toplevel->setStyleSheet(styleSheet);
+ widgets.append(toplevel);
+
+ toplevel = WidgetPtr(new DoubleInheritanceDialog);
+ toplevel->resize(200, 200);
+ toplevel->move(topLeft + QPoint(20, 320));
+ toplevel->setStyleSheet(styleSheet);
+ widgets.append(toplevel);
// Testing gradients in QComboBox.
- QLayout* layout;
- QComboBox* cb;
// First color
- widgets[2] = new QDialog;
- layout = new QGridLayout;
- cb = new QComboBox;
+ toplevel = WidgetPtr(new QDialog);
+ toplevel->move(topLeft + QPoint(320, 20));
+ QGridLayout *layout = new QGridLayout(toplevel.data());
+ QComboBox* cb = new QComboBox;
+ cb->setMinimumWidth(160);
cb->setStyleSheet("* { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #e8ff66, stop:1 #000000); }");
- layout->addWidget(cb);
- widgets[2]->setLayout(layout);
+ layout->addWidget(cb, 0, 0);
+ widgets.append(toplevel);
// Second color
- widgets[3] = new QDialog;
- layout = new QGridLayout;
+ toplevel = WidgetPtr(new QDialog);
+ toplevel->move(topLeft + QPoint(320, 320));
+ layout = new QGridLayout(toplevel.data());
cb = new QComboBox;
+ cb->setMinimumWidth(160);
cb->setStyleSheet("* { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #e8ff66, stop:1 #000000); }");
- layout->addWidget(cb);
- widgets[3]->setLayout(layout);
-
- for (int c = 0; c < number; ++c) {
- QWidget* widget = widgets[c];
+ layout->addWidget(cb, 0, 0);
+ widgets.append(toplevel);
+ for (int c = 0; c < widgets.size(); ++c) {
+ QWidget *widget = widgets.at(c).data();
+ widget->setWindowTitle(QStringLiteral("background ") + QString::number(c));
widget->show();
QVERIFY(QTest::qWaitForWindowExposed(widget));
@@ -941,12 +964,15 @@ void tst_QStyleSheetStyle::background()
if (image.depth() < 24)
QSKIP("Test doesn't support color depth < 24");
+ if (c == 2 && !QApplication::style()->objectName().compare(QLatin1String("fusion"), Qt::CaseInsensitive))
+ QEXPECT_FAIL("", "QTBUG-21468", Abort);
+
QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)),
- (QString::fromLatin1(widget->metaObject()->className())
+ (QString::number(c) + QLatin1Char(' ') + QString::fromLatin1(widget->metaObject()->className())
+ " did not contain background image with color #e8ff66")
.toLocal8Bit().constData());
- delete widget;
+ widget->hide();
}
}
@@ -956,6 +982,7 @@ void tst_QStyleSheetStyle::tabAlignement()
QTabWidget tabWidget(&topLevel);
tabWidget.addTab(new QLabel("tab1"),"tab1");
tabWidget.resize(QSize(400,400));
+ centerOnScreen(&topLevel);
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QTabBar *bar = tabWidget.findChild<QTabBar*>();
@@ -1023,6 +1050,7 @@ void tst_QStyleSheetStyle::minmaxSizes()
tabWidget.setStyleSheet("QTabBar::tab { min-width:100px; max-width:130px; }");
+ centerOnScreen(&tabWidget);
tabWidget.show();
QTest::qWait(50);
//i allow 4px additional border from the native style (hence the -2, <=2)
@@ -1050,6 +1078,7 @@ void tst_QStyleSheetStyle::task206238_twice()
tw->addTab(new QLabel("foo"), "test");
w.setCentralWidget(tw);
w.setStyleSheet("background: red;");
+ centerOnScreen(&w);
w.show();
QTest::qWait(20);
QCOMPARE(BACKGROUND(w) , QColor("red"));
@@ -1219,6 +1248,8 @@ void tst_QStyleSheetStyle::proxyStyle()
QString styleSheet("QPushButton {background-color: red; }");
QWidget *w = new QWidget;
+ w->setMinimumWidth(160);
+ centerOnScreen(w);
QVBoxLayout *layout = new QVBoxLayout(w);
QPushButton *pb1 = new QPushButton(qApp->style()->objectName(), w);
@@ -1294,6 +1325,7 @@ void tst_QStyleSheetStyle::emptyStyleSheet()
layout.addWidget(new QDateEdit(&w));
layout.addWidget(new QGroupBox("some text", &w));
+ centerOnScreen(&w);
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
//workaround the fact that the label sizehint is one pixel different the first time.
@@ -1315,13 +1347,30 @@ void tst_QStyleSheetStyle::emptyStyleSheet()
img2.save("emptyStyleSheet_img2.png");
}
+ QEXPECT_FAIL("", "QTBUG-21468", Abort);
QCOMPARE(img1,img2);
}
+class ApplicationStyleSetter
+{
+public:
+ explicit inline ApplicationStyleSetter(QStyle *s) : m_oldStyleName(QApplication::style()->objectName())
+ { QApplication::setStyle(s); }
+ inline ~ApplicationStyleSetter()
+ { QApplication::setStyle(QStyleFactory::create(m_oldStyleName)); }
+
+private:
+ const QString m_oldStyleName;
+};
+
void tst_QStyleSheetStyle::toolTip()
{
qApp->setStyleSheet(QString());
QWidget w;
+ // Use "Fusion" to prevent the Vista style from clobbering the tooltip palette in polish().
+ QStyle *fusionStyle = QStyleFactory::create(QLatin1String("Fusion"));
+ QVERIFY(fusionStyle);
+ ApplicationStyleSetter as(fusionStyle);
QHBoxLayout layout(&w);
w.setLayout(&layout);
@@ -1349,11 +1398,12 @@ void tst_QStyleSheetStyle::toolTip()
wid4->setToolTip("this is wid4");
wid4->setObjectName("wid4");
+ centerOnScreen(&w);
w.show();
qApp->setActiveWindow(&w);
QVERIFY(QTest::qWaitForWindowActive(&w));
- QColor normalToolTip = qApp->palette().toolTipBase().color();
+ const QColor normalToolTip = QToolTip::palette().color(QPalette::Inactive, QPalette::ToolTipBase);
QList<QWidget *> widgets;
QList<QColor> colors;
@@ -1372,12 +1422,13 @@ void tst_QStyleSheetStyle::toolTip()
QWidget *tooltip = 0;
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
- if (widget->inherits("QTipLabel") && widget->isVisible()) {
+ if (widget->inherits("QTipLabel")) {
tooltip = widget;
break;
}
}
QVERIFY(tooltip);
+ QTRY_VERIFY(tooltip->isVisible()); // Wait until Roll-Effect is finished (Windows Vista)
QCOMPARE(tooltip->palette().color(tooltip->backgroundRole()), col);
}
@@ -1394,6 +1445,8 @@ void tst_QStyleSheetStyle::embeddedFonts()
{
//task 235622 and 210551
QSpinBox spin;
+ spin.setMinimumWidth(160);
+ spin.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 20));
spin.show();
spin.setStyleSheet("QSpinBox { font-size: 32px; }");
QTest::qWait(20);
@@ -1411,6 +1464,8 @@ void tst_QStyleSheetStyle::embeddedFonts()
//task 242556
QComboBox box;
+ box.setMinimumWidth(160);
+ box.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 120));
box.setEditable(true);
box.addItems(QStringList() << "First" << "Second" << "Third");
box.setStyleSheet("QComboBox { font-size: 32px; }");
@@ -1483,6 +1538,7 @@ void tst_QStyleSheetStyle::complexWidgetFocus()
layout->addWidget(widget);
frame.setLayout(layout);
+ centerOnScreen(&frame);
frame.show();
QApplication::setActiveWindow(&frame);
QVERIFY(QTest::qWaitForWindowActive(&frame));
@@ -1507,6 +1563,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
{
QTreeView tree;
tree.setStyleSheet( "QTreeView:disabled { background-color:#ab1251; }" );
+ tree.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100));
tree.show();
QTest::qWait(20);
QImage image(tree.width(), tree.height(), QImage::Format_ARGB32);
@@ -1527,6 +1584,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
QTableWidget table(12, 12);
table.setItem(0, 0, new QTableWidgetItem());
table.setStyleSheet( "QTableView {background-color: #ff0000}" );
+ table.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(300, 100));
table.show();
QTest::qWait(20);
image = QImage(table.width(), table.height(), QImage::Format_ARGB32);
@@ -1560,6 +1618,7 @@ void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()
layout->addWidget(spinbox);
frame.setLayout(layout);
+ centerOnScreen(&frame);
frame.show();
QApplication::setActiveWindow(&frame);
spinbox->setFocus();
@@ -1619,6 +1678,7 @@ void tst_QStyleSheetStyle::QTBUG11658_cachecrash()
Widget(QWidget *parent = 0)
: QWidget(parent)
{
+ setMinimumWidth(160);
QVBoxLayout* pLayout = new QVBoxLayout(this);
QCheckBox* pCheckBox = new QCheckBox(this);
pLayout->addWidget(pCheckBox);
@@ -1633,6 +1693,7 @@ void tst_QStyleSheetStyle::QTBUG11658_cachecrash()
Widget *w = new Widget();
delete w;
w = new Widget();
+ centerOnScreen(w);
w->show();
QVERIFY(QTest::qWaitForWindowExposed(w));
@@ -1653,6 +1714,8 @@ void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget()
}
} w;
w.setStyleSheet("* { background-color: white; color:black; border 3px solid yellow }");
+ w.setMinimumWidth(160);
+ centerOnScreen(&w);
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
}
@@ -1675,6 +1738,7 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
// parsing of this stylesheet must not crash, and it must be correctly applied
widget.setStyleSheet(QStringLiteral("QHeaderView::section:vertical { background-color: #FF0000 }"));
+ centerOnScreen(&widget);
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
@@ -1685,6 +1749,8 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
QHeaderView *verticalHeader = widget.verticalHeader();
QImage image(verticalHeader->size(), QImage::Format_ARGB32);
verticalHeader->render(&image);
+ if (!QApplication::style()->objectName().compare(QLatin1String("fusion"), Qt::CaseInsensitive))
+ QEXPECT_FAIL("", "QTBUG-21468", Abort);
QVERIFY(testForColors(image, QColor(0xFF, 0x00, 0x00)));
}
diff --git a/tests/auto/widgets/styles/styles.pro b/tests/auto/widgets/styles/styles.pro
index 1791279b72..508b6ecd41 100644
--- a/tests/auto/widgets/styles/styles.pro
+++ b/tests/auto/widgets/styles/styles.pro
@@ -12,5 +12,5 @@ SUBDIRS=\
!mac:SUBDIRS -= \
qmacstyle \
-!contains( styles, motif ):SUBDIRS -= \
+ios|android|qnx|*wince*:SUBDIRS -= \
qstylesheetstyle \
diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
index 6a3bcc7a7d..fadfc0b48a 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
@@ -60,26 +60,26 @@ class XmlServer : public QThread
{
Q_OBJECT
public:
- XmlServer();
+ XmlServer(QObject *parent = 0) : QThread(parent), quit_soon(false), listening(false) {}
+
bool quit_soon;
+ bool listening;
protected:
virtual void run();
};
-XmlServer::XmlServer()
-{
- quit_soon = false;
-}
-
-#define CHUNK_SIZE 1
+#define CHUNK_SIZE 2048
void XmlServer::run()
{
QTcpServer srv;
- if (!srv.listen(QHostAddress::Any, TEST_PORT))
+ listening = srv.listen(QHostAddress::Any, TEST_PORT);
+ if (!listening) {
+ qWarning() << "Failed to listen on" << TEST_PORT << srv.errorString();
return;
+ }
for (;;) {
srv.waitForNewConnection(100);
@@ -168,12 +168,9 @@ class tst_QXmlSimpleReader : public QObject
QString prefix;
};
-tst_QXmlSimpleReader::tst_QXmlSimpleReader()
+tst_QXmlSimpleReader::tst_QXmlSimpleReader() : server(new XmlServer(this))
{
- server = new XmlServer();
- server->setParent(this);
server->start();
- QTest::qSleep(1000);
}
tst_QXmlSimpleReader::~tst_QXmlSimpleReader()
@@ -568,16 +565,13 @@ void tst_QXmlSimpleReader::inputFromSocket()
{
QFETCH(QString, file_name);
+ QTRY_VERIFY(server->listening);
+
QTcpSocket sock;
sock.connectToHost(QHostAddress::LocalHost, TEST_PORT);
-
- const bool connectionSuccess = sock.waitForConnected();
- if(!connectionSuccess) {
- QTextStream out(stderr);
- out << "QTcpSocket::errorString()" << sock.errorString();
- }
-
- QVERIFY(connectionSuccess);
+ QVERIFY2(sock.waitForConnected(),
+ qPrintable(QStringLiteral("Cannot connect on port ") + QString::number(TEST_PORT)
+ + QStringLiteral(": ") + sock.errorString()));
sock.write(file_name.toLocal8Bit() + "\n");
QVERIFY(sock.waitForBytesWritten());