From 1ea191276ea49ce2334d21b1f4a2c66ee8889466 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 8 Oct 2013 13:31:19 +0200 Subject: QWizard: give all buttons an objectName Only Commit, Finish and Cancel didn't have an object name, yet. Also Extract Method on the switch statement, add a test, and use QStringBuilder. Task-number: QTBUG-29924 Reported-by: Leo Arias Change-Id: I8c29606bc53e9d4caab631da2089e971a9da2d75 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 4506d0af14..a711bc28e3 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -52,6 +52,8 @@ #include #include +Q_DECLARE_METATYPE(QWizard::WizardButton); + static QImage grabWidget(QWidget *window) { return window->grab().toImage(); @@ -100,6 +102,8 @@ private slots: void setWizardStyle(); void removePage(); void sideWidget(); + void objectNames_data(); + void objectNames(); // task-specific tests below me: void task177716_disableCommitButton(); @@ -2384,6 +2388,44 @@ void tst_QWizard::sideWidget() QVERIFY(wizard.sideWidget() == 0); } +void tst_QWizard::objectNames_data() +{ + QTest::addColumn("wizardButton"); + QTest::addColumn("buttonName"); + + QTest::newRow("BackButton") << QWizard::BackButton << QStringLiteral("__qt__passive_wizardbutton0"); + QTest::newRow("NextButton") << QWizard::NextButton << QStringLiteral("__qt__passive_wizardbutton1"); + QTest::newRow("CommitButton") << QWizard::CommitButton << QStringLiteral("qt_wizard_commit"); + QTest::newRow("FinishButton") << QWizard::FinishButton << QStringLiteral("qt_wizard_finish"); + QTest::newRow("CancelButton") << QWizard::CancelButton << QStringLiteral("qt_wizard_cancel"); + QTest::newRow("HelpButton") << QWizard::HelpButton << QStringLiteral("__qt__passive_wizardbutton5"); + QTest::newRow("CustomButton1") << QWizard::CustomButton1 << QStringLiteral("__qt__passive_wizardbutton6"); + QTest::newRow("CustomButton2") << QWizard::CustomButton2 << QStringLiteral("__qt__passive_wizardbutton7"); + QTest::newRow("CustomButton3") << QWizard::CustomButton3 << QStringLiteral("__qt__passive_wizardbutton8"); +} + +void tst_QWizard::objectNames() +{ + QFETCH(QWizard::WizardButton, wizardButton); + QFETCH(QString, buttonName); + + QWizard wizard; + QList buttons = QList() + << QWizard::BackButton + << QWizard::NextButton + << QWizard::CommitButton + << QWizard::FinishButton + << QWizard::CancelButton + << QWizard::HelpButton + << QWizard::CustomButton1 + << QWizard::CustomButton2 + << QWizard::CustomButton3 + ; + QVERIFY(buttons.contains(wizardButton)); + QVERIFY(wizard.button(wizardButton)); + QCOMPARE(wizard.button(wizardButton)->objectName(), buttonName); +} + class task177716_CommitPage : public QWizardPage { Q_OBJECT -- cgit v1.2.3 From 2a704239eaf6edd40b2686c3a4ce9be20f95c53b Mon Sep 17 00:00:00 2001 From: El Mehdi Fekari Date: Mon, 28 Oct 2013 17:11:44 +0100 Subject: QLocale: Add auto tests for Poruguese(Brazil) and Greek locales Change-Id: Ib1b553efb39a150710ceb609d2cb099f19f73e35 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index d6dea05755..028cea3d62 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1733,6 +1733,11 @@ void tst_QLocale::dayName() QLocale ir("ga_IE"); QCOMPARE(ir.dayName(1, QLocale::ShortFormat), QLatin1String("Luan")); QCOMPARE(ir.dayName(7, QLocale::ShortFormat), QLatin1String("Domh")); + + QLocale gr("el_GR"); + QCOMPARE(gr.dayName(2, QLocale::ShortFormat), QString::fromUtf8("\316\244\317\201\316\257")); + QCOMPARE(gr.dayName(4, QLocale::ShortFormat), QString::fromUtf8("\316\240\316\255\316\274")); + QCOMPARE(gr.dayName(6, QLocale::ShortFormat), QString::fromUtf8("\316\243\316\254\316\262")); } void tst_QLocale::standaloneDayName_data() @@ -1903,6 +1908,10 @@ void tst_QLocale::timeFormat() const QLocale cat("ca_ES"); QCOMPARE(cat.timeFormat(QLocale::ShortFormat), QLatin1String("H.mm")); QCOMPARE(cat.timeFormat(QLocale::LongFormat), QLatin1String("H.mm.ss t")); + + const QLocale bra("pt_BR"); + QCOMPARE(bra.timeFormat(QLocale::ShortFormat), QLatin1String("HH:mm")); + QCOMPARE(bra.timeFormat(QLocale::LongFormat), QLatin1String("HH:mm:ss t")); } void tst_QLocale::dateTimeFormat() -- cgit v1.2.3 From 12981e70a8b7a193ad5ed6449ffd1f8f62d799a2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 21 Oct 2013 14:59:17 +0200 Subject: MacGui tests: Remove references to CGPostMouseEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CGPostMouseEvent is obsolete and known to have "undocumented special cases and undesirable side effects." The newer Quatz API doesn't allow neither multiple mouse button events nor preserving the mouse cursor location. Change-Id: I121b02fd01e2990488b05e45431cbdc13589656e Reviewed-by: Morten Johan Sørvig --- tests/auto/other/macgui/guitest.cpp | 25 ++++++++++++++----------- tests/auto/other/macgui/guitest.h | 3 +-- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/macgui/guitest.cpp b/tests/auto/other/macgui/guitest.cpp index d7431dd88e..3359e7d935 100644 --- a/tests/auto/other/macgui/guitest.cpp +++ b/tests/auto/other/macgui/guitest.cpp @@ -144,22 +144,25 @@ WidgetNavigator::~WidgetNavigator() namespace NativeEvents { #ifdef Q_OS_MAC - void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons, MousePosition updateMouse) + void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons) { CGPoint position; position.x = globalPos.x(); position.y = globalPos.y(); - const bool updateMousePosition = (updateMouse == UpdatePosition); - - // Mouse down. - CGPostMouseEvent(position, updateMousePosition, 3, - (buttons & Qt::LeftButton) ? true : false, - (buttons & Qt::MidButton/* Middlebutton! */) ? true : false, - (buttons & Qt::RightButton) ? true : false); - - // Mouse up. - CGPostMouseEvent(position, updateMousePosition, 3, false, false, false); + CGEventType mouseDownType = (buttons & Qt::LeftButton) ? kCGEventLeftMouseDown : + (buttons & Qt::RightButton) ? kCGEventRightMouseDown : + kCGEventOtherMouseDown; + CGMouseButton mouseButton = mouseDownType == kCGEventOtherMouseDown ? kCGMouseButtonCenter : kCGEventLeftMouseDown; + CGEventRef mouseEvent = CGEventCreateMouseEvent(NULL, mouseDownType, position, mouseButton); + CGEventPost(kCGHIDEventTap, mouseEvent); + + CGEventType mouseUpType = (buttons & Qt::LeftButton) ? kCGEventLeftMouseUp : + (buttons & Qt::RightButton) ? kCGEventRightMouseUp : + kCGEventOtherMouseUp; + CGEventSetType(mouseEvent, mouseUpType); + CGEventPost(kCGHIDEventTap, mouseEvent); + CFRelease(mouseEvent); } #else # error Oops, NativeEvents::mouseClick() is not implemented on this platform. diff --git a/tests/auto/other/macgui/guitest.h b/tests/auto/other/macgui/guitest.h index 569a67d7fe..6fc4eac59f 100644 --- a/tests/auto/other/macgui/guitest.h +++ b/tests/auto/other/macgui/guitest.h @@ -86,11 +86,10 @@ private: (Implemented so far: mouseClick on Mac) */ namespace NativeEvents { - enum MousePosition { UpdatePosition, DontUpdatePosition }; /* Simulates a mouse click with button at globalPos. */ - void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons, MousePosition updateMouse = DontUpdatePosition); + void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons); }; class ColorWidget : public QWidget -- cgit v1.2.3 From 721ec985011489b35ec9fd4f3c3cb9d51864f003 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 23 Oct 2013 14:50:45 +0200 Subject: remove qt_windows.h include from qwineventnotifier.h We must not include qt_windows.h in public headers, otherwise we're cluttering the environment with a colorful bouquet of Windows API preprocessor macros and typedefs. Task-number: QTBUG-34058 Change-Id: I415717ea2a47f39e7f4b7ce1c1df9d49afc99278 Reviewed-by: Olivier Goffart --- tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp | 1 + tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 8a0ff162c6..952cb031b8 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -42,6 +42,7 @@ #include #include #include +#include class tst_QWinEventNotifier : public QObject { diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 0ee40713aa..1e2b0ed649 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -48,7 +48,7 @@ #include #ifdef Q_OS_WIN -# include +# include #endif class tst_QDateTime : public QObject -- cgit v1.2.3 From fae95d5da36f4011525a96b69187805db770e04a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 25 Oct 2013 17:00:17 +0200 Subject: Test that Qt tools can handle ' as a digit separator. Change-Id: I0a3446d02184989c32367e66d4f5d9e464a56ec6 Reviewed-by: Thiago Macieira --- tests/auto/tools/moc/moc.pro | 3 +- .../tools/moc/single-quote-digit-separator-n3781.h | 58 ++++++++++++++++++++++ tests/auto/tools/qdbuscpp2xml/test1.h | 11 ++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/auto/tools/moc/single-quote-digit-separator-n3781.h (limited to 'tests') diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index 0d25131c47..779e992881 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -23,7 +23,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n forward-declared-param.h \ parse-defines.h \ function-with-attributes.h \ - plugin_metadata.h + plugin_metadata.h \ + single-quote-digit-separator-n3781.h if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h diff --git a/tests/auto/tools/moc/single-quote-digit-separator-n3781.h b/tests/auto/tools/moc/single-quote-digit-separator-n3781.h new file mode 100644 index 0000000000..0b234011d5 --- /dev/null +++ b/tests/auto/tools/moc/single-quote-digit-separator-n3781.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class KDAB : public QObject +{ + Q_OBJECT +public: + // C++1y allows use of single quote as a digit separator, useful for large + // numbers. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf + // Ensure that moc does not get confused with this. + enum Salaries { + Steve +#ifdef Q_MOC_RUN + = 1'234'567 +#endif + }; + Q_ENUMS(Salaries) +}; diff --git a/tests/auto/tools/qdbuscpp2xml/test1.h b/tests/auto/tools/qdbuscpp2xml/test1.h index d4a7d1dab3..b08115e193 100644 --- a/tests/auto/tools/qdbuscpp2xml/test1.h +++ b/tests/auto/tools/qdbuscpp2xml/test1.h @@ -54,7 +54,18 @@ class Test1 : public QObject Q_CLASSINFO("D-Bus Interface", "org.qtProject.qdbuscpp2xmlTests.Test1") Q_PROPERTY(int numProperty1 READ numProperty1 CONSTANT) Q_PROPERTY(int numProperty2 READ numProperty2 WRITE setNumProperty2) + Q_ENUMS(Salaries) public: + // C++1y allows use of single quote as a digit separator, useful for large + // numbers. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf + // Ensure that qdbuscpp2xml does not get confused with this appearing. + enum Salaries { + Steve +#ifdef Q_MOC_RUN + = 1'234'567 +#endif + }; + Test1(QObject *parent = 0) : QObject(parent) {} int numProperty1() { return 42; } -- cgit v1.2.3 From c1f76a3347f23792110c19508b166d60dedb3dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo=20F=C3=A4lt?= Date: Tue, 29 Oct 2013 11:41:20 +0200 Subject: Adding CI utilities to Android test script It is now configurable if test results are stored in xml, plain text or in both formats. Default is xml, like it was, Max runtime is also configurable so that we can reduce the CI round. With default setting it takes more than eight hours within current CI node. The latest test result dir is linked as latest. Change-Id: I5d27cefe17e4f86648132db7ec104711d993c3de Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/android/runtests_androiddeployqt.pl | 38 ++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/android/runtests_androiddeployqt.pl b/tests/auto/android/runtests_androiddeployqt.pl index d3c9a7bc11..1cc52d0495 100755 --- a/tests/auto/android/runtests_androiddeployqt.pl +++ b/tests/auto/android/runtests_androiddeployqt.pl @@ -53,6 +53,8 @@ use Pod::Usage; my @stack = cwd; my $device_serial=""; # "-s device_serial"; my $deployqt_device_serial=""; # "-device device_serial"; +my $log_out="xml"; +my $max_runtime = 5; my $className="org.qtproject.qt5.android.bindings.QtActivity"; my $jobs = 4; my $testsubset = ""; @@ -75,6 +77,8 @@ GetOptions('h|help' => \$help , 't|test=s' => \$testsubset , 'c|clean' => \$make_clean , 'j|jobs=i' => \$jobs + , 'logtype=s' => \$log_out + , 'runtime=i' => \$max_runtime , 'sdk=s' => \$android_sdk_dir , 'ndk=s' => \$android_ndk_dir , 'toolchain=s' => \$android_toolchain_version @@ -102,7 +106,6 @@ if ($android_to_connect ne ""){ $device_serial =$android_to_connect; } - system("$adb_tool devices") == 0 or die "No device found, please plug/start at least one device/emulator\n"; # make sure we have at least on device attached $deployqt_device_serial = "--device $device_serial" if ($device_serial); @@ -171,6 +174,8 @@ my $temp_dir=tempdir(CLEANUP => 1); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $output_dir=$stack[0]."/".(1900+$year)."-$mon-$mday-$hour:$min"; mkdir($output_dir); +unlink("latest"); +system(" ln -s $output_dir latest"); my $sdk_api=0; my $output = `$adb_tool $device_serial shell getprop`; # get device properties if ($output =~ m/.*\[ro.build.version.sdk\]: \[(\d+)\]/) @@ -186,8 +191,22 @@ sub startTest my $packageName = "org.qtproject.example.tst_$testName"; my $intentName = "$packageName/org.qtproject.qt5.android.bindings.QtActivity"; my $output_file = shift; + my $get_xml= 0; + my $get_txt= 0; + my $testLib =""; + if ($log_out eq "xml") { + $testLib="-o /data/data/$packageName/output.xml,xml"; + $get_xml = 1; + } elsif ($log_out eq "txt") { + $testLib="-o /data/data/$packageName/output.txt,txt"; + $get_txt = 1; + } else { + $testLib="-o /data/data/$packageName/output.xml,xml -o /data/data/$packageName/output.txt,txt"; + $get_xml = 1; + $get_txt = 1; + } - system("$adb_tool $device_serial shell am start -e applicationArguments \"-o /data/data/$packageName/output.xml\" -n $intentName"); # start intent + system("$adb_tool $device_serial shell am start -e applicationArguments \"$testLib\" -n $intentName"); # start intent #wait to start (if it has not started and quit already) waitForProcess($packageName,1,10); @@ -198,7 +217,8 @@ sub startTest print "Someone should kill $packageName\n"; return 1; } - system("$adb_tool $device_serial pull /data/data/$packageName/output.xml $output_dir/$output_file"); + system("$adb_tool $device_serial pull /data/data/$packageName/output.xml $output_dir/$output_file.xml") if ($get_xml); + system("$adb_tool $device_serial pull /data/data/$packageName/output.txt $output_dir/$output_file.txt") if ($get_txt); return 1; } @@ -228,7 +248,7 @@ foreach (split("\n",$testsFiles)) $output_name =~ s/\///; # remove first "/" character $output_name =~ s/\//_/g; # replace all "/" with "_" $output_name=$application unless($output_name); - $time_out=5*60/5; # 5 minutes time out for a normal test + $time_out=$max_runtime*60/5; # 5 minutes time out for a normal test $applicationLibrary = `find $temp_dir -name libtst_bench_$application.so`; @@ -248,7 +268,7 @@ foreach (split("\n",$testsFiles)) } else { - startTest($application, "$output_name.xml") or warn "Can't run $application ...\n"; + startTest($application, "$output_name") or warn "Can't run $application ...\n"; } popd(); @@ -306,6 +326,14 @@ Android strip tool path, used to deploy qt libs. Android readelf tool path, used to check if a test application uses qt OpenGL. +=item B<--logtype = xml|txt|both> + +The format of log file, default is xml. + +=item B<--runtime = minutes> + +The timeout period before stopping individual tests from running. + =item B<-h --help> Print a brief help message and exits. -- cgit v1.2.3 From aa92cab34664143aa92ed6808ec925466de6f1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 30 Oct 2013 12:41:12 +0100 Subject: remove compiler warning Change-Id: I40750320d21165333b195aca7564a6f4ee9d9eef Reviewed-by: Gunnar Sletta --- tests/auto/opengl/qglthreads/tst_qglthreads.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index c74edab9a2..f5923764b8 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -346,12 +346,12 @@ void renderAScene(int w, int h) for (int i=0; i<1000; ++i) { GLfloat pos[] = { - (rand() % 100) / 100., - (rand() % 100) / 100., - (rand() % 100) / 100., - (rand() % 100) / 100., - (rand() % 100) / 100., - (rand() % 100) / 100. + (rand() % 100) / 100.f, + (rand() % 100) / 100.f, + (rand() % 100) / 100.f, + (rand() % 100) / 100.f, + (rand() % 100) / 100.f, + (rand() % 100) / 100.f }; glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, pos); -- cgit v1.2.3 From 33a88d6cd71691dd2fe616d65a3f303d2e683420 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 28 Oct 2013 16:57:00 +0100 Subject: Stabilize moveChild/showAndMoveChild-tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass window flags on to ColorWidget constructor and use a window frame + stay on top-hint for the moveChild/showAndMoveChild tests to make the screen grabbing more reliable. Disable animations on Windows since they seem to affect screen grabbing as well (fading in of windows). Task-number: QTBUG-30566 Change-Id: I8eacfc203d26674dc1b283d6643f3d434f218f26 Reviewed-by: Jan Arve Sæther --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 86 ++++++++++++++++------- 1 file changed, 59 insertions(+), 27 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 227f61b0a3..fe85a1a42f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -170,6 +170,24 @@ static inline void centerOnScreen(QWidget *w) w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); } +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +static inline void setWindowsAnimationsEnabled(bool enabled) +{ + ANIMATIONINFO animation = { sizeof(ANIMATIONINFO), enabled }; + SystemParametersInfo(SPI_SETANIMATION, 0, &animation, 0); +} + +static inline bool windowsAnimationsEnabled() +{ + ANIMATIONINFO animation = { sizeof(ANIMATIONINFO), 0 }; + SystemParametersInfo(SPI_GETANIMATION, 0, &animation, 0); + return animation.iMinAnimate; +} +#else // Q_OS_WIN && !Q_OS_WINCE +inline void setWindowsAnimationsEnabled(bool) {} +static inline bool windowsAnimationsEnabled() { return false; } +#endif // !Q_OS_WIN || Q_OS_WINCE + class tst_QWidget : public QObject { Q_OBJECT @@ -425,6 +443,7 @@ private: QWidget *testWidget; const QString m_platform; + const bool m_windowsAnimationsEnabled; }; bool tst_QWidget::ensureScreenSize(int width, int height) @@ -579,8 +598,12 @@ void tst_QWidget::getSetCheck() #endif } -tst_QWidget::tst_QWidget() : m_platform(qApp->platformName().toLower()) +tst_QWidget::tst_QWidget() + : m_platform(qApp->platformName().toLower()) + , m_windowsAnimationsEnabled(windowsAnimationsEnabled()) { + if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild() + setWindowsAnimationsEnabled(false); QFont font; font.setBold(true); font.setPointSize(42); @@ -596,6 +619,8 @@ tst_QWidget::tst_QWidget() : m_platform(qApp->platformName().toLower()) tst_QWidget::~tst_QWidget() { + if (m_windowsAnimationsEnabled) + setWindowsAnimationsEnabled(m_windowsAnimationsEnabled); } class BezierViewer : public QWidget { @@ -4751,8 +4776,8 @@ void tst_QWidget::windowMoveResize() class ColorWidget : public QWidget { public: - ColorWidget(QWidget *parent = 0, const QColor &c = QColor(Qt::red)) - : QWidget(parent, Qt::FramelessWindowHint), color(c), enters(0), leaves(0) + ColorWidget(QWidget *parent = 0, Qt::WindowFlags f = 0, const QColor &c = QColor(Qt::red)) + : QWidget(parent, f), color(c), enters(0), leaves(0) { QPalette opaquePalette = palette(); opaquePalette.setColor(backgroundRole(), color); @@ -4783,6 +4808,12 @@ public: int leaves; }; +static inline QByteArray msgRgbMismatch(unsigned actual, unsigned expected) +{ + return QByteArrayLiteral("Color mismatch, 0x") + QByteArray::number(actual, 16) + + QByteArrayLiteral(" != 0x") + QByteArray::number(expected, 16); +} + #define VERIFY_COLOR(region, color) { \ const QRegion r = QRegion(region); \ QScreen *screen = qApp->primaryScreen(); \ @@ -4802,7 +4833,7 @@ public: uint firstPixel = image.pixel(0,0) | alphaCorrection; \ if ( firstPixel != QColor(color).rgb() && t < 4 ) \ { QTest::qWait(200); continue; } \ - QCOMPARE(firstPixel, QColor(color).rgb()); \ + QVERIFY2(firstPixel == QColor(color).rgb(), msgRgbMismatch(firstPixel, QColor(color).rgb())); \ QCOMPARE(pixmap, expectedPixmap); \ break; \ } \ @@ -4815,7 +4846,7 @@ void tst_QWidget::popupEnterLeave() parent.setWindowFlags(Qt::FramelessWindowHint); parent.setGeometry(10, 10, 200, 100); - ColorWidget alien(&parent, Qt::black); + ColorWidget alien(&parent, Qt::Widget, Qt::black); alien.setGeometry(0, 0, 10, 10); alien.show(); @@ -4866,23 +4897,23 @@ void tst_QWidget::moveChild_data() void tst_QWidget::moveChild() { -#if defined(UBUNTU_ONEIRIC) - QSKIP("QTBUG-30566 - Unstable auto-test"); -#endif QFETCH(QPoint, offset); - ColorWidget parent; + ColorWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint); // prevent custom styles parent.setStyle(QStyleFactory::create(QLatin1String("Windows"))); - ColorWidget child(&parent, Qt::blue); + ColorWidget child(&parent, Qt::Widget, Qt::blue); #ifndef Q_OS_WINCE - parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()), - QSize(100, 100))); + parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()) + QPoint(50, 50), + QSize(200, 200))); #else parent.setGeometry(60, 60, 150, 150); #endif child.setGeometry(25, 25, 50, 50); +#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting + QCursor::setPos(parent.geometry().topRight() + QPoint(50 , 50)); +#endif parent.show(); QVERIFY(QTest::qWaitForWindowExposed(&parent)); QTest::qWait(30); @@ -4922,7 +4953,7 @@ void tst_QWidget::showAndMoveChild() #if defined(UBUNTU_ONEIRIC) QSKIP("QTBUG-30566 - Unstable auto-test"); #endif - QWidget parent(0, Qt::FramelessWindowHint); + QWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint); // prevent custom styles parent.setStyle(QStyleFactory::create(QLatin1String("Windows"))); @@ -4930,6 +4961,9 @@ void tst_QWidget::showAndMoveChild() QRect desktopDimensions = desktop.availableGeometry(&parent); desktopDimensions = desktopDimensions.adjusted(64, 64, -64, -64); +#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting + QCursor::setPos(desktopDimensions.topRight() + QPoint(40, 40)); +#endif parent.setGeometry(desktopDimensions); parent.setPalette(Qt::red); parent.show(); @@ -4960,13 +4994,13 @@ void tst_QWidget::subtractOpaqueSiblings() QWidget w; w.setGeometry(50, 50, 300, 300); - ColorWidget *large = new ColorWidget(&w, Qt::red); + ColorWidget *large = new ColorWidget(&w, Qt::Widget, Qt::red); large->setGeometry(50, 50, 200, 200); - ColorWidget *medium = new ColorWidget(large, Qt::gray); + ColorWidget *medium = new ColorWidget(large, Qt::Widget, Qt::gray); medium->setGeometry(50, 50, 100, 100); - ColorWidget *tall = new ColorWidget(&w, Qt::blue); + ColorWidget *tall = new ColorWidget(&w, Qt::Widget, Qt::blue); tall->setGeometry(100, 30, 50, 100); w.show(); @@ -7049,7 +7083,7 @@ void tst_QWidget::repaintWhenChildDeleted() QTest::qWait(1000); } #endif - ColorWidget w(0, Qt::red); + ColorWidget w(0, Qt::FramelessWindowHint, Qt::red); #if !defined(Q_OS_WINCE) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; @@ -7065,7 +7099,7 @@ void tst_QWidget::repaintWhenChildDeleted() w.r = QRegion(); { - ColorWidget child(&w, Qt::blue); + ColorWidget child(&w, Qt::Widget, Qt::blue); child.setGeometry(10, 10, 10, 10); child.show(); QTest::qWait(10); @@ -7080,7 +7114,7 @@ void tst_QWidget::repaintWhenChildDeleted() // task 175114 void tst_QWidget::hideOpaqueChildWhileHidden() { - ColorWidget w(0, Qt::red); + ColorWidget w(0, Qt::FramelessWindowHint, Qt::red); #if !defined(Q_OS_WINCE) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; @@ -7090,10 +7124,10 @@ void tst_QWidget::hideOpaqueChildWhileHidden() w.setGeometry(60, 60, 110, 110); #endif - ColorWidget child(&w, Qt::blue); + ColorWidget child(&w, Qt::Widget, Qt::blue); child.setGeometry(10, 10, 80, 80); - ColorWidget child2(&child, Qt::white); + ColorWidget child2(&child, Qt::Widget, Qt::white); child2.setGeometry(10, 10, 60, 60); w.show(); @@ -9780,18 +9814,16 @@ void tst_QWidget::underMouse() // Move the mouse cursor to a safe location QCursor::setPos(0,0); - ColorWidget topLevelWidget(0, Qt::blue); - ColorWidget childWidget1(&topLevelWidget, Qt::yellow); - ColorWidget childWidget2(&topLevelWidget, Qt::black); - ColorWidget popupWidget(0, Qt::green); + ColorWidget topLevelWidget(0, Qt::FramelessWindowHint, Qt::blue); + ColorWidget childWidget1(&topLevelWidget, Qt::Widget, Qt::yellow); + ColorWidget childWidget2(&topLevelWidget, Qt::Widget, Qt::black); + ColorWidget popupWidget(0, Qt::Popup, Qt::green); topLevelWidget.setObjectName("topLevelWidget"); childWidget1.setObjectName("childWidget1"); childWidget2.setObjectName("childWidget2"); popupWidget.setObjectName("popupWidget"); - popupWidget.setWindowFlags(Qt::Popup); - topLevelWidget.setGeometry(100, 100, 300, 300); childWidget1.setGeometry(20, 20, 100, 100); childWidget2.setGeometry(20, 120, 100, 100); -- cgit v1.2.3 From 04de24c6449422d29a0d4760375aa94f59222fa3 Mon Sep 17 00:00:00 2001 From: Chengyong Xie Date: Fri, 13 Sep 2013 16:25:22 +0800 Subject: Fix setVisible() of QWidget has no effect in QTreeWidgetItem Check if the item is hidden before show the item(QWidget) Task-number: QTBUG-13522 Change-Id: I1c605d5cb8a80f340e9b7601612d3760f51cb4a7 Reviewed-by: Liang Qi Reviewed-by: Stephen Kelly Reviewed-by: David Faure --- .../itemviews/qtreewidget/tst_qtreewidget.cpp | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 83ba1ddcda..1de5749c69 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -165,6 +165,7 @@ private slots: void setChildIndicatorPolicy(); void task20345_sortChildren(); + void taskQTBUG13522_checkItemVisibilityBeforeItemShow(); public slots: void itemSelectionChanged(); @@ -3371,6 +3372,39 @@ void tst_QTreeWidget::task20345_sortChildren() QVERIFY(1); } +void tst_QTreeWidget::taskQTBUG13522_checkItemVisibilityBeforeItemShow() +{ + class TreeView : public QTreeWidget + { + public: + explicit TreeView(QWidget *parent = 0) : QTreeWidget(parent) + , item1_visibility(false), item2_visibility(false) {} + void showEvent(QShowEvent * /*event*/) Q_DECL_OVERRIDE + { + item1_visibility = !item1->isVisible(); + item2_visibility = item2->isVisible(); + } + QWidget *item1; + QWidget *item2; + bool item1_visibility; + bool item2_visibility; + + } tw; + tw.item1 = new QWidget(&tw); + tw.item2 = new QWidget(&tw); + QTreeWidgetItem *widget_item = new QTreeWidgetItem(); + widget_item->setText(0, "example text"); + tw.addTopLevelItem(widget_item); + tw.setItemWidget(widget_item, 0, tw.item1); + widget_item = new QTreeWidgetItem(); + tw.setItemWidget(widget_item, 0, tw.item2); + //set visible must after setItemWidget or setItemWidget will reset the visibility + tw.item1->setVisible(false); + tw.item2->setVisible(true); + tw.show(); + QTRY_VERIFY(tw.item1_visibility); + QTRY_VERIFY(tw.item2_visibility); +} QTEST_MAIN(tst_QTreeWidget) #include "tst_qtreewidget.moc" -- cgit v1.2.3 From 7b33bd411061b021c6a6d68f64dfac205a4e65ac Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 31 Oct 2013 14:27:49 +0100 Subject: Fix stability issues in tst_qwidget with VERIFY_COLOR The grabbing always grabbed the desktop. This caused it to also grab tooltips, siderbars etc that could overlap the window which again caused the pixmap comparison to obviously fail. This will currently only fix it on windows. If needed, it should also be fixed for other platforms. Task-number: QTBUG-30566 Change-Id: I5cee8651e1d94dedded0acae8b19f351acd976c4 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 84 ++++++++++++++++------- 1 file changed, 61 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index fe85a1a42f..03d6c1cdbd 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -75,6 +75,7 @@ #include #include #include +#include #include "../../../qtest-config.h" @@ -4814,31 +4815,73 @@ static inline QByteArray msgRgbMismatch(unsigned actual, unsigned expected) QByteArrayLiteral(" != 0x") + QByteArray::number(expected, 16); } -#define VERIFY_COLOR(region, color) { \ +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +QT_BEGIN_NAMESPACE +extern Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); +QT_END_NAMESPACE + +// grabs the window *without including any overlapping windows* +static QPixmap grabWindow(QWindow *window, int x, int y, int width, int height) +{ + const HWND hwnd = (HWND)window->winId(); + + // Create and setup bitmap + const HDC displayDc = ::GetDC(0); + const HDC bitmapDc = ::CreateCompatibleDC(displayDc); + const HBITMAP bitmap = ::CreateCompatibleBitmap(displayDc, width, height); + const HGDIOBJ oldBitmap = ::SelectObject(bitmapDc, bitmap); + + // copy data + const HDC windowDc = ::GetDC(hwnd); + ::BitBlt(bitmapDc, 0, 0, width, height, windowDc, x, y, SRCCOPY); + + // clean up all but bitmap + ::ReleaseDC(hwnd, windowDc); + ::SelectObject(bitmapDc, oldBitmap); + ::DeleteDC(bitmapDc); + + const QPixmap pixmap = qt_pixmapFromWinHBITMAP(bitmap); + + ::DeleteObject(bitmap); + ::ReleaseDC(0, displayDc); + + return pixmap; +} +#else +// fallback for other platforms. +static QPixmap grabWindow(QWindow *window, int x, int y, int width, int height) +{ + QScreen *screen = window->screen(); + return screen ? screen->grabWindow(window->winId(), x, y, width, height) : QPixmap(); +} +#endif //defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) + +#define VERIFY_COLOR(child, region, color) do { \ const QRegion r = QRegion(region); \ - QScreen *screen = qApp->primaryScreen(); \ - const WId desktopWinId = QDesktopWidget().winId(); \ + QWindow *window = child.window()->windowHandle(); \ + Q_ASSERT(window); \ + const QPoint offset = child.mapTo(child.window(), QPoint(0,0)); \ for (int i = 0; i < r.rects().size(); ++i) { \ - const QRect rect = r.rects().at(i); \ + const QRect rect = r.rects().at(i).translated(offset); \ for (int t = 0; t < 5; t++) { \ - const QPixmap pixmap = screen->grabWindow(desktopWinId, \ - rect.left(), rect.top(), \ - rect.width(), rect.height()); \ + const QPixmap pixmap = grabWindow(window, \ + rect.left(), rect.top(), \ + rect.width(), rect.height()); \ QCOMPARE(pixmap.size(), rect.size()); \ QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ - expectedPixmap.detach(); \ + expectedPixmap.detach(); \ expectedPixmap.fill(color); \ - QImage image = pixmap.toImage(); \ + QImage image = pixmap.toImage(); \ uint alphaCorrection = image.format() == QImage::Format_RGB32 ? 0xff000000 : 0; \ - uint firstPixel = image.pixel(0,0) | alphaCorrection; \ - if ( firstPixel != QColor(color).rgb() && t < 4 ) \ + uint firstPixel = image.pixel(0,0) | alphaCorrection; \ + if ( firstPixel != QColor(color).rgb() && t < 4 ) \ { QTest::qWait(200); continue; } \ QVERIFY2(firstPixel == QColor(color).rgb(), msgRgbMismatch(firstPixel, QColor(color).rgb())); \ QCOMPARE(pixmap, expectedPixmap); \ break; \ } \ } \ -} +} while (0) void tst_QWidget::popupEnterLeave() { @@ -4917,14 +4960,12 @@ void tst_QWidget::moveChild() parent.show(); QVERIFY(QTest::qWaitForWindowExposed(&parent)); QTest::qWait(30); - const QPoint tlwOffset = parent.geometry().topLeft(); QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); - VERIFY_COLOR(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child, child.rect(), child.color); - VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), - parent.color); + VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), parent.color); parent.reset(); child.reset(); @@ -4942,10 +4983,8 @@ void tst_QWidget::moveChild() // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif - VERIFY_COLOR(child.geometry().translated(tlwOffset), - child.color); - VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), - parent.color); + VERIFY_COLOR(child, child.rect(), child.color); + VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), parent.color); } void tst_QWidget::showAndMoveChild() @@ -4971,7 +5010,6 @@ void tst_QWidget::showAndMoveChild() QVERIFY(QTest::qWaitForWindowActive(&parent)); QTest::qWait(10); - const QPoint tlwOffset = parent.geometry().topLeft(); QWidget child(&parent); child.resize(desktopDimensions.width()/2, desktopDimensions.height()/2); child.setPalette(Qt::blue); @@ -4983,8 +5021,8 @@ void tst_QWidget::showAndMoveChild() child.move(desktopDimensions.width()/2, desktopDimensions.height()/2); qApp->processEvents(); - VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); - VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); + VERIFY_COLOR(child, child.rect(), Qt::blue); + VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), Qt::red); } // Cocoa only has rect granularity. -- cgit v1.2.3 From dd5f1ab4541a50e963555a082534fc4275680a33 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Nov 2013 16:05:39 +0100 Subject: Fix compilation of the manual dialogs test with Qt 4. This is useful for comparisons and bug fixes. Change-Id: Ib5c5bcb7df4b15779be0b613782206f052c94430 Reviewed-by: J-P Nurmi --- tests/manual/dialogs/filedialogpanel.cpp | 10 ++++++++++ tests/manual/dialogs/fontdialogpanel.cpp | 2 ++ tests/manual/dialogs/messageboxpanel.cpp | 4 ++++ 3 files changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp index e234835cdb..682e944556 100644 --- a/tests/manual/dialogs/filedialogpanel.cpp +++ b/tests/manual/dialogs/filedialogpanel.cpp @@ -355,6 +355,7 @@ void FileDialogPanel::getOpenFileNames() void FileDialogPanel::getOpenFileUrls() { +#if QT_VERSION >= 0x050000 QString selectedFilter = m_selectedNameFilter->text().trimmed(); const QList files = QFileDialog::getOpenFileUrls(this, tr("getOpenFileNames Qt %1").arg(QLatin1String(QT_VERSION_STR)), @@ -367,6 +368,7 @@ void FileDialogPanel::getOpenFileUrls() << "\nName filter: " << selectedFilter; QMessageBox::information(this, tr("getOpenFileNames"), result, QMessageBox::Ok); } +#endif // Qt 5 } void FileDialogPanel::getOpenFileName() @@ -386,6 +388,7 @@ void FileDialogPanel::getOpenFileName() void FileDialogPanel::getOpenFileUrl() { +#if QT_VERSION >= 0x050000 QString selectedFilter = m_selectedNameFilter->text().trimmed(); const QUrl file = QFileDialog::getOpenFileUrl(this, tr("getOpenFileUrl Qt %1").arg(QLatin1String(QT_VERSION_STR)), @@ -398,6 +401,7 @@ void FileDialogPanel::getOpenFileUrl() << "\nName filter: " << selectedFilter; QMessageBox::information(this, tr("getOpenFileName"), result, QMessageBox::Ok); } +#endif // Qt 5 } void FileDialogPanel::getSaveFileName() @@ -417,6 +421,7 @@ void FileDialogPanel::getSaveFileName() void FileDialogPanel::getSaveFileUrl() { +#if QT_VERSION >= 0x050000 QString selectedFilter = m_selectedNameFilter->text().trimmed(); const QUrl file = QFileDialog::getSaveFileUrl(this, tr("getSaveFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)), @@ -429,6 +434,7 @@ void FileDialogPanel::getSaveFileUrl() << "\nName filter: " << selectedFilter; QMessageBox::information(this, tr("getSaveFileNames"), result, QMessageBox::Ok); } +#endif // Qt 5 } void FileDialogPanel::getExistingDirectory() @@ -442,12 +448,14 @@ void FileDialogPanel::getExistingDirectory() void FileDialogPanel::getExistingDirectoryUrl() { +#if QT_VERSION >= 0x050000 const QUrl dir = QFileDialog::getExistingDirectoryUrl(this, tr("getExistingDirectory Qt %1").arg(QLatin1String(QT_VERSION_STR)), QUrl(m_directory->text()), options() | QFileDialog::ShowDirsOnly, allowedSchemes()); if (!dir.isEmpty()) QMessageBox::information(this, tr("getExistingDirectory"), QLatin1String("Directory: ") + dir.toString(), QMessageBox::Ok); +#endif // Qt 5 } void FileDialogPanel::restoreDefaults() @@ -493,9 +501,11 @@ void FileDialogPanel::applySettings(QFileDialog *d) const if (!filter.isEmpty()) d->selectNameFilter(filter); } else { +#if QT_VERSION >= 0x050000 d->setMimeTypeFilters(filters); if (!filter.isEmpty()) d->selectMimeTypeFilter(filter); +#endif // Qt 5 } foreach (LabelLineEdit *l, m_labelLineEdits) l->apply(d); diff --git a/tests/manual/dialogs/fontdialogpanel.cpp b/tests/manual/dialogs/fontdialogpanel.cpp index c72bf77351..ff45402197 100644 --- a/tests/manual/dialogs/fontdialogpanel.cpp +++ b/tests/manual/dialogs/fontdialogpanel.cpp @@ -209,10 +209,12 @@ void FontDialogPanel::applySettings(QFontDialog *d) const { d->setOption(QFontDialog::NoButtons, m_noButtons->isChecked()); d->setOption(QFontDialog::DontUseNativeDialog, m_dontUseNativeDialog->isChecked()); +#if QT_VERSION >= 0x050000 d->setOption(QFontDialog::ScalableFonts, m_scalableFilter->isChecked()); d->setOption(QFontDialog::NonScalableFonts, m_nonScalableFilter->isChecked()); d->setOption(QFontDialog::MonospacedFonts, m_monospacedFilter->isChecked()); d->setOption(QFontDialog::ProportionalFonts, m_proportionalFilter->isChecked()); +#endif // Qt 5 QFont font = m_fontFamilyBox->currentFont(); font.setPointSizeF(m_fontSizeBox->value()); diff --git a/tests/manual/dialogs/messageboxpanel.cpp b/tests/manual/dialogs/messageboxpanel.cpp index 529a8251e1..ced582981e 100644 --- a/tests/manual/dialogs/messageboxpanel.cpp +++ b/tests/manual/dialogs/messageboxpanel.cpp @@ -149,9 +149,11 @@ void MessageBoxPanel::setupMessageBox(QMessageBox &box) if (box.standardButtons() == (QMessageBox::StandardButtons) 0) box.setStandardButtons(QMessageBox::Ok); // just to have something. +#if QT_VERSION >= 0x050000 box.setCheckBox(0); if (m_checkboxText->text().length() > 0) box.setCheckBox(new QCheckBox(m_checkboxText->text())); +#endif // Qt 5 box.setIcon((QMessageBox::Icon) m_iconComboBox->currentIndex()); } @@ -176,12 +178,14 @@ void MessageBoxPanel::doExec() QString sres; sres.setNum(res, 16); m_resultLabel->setText(QString::fromLatin1("Return value (hex): %1").arg(sres)); +#if QT_VERSION >= 0x050000 if (m_msgbox->checkBox()) { if (m_msgbox->checkBox()->isChecked()) m_checkBoxResult->setText(QString::fromLatin1("Checkbox was checked")); else m_checkBoxResult->setText(QString::fromLatin1("Checkbox was not checked")); } +#endif // Qt 5 } void MessageBoxPanel::doShowApply() -- cgit v1.2.3 From c2b8ebe9dbb2b3fa8f5e157b4d98e0a8d8208332 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 4 Nov 2013 15:06:17 +0100 Subject: tests: make qt_on_cocoa build again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QPA was public since 36547f4eff44361f7a6acd0cff107c0e47561f93. Change-Id: I838cc0736dc75e5301dd41f3ea89848f300443d4 Reviewed-by: Morten Johan Sørvig --- tests/manual/cocoa/qt_on_cocoa/main.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm index c9338f25f4..9a39788b02 100644 --- a/tests/manual/cocoa/qt_on_cocoa/main.mm +++ b/tests/manual/cocoa/qt_on_cocoa/main.mm @@ -44,7 +44,7 @@ #include #include -#include +#include #include -- cgit v1.2.3 From 2e8ad02b7d10c100dcd9d559b019c474fa4b8a29 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Nov 2013 12:46:42 +0100 Subject: Add print dialog manual test. Allowing for creating a printer in various modes and toying with the paper settings. Task-number: QTBUG-34276 Change-Id: Ieb35dc55c509f84d7d81817c7903e02a41ba8b44 Reviewed-by: John Layt --- tests/manual/dialogs/dialogs.pro | 6 +- tests/manual/dialogs/filedialogpanel.cpp | 39 +-- tests/manual/dialogs/main.cpp | 4 + tests/manual/dialogs/printdialogpanel.cpp | 417 ++++++++++++++++++++++++++++++ tests/manual/dialogs/printdialogpanel.h | 95 +++++++ tests/manual/dialogs/utils.cpp | 85 ++++++ tests/manual/dialogs/utils.h | 88 +++++++ 7 files changed, 699 insertions(+), 35 deletions(-) create mode 100644 tests/manual/dialogs/printdialogpanel.cpp create mode 100644 tests/manual/dialogs/printdialogpanel.h create mode 100644 tests/manual/dialogs/utils.cpp create mode 100644 tests/manual/dialogs/utils.h (limited to 'tests') diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro index d19c3026d0..71c41119fe 100644 --- a/tests/manual/dialogs/dialogs.pro +++ b/tests/manual/dialogs/dialogs.pro @@ -1,10 +1,10 @@ QT += core gui -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport TARGET = dialogs TEMPLATE = app SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp \ - wizardpanel.cpp messageboxpanel.cpp + wizardpanel.cpp messageboxpanel.cpp printdialogpanel.cpp utils.cpp HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h \ - wizardpanel.h messageboxpanel.h + wizardpanel.h messageboxpanel.h printdialogpanel.h utils.h diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp index 682e944556..2ae6241849 100644 --- a/tests/manual/dialogs/filedialogpanel.cpp +++ b/tests/manual/dialogs/filedialogpanel.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "filedialogpanel.h" +#include "utils.h" #include #include @@ -48,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -60,25 +60,19 @@ #include #include -struct ComboData -{ - const char *description; - int value; -}; - -const ComboData acceptModeComboData[] = +const FlagData acceptModeComboData[] = { {"AcceptOpen", QFileDialog::AcceptOpen }, {"AcceptSave", QFileDialog::AcceptSave } }; -const ComboData viewModeComboData[] = +const FlagData viewModeComboData[] = { {"Detail", QFileDialog::Detail}, {"List", QFileDialog::List} }; -const ComboData fileModeComboData[] = +const FlagData fileModeComboData[] = { {"AnyFile", QFileDialog::AnyFile}, {"ExistingFile", QFileDialog::ExistingFile}, @@ -87,25 +81,6 @@ const ComboData fileModeComboData[] = {"DirectoryOnly", QFileDialog::DirectoryOnly} }; -static QComboBox *createCombo(QWidget *parent, const ComboData *d, size_t size) -{ - QComboBox *c = new QComboBox(parent); - for (size_t i = 0; i < size; ++i) - c->addItem(QLatin1String(d[i].description), QVariant(d[i].value)); - return c; -} - -template -Enum comboBoxValue(const QComboBox *c) -{ - return static_cast(c->itemData(c->currentIndex()).toInt()); -} - -inline void setComboBoxValue(QComboBox *c, int v) -{ - c->setCurrentIndex(c->findData(QVariant(v))); -} - static inline QPushButton *addButton(const QString &description, QGridLayout *layout, int &row, int column, QObject *receiver, const char *slotFunc) { @@ -155,9 +130,9 @@ FileDialogPanel::FileDialogPanel(QWidget *parent) , m_resolveSymLinks(new QCheckBox(tr("Resolve symlinks"))) , m_native(new QCheckBox(tr("Use native dialog"))) , m_customDirIcons(new QCheckBox(tr("Don't use custom directory icons"))) - , m_acceptMode(createCombo(this, acceptModeComboData, sizeof(acceptModeComboData)/sizeof(ComboData))) - , m_fileMode(createCombo(this, fileModeComboData, sizeof(fileModeComboData)/sizeof(ComboData))) - , m_viewMode(createCombo(this, viewModeComboData, sizeof(viewModeComboData)/sizeof(ComboData))) + , m_acceptMode(createCombo(this, acceptModeComboData, sizeof(acceptModeComboData)/sizeof(FlagData))) + , m_fileMode(createCombo(this, fileModeComboData, sizeof(fileModeComboData)/sizeof(FlagData))) + , m_viewMode(createCombo(this, viewModeComboData, sizeof(viewModeComboData)/sizeof(FlagData))) , m_allowedSchemes(new QLineEdit(this)) , m_defaultSuffix(new QLineEdit(this)) , m_directory(new QLineEdit(this)) diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp index c5f14cabef..6082727c3b 100644 --- a/tests/manual/dialogs/main.cpp +++ b/tests/manual/dialogs/main.cpp @@ -42,6 +42,7 @@ #include "filedialogpanel.h" #include "colordialogpanel.h" #include "fontdialogpanel.h" +#include "printdialogpanel.h" #include "wizardpanel.h" #include "messageboxpanel.h" @@ -75,6 +76,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) tabWidget->addTab(new FontDialogPanel, tr("QFontDialog")); tabWidget->addTab(new WizardPanel, tr("QWizard")); tabWidget->addTab(new MessageBoxPanel, tr("QMessageBox")); +#ifndef QT_NO_PRINTER + tabWidget->addTab(new PrintDialogPanel, tr("QPrintDialog")); +#endif setCentralWidget(tabWidget); } diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp new file mode 100644 index 0000000000..02beaa4bae --- /dev/null +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -0,0 +1,417 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT_NO_PRINTER + +#include "printdialogpanel.h" +#include "utils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const FlagData modeComboData[] = +{ + {"ScreenResolution", QPrinter::ScreenResolution}, + {"PrinterResolution", QPrinter::PrinterResolution}, + {"HighResolution", QPrinter::HighResolution} +}; + +const FlagData orientationComboData[] = +{ + {"Portrait", QPrinter::Portrait}, + {"Landscape", QPrinter::Landscape}, +}; + +const FlagData pageSizeComboData[] = +{ + {"A4", QPrinter::A4}, + {"B5", QPrinter::B5}, + {"Letter", QPrinter::Letter}, + {"Legal", QPrinter::Legal}, + {"Executive", QPrinter::Executive}, + {"A0", QPrinter::A0}, + {"A1", QPrinter::A1}, + {"A2", QPrinter::A2}, + {"A3", QPrinter::A3}, + {"A5", QPrinter::A5}, + {"A6", QPrinter::A6}, + {"A7", QPrinter::A7}, + {"A8", QPrinter::A8}, + {"A9", QPrinter::A9}, + {"B0", QPrinter::B0}, + {"B1", QPrinter::B1}, + {"B10", QPrinter::B10}, + {"B2", QPrinter::B2}, + {"B3", QPrinter::B3}, + {"B4", QPrinter::B4}, + {"B6", QPrinter::B6}, + {"B7", QPrinter::B7}, + {"B8", QPrinter::B8}, + {"B9", QPrinter::B9}, + {"C5E", QPrinter::C5E}, + {"Comm10E", QPrinter::Comm10E}, + {"DLE", QPrinter::DLE}, + {"Folio", QPrinter::Folio}, + {"Ledger", QPrinter::Ledger}, + {"Tabloid", QPrinter::Tabloid}, + {"Custom", QPrinter::Custom} +}; + +const FlagData printDialogOptions[] = +{ + {"PrintToFile", QPrintDialog::PrintToFile}, + {"PrintSelection", QPrintDialog::PrintSelection}, + {"PrintPageRange", QPrintDialog::PrintPageRange}, + {"PrintShowPageSize", QPrintDialog::PrintShowPageSize}, + {"PrintCollateCopies", QPrintDialog::PrintCollateCopies}, + {"PrintCurrentPage", QPrintDialog::PrintCurrentPage} +}; + +const FlagData printRangeOptions[] = +{ + {"AllPages", QPrintDialog::AllPages}, + {"Selection", QPrintDialog::Selection}, + {"PageRange", QPrintDialog::PageRange}, + {"CurrentPage", QPrintDialog::CurrentPage} +}; + +QTextStream &operator<<(QTextStream &s, const QSizeF &size) +{ + s << size.width() << 'x' << size.height(); + return s; +} + +QTextStream &operator<<(QTextStream &s, const QRectF &rect) +{ + s << rect.width() << 'x' << rect.height() << forcesign << rect.x() << rect.y() << noforcesign; + return s; +} + +QTextStream &operator<<(QTextStream &s, const QPrinter &printer) +{ + s << '"' << printer.printerName() << "\"\nPaper #" <= 0x050000 + << " \"" << printer.paperName() << '"' +#endif + << (printer.orientation() == QPrinter::Portrait ? ", Portrait" : ", Landscape"); + if (printer.fullPage()) + s << ", full page"; + s << "\nPaper size: " + << printer.paperSize(QPrinter::Point) << "pt " + << printer.paperSize(QPrinter::Millimeter) << "mm " + << "\n " << printer.paperSize(QPrinter::DevicePixel) << "device pt " + << printer.paperSize(QPrinter::Inch) << "inch " +#if QT_VERSION >= 0x050000 + << "\nPagedPaintDevSize: " << printer.pageSizeMM() << "mm" +#endif + << "\nLogical resolution : " << printer.logicalDpiX() << ',' << printer.logicalDpiY() << "DPI" + << "\nPhysical resolution: " << printer.physicalDpiX() << ',' << printer.physicalDpiY() << "DPI" + << "\nPaperRect: " << printer.paperRect(QPrinter::Point) << "pt " + << printer.paperRect(QPrinter::Millimeter) << "mm " + << "\n " << printer.paperRect(QPrinter::DevicePixel) << "device pt" + << "\nPageRect: " << printer.pageRect(QPrinter::Point) << "pt " + << printer.pageRect(QPrinter::Millimeter) << "mm " + << "\n " << printer.pageRect(QPrinter::DevicePixel) << "device pt"; + return s; +} + +// Print a page with a rectangular frame, vertical / horizontal rulers in cm and printer info. + +static void drawHorizCmRuler(QPainter &painter, int x1, int x2, int y) +{ + painter.drawLine(x1, y, x2, y); + const int dpI = painter.device()->logicalDpiX(); + const int dpCm = qRound(double(dpI) / 2.54); + const int h = dpCm / 2; + const QFontMetrics fm(painter.font()); + for (int cm = 0, x = x1; x < x2; x += dpCm, ++cm) { + painter.drawLine(x, y, x, y - h); + if (cm) { + const QString n = QString::number(cm); + const QRect br = fm.boundingRect(n); + painter.drawText(x - br.width() / 2, y - h - 10, n); + } + } +} + +static void drawVertCmRuler(QPainter &painter, int x, int y1, int y2) +{ + painter.drawLine(x, y1, x, y2); + const int dpI = painter.device()->logicalDpiY(); + const int dpCm = qRound(double(dpI) / 2.54); + const int h = dpCm / 2; + const QFontMetrics fm(painter.font()); + for (int cm = 0, y = y1; y < y2; y += dpCm, ++cm) { + painter.drawLine(x, y, x + h, y); + if (cm) { + const QString n = QString::number(cm); + const QRect br = fm.boundingRect(n); + painter.drawText(x + h + 10, y + br.height() / 2, n); + } + } +} + +static void print(QPrinter *printer) +{ + QPainter painter(printer); + const QRectF pageF = printer->pageRect(); + + painter.drawRect(pageF); + + drawHorizCmRuler(painter, pageF.x(), pageF.right(), pageF.height() /2); + drawVertCmRuler(painter, pageF.x() + pageF.width() / 2, pageF.top(), pageF.bottom()); + + QFont font = painter.font(); + font.setFamily("Courier"); + font.setPointSize(10); + painter.setFont(font); + + // Format message. + const int charHeight = QFontMetrics(font).boundingRect('X').height(); + QString msg; + QTextStream str(&msg); + str << "Qt "<< QT_VERSION_STR; +#if QT_VERSION >= 0x050000 + str << ' ' << QGuiApplication::platformName(); +#endif + str << ' ' << QDateTime::currentDateTime().toString() + << "\nFont: " << font.family() << ' ' << font.pointSize() << '\n' + << *printer; + + QPointF textPoint = pageF.topLeft() + QPoint(10, charHeight + 10); + foreach (const QString &line, msg.split('\n')) { + painter.drawText(textPoint, line); + textPoint.ry() += (15 * charHeight) / 10; + } + + painter.end(); +} + +class PrintPreviewDialog : public QPrintPreviewDialog { + Q_OBJECT +public: + explicit PrintPreviewDialog(QPrinter *printer, QWidget *parent = 0) : QPrintPreviewDialog(printer, parent) + { + connect(this, SIGNAL(paintRequested(QPrinter*)), this, SLOT(slotPaintRequested(QPrinter*))); + } + +public slots: + void slotPaintRequested(QPrinter *p) { print(p); } +}; + +class PageSizeControl : public QWidget { +public: + explicit PageSizeControl(QWidget *parent = 0); + QSizeF pageSize() const { return QSizeF(m_width->value(), m_height->value()); } + void setPageSize(const QSizeF &s) { m_width->setValue(s.width()); m_height->setValue(s.height()); } + +private: + QDoubleSpinBox *m_width; + QDoubleSpinBox *m_height; +}; + +PageSizeControl::PageSizeControl(QWidget *parent) + : QWidget(parent) + , m_width(new QDoubleSpinBox(this)) + , m_height(new QDoubleSpinBox(this)) +{ + m_width->setRange(1, 1000); + m_width->setSingleStep(10); + m_height->setRange(1, 1000); + m_height->setSingleStep(10); + QHBoxLayout *hBoxLayout = new QHBoxLayout(this); + hBoxLayout->addWidget(m_width); + hBoxLayout->addWidget(new QLabel("x", this)); + hBoxLayout->addWidget(m_height); + hBoxLayout->addWidget(new QLabel("mm", this)); +} + +PrintDialogPanel::PrintDialogPanel(QWidget *parent) + : QWidget(parent) + , m_creationGroupBox(new QGroupBox(tr("Create"), this)) + , m_settingsGroupBox(new QGroupBox(tr("Settings"), this)) + , m_dialogsGroupBox(new QGroupBox(tr("Dialogs"), this)) + , m_pageSizeCombo(new QComboBox) +{ + // Create with resolution + QHBoxLayout *hBoxLayout = new QHBoxLayout(m_creationGroupBox); + m_modeCombo = createCombo(m_creationGroupBox, modeComboData, sizeof(modeComboData)/sizeof(FlagData)); + hBoxLayout->addWidget(m_modeCombo); + m_createButton = new QPushButton(tr("Create"), m_creationGroupBox); + connect(m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter())); + hBoxLayout->addWidget(m_createButton); + m_deleteButton = new QPushButton(tr("Delete"), m_creationGroupBox); + connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter())); + hBoxLayout->addWidget(m_deleteButton); + hBoxLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); + + QFormLayout *formLayout = new QFormLayout(m_settingsGroupBox); + m_pageSizeCombo = createCombo(m_settingsGroupBox, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData)); + connect(m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(enableCustomSizeControl())); + formLayout->addRow(tr("Paper #:"), m_pageSizeCombo); + m_customPageSizeControl = new PageSizeControl; + formLayout->addRow(tr("Custom size:"), m_customPageSizeControl); + m_orientationCombo = createCombo(m_settingsGroupBox, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData)); + formLayout->addRow("Orientation:", m_orientationCombo); + m_fullPageCheckBox = new QCheckBox(tr("Full page"), m_settingsGroupBox); + formLayout->addRow(m_fullPageCheckBox); + + QVBoxLayout *vBoxLayout = new QVBoxLayout(m_dialogsGroupBox); + + m_printDialogOptionsControl = new OptionsControl(tr("Options"), printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData), m_dialogsGroupBox); + vBoxLayout->addWidget(m_printDialogOptionsControl); + m_printDialogRangeCombo = createCombo(m_dialogsGroupBox, printRangeOptions, sizeof(printRangeOptions) / sizeof(FlagData)); + vBoxLayout->addWidget(m_printDialogRangeCombo); + + { + QPrintDialog dialog; + m_printDialogOptionsControl->setValue(dialog.options()); + m_printDialogRangeCombo->setCurrentIndex(dialog.printRange()); + } + + QPushButton *button = new QPushButton(tr("Print..."), m_dialogsGroupBox); + connect(button, SIGNAL(clicked()), this, SLOT(showPrintDialog())); + vBoxLayout->addWidget(button); + button = new QPushButton(tr("Preview..."), m_dialogsGroupBox); + connect(button, SIGNAL(clicked()), this, SLOT(showPreviewDialog())); + vBoxLayout->addWidget(button); + + QGridLayout *gridLayout = new QGridLayout(this); + gridLayout->addWidget(m_creationGroupBox, 0, 0); + gridLayout->addWidget(m_settingsGroupBox, 1, 0); + gridLayout->addWidget(m_dialogsGroupBox, 0, 1, 2, 1); + gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 2, 0, 1, 2); + + enablePanels(); +} + +PrintDialogPanel::~PrintDialogPanel() +{ +} + +void PrintDialogPanel::enablePanels() +{ + const bool exists = !m_printer.isNull(); + m_createButton->setEnabled(!exists); + m_modeCombo->setEnabled(!exists); + m_deleteButton->setEnabled(exists); + m_settingsGroupBox->setEnabled(exists); + m_dialogsGroupBox->setEnabled(exists); +} + +void PrintDialogPanel::createPrinter() +{ + const QPrinter::PrinterMode mode = comboBoxValue(m_modeCombo); + m_printer.reset(new QPrinter(mode)); // Can set only once. + retrieveSettings(m_printer.data()); + enablePanels(); + enableCustomSizeControl(); +} + +void PrintDialogPanel::deletePrinter() +{ + m_printer.reset(); + enablePanels(); +} + +void PrintDialogPanel::applySettings(QPrinter *printer) const +{ + const QPrinter::PageSize pageSize = comboBoxValue(m_pageSizeCombo); + if (pageSize == QPrinter::Custom) + printer->setPaperSize(m_customPageSizeControl->pageSize(), QPrinter::Millimeter); + else + printer->setPageSize(pageSize); + printer->setOrientation(comboBoxValue(m_orientationCombo)); + printer->setFullPage(m_fullPageCheckBox->isChecked()); +} + +void PrintDialogPanel::retrieveSettings(const QPrinter *printer) +{ + setComboBoxValue(m_pageSizeCombo, printer->pageSize()); + setComboBoxValue(m_orientationCombo, printer->orientation()); + m_fullPageCheckBox->setChecked(printer->fullPage()); + m_customPageSizeControl->setPageSize(m_printer->paperSize(QPrinter::Millimeter)); +} + +void PrintDialogPanel::enableCustomSizeControl() +{ + m_customPageSizeControl->setEnabled(m_pageSizeCombo->currentIndex() == QPrinter::Custom); +} + +void PrintDialogPanel::showPrintDialog() +{ + applySettings(m_printer.data()); + QPrintDialog dialog(m_printer.data(), this); + dialog.setOptions(m_printDialogOptionsControl->value()); + dialog.setPrintRange(comboBoxValue(m_printDialogRangeCombo)); + if (dialog.exec() == QDialog::Accepted) + retrieveSettings(m_printer.data()); +} + +void PrintDialogPanel::showPreviewDialog() +{ + applySettings(m_printer.data()); + PrintPreviewDialog dialog(m_printer.data(), this); + dialog.resize(QApplication::desktop()->availableGeometry().size() * 4/ 5); + if (dialog.exec() == QDialog::Accepted) + retrieveSettings(m_printer.data()); +} + +#include "printdialogpanel.moc" + +#endif // !QT_NO_PRINTER diff --git a/tests/manual/dialogs/printdialogpanel.h b/tests/manual/dialogs/printdialogpanel.h new file mode 100644 index 0000000000..4999504a3c --- /dev/null +++ b/tests/manual/dialogs/printdialogpanel.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PRINTDIALOGPANEL_H +#define PRINTDIALOGPANEL_H + +#ifndef QT_NO_PRINTER + +#include + +QT_BEGIN_NAMESPACE +class QPrinter; +class QComboBox; +class QGroupBox; +class QPushButton; +class QCheckBox; +QT_END_NAMESPACE + +class PageSizeControl; +class OptionsControl; + +class PrintDialogPanel : public QWidget +{ + Q_OBJECT +public: + explicit PrintDialogPanel(QWidget *parent = 0); + ~PrintDialogPanel(); + +private slots: + void createPrinter(); + void deletePrinter(); + void showPrintDialog(); + void showPreviewDialog(); + void enableCustomSizeControl(); + +private: + void applySettings(QPrinter *printer) const; + void retrieveSettings(const QPrinter *printer); + void enablePanels(); + + QGroupBox *m_creationGroupBox; + QPushButton *m_createButton; + QPushButton *m_deleteButton; + QGroupBox *m_settingsGroupBox; + QCheckBox *m_fullPageCheckBox; + QGroupBox *m_dialogsGroupBox; + OptionsControl *m_printDialogOptionsControl; + QComboBox *m_printDialogRangeCombo; + QComboBox *m_modeCombo; + QComboBox *m_orientationCombo; + QComboBox *m_pageSizeCombo; + PageSizeControl *m_customPageSizeControl; + QScopedPointer m_printer; +}; + +#endif // !QT_NO_PRINTER +#endif // PRINTDIALOGPANEL_H diff --git a/tests/manual/dialogs/utils.cpp b/tests/manual/dialogs/utils.cpp new file mode 100644 index 0000000000..7e0067c7f3 --- /dev/null +++ b/tests/manual/dialogs/utils.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "utils.h" + +#include +#include + +QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size) +{ + QComboBox *c = new QComboBox(parent); + for (size_t i = 0; i < size; ++i) + c->addItem(QLatin1String(d[i].description), QVariant(d[i].value)); + return c; +} + +void setComboBoxValue(QComboBox *c, int v) +{ + c->setCurrentIndex(c->findData(QVariant(v))); +} + +OptionsControl::OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent) + : QGroupBox(title, parent) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + for (size_t i = 0; i < count; ++i) { + QCheckBox *box = new QCheckBox(QString::fromLatin1(data[i].description)); + m_checkBoxes.push_back(CheckBoxFlagPair(box, data[i].value)); + layout->addWidget(box); + } +} + +void OptionsControl::setValue(int flags) +{ + foreach (const CheckBoxFlagPair &cf, m_checkBoxes) + cf.first->setChecked(cf.second & flags); +} + +int OptionsControl::intValue() const +{ + int result = 0; + foreach (const CheckBoxFlagPair &cf, m_checkBoxes) { + if (cf.first->isChecked()) + result |= cf.second; + } + return result; +} diff --git a/tests/manual/dialogs/utils.h b/tests/manual/dialogs/utils.h new file mode 100644 index 0000000000..634795627f --- /dev/null +++ b/tests/manual/dialogs/utils.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef UTILS_H +#define UTILS_H + +#include +#include +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QCheckBox) + +// Associate enum/flag value with a description. +struct FlagData +{ + const char *description; + int value; +}; + +// Helpers for creating combo boxes representing enumeration values from flag data. +QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size); + +template +Enum comboBoxValue(const QComboBox *c) +{ + return static_cast(c->itemData(c->currentIndex()).toInt()); +} + +void setComboBoxValue(QComboBox *c, int v); + +// A group box with check boxes for option flags. +class OptionsControl : public QGroupBox { +public: + explicit OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent); + + void setValue(int flags); + template + Enum value() const { return static_cast(intValue()); } + +private: + typedef QPair CheckBoxFlagPair; + + int intValue() const; + + QList m_checkBoxes; +}; + +#endif // UTILS_H -- cgit v1.2.3 From 161e8653c342278a4881da952ea723b107df93c0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Nov 2013 09:17:10 +0100 Subject: Disable clear button in read-only QLineEdit. Task-number: QTBUG-34315 Change-Id: I6c318879aee907c080e871a541da4ba5eadd71ed Reviewed-by: Giuseppe D'Angelo --- tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 3000aad9ce..a9f5cb686c 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -4097,6 +4097,9 @@ void tst_QLineEdit::clearButton() QTRY_COMPARE(filterModel->rowCount(), 1); // matches 'ab' QTest::mouseClick(clearButton, Qt::LeftButton, 0, QRect(QPoint(0, 0), clearButton->size()).center()); QTRY_COMPARE(filterModel->rowCount(), 3); + + filterLineEdit->setReadOnly(true); // QTBUG-34315 + QVERIFY(!clearButton->isEnabled()); } void tst_QLineEdit::sideWidgets() -- cgit v1.2.3 From 46a8885ae486e238a39efa5119c2714f328b08e4 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 27 Sep 2013 12:32:28 +0200 Subject: Disallow deep or widely nested entity references. Nested references with a depth of 2 or greater will fail. References that partially expand to greater than 1024 characters will also fail. Change-Id: Id4e49d6f7cf51e3a247efdb4c6c7c9bd9b223f6e Reviewed-by: Richard J. Moore Reviewed-by: Lars Knoll --- .../sax/qxmlsimplereader/tst_qxmlsimplereader.cpp | 58 ++++++++++++++++++++++ .../xmldocs/1-levels-nested-dtd.xml | 12 +++++ .../xmldocs/2-levels-nested-dtd.xml | 13 +++++ .../internal-entity-polynomial-attribute.xml | 13 +++++ 4 files changed, 96 insertions(+) create mode 100644 tests/auto/xml/sax/qxmlsimplereader/xmldocs/1-levels-nested-dtd.xml create mode 100644 tests/auto/xml/sax/qxmlsimplereader/xmldocs/2-levels-nested-dtd.xml create mode 100644 tests/auto/xml/sax/qxmlsimplereader/xmldocs/internal-entity-polynomial-attribute.xml (limited to 'tests') diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp index f09fbff6c4..57d078ba65 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -160,6 +160,7 @@ class tst_QXmlSimpleReader : public QObject void reportNamespace() const; void reportNamespace_data() const; void roundtripWithNamespaces() const; + void dtdRecursionLimit(); private: static QDomDocument fromByteArray(const QString &title, const QByteArray &ba, bool *ok); @@ -755,5 +756,62 @@ void tst_QXmlSimpleReader::roundtripWithNamespaces() const } } +class TestHandler : public QXmlDefaultHandler +{ +public: + TestHandler() : + recursionCount(0) + { + } + + bool internalEntityDecl(const QString &name, const QString &value) + { + ++recursionCount; + return QXmlDefaultHandler::internalEntityDecl(name, value); + } + + int recursionCount; +}; + +void tst_QXmlSimpleReader::dtdRecursionLimit() +{ + QFile file("xmldocs/2-levels-nested-dtd.xml"); + QVERIFY(file.open(QIODevice::ReadOnly)); + QXmlSimpleReader xmlReader; + { + QXmlInputSource *source = new QXmlInputSource(&file); + TestHandler handler; + xmlReader.setDeclHandler(&handler); + xmlReader.setErrorHandler(&handler); + QVERIFY(!xmlReader.parse(source)); + } + + file.close(); + file.setFileName("xmldocs/1-levels-nested-dtd.xml"); + QVERIFY(file.open(QIODevice::ReadOnly)); + { + QXmlInputSource *source = new QXmlInputSource(&file); + TestHandler handler; + xmlReader.setDeclHandler(&handler); + xmlReader.setErrorHandler(&handler); + QVERIFY(!xmlReader.parse(source)); + // The error wasn't because of the recursion limit being reached, + // it was because the document is not valid. + QVERIFY(handler.recursionCount < 2); + } + + file.close(); + file.setFileName("xmldocs/internal-entity-polynomial-attribute.xml"); + QVERIFY(file.open(QIODevice::ReadOnly)); + { + QXmlInputSource *source = new QXmlInputSource(&file); + TestHandler handler; + xmlReader.setDeclHandler(&handler); + xmlReader.setErrorHandler(&handler); + QVERIFY(!xmlReader.parse(source)); + QVERIFY(handler.recursionCount == 1); + } +} + QTEST_MAIN(tst_QXmlSimpleReader) #include "tst_qxmlsimplereader.moc" diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/1-levels-nested-dtd.xml b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/1-levels-nested-dtd.xml new file mode 100644 index 0000000000..0dfc15b165 --- /dev/null +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/1-levels-nested-dtd.xml @@ -0,0 +1,12 @@ + + + + + +]> + \ No newline at end of file diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/2-levels-nested-dtd.xml b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/2-levels-nested-dtd.xml new file mode 100644 index 0000000000..7ec06db85f --- /dev/null +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/2-levels-nested-dtd.xml @@ -0,0 +1,13 @@ + + + + + + +]> + diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/internal-entity-polynomial-attribute.xml b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/internal-entity-polynomial-attribute.xml new file mode 100644 index 0000000000..bbb88f39f6 --- /dev/null +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/internal-entity-polynomial-attribute.xml @@ -0,0 +1,13 @@ + + + + + + + + +]> + + -- cgit v1.2.3 From 73efc9a2cd9839c75eb8bd1449ce23232ac0d306 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 5 Oct 2013 20:01:36 +0200 Subject: Test exceptions in signals and slots Only DirectConnection is tested Change-Id: I525c6a65428489c34e58d1d9600b4e5ebda733b9 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 97 +++++++++++++++++++++++ 1 file changed, 97 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 05d81c2bd1..ece88d47e3 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -151,6 +151,7 @@ private slots: void contextDoesNotLeakFunctor(); void connectBase(); void qmlConnect(); + void exceptions(); }; struct QObjectCreatedOnShutdown @@ -6136,6 +6137,102 @@ void tst_QObject::qmlConnect() #endif } +#ifndef QT_NO_EXCEPTIONS +class ObjectException : public std::exception { }; + +struct ThrowFunctor +{ + CountedStruct operator()(const CountedStruct &, CountedStruct s2) const + { + throw ObjectException(); + return s2; + } + CountedStruct s; +}; +#endif + +class ExceptionThrower : public QObject +{ + Q_OBJECT +public slots: + CountedStruct throwException(const CountedStruct &, CountedStruct s2) + { +#ifndef QT_NO_EXCEPTIONS + throw ObjectException(); +#endif + return s2; + } +signals: + CountedStruct mySignal(const CountedStruct &s1, CountedStruct s2); +}; + +void tst_QObject::exceptions() +{ +#ifndef QT_NO_EXCEPTIONS + ReceiverObject receiver; + + // String based syntax + { + QCOMPARE(countedStructObjectsCount, 0); + ExceptionThrower thrower; + receiver.reset(); + + connect(&thrower, SIGNAL(mySignal(CountedStruct,CountedStruct)), &receiver, SLOT(slot1())); + connect(&thrower, SIGNAL(mySignal(CountedStruct,CountedStruct)), &thrower, SLOT(throwException(CountedStruct,CountedStruct))); + connect(&thrower, SIGNAL(mySignal(CountedStruct,CountedStruct)), &receiver, SLOT(slot2())); + try { + CountedStruct s; + emit thrower.mySignal(s, s); + QFAIL("Exception not thrown?"); + } catch (ObjectException&) {} + QCOMPARE(receiver.count_slot1, 1); + QCOMPARE(receiver.count_slot2, 0); + QCOMPARE(countedStructObjectsCount, 0); + } + // Pointer to member function + { + QCOMPARE(countedStructObjectsCount, 0); + ExceptionThrower thrower; + receiver.reset(); + + connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot1); + connect(&thrower, &ExceptionThrower::mySignal, &thrower, &ExceptionThrower::throwException); + connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot2); + try { + CountedStruct s; + emit thrower.mySignal(s, s); + QFAIL("Exception not thrown?"); + } catch (ObjectException&) {} + QCOMPARE(receiver.count_slot1, 1); + QCOMPARE(receiver.count_slot2, 0); + QCOMPARE(countedStructObjectsCount, 0); + } + // Functor + { + QCOMPARE(countedStructObjectsCount, 0); + ExceptionThrower thrower; + receiver.reset(); + + connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot1); + connect(&thrower, &ExceptionThrower::mySignal, ThrowFunctor()); + connect(&thrower, &ExceptionThrower::mySignal, &receiver, &ReceiverObject::slot2); + try { + CountedStruct s; + emit thrower.mySignal(s, s); + QFAIL("Exception not thrown?"); + } catch (ObjectException&) {} + QCOMPARE(receiver.count_slot1, 1); + QCOMPARE(receiver.count_slot2, 0); + QCOMPARE(countedStructObjectsCount, 1); // the Functor + } + QCOMPARE(countedStructObjectsCount, 0); + + +#else + QSKIP("Needs exceptions"); +#endif +} + // Test for QtPrivate::HasQ_OBJECT_Macro Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro::Value); Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro::Value); -- cgit v1.2.3 From 94ad841ab547e98da111ac41f235cb94cf2d0a45 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 5 Oct 2013 20:24:14 +0200 Subject: Test that QMetaObject::invokeMethod is exception safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie4662b7e475dc3d1ce9f36e8219361d9507622b4 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz Reviewed-by: Jędrzej Nowacki --- .../corelib/kernel/qmetaobject/tst_qmetaobject.cpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 870e65f0cc..3afc2bc574 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -155,6 +155,7 @@ private slots: void invokeCustomTypes(); void invokeMetaConstructor(); void invokeTypedefTypes(); + void invokeException(); void qtMetaObjectInheritance(); void normalizedSignature_data(); void normalizedSignature(); @@ -301,6 +302,19 @@ void tst_QMetaObject::connectSlotsByName() struct MyUnregisteredType { }; +static int countedStructObjectsCount = 0; +struct CountedStruct +{ + CountedStruct() { ++countedStructObjectsCount; } + CountedStruct(const CountedStruct &) { ++countedStructObjectsCount; } + CountedStruct &operator=(const CountedStruct &) { return *this; } + ~CountedStruct() { --countedStructObjectsCount; } +}; + +#ifndef QT_NO_EXCEPTIONS +class ObjectException : public std::exception { }; +#endif + class QtTestObject: public QObject { friend class tst_QMetaObject; @@ -340,6 +354,13 @@ public slots: void slotWithUnregisteredParameterType(MyUnregisteredType); + CountedStruct throwingSlot(const CountedStruct &, CountedStruct s2) { +#ifndef QT_NO_EXCEPTIONS + throw ObjectException(); +#endif + return s2; + } + signals: void sig0(); QString sig1(QString s1); @@ -847,6 +868,23 @@ void tst_QMetaObject::invokeTypedefTypes() QCOMPARE(spy.at(0).at(0), QVariant(arg)); } +void tst_QMetaObject::invokeException() +{ +#ifndef QT_NO_EXCEPTIONS + QtTestObject obj; + QCOMPARE(countedStructObjectsCount, 0); + try { + CountedStruct s; + QVERIFY(QMetaObject::invokeMethod(&obj, "throwingSlot", Q_RETURN_ARG(CountedStruct, s), + Q_ARG(CountedStruct, s), Q_ARG(CountedStruct, s))); + QFAIL("Did not throw"); + } catch(ObjectException &) {} + QCOMPARE(countedStructObjectsCount, 0); +#else + QSKIP("Needs exceptions"); +#endif +} + void tst_QMetaObject::normalizedSignature_data() { QTest::addColumn("signature"); -- cgit v1.2.3 From ec12d641faaab2758bc2a31f1c106bc8bdf84466 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 4 Nov 2013 17:40:01 +0100 Subject: tst_qurl: add test for matches() with empty vs null case Change-Id: I0f31eed9af0a7f1aed9ce5118b49ddbbff4f5f39 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 2128d68485..12b9159bf2 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -378,6 +378,14 @@ void tst_QUrl::comparison() QVERIFY(!passUrl1.matches(passUrl2, QUrl::None)); QVERIFY(passUrl1.matches(passUrl2, QUrl::RemovePassword)); + // RemovePassword, null vs empty + QUrl emptyPassUrl1("http://user:@host/"); + QUrl emptyPassUrl2("http://user@host/"); + QVERIFY(!(emptyPassUrl1 == emptyPassUrl2)); + QVERIFY(emptyPassUrl1 != emptyPassUrl2); + QVERIFY(!emptyPassUrl1.matches(emptyPassUrl2, QUrl::None)); + QVERIFY(emptyPassUrl1.matches(emptyPassUrl2, QUrl::RemovePassword)); + // RemoveQuery, RemoveFragment QUrl queryFragUrl1("http://host/file?query#fragment"); QUrl queryFragUrl2("http://host/file?q2#f2"); -- cgit v1.2.3 From 44d48862c0ff4b67a76734deae5e76f926a77bce Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 31 Oct 2013 18:17:44 +0100 Subject: QStandardPaths: add GenericConfigLocation This is what ConfigLocation was meant to be. A directory shared by all applications. Unfortunately when I wrote the fallback on Windows, I picked DataLocation (which is app-specific) instead of GenericDataLocation (which is shared between apps). This makes it impossible to have config files shared between apps, e.g. for libraries. It also makes ConfigLocation quite inconsistent (on Windows one cannot use it to load another app's config file, while it works everywhere else). All this is fixed by GenericConfigLocation, which is shared between apps. Change-Id: I23a755131061d4fea01e13dd1038fbd8ef333a5d Reviewed-by: Alex Richardson Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 9ac1526f07..35a59401b7 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -56,7 +56,7 @@ #define Q_XDG_PLATFORM #endif -const int MaxStandardLocation = QStandardPaths::GenericCacheLocation; +static const int MaxStandardLocation = QStandardPaths::GenericConfigLocation; class tst_qstandardpaths : public QObject { @@ -127,7 +127,8 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths "RuntimeLocation", "ConfigLocation", "DownloadLocation", - "GenericCacheLocation" + "GenericCacheLocation", + "GenericConfigLocation" }; void tst_qstandardpaths::dump() @@ -151,9 +152,11 @@ void tst_qstandardpaths::testDefaultLocations() const QString expectedConfHome = QDir::homePath() + QString::fromLatin1("/.config"); QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), expectedConfHome); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), expectedConfHome); const QStringList confDirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation); QCOMPARE(confDirs.count(), 2); QVERIFY(confDirs.contains(expectedConfHome)); + QCOMPARE(QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation), confDirs); const QStringList genericDataDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); QCOMPARE(genericDataDirs.count(), 3); @@ -178,6 +181,7 @@ void tst_qstandardpaths::testCustomLocations() // test writableLocation() QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), m_localConfigDir); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), m_localConfigDir); // test locate() const QString thisFileName = QString::fromLatin1("aFile"); @@ -212,6 +216,7 @@ void tst_qstandardpaths::enableTestMode() // ConfigLocation const QString configDir = qttestDir + QLatin1String("/config"); QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation), configDir); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation), configDir); const QStringList confDirs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation); QCOMPARE(confDirs, QStringList() << configDir << m_globalConfigDir); @@ -235,6 +240,7 @@ void tst_qstandardpaths::enableTestMode() testLocations.insert(QStandardPaths::DataLocation, QStandardPaths::writableLocation(QStandardPaths::DataLocation)); testLocations.insert(QStandardPaths::GenericDataLocation, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); testLocations.insert(QStandardPaths::ConfigLocation, QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); + testLocations.insert(QStandardPaths::GenericConfigLocation, QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); testLocations.insert(QStandardPaths::CacheLocation, QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); testLocations.insert(QStandardPaths::GenericCacheLocation, QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); // On Windows, what should "Program Files" become, in test mode? -- cgit v1.2.3 From 0cdf2a8023473e03121fc99194182a3fb86dd6aa Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 5 Nov 2013 20:18:49 +0100 Subject: Revert "Ensure CSS rules are inherited from the parent tags" Since the original change caused a problem with the CSS rules being always inherited where in some cases this should not be happening. This reverts commit 6f6546613774a48fe12f13f796ed7115dfe49a27. Change-Id: I6e9cf163d752b1869b5e967a7ab59963d655ba87 Reviewed-by: Simon Hausmann --- .../gui/text/qtextdocument/tst_qtextdocument.cpp | 31 ---------------------- 1 file changed, 31 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index b065f537f7..d5ddf8fbec 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -187,8 +187,6 @@ private slots: void htmlExportImportBlockCount(); void QTBUG27354_spaceAndSoftSpace(); - void cssInheritance(); - void QTBUG28998_linkColor(); private: @@ -2949,35 +2947,6 @@ void tst_QTextDocument::QTBUG27354_spaceAndSoftSpace() } } -void tst_QTextDocument::cssInheritance() -{ - { - QTextDocument td; - td.setHtml("" - "

Foo

Bar

Baz

"); - QTextBlock block = td.begin(); - while (block.isValid()) { - QTextBlockFormat fmt = block.blockFormat(); - QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight); - QVERIFY(fmt.lineHeight() == 200); - block = block.next(); - } - } - { - QTextDocument td; - td.setHtml("" - "

Foo

Bar

Baz

"); - QTextBlock block = td.begin(); - QTextBlockFormat fmt = block.blockFormat(); - QVERIFY(fmt.lineHeightType() == QTextBlockFormat::FixedHeight); - QVERIFY(fmt.lineHeight() == 40); - block = block.next(); - fmt = block.blockFormat(); - QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight); - QVERIFY(fmt.lineHeight() == 300); - } -} - void tst_QTextDocument::QTBUG28998_linkColor() { QPalette pal; -- cgit v1.2.3 From 569dec8e78030689740b2ff99c071862aa9abaaa Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Nov 2013 22:14:35 +0100 Subject: QIntegerForSize: add test Make sure that the size of QIntegerForSize::{Signed,Unsigned} is actually N. Change-Id: I221304f7c420e80758ef7b115bafb7cf1f8c8829 Reviewed-by: Olivier Goffart Reviewed-by: Giuseppe D'Angelo --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 4a50a45ea6..0d08e912f8 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -59,6 +59,7 @@ private slots: void qCoreAppStartupFunctionRestart(); void isEnum(); void qAlignOf(); + void integerForSize(); }; void tst_QGlobal::qIsNull() @@ -566,5 +567,19 @@ void tst_QGlobal::qAlignOf() #undef TEST_AlignOf_RValueRef #undef TEST_AlignOf_impl +void tst_QGlobal::integerForSize() +{ + // compile-only test: + Q_STATIC_ASSERT(sizeof(QIntegerForSize<1>::Signed) == 1); + Q_STATIC_ASSERT(sizeof(QIntegerForSize<2>::Signed) == 2); + Q_STATIC_ASSERT(sizeof(QIntegerForSize<4>::Signed) == 4); + Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Signed) == 8); + + Q_STATIC_ASSERT(sizeof(QIntegerForSize<1>::Unsigned) == 1); + Q_STATIC_ASSERT(sizeof(QIntegerForSize<2>::Unsigned) == 2); + Q_STATIC_ASSERT(sizeof(QIntegerForSize<4>::Unsigned) == 4); + Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Unsigned) == 8); +} + QTEST_APPLESS_MAIN(tst_QGlobal) #include "tst_qglobal.moc" -- cgit v1.2.3 From 8ef5e700b8471b865328472b52a790686507bb45 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 2 Nov 2013 17:31:12 +0100 Subject: QMetaType: Fix conversion between module types. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7215b4599c3f0459139b32b6571f0a9e60182ee9 Reviewed-by: Jędrzej Nowacki --- .../auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 4b2cce63e5..42570751fc 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -118,6 +118,7 @@ private slots: void colorInteger(); void invalidQColor(); + void validQColor(); void debugStream_data(); void debugStream(); @@ -540,6 +541,21 @@ void tst_QGuiVariant::invalidQColor() QVERIFY(!qvariant_cast(va).isValid()); } +void tst_QGuiVariant::validQColor() +{ + QColor col(Qt::red); + QVariant va(col.name()); + QVERIFY(va.canConvert(QVariant::Color)); + + QVERIFY(va.convert(QVariant::Color)); + + QVERIFY(col.isValid()); + + QVERIFY(va.convert(QVariant::String)); + + QCOMPARE(qvariant_cast(va), col.name()); +} + void tst_QGuiVariant::colorInteger() { QVariant v = QColor(Qt::red); -- cgit v1.2.3 From ecfbb4e441ec7870c96de664189c373f3e527e72 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 18 Sep 2013 18:43:32 +0200 Subject: tst_QFlags: make constExpr() check compile on clang trunk The problem is the verifyConstExpr<>() line involving the ~ operator. The result as an integer is a value that can no longer be represented in an int. This is known at compile time and thus template deduction, which only has an int to match against, fails. To fix, use an unsigned int as the first template argument of verifyConstExpr<>(). Clang's error message for this is really sub-optimal, cf. http://llvm.org/bugs/show_bug.cgi?id=17834 Change-Id: I3a77dc54d2bee12b016d75724ac1bd7801f4cf2d Reviewed-by: Olivier Goffart --- tests/auto/corelib/global/qflags/tst_qflags.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index e50a6b63fe..73a69a1309 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -99,7 +99,7 @@ void tst_QFlags::testFlagMultiBits() const } } -template bool verifyConstExpr(T n) { return n == N; } +template bool verifyConstExpr(T n) { return n == N; } void tst_QFlags::constExpr() { -- cgit v1.2.3 From 79b975756a100cc46182c2949e71a683a656bd12 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 4 Nov 2013 16:12:32 +0100 Subject: Revert "Add tracing to logging framework" The tracing API still misses some real-world exposure. Let's re-do this in dev to have more time. This reverts parts of following commits: 466e0dff4bb686e51d0ab3f905631fcb7dd8bfef 7a47aebe9ed41d6cd9c9bcd45758d4d553668e99 a652bab6a7ebf78b029fea95c2801deb6f4f524a 8f0654ceb878b6c8a08c7f5b790027c26e007c13 4162522edd9d31bd2798ab37f083adff818d886e 32f27b4367c4e042a3f0cda671579494e31c1d69 9ff81bdc1ab4e3d14914192cd63ae625a507fe90 Change-Id: If97340c37b8b3363f597683336a8390d5ff386f1 Reviewed-by: hjk Reviewed-by: Robin Burchell --- tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index a49793c3d4..50268f20a4 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -69,7 +69,6 @@ QByteArray qMyMessageFormatString(QtMsgType type, const QMessageLogContext &cont case QtWarningMsg: message.append(".warning"); break; case QtCriticalMsg:message.append(".critical"); break; case QtFatalMsg: message.append(".fatal"); break; - case QtTraceMsg: message.append(".trace"); break; } message.append(": "); message.append(qPrintable(str)); -- cgit v1.2.3 From dd262dc7f5c02ffaaa965815a9ccc8978efdbabf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 8 Nov 2013 11:27:15 +0100 Subject: Revert "Fix setVisible() of QWidget has no effect in QTreeWidgetItem" It introduces QTBUG-34653 (Qt Designer widget box no longer repainted after collapsing items or using the filter). This reverts commit 04de24c6449422d29a0d4760375aa94f59222fa3. Task-number: QTBUG-13522 Task-number: QTBUG-34653 Change-Id: Ieb9766e7f15acea901fce4ad7142aa72557b9957 Reviewed-by: Giuseppe D'Angelo --- .../itemviews/qtreewidget/tst_qtreewidget.cpp | 34 ---------------------- 1 file changed, 34 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 1de5749c69..83ba1ddcda 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -165,7 +165,6 @@ private slots: void setChildIndicatorPolicy(); void task20345_sortChildren(); - void taskQTBUG13522_checkItemVisibilityBeforeItemShow(); public slots: void itemSelectionChanged(); @@ -3372,39 +3371,6 @@ void tst_QTreeWidget::task20345_sortChildren() QVERIFY(1); } -void tst_QTreeWidget::taskQTBUG13522_checkItemVisibilityBeforeItemShow() -{ - class TreeView : public QTreeWidget - { - public: - explicit TreeView(QWidget *parent = 0) : QTreeWidget(parent) - , item1_visibility(false), item2_visibility(false) {} - void showEvent(QShowEvent * /*event*/) Q_DECL_OVERRIDE - { - item1_visibility = !item1->isVisible(); - item2_visibility = item2->isVisible(); - } - QWidget *item1; - QWidget *item2; - bool item1_visibility; - bool item2_visibility; - - } tw; - tw.item1 = new QWidget(&tw); - tw.item2 = new QWidget(&tw); - QTreeWidgetItem *widget_item = new QTreeWidgetItem(); - widget_item->setText(0, "example text"); - tw.addTopLevelItem(widget_item); - tw.setItemWidget(widget_item, 0, tw.item1); - widget_item = new QTreeWidgetItem(); - tw.setItemWidget(widget_item, 0, tw.item2); - //set visible must after setItemWidget or setItemWidget will reset the visibility - tw.item1->setVisible(false); - tw.item2->setVisible(true); - tw.show(); - QTRY_VERIFY(tw.item1_visibility); - QTRY_VERIFY(tw.item2_visibility); -} QTEST_MAIN(tst_QTreeWidget) #include "tst_qtreewidget.moc" -- cgit v1.2.3 From 2ee97f505b29a8539685885a239477d4417cc76a Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 3 Nov 2013 13:59:36 +0100 Subject: Fix QVariant::canConvert with longlong MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add few cases where conversion to or from LongLong was missing We need to make it work if we want to use variant.canConvert [ChangeLog][QtCore][QVariant] Fixed QVariant::canConvert with longlong Change-Id: I0f65073802b62d99250601dd90a8cd2e4d934b60 Reviewed-by: Jędrzej Nowacki --- .../auto/corelib/kernel/qvariant/tst_qvariant.cpp | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 422bd63163..a696b0ee1e 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -888,6 +888,17 @@ void tst_QVariant::toLongLong_data() bytearray[3] = '0'; QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qlonglong) 3200 << true; QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qlonglong)321 << true; + + qint64 value64 = (Q_INT64_C(12) << 35) + 8; + QTest::newRow("qint64") << QVariant::fromValue(value64) << qlonglong(value64) << true; + QTest::newRow("-qint64") << QVariant::fromValue(-value64) << qlonglong(-value64) << true; + QTest::newRow("long") << QVariant::fromValue(long(464646)) << qlonglong(464646) << true; + QTest::newRow("LONG_MAX") << QVariant::fromValue( LONG_MAX ) << qlonglong(LONG_MAX) << true; + QTest::newRow("LONG_MIN") << QVariant::fromValue( LONG_MIN ) << qlonglong(LONG_MIN) << true; + + QTest::newRow( "short" ) << QVariant(short(12)) << qlonglong(12) << true; + QTest::newRow( "-short" ) << QVariant(short(-24)) << qlonglong(-24) << true; + QTest::newRow( "ushort" ) << QVariant(ushort(15)) << qlonglong(15) << true; } void tst_QVariant::toLongLong() @@ -933,6 +944,15 @@ void tst_QVariant::toULongLong_data() bytearray[3] = '1'; QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qulonglong) 3201 << true; QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qulonglong)321 << true; + + quint64 value64 = (Q_INT64_C(12) << 35) + 8; + QTest::newRow("qint64") << QVariant::fromValue(value64) << qulonglong(value64) << true; + QTest::newRow("long") << QVariant::fromValue(long(464646)) << qulonglong(464646) << true; + QTest::newRow("LONG_MAX") << QVariant::fromValue( LONG_MAX ) << qulonglong(LONG_MAX) << true; + QTest::newRow("ULONG_MAX") << QVariant::fromValue( ULONG_MAX ) << qulonglong(ULONG_MAX) << true; + QTest::newRow( "short" ) << QVariant(short(12)) << qulonglong(12) << true; + QTest::newRow( "-short" ) << QVariant(short(-24)) << qulonglong(-24) << true; + QTest::newRow( "ushort" ) << QVariant(ushort(15)) << qulonglong(15) << true; } void tst_QVariant::toULongLong() @@ -2895,24 +2915,27 @@ void tst_QVariant::numericalConvert() QVariant vuint(uint(5)); QVariant vshort(short(5)); QVariant vlonglong(quint64(5)); + QVariant vlong = QVariant::fromValue(long(5)); QVariant vstringint(QString::fromLatin1("5")); QVariant vstring(QString::fromLatin1("5.3")); QVector vect; - vect << &vfloat << &vdouble << &vreal << &vint << &vuint << &vshort<< &vlonglong << &vstringint << &vstring; + vect << &vfloat << &vdouble << &vreal << &vint << &vuint << &vshort<< &vlonglong << &vlong << &vstringint << &vstring; for(int i = 0; i < vect.size(); i++) { double num = 5.3; - if (i >= 3 && i <= 7) + if (i >= 3 && i <= 8) num = 5; QVariant *v = vect.at(i); QCOMPARE(v->toFloat() , float(num)); QCOMPARE(float(v->toReal()) , float(num)); QCOMPARE(float(v->toDouble()) , float(num)); - if(i != 8) { + if (i != 9) { QCOMPARE(v->toInt() , int(num)); QCOMPARE(v->toUInt() , uint(num)); QCOMPARE(v->toULongLong() , quint64(num)); + QCOMPARE(v->value() , ulong(num)); + QCOMPARE(v->value() , ushort(num)); } QCOMPARE(v->toString() , QString::number(num)); } -- cgit v1.2.3 From 34d21610ba72ea775d47619c08086f8bb0e7160b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 3 Nov 2013 14:17:15 +0100 Subject: QVariant: Convert automatically from enum types to integral types. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][QtCore][QVariant] Variant containing enum types can now be converted to integer Change-Id: Ibbbc9ae29ab45d67c582fa2d406afc19c5dc41ce Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- .../auto/corelib/kernel/qvariant/tst_qvariant.cpp | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index a696b0ee1e..aef79e0c2f 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -247,6 +247,8 @@ private slots: void iterateContainerElements(); void pairElements(); + + void enums(); private: void dataStream_data(QDataStream::Version version); void loadQVariantFromDataStream(QDataStream::Version version); @@ -3953,5 +3955,87 @@ void tst_QVariant::pairElements() TEST_PAIR_ELEMENT_ACCESS(std::pair, int, QVariant, 44, 15) } +enum EnumTest_Enum0 { EnumTest_Enum0_value = 42, ensureSignedEnum0 = -1 }; +Q_DECLARE_METATYPE(EnumTest_Enum0) +enum EnumTest_Enum1 { EnumTest_Enum1_value = 42, EnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 }; +Q_DECLARE_METATYPE(EnumTest_Enum1) + +#if defined(Q_COMPILER_CLASS_ENUM) +enum EnumTest_Enum3 : qint64 { EnumTest_Enum3_value = -47, EnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5 }; +Q_DECLARE_METATYPE(EnumTest_Enum3) +enum EnumTest_Enum4 : quint64 { EnumTest_Enum4_value = 47, EnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; +Q_DECLARE_METATYPE(EnumTest_Enum4) +enum EnumTest_Enum5 : uint { EnumTest_Enum5_value = 47 }; +Q_DECLARE_METATYPE(EnumTest_Enum5) +enum EnumTest_Enum6 : uchar { EnumTest_Enum6_value = 47 }; +Q_DECLARE_METATYPE(EnumTest_Enum6) +enum class EnumTest_Enum7 { EnumTest_Enum7_value = 47, ensureSignedEnum7 = -1 }; +Q_DECLARE_METATYPE(EnumTest_Enum7) +enum EnumTest_Enum8 : short { EnumTest_Enum8_value = 47 }; +Q_DECLARE_METATYPE(EnumTest_Enum8) +#endif + +template void testVariant(Enum value, bool *ok) +{ + *ok = false; + QVariant var = QVariant::fromValue(value); + + QCOMPARE(var.userType(), qMetaTypeId()); + + QVERIFY(var.canConvert()); + QVERIFY(var.canConvert()); + QVERIFY(var.canConvert()); + QVERIFY(var.canConvert()); + QVERIFY(var.canConvert()); + QVERIFY(var.canConvert()); + QVERIFY(var.canConvert()); + + + QCOMPARE(var.value(), value); + QCOMPARE(var.value(), static_cast(value)); + QCOMPARE(var.value(), static_cast(value)); + QCOMPARE(var.value(), static_cast(value)); + QCOMPARE(var.value(), static_cast(value)); + QCOMPARE(var.value(), static_cast(value)); + QCOMPARE(var.value(), static_cast(value)); + + QVariant var2 = var; + QVERIFY(var2.convert(QMetaType::Int)); + QCOMPARE(var2.value(), static_cast(value)); + + *ok = true; +} + +void tst_QVariant::enums() +{ + bool ok = false; + testVariant(EnumTest_Enum0_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum1_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum1_bigValue, &ok); + QVERIFY(ok); +#if defined(Q_COMPILER_CLASS_ENUM) + testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum3::EnumTest_Enum3_bigValue, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum4::EnumTest_Enum4_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum4::EnumTest_Enum4_bigValue, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum5::EnumTest_Enum5_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum6::EnumTest_Enum6_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum7::EnumTest_Enum7_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum8::EnumTest_Enum8_value, &ok); + QVERIFY(ok); + testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok); + QVERIFY(ok); +#endif +} + QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" -- cgit v1.2.3 From becdfa6fabb80d35e430a13835f01a6ff3f6cc73 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 6 Nov 2013 22:44:38 +0100 Subject: QSslConfiguration: rename [get]session() to [get]sessionTicket() to reflect the fact that this returns and sets the whole session ticket, and not just the session ID. Change-Id: I00fe2bc4197dbcd7a02b3ae4f2f84e3a2a7edad0 Reviewed-by: Richard J. Moore --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 2826c497df..1837e8d665 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -6042,7 +6042,7 @@ void tst_QNetworkReply::sslSessionSharingFromPersistentSession() QTestEventLoop::instance().enterLoop(20); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(warmupReply->error(), QNetworkReply::NoError); - QByteArray sslSession = warmupReply->sslConfiguration().session(); + QByteArray sslSession = warmupReply->sslConfiguration().sessionTicket(); QCOMPARE(!sslSession.isEmpty(), sessionPersistenceEnabled); // test server sends a life time hint of 0 (old server) or 300 (new server), @@ -6060,7 +6060,7 @@ void tst_QNetworkReply::sslSessionSharingFromPersistentSession() QNetworkRequest request(warmupRequest); if (sessionPersistenceEnabled) { QSslConfiguration configuration = request.sslConfiguration(); - configuration.setSession(sslSession); + configuration.setSessionTicket(sslSession); request.setSslConfiguration(configuration); } QNetworkAccessManager newManager; -- cgit v1.2.3 From 5f5c8798329041db7c02d2cd0610bfe4f3b22c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Martsum?= Date: Thu, 7 Nov 2013 18:58:15 +0100 Subject: QHeaderView - remove confusing bool It is probably better not to have a default boolean in QHeaderView::setResizeContentsPrecision Task-number: QTBUG-34665 Change-Id: I0bb2c35abc1d5713bb3ee65df3af86c04f175a38 Reviewed-by: Giuseppe D'Angelo --- .../widgets/itemviews/autoResizePrecision/tablehorz/testtable1.cpp | 3 ++- .../widgets/itemviews/autoResizePrecision/tablevert/testtable2.cpp | 3 ++- .../widgets/itemviews/autoResizePrecision/treeview/testtree.cpp | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/manual/widgets/itemviews/autoResizePrecision/tablehorz/testtable1.cpp b/tests/manual/widgets/itemviews/autoResizePrecision/tablehorz/testtable1.cpp index 463366433c..f4ecae83fe 100644 --- a/tests/manual/widgets/itemviews/autoResizePrecision/tablehorz/testtable1.cpp +++ b/tests/manual/widgets/itemviews/autoResizePrecision/tablehorz/testtable1.cpp @@ -100,7 +100,8 @@ protected: void TableDialog::slotValueChanged(int newval) { - tableView->horizontalHeader()->setResizeContentsPrecision(newval, true); + tableView->horizontalHeader()->setResizeContentsPrecision(newval); + tableView->resizeColumnsToContents(); } diff --git a/tests/manual/widgets/itemviews/autoResizePrecision/tablevert/testtable2.cpp b/tests/manual/widgets/itemviews/autoResizePrecision/tablevert/testtable2.cpp index 027801d528..b64a4325f9 100644 --- a/tests/manual/widgets/itemviews/autoResizePrecision/tablevert/testtable2.cpp +++ b/tests/manual/widgets/itemviews/autoResizePrecision/tablevert/testtable2.cpp @@ -110,7 +110,8 @@ protected: void TableDialog::slotValueChanged(int newval) { - tableView->verticalHeader()->setResizeContentsPrecision(newval, true); + tableView->verticalHeader()->setResizeContentsPrecision(newval); + tableView->resizeRowsToContents(); } diff --git a/tests/manual/widgets/itemviews/autoResizePrecision/treeview/testtree.cpp b/tests/manual/widgets/itemviews/autoResizePrecision/treeview/testtree.cpp index c48d933fcd..d9984ca8ea 100644 --- a/tests/manual/widgets/itemviews/autoResizePrecision/treeview/testtree.cpp +++ b/tests/manual/widgets/itemviews/autoResizePrecision/treeview/testtree.cpp @@ -118,7 +118,9 @@ protected: void TreeDialog::slotValueChanged(int newval) { - treeWidget->header()->setResizeContentsPrecision(newval, true); + treeWidget->header()->setResizeContentsPrecision(newval); + for (int u = 0; u < treeWidget->header()->count(); ++u) + treeWidget->resizeColumnToContents(u); } int main(int argc, char *argv[]) -- cgit v1.2.3 From ee53530a0e7a60828d74cf29a42bacb2828c9ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo=20F=C3=A4lt?= Date: Thu, 7 Nov 2013 14:11:22 +0200 Subject: Mark tst_qgl as insignificant in angle build All ci nodes are currently missing 3d support, when that is enabled this test will start to fail. Task-number: QTQAINFRA-711 Change-Id: Ie6b840e290a9371fa895681e58d6dedf55b777e6 Reviewed-by: Gunnar Sletta --- tests/auto/opengl/qgl/qgl.pro | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/opengl/qgl/qgl.pro b/tests/auto/opengl/qgl/qgl.pro index 311e41a624..35b5c6888b 100644 --- a/tests/auto/opengl/qgl/qgl.pro +++ b/tests/auto/opengl/qgl/qgl.pro @@ -12,3 +12,4 @@ RESOURCES = qgl.qrc linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = lucid ]"): CONFIG+=insignificant_test # QTBUG-25293 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +win32-msvc2010:contains(QT_CONFIG, angle):CONFIG += insignificant_test # QTQAINFRA-711 -- cgit v1.2.3 From 105da329a34a59eb46eea5ee9ed46bd20e83dc58 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 14 Nov 2013 08:59:30 +0100 Subject: Skip tst_QGraphicsItem::ensureUpdateOnTextItem() on OSX 10.7 Change-Id: Iedb8ed3ac797d11c47f08b92507401e2e1e96c14 Reviewed-by: Iikka Eklund --- tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index b45ce88c83..6c26ddb293 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6458,6 +6458,12 @@ public: void tst_QGraphicsItem::ensureUpdateOnTextItem() { +#ifdef Q_OS_MAC + if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_7) { + QSKIP("This test is unstable on 10.7 in CI"); + } +#endif + QGraphicsScene scene; QGraphicsView view(&scene); view.show(); -- cgit v1.2.3 From f1053d94f59f053ce4acad9320df14f1fbe4faac Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 11 Nov 2013 14:27:40 +0100 Subject: Fully expand entities to ensure deep or widely nested ones fail parsing With 46a8885ae486e238a39efa5119c2714f328b08e4, we failed when parsing entities whose partially expanded size was greater than 1024 characters. That was not enough, so now we fully expand all entities. Amends 46a8885ae486e238a39efa5119c2714f328b08e4. Change-Id: Ie80720d7e04d825eb4eebf528140eb94806c02b1 Reviewed-by: Richard J. Moore Reviewed-by: Lars Knoll --- tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp index 57d078ba65..ed909946e6 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -809,7 +809,7 @@ void tst_QXmlSimpleReader::dtdRecursionLimit() xmlReader.setDeclHandler(&handler); xmlReader.setErrorHandler(&handler); QVERIFY(!xmlReader.parse(source)); - QVERIFY(handler.recursionCount == 1); + QCOMPARE(handler.recursionCount, 2); } } -- cgit v1.2.3 From 4d1ece8b44b27294cdf77c685aa3d34882cdef95 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 9 Nov 2013 17:41:26 +0100 Subject: QKeySequenceEdit: simplify clear() As the test case shows, clear() is semantically equivalent to setKeySequence(QKeySequence()), so implement it that way. Change-Id: Id68edbbf85aac3bcff82c81310c38274ed8e6708 Reviewed-by: J-P Nurmi Reviewed-by: Friedemann Kleint --- .../qkeysequenceedit/tst_qkeysequenceedit.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp index 8c010abfe6..1434d98e59 100644 --- a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp +++ b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp @@ -43,6 +43,8 @@ #include #include +#include +#include Q_DECLARE_METATYPE(Qt::Key) Q_DECLARE_METATYPE(Qt::KeyboardModifiers) @@ -55,6 +57,7 @@ private slots: void testSetters(); void testKeys_data(); void testKeys(); + void testLineEditContents(); }; void tst_QKeySequenceEdit::testSetters() @@ -100,5 +103,26 @@ void tst_QKeySequenceEdit::testKeys() QTRY_COMPARE(spy.count(), 1); } +void tst_QKeySequenceEdit::testLineEditContents() +{ + QKeySequenceEdit edit; + QLineEdit *le = edit.findChild(); + QVERIFY(le); + + QCOMPARE(le->text(), QString()); + + edit.setKeySequence(QKeySequence::New); + QCOMPARE(edit.keySequence(), QKeySequence(QKeySequence::New)); + + edit.clear(); + QCOMPARE(le->text(), QString()); + + edit.setKeySequence(QKeySequence::New); + QVERIFY(le->text() != QString()); + + edit.setKeySequence(QKeySequence()); + QCOMPARE(le->text(), QString()); +} + QTEST_MAIN(tst_QKeySequenceEdit) #include "tst_qkeysequenceedit.moc" -- cgit v1.2.3 From 3396ba5612c1047d1b21a90c4996dff848c00114 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 13 Sep 2013 23:20:38 +0200 Subject: Match up the specified paper size to an existing one if possible When EnumForms was used then the dmPaperSize was not always correct for the custom paper sizes available on some printers. By using DeviceCapabilities we can be sure that the information is correct in this respect. This also fixes respecting of the custom paper size if one is given and there is no corresponding existing paper size for it. Task-number: QTBUG-34276 Change-Id: I9924d5be8527027fc434261e37f6c7aae66210c3 Reviewed-by: Friedemann Kleint --- .../printsupport/kernel/qprinter/tst_qprinter.cpp | 79 +++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 7251cca528..644cd33e5c 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -113,6 +113,8 @@ private slots: void testCustomPageSizes(); void customPaperSizeAndMargins_data(); void customPaperSizeAndMargins(); + void customPaperNameSettingBySize(); + void customPaperNameSettingByName(); #if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) void printDialogCompleter(); #endif @@ -967,6 +969,13 @@ void tst_QPrinter::errorReporting() painter.end(); } +static QByteArray msgSizeMismatch(const QSizeF &actual, const QSizeF &expected) +{ + QString result; + QDebug(&result) << "Paper size mismatch" << actual << "!=" << expected; + return result.toLocal8Bit(); +} + void tst_QPrinter::testCustomPageSizes() { QPrinter p; @@ -975,12 +984,16 @@ void tst_QPrinter::testCustomPageSizes() p.setPaperSize(customSize, QPrinter::Inch); QSizeF paperSize = p.paperSize(QPrinter::Inch); - QCOMPARE(paperSize, customSize); + // Due to the different calculations, the sizes may be off by a fraction so we have to check it manually + // instead of relying on QSizeF comparison + QVERIFY2(sqrt(pow(paperSize.width() - customSize.width(), 2.0) + pow(paperSize.height() - customSize.height(), 2.0)) < 0.01, + msgSizeMismatch(paperSize, customSize)); QPrinter p2(QPrinter::HighResolution); p2.setPaperSize(customSize, QPrinter::Inch); paperSize = p.paperSize(QPrinter::Inch); - QCOMPARE(paperSize, customSize); + QVERIFY2(sqrt(pow(paperSize.width() - customSize.width(), 2.0) + pow(paperSize.height() - customSize.height(), 2.0)) < 0.01, + msgSizeMismatch(paperSize, customSize)); } void tst_QPrinter::customPaperSizeAndMargins_data() @@ -1193,6 +1206,68 @@ void tst_QPrinter::testPageMetrics() QCOMPARE(printer.pageSizeMM(), QSizeF(widthMMf, heightMMf)); } +void tst_QPrinter::customPaperNameSettingBySize() +{ +#ifndef Q_OS_WIN + QSKIP("Currently this triggers a problem on non Windows platforms, this will be fixed separately - QTBUG-34521"); +#endif + QPrinter printer(QPrinter::HighResolution); + QPrinterInfo info(printer); + QList > sizes = info.supportedSizesWithNames(); + if (sizes.size() == 0) + QSKIP("No printers installed on this machine"); + for (int i=0; i > sizes = info.supportedSizesWithNames(); + if (sizes.size() == 0) + QSKIP("No printers installed on this machine"); + for (int i=0; i Date: Tue, 12 Nov 2013 11:17:05 +0100 Subject: qcompilerdetection.h: add Q_COMPILER_UNIFORM_INIT Up to now, the feature classe Uniform Initialization was subsumed by the Q_COMPILER_INITIALIZER_LISTS flag together with support for std::initializer_list. This caused at least two problems: 1. On QNX, the standard libray does not ship , even though the compiler (a GCC 4.6, IIRC) supports it. But since there was only one Q_COMPILER flag for both, support for the compiler-only part of the feature had to be disabled, too. 2. MSVC 2013 supports initializer lists, but has a bug that renders full uniform initialization support, as required for QUuid, useless. By splitting the feature into two, we can separate them better, and do so in QUuid, which is the only class that currently takes advantage of uniform initialization (to provide constexpr constructors). Since Q_COMPILER_INITIALIZER_LISTS worked as a flag for uniform initialization so far, with the two known exceptions above, UNIFORM_INIT is defined whenever INITIALIZER_LIST is, except that I don't revert UNIFORM_INIT on QNX as I do for INITIALIZER_LISTS and that I expect the MSVC 2013 features to set INITIALIZER_LIST, but not UNIFORM_INIT. Task-number: QTBUG-34705 Change-Id: I81916e950a0f3aab3de7977e0326d2de3d31b14c Reviewed-by: Yuchen Deng Reviewed-by: Thiago Macieira --- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 197d56359f..227351485d 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -64,6 +64,7 @@ private slots: void isNull(); void equal(); void notEqual(); + void cpp11(); // Only in Qt > 3.2.x void generate(); @@ -245,6 +246,17 @@ void tst_QUuid::notEqual() QVERIFY( uuidA != uuidB ); } +void tst_QUuid::cpp11() { +#ifdef Q_COMPILER_UNIFORM_INIT + // "{fc69b59e-cc34-4436-a43c-ee95d128b8c5}" cf, initTestCase + Q_DECL_CONSTEXPR QUuid u1{0xfc69b59e, 0xcc34, 0x4436, 0xa4, 0x3c, 0xee, 0x95, 0xd1, 0x28, 0xb8, 0xc5}; + Q_DECL_CONSTEXPR QUuid u2 = {0xfc69b59e, 0xcc34, 0x4436, 0xa4, 0x3c, 0xee, 0x95, 0xd1, 0x28, 0xb8, 0xc5}; + Q_UNUSED(u1); + Q_UNUSED(u2); +#else + QSKIP("This compiler is not in C++11 mode or it doesn't support uniform initialization"); +#endif +} void tst_QUuid::generate() { -- cgit v1.2.3 From 7d72516b52b20b0782d972224a55a43e74b8ae5a Mon Sep 17 00:00:00 2001 From: Alan Alpert <416365416c@gmail.com> Date: Fri, 13 Sep 2013 13:57:21 -0700 Subject: Change platform selectors to match qmake selectors Previously matched Qt.platform.os, however that can only provide one string. Multiple selectors can be present at once, so we can provide both unix and linux instead of having to pick the most specialized one. Task-number: QTBUG-34796 Change-Id: I219517d740fa7385e923a9e09cb7e241378fbaee Reviewed-by: David Faure --- .../io/qfileselector/platforms/+android/test2 | 0 .../io/qfileselector/platforms/+blackberry/test2 | 0 .../io/qfileselector/platforms/+generic_unix/test | 0 .../corelib/io/qfileselector/platforms/+ios/test2 | 0 .../io/qfileselector/platforms/+linux/test2 | 0 .../corelib/io/qfileselector/platforms/+mac/test | 0 .../corelib/io/qfileselector/platforms/+mac/test2 | 0 .../io/qfileselector/platforms/+unix/+android/test | 0 .../qfileselector/platforms/+unix/+blackberry/test | 0 .../io/qfileselector/platforms/+unix/+ios/test | 0 .../io/qfileselector/platforms/+unix/+linux/test | 0 .../io/qfileselector/platforms/+unix/+mac/test | 0 .../corelib/io/qfileselector/platforms/+unix/test | 0 .../io/qfileselector/platforms/+wince/test2 | 0 .../qfileselector/platforms/+windows/+wince/test | 0 .../io/qfileselector/platforms/+windows/test2 | 0 .../auto/corelib/io/qfileselector/platforms/test2 | 0 .../corelib/io/qfileselector/qfileselector.qrc | 22 +++++++++++++--- .../corelib/io/qfileselector/tst_qfileselector.cpp | 30 +++++++++++++++++++--- 19 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+android/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2 delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+ios/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+linux/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+mac/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+mac/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+wince/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+windows/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/test2 (limited to 'tests') diff --git a/tests/auto/corelib/io/qfileselector/platforms/+android/test2 b/tests/auto/corelib/io/qfileselector/platforms/+android/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2 b/tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test b/tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+ios/test2 b/tests/auto/corelib/io/qfileselector/platforms/+ios/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+linux/test2 b/tests/auto/corelib/io/qfileselector/platforms/+linux/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+mac/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test2 b/tests/auto/corelib/io/qfileselector/platforms/+mac/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+wince/test2 b/tests/auto/corelib/io/qfileselector/platforms/+wince/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test b/tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+windows/test2 b/tests/auto/corelib/io/qfileselector/platforms/+windows/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/test2 b/tests/auto/corelib/io/qfileselector/platforms/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc index c644e41107..abfead2a55 100644 --- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc +++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc @@ -11,13 +11,27 @@ extras/+custom3/+custom5/test extras/+custom5/+custom3/test platforms/test + platforms/+unix/+android/test + platforms/+unix/+blackberry/test + platforms/+unix/+ios/test + platforms/+unix/+mac/test + platforms/+windows/+wince/test + platforms/+windows/test + platforms/+windows/test2 + platforms/+unix/+linux/test + platforms/+unix/test + platforms/test2 + platforms/+android/test2 + platforms/+blackberry/test2 + platforms/+ios/test2 + platforms/+mac/test2 + platforms/+linux/test2 + platforms/+wince/test2 platforms/+android/test platforms/+blackberry/test platforms/+ios/test - platforms/+osx/test - platforms/+wince/test - platforms/+windows/test + platforms/+mac/test platforms/+linux/test - platforms/+generic_unix/test + platforms/+wince/test diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index 2baebd0296..d6461c3aba 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -91,9 +91,33 @@ void tst_QFileSelector::basicTest_data() QTest::addColumn("expectedPath"); QString test("/test");// '/' is here so dir string can also be selector string - QTest::newRow("platform") << QString(":/platforms/test") << QStringList() - << QString(":/platforms/") + QLatin1Char(selectorIndicator) - + QFileSelectorPrivate::platformSelectors().first() + test; + QString test2("/test2"); + QString expectedPlatform1File(":/platforms"); + QString expectedPlatform2File(""); //Only the last selector +#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_IOS) && !defined(Q_OS_LINUX) && !defined(Q_OS_MAC) + /* We are only aware of specific unixes, and do not have test files for any of the others. + However those unixes can get a selector added from the result of a uname call, so this will + lead to a case where we don't have that file so we can't expect the concatenation of platform + selectors to work. It should just find the +unix/test file.*/ + expectedPlatform1File = QString(":/platforms/") + QLatin1Char(selectorIndicator) + + QString("unix/test"); + expectedPlatform2File = QString(":/platforms/test2"); +#else + foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) { + expectedPlatform1File = expectedPlatform1File + QLatin1Char('/') + QLatin1Char(selectorIndicator) + + selector; + expectedPlatform2File = selector; + } + expectedPlatform1File += test; + expectedPlatform2File = QLatin1String(":/platforms/") + QLatin1Char(selectorIndicator) + + expectedPlatform2File + test2; +#endif + + QTest::newRow("platform1") << QString(":/platforms/test") << QStringList() + << expectedPlatform1File; + + QTest::newRow("platform2") << QString(":/platforms/test2") << QStringList() + << expectedPlatform2File; QString resourceTestPath(":/extras/test"); QString custom1("custom1"); -- cgit v1.2.3 From de5b3780cf57154c0ae3bc59e125c12904856ae4 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Wed, 13 Nov 2013 10:35:17 +0100 Subject: QFormLayout: Avoid assertion with negative spacings. It's not really clear if styles *must* return a non-negative value for QStyle::pixelMetric(PM_Layout{Vertical,Horizontal}Spacing), but both QBoxLayout and QGridLayout seems to be robust enough to handle this. They will simply make sure that the spacing is never negative. We therefore make QFormLayout equally robust. Task-number: QTBUG-34731 Change-Id: I62235bfcd8adf7757cf15bc9927b29650ae6459d Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index 135605f185..d04b812878 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -347,6 +348,19 @@ void tst_QFormLayout::spacing() style->hspacing = 20; //QCOMPARE(fl->spacing(), 20); + + + // Do not assert if spacings are negative (QTBUG-34731) + style->vspacing = -1; + style->hspacing = -1; + QLabel *label = new QLabel(tr("Asserts")); + QCheckBox *checkBox = new QCheckBox(tr("Yes")); + fl->setWidget(0, QFormLayout::LabelRole, label); + fl->setWidget(1, QFormLayout::FieldRole, checkBox); + w->resize(200, 100); + w->show(); + QVERIFY(QTest::qWaitForWindowExposed(w)); + delete w; delete style; } -- cgit v1.2.3 From e2557933cb62ba26c16262a26bc0654e655f3a9f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Nov 2013 16:48:52 +0100 Subject: Remove QTRY_ macro from tst_qabstractitemview. Change-Id: Ic8b8e5c242b640581aa735a3716666d4e7ff44eb Reviewed-by: Robin Burchell --- .../itemviews/qabstractitemview/tst_qabstractitemview.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 0c6d369254..2881f58660 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -59,17 +59,6 @@ #include #include -// Will try to wait for the condition while allowing event processing -// for a maximum of 5 seconds. -#define TRY_COMPARE(expr, expected) \ - do { \ - const int step = 50; \ - for (int q = 0; q < 5000 && ((expr) != (expected)); q+=step) { \ - QTest::qWait(step); \ - } \ - QCOMPARE(expr, expected); \ - } while(0) - static inline void setFrameless(QWidget *w) { Qt::WindowFlags flags = w->windowFlags(); @@ -751,7 +740,7 @@ void tst_QAbstractItemView::persistentEditorFocus() QTRY_VERIFY(view.isVisible()); for (int i = 0; i < list.count(); ++i) { - TRY_COMPARE(list.at(i)->isVisible(), true); + QTRY_VERIFY(list.at(i)->isVisible()); QPoint p = QPoint(5, 5); QMouseEvent mouseEvent(QEvent::MouseButtonPress, p, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); @@ -1056,7 +1045,7 @@ void tst_QAbstractItemView::setItemDelegate() v.edit(index); // This will close the editor - TRY_COMPARE(QApplication::focusWidget() == 0, false); + QTRY_VERIFY(QApplication::focusWidget()); QWidget *editor = QApplication::focusWidget(); QVERIFY(editor); editor->hide(); -- cgit v1.2.3 From afe8e368721b6cac34d3b8de7689b53200f8c6fb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Nov 2013 16:55:39 +0100 Subject: Stabilize tst_qabstractitemview. Center windows on screen to avoid conflicts with Unity taskbars, observe minimum geometry for Windows, move cursor out of the way for Mac. Introduce QScopedPointer to ensure cleanup in case of failures. Change-Id: Ic169e015e795597457b8e85a28ff7fcb7b9b9430 Reviewed-by: Robin Burchell --- .../qabstractitemview/tst_qabstractitemview.cpp | 139 ++++++++++++++++----- 1 file changed, 106 insertions(+), 33 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 2881f58660..36bf76564f 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -58,6 +58,8 @@ #include #include #include +#include +#include static inline void setFrameless(QWidget *w) { @@ -67,6 +69,22 @@ static inline void setFrameless(QWidget *w) w->setWindowFlags(flags); } +static inline void centerOnScreen(QWidget *w) +{ + const QPoint offset = QPoint(w->width() / 2, w->height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + +// Move cursor out of widget area to avoid undesired interaction on Mac. +static inline void moveCursorAway(const QWidget *topLevel) +{ +#ifndef QT_NO_CURSOR + QCursor::setPos(topLevel->geometry().topRight() + QPoint(100, 0)); +#else + Q_UNUSED(topLevel) +#endif +} + class TestView : public QAbstractItemView { Q_OBJECT @@ -363,25 +381,27 @@ void tst_QAbstractItemView::emptyModels() { QFETCH(QString, viewType); - TestView *view = 0; + QScopedPointer view; if (viewType == "QListView") - view = reinterpret_cast(new QListView()); + view.reset(new QListView()); else if (viewType == "QTableView") - view = reinterpret_cast(new QTableView()); + view.reset(new QTableView()); else if (viewType == "QTreeView") - view = reinterpret_cast(new QTreeView()); + view.reset(new QTreeView()); else if (viewType == "QHeaderView") - view = reinterpret_cast(new QHeaderView(Qt::Vertical)); + view.reset(new QHeaderView(Qt::Vertical)); else QVERIFY(0); + centerOnScreen(view.data()); + moveCursorAway(view.data()); view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); QVERIFY(!view->model()); QVERIFY(!view->selectionModel()); //QVERIFY(view->itemDelegate() != 0); - basic_tests(view); - delete view; + basic_tests(reinterpret_cast(view.data())); } void tst_QAbstractItemView::setModel_data() @@ -397,24 +417,28 @@ void tst_QAbstractItemView::setModel_data() void tst_QAbstractItemView::setModel() { QFETCH(QString, viewType); - TestView *view = 0; + + QScopedPointer view; + if (viewType == "QListView") - view = reinterpret_cast(new QListView()); + view.reset(new QListView()); else if (viewType == "QTableView") - view = reinterpret_cast(new QTableView()); + view.reset(new QTableView()); else if (viewType == "QTreeView") - view = reinterpret_cast(new QTreeView()); + view.reset(new QTreeView()); else if (viewType == "QHeaderView") - view = reinterpret_cast(new QHeaderView(Qt::Vertical)); + view.reset(new QHeaderView(Qt::Vertical)); else QVERIFY(0); + centerOnScreen(view.data()); + moveCursorAway(view.data()); view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); QStandardItemModel model(20,20); view->setModel(0); view->setModel(&model); - basic_tests(view); - delete view; + basic_tests(reinterpret_cast(view.data())); } void tst_QAbstractItemView::basic_tests(TestView *view) @@ -625,7 +649,10 @@ void tst_QAbstractItemView::noModel() view.setModel(&model); // Make the viewport smaller than the contents, so that we can scroll view.resize(100,100); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); // make sure that the scrollbars are not at value 0 view.scrollTo(view.model()->index(10,10)); @@ -645,7 +672,10 @@ void tst_QAbstractItemView::dragSelect() QTableView view; view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.setVisible(true); + QVERIFY(QTest::qWaitForWindowExposed(&view)); const int delay = 2; for (int i = 0; i < 2; ++i) { @@ -666,7 +696,10 @@ void tst_QAbstractItemView::rowDelegate() QTableView view; view.setModel(&model); view.setItemDelegateForRow(3, &delegate); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index = model.index(3, 0); view.openPersistentEditor(index); @@ -683,7 +716,10 @@ void tst_QAbstractItemView::columnDelegate() QTableView view; view.setModel(&model); view.setItemDelegateForColumn(3, &delegate); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index = model.index(0, 3); view.openPersistentEditor(index); @@ -736,8 +772,10 @@ void tst_QAbstractItemView::persistentEditorFocus() view.setCurrentIndex(model.index(0, 0)); QCOMPARE(view.currentIndex(), model.index(0, 0)); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTRY_VERIFY(view.isVisible()); + QVERIFY(QTest::qWaitForWindowExposed(&view)); for (int i = 0; i < list.count(); ++i) { QTRY_VERIFY(list.at(i)->isVisible()); @@ -1034,6 +1072,8 @@ void tst_QAbstractItemView::setItemDelegate() } } } + centerOnScreen(&v); + moveCursorAway(&v); v.show(); #ifdef Q_WS_X11 QCursor::setPos(v.geometry().center()); @@ -1111,20 +1151,25 @@ void tst_QAbstractItemView::setCurrentIndex() QFETCH(int, itemFlags); QFETCH(bool, result); - TestView *view = 0; + QScopedPointer view; + if (viewType == "QListView") - view = reinterpret_cast(new QListView()); + view.reset(new QListView()); else if (viewType == "QTableView") - view = reinterpret_cast(new QTableView()); + view.reset(new QTableView()); else if (viewType == "QTreeView") - view = reinterpret_cast(new QTreeView()); + view.reset(new QTreeView()); else if (viewType == "QHeaderView") - view = reinterpret_cast(new QHeaderView(Qt::Vertical)); + view.reset(new QHeaderView(Qt::Vertical)); else QVERIFY(0); + + centerOnScreen(view.data()); + moveCursorAway(view.data()); view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); - QStandardItemModel *model = new QStandardItemModel(view); + QStandardItemModel *model = new QStandardItemModel(view.data()); QStandardItem *item = new QStandardItem("first item"); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); model->appendRow(item); @@ -1139,8 +1184,6 @@ void tst_QAbstractItemView::setCurrentIndex() QVERIFY(view->currentIndex() == model->index(0,0)); view->setCurrentIndex(model->index(1,0)); QVERIFY(view->currentIndex() == model->index(result ? 1 : 0,0)); - - delete view; } void tst_QAbstractItemView::task221955_selectedEditor() @@ -1159,11 +1202,13 @@ void tst_QAbstractItemView::task221955_selectedEditor() tree.setItemWidget(dummy, 0, button = new QPushButton("More...")); button->setAutoFillBackground(true); // as recommended in doc + centerOnScreen(&tree); + moveCursorAway(&tree); tree.show(); tree.setFocus(); tree.setCurrentIndex(tree.model()->index(1,0)); - QTest::qWait(100); QApplication::setActiveWindow(&tree); + QVERIFY(QTest::qWaitForWindowActive(&tree)); QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0))); @@ -1207,9 +1252,11 @@ void tst_QAbstractItemView::task250754_fontChange() } tree.setModel(m); + w.resize(160, 240); // Minimum width for windows with frame on Windows 8 + centerOnScreen(&w); + moveCursorAway(&w); w.show(); - w.resize(150,240); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QFont font = tree.font(); font.setPixelSize(10); tree.setFont(font); @@ -1233,8 +1280,10 @@ void tst_QAbstractItemView::task200665_itemEntered() QStandardItemModel model(1000,1); QListView view; view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(200); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QRect rect = view.visualRect(model.index(0,0)); QCursor::setPos( view.viewport()->mapToGlobal(rect.center()) ); QSignalSpy spy(&view, SIGNAL(entered(QModelIndex))); @@ -1256,7 +1305,10 @@ void tst_QAbstractItemView::task257481_emptyEditor() QTreeView treeView; treeView.setRootIsDecorated(false); treeView.setModel(&model); + centerOnScreen(&treeView); + moveCursorAway(&treeView); treeView.show(); + QVERIFY(QTest::qWaitForWindowExposed(&treeView)); treeView.edit(model.index(0,0)); QList lineEditors = treeView.viewport()->findChildren(); @@ -1287,14 +1339,16 @@ void tst_QAbstractItemView::shiftArrowSelectionAfterScrolling() } QListView view; - view.setFixedSize(150, 250); + view.setFixedSize(160, 250); // Minimum width for windows with frame on Windows 8 view.setFlow(QListView::LeftToRight); view.setGridSize(QSize(100, 100)); view.setSelectionMode(QListView::ExtendedSelection); view.setViewMode(QListView::IconMode); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index0 = model.index(0, 0); QModelIndex index1 = model.index(1, 0); @@ -1322,14 +1376,16 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection() } QListView view; - view.setFixedSize(150, 450); + view.setFixedSize(160, 450); // Minimum width for windows with frame on Windows 8 view.setFlow(QListView::LeftToRight); view.setGridSize(QSize(100, 100)); view.setSelectionMode(QListView::ExtendedSelection); view.setViewMode(QListView::IconMode); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index0 = model.index(0, 0); QModelIndex index1 = model.index(1, 0); @@ -1397,14 +1453,16 @@ void tst_QAbstractItemView::ctrlRubberbandSelection() } QListView view; - view.setFixedSize(150, 450); + view.setFixedSize(160, 450); // Minimum width for windows with frame on Windows 8 view.setFlow(QListView::LeftToRight); view.setGridSize(QSize(100, 100)); view.setSelectionMode(QListView::ExtendedSelection); view.setViewMode(QListView::IconMode); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index1 = model.index(1, 0); QModelIndex index2 = model.index(2, 0); @@ -1443,6 +1501,8 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection() font.setPixelSize(10); view.setFont(font); view.resize(200,240); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); QApplication::setActiveWindow(&view); @@ -1482,7 +1542,11 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection() for (int j = 0; j < table.columnCount(); ++j) table.setItem(i, j, new QTableWidgetItem("choo-be-doo-wah")); + centerOnScreen(&table); + moveCursorAway(&table); table.show(); + QVERIFY(QTest::qWaitForWindowExposed(&table)); + table.setSelectionMode(QAbstractItemView::ExtendedSelection); table.selectAll(); QVERIFY(QTest::qWaitForWindowExposed(&table)); @@ -1512,6 +1576,8 @@ void tst_QAbstractItemView::testClickedSignal() { QTableWidget view(5, 5); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1580,6 +1646,8 @@ void tst_QAbstractItemView::testChangeEditorState() view.setEditTriggers(QAbstractItemView::CurrentChanged); view.setItemDelegate(new StateChangeDelegate); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1596,7 +1664,10 @@ void tst_QAbstractItemView::deselectInSingleSelection() s.setRowCount(10); s.setColumnCount(10); view.setModel(&s); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.setSelectionMode(QAbstractItemView::SingleSelection); view.setEditTriggers(QAbstractItemView::NoEditTriggers); QApplication::setActiveWindow(&view); @@ -1639,6 +1710,8 @@ void tst_QAbstractItemView::testNoActivateOnDisabledItem() model.setItem(0, 0, item); item->setFlags(Qt::NoItemFlags); treeView.setModel(&model); + centerOnScreen(&treeView); + moveCursorAway(&treeView); treeView.show(); QApplication::setActiveWindow(&treeView); -- cgit v1.2.3 From 6c04c21c101b70401ad9cb08de1562dc90166e9c Mon Sep 17 00:00:00 2001 From: Martin Pley Date: Fri, 15 Nov 2013 22:01:54 +0100 Subject: Crash fix in QTreeView::sizeHintForColumn(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vertical scrollbar may get out of sync. When this happens, the calculation of firstVisibleItem will retrun "-1". This must be handled in ::sizeHintForColumn(). Added an auto-test for the crashes. Task-number: QTBUG-34717 Change-Id: I867fd144ef3ce45e382337c5eafe345f573cd944 Reviewed-by: Thorbjørn Lund Martsum --- .../widgets/itemviews/qtreeview/tst_qtreeview.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 8d31fcdf13..ccdce1fe0c 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -259,6 +259,7 @@ private slots: void taskQTBUG_25333_adjustViewOptionsForIndex(); void taskQTBUG_18539_emitLayoutChanged(); void taskQTBUG_8176_emitOnExpandAll(); + void taskQTBUG_34717_collapseAtBottom(); void testInitialFocus(); }; @@ -4240,6 +4241,35 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll() QCOMPARE(spy2.size(), 1); // item2 is collapsed } +// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end +// of an expanded tree, then collapse all) +// The test passes simply if it doesn't crash. +void tst_QTreeView::taskQTBUG_34717_collapseAtBottom() +{ + QTreeWidget treeWidget; + treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents); + treeWidget.setColumnCount(2); + QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root"); + for (int i = 0; i < 200; ++i) { + QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item"))); + new QTreeWidgetItem(item, QStringList() << "Child" << "1"); + new QTreeWidgetItem(item, QStringList() << "Child" << "2"); + new QTreeWidgetItem(item, QStringList() << "Child" << "3"); + } + treeWidget.show(); + treeWidget.expandAll(); + treeWidget.scrollToBottom(); + treeWidget.collapseAll(); + + treeWidget.setAnimated(true); + treeWidget.expandAll(); + treeWidget.scrollToBottom(); + mainItem->setExpanded(false); + + PublicView *pview = (PublicView*) &treeWidget; + QVERIFY(pview->sizeHintForColumn(1) >= 0); +} + void tst_QTreeView::testInitialFocus() { QTreeWidget treeWidget; -- cgit v1.2.3 From 2026e502596cf6d447caf9545ffed8d3f73fe597 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 2 Sep 2013 10:26:21 +0200 Subject: QCommandLineParser: add word-wrapping algorithm Rather than breaking at column 79 precisely, break entire words, to improve readability. Change-Id: Ie30db00f0e6ed95cce87480c3b91804826c6076b Reviewed-by: Oswald Buddenhagen --- .../testhelper/qcommandlineparser_test_helper.cpp | 11 ++++- .../qcommandlineparser/tst_qcommandlineparser.cpp | 49 ++++++++++++---------- 2 files changed, 38 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index 07f8ddfc8e..2b30b0486b 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -69,9 +69,18 @@ int main(int argc, char *argv[]) // An option with a longer description, to test wrapping QCommandLineOption noImplicitIncludesOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-implicit-includes")); - noImplicitIncludesOption.setDescription(QStringLiteral("Disable automatic generation of implicit #include-directives.")); + noImplicitIncludesOption.setDescription(QStringLiteral("Disable magic generation of implicit #include-directives.")); parser.addOption(noImplicitIncludesOption); + QCommandLineOption newlineOption(QStringList() << QStringLiteral("newline")); + newlineOption.setDescription(QString::fromLatin1("This is an option with a rather long\n" + "description using explicit newline characters " + "(but testing automatic wrapping too). In addition, " + "here, we test breaking after a comma. Testing -option. " + "Long URL: http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application " + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + parser.addOption(newlineOption); + // This program supports different options depending on the "command" (first argument). // Call parse() to find out the positional arguments. parser.parse(QCoreApplication::arguments()); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index d8965dee5d..f37e192ad3 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -459,27 +459,40 @@ void tst_QCommandLineParser::testVersionOption() #endif // !QT_NO_PROCESS } +static const char expectedOptionsHelp[] = + "Options:\n" + " -h, --help Displays this help.\n" + " -v, --version Displays version information.\n" + " --load Load file from URL.\n" + " -o, --output Set output file.\n" + " -D Define macro.\n" + " -n, --no-implicit-includes Disable magic generation of implicit\n" + " #include-directives.\n" + " --newline This is an option with a rather long\n" + " description using explicit newline characters (but\n" + " testing automatic wrapping too). In addition,\n" + " here, we test breaking after a comma. Testing\n" + " -option. Long URL:\n" + " http://qt-project.org/wiki/How_to_create_a_library\n" + " _with_Qt_and_use_it_in_an_application\n" + " abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx\n" + " yzabcdefghijklmnopqrstuvwxyz\n"; + void tst_QCommandLineParser::testHelpOption_data() { QTest::addColumn("parsingMode"); QTest::addColumn("expectedHelpOutput"); - QString expectedOutput = + QString expectedOutput = QString::fromLatin1( "Usage: testhelper/qcommandlineparser_test_helper [options] parsingMode command\n" "Test helper\n" - "\n" - "Options:\n" - " -h, --help Displays this help.\n" - " -v, --version Displays version information.\n" - " --load Load file from URL.\n" - " -o, --output Set output file.\n" - " -D Define macro.\n" - " -n, --no-implicit-includes Disable automatic generation of implicit #include\n" - " -directives.\n" + "\n") + + QString::fromLatin1(expectedOptionsHelp) + + QString::fromLatin1( "\n" "Arguments:\n" " parsingMode The parsing mode to test.\n" - " command The command to execute.\n"; + " command The command to execute.\n"); #ifdef Q_OS_WIN expectedOutput.replace(" -h, --help Displays this help.\n", " -?, -h, --help Displays this help.\n"); @@ -510,6 +523,7 @@ void tst_QCommandLineParser::testHelpOption() #ifdef Q_OS_WIN output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif + QCOMPARE(output.split('\n'), expectedHelpOutput.split('\n')); // easier to debug than the next line, on failure QCOMPARE(output, expectedHelpOutput); process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "resize" << "--help"); @@ -519,18 +533,11 @@ void tst_QCommandLineParser::testHelpOption() #ifdef Q_OS_WIN output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif - QByteArray expectedResizeHelp = + QByteArray expectedResizeHelp = QByteArrayLiteral( "Usage: testhelper/qcommandlineparser_test_helper [options] resize [resize_options]\n" "Test helper\n" - "\n" - "Options:\n" - " -h, --help Displays this help.\n" - " -v, --version Displays version information.\n" - " --load Load file from URL.\n" - " -o, --output Set output file.\n" - " -D Define macro.\n" - " -n, --no-implicit-includes Disable automatic generation of implicit #include\n" - " -directives.\n" + "\n") + + expectedOptionsHelp + " --size New size.\n" "\n" "Arguments:\n" -- cgit v1.2.3 From 3e803b5180e7059c01c15ea84cadd54982e1a221 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 13 Nov 2013 11:37:37 +0100 Subject: QCollator: enable move semantics This necessitates adding d==0 checks in QCollator. By documenting that moved-from instances can only be assigned to or destroyed, we can limit the functions in which to check for d==0 to the assignment operator and the destructor. Doing otherwise would destroy all advantages of move semantics by introducing a heap allocation to re-populate other.d. Add a test for this (QCollator didn't have any before). Change-Id: Ic6ff202072822bebfd5e48259c3d0fa345a63118 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qcollator/qcollator.pro | 7 ++ .../auto/corelib/tools/qcollator/tst_qcollator.cpp | 92 ++++++++++++++++++++++ tests/auto/corelib/tools/tools.pro | 1 + 3 files changed, 100 insertions(+) create mode 100644 tests/auto/corelib/tools/qcollator/qcollator.pro create mode 100644 tests/auto/corelib/tools/qcollator/tst_qcollator.cpp (limited to 'tests') diff --git a/tests/auto/corelib/tools/qcollator/qcollator.pro b/tests/auto/corelib/tools/qcollator/qcollator.pro new file mode 100644 index 0000000000..3c5987ffa0 --- /dev/null +++ b/tests/auto/corelib/tools/qcollator/qcollator.pro @@ -0,0 +1,7 @@ +CONFIG += testcase parallel_test +TARGET = tst_qcollator +QT = core testlib +SOURCES = tst_qcollator.cpp +DEFINES += QT_NO_CAST_TO_ASCII +contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp new file mode 100644 index 0000000000..3df8422a34 --- /dev/null +++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include + +#include + +class tst_QCollator : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void moveSemantics(); +}; + +#ifdef Q_COMPILER_RVALUE_REFS +static bool dpointer_is_null(QCollator &c) +{ + char mem[sizeof c]; + using namespace std; + memcpy(mem, &c, sizeof c); + for (size_t i = 0; i < sizeof c; ++i) + if (mem[i]) + return false; + return true; +} +#endif + +void tst_QCollator::moveSemantics() +{ +#ifdef Q_COMPILER_RVALUE_REFS + const QLocale de_AT(QLocale::German, QLocale::Austria); + + QCollator c1(de_AT); + QCOMPARE(c1.locale(), de_AT); + + QCollator c2(std::move(c1)); + QCOMPARE(c2.locale(), de_AT); + QVERIFY(dpointer_is_null(c1)); + + c1 = std::move(c2); + QCOMPARE(c1.locale(), de_AT); + QVERIFY(dpointer_is_null(c2)); +#else + QSKIP("The compiler is not in C++11 mode or does not support move semantics."); +#endif +} + +QTEST_APPLESS_MAIN(tst_QCollator) + +#include "tst_qcollator.moc" diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index e920813db2..286afdfd18 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -8,6 +8,7 @@ SUBDIRS=\ qbytedatabuffer \ qcache \ qchar \ + qcollator \ qcommandlineparser \ qcontiguouscache \ qcryptographichash \ -- cgit v1.2.3 From eb122a6fe4de5b95acb287f92c6ca5e81864b1c6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 16 Nov 2013 14:30:38 +0100 Subject: tst_QAlgorithms: fix compilation with C++11 enabled GCC refuses to use a merely static const uint array in a constexpr function. Fix by making the array constexpr if supported by the compiler. Change-Id: Idd59d3f74f8f4e98aad82bc892f4a6469932df9f Reviewed-by: Olivier Goffart Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 144bc62b1b..64eb91b7b6 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -1027,7 +1027,7 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const } // alternative implementation of qPopulationCount for comparison: -static const uint bitsSetInNibble[] = { +static Q_DECL_CONSTEXPR const uint bitsSetInNibble[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, }; -- cgit v1.2.3 From aafbd7392ead765c2038a1ac6b569d083effb81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Martsum?= Date: Tue, 12 Nov 2013 20:01:22 +0100 Subject: QHeaderView - do not ignore -1 as minimum section size We claim that -1 is a special automatic value, but calling setMinimumSectionSize with -1 is unfortunately ignored due a regression in 524c3e05e811d81fbcd71eedb377b7eaa0a21ef3 Change-Id: I7d7e5dbbf78e561849d2f2352c9edb2df36aa181 Reviewed-by: Giuseppe D'Angelo --- tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 398b1b4d98..3e6df0f136 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -368,6 +368,8 @@ void tst_QHeaderView::getSetCheck() QCOMPARE(0, obj1.minimumSectionSize()); obj1.setMinimumSectionSize(99999); QCOMPARE(99999, obj1.minimumSectionSize()); + obj1.setMinimumSectionSize(-1); + QVERIFY(obj1.minimumSectionSize() < 100); // int QHeaderView::offset() // void QHeaderView::setOffset(int) -- cgit v1.2.3 From 69a8c59b3ffe81f20cb5f1425d72cca8053a0527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 15 Nov 2013 19:25:54 +0100 Subject: tst_QWindow: Set explicit window position to please qWaitForWindowActive qWaitForWindowActive waits until the timeout for the window to receive a non-0x0 position, even when it's active, just in case the WM sets the position as a response to focus-in. Change-Id: I748cce2747f406a8cdff556465175f02675fcd13 Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index c4983f4462..bd5959786f 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -843,7 +843,10 @@ void tst_QWindow::activateAndClose() { for (int i = 0; i < 10; ++i) { QWindow window; - window.show(); + // qWaitForWindowActive will block for the duration of + // of the timeout if the window is at 0,0 + window.setGeometry(QGuiApplication::primaryScreen()->availableGeometry().adjusted(1, 1, -1, -1)); + window.showNormal(); window.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&window)); QCOMPARE(qGuiApp->focusWindow(), &window); -- cgit v1.2.3 From 7e768dde39f9365a4e1fc45afc492b74744a44e6 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Sat, 16 Nov 2013 17:17:15 +0100 Subject: Widgets: Never revoke focus by click on focused widget. When clicking on a widget currently focused, w/o having Qt::ClickFocus set as focus policy, the focus should stay on the widget and not get propagated to the widget's parent. Task-number: QTBUG-34042 Change-Id: I53f1153829cc7228de02a90e38125b5cf4ee5008 Reviewed-by: Marc Mutz --- .../kernel/qapplication/tst_qapplication.cpp | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 8d75298673..091927abe4 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -153,6 +153,7 @@ private slots: void focusChanged(); void focusOut(); + void focusMouseClick(); void execAfterExit(); @@ -1771,6 +1772,63 @@ void tst_QApplication::focusOut() QTest::qWait(2000); } +class SpontaneousEvent +{ + Q_GADGET + QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) + Q_ENUMS(Type) +public: + enum Type { + Void + }; + + virtual ~SpontaneousEvent() {} + + QEventPrivate *d; + ushort t; + + ushort posted : 1; + ushort spont : 1; +}; + +void tst_QApplication::focusMouseClick() +{ + int argc = 1; + QApplication app(argc, &argv0); + + QWidget w; + w.setFocusPolicy(Qt::StrongFocus); + QWidget w2(&w); + w2.setFocusPolicy(Qt::TabFocus); + w.show(); + w.setFocus(); + QTRY_COMPARE(QApplication::focusWidget(), &w); + + // front most widget has Qt::TabFocus, parent widget accepts clicks as well + // now send a mouse button press event and check what happens with the focus + // it should be given to the parent widget + QMouseEvent ev(QEvent::MouseButtonPress, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + reinterpret_cast(&ev)->spont = 1; + QVERIFY(ev.spontaneous()); + qApp->notify(&w2, &ev); + QCOMPARE(QApplication::focusWidget(), &w); + + // then we give the inner widget strong focus -> it should get focus + w2.setFocusPolicy(Qt::StrongFocus); + reinterpret_cast(&ev)->spont = 1; + QVERIFY(ev.spontaneous()); + qApp->notify(&w2, &ev); + QTRY_COMPARE(QApplication::focusWidget(), &w2); + + // now back to tab focus and click again (it already had focus) -> focus should stay + // (focus was revoked as of QTBUG-34042) + w2.setFocusPolicy(Qt::TabFocus); + reinterpret_cast(&ev)->spont = 1; + QVERIFY(ev.spontaneous()); + qApp->notify(&w2, &ev); + QCOMPARE(QApplication::focusWidget(), &w2); +} + void tst_QApplication::execAfterExit() { int argc = 1; -- cgit v1.2.3 From 1b9be3f48156a4928a2447bdf13f8b67fd507932 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 18 Nov 2013 22:43:19 +0100 Subject: Testlib.selftest: Improve process execution, run on openSUSE. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Give processes a more complete environment (openSUSE requires more variables to start an X11-process), add test column indicating whether a test is supposed to crash. If it is not, report crash reason. Change-Id: I1e0ad59824963f69ee425f331d845741be2b3928 Reviewed-by: Tony Sarajärvi Reviewed-by: Frederik Gladhorn --- tests/auto/testlib/selftests/tst_selftests.cpp | 68 +++++++++++++++++--------- 1 file changed, 45 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index b737f823c8..e332f01861 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -63,7 +63,7 @@ private slots: void cleanup(); private: - void doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments); + void doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments, bool crashes); QString logName(const QString &logger) const; QList allLoggerSets() const; @@ -324,6 +324,7 @@ void tst_Selftests::runSubTest_data() QTest::addColumn("subdir"); QTest::addColumn("loggers"); QTest::addColumn("arguments"); + QTest::addColumn("crashes"); QStringList tests = QStringList() // << "alive" // timer dependent @@ -479,11 +480,14 @@ void tst_Selftests::runSubTest_data() continue; } } - + const bool crashes = subtest == QLatin1String("assert") || subtest == QLatin1String("exceptionthrow") + || subtest == QLatin1String("fetchbogus") || subtest == QLatin1String("crashedterminate") + || subtest == QLatin1String("crashes") || subtest == QLatin1String("silent"); QTest::newRow(qPrintable(QString("%1 %2").arg(subtest).arg(loggerSet.name))) << subtest << loggers << arguments + << crashes ; } } @@ -491,30 +495,41 @@ void tst_Selftests::runSubTest_data() #ifndef QT_NO_PROCESS -static void insertEnvironmentVariable(QString const& name, QProcessEnvironment &result) -{ - const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment(); - const QString value = systemEnvironment.value(name); - if (!value.isEmpty()) - result.insert(name, value); -} - -static inline QProcessEnvironment processEnvironment() +static QProcessEnvironment processEnvironment() { - QProcessEnvironment result; - insertEnvironmentVariable(QStringLiteral("PATH"), result); - // Preserve DISPLAY for X11 as some tests use Qt GUI. -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) - insertEnvironmentVariable(QStringLiteral("DISPLAY"), result); -#endif - insertEnvironmentVariable(QStringLiteral("QT_QPA_PLATFORM"), result); + static QProcessEnvironment result; + if (result.isEmpty()) { + const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment(); + foreach (const QString &key, systemEnvironment.keys()) { + const bool useVariable = key == QLatin1String("PATH") || key == QLatin1String("QT_QPA_PLATFORM") +#ifdef Q_OS_UNIX + || key == QLatin1String("HOME") || key == QLatin1String("USER") // Required for X11 on openSUSE +# ifndef Q_OS_MAC + || key == QLatin1String("DISPLAY") || key == QLatin1String("XAUTHLOCALHOSTNAME") + || key.startsWith(QLatin1String("XDG_")) +# endif // !Q_OS_MAC +#endif // Q_OS_UNIX #ifdef __COVERAGESCANNER__ - insertEnvironmentVariable(QStringLiteral("QT_TESTCOCOON_ACTIVE"), result); + || key == QLatin1String("QT_TESTCOCOON_ACTIVE") #endif + ; + if (useVariable) + result.insert(key, systemEnvironment.value(key)); + } + } return result; } -void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments) +static inline QByteArray msgProcessError(const QString &binary, const QStringList &args, + const QProcessEnvironment &e, const QString &what) +{ + QString result; + QTextStream(&result) <<"Error running " << binary << ' ' << args.join(' ') + << " with environment " << e.toStringList().join(' ') << ": " << what; + return result.toLocal8Bit(); +} + +void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments, bool crashes) { #if defined(__GNUC__) && defined(__i386) && defined(Q_OS_LINUX) if (arguments.contains("-callgrind")) { @@ -532,8 +547,14 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge proc.setProcessEnvironment(environment); const QString path = subdir + QLatin1Char('/') + subdir; proc.start(path, arguments); - QVERIFY2(proc.waitForStarted(), qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, proc.errorString()))); - QVERIFY2(proc.waitForFinished(), qPrintable(proc.errorString())); + QVERIFY2(proc.waitForStarted(), msgProcessError(path, arguments, environment, QStringLiteral("Cannot start: ") + proc.errorString())); + QVERIFY2(proc.waitForFinished(), msgProcessError(path, arguments, environment, QStringLiteral("Timed out: ") + proc.errorString())); + if (!crashes) { + QVERIFY2(proc.exitStatus() == QProcess::NormalExit, + msgProcessError(path, arguments, environment, + QStringLiteral("Crashed: ") + proc.errorString() + + QStringLiteral(": ") + QString::fromLocal8Bit(proc.readAllStandardError()))); + } QList actualOutputs; for (int i = 0; i < loggers.count(); ++i) { @@ -700,8 +721,9 @@ void tst_Selftests::runSubTest() QFETCH(QString, subdir); QFETCH(QStringList, loggers); QFETCH(QStringList, arguments); + QFETCH(bool, crashes); - doRunSubTest(subdir, loggers, arguments); + doRunSubTest(subdir, loggers, arguments, crashes); #endif // !QT_NO_PROCESS } -- cgit v1.2.3 From e1c0a1b56cddcbab91e4d0fc325482b51c55e3d1 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 18 Nov 2013 20:00:16 +0100 Subject: QProgressDialog: add unittest for the auto-show feature Change-Id: I244d0b740467a09e8833f4debb95b19e45df371f Reviewed-by: Marc Mutz --- .../qprogressdialog/tst_qprogressdialog.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp index 68502f0d8d..060fa51293 100644 --- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp +++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp @@ -57,6 +57,8 @@ public: virtual ~tst_QProgressDialog(); private slots: + void autoShow_data(); + void autoShow(); void getSetCheck(); void task198202(); void QTBUG_31046(); @@ -70,6 +72,34 @@ tst_QProgressDialog::~tst_QProgressDialog() { } +void tst_QProgressDialog::autoShow_data() +{ + QTest::addColumn("min"); + QTest::addColumn("max"); + QTest::addColumn("delay"); + QTest::addColumn("expectedAutoShow"); + + QTest::newRow("50_to_100_long") << 50 << 100 << 100 << true; // 50*100ms = 5s + QTest::newRow("50_to_100_short") << 50 << 1 << 100 << false; // 50*1ms = 50ms + + QTest::newRow("0_to_100_long") << 0 << 100 << 100 << true; // 100*100ms = 10s + QTest::newRow("0_to_10_short") << 0 << 10 << 100 << false; // 10*100ms = 1s +} + +void tst_QProgressDialog::autoShow() +{ + QFETCH(int, min); + QFETCH(int, max); + QFETCH(int, delay); + QFETCH(bool, expectedAutoShow); + + QProgressDialog dlg("", "", min, max); + dlg.setValue(0); + QThread::msleep(delay); + dlg.setValue(min+1); + QCOMPARE(dlg.isVisible(), expectedAutoShow); +} + // Testing get/set functions void tst_QProgressDialog::getSetCheck() { -- cgit v1.2.3 From 829b1d13b225e87b8a385397e2b53c7a9f8cda9e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 28 Oct 2013 14:11:50 +0100 Subject: Ensure Qt::WA_Mapped is set in case of obscured native windows. Task-number: QTBUG-33520 Change-Id: I51f9b4634be29fd32f4ad9cc8b5d3e10b19ea2f5 Reviewed-by: Oliver Wolff Reviewed-by: Joerg Bornemann Reviewed-by: Gunnar Sletta --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 4 ++++ .../kernel/qwidget_window/tst_qwidget_window.cpp | 28 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 03d6c1cdbd..7bb5fd4614 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -7192,6 +7192,10 @@ void tst_QWidget::hideOpaqueChildWhileHidden() #if !defined(Q_OS_WINCE) void tst_QWidget::updateWhileMinimized() { +#ifdef Q_OS_UNIX + if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) + QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. +#endif // Q_OS_UNIX UpdateWidget widget; // Filter out activation change and focus events to avoid update() calls in QWidget. widget.updateOnActivationChangeAndFocusIn = false; diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 1bbbfd610e..f5585c583a 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -91,6 +91,8 @@ private slots: void tst_showWithoutActivating(); void tst_paintEventOnSecondShow(); + void obscuredNativeMapped(); + #ifndef QT_NO_DRAGANDDROP void tst_dnd(); #endif @@ -368,6 +370,32 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() QTRY_VERIFY(w.paintEventReceived); } +// QTBUG-33520, a toplevel fully obscured by native children should still receive Qt::WA_Mapped +void tst_QWidget_window::obscuredNativeMapped() +{ + enum { size = 200 }; + + QWidget topLevel; + topLevel.setWindowFlags(Qt::FramelessWindowHint); + QWidget *child = new QWidget(&topLevel); + child->resize(size, size); + topLevel.resize(size, size); + topLevel.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(size /2 , size / 2)); + child->winId(); + topLevel.show(); + QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); +#if defined(Q_OS_MAC) + QSKIP("This test fails on Mac."); // Minimized windows are not unmapped for some reason. +#elif defined(Q_OS_UNIX) + if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) + QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. +#endif // Q_OS_UNIX + topLevel.setWindowState(Qt::WindowMinimized); + QTRY_VERIFY(!topLevel.testAttribute(Qt::WA_Mapped)); + topLevel.setWindowState(Qt::WindowNoState); + QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); +} + #ifndef QT_NO_DRAGANDDROP /* DnD test for QWidgetWindow (handleDrag*Event() functions). -- cgit v1.2.3 From 49a3fe0cf8c8cddba6dacfb796e9db13c4ac74c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 15 Nov 2013 17:55:25 +0100 Subject: tst_QWindow: Use showNormal() to prevent maximize/fullscreen interference We don't want platform behavior for whether or not maximized/fullscreen windows can be resized to affect the test for resize event propagation. Change-Id: I8c118733ca5d2553aacf24d0b8debeb1a4e27103 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Gunnar Sletta --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index bd5959786f..259c840ae7 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -177,7 +177,7 @@ void tst_QWindow::resizeEventAfterResize() Window window; window.setGeometry(geometry); - window.show(); + window.showNormal(); QTRY_COMPARE(window.received(QEvent::Resize), 1); -- cgit v1.2.3 From 54b8c27e03d04c1e5cd35f75d5c0a8111240eb74 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 15 Nov 2013 11:26:38 +0100 Subject: Fix crash when windowcontainer is used in a dockwidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dockwidget's toplevel window would be a parent of the container's window when floating. When plugged back into the mainwindow the dockwidget's window is destroyed and the container's window along with it. Added a function toplevelAboutToBeDestroyed to unparent the containers window before this happens so parentWasChanged will work correctly. Change-Id: I06679cfb3a8fa3834c0db0be5973c012b8277275 Reviewed-by: Ulf Hermann Reviewed-by: Jørgen Lind --- .../qwindowcontainer/tst_qwindowcontainer.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index c17a03e058..cd6433bbe7 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -46,6 +46,8 @@ #include #include +#include +#include class Window : public QWindow @@ -80,6 +82,7 @@ private slots: void testUnparenting(); void testActivation(); void testAncestorChange(); + void testDockWidget(); }; @@ -278,6 +281,7 @@ void tst_QWindowContainer::testAncestorChange() newRoot->setGeometry(100, 100, 200, 200); newRoot->show(); QVERIFY(QTest::qWaitForWindowExposed(newRoot)); + QCOMPARE(newRoot->windowHandle(), window->parent()); // newRoot // + right // + container @@ -285,6 +289,31 @@ void tst_QWindowContainer::testAncestorChange() QCOMPARE(window->geometry(), QRect(100, 0, 100, 100)); } + +void tst_QWindowContainer::testDockWidget() +{ + QMainWindow mainWindow; + mainWindow.resize(200, 200); + + QDockWidget *dock = new QDockWidget(); + QWindow *window = new QWindow(); + QWidget *container = QWidget::createWindowContainer(window); + dock->setWidget(container); + mainWindow.addDockWidget(Qt::RightDockWidgetArea, dock); + + mainWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); + QVERIFY(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_VERIFY(window->parent() == mainWindow.window()->windowHandle()); +} + QTEST_MAIN(tst_QWindowContainer) #include "tst_qwindowcontainer.moc" -- cgit v1.2.3 From 097be87a64995bab43ba5b7d2a7aff5571a298b9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 19 Nov 2013 11:02:50 +0100 Subject: Stabilize tst_QGraphicsScene::isActive(). Position windows, use QTRY_VERIFY. Change-Id: I84349dd696a633840973e9db0c538830aaa96948 Reviewed-by: Frederik Gladhorn --- .../auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index fe1df6c8f0..15c92663ec 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -4072,6 +4072,7 @@ void tst_QGraphicsScene::isActive() { + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QWidget toplevel2; QHBoxLayout *layout = new QHBoxLayout; toplevel2.setLayout(layout); @@ -4085,12 +4086,13 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); + toplevel2.move(availableGeometry.topLeft() + QPoint(50, 50)); toplevel2.show(); QApplication::setActiveWindow(&toplevel2); QVERIFY(QTest::qWaitForWindowActive(&toplevel2)); QCOMPARE(QApplication::activeWindow(), &toplevel2); - QVERIFY(scene1.isActive()); + QTRY_VERIFY(scene1.isActive()); QVERIFY(!scene2.isActive()); QVERIFY(scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); @@ -4133,6 +4135,7 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene2.hasFocus()); QGraphicsView topLevelView; + topLevelView.move(availableGeometry.topLeft() + QPoint(500, 50)); topLevelView.show(); QApplication::setActiveWindow(&topLevelView); topLevelView.setFocus(); -- cgit v1.2.3 From 0787550f637b10317e06dea249a51c24f7e18b7e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 19 Nov 2013 11:04:15 +0100 Subject: Stabilize tst_QGraphicsView::hoverLeave(). Position windows, use QTRY_VERIFY. Change-Id: I0fab91c65b30e7028343c7e9b19a1b232fe72ebf Reviewed-by: Frederik Gladhorn --- .../graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 7a0ba50ff0..37cc6522a2 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4687,13 +4687,17 @@ public: void tst_QGraphicsView::hoverLeave() { + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(160, 160); + view.move(availableGeometry.center() - QPoint(80, 80)); GraphicsItemWithHover *item = new GraphicsItemWithHover; scene.addItem(item); // move the cursor out of the way - QCursor::setPos(1,1); + const QPoint outOfWindow = view.geometry().topRight() + QPoint(50, 0); + QCursor::setPos(outOfWindow); view.show(); qApp->setActiveWindow(&view); @@ -4701,16 +4705,14 @@ void tst_QGraphicsView::hoverLeave() QPoint pos = view.viewport()->mapToGlobal(view.mapFromScene(item->mapToScene(10, 10))); QCursor::setPos(pos); - QTest::qWait(200); - QVERIFY(item->receivedEnterEvent); + QTRY_VERIFY(item->receivedEnterEvent); QCOMPARE(item->enterWidget, view.viewport()); - QCursor::setPos(1,1); - QTest::qWait(200); + QCursor::setPos(outOfWindow); #ifdef Q_OS_MAC QEXPECT_FAIL("", "QTBUG-26274 - behaviour regression", Abort); #endif - QVERIFY(item->receivedLeaveEvent); + QTRY_VERIFY(item->receivedLeaveEvent); QCOMPARE(item->leaveWidget, view.viewport()); } -- cgit v1.2.3 From 054dfae39d093200fcce477b30a17bacf422be36 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 19 Nov 2013 11:05:23 +0100 Subject: Stabilize tst_QGraphicsWidget::updateFocusChainWhenChildDie(). Position windows, use QTRY_VERIFY. Change-Id: I185bcd91bcdffbc0460a4d24f685d3dde84338a7 Reviewed-by: Frederik Gladhorn --- .../graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 2dd2089f81..3271b31692 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include "../../../qtest-config.h" @@ -1780,8 +1781,11 @@ void tst_QGraphicsWidget::verifyFocusChain() void tst_QGraphicsWidget::updateFocusChainWhenChildDie() { + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(200, 150); + view.move(availableGeometry.topLeft() + QPoint(50, 50)); view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1801,6 +1805,9 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() QVERIFY(w1_1->hasFocus()); QWidget myWidget(0); QLineEdit edit(&myWidget); + (new QHBoxLayout(&myWidget))->addWidget(&edit); + edit.setMinimumWidth(160); // Windows + myWidget.move(availableGeometry.topLeft() + QPoint(350, 50)); myWidget.show(); edit.setFocus(); QTRY_VERIFY(edit.hasFocus()); @@ -1809,8 +1816,9 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() w->setParentItem(parent); //We don't crash perfect QVERIFY(w); - QTest::mouseMove(view.viewport()); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0); + const QPoint center(view.viewport()->width() / 2, view.viewport()->height() / 2); + QTest::mouseMove(view.viewport(), center); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, center); #ifdef Q_OS_MAC QEXPECT_FAIL("", "QTBUG-23699", Continue); #endif -- cgit v1.2.3 From 885bd1d0e57b9e0e5a7c4945866c2ef00ae30c92 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 16 Nov 2013 22:07:01 +0100 Subject: tst_QFileSystemModel: don't expect ~/Documents to exist For me, this test failed because I don't have a Documents folder in my home directory, even though that's what's returned from QStandardPaths as the first DocumentsLocation. Fix by falling back on the home directory if documentPaths.front() does not exist. Change-Id: I483f62f3b4b43d055c74774a7058a4aa420849b1 Reviewed-by: Friedemann Kleint --- .../widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 61a2abc084..9cb391d5f4 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -212,7 +212,14 @@ void tst_QFileSystemModel::rootPath() QString oldRootPath = model->rootPath(); const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); QVERIFY(!documentPaths.isEmpty()); - const QString documentPath = documentPaths.front(); + QString documentPath = documentPaths.front(); + // In particular on Linux, ~/Documents (the first + // DocumentsLocation) may not exist, so choose ~ in that case: + if (!QFile::exists(documentPath)) { + documentPath = QDir::homePath(); + qWarning("%s: first documentPath \"%s\" does not exist. Using ~ (\"%s\") instead.", + Q_FUNC_INFO, qPrintable(documentPaths.front()), qPrintable(documentPath)); + } root = model->setRootPath(documentPath); QTRY_VERIFY(model->rowCount(root) >= 0); -- cgit v1.2.3 From 6bf759b31040fb5d05044cd14d5889fbd19a8942 Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 11 Nov 2013 13:30:44 +0100 Subject: QTimeZone - Change Olsen ID to IANA ID The name Olson was misspelled as Olsen in the public api of QTimeZone which is needed to be fixed before first public release in 5.2 would freeze the api and prevent it being fixed. It has been decided that renaming as IANA ID would be more future-proof. Fixes to the private code will be done separately to keep this patch against release branch to the minimum required. Task-number: QTBUG-34735 Change-Id: I8ee90644862c907f6d1937b8536f0c02583ae736 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- .../auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index ed08bcefbf..ac8530bd54 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -371,7 +371,7 @@ void tst_QTimeZone::windowsId() { /* Current Windows zones for "Central Standard Time": - Region Olsen Id(s) + Region IANA Id(s) Default "America/Chicago" Canada "America/Winnipeg America/Rainy_River America/Rankin_Inlet America/Resolute" Mexico "America/Matamoros" @@ -380,24 +380,24 @@ void tst_QTimeZone::windowsId() "America/North_Dakota/New_Salem" AnyCountry "CST6CDT" */ - QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Chicago"), + QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Chicago"), QByteArray("Central Standard Time")); - QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Resolute"), + QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Resolute"), QByteArray("Central Standard Time")); // Partials shouldn't match - QCOMPARE(QTimeZone::olsenIdToWindowsId("America/Chi"), QByteArray()); - QCOMPARE(QTimeZone::olsenIdToWindowsId("InvalidZone"), QByteArray()); - QCOMPARE(QTimeZone::olsenIdToWindowsId(QByteArray()), QByteArray()); + QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Chi"), QByteArray()); + QCOMPARE(QTimeZone::ianaIdToWindowsId("InvalidZone"), QByteArray()); + QCOMPARE(QTimeZone::ianaIdToWindowsId(QByteArray()), QByteArray()); // Check default value - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time"), + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time"), QByteArray("America/Chicago")); - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time", QLocale::Canada), + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::Canada), QByteArray("America/Winnipeg")); - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId("Central Standard Time", QLocale::AnyCountry), + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::AnyCountry), QByteArray("CST6CDT")); - QCOMPARE(QTimeZone::windowsIdToDefaultOlsenId(QByteArray()), QByteArray()); + QCOMPARE(QTimeZone::windowsIdToDefaultIanaId(QByteArray()), QByteArray()); // No country is sorted list of all zones QList list; @@ -406,39 +406,39 @@ void tst_QTimeZone::windowsId() << "America/North_Dakota/Center" << "America/North_Dakota/New_Salem" << "America/Rainy_River" << "America/Rankin_Inlet" << "America/Resolute" << "America/Winnipeg" << "CST6CDT"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time"), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time"), list); // Check country with no match returns empty list list.clear(); - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::NewZealand), + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::NewZealand), list); // Check valid country returns list in preference order list.clear(); list << "America/Winnipeg" << "America/Rainy_River" << "America/Rankin_Inlet" << "America/Resolute"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::Canada), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Canada), list); list.clear(); list << "America/Matamoros"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::Mexico), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::Mexico), list); list.clear(); list << "America/Chicago" << "America/Indiana/Knox" << "America/Indiana/Tell_City" << "America/Menominee" << "America/North_Dakota/Beulah" << "America/North_Dakota/Center" << "America/North_Dakota/New_Salem"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::UnitedStates), + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::UnitedStates), list); list.clear(); list << "CST6CDT"; - QCOMPARE(QTimeZone::windowsIdToOlsenIds("Central Standard Time", QLocale::AnyCountry), + QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::AnyCountry), list); // Check no windowsId return empty list.clear(); - QCOMPARE(QTimeZone::windowsIdToOlsenIds(QByteArray()), list); - QCOMPARE(QTimeZone::windowsIdToOlsenIds(QByteArray(), QLocale::AnyCountry), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray()), list); + QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyCountry), list); } void tst_QTimeZone::utcTest() -- cgit v1.2.3 From 8e6258f059140ce735391b6438d5976dc9469e95 Mon Sep 17 00:00:00 2001 From: John Layt Date: Fri, 20 Sep 2013 18:35:08 +0200 Subject: QTimeZone - Fix TZ file abbreviations Fix parsing of TZ file abbreviations, to correctly return cases where POSIX rule doesn't have separate DST rules, and where abbreviation is a sub-string of another abbreviation, otherwise any toString() call will crash. Add test to exercise all available time zones, especially useful for TZ file to confirm all file format variations dealt with. Fix parsing of Version 3 of TZ file, and ICU display name, to allow all files generated from release 2013f to pass, otherwise isValid() call will crash. Task-number: QTBUG-34061 Change-Id: Ie0b6abc218adff1c8967eb33fdb0762041d2305f Reviewed-by: Thiago Macieira --- .../auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 54 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index ac8530bd54..cfb20f51e4 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -57,6 +57,7 @@ private slots: void nullTest(); void dataStreamTest(); void availableTimeZoneIds(); + void stressTest(); void windowsId(); // Backend tests void utcTest(); @@ -75,7 +76,7 @@ private: tst_QTimeZone::tst_QTimeZone() { - // Set to true to print debug output + // Set to true to print debug output, test Display Names and run long stress tests debug = false; } @@ -367,6 +368,50 @@ void tst_QTimeZone::availableTimeZoneIds() } } +void tst_QTimeZone::stressTest() +{ + QList idList = QTimeZone::availableTimeZoneIds(); + foreach (const QByteArray &id, idList) { + QTimeZone testZone = QTimeZone(id); + QCOMPARE(testZone.isValid(), true); + QCOMPARE(testZone.id(), id); + QDateTime testDate = QDateTime(QDate(2015, 1, 1), QTime(0, 0, 0), Qt::UTC); + testZone.country(); + testZone.comment(); + testZone.displayName(testDate); + testZone.displayName(QTimeZone::DaylightTime); + testZone.displayName(QTimeZone::StandardTime); + testZone.abbreviation(testDate); + testZone.offsetFromUtc(testDate); + testZone.standardTimeOffset(testDate); + testZone.daylightTimeOffset(testDate); + testZone.hasDaylightTime(); + testZone.isDaylightTime(testDate); + testZone.offsetData(testDate); + testZone.hasTransitions(); + testZone.nextTransition(testDate); + testZone.previousTransition(testDate); + // Dates known to be outside possible tz file pre-calculated rules range + QDateTime lowDate1 = QDateTime(QDate(1800, 1, 1), QTime(0, 0, 0), Qt::UTC); + QDateTime lowDate2 = QDateTime(QDate(1800, 6, 1), QTime(0, 0, 0), Qt::UTC); + QDateTime highDate1 = QDateTime(QDate(2200, 1, 1), QTime(0, 0, 0), Qt::UTC); + QDateTime highDate2 = QDateTime(QDate(2200, 6, 1), QTime(0, 0, 0), Qt::UTC); + testZone.nextTransition(lowDate1); + testZone.nextTransition(lowDate2); + testZone.previousTransition(lowDate2); + testZone.previousTransition(lowDate2); + testZone.nextTransition(highDate1); + testZone.nextTransition(highDate2); + testZone.previousTransition(highDate1); + testZone.previousTransition(highDate2); + if (debug) { + // This could take a long time, depending on platform and database + qDebug() << "Stress test calculating transistions for" << testZone.id(); + testZone.transitions(lowDate1, highDate1); + } + } +} + void tst_QTimeZone::windowsId() { /* @@ -639,10 +684,11 @@ void tst_QTimeZone::tzTest() QCOMPARE(dat.standardTimeOffset, 3600); QCOMPARE(dat.daylightTimeOffset, 0); + // Test previous to low value is invalid dat = tzp.previousTransition(-9999999999999); - QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000); - QCOMPARE(dat.standardTimeOffset, 3600); - QCOMPARE(dat.daylightTimeOffset, 0); + QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits::min()); + QCOMPARE(dat.standardTimeOffset, std::numeric_limits::min()); + QCOMPARE(dat.daylightTimeOffset, std::numeric_limits::min()); dat = tzp.nextTransition(-9999999999999); QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000); -- cgit v1.2.3 From 6ad97bfa736c97b50019d0192f55959848e7067a Mon Sep 17 00:00:00 2001 From: John Layt Date: Sat, 2 Nov 2013 18:53:32 +0100 Subject: QTimeZone - Fix dateForLocalTime() to check validity of next transition The private method dateForLocalTime() was not checking that transitions were valid, resulting in infinite looping when a time zone didn't have any future transitions. Change-Id: I0e5d07063861778dd86056a80c36fdd9f9d36133 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 6 ++++++ tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 1e2b0ed649..6c80c5ff47 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2903,6 +2903,12 @@ void tst_QDateTime::timeZones() const // - Test 03:00:00 = 1 hour after tran hourAfterStd = QDateTime(QDate(2013, 10, 27), QTime(3, 0, 0), cet); QCOMPARE(hourAfterStd.toMSecsSinceEpoch(), dstToStdMSecs + 3600000); + + // Test Time Zone that has transitions but no future transitions afer a given date + QTimeZone sgt("Asia/Singapore"); + QDateTime future(QDate(2015, 1, 1), QTime(0, 0, 0), sgt); + QVERIFY(future.isValid()); + QCOMPARE(future.offsetFromUtc(), 28800); } void tst_QDateTime::invalid() const diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index cfb20f51e4..d7643ff55d 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -409,6 +409,10 @@ void tst_QTimeZone::stressTest() qDebug() << "Stress test calculating transistions for" << testZone.id(); testZone.transitions(lowDate1, highDate1); } + testDate.setTimeZone(testZone); + testDate.isValid(); + testDate.offsetFromUtc(); + testDate.timeZoneAbbreviation(); } } -- cgit v1.2.3 From b4bb70973328d251ecf33ec58722bdb5d32366ed Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 15 Nov 2013 13:38:03 +0100 Subject: Remove QMacStyle titlebar height + 4 adjustment and consequences This was a tweak to fix a bug in 2005 which has probably outlived its usefulness, plus an accumulation of workarounds on top. (started as 48b5266e8ff9b472a16290dd923fe24dd0b6989b in the historical repo) Task-number: QTBUG-34760 Change-Id: I2c01269e43636385ee5c89305c6b90f4a7f2c537 Reviewed-by: Gabriel de Dietrich --- tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 5b146cf443..b3e50b8ba8 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -954,9 +954,6 @@ void tst_QMdiSubWindow::mouseDoubleClick() QStyleOptionTitleBar options; options.initFrom(window); int height = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); - // ### Remove this after mac style has been fixed - if (window->style()->inherits("QMacStyle")) - height -= 4; // has border if (!window->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, window)) height += window->isMinimized() ? 8 : 4; @@ -1692,11 +1689,6 @@ void tst_QMdiSubWindow::fixedMinMaxSize() QStyleOptionTitleBar options; options.initFrom(subWindow); int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) - // ### Remove this after mac style has been fixed - if (subWindow->style()->inherits("QMacStyle")) - minimizedHeight -= 4; -#endif if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow)) minimizedHeight += 8; int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MDIMinimizedWidth, &options); -- cgit v1.2.3 From 773610cc451bb2b4319da6567b21510022d08014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 21 Nov 2013 14:43:40 +0100 Subject: Revert "Ensure Qt::WA_Mapped is set in case of obscured native windows." Qt::WA_Mapped maps (sic) to windowHandle()->isExposed(), and we set/update it in QWidgetWindow::handleExposeEvent(). Setting it directly in show_sys shortcuts QPA and assumes showing a window is synchronous on all platforms, resulting in trying to flush the widget backingstore when the window was not exposed yet (due to discardSyncRequest starting to return false). This reverts commit 829b1d13b225e87b8a385397e2b53c7a9f8cda9e. Change-Id: I0bd700d4939bc69ba184d8586435b68ec3dd72fb Reviewed-by: Gunnar Sletta --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 4 ---- .../kernel/qwidget_window/tst_qwidget_window.cpp | 28 ---------------------- 2 files changed, 32 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 7bb5fd4614..03d6c1cdbd 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -7192,10 +7192,6 @@ void tst_QWidget::hideOpaqueChildWhileHidden() #if !defined(Q_OS_WINCE) void tst_QWidget::updateWhileMinimized() { -#ifdef Q_OS_UNIX - if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) - QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. -#endif // Q_OS_UNIX UpdateWidget widget; // Filter out activation change and focus events to avoid update() calls in QWidget. widget.updateOnActivationChangeAndFocusIn = false; diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index f5585c583a..1bbbfd610e 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -91,8 +91,6 @@ private slots: void tst_showWithoutActivating(); void tst_paintEventOnSecondShow(); - void obscuredNativeMapped(); - #ifndef QT_NO_DRAGANDDROP void tst_dnd(); #endif @@ -370,32 +368,6 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() QTRY_VERIFY(w.paintEventReceived); } -// QTBUG-33520, a toplevel fully obscured by native children should still receive Qt::WA_Mapped -void tst_QWidget_window::obscuredNativeMapped() -{ - enum { size = 200 }; - - QWidget topLevel; - topLevel.setWindowFlags(Qt::FramelessWindowHint); - QWidget *child = new QWidget(&topLevel); - child->resize(size, size); - topLevel.resize(size, size); - topLevel.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(size /2 , size / 2)); - child->winId(); - topLevel.show(); - QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); -#if defined(Q_OS_MAC) - QSKIP("This test fails on Mac."); // Minimized windows are not unmapped for some reason. -#elif defined(Q_OS_UNIX) - if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) - QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. -#endif // Q_OS_UNIX - topLevel.setWindowState(Qt::WindowMinimized); - QTRY_VERIFY(!topLevel.testAttribute(Qt::WA_Mapped)); - topLevel.setWindowState(Qt::WindowNoState); - QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); -} - #ifndef QT_NO_DRAGANDDROP /* DnD test for QWidgetWindow (handleDrag*Event() functions). -- cgit v1.2.3 From 219455951bec627528a3674c3b49409f3391f7a4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 15 Oct 2013 12:59:49 +0200 Subject: Center/position windows in tst_qmenu. Avoid menus showing up at 0,0 which is a taskbar area when running Unity. Task-number: QTBUG-33972 Change-Id: I156eec78248cec1708adf6bcf2e9ddcc98b7d8c4 Reviewed-by: Frederik Gladhorn --- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 53 +++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 7c1bb957d6..81ed983d0f 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,17 @@ Q_DECLARE_METATYPE(Qt::Key); Q_DECLARE_METATYPE(Qt::KeyboardModifiers); +static inline void centerOnScreen(QWidget *w, const QSize &size) +{ + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + +static inline void centerOnScreen(QWidget *w) +{ + centerOnScreen(w, w->geometry().size()); +} + class tst_QMenu : public QObject { Q_OBJECT @@ -257,9 +269,12 @@ void tst_QMenu::addActionsAndClear() void tst_QMenu::mouseActivation() { QWidget topLevel; + topLevel.resize(300, 200); + centerOnScreen(&topLevel); QMenu menu(&topLevel); topLevel.show(); menu.addAction("Menu Action"); + menu.move(topLevel.geometry().topRight() + QPoint(50, 0)); menu.show(); QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center(), 300); QVERIFY(!menu.isVisible()); @@ -275,8 +290,10 @@ void tst_QMenu::mouseActivation() QMenu submenu("Menu"); submenu.addAction("action"); QAction *action = menubar.addMenu(&submenu); + menubar.move(topLevel.geometry().topRight() + QPoint(300, 0)); menubar.show(); + QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300); QVERIFY(submenu.isVisible()); QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300); @@ -378,13 +395,16 @@ void tst_QMenu::focus() #endif QWidget window; + window.resize(300, 200); QPushButton button("Push me", &window); + centerOnScreen(&window); window.show(); qApp->setActiveWindow(&window); QVERIFY(button.hasFocus()); QCOMPARE(QApplication::focusWidget(), (QWidget *)&button); QCOMPARE(QApplication::activeWindow(), &window); + menu.move(window.geometry().topRight() + QPoint(50, 0)); menu.show(); QVERIFY(button.hasFocus()); QCOMPARE(QApplication::focusWidget(), (QWidget *)&button); @@ -399,6 +419,8 @@ void tst_QMenu::overrideMenuAction() { //test the override menu action by first creating an action to which we set its menu QMainWindow w; + w.resize(300, 200); + centerOnScreen(&w); QAction *aFileMenu = new QAction("&File", &w); w.menuBar()->addAction(aFileMenu); @@ -442,6 +464,8 @@ void tst_QMenu::statusTip() { //check that the statustip of actions inserted into the menu are displayed QMainWindow w; + w.resize(300, 200); + centerOnScreen(&w); connect(w.statusBar(), SIGNAL(messageChanged(QString)), SLOT(onStatusMessageChanged(QString)));; //creates the status bar QToolBar tb; QAction a("main action", &tb); @@ -540,10 +564,12 @@ void tst_QMenu::tearOff() menu->addAction("bbb"); QVERIFY(menu->isTearOffEnabled()); + widget.resize(300, 200); + centerOnScreen(&widget); widget.show(); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); - menu->popup(QPoint(0,0)); + menu->popup(widget.geometry().topRight() + QPoint(50, 0)); QVERIFY(QTest::qWaitForWindowActive(menu)); QVERIFY(!menu->isTearOffMenuVisible()); @@ -568,14 +594,18 @@ void tst_QMenu::layoutDirection() { QMainWindow win; win.setLayoutDirection(Qt::RightToLeft); + win.resize(300, 200); + centerOnScreen(&win); QMenu menu(&win); + menu.move(win.geometry().topRight() + QPoint(50, 0)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); menu.close(); menu.setParent(0); + menu.move(win.geometry().topRight() + QPoint(50, 0)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QCOMPARE(menu.layoutDirection(), QApplication::layoutDirection()); @@ -702,6 +732,7 @@ void tst_QMenu::task256918_setFont() QFont f; f.setPointSize(30); action->setFont(f); + centerOnScreen(&menu, QSize(120, 40)); menu.show(); //ensures that the actiongeometry are calculated QVERIFY(menu.actionGeometry(action).height() > f.pointSize()); } @@ -830,6 +861,13 @@ void PopulateOnAboutToShowTestMenu::populateMenu() addSeparator(); } +static inline QByteArray msgGeometryIntersects(const QRect &r1, const QRect &r2) +{ + QString result; + QDebug(&result) << r1 << "intersects" << r2; + return result.toLocal8Bit(); +} + void tst_QMenu::pushButtonPopulateOnAboutToShow() { QPushButton b("Test PushButton"); @@ -842,7 +880,7 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow() const QRect screen = QApplication::desktop()->screenGeometry(scrNumber); QRect desiredGeometry = b.geometry(); - desiredGeometry.moveTopLeft(QPoint(10, screen.bottom()-b.height()-5)); + desiredGeometry.moveTopLeft(QPoint(screen.x() + 10, screen.bottom() - b.height() - 5)); b.setGeometry(desiredGeometry); QVERIFY(QTest::qWaitForWindowExposed(&b)); @@ -859,13 +897,13 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow() QTimer::singleShot(300, buttonMenu, SLOT(hide())); QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); - QVERIFY(!buttonMenu->geometry().intersects(b.geometry())); + QVERIFY2(!buttonMenu->geometry().intersects(b.geometry()), msgGeometryIntersects(buttonMenu->geometry(), b.geometry())); // note: we're assuming that, if we previously got the desired geometry, we'll get it here too b.move(10, screen.bottom()-buttonMenu->height()-5); QTimer::singleShot(300, buttonMenu, SLOT(hide())); QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); - QVERIFY(!buttonMenu->geometry().intersects(b.geometry())); + QVERIFY2(!buttonMenu->geometry().intersects(b.geometry()), msgGeometryIntersects(buttonMenu->geometry(), b.geometry())); } void tst_QMenu::QTBUG7907_submenus_autoselect() @@ -878,6 +916,7 @@ void tst_QMenu::QTBUG7907_submenus_autoselect() set1.addMenu(&subset); menu.addMenu(&set1); menu.addMenu(&set2); + centerOnScreen(&menu, QSize(120, 100)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) ); @@ -893,6 +932,7 @@ void tst_QMenu::QTBUG7411_submenus_activate() sub1.addAction("foo"); sub1.setTitle("&sub1"); QAction *act1 = menu.addMenu(&sub1); + centerOnScreen(&menu, QSize(120, 100)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); menu.setActiveAction(act); @@ -911,12 +951,12 @@ void tst_QMenu::QTBUG30595_rtl_submenu() sub.addAction("bar"); sub.setTitle("&sub"); menu.addMenu(&sub); - menu.move(200, 20); + centerOnScreen(&menu, QSize(120, 40)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) ); QTRY_VERIFY(sub.isVisible()); - QVERIFY(sub.pos().x() < menu.pos().x()); + QVERIFY2(sub.pos().x() < menu.pos().x(), QByteArray::number(sub.pos().x()) + QByteArrayLiteral(" not less than ") + QByteArray::number(menu.pos().x())); } void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() @@ -927,6 +967,7 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() subsub1.addAction("foo"); sub1.addMenu(&subsub1); menu.addMenu(&sub1); + centerOnScreen(&menu, QSize(120, 100)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QTest::keyPress(&menu, Qt::Key_S); -- cgit v1.2.3 From f805020410c8ccb0cd223988565bcabde1c5806b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 15 Nov 2013 09:46:02 +0100 Subject: Fix a race that occurred as we unlock the mutex to destroy the functor in ~QObject When we unlock the mutex, we need to take in account that the Connection pointed by 'node' may be destroyed in another thread while it is unlocked Doing 'node->prev = &node' will make sure that 'node' is actually updated when it is destroyed. Setting isSlotObject under the mutex is safer and ensure that no other thread will attempt to deref the object. The regression was introduced in 5885b8f775998c30d53f40b7f368c5f6364e6df4 tst_qobjectrace was updated to catch races arising when we are connecting with function pointers. Change-Id: Ia0d11ae8df563dad97eb86993a786b579b28cd03 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Lars Knoll --- tests/auto/other/qobjectrace/tst_qobjectrace.cpp | 76 ++++++++++++++++++------ 1 file changed, 57 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp index ab05c64fe5..71a90e83f7 100644 --- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp @@ -47,6 +47,12 @@ enum { OneMinute = 60 * 1000, TwoMinutes = OneMinute * 2 }; + +struct Functor +{ + void operator()() const {}; +}; + class tst_QObjectRace: public QObject { Q_OBJECT @@ -122,11 +128,7 @@ signals: private slots: void checkStopWatch() { -#if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS) - if (stopWatch.elapsed() >= OneMinute / 2) -#else - if (stopWatch.elapsed() >= OneMinute) -#endif + if (stopWatch.elapsed() >= 5000) quit(); QObject o; @@ -188,16 +190,34 @@ class MyObject : public QObject void signal7(); }; +namespace { +const char *_slots[] = { SLOT(slot1()) , SLOT(slot2()) , SLOT(slot3()), + SLOT(slot4()) , SLOT(slot5()) , SLOT(slot6()), + SLOT(slot7()) }; + +const char *_signals[] = { SIGNAL(signal1()), SIGNAL(signal2()), SIGNAL(signal3()), + SIGNAL(signal4()), SIGNAL(signal5()), SIGNAL(signal6()), + SIGNAL(signal7()) }; +typedef void (MyObject::*PMFType)(); +const PMFType _slotsPMF[] = { &MyObject::slot1, &MyObject::slot2, &MyObject::slot3, + &MyObject::slot4, &MyObject::slot5, &MyObject::slot6, + &MyObject::slot7 }; + +const PMFType _signalsPMF[] = { &MyObject::signal1, &MyObject::signal2, &MyObject::signal3, + &MyObject::signal4, &MyObject::signal5, &MyObject::signal6, + &MyObject::signal7 }; + +} class DestroyThread : public QThread { Q_OBJECT - QObject **objects; + MyObject **objects; int number; public: - void setObjects(QObject **o, int n) + void setObjects(MyObject **o, int n) { objects = o; number = n; @@ -206,8 +226,29 @@ public: } void run() { - for(int i = 0; i < number; i++) + for (int i = number-1; i >= 0; --i) { + /* Do some more connection and disconnection between object in this thread that have not been destroyed yet */ + + const int nAlive = i+1; + connect (objects[((i+1)*31) % nAlive], _signals[(12*i)%7], objects[((i+2)*37) % nAlive], _slots[(15*i+2)%7] ); + disconnect(objects[((i+1)*31) % nAlive], _signals[(12*i)%7], objects[((i+2)*37) % nAlive], _slots[(15*i+2)%7] ); + + connect (objects[((i+4)*41) % nAlive], _signalsPMF[(18*i)%7], objects[((i+5)*43) % nAlive], _slotsPMF[(19*i+2)%7] ); + disconnect(objects[((i+4)*41) % nAlive], _signalsPMF[(18*i)%7], objects[((i+5)*43) % nAlive], _slotsPMF[(19*i+2)%7] ); + + QMetaObject::Connection c = connect(objects[((i+5)*43) % nAlive], _signalsPMF[(9*i+1)%7], Functor()); + disconnect(c); + + disconnect(objects[i], _signalsPMF[(10*i+5)%7], 0, 0); + disconnect(objects[i], _signals[(11*i+6)%7], 0, 0); + + disconnect(objects[i], 0, objects[(i*17+6) % nAlive], 0); + if (i%4 == 1) { + disconnect(objects[i], 0, 0, 0); + } + delete objects[i]; + } } }; @@ -216,27 +257,24 @@ public: void tst_QObjectRace::destroyRace() { - enum { ThreadCount = 10, ObjectCountPerThread = 733, + enum { ThreadCount = 10, ObjectCountPerThread = 2777, ObjectCount = ThreadCount * ObjectCountPerThread }; - const char *_slots[] = { SLOT(slot1()) , SLOT(slot2()) , SLOT(slot3()), - SLOT(slot4()) , SLOT(slot5()) , SLOT(slot6()), - SLOT(slot7()) }; - - const char *_signals[] = { SIGNAL(signal1()), SIGNAL(signal2()), SIGNAL(signal3()), - SIGNAL(signal4()), SIGNAL(signal5()), SIGNAL(signal6()), - SIGNAL(signal7()) }; - - QObject *objects[ObjectCount]; + MyObject *objects[ObjectCount]; for (int i = 0; i < ObjectCount; ++i) objects[i] = new MyObject; - for (int i = 0; i < ObjectCount * 11; ++i) { + for (int i = 0; i < ObjectCount * 17; ++i) { connect(objects[(i*13) % ObjectCount], _signals[(2*i)%7], objects[((i+2)*17) % ObjectCount], _slots[(3*i+2)%7] ); connect(objects[((i+6)*23) % ObjectCount], _signals[(5*i+4)%7], objects[((i+8)*41) % ObjectCount], _slots[(i+6)%7] ); + + connect(objects[(i*67) % ObjectCount], _signalsPMF[(2*i)%7], + objects[((i+1)*71) % ObjectCount], _slotsPMF[(3*i+2)%7] ); + connect(objects[((i+3)*73) % ObjectCount], _signalsPMF[(5*i+4)%7], + objects[((i+5)*79) % ObjectCount], Functor() ); } DestroyThread *threads[ThreadCount]; -- cgit v1.2.3 From db4afbef7d1e2405a3b8f007e9009f509b4a3eac Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 25 Nov 2013 20:36:58 +0100 Subject: QPrinterInfo - Fix isNull() by fixing constructors The QPrinterInfo copy and QPrinter constructors and the assignment operator were not taking the shared_null into account, and so any use of them resulted in a new null QPrinterInfo different to shared_null, which lead to isNull() always returning true in anything other than the simplest use case. While fixing this also make the shared_null a Q_GLOBAL_STATIC. Task-number: QTBUG-21087 Change-Id: I0beb24088208e9ed58d21ca26b0c8d00b02e5b8f Reviewed-by: Gunnar Sletta --- tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index 7deb31c2c9..9416224440 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -275,6 +275,9 @@ void tst_QPrinterInfo::testConstructors() QCOMPARE(null.printerName(), QString()); QVERIFY(null.isNull()); + QPrinterInfo null2(null); + QVERIFY(null2.isNull()); + QList printers = QPrinterInfo::availablePrinters(); for (int i = 0; i < printers.size(); ++i) { @@ -295,6 +298,12 @@ void tst_QPrinterInfo::testConstructors() void tst_QPrinterInfo::testAssignment() { + QPrinterInfo null; + QVERIFY(null.isNull()); + QPrinterInfo null2; + null2 = null; + QVERIFY(null2.isNull()); + QList printers = QPrinterInfo::availablePrinters(); for (int i = 0; i < printers.size(); ++i) { -- cgit v1.2.3 From 1c2be58fecaff1de5f2849192eb712984ebd59bd Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 26 Nov 2013 11:00:31 +0200 Subject: Fix test compilation on WinRT Tweak a handful of tests which didn't compile on this platform. Change-Id: I208d9eb289dfb226746c6d0163c3ea752485033b Reviewed-by: Friedemann Kleint Reviewed-by: Frederik Gladhorn --- .../auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp | 10 +++++++--- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 6 +++--- .../io/qprocess/testProcessLoopback/testProcessLoopback.pro | 1 + tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp | 4 +++- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index 7d041e69cb..ac8d433f96 100644 --- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -49,9 +49,13 @@ #ifdef Q_OS_UNIX #include #endif -#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) -#include -#define sleep(X) Sleep(X) +#if defined(Q_OS_WIN) +# include +# ifndef Q_OS_WINRT +# define sleep(X) Sleep(X) +# else +# define sleep(X) WaitForSingleObjectEx(GetCurrentThread(), X, FALSE); +# endif #endif //on solaris, threads that loop on the release bool variable diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 03d6c1cdbd..36a3a8bad5 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -171,7 +171,7 @@ static inline void centerOnScreen(QWidget *w) w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) static inline void setWindowsAnimationsEnabled(bool enabled) { ANIMATIONINFO animation = { sizeof(ANIMATIONINFO), enabled }; @@ -184,10 +184,10 @@ static inline bool windowsAnimationsEnabled() SystemParametersInfo(SPI_GETANIMATION, 0, &animation, 0); return animation.iMinAnimate; } -#else // Q_OS_WIN && !Q_OS_WINCE +#else // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT inline void setWindowsAnimationsEnabled(bool) {} static inline bool windowsAnimationsEnabled() { return false; } -#endif // !Q_OS_WIN || Q_OS_WINCE +#endif // !Q_OS_WIN || Q_OS_WINCE || Q_OS_WINRT class tst_QWidget : public QObject { diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro index 3940ddbf98..8fd4db6b4b 100644 --- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro +++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro @@ -1,5 +1,6 @@ SOURCES = main.cpp CONFIG -= qt app_bundle CONFIG += console +winrt: QMAKE_LFLAGS += /ENTRY:mainCRTStartup DESTDIR = ./ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp index a7480e6afe..47227ef630 100644 --- a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp @@ -88,7 +88,9 @@ void NativeMutexUnlock(NativeMutexType *mutex) } #endif #elif defined(Q_OS_WIN) -# define _WIN32_WINNT 0x0400 +# ifndef Q_OS_WINRT +# define _WIN32_WINNT 0x0400 +# endif # include typedef CRITICAL_SECTION NativeMutexType; void NativeMutexInitialize(NativeMutexType *mutex) -- cgit v1.2.3