diff options
author | Liang Qi <liang.qi@qt.io> | 2018-04-26 09:55:10 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-04-26 09:55:10 +0200 |
commit | 866b47916dfcf2823b8fc4df719f1ebf15acef70 (patch) | |
tree | a4eef09d00d407dec26b99b9f094bf1f5093dcb8 | |
parent | a9fc91466c2c143bea422d98af24755f43c2b97b (diff) | |
parent | 4bab1b0d7c2462ee9c5369c949b45bc4dedc1194 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
src/plugins/platforms/cocoa/qcocoawindow.mm
Change-Id: Ideea96d1b43d47b1d9b34e11c9986a88e240aa71
50 files changed, 216 insertions, 310 deletions
diff --git a/bin/syncqt.pl b/bin/syncqt.pl index c6aced4412..9a889c062b 100755 --- a/bin/syncqt.pl +++ b/bin/syncqt.pl @@ -882,7 +882,6 @@ die "The -version argument is mandatory" if (!$module_version); $build_basedir = $out_basedir if (!defined($build_basedir)); our @ignore_headers = (); -our @ignore_for_master_contents = (); our @ignore_for_include_check = (); our @ignore_for_qt_begin_namespace_check = (); our @ignore_for_qt_module_check = (); @@ -1026,10 +1025,6 @@ foreach my $lib (@modules_to_sync) { $qpa_header = 1; } elsif ($allheadersprivate || $thisprivate || $public_header =~ /_p(ch)?\.h$/) { $public_header = 0; - } else { - foreach (@ignore_for_master_contents) { - $public_header = 0 if($header eq $_); - } } my $clean_header; diff --git a/configure.json b/configure.json index 323b25e1d6..595bb619ce 100644 --- a/configure.json +++ b/configure.json @@ -552,11 +552,11 @@ "output": [ "prepareSpec", "prepareOptions", "preparePaths", "reloadSpec" ] }, "machineTuple": { - "condition": "!config.linux || config.android || tests.machineTuple", + "condition": "config.linux && !config.android && tests.machineTuple", "output": [ "machineTuple" ] }, "commit": { - "condition": "features.machineTuple", + "condition": "features.machineTuple || true", "output": [ "commitOptions" ] }, "android-style-assets": { diff --git a/examples/widgets/doc/src/dirview.qdoc b/examples/widgets/doc/src/dirview.qdoc index d9a16fa58d..6db339eced 100644 --- a/examples/widgets/doc/src/dirview.qdoc +++ b/examples/widgets/doc/src/dirview.qdoc @@ -37,6 +37,10 @@ \borderedimage dirview-example.png + \quotefromfile itemviews/dirview/main.cpp + \skipto QCommandLineParser parser + \printuntil parser.positionalArguments + The example supports a number of command line options. These options include: \list @@ -47,22 +51,17 @@ use custom directory options \endlist - \quotefromfile itemviews/dirview/main.cpp - \skipto QCommandLineParser parser - \printuntil parser.positionalArguments - - Declares a QFileSystemModel as data model for viewing - the local file system. QFileSystem works with a cache, that is, - it is updated continually with QFileSystemWatcher on that folder. - \skipto QFileSystemModel \printuntil tree.setModel - Creates a model/view implementation called \c tree - for viewing the filesystem. + Declares \c model as data model for reading the local filesystem. + \c model.setRootPath("") sets the current folder as the folder from + which \c model will start reading. + QTreeView object \c tree visualizes the filesystem in a tree structure. \skipto tree.setAnimated(false) \printuntil tree.setWindowTitle - Sets some formatting options for \c tree. + Sets layout options for animation, indentation, sorting, and sizing of the + filesystem tree. */ diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index 5433b28025..78c174a8bf 100644 --- a/examples/widgets/painting/gradients/gradients.cpp +++ b/examples/widgets/painting/gradients/gradients.cpp @@ -88,7 +88,8 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent) setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - connect(m_hoverPoints, SIGNAL(pointsChanged(QPolygonF)), this, SIGNAL(colorsChanged())); + connect(m_hoverPoints, &HoverPoints::pointsChanged, + this, &ShadeWidget::colorsChanged); } QPolygonF ShadeWidget::points() const @@ -191,10 +192,14 @@ GradientEditor::GradientEditor(QWidget *parent) vbox->addWidget(m_blue_shade); vbox->addWidget(m_alpha_shade); - connect(m_red_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_green_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_blue_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); - connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); + connect(m_red_shade, &ShadeWidget::colorsChanged, + this, &GradientEditor::pointsUpdated); + connect(m_green_shade, &ShadeWidget::colorsChanged, + this, &GradientEditor::pointsUpdated); + connect(m_blue_shade, &ShadeWidget::colorsChanged, + this, &GradientEditor::pointsUpdated); + connect(m_alpha_shade, &ShadeWidget::colorsChanged, + this, &GradientEditor::pointsUpdated); } inline static bool x_less_than(const QPointF &p1, const QPointF &p2) @@ -354,33 +359,46 @@ GradientWidget::GradientWidget(QWidget *parent) defaultsGroupLayout->addWidget(default3Button); editorGroupLayout->addWidget(default4Button); - connect(m_editor, SIGNAL(gradientStopsChanged(QGradientStops)), - m_renderer, SLOT(setGradientStops(QGradientStops))); - - connect(m_linearButton, SIGNAL(clicked()), m_renderer, SLOT(setLinearGradient())); - connect(m_radialButton, SIGNAL(clicked()), m_renderer, SLOT(setRadialGradient())); - connect(m_conicalButton, SIGNAL(clicked()), m_renderer, SLOT(setConicalGradient())); - - connect(m_padSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setPadSpread())); - connect(m_reflectSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setReflectSpread())); - connect(m_repeatSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setRepeatSpread())); - - connect(default1Button, SIGNAL(clicked()), this, SLOT(setDefault1())); - connect(default2Button, SIGNAL(clicked()), this, SLOT(setDefault2())); - connect(default3Button, SIGNAL(clicked()), this, SLOT(setDefault3())); - connect(default4Button, SIGNAL(clicked()), this, SLOT(setDefault4())); - - connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource())); + connect(m_editor, &GradientEditor::gradientStopsChanged, + m_renderer, &GradientRenderer::setGradientStops); + connect(m_linearButton, &QRadioButton::clicked, + m_renderer, &GradientRenderer::setLinearGradient); + connect(m_radialButton, &QRadioButton::clicked, + m_renderer, &GradientRenderer::setRadialGradient); + connect(m_conicalButton,&QRadioButton::clicked, + m_renderer, &GradientRenderer::setConicalGradient); + + connect(m_padSpreadButton, &QRadioButton::clicked, + m_renderer, &GradientRenderer::setPadSpread); + connect(m_reflectSpreadButton, &QRadioButton::clicked, + m_renderer, &GradientRenderer::setReflectSpread); + connect(m_repeatSpreadButton, &QRadioButton::clicked, + m_renderer, &GradientRenderer::setRepeatSpread); + + connect(default1Button, &QPushButton::clicked, + this, &GradientWidget::setDefault1); + connect(default2Button, &QPushButton::clicked, + this, &GradientWidget::setDefault2); + connect(default3Button, &QPushButton::clicked, + this, &GradientWidget::setDefault3); + connect(default4Button, &QPushButton::clicked, + this, &GradientWidget::setDefault4); + + connect(showSourceButton, &QPushButton::clicked, + m_renderer, &GradientRenderer::showSource); #ifdef QT_OPENGL_SUPPORT - connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool))); + connect(enableOpenGLButton, QOverload<bool>::of(&QPushButton::clicked), + m_renderer, &ArthurFrame::enableOpenGL); #endif - connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool))); - connect(whatsThisButton, SIGNAL(clicked(bool)), - m_renderer->hoverPoints(), SLOT(setDisabled(bool))); - connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)), - whatsThisButton, SLOT(setChecked(bool))); - connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)), - m_renderer->hoverPoints(), SLOT(setDisabled(bool))); + + connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked), + m_renderer, &ArthurFrame::setDescriptionEnabled); + connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked), + m_renderer->hoverPoints(), &HoverPoints::setDisabled); + connect(m_renderer, QOverload<bool>::of(&ArthurFrame::descriptionEnabledChanged), + whatsThisButton, &QPushButton::setChecked); + connect(m_renderer, QOverload<bool>::of(&ArthurFrame::descriptionEnabledChanged), + m_renderer->hoverPoints(), &HoverPoints::setDisabled); m_renderer->loadSourceFile(":res/gradients/gradients.cpp"); m_renderer->loadDescription(":res/gradients/gradients.html"); diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 82573347b6..99aecdd8ce 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1953,11 +1953,12 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) } QT_PCLOSE(proc); if(!indeps.isEmpty()) { + QDir outDir(Option::output_dir); // ### This is basically fubar. Add 'lines' flag to CONFIG? QStringList dep_cmd_deps = indeps.replace('\n', ' ').simplified().split(' '); for(int i = 0; i < dep_cmd_deps.count(); ++i) { QString &file = dep_cmd_deps[i]; - QString absFile = QDir(Option::output_dir).absoluteFilePath(file); + QString absFile = outDir.absoluteFilePath(file); if (exists(absFile)) { file = absFile; } else { @@ -1965,8 +1966,9 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths(); for (QList<QMakeLocalFileName>::Iterator dit = depdirs.begin(); dit != depdirs.end(); ++dit) { - if (exists((*dit).local() + '/' + file)) { - localFile = (*dit).local() + '/' + file; + QString lf = outDir.absoluteFilePath((*dit).local() + '/' + file); + if (exists(lf)) { + localFile = lf; break; } } @@ -2045,11 +2047,12 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) } QT_PCLOSE(proc); if(!indeps.isEmpty()) { + QDir outDir(Option::output_dir); // ### This is basically fubar. Add 'lines' flag to CONFIG? QStringList dep_cmd_deps = indeps.replace('\n', ' ').simplified().split(' '); for(int i = 0; i < dep_cmd_deps.count(); ++i) { QString &file = dep_cmd_deps[i]; - QString absFile = QDir(Option::output_dir).absoluteFilePath(file); + QString absFile = outDir.absoluteFilePath(file); if (exists(absFile)) { file = absFile; } else { @@ -2057,8 +2060,9 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths(); for (QList<QMakeLocalFileName>::Iterator dit = depdirs.begin(); dit != depdirs.end(); ++dit) { - if (exists((*dit).local() + '/' + file)) { - localFile = (*dit).local() + '/' + file; + QString lf = outDir.absoluteFilePath((*dit).local() + '/' + file); + if (exists(lf)) { + localFile = lf; break; } } diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index ceb3f8adf3..2d7b9a9ac8 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -387,11 +387,11 @@ CONFIG += no_keywords //! [34] QString FriendlyConversation::greeting(int type) { -static const char *greeting_strings[] = { - QT_TR_NOOP("Hello"), - QT_TR_NOOP("Goodbye") -}; -return tr(greeting_strings[type]); + static const char *greeting_strings[] = { + QT_TR_NOOP("Hello"), + QT_TR_NOOP("Goodbye") + }; + return tr(greeting_strings[type]); } //! [34] @@ -410,7 +410,7 @@ QString FriendlyConversation::greeting(int type) QString global_greeting(int type) { return qApp->translate("FriendlyConversation", - greeting_strings[type]); + greeting_strings[type]); } //! [35] @@ -434,8 +434,8 @@ QString FriendlyConversation::greeting(int type) QString global_greeting(int type) { return qApp->translate("FriendlyConversation", - greeting_strings[type].source, - greeting_strings[type].comment); + greeting_strings[type].source, + greeting_strings[type].comment); } //! [36] diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 30c80b8b6f..21f22a32ba 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -648,10 +648,10 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); compiler or platform specific code to their application. The remaining macros are convenience macros for larger operations: - The QT_TRANSLATE_NOOP() and QT_TR_NOOP() macros provide the - possibility of marking text for dynamic translation, - i.e. translation without changing the stored source text. The - Q_ASSERT() and Q_ASSERT_X() enables warning messages of various + The QT_TR_NOOP(), QT_TRANSLATE_NOOP(), and QT_TRANSLATE_NOOP3() + macros provide the possibility of marking strings for delayed + translation. + The Q_ASSERT() and Q_ASSERT_X() enables warning messages of various level of refinement. The Q_FOREACH() and foreach() macros implement Qt's foreach loop. @@ -662,11 +662,11 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); memory, if the pointer is 0. The qPrintable() and qUtf8Printable() macros represent an easy way of printing text. - Finally, the QT_POINTER_SIZE macro expands to the size of a - pointer in bytes, and the QT_VERSION and QT_VERSION_STR macros - expand to a numeric value or a string, respectively, specifying - Qt's version number, i.e the version the application is compiled - against. + The QT_POINTER_SIZE macro expands to the size of a pointer in bytes. + + The macros QT_VERSION and QT_VERSION_STR expand to a numeric value + or a string, respectively, that specifies the version of Qt that the + application is compiled against. \sa <QtAlgorithms>, QSysInfo */ @@ -3676,19 +3676,18 @@ bool qunsetenv(const char *varName) \macro QT_TR_NOOP(sourceText) \relates <QtGlobal> - Marks the string literal \a sourceText for dynamic translation in - the current context (class), i.e the stored \a sourceText will not - be altered. + Marks the UTF-8 encoded string literal \a sourceText for delayed + translation in the current context (class). - The macro expands to \a sourceText. + The macro tells lupdate to collect the string, and expands to + \a sourceText itself. Example: \snippet code/src_corelib_global_qglobal.cpp 34 - The macro QT_TR_NOOP_UTF8() is identical except that it tells lupdate - that the source string is encoded in UTF-8. Corresponding variants - exist in the QT_TRANSLATE_NOOP() family of macros, too. + The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies + to all other _UTF8 macros as well. \sa QT_TRANSLATE_NOOP(), {Internationalization with Qt} */ @@ -3697,12 +3696,12 @@ bool qunsetenv(const char *varName) \macro QT_TRANSLATE_NOOP(context, sourceText) \relates <QtGlobal> - Marks the string literal \a sourceText for dynamic translation in - the given \a context; i.e, the stored \a sourceText will not be - altered. The \a context is typically a class and also needs to - be specified as string literal. + Marks the UTF-8 encoded string literal \a sourceText for delayed + translation in the given \a context. The \a context is typically + a class name and also needs to be specified as a string literal. - The macro expands to \a sourceText. + The macro tells lupdate to collect the string, and expands to + \a sourceText itself. Example: @@ -3712,18 +3711,19 @@ bool qunsetenv(const char *varName) */ /*! - \macro QT_TRANSLATE_NOOP3(context, sourceText, comment) + \macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation) \relates <QtGlobal> \since 4.4 - Marks the string literal \a sourceText for dynamic translation in the - given \a context and with \a comment, i.e the stored \a sourceText will - not be altered. The \a context is typically a class and also needs to - be specified as string literal. The string literal \a comment - will be available for translators using e.g. Qt Linguist. + Marks the UTF-8 encoded string literal \a sourceText for delayed + translation in the given \a context with the given \a disambiguation. + The \a context is typically a class and also needs to be specified + as a string literal. The string literal \a disambiguation should be + a short semantic tag to tell apart otherwise identical strings. - The macro expands to anonymous struct of the two string - literals passed as \a sourceText and \a comment. + The macro tells lupdate to collect the string, and expands to an + anonymous struct of the two string literals passed as \a sourceText + and \a disambiguation. Example: diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 055fe6f40a..f86b62d56a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1062,7 +1062,7 @@ template <typename Ptr> inline auto qGetPtrHelper(const Ptr &ptr) -> decltype(pt #define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment} #define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment} -#ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above +#ifndef QT_NO_TRANSLATION // ### Qt6: This should enclose the NOOPs above // Defined in qcoreapplication.cpp // The better name qTrId() is reserved for an upcoming function which would diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index b029274329..a6c27d19c0 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -147,9 +147,15 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) Rules are evaluated in text order, from first to last. That is, if two rules apply to a category/type, the rule that comes later is applied. - Rules can be set via \l setFilterRules(). Since Qt 5.3, logging rules can also - be set in the \c QT_LOGGING_RULES environment variable, and - are automatically loaded from the \c [Rules] section of a logging + Rules can be set via \l setFilterRules(): + + \code + QLoggingCategory::setFilterRules("*.debug=false\n" + "driver.usb.debug=true"); + \endcode + + Since Qt 5.3, logging rules are also + automatically loaded from the \c [Rules] section of a logging configuration file. Such configuration files are looked up in the QtProject configuration directory, or explicitly set in a \c QT_LOGGING_CONF environment variable: @@ -160,19 +166,18 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) driver.usb.debug=true \endcode - Rules set by \l setFilterRules() take precedence over rules specified - in the QtProject configuration directory, and can, in turn, be - overwritten by rules from the configuration file specified by - \c QT_LOGGING_CONF, and rules set by \c QT_LOGGING_RULES. - - - Since Qt 5.6, \c QT_LOGGING_RULES may contain multiple rules separated - by semicolons: + Since Qt 5.3, logging rules can also be specified in a \c QT_LOGGING_RULES + environment variable. And since Qt 5.6, multiple rules can also be + separated by semicolons: \code QT_LOGGING_RULES="*.debug=false;driver.usb.debug=true" \endcode + Rules set by \l setFilterRules() take precedence over rules specified + in the QtProject configuration directory, and can, in turn, be + overwritten by rules from the configuration file specified by + \c QT_LOGGING_CONF, and rules set by \c QT_LOGGING_RULES. Order of evaluation: \list diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index c0214e9c11..35c8baf0de 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -520,7 +520,12 @@ public: const typename Simd::Float32x4 v_r0 = Simd::v_dup(data->gradient.radial.focal.radius); const typename Simd::Float32x4 v_dr = Simd::v_dup(op->radial.dr); +#if defined(__ARM_NEON__) + // NEON doesn't have SIMD sqrt, but uses rsqrt instead that can't be taken of 0. + const typename Simd::Float32x4 v_min = Simd::v_dup(std::numeric_limits<float>::epsilon()); +#else const typename Simd::Float32x4 v_min = Simd::v_dup(0.0f); +#endif const typename Simd::Float32x4 v_max = Simd::v_dup(float(GRADIENT_STOPTABLE_SIZE-1)); const typename Simd::Float32x4 v_half = Simd::v_dup(0.5f); diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index d04dd08058..70132b542c 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -2474,7 +2474,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout QTextTableData *td = static_cast<QTextTableData *>(data(lastIt.currentFrame())); QTextLayout *layout = block.layout(); - QFixed height = QFixed::fromReal(layout->lineAt(0).height()); + QFixed height = layout->lineCount() > 0 ? QFixed::fromReal(layout->lineAt(0).height()) : QFixed(); if (layoutStruct->pageBottom == origPageBottom) { layoutStruct->y -= height; @@ -2486,10 +2486,12 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout layoutBlock(block, docPos, blockFormat, layoutStruct, layoutFrom, layoutTo, previousBlockFormatPtr); } - QPointF linePos((td->position.x + td->size.width).toReal(), - (td->position.y + td->size.height - height).toReal()); + if (layout->lineCount() > 0) { + QPointF linePos((td->position.x + td->size.width).toReal(), + (td->position.y + td->size.height - height).toReal()); - layout->lineAt(0).setPosition(linePos - layout->position()); + layout->lineAt(0).setPosition(linePos - layout->position()); + } } if (blockFormat.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter) diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index 29aaaae683..33b102f3eb 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -73,8 +73,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) return newFont; } -@class QT_MANGLE_NAMESPACE(QNSFontPanelDelegate); - @interface QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) : NSObject<NSWindowDelegate, QNSPanelDelegate> - (void)restoreOriginalContentView; - (void)updateQtFont; @@ -109,7 +107,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); [mFontPanel setRestorable:NO]; [mFontPanel setDelegate:self]; - [[NSFontManager sharedFontManager] setDelegate:self]; + + [NSFontManager sharedFontManager].target = self; // Action is changeFont: [mFontPanel retain]; } @@ -120,7 +119,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); { [mStolenContentView release]; [mFontPanel setDelegate:nil]; - [[NSFontManager sharedFontManager] setDelegate:nil]; + [NSFontManager sharedFontManager].target = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 0ef06ccea7..20358e7269 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -394,8 +394,10 @@ void QCocoaWindow::setVisible(bool visible) removeMonitor(); monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDownMask|NSMouseMovedMask handler:^(NSEvent *e) { QPointF localPoint = QCocoaScreen::mapFromNative([NSEvent mouseLocation]); + const auto eventType = e.type == NSMouseMoved ? QEvent::MouseMove : QEvent::MouseButtonPress; QWindowSystemInterface::handleMouseEvent(window(), window()->mapFromGlobal(localPoint.toPoint()), localPoint, - cocoaButton2QtButton([e buttonNumber])); + Qt::MouseButtons(uint(NSEvent.pressedMouseButtons & 0xFFFF)), + cocoaButton2QtButton(e.buttonNumber), eventType); }]; } } @@ -1331,7 +1333,7 @@ void QCocoaWindow::recreateWindowIfNeeded() void QCocoaWindow::requestUpdate() { qCDebug(lcQpaDrawing) << "QCocoaWindow::requestUpdate" << window(); - [qnsview_cast(m_view) requestUpdate]; + QPlatformWindow::requestUpdate(); } void QCocoaWindow::deliverUpdateRequest() diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 2e44626112..35f81f0165 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -102,6 +102,7 @@ QWindowsKeyMapper::QWindowsKeyMapper() QGuiApplication *app = static_cast<QGuiApplication *>(QGuiApplication::instance()); QObject::connect(app, &QGuiApplication::applicationStateChanged, app, clearKeyRecorderOnApplicationInActive); + changeKeyboard(); } QWindowsKeyMapper::~QWindowsKeyMapper() @@ -317,9 +318,9 @@ static const uint KeyTbl[] = { // Keyboard mapping table Qt::Key_9, // 105 0x69 VK_NUMPAD9 | Numeric keypad 9 key Qt::Key_Asterisk, // 106 0x6A VK_MULTIPLY | Multiply key Qt::Key_Plus, // 107 0x6B VK_ADD | Add key - Qt::Key_Comma, // 108 0x6C VK_SEPARATOR | Separator key + Qt::Key_unknown, // 108 0x6C VK_SEPARATOR | Separator key (locale-dependent) Qt::Key_Minus, // 109 0x6D VK_SUBTRACT | Subtract key - Qt::Key_Period, // 110 0x6E VK_DECIMAL | Decimal key + Qt::Key_unknown, // 110 0x6E VK_DECIMAL | Decimal key (locale-dependent) Qt::Key_Slash, // 111 0x6F VK_DIVIDE | Divide key Qt::Key_F1, // 112 0x70 VK_F1 | F1 key Qt::Key_F2, // 113 0x71 VK_F2 | F2 key @@ -810,7 +811,7 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd, // Reset layout map when system keyboard layout is changed if (msg.message == WM_INPUTLANGCHANGE) { - deleteLayouts(); + changeKeyboard(); return true; } diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index d388327687..097931913e 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -48,6 +48,7 @@ #include <QMdiSubWindow> #endif #include <QAbstractScrollArea> +#include <QPainter> QT_BEGIN_NAMESPACE diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 8ba6504f87..98f2b8df2d 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3850,7 +3850,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if(hasStyleRule(w, PseudoElement_HeaderViewSection)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw() - || subRule.hasBackground() || subRule.hasPalette()) { + || subRule.hasBackground() || subRule.hasPalette() || subRule.hasFont) { ParentStyle::drawControl(ce, opt, p, w); return; } @@ -3887,12 +3887,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q QStyleOptionHeader hdr(*header); QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button); - QFont oldFont = p->font(); - if (subRule.hasFont) + if (subRule.hasFont) { + QFont oldFont = p->font(); p->setFont(subRule.font.resolve(p->font())); - baseStyle()->drawControl(ce, &hdr, p, w); - if (subRule.hasFont) + ParentStyle::drawControl(ce, &hdr, p, w); p->setFont(oldFont); + } else { + baseStyle()->drawControl(ce, &hdr, p, w); + } return; } break; diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp index ca40927ef9..32e5b8ee56 100644 --- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp +++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp @@ -185,12 +185,10 @@ private Q_SLOTS: }; template <bool> inline void booleanHelper() { } -struct TypeInStruct { TEST_TYPE type; }; void tst_QAtomicIntegerXX::static_checks() { Q_STATIC_ASSERT(sizeof(QAtomicInteger<T>) == sizeof(T)); - Q_STATIC_ASSERT(Q_ALIGNOF(QAtomicInteger<T>) == Q_ALIGNOF(TypeInStruct)); // statements with no effect (void) QAtomicInteger<T>::isReferenceCountingNative(); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 4fe2e769e7..40d0f4f32a 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -589,6 +589,9 @@ void tst_QWindow::childWindowPositioning_data() void tst_QWindow::childWindowPositioning() { + if (isPlatformWayland()) + QSKIP("Wayland: This is flaky (protocol errors for xdg-shell v6). See QTBUG-67648."); + const QPoint topLeftOrigin(0, 0); ColoredWindow topLevelWindowFirst(Qt::green); diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index ba405e2860..181c609c6e 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -2963,10 +2963,6 @@ void fpe_steepSlopes() void fpe_radialGradients() { -#if defined(Q_PROCESSOR_ARM) - QEXPECT_FAIL("", "Test fails for ARM (QTBUG-59961)", Continue); -#endif - FpExceptionChecker checker(FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO); QImage img(21, 21, QImage::Format_ARGB32_Premultiplied); diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp index a1cb729849..5b142048b5 100644 --- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp @@ -365,9 +365,8 @@ void tst_QGraphicsEffect::draw() // Make sure we update the source when disabling/enabling the effect. effect->setEnabled(false); - QTest::qWait(50); + QTRY_COMPARE(item->numRepaints, 1); QCOMPARE(effect->numRepaints, 0); - QCOMPARE(item->numRepaints, 1); effect->reset(); item->reset(); diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index c70ac0309f..5301dababc 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -288,7 +288,6 @@ void tst_QApplication::alert() widget2.show(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); QVERIFY(QTest::qWaitForWindowExposed(&widget2)); - QTest::qWait(100); app.alert(&widget, -1); app.alert(&widget, 250); widget2.activateWindow(); @@ -1711,6 +1710,7 @@ void tst_QApplication::focusOut() le2->setStyleSheet("background: #fee"); le2->move(100, 100); w.show(); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QTest::qWait(2000); le2->setFocus(); diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 3dfb9c35b3..b2650d1f32 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -227,15 +227,13 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing() window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); - int spacing = pb2->geometry().left() - pb1->geometry().right() - 1; - QCOMPARE(spacing, 6); + auto spacing = [&]() { return pb2->geometry().left() - pb1->geometry().right() - 1; }; + QCOMPARE(spacing(), 6); QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle()); style2->hspacing = 10; window.setStyle(style2.data()); - QTest::qWait(100); - spacing = pb2->geometry().left() - pb1->geometry().right() - 1; - QCOMPARE(spacing, 10); + QTRY_COMPARE(spacing(), 10); } void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected() diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index 1ccda25339..162da61584 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -164,7 +164,7 @@ private slots: void tst_QFormLayout::cleanup() { - QVERIFY(QApplication::topLevelWidgets().isEmpty()); + QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QFormLayout::rowCount() @@ -1188,7 +1188,6 @@ void tst_QFormLayout::layoutAlone() w.setWindowTitle(QTest::currentTestFunction()); w.show(); layout.activate(); - QTest::qWait(500); } void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout() diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 40a2319910..5e0327319b 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -1441,7 +1441,6 @@ void tst_QGridLayout::layoutSpacing() QLayout *layout = widget->layout(); QVERIFY(layout); - //QTest::qWait(2000); for (int pi = 0; pi < expectedpositions.count(); ++pi) { QLayoutItem *item = layout->itemAt(pi); //qDebug() << item->widget()->pos(); diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index ff35b0cdb1..b78287f84b 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -604,7 +604,7 @@ void tst_QShortcut::disabledItems() { clearAllShortcuts(); mainW->activateWindow(); - QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowActive(mainW)); /* Testing Disabled Shortcuts Qt::Key_M on slot1 diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp index 5be4846b3e..10712ea9ad 100644 --- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp @@ -103,7 +103,7 @@ void tst_QStackedLayout::init() // make sure the tests work with focus follows mouse QCursor::setPos(testWidget->geometry().center()); testWidget->activateWindow(); - QTest::qWait(250); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); } void tst_QStackedLayout::cleanup() @@ -251,24 +251,13 @@ void tst_QStackedLayout::removeWidget() testLayout->addWidget(w2); vbox->addLayout(testLayout); top->setFocus(); - QTest::qWait(100); top->activateWindow(); - QTest::qWait(100); - int i =0; - for (;;) { - if (QApplication::focusWidget() == top) - break; - else if (i >= 5) - QSKIP("Can't get focus"); - QTest::qWait(100); - ++i; - } - QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(top)); + QTRY_COMPARE(QApplication::focusWidget(), top); // focus should stay at the 'top' widget testLayout->removeWidget(w1); - QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(top)); + QCOMPARE(QApplication::focusWidget(), top); } class LineEdit : public QLineEdit diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index a3e549aa50..c9c8e193b3 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -146,13 +146,7 @@ void tst_QWindowContainer::testExposeObscure() container->hide(); - QElapsedTimer timer; - timer.start(); - while (window->numberOfObscures == 0 && timer.elapsed() < 5000) { - QTest::qWait(10); - } - - QVERIFY(window->numberOfObscures > 0); + QTRY_VERIFY(window->numberOfObscures > 0); } @@ -345,11 +339,9 @@ void tst_QWindowContainer::testDockWidget() QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); QCOMPARE(window->parent(), mainWindow.window()->windowHandle()); - QTest::qWait(1000); dock->setFloating(true); QTRY_VERIFY(window->parent() != mainWindow.window()->windowHandle()); - QTest::qWait(1000); dock->setFloating(false); QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle()); } diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 7953077152..28a099de83 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1136,7 +1136,7 @@ void tst_QStyleSheetStyle::minmaxSizes() centerOnScreen(&tabWidget); tabWidget.show(); - QTest::qWait(50); + QVERIFY(QTest::qWaitForWindowActive(&tabWidget)); //i allow 4px additional border from the native style (hence the -2, <=2) QVERIFY(qAbs(page2->maximumSize().width() - 500 - 2) <= 2); QVERIFY(qAbs(page2->minimumSize().width() - 250 - 2) <= 2); @@ -1165,7 +1165,7 @@ void tst_QStyleSheetStyle::task206238_twice() w.setStyleSheet("background: red;"); centerOnScreen(&w); w.show(); - QTest::qWait(20); + QVERIFY(QTest::qWaitForWindowActive(&w)); QCOMPARE(BACKGROUND(w) , red); QCOMPARE(BACKGROUND(*tw), red); w.setStyleSheet("background: red;"); @@ -1366,8 +1366,7 @@ void tst_QStyleSheetStyle::proxyStyle() layout->addWidget(pb5); w->show(); - - QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowActive(w)); // Test for QTBUG-7198 - style sheet overrides custom element size QStyleOptionViewItem opt; @@ -1557,9 +1556,9 @@ void tst_QStyleSheetStyle::embeddedFonts() box.addItems(QStringList() << "First" << "Second" << "Third"); box.setStyleSheet("QComboBox { font-size: 32px; }"); box.show(); + QVERIFY(QTest::qWaitForWindowActive(&box)); embedded = box.findChild<QLineEdit *>(); QVERIFY(embedded); - QTest::qWait(20); QCOMPARE(box.font().pixelSize(), 32); QCOMPARE(embedded->font().pixelSize(), 32); } @@ -1652,7 +1651,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground() tree.setStyleSheet( "QTreeView:disabled { background-color:#ab1251; }" ); tree.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100)); tree.show(); - QTest::qWait(20); + QVERIFY(QTest::qWaitForWindowActive(&tree)); QImage image(tree.width(), tree.height(), QImage::Format_ARGB32); tree.render(&image); @@ -1673,7 +1672,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground() table.setStyleSheet( "QTableView {background-color: #ff0000}" ); table.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(300, 100)); table.show(); - QTest::qWait(20); + QVERIFY(QTest::qWaitForWindowActive(&table)); image = QImage(table.width(), table.height(), QImage::Format_ARGB32); table.render(&image); QVERIFY(testForColors(image, Qt::red, true)); diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp index bc7756d32f..e77faa1e75 100644 --- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp @@ -473,14 +473,9 @@ void tst_QAbstractButton::setShortcut() QKeySequence seq( Qt::Key_A ); testWidget->setShortcut( seq ); QApplication::setActiveWindow(testWidget); - + testWidget->activateWindow(); // must be active to get shortcuts - for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) { - testWidget->activateWindow(); - QApplication::instance()->processEvents(); - QTest::qWait(100); - } - QVERIFY(testWidget->isActiveWindow()); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); QTest::keyClick( testWidget, 'A' ); QTest::qWait(300); // Animate click takes time @@ -508,9 +503,7 @@ void tst_QAbstractButton::animateClick() QVERIFY( testWidget->isDown() ); qApp->processEvents(); QVERIFY( testWidget->isDown() ); - QTest::qWait(200); - qApp->processEvents(); - QVERIFY( !testWidget->isDown() ); + QTRY_VERIFY( !testWidget->isDown() ); } void tst_QAbstractButton::shortcutEvents() @@ -614,7 +607,7 @@ void tst_QAbstractButton::keyNavigation() widget.show(); qApp->setActiveWindow(&widget); widget.activateWindow(); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowActive(&widget)); buttons[1][1]->setFocus(); QTest::qWait(400); diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp index 60efcddc60..372a467ada 100644 --- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp +++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp @@ -346,6 +346,7 @@ void tst_QAbstractScrollArea::patternBackground() widget.resize(600, 600); scrollArea.setWidget(&widget); topLevel.show(); + QVERIFY(QTest::qWaitForWindowActive(&topLevel)); QLinearGradient linearGrad(QPointF(250, 250), QPointF(300, 300)); linearGrad.setColorAt(0, Qt::yellow); @@ -354,7 +355,6 @@ void tst_QAbstractScrollArea::patternBackground() scrollArea.viewport()->setPalette(QPalette(Qt::black, bg, bg, bg, bg, bg, bg, bg, bg)); widget.setPalette(Qt::transparent); - QTest::qWait(50); QImage image(200, 200, QImage::Format_ARGB32); scrollArea.render(&image); @@ -366,7 +366,6 @@ void tst_QAbstractScrollArea::patternBackground() QScrollBar *vbar = scrollArea.verticalScrollBar(); vbar->setValue(vbar->maximum()); - QTest::qWait(50); scrollArea.render(&image); QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb()); diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp index 8e4a800a75..5c0f4b1536 100644 --- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp +++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp @@ -174,12 +174,10 @@ void tst_QCalendarWidget::buttonClickCheck() QTest::mouseClick(button, Qt::LeftButton, Qt::NoModifier, button->rect().center(), 2); QVERIFY(!button->isVisible()); QSpinBox *spinbox = object.findChild<QSpinBox *>("qt_calendar_yearedit"); - QTest::qWait(500); QTest::keyClick(spinbox, '2'); QTest::keyClick(spinbox, '0'); QTest::keyClick(spinbox, '0'); QTest::keyClick(spinbox, '6'); - QTest::qWait(500); QWidget *widget = object.findChild<QWidget *>("qt_calendar_calendarview"); QTest::mouseMove(widget); QTest::mouseClick(widget, Qt::LeftButton); @@ -305,7 +303,6 @@ void tst_QCalendarWidget::showPrevNext() QCOMPARE(calWidget.monthShown(), expectedDate.month()); // QTBUG-4058 - QTest::qWait(20); QToolButton *button = calWidget.findChild<QToolButton *>("qt_calendar_prevmonth"); QTest::mouseClick(button, Qt::LeftButton); expectedDate = expectedDate.addMonths(-1); diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp index c9699bfb81..0cbab5e17c 100644 --- a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp +++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp @@ -83,6 +83,7 @@ void tst_QCheckBox::initTestCase() testWidget->setObjectName("testObject"); testWidget->resize( 200, 200 ); testWidget->show(); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); } void tst_QCheckBox::cleanupTestCase() @@ -240,13 +241,11 @@ void tst_QCheckBox::pressed() QVERIFY( !testWidget->isChecked() ); QTest::keyPress( testWidget, Qt::Key_Space ); - QTest::qWait(100); QVERIFY( press_count == 1 ); QVERIFY( release_count == 0 ); QVERIFY( !testWidget->isChecked() ); QTest::keyRelease( testWidget, Qt::Key_Space ); - QTest::qWait(100); QVERIFY( press_count == 1 ); QVERIFY( release_count == 1 ); QVERIFY( testWidget->isChecked() ); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 37f0864213..80844715ef 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1995,19 +1995,16 @@ void tst_QComboBox::flaggedItems() QApplication::setActiveWindow(&comboBox); comboBox.activateWindow(); comboBox.setFocus(); + QVERIFY(QTest::qWaitForWindowActive(&comboBox)); QTRY_VERIFY(comboBox.isVisible()); QTRY_VERIFY(comboBox.hasFocus()); if (editable) comboBox.lineEdit()->selectAll(); - QSignalSpy indexChangedInt(&comboBox, SIGNAL(currentIndexChanged(int))); for (int i = 0; i < keyMovementList.count(); ++i) { Qt::Key key = keyMovementList[i]; QTest::keyClick(&comboBox, key); - if (indexChangedInt.count() != i + 1) { - QTest::qWait(400); - } } QCOMPARE(comboBox.currentIndex() , expectedIndex); @@ -2447,7 +2444,7 @@ void tst_QComboBox::task220195_keyBoardSelection2() combo.addItem( QLatin1String("foo3")); combo.show(); QApplication::setActiveWindow(&combo); - QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo)); + QVERIFY(QTest::qWaitForWindowActive(&combo)); combo.setCurrentIndex(-1); QVERIFY(combo.currentText().isNull()); diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp index 667e348945..c0f33b9c79 100644 --- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp +++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp @@ -110,6 +110,7 @@ void tst_QCommandLinkButton::initTestCase() testWidget->setObjectName("testWidget"); testWidget->resize( 200, 200 ); testWidget->show(); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); connect( testWidget, SIGNAL(clicked()), this, SLOT(onClicked()) ); connect( testWidget, SIGNAL(pressed()), this, SLOT(onPressed()) ); @@ -166,12 +167,6 @@ void tst_QCommandLinkButton::onReleased() void tst_QCommandLinkButton::setAutoRepeat() { - // Give the last tests time to finish - i.e., wait for the window close - // and deactivate to avoid a race condition here. We can't add this to the - // end of the defaultAndAutoDefault test, since any failure in that test - // will return out of that function. - QTest::qWait( 1000 ); - // If this changes, this test must be completely revised. QVERIFY( !testWidget->isCheckable() ); @@ -194,8 +189,6 @@ void tst_QCommandLinkButton::setAutoRepeat() testWidget->setAutoRepeat( false ); QTest::keyPress( testWidget, Qt::Key_Space ); - QTest::qWait( 300 ); - QVERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QVERIFY( press_count == 1 ); @@ -206,18 +199,16 @@ void tst_QCommandLinkButton::setAutoRepeat() resetCounters(); // check that the button is down if we press space while in autorepeat - // we can't actually confirm how many times it is fired, more than 1 is enough. testWidget->setDown( false ); testWidget->setAutoRepeat( true ); QTest::keyPress( testWidget, Qt::Key_Space ); - QTest::qWait(900); + QTRY_VERIFY(press_count > 10); QVERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QTest::keyRelease( testWidget, Qt::Key_Space ); QCOMPARE(press_count, release_count); QCOMPARE(release_count, click_count); - QVERIFY(press_count > 1); // #### shouldn't I check here to see if multiple signals have been fired??? @@ -227,8 +218,6 @@ void tst_QCommandLinkButton::setAutoRepeat() testWidget->setAutoRepeat( false ); QTest::keyPress( testWidget, Qt::Key_Enter ); - QTest::qWait( 300 ); - QVERIFY( !testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QVERIFY( press_count == 0 ); @@ -241,7 +230,6 @@ void tst_QCommandLinkButton::setAutoRepeat() testWidget->setDown( false ); testWidget->setAutoRepeat( true ); QTest::keyClick( testWidget, Qt::Key_Enter ); - QTest::qWait( 300 ); QVERIFY( !testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QVERIFY( press_count == 0 ); @@ -252,23 +240,19 @@ void tst_QCommandLinkButton::setAutoRepeat() void tst_QCommandLinkButton::pressed() { QTest::keyPress( testWidget, ' ' ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)0 ); QTest::keyRelease( testWidget, ' ' ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)1 ); QTest::keyPress( testWidget,Qt::Key_Enter ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)1 ); testWidget->setAutoDefault(true); QTest::keyPress( testWidget,Qt::Key_Enter ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)2 ); QCOMPARE( release_count, (uint)2 ); testWidget->setAutoDefault(false); @@ -349,19 +333,7 @@ void tst_QCommandLinkButton::setAccel() // The shortcut will not be activated unless the button is in a active // window and has focus testWidget->setFocus(); - - // QWidget::isActiveWindow() can report window active before application - // has handled the asynchronous activation event on platforms that have - // implemented QPlatformWindow::isActive(), so process events to sync up. - QApplication::instance()->processEvents(); - - for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) { - testWidget->activateWindow(); - QApplication::instance()->processEvents(); - QTest::qWait(100); - } - - QVERIFY(testWidget->isActiveWindow()); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); QTest::keyClick( testWidget, 'A', Qt::AltModifier ); QTest::qWait( 500 ); diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index f127fd98f7..17b0e9ce5f 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -838,10 +838,9 @@ void tst_QDialogButtonBox::task191642_default() bb->addButton(QDialogButtonBox::Help); dlg.show(); - QTest::qWait(10); + QVERIFY(QTest::qWaitForWindowActive(&dlg)); QVERIFY(def->isDefault()); QTest::keyPress( &dlg, Qt::Key_Enter ); - QTest::qWait(100); QCOMPARE(clicked.count(), 1); } diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 1a1023208a..7d1e736f42 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -579,8 +579,7 @@ void tst_QDockWidget::visibilityChanged() QCOMPARE(spy.count(), 0); mw.addDockWidget(Qt::RightDockWidgetArea, &dw2); - QTest::qWait(200); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); } @@ -672,8 +671,7 @@ void tst_QDockWidget::dockLocationChanged() dw.setFloating(true); QTest::qWait(100); dw.setFloating(false); - QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::TopDockWidgetArea); spy.clear(); @@ -936,8 +934,7 @@ void tst_QDockWidget::task248604_infiniteResize() d.setContentsMargins(2, 2, 2, 2); d.setMinimumSize(320, 240); d.showNormal(); - QTest::qWait(400); - QCOMPARE(d.size(), QSize(320, 240)); + QTRY_COMPARE(d.size(), QSize(320, 240)); } @@ -950,7 +947,7 @@ void tst_QDockWidget::task258459_visibilityChanged() QSignalSpy spy1(&dock1, SIGNAL(visibilityChanged(bool))); QSignalSpy spy2(&dock2, SIGNAL(visibilityChanged(bool))); win.show(); - QTest::qWait(200); + QVERIFY(QTest::qWaitForWindowActive(&win)); QCOMPARE(spy1.count(), 1); QCOMPARE(spy1.first().first().toBool(), false); //dock1 is invisible QCOMPARE(spy2.count(), 1); diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 5382d5c6db..9c56d30dfb 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -167,6 +167,7 @@ void tst_QDoubleSpinBox::initTestCase() testFocusWidget = new QWidget(0); testFocusWidget->resize(200, 100); testFocusWidget->show(); + QVERIFY(QTest::qWaitForWindowActive(testFocusWidget)); } void tst_QDoubleSpinBox::cleanupTestCase() @@ -773,8 +774,7 @@ void tst_QDoubleSpinBox::editingFinished() testFocusWidget->show(); QApplication::setActiveWindow(testFocusWidget); - QTest::qWait(10); - QTRY_VERIFY(testFocusWidget->isActiveWindow()); + QVERIFY(QTest::qWaitForWindowActive(testFocusWidget)); box->setFocus(); QTRY_VERIFY(box->hasFocus()); @@ -1000,7 +1000,7 @@ void tst_QDoubleSpinBox::task224497_fltMax() dspin->setMinimum(3); dspin->setMaximum(FLT_MAX); dspin->show(); - QTest::qWait(1000); + QVERIFY(QTest::qWaitForWindowActive(dspin)); dspin->lineEdit()->selectAll(); QTest::keyClick(dspin->lineEdit(), Qt::Key_Delete); QTest::keyClick(dspin->lineEdit(), Qt::Key_1); diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index 84071962bc..34862f6810 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -398,7 +398,6 @@ void tst_QLabel::task226479_movieResize() label.paintedRegion = QRegion(); movie->setFileName(QFINDTESTDATA("green.png")); movie->start(); - QTest::qWait(50); QTRY_COMPARE(label.paintedRegion , QRegion(label.rect()) ); } diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 9015c03f3f..9da33d9525 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3600,18 +3600,15 @@ void tst_QLineEdit::task174640_editingFinished() QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished())); le1->setFocus(); - QTest::qWait(20); QTRY_VERIFY(le1->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 0); le2->setFocus(); - QTest::qWait(20); QTRY_VERIFY(le2->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 1); editingFinishedSpy.clear(); le1->setFocus(); - QTest::qWait(20); QTRY_VERIFY(le1->hasFocus()); QMenu *testMenu1 = new QMenu(le1); @@ -3707,7 +3704,6 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged() QVERIFY(QTest::qWaitForWindowExposed(&lineEdit)); // to be safe and avoid failing setFocus with window managers lineEdit.setFocus(); QSignalSpy changedSpy(&lineEdit, SIGNAL(textChanged(QString))); - QTest::qWait(200); QTest::keyPress(&lineEdit, 'a'); QTest::keyPress(&lineEdit, 'b'); QTest::keyPress(&lineEdit, 'c'); diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 30dc1e6043..ae71663036 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -1745,17 +1745,15 @@ void tst_QMainWindow::setCursor() QCOMPARE(cur.shape(), mw.cursor().shape()); mw.resize(200,200); mw.show(); - QTest::qWait(50); + QVERIFY(QTest::qWaitForWindowActive(&mw)); QCOMPARE(cur.shape(), mw.cursor().shape()); QHoverEvent enterE(QEvent::HoverEnter, QPoint(10,10), QPoint()); mw.event(&enterE); - QTest::qWait(50); QCOMPARE(cur.shape(), mw.cursor().shape()); QHoverEvent leaveE(QEvent::HoverLeave, QPoint(), QPoint()); mw.event(&leaveE); - QTest::qWait(50); QCOMPARE(cur.shape(), mw.cursor().shape()); } #endif @@ -1844,7 +1842,7 @@ void tst_QMainWindow::dockWidgetSize() mainWindow.addDockWidget(Qt::TopDockWidgetArea, &dock); mainWindow.show(); - QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowActive(&mainWindow)); if (mainWindow.size() == mainWindow.sizeHint()) { QCOMPARE(widget.size(), widget.sizeHint()); QCOMPARE(dock.widget()->size(), dock.widget()->sizeHint()); diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index a9d8c48d63..360e0c93c4 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -963,8 +963,6 @@ void tst_QMdiSubWindow::setSystemMenu() mainWindow.menuBar()->setNativeMenuBar(false); mainWindow.show(); QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); - QTest::qWait(60); - QTRY_VERIFY(subWindow->isVisible()); QPoint globalPopupPos; @@ -972,7 +970,6 @@ void tst_QMdiSubWindow::setSystemMenu() // Show system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(25); QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), (globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) ); @@ -997,7 +994,6 @@ void tst_QMdiSubWindow::setSystemMenu() // Show the new system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(25); QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); @@ -1011,7 +1007,6 @@ void tst_QMdiSubWindow::setSystemMenu() QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget(); QVERIFY(menuLabel); subWindow->showSystemMenu(); - QTest::qWait(25); QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), (globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height())))); @@ -1027,7 +1022,6 @@ void tst_QMdiSubWindow::setSystemMenu() QTest::qWait(150); subWindow->showSystemMenu(); - QTest::qWait(250); QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); // + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top()) globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0); @@ -1044,7 +1038,6 @@ void tst_QMdiSubWindow::setSystemMenu() menuLabel = subWindow->maximizedSystemMenuIconWidget(); QVERIFY(menuLabel); subWindow->showSystemMenu(); - QTest::qWait(250); QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height())); globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0); @@ -1648,8 +1641,6 @@ void tst_QMdiSubWindow::resizeTimer() QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget); mdiArea.show(); QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); - QTest::qWait(300); - EventSpy timerEventSpy(subWindow, QEvent::Timer); QCOMPARE(timerEventSpy.count(), 0); @@ -1809,10 +1800,9 @@ void tst_QMdiSubWindow::closeOnDoubleClick() QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); subWindow->showSystemMenu(); - QTest::qWait(200); - QPointer<QMenu> systemMenu = subWindow->systemMenu(); - QVERIFY(systemMenu); + QPointer<QMenu> systemMenu; + QTRY_VERIFY( (systemMenu = subWindow->systemMenu()) ); QVERIFY(systemMenu->isVisible()); const QRect actionGeometry = systemMenu->actionGeometry(systemMenu->actions().at(actionIndex)); diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 9e0db6fb3f..4a7d653064 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -988,18 +988,14 @@ void tst_QMenu::task258920_mouseBorder() const QPoint center = QApplication::desktop()->availableGeometry().center(); menu.popup(center); QVERIFY(QTest::qWaitForWindowExposed(&menu)); - QTest::qWait(100); QRect actionRect = menu.actionGeometry(action); const QPoint actionCenter = actionRect.center(); QTest::mouseMove(&menu, actionCenter - QPoint(-10, 0)); - QTest::qWait(30); QTest::mouseMove(&menu, actionCenter); - QTest::qWait(30); QTest::mouseMove(&menu, actionCenter + QPoint(10, 0)); QTRY_COMPARE(action, menu.activeAction()); menu.painted = false; QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1)); - QTest::qWait(30); QTRY_COMPARE(static_cast<QAction*>(0), menu.activeAction()); QTRY_VERIFY(menu.painted); } @@ -1106,7 +1102,6 @@ void tst_QMenu::QTBUG7907_submenus_autoselect() menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) ); - QTest::qWait(500); QVERIFY(!subset.isVisible()); } @@ -1401,7 +1396,6 @@ void tst_QMenu::QTBUG_56917_wideMenuSize() menu.addAction(longString); QSize menuSizeHint = menu.sizeHint(); menu.popup(QPoint()); - QTest::qWait(100); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QVERIFY(menu.isVisible()); QVERIFY(menu.height() <= menuSizeHint.height()); @@ -1419,7 +1413,6 @@ void tst_QMenu::QTBUG_56917_wideMenuScreenNumber() QMenu menu; menu.addAction(longString); menu.popup(QApplication::desktop()->screen(i)->geometry().center()); - QTest::qWait(100); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QVERIFY(menu.isVisible()); QCOMPARE(QApplication::desktop()->screenNumber(&menu), i); diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp index 35209c2501..39989c6dbb 100644 --- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp @@ -163,12 +163,9 @@ void tst_QProgressBar::format() bar.move(300, 300); bar.show(); QVERIFY(QTest::qWaitForWindowExposed(&bar)); - QVERIFY(QTest::qWaitForWindowExposed(&bar)); - QTest::qWait(20); bar.repainted = false; bar.setFormat("%v of %m (%p%)"); - QTest::qWait(20); QTRY_VERIFY(bar.repainted); bar.repainted = false; bar.setFormat("%v of %m (%p%)"); diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 2b54008de7..625f38d8ae 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -183,9 +183,7 @@ void tst_QPushButton::autoRepeat() testWidget->setAutoRepeat( false ); QTest::keyPress( testWidget, Qt::Key_Space ); - QTest::qWait( 300 ); - - QVERIFY( testWidget->isDown() ); + QTRY_VERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QVERIFY( press_count == 1 ); QVERIFY( release_count == 0 ); @@ -200,13 +198,12 @@ void tst_QPushButton::autoRepeat() testWidget->setDown( false ); testWidget->setAutoRepeat( true ); QTest::keyPress( testWidget, Qt::Key_Space ); - QTest::qWait(900); + QTRY_VERIFY(press_count > 3); QVERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QTest::keyRelease( testWidget, Qt::Key_Space ); QCOMPARE(press_count, release_count); QCOMPARE(release_count, click_count); - QVERIFY(press_count > 1); // #### shouldn't I check here to see if multiple signals have been fired??? @@ -241,23 +238,19 @@ void tst_QPushButton::autoRepeat() void tst_QPushButton::pressed() { QTest::keyPress( testWidget, ' ' ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)0 ); QTest::keyRelease( testWidget, ' ' ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)1 ); QTest::keyPress( testWidget,Qt::Key_Enter ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)1 ); testWidget->setAutoDefault(true); QTest::keyPress( testWidget,Qt::Key_Enter ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)2 ); QCOMPARE( release_count, (uint)2 ); testWidget->setAutoDefault(false); @@ -340,14 +333,8 @@ void tst_QPushButton::setAccel() // window and has focus QApplication::setActiveWindow(testWidget); testWidget->setFocus(); - for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) { - testWidget->activateWindow(); - QApplication::instance()->processEvents(); - QTest::qWait(100); - } - QVERIFY(testWidget->isActiveWindow()); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); QTest::keyClick( testWidget, 'A', Qt::AltModifier ); - QTest::qWait( 50 ); QTRY_VERIFY( click_count == 1 ); QVERIFY( press_count == 1 ); QVERIFY( release_count == 1 ); @@ -576,10 +563,8 @@ void tst_QPushButton::sizeHint() dialog->showNormal(); tabWidget->setCurrentWidget(tab2); tabWidget->setCurrentWidget(tab1); - QTest::qWait(100); - QApplication::processEvents(); - QCOMPARE(button1_2->size(), button2_2->size()); + QTRY_COMPARE(button1_2->size(), button2_2->size()); } } diff --git a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp index e3752df09e..a4edea23bc 100644 --- a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp +++ b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp @@ -70,15 +70,13 @@ void tst_QRadioButton::task190739_focus() widget.show(); widget.activateWindow(); - QApplication::setActiveWindow(&widget); - QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowActive(&widget)); QVERIFY(edit.hasFocus()); QVERIFY(!radio1.isChecked()); QTest::keyClick(&edit, Qt::Key_O, Qt::ControlModifier, 20); - QTest::qWait(200); - QVERIFY(radio1.isChecked()); + QTRY_VERIFY(radio1.isChecked()); QVERIFY(edit.hasFocus()); QVERIFY(!radio1.hasFocus()); } diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 5ee9160916..2223fb55cc 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -854,12 +854,11 @@ void tst_QSpinBox::editingFinished() testFocusWidget.hide(); QCOMPARE(editingFinishedSpy1.count(), 4); QCOMPARE(editingFinishedSpy2.count(), 4); - QTest::qWait(100); //task203285 editingFinishedSpy1.clear(); testFocusWidget.show(); - QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowActive(&testFocusWidget)); box->setKeyboardTracking(false); qApp->setActiveWindow(&testFocusWidget); testFocusWidget.activateWindow(); diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index cad7bd69d7..77abf5e5a7 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -287,7 +287,7 @@ void tst_QSplitter::saveAndRestoreStateOfNotYetShownSplitter() QByteArray ba = spl->saveState(); spl->restoreState(ba); spl->show(); - QTest::qWait(500); + QVERIFY(QTest::qWaitForWindowActive(spl)); QCOMPARE(l1->geometry().isValid(), true); QCOMPARE(l2->geometry().isValid(), true); @@ -607,8 +607,7 @@ void tst_QSplitter::testShowHide() lay->addWidget(split); widget.setLayout(lay); topLevel.show(); - - QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowActive(&topLevel)); widget.hide(); split->widget(0)->setHidden(hideWidget1); @@ -976,14 +975,13 @@ void tst_QSplitter::task169702_sizes() outerSplitter->setGeometry(100, 100, 500, 500); topLevel.show(); + QVERIFY(QTest::qWaitForWindowActive(&topLevel)); - QTest::qWait(100); testW->m_iFactor++; testW->updateGeometry(); - QTest::qWait(500); //Make sure the minimimSizeHint is respected - QCOMPARE(testW->size().height(), testW->minimumSizeHint().height()); + QTRY_COMPARE(testW->size().height(), testW->minimumSizeHint().height()); } void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget_data() @@ -1012,8 +1010,7 @@ void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget() l->hide(); else delete l; - QTest::qWait(100); - QVERIFY(s.sizes().at(0) > 0); + QTRY_VERIFY(s.sizes().at(0) > 0); } void tst_QSplitter::setLayout() diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index b5ffb90e42..cd7fe3710d 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -549,8 +549,7 @@ void tst_QTabWidget::paintEventCount() QCOMPARE(tw->currentIndex(), 0); tw->show(); - - QTest::qWait(1000); + QVERIFY(QTest::qWaitForWindowActive(tw)); // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point. static const int MaxInitialPaintCount = diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp index 3525dcddd6..301801ed2e 100644 --- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp @@ -1038,11 +1038,9 @@ void tst_QToolBar::accel() mw.show(); QApplication::setActiveWindow(&mw); - QTest::qWait(100); - QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&mw)); + QVERIFY(QTest::qWaitForWindowActive(&mw)); QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier); - QTest::qWait(300); QTRY_COMPARE(spy.count(), 1); #ifdef Q_OS_MAC @@ -1085,19 +1083,19 @@ void tst_QToolBar::task197996_visibility() pAction->setVisible(true); mw.show(); + QVERIFY(QTest::qWaitForWindowActive(&mw)); QVERIFY(toolBar->widgetForAction(pAction)->isVisible()); toolBar->setVisible(false); pAction->setVisible(false); + QVERIFY(!toolBar->widgetForAction(pAction)->isVisible()); + toolBar->setVisible(true); pAction->setVisible(true); - QTest::qWait(100); - - QVERIFY(toolBar->widgetForAction(pAction)->isVisible()); - + QTRY_VERIFY(toolBar->widgetForAction(pAction)->isVisible()); } QTEST_MAIN(tst_QToolBar) diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp index 1775f03680..a7a62496e6 100644 --- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp @@ -141,8 +141,7 @@ void tst_QToolButton::triggered() timer->start(); QTimer::singleShot(10000, &mainWidget, SLOT(close())); // Emergency bail-out toolButton->showMenu(); - QTest::qWait(20); - QCOMPARE(spy.count(),2); + QTRY_COMPARE(spy.count(),2); QCOMPARE(qvariant_cast<QAction *>(spy.at(1).at(0)), one); } |