diff options
Diffstat (limited to 'tests/auto')
323 files changed, 12133 insertions, 4049 deletions
diff --git a/tests/auto/android/runtests_androiddeployqt.pl b/tests/auto/android/runtests_androiddeployqt.pl deleted file mode 100755 index 24b44cf9b2..0000000000 --- a/tests/auto/android/runtests_androiddeployqt.pl +++ /dev/null @@ -1,550 +0,0 @@ -#!/usr/bin/perl -w -############################################################################# -## -## Copyright (C) 2012-2013 BogDan Vatra <bogdan@kde.org> -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -use Cwd; -use Cwd 'abs_path'; -use File::Basename; -use File::Temp 'tempdir'; -use File::Path 'remove_tree'; -use Getopt::Long; -use Pod::Usage; -use XML::Simple; -use Term::ANSIColor; - -### default options -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 = ""; -my $man = 0; -my $help = 0; -my $make_clean = 0; -my $stop_on_fail = 0; -my $time_out=400; -my $android_toolchain_version = "4.8"; -my $host_arch = "linux-x86"; -my $android_sdk_dir = "$ENV{'ANDROID_SDK_ROOT'}"; -my $android_ndk_dir = "$ENV{'ANDROID_NDK_ROOT'}"; -my $android_to_connect = "$ENV{'ANDROID_DEVICE'}"; -my $ant_tool = `which ant`; -my $silent = 0; -chomp $ant_tool; -my $strip_tool=""; -my $readelf_tool=""; -# for ci usage -my @failures = ''; -my $total_tests = 0; -my $total_failed = 0; -my $failed_insignificants = 0; -my $ci_use = 0; -my $start = time(); -my $uninstall = 0; - -GetOptions('h|help' => \$help - , man => \$man - , 's|serial=s' => \$device_serial - , '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 - , 'host=s' => \$host_arch - , 'ant=s' => \$ant_tool - , 'strip=s' => \$strip_tool - , 'readelf=s' => \$readelf_tool - , 'testcase=s' => \$testcase - , 'f|fail' => sub { $stop_on_fail = 1 } - , 'silent' => sub { $silent = 1 } - , 'ci' => sub { $ci_use = 1 } - , 'uninstall' => sub { $uninstall = 1 } - ) or pod2usage(2); -pod2usage(1) if $help; -pod2usage(-verbose => 2) if $man; - -if ($ci_use){ - use QMake::Project; -} -my $adb_tool="$android_sdk_dir/platform-tools/adb"; - -# For CI. Nodes are connecting to test devices over IP, which is stored to env variable -if ($android_to_connect ne ""){ - print " Found device to be connected from env: $android_to_connect \n"; - system("$adb_tool disconnect $android_to_connect"); - system("$adb_tool connect $android_to_connect"); - sleep(2);# let it connect - system("$adb_tool -s $android_to_connect reboot &");# adb bug, it blocks forever - sleep(15); # wait for the device to come up again - system("$adb_tool disconnect $android_to_connect");# cleans up the left adb reboot process - system("$adb_tool connect $android_to_connect"); - $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); -$device_serial = "-s $device_serial" if ($device_serial); -$testsubset="/$testsubset" if ($testsubset); - -$strip_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-$android_toolchain_version/prebuilt/$host_arch/bin/arm-linux-androideabi-strip" unless($strip_tool); -$readelf_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-$android_toolchain_version/prebuilt/$host_arch/bin/arm-linux-androideabi-readelf" unless($readelf_tool); -$readelf_tool="$readelf_tool -d -w "; - -sub dir -{ -# print "@stack\n"; -} - -sub pushd ($) -{ - unless ( chdir $_[0] ) - { - warn "Error: $!\n"; - return; - } - unshift @stack, cwd; - dir; -} - -sub popd () -{ - @stack > 1 and shift @stack; - chdir $stack[0]; - dir; -} - -############################## -# Read possible insignificance -# from pro file -############################## -sub check_if_insignificant -{ - return 0 if ( !$ci_use ); - my $case = shift; - my $insignificant = 0; - my $prj = QMake::Project->new( 'Makefile' ); - $insignificant = $prj->test( 'insignificant_test' ); - return $insignificant; -} - -############################## -# Print output from given -# $testresult.txt file -############################## -sub print_output -{ - my $res_file = shift; - my $case = shift; - my $insignificant = shift; - my $print_all = 0; - $total_tests++; - if (-e $res_file) { - open my $file, $res_file or die "Could not open $res_file: $!"; - while (my $line = <$file>) { - if ($line =~ m/^FAIL/) { - print "$line"; - # Pretend to be like the "real" testrunner and print out - # all steps - $print_all = 1; - } - } - close $file; - if ($print_all) { - # In case we are printing all, the test failed - system("cat $res_file"); - if ($insignificant) { - print " Testrunner: $case failed, but it is marked with insignificant_test\n"; - push (@failures ,(basename($case)." [insignificant]")); - $failed_insignificants++; - } else { - $total_failed++; - push (@failures ,(basename($case))); - } - } else { - my $cmd = "sed -n 'x;\$p' ${res_file}"; - my $summary = qx(${cmd}); - if ($summary =~ m/^Totals/) { - print "$summary"; - } else { - print "Error: The log is incomplete. Looks like you have to increase the timeout."; - # The test log seems inclomplete, considering the test as failed. - if ($insignificant) { - print " Testrunner: $case failed, but it is marked with insignificant_test\n"; - push (@failures ,(basename($case)." [insignificant]")); - $failed_insignificants++; - } else { - $total_failed++; - push (@failures ,(basename($case))); - } - } - } - } else { - if ($insignificant) { - print " Failed to execute $case, but it is marked with insignificant_test\n"; - push (@failures ,(basename($case)." [insignificant]")); - $failed_insignificants++; - } else { - print "Failed to execute $case \n"; - $total_failed++; - push (@failures ,(basename($case))); - } - } -} - -############################## -# Print summary of test run -############################## - -sub print_summary -{ - my $total = time()-$start; - my $h = 0; - my $m = 0; - my $s = 0; - my $exit = 0; - print "=== Timing: =================== TEST RUN COMPLETED! ============================\n"; - if ($total > 60*60) { - $h = int($total/60/60); - $s = int($total - $h*60*60); - - $m = int($s/60); - $s = 0; - print "Total: $h hours $m minutes\n"; - } elsif ($total > 60) { - $m = int($total/60); - $s = int($total - $m*60); - print "Total: $m minutes $s seconds\n"; - } else { - $s = int($total); - print "Total: $s seconds\n"; - } - - print "=== Failures: =================================================================="; - foreach my $failed (@failures) { - print $failed."\n"; - $exit = 1; - } - print "=== Totals: ".$total_tests." tests, ".($total_tests-$total_failed). - " passes, ".$failed_insignificants. - " insignificant fails ======================\n"; - return $exit; -} - - -sub waitForProcess -{ - my $process=shift; - my $action=shift; - my $timeout=shift; - my $sleepPeriod=shift; - $sleepPeriod=1 if !defined($sleepPeriod); - print "Waiting for $process ".$timeout*$sleepPeriod." seconds to" if (!$silent); - print $action?" start...\n":" die...\n" if (!$silent); - while ($timeout--) - { - my $output = `$adb_tool $device_serial shell ps 2>&1`; # get current processes - #FIXME check why $output is not matching m/.*S $process\n/ or m/.*S $process$/ (eol) - my $res=($output =~ m/.*S $process/)?1:0; # check the procress - if ($action == $res) - { - print "... succeed\n" if (!$silent); - return 1; - } - sleep($sleepPeriod); - print "timeount in ".$timeout*$sleepPeriod." seconds\n" if (!$silent); - } - print "... failed\n" if (!$silent); - return 0; -} - -my $src_dir_qt=abs_path(dirname($0)."/../../.."); -my $quadruplor_dir="$src_dir_qt/tests/auto/android"; -my $qmake_path="$src_dir_qt/bin/qmake"; -my $androiddeployqt_path="$src_dir_qt/bin/androiddeployqt"; -my $tests_dir="$src_dir_qt/tests$testsubset"; -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+)\]/) -{ - $sdk_api=int($1); - $sdk_api=5 if ($sdk_api>5 && $sdk_api<8); - $sdk_api=9 if ($sdk_api>9); -} - -sub checkXMLOutput -{ - print color 'bold red'; - my $fileName = shift; - my $XMLOutput = eval { XMLin($fileName, ForceArray => 1) }; - if (!defined($XMLOutput)) { - print "Can't parse the $fileName file, probably the test crased.\n"; - print color 'reset'; - die "Stopping\n" if $stop_on_fail; - return; - } - my $testName = $XMLOutput->{name}; - my $fail = 0; - while (my($node_key, $node_valule) = each (%{$XMLOutput})) { - next if $node_key ne "TestFunction"; - while (my($function_key, $function_valule) = each (%{$node_valule})) { - while (my($test_key, $test_valule) = each (%{$function_valule})) { - next if $test_key ne "Incident"; - for my $incident (@{$test_valule}) { - if (($incident->{type} ne "pass") && ($incident->{type} ne "xfail")) { - print "test $testName::$function_key failed $incident->{file}:$incident->{line}\n"; - $fail = 1; - } - } - } - } - } - print color 'reset'; - die "Stopping\n" if $stop_on_fail and $fail; -} - -sub startTest -{ - my $testName = shift; - my $packageName = "org.qtproject.example.tst_$testName"; - my $intentName = "$packageName/org.qtproject.qt5.android.bindings.QtActivity"; - my $output_file = shift; - my $insignificance = 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; - } - - my $cmd="${adb_tool} ${device_serial} shell am start -e applicationArguments \"${testLib}\" -n ${intentName}"; - my $res = qx(${cmd}); - print $res if (!$silent); - #wait to start (if it has not started and quit already) - waitForProcess($packageName,1,10); - - #wait to stop - unless(waitForProcess($packageName,0,$time_out,5)) - { - #killProcess($packageName); - print "Someone should kill $packageName\n"; - system("$adb_tool $device_serial uninstall $packageName") if ($uninstall); - return 1; - } - - # Wait for three seconds to allow process to write all data - sleep(3); - - 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); - if ($get_txt){ - print "Test results for $packageName:\n"; - my $insig = - print_output("$output_dir/$output_file.txt", $packageName, $insignificance); - } - system("$adb_tool $device_serial uninstall $packageName") if ($uninstall); - - checkXMLOutput("$output_dir/$output_file.xml") if ($get_xml); - return 1; -} - -########### build qt tests and benchmarks ########### -pushd($tests_dir); -print "Building $tests_dir \n"; -system("make distclean") if ($make_clean); -system("$qmake_path -r") == 0 or die "Can't run qmake\n"; #exec qmake -system("make -j$jobs") == 0 or warn "Can't build all tests\n"; #exec make - -my $testsFiles = ""; -if ($testcase) { - $testsFiles=`find . -name libtst_$testcase.so`; # only tests -} else { - $testsFiles=`find . -name libtst_*.so`; # only tests -} - -foreach (split("\n",$testsFiles)) -{ - chomp; #remove white spaces - pushd(abs_path(dirname($_))); # cd to application dir - my $insig = check_if_insignificant(); - my $cmd="make INSTALL_ROOT=${temp_dir} install"; - my $res = qx(${cmd}); - print $res if (!$silent); - my $application=basename(cwd); - if ($silent) { - $cmd="$androiddeployqt_path --install ${deployqt_device_serial} --output ${temp_dir} --deployment debug --verbose --input android-libtst_${application}.so-deployment-settings.json >/dev/null 2>&1"; - } else { - $cmd="$androiddeployqt_path --install ${deployqt_device_serial} --output ${temp_dir} --deployment debug --verbose --input android-libtst_${application}.so-deployment-settings.json"; - } - $res = qx(${cmd}); - print $res if (!$silent); - my $output_name=dirname($_); - $output_name =~ s/\.//; # remove first "." character - $output_name =~ s/\///; # remove first "/" character - $output_name =~ s/\//_/g; # replace all "/" with "_" - $output_name=$application unless($output_name); - $time_out=$max_runtime*60/5; # 5 minutes time out for a normal test - - $applicationLibrary = `find $temp_dir -name libtst_bench_$application.so`; - - if ($applicationLibrary) - { - $time_out=5*60/5; # 10 minutes for a benchmark - $application = "bench_$application"; - } - else - { - $applicationLibrary = `find $temp_dir -name libtst_$application.so`; - } - - if (!$applicationLibrary) - { - print "Can't find application binary libtst_$application.so in $temp_dir!\n"; - } - else - { - startTest($application, "$output_name", $insig) or warn "Can't run $application ...\n"; - } - - popd(); - remove_tree( $temp_dir, {keep_root => 1} ); -} -print_summary() if ($ci_use); -popd(); - -__END__ - -=head1 NAME - -Script to run all qt tests/benchmarks to an android device/emulator - -=head1 SYNOPSIS - -runtests.pl [options] - -=head1 OPTIONS - -=over 8 -=item B<-f --fail> - -Stop the script when test fails. Default 0 - -=item B<-s --serial = serial> - -Device serial number. May be empty if only one device is attached. - -=item B<-t --test = test_subset> - -Tests subset (e.g. benchmarks, auto, auto/qbuffer, etc.). - -=item B<-c --clean> - -Clean tests before building them. - -=item B<-j --jobs = number> - -Make jobs when building tests. - -=item B<--sdk = sdk_path> - -Android SDK path. - -=item B<--ndk = ndk_path> - -Android NDK path. - -=item B<--ant = ant_tool_path> - -Ant tool path. - -=item B<--strip = strip_tool_path> - -Android strip tool path, used to deploy qt libs. - -=item B<--readelf = readelf_tool_path> - -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<-silent> - -Suppress output of system commands. - -=item B<-ci> - -Enables checking if test is insignificant or not. Also prints test -summary after all tests has been executed. - -=item B<-uninstall> - -Uninstalls the test after has been executed. - -=item B<-h --help> - -Print a brief help message and exits. - -=item B<--man> - -Prints the manual page and exits. - -=back - -=head1 DESCRIPTION - -B<This program> will run all qt tests/benchmarks to an android device/emulator. - -=cut diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index 2e698e6615..3c77b1ba0b 100644 --- a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -88,7 +88,7 @@ QAtomicInt iterations; class PrintFor : public IterateKernel<TestIterator, void> { public: - PrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); } + PrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.storeRelaxed(0); } bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { iterations.fetchAndAddRelaxed(end - begin); @@ -107,7 +107,7 @@ public: class SleepPrintFor : public IterateKernel<TestIterator, void> { public: - SleepPrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); } + SleepPrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.storeRelaxed(0); } inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { QTest::qSleep(200); @@ -127,7 +127,7 @@ public: void tst_QtConcurrentIterateKernel::instantiate() { startThreadEngine(new PrintFor(0, 40)).startBlocking(); - QCOMPARE(iterations.load(), 40); + QCOMPARE(iterations.loadRelaxed(), 40); } void tst_QtConcurrentIterateKernel::cancel() @@ -138,8 +138,8 @@ void tst_QtConcurrentIterateKernel::cancel() f.waitForFinished(); QVERIFY(f.isCanceled()); // the threads might run one iteration each before they are canceled. - QVERIFY2(iterations.load() <= QThread::idealThreadCount(), - (QByteArray::number(iterations.load()) + ' ' + QByteArray::number(QThread::idealThreadCount()))); + QVERIFY2(iterations.loadRelaxed() <= QThread::idealThreadCount(), + (QByteArray::number(iterations.loadRelaxed()) + ' ' + QByteArray::number(QThread::idealThreadCount()))); } } @@ -147,7 +147,7 @@ QAtomicInt counter; class CountFor : public IterateKernel<TestIterator, void> { public: - CountFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); } + CountFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.storeRelaxed(0); } inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { counter.fetchAndAddRelaxed(end - begin); @@ -164,10 +164,10 @@ void tst_QtConcurrentIterateKernel::stresstest() const int iterations = 1000; const int times = 50; for (int i = 0; i < times; ++i) { - counter.store(0); + counter.storeRelaxed(0); CountFor f(0, iterations); f.startBlocking(); - QCOMPARE(counter.load(), iterations); + QCOMPARE(counter.loadRelaxed(), iterations); } } @@ -186,7 +186,7 @@ public: // this class throttles between iterations 100 and 200, // and then records how many threads that run between // iterations 140 and 160. - ThrottleFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); throttling = false; } + ThrottleFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.storeRelaxed(0); throttling = false; } inline bool runIterations(TestIterator/*beginIterator*/, int begin, int end, void *) { if (200 >= begin && 200 < end) { @@ -217,7 +217,7 @@ public: bool shouldThrottleThread() { - const int load = iterations.load(); + const int load = iterations.loadRelaxed(); return (load > 100 && load < 200); } bool throttling; @@ -226,14 +226,14 @@ public: void tst_QtConcurrentIterateKernel::throttling() { const int totalIterations = 400; - iterations.store(0); + iterations.storeRelaxed(0); threads.clear(); ThrottleFor f(0, totalIterations); f.startBlocking(); - QCOMPARE(iterations.load(), totalIterations); + QCOMPARE(iterations.loadRelaxed(), totalIterations); QCOMPARE(threads.count(), 1); diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index b864b065e6..383de0b2ce 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -127,14 +127,11 @@ void tst_QtConcurrentMap::map() QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); QCOMPARE(numberList, QList<Number>() << 4 << 8 << 12); -#ifdef Q_COMPILER_LAMBDA // lambda QtConcurrent::map(list, [](int &x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList<int>() << 128 << 256 << 384); QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList<int>() << 256 << 512 << 768); -#endif - } // functors don't take arguments by reference, making these no-ops @@ -160,13 +157,11 @@ void tst_QtConcurrentMap::map() QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); QCOMPARE(list, QList<int>() << 1 << 2 << 3); -#ifdef Q_COMPILER_LAMBDA // lambda QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList<int>() << 1 << 2 << 3); QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished(); QCOMPARE(list, QList<int>() << 1 << 2 << 3); -#endif } // Linked lists and forward iterators @@ -2026,12 +2021,12 @@ int fn(int &i) return i; } -int fnConstNoExcept(const int &i) Q_DECL_NOTHROW +int fnConstNoExcept(const int &i) noexcept { return i; } -int fnNoExcept(int &i) Q_DECL_NOTHROW +int fnNoExcept(int &i) noexcept { return i; } @@ -2046,12 +2041,12 @@ QString changeType(int &) return QString(); } -QString changeTypeConstNoExcept(const int &) Q_DECL_NOTHROW +QString changeTypeConstNoExcept(const int &) noexcept { return QString(); } -QString changeTypeNoExcept(int &) Q_DECL_NOTHROW +QString changeTypeNoExcept(int &) noexcept { return QString(); } @@ -2066,12 +2061,12 @@ int changeTypeQStringList(QStringList &) return 0; } -int changeTypeQStringListConstNoExcept(const QStringList &) Q_DECL_NOTHROW +int changeTypeQStringListConstNoExcept(const QStringList &) noexcept { return 0; } -int changeTypeQStringListNoExcept(QStringList &) Q_DECL_NOTHROW +int changeTypeQStringListNoExcept(QStringList &) noexcept { return 0; } @@ -2101,22 +2096,22 @@ public: return QString(); } - MemFnTester fnNoExcept() Q_DECL_NOTHROW + MemFnTester fnNoExcept() noexcept { return MemFnTester(); } - MemFnTester fnConstNoExcept() const Q_DECL_NOTHROW + MemFnTester fnConstNoExcept() const noexcept { return MemFnTester(); } - QString changeTypeNoExcept() Q_DECL_NOTHROW + QString changeTypeNoExcept() noexcept { return QString(); } - QString changeTypeConstNoExcept() const Q_DECL_NOTHROW + QString changeTypeConstNoExcept() const noexcept { return QString(); } @@ -2186,8 +2181,8 @@ public: void updatePeak() { forever { - const int localPeak = peakInstanceCount.load(); - const int localCurrent = currentInstanceCount.load(); + const int localPeak = peakInstanceCount.loadRelaxed(); + const int localCurrent = currentInstanceCount.loadRelaxed(); if (localCurrent <= localPeak) break; if (peakInstanceCount.testAndSetOrdered(localPeak, localCurrent)) @@ -2225,35 +2220,35 @@ void tst_QtConcurrentMap::throttling() const int allowedTemporaries = QThread::idealThreadCount() * 40; { - currentInstanceCount.store(0); - peakInstanceCount.store(0); + currentInstanceCount.storeRelaxed(0); + peakInstanceCount.storeRelaxed(0); QList<InstanceCounter> instances; for (int i = 0; i < itemcount; ++i) instances.append(InstanceCounter()); - QCOMPARE(currentInstanceCount.load(), itemcount); + QCOMPARE(currentInstanceCount.loadRelaxed(), itemcount); int results = QtConcurrent::blockingMappedReduced(instances, slowMap, fastReduce); QCOMPARE(results, itemcount); - QCOMPARE(currentInstanceCount.load(), itemcount); - QVERIFY(peakInstanceCount.load() < itemcount + allowedTemporaries); + QCOMPARE(currentInstanceCount.loadRelaxed(), itemcount); + QVERIFY(peakInstanceCount.loadRelaxed() < itemcount + allowedTemporaries); } { - QCOMPARE(currentInstanceCount.load(), 0); - peakInstanceCount.store(0); + QCOMPARE(currentInstanceCount.loadRelaxed(), 0); + peakInstanceCount.storeRelaxed(0); QList<InstanceCounter> instances; for (int i = 0; i < itemcount; ++i) instances.append(InstanceCounter()); - QCOMPARE(currentInstanceCount.load(), itemcount); + QCOMPARE(currentInstanceCount.loadRelaxed(), itemcount); int results = QtConcurrent::blockingMappedReduced(instances, fastMap, slowReduce); QCOMPARE(results, itemcount); - QCOMPARE(currentInstanceCount.load(), itemcount); - QVERIFY(peakInstanceCount.load() < itemcount + allowedTemporaries); + QCOMPARE(currentInstanceCount.loadRelaxed(), itemcount); + QVERIFY(peakInstanceCount.loadRelaxed() < itemcount + allowedTemporaries); } } @@ -2385,8 +2380,8 @@ InstanceCounter ic_fn(const InstanceCounter & ic) // assigned over with operator == void tst_QtConcurrentMap::qFutureAssignmentLeak() { - currentInstanceCount.store(0); - peakInstanceCount.store(0); + currentInstanceCount.storeRelaxed(0); + peakInstanceCount.storeRelaxed(0); QFuture<InstanceCounter> future; { QList<InstanceCounter> list; @@ -2405,9 +2400,9 @@ void tst_QtConcurrentMap::qFutureAssignmentLeak() // Use QTRY_COMPARE because QtConcurrent::ThreadEngine::asynchronousFinish() // deletes its internals after signaling finished, so it might still be holding // on to copies of InstanceCounter for a short while. - QTRY_COMPARE(currentInstanceCount.load(), 1000); + QTRY_COMPARE(currentInstanceCount.loadRelaxed(), 1000); future = QFuture<InstanceCounter>(); - QTRY_COMPARE(currentInstanceCount.load(), 0); + QTRY_COMPARE(currentInstanceCount.loadRelaxed(), 0); } inline void increment(int &num) diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp index 1596a9fafd..a4eb2936b5 100644 --- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -48,12 +48,8 @@ private slots: #ifndef QT_NO_EXCEPTIONS void exceptions(); #endif -#ifdef Q_COMPILER_DECLTYPE void functor(); -#endif -#ifdef Q_COMPILER_LAMBDA void lambda(); -#endif }; void light() @@ -126,23 +122,23 @@ public: class ANoExcept { public: - int member0() Q_DECL_NOTHROW { return 10; } - int member1(int in) Q_DECL_NOTHROW { return in; } + int member0() noexcept { return 10; } + int member1(int in) noexcept { return in; } typedef int result_type; - int operator()() Q_DECL_NOTHROW { return 10; } - int operator()(int in) Q_DECL_NOTHROW { return in; } + int operator()() noexcept { return 10; } + int operator()(int in) noexcept { return in; } }; class AConstNoExcept { public: - int member0() const Q_DECL_NOTHROW { return 10; } - int member1(int in) const Q_DECL_NOTHROW { return in; } + int member0() const noexcept { return 10; } + int member1(int in) const noexcept { return in; } typedef int result_type; - int operator()() const Q_DECL_NOTHROW { return 10; } - int operator()(int in) const Q_DECL_NOTHROW { return in; } + int operator()() const noexcept { return 10; } + int operator()(int in) const noexcept { return in; } }; void tst_QtConcurrentRun::returnValue() @@ -510,17 +506,17 @@ void tst_QtConcurrentRun::recursive() int levels = 15; for (int i = 0; i < QThread::idealThreadCount(); ++i) { - count.store(0); + count.storeRelaxed(0); QThreadPool::globalInstance()->setMaxThreadCount(i); recursiveRun(levels); - QCOMPARE(count.load(), (int)std::pow(2.0, levels) - 1); + QCOMPARE(count.loadRelaxed(), (int)std::pow(2.0, levels) - 1); } for (int i = 0; i < QThread::idealThreadCount(); ++i) { - count.store(0); + count.storeRelaxed(0); QThreadPool::globalInstance()->setMaxThreadCount(i); recursiveResult(levels); - QCOMPARE(count.load(), (int)std::pow(2.0, levels) - 1); + QCOMPARE(count.loadRelaxed(), (int)std::pow(2.0, levels) - 1); } } @@ -574,7 +570,7 @@ public: static QAtomicInt cancel; void run() override { int iter = 60; - while (--iter && !cancel.load()) + while (--iter && !cancel.loadRelaxed()) QThread::currentThread()->msleep(25); } }; @@ -642,13 +638,12 @@ void tst_QtConcurrentRun::exceptions() caught = true; } - SlowTask::cancel.store(true); + SlowTask::cancel.storeRelaxed(true); QVERIFY2(caught, "did not get exception"); } #endif -#ifdef Q_COMPILER_DECLTYPE // Compiler supports decltype struct Functor { int operator()() { return 42; } @@ -706,9 +701,7 @@ void tst_QtConcurrentRun::functor() QtConcurrent::run(&pool, f, 1,2,3,4,5).waitForFinished(); } } -#endif -#ifdef Q_COMPILER_LAMBDA // Compiler supports lambda void tst_QtConcurrentRun::lambda() { @@ -717,14 +710,12 @@ void tst_QtConcurrentRun::lambda() QCOMPARE(QtConcurrent::run([](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); QCOMPARE(QtConcurrent::run([](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); -#ifdef Q_COMPILER_INITIALIZER_LISTS { QString str { "Hello World Foo" }; QFuture<QStringList> f1 = QtConcurrent::run([&](){ return str.split(' '); }); auto r = f1.result(); QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); } -#endif // and now with explicit pool: QThreadPool pool; @@ -733,16 +724,13 @@ void tst_QtConcurrentRun::lambda() QCOMPARE(QtConcurrent::run(&pool, [](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); QCOMPARE(QtConcurrent::run(&pool, [](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); -#ifdef Q_COMPILER_INITIALIZER_LISTS { QString str { "Hello World Foo" }; QFuture<QStringList> f1 = QtConcurrent::run(&pool, [&](){ return str.split(' '); }); auto r = f1.result(); QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); } -#endif } -#endif QTEST_MAIN(tst_QtConcurrentRun) #include "tst_qtconcurrentrun.moc" diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp index a68f7d5a4e..d4c669cddc 100644 --- a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp +++ b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp @@ -28,6 +28,7 @@ #include <qtconcurrentthreadengine.h> #include <qexception.h> #include <QThread> +#include <QElapsedTimer> #include <QtTest/QtTest> using namespace QtConcurrent; @@ -186,7 +187,7 @@ class ThrottleAlwaysUser : public ThreadEngine<void> public: ThrottleAlwaysUser() { - count.store(initialCount = 100); + count.storeRelaxed(initialCount = 100); finishing = false; } @@ -198,7 +199,7 @@ public: ThreadFunctionResult threadFunction() { forever { - const int local = count.load(); + const int local = count.loadRelaxed(); if (local == 0) { finishing = true; return ThreadFinished; @@ -223,13 +224,13 @@ void tst_QtConcurrentThreadEngine::throttle() for (int i = 0; i < repeats; ++i) { QFuture<void> f = (new ThrottleAlwaysUser())->startAsynchronously(); f.waitForFinished(); - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } for (int i = 0; i < repeats; ++i) { ThrottleAlwaysUser t; t.startBlocking(); - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } } @@ -382,7 +383,7 @@ void tst_QtConcurrentThreadEngine::cancelQueuedSlowUser() { const int times = 100; - QTime t; + QElapsedTimer t; t.start(); { diff --git a/tests/auto/corelib/corelib.pro b/tests/auto/corelib/corelib.pro index 44e1c519b0..1d76e1549b 100644 --- a/tests/auto/corelib/corelib.pro +++ b/tests/auto/corelib/corelib.pro @@ -14,4 +14,5 @@ SUBDIRS = \ serialization \ statemachine \ thread \ + time \ tools diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 72b086350e..1568855032 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -142,7 +142,6 @@ void tst_QFlags::signedness() std::is_signed<Qt::Alignment::Int>::value)); } -#if defined(Q_COMPILER_CLASS_ENUM) enum class MyStrictEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 }; Q_DECLARE_FLAGS( MyStrictFlags, MyStrictEnum ) Q_DECLARE_OPERATORS_FOR_FLAGS( MyStrictFlags ) @@ -154,11 +153,9 @@ Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isComplex ); Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isStatic ); Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isLarge ); Q_STATIC_ASSERT( !QTypeInfo<MyStrictFlags>::isPointer ); -#endif void tst_QFlags::classEnum() { -#if defined(Q_COMPILER_CLASS_ENUM) // The main aim of the test is making sure it compiles // The QCOMPARE are there as an extra MyStrictEnum e1 = MyStrictEnum::StrictOne; @@ -257,27 +254,19 @@ void tst_QFlags::classEnum() // Just to make sure it compiles if (false) qDebug() << f3; -#endif } void tst_QFlags::initializerLists() { -#if defined(Q_COMPILER_INITIALIZER_LISTS) Qt::MouseButtons bts = { Qt::LeftButton, Qt::RightButton }; QVERIFY(bts.testFlag(Qt::LeftButton)); QVERIFY(bts.testFlag(Qt::RightButton)); QVERIFY(!bts.testFlag(Qt::MiddleButton)); -#if defined(Q_COMPILER_CLASS_ENUM) MyStrictNoOpFlags flags = { MyStrictNoOpEnum::StrictOne, MyStrictNoOpEnum::StrictFour }; QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictOne)); QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictFour)); QVERIFY(!flags.testFlag(MyStrictNoOpEnum::StrictTwo)); -#endif // Q_COMPILER_CLASS_ENUM - -#else - QSKIP("This test requires C++11 initializer_list support."); -#endif // Q_COMPILER_INITIALIZER_LISTS } void tst_QFlags::testSetFlags() diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index b73a297245..5c7737085e 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 by Southwest Research Institute (R) ** Contact: https://www.qt.io/licensing/ ** @@ -48,6 +49,7 @@ private slots: void arithOps(); void floatToFloat16(); void floatFromFloat16(); + void limits(); }; void tst_qfloat16::fuzzyCompare_data() @@ -347,5 +349,164 @@ void tst_qfloat16::floatFromFloat16() QCOMPARE(out[i], expected[i]); } +static qfloat16 powf16(qfloat16 base, int raise) +{ + const qfloat16 one(1.f); + if (raise < 0) { + raise = -raise; + base = one / base; + } + qfloat16 answer = (raise & 1) ? base : one; + while (raise > 0) { + raise >>= 1; + base *= base; + if (raise & 1) + answer *= base; + } + return answer; +} + +void tst_qfloat16::limits() +{ + // *NOT* using QCOMPARE() on finite qfloat16 values, since that uses fuzzy + // comparison, and we need exact here. + using Bounds = std::numeric_limits<qfloat16>; + QVERIFY(Bounds::is_specialized); + QVERIFY(Bounds::is_signed); + QVERIFY(!Bounds::is_integer); + QVERIFY(!Bounds::is_exact); + QVERIFY(Bounds::is_iec559); + QVERIFY(Bounds::is_bounded); + QVERIFY(!Bounds::is_modulo); + QVERIFY(!Bounds::traps); + QVERIFY(Bounds::has_infinity); + QVERIFY(Bounds::has_quiet_NaN); + QVERIFY(Bounds::has_signaling_NaN); + QCOMPARE(Bounds::has_denorm, std::denorm_present); + QCOMPARE(Bounds::round_style, std::round_to_nearest); + QCOMPARE(Bounds::radix, 2); + // Untested: has_denorm_loss + + // A few common values: + const qfloat16 zero(0), one(1), ten(10); + QVERIFY(qIsFinite(zero)); + QVERIFY(!qIsInf(zero)); + QVERIFY(!qIsNaN(zero)); + QCOMPARE(qFpClassify(zero), FP_ZERO); + QVERIFY(qIsFinite(one)); + QVERIFY(!qIsInf(one)); + QCOMPARE(qFpClassify(one), FP_NORMAL); + QVERIFY(!qIsNaN(one)); + QVERIFY(qIsFinite(ten)); + QVERIFY(!qIsInf(ten)); + QVERIFY(!qIsNaN(ten)); + QCOMPARE(qFpClassify(ten), FP_NORMAL); + + // digits in the mantissa, including the implicit 1 before the binary dot at its left: + QVERIFY(qfloat16(1 << (Bounds::digits - 1)) + one > qfloat16(1 << (Bounds::digits - 1))); + QVERIFY(qfloat16(1 << Bounds::digits) + one == qfloat16(1 << Bounds::digits)); + + // There is a wilful of-by-one in how m(ax|in)_exponent are defined; they're + // the lowest and highest n for which radix^{n-1} are normal and finite. + const qfloat16 two(Bounds::radix); + qfloat16 bit = powf16(two, Bounds::max_exponent - 1); + QVERIFY(qIsFinite(bit)); + QVERIFY(qIsInf(bit * two)); + bit = powf16(two, Bounds::min_exponent - 1); + QVERIFY(bit.isNormal()); + QCOMPARE(qFpClassify(bit), FP_NORMAL); + QVERIFY(!(bit / two).isNormal()); + QCOMPARE(qFpClassify(bit / two), FP_SUBNORMAL); + QVERIFY(bit / two > zero); + + // Base ten (with no matching off-by-one idiocy): + // the lowest negative number n such that 10^n is a valid normalized value + qfloat16 low10(powf16(ten, Bounds::min_exponent10)); + QVERIFY(low10 > zero); + QVERIFY(low10.isNormal()); + low10 /= ten; + QVERIFY(low10 == zero || !low10.isNormal()); + // the largest positive number n such that 10^n is a representable finite value + qfloat16 high10(powf16(ten, Bounds::max_exponent10)); + QVERIFY(high10 > zero); + QVERIFY(qIsFinite(high10)); + QVERIFY(!qIsFinite(high10 * ten)); + QCOMPARE(qFpClassify(high10), FP_NORMAL); + + // How many digits are significant ? (Casts avoid linker errors ...) + QCOMPARE(int(Bounds::digits10), 3); // 9.79e-4 has enough sigificant digits: + qfloat16 below(9.785e-4f), above(9.794e-4f); +#if 0 // Sadly, the QEMU x-compile for arm64 "optimises" comparisons: + const bool overOptimised = false; +#else + const bool overOptimised = (below != above); + if (overOptimised) + QEXPECT_FAIL("", "Over-optimised on QEMU", Continue); +#endif // (but it did, so should, pass everywhere else, confirming digits10 is indeed 3). + QVERIFY(below == above); + QCOMPARE(int(Bounds::max_digits10), 5); // we need 5 to distinguish these two: + QVERIFY(qfloat16(1000.5f) != qfloat16(1001.4f)); + + // Actual limiting values of the type: + const qfloat16 rose(one + Bounds::epsilon()); + QVERIFY(rose > one); + if (overOptimised) + QEXPECT_FAIL("", "Over-optimised on QEMU", Continue); + QVERIFY(one + Bounds::epsilon() / rose == one); + QVERIFY(qIsInf(Bounds::infinity())); + QVERIFY(!qIsNaN(Bounds::infinity())); + QVERIFY(!qIsFinite(Bounds::infinity())); + QCOMPARE(Bounds::infinity(), Bounds::infinity()); + QCOMPARE(qFpClassify(Bounds::infinity()), FP_INFINITE); + + QVERIFY(Bounds::infinity() > -Bounds::infinity()); + QVERIFY(Bounds::infinity() > zero); + QVERIFY(qIsInf(-Bounds::infinity())); + QVERIFY(!qIsNaN(-Bounds::infinity())); + QVERIFY(!qIsFinite(-Bounds::infinity())); + QCOMPARE(-Bounds::infinity(), -Bounds::infinity()); + QCOMPARE(qFpClassify(-Bounds::infinity()), FP_INFINITE); + + QVERIFY(-Bounds::infinity() < zero); + QVERIFY(qIsNaN(Bounds::quiet_NaN())); + QVERIFY(!qIsInf(Bounds::quiet_NaN())); + QVERIFY(!qIsFinite(Bounds::quiet_NaN())); + QVERIFY(!(Bounds::quiet_NaN() == Bounds::quiet_NaN())); + QCOMPARE(Bounds::quiet_NaN(), Bounds::quiet_NaN()); + QCOMPARE(qFpClassify(Bounds::quiet_NaN()), FP_NAN); + + QVERIFY(Bounds::max() > zero); + QVERIFY(qIsFinite(Bounds::max())); + QVERIFY(!qIsInf(Bounds::max())); + QVERIFY(!qIsNaN(Bounds::max())); + QVERIFY(qIsInf(Bounds::max() * rose)); + QCOMPARE(qFpClassify(Bounds::max()), FP_NORMAL); + + QVERIFY(Bounds::lowest() < zero); + QVERIFY(qIsFinite(Bounds::lowest())); + QVERIFY(!qIsInf(Bounds::lowest())); + QVERIFY(!qIsNaN(Bounds::lowest())); + QVERIFY(qIsInf(Bounds::lowest() * rose)); + QCOMPARE(qFpClassify(Bounds::lowest()), FP_NORMAL); + + QVERIFY(Bounds::min() > zero); + QVERIFY(Bounds::min().isNormal()); + QVERIFY(!(Bounds::min() / rose).isNormal()); + QVERIFY(qIsFinite(Bounds::min())); + QVERIFY(!qIsInf(Bounds::min())); + QVERIFY(!qIsNaN(Bounds::min())); + QCOMPARE(qFpClassify(Bounds::min()), FP_NORMAL); + + QVERIFY(Bounds::denorm_min() > zero); + QVERIFY(!Bounds::denorm_min().isNormal()); + QVERIFY(qIsFinite(Bounds::denorm_min())); + QVERIFY(!qIsInf(Bounds::denorm_min())); + QVERIFY(!qIsNaN(Bounds::denorm_min())); + if (overOptimised) + QEXPECT_FAIL("", "Over-optimised on QEMU", Continue); + QCOMPARE(Bounds::denorm_min() / rose, zero); + QCOMPARE(qFpClassify(Bounds::denorm_min()), FP_SUBNORMAL); +} + QTEST_APPLESS_MAIN(tst_qfloat16) #include "tst_qfloat16.moc" diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index 0719c4b921..c7124454d0 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -85,7 +85,7 @@ int tst_QtVersion() return QT_VERSION; } -const char *tst_qVersion() Q_DECL_NOTHROW +const char *tst_qVersion() Q_DECL_NOEXCEPT { #if !defined(QT_NAMESPACE) return qVersion(); diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 7800a101ec..b33dec8a61 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -456,12 +456,8 @@ typedef int (Empty::*memFun) (); } while (false) \ /**/ -#ifdef Q_COMPILER_RVALUE_REFS #define TEST_AlignOf_RValueRef(type, alignment) \ TEST_AlignOf_impl(type, alignment) -#else -#define TEST_AlignOf_RValueRef(type, alignment) do {} while (false) -#endif #define TEST_AlignOf_impl(type, alignment) \ do { \ diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp index 2d7db813dd..820a0b999b 100644 --- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp +++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp @@ -145,7 +145,7 @@ void tst_QGlobalStatic::exception() exceptionCaught = true; } QVERIFY(exceptionCaught); - QCOMPARE(Q_QGS_throwingGS::guard.load(), 0); + QCOMPARE(Q_QGS_throwingGS::guard.loadRelaxed(), 0); QVERIFY(!throwingGS.exists()); QVERIFY(!throwingGS.isDestroyed()); } @@ -154,10 +154,10 @@ QBasicAtomicInt exceptionControlVar = Q_BASIC_ATOMIC_INITIALIZER(1); Q_GLOBAL_STATIC_WITH_ARGS(ThrowingType, exceptionGS, (exceptionControlVar)) void tst_QGlobalStatic::catchExceptionAndRetry() { - if (exceptionControlVar.load() != 1) + if (exceptionControlVar.loadRelaxed() != 1) QSKIP("This test cannot be run more than once"); - ThrowingType::constructedCount.store(0); - ThrowingType::destructedCount.store(0); + ThrowingType::constructedCount.storeRelaxed(0); + ThrowingType::destructedCount.storeRelaxed(0); bool exceptionCaught = false; try { @@ -165,11 +165,11 @@ void tst_QGlobalStatic::catchExceptionAndRetry() } catch (int) { exceptionCaught = true; } - QCOMPARE(ThrowingType::constructedCount.load(), 1); + QCOMPARE(ThrowingType::constructedCount.loadRelaxed(), 1); QVERIFY(exceptionCaught); exceptionGS(); - QCOMPARE(ThrowingType::constructedCount.load(), 2); + QCOMPARE(ThrowingType::constructedCount.loadRelaxed(), 2); } QBasicAtomicInt threadStressTestControlVar = Q_BASIC_ATOMIC_INITIALIZER(5); @@ -194,9 +194,9 @@ void tst_QGlobalStatic::threadStressTest() } }; - ThrowingType::constructedCount.store(0); - ThrowingType::destructedCount.store(0); - int expectedConstructionCount = threadStressTestControlVar.load() + 1; + ThrowingType::constructedCount.storeRelaxed(0); + ThrowingType::destructedCount.storeRelaxed(0); + int expectedConstructionCount = threadStressTestControlVar.loadRelaxed() + 1; if (expectedConstructionCount <= 0) QSKIP("This test cannot be run more than once"); diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index d3ed1a6d0d..23507ec2e6 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -254,19 +254,15 @@ public: int rvalue() && { ADD("TestClass1::rvalue"); return 0; } int const_rvalue() const && { ADD("TestClass1::const_rvalue"); return 0; } #endif -#ifdef Q_COMPILER_DECLTYPE int decltype_param(int x = 0, decltype(x) = 0) { ADD("TestClass1::decltype_param"); return x; } template<typename T> int decltype_template_param(T x = 0, decltype(x) = 0) { ADD("TestClass1::decltype_template_param"); return x; } template<typename T> void decltype_template_param2(T x, decltype(x + QString())) { ADD("TestClass1::decltype_template_param2"); } -# ifdef Q_COMPILER_AUTO_FUNCTION auto decltype_return(int x = 0) -> decltype(x) { ADD("TestClass1::decltype_return"); return x; } template <typename T> auto decltype_template_return(T x = 0) -> decltype(x) { ADD("TestClass1::decltype_template_return"); return x; } -# endif -#endif public: TestClass1() @@ -323,15 +319,11 @@ public: std::move(*this).rvalue(); std::move(*this).const_rvalue(); #endif -#ifdef Q_COMPILER_DECLTYPE decltype_param(); decltype_template_param(0); decltype_template_param2(QByteArray(), QString()); -# ifdef Q_COMPILER_AUTO_FUNCTION decltype_return(); decltype_template_return(0); -# endif -#endif } }; @@ -878,12 +870,14 @@ void tst_qmessagehandler::setMessagePattern() #endif // make sure there is no QT_MESSAGE_PATTERN in the environment - QStringList environment = m_baseEnvironment; - QMutableListIterator<QString> iter(environment); - while (iter.hasNext()) { - if (iter.next().startsWith("QT_MESSAGE_PATTERN")) - iter.remove(); - } + QStringList environment; + environment.reserve(m_baseEnvironment.size()); + const auto doesNotStartWith = [](QLatin1String s) { + return [s](const QString &str) { return !str.startsWith(s); }; + }; + std::copy_if(m_baseEnvironment.cbegin(), m_baseEnvironment.cend(), + std::back_inserter(environment), + doesNotStartWith(QLatin1String("QT_MESSAGE_PATTERN"))); process.setEnvironment(environment); process.start(appExe); diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 03300c6dbe..0a84b1fdd8 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -42,7 +42,8 @@ class tst_QNumeric: public QObject private slots: void fuzzyCompare_data(); void fuzzyCompare(); - void qNan(); + void qNanInf(); + void classifyfp(); void floatDistance_data(); void floatDistance(); void floatDistance_double_data(); @@ -91,7 +92,7 @@ void tst_QNumeric::fuzzyCompare() # pragma GCC optimize "no-fast-math" #endif -void tst_QNumeric::qNan() +void tst_QNumeric::qNanInf() { #if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404) QSKIP("Non-conformant fast math mode is enabled, cannot run test"); @@ -99,9 +100,16 @@ void tst_QNumeric::qNan() double nan = qQNaN(); QVERIFY(!(0 > nan)); QVERIFY(!(0 < nan)); + QVERIFY(!(0 == nan)); + QVERIFY(!(nan == nan)); QVERIFY(qIsNaN(nan)); QVERIFY(qIsNaN(nan + 1)); QVERIFY(qIsNaN(-nan)); + QVERIFY(qIsNaN(1.0 / nan)); + QVERIFY(qIsNaN(0.0 / nan)); + QVERIFY(qIsNaN(0.0 * nan)); + QCOMPARE(nan, nan); + QCOMPARE(nan, -nan); Q_STATIC_ASSERT(sizeof(double) == 8); #ifdef Q_LITTLE_ENDIAN @@ -113,17 +121,56 @@ void tst_QNumeric::qNan() QVERIFY(!qIsFinite(nan)); QVERIFY(!qIsInf(nan)); QVERIFY(qIsNaN(nan)); + QVERIFY(qIsNaN(-nan)); + QVERIFY(!(nan == nan)); + QVERIFY(qIsNaN(0.0 * nan)); + QCOMPARE(qFpClassify(nan), FP_NAN); + QCOMPARE(nan, nan); + QCOMPARE(nan, -nan); + QCOMPARE(nan, qQNaN()); double inf = qInf(); QVERIFY(inf > 0); QVERIFY(-inf < 0); QVERIFY(qIsInf(inf)); + QCOMPARE(inf, inf); + QCOMPARE(-inf, -inf); QVERIFY(qIsInf(-inf)); - QVERIFY(qIsInf(2*inf)); - QCOMPARE(1/inf, 0.0); - QVERIFY(qIsNaN(0*nan)); - QVERIFY(qIsNaN(0*inf)); - QVERIFY(qFuzzyCompare(1/inf, 0.0)); + QVERIFY(qIsInf(inf + 1)); + QVERIFY(qIsInf(inf - 1)); + QVERIFY(qIsInf(inf * 2.0)); + QVERIFY(qIsInf(inf / 2.0)); + QVERIFY(qFuzzyCompare(1.0 / inf, 0.0)); + QCOMPARE(1.0 / inf, 0.0); + QVERIFY(qIsNaN(0.0 * inf)); +} + +void tst_QNumeric::classifyfp() +{ + QCOMPARE(qFpClassify(qQNaN()), FP_NAN); + + QCOMPARE(qFpClassify(qInf()), FP_INFINITE); + QCOMPARE(qFpClassify(-qInf()), FP_INFINITE); + QCOMPARE(qFpClassify(DBL_MAX * 2.0), FP_INFINITE); + QCOMPARE(qFpClassify(FLT_MAX * 2.f), FP_INFINITE); + QCOMPARE(qFpClassify(DBL_MAX * -2.0), FP_INFINITE); + QCOMPARE(qFpClassify(FLT_MAX * -2.f), FP_INFINITE); + + QCOMPARE(qFpClassify(1.0), FP_NORMAL); + QCOMPARE(qFpClassify(DBL_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(-DBL_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(DBL_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(-DBL_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(DBL_MIN / 2.0), FP_SUBNORMAL); + QCOMPARE(qFpClassify(DBL_MIN / -2.0), FP_SUBNORMAL); + + QCOMPARE(qFpClassify(1.f), FP_NORMAL); + QCOMPARE(qFpClassify(FLT_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(-FLT_MAX), FP_NORMAL); + QCOMPARE(qFpClassify(FLT_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(-FLT_MIN), FP_NORMAL); + QCOMPARE(qFpClassify(FLT_MIN / 2.f), FP_SUBNORMAL); + QCOMPARE(qFpClassify(FLT_MIN / -2.f), FP_SUBNORMAL); } void tst_QNumeric::floatDistance_data() @@ -461,13 +508,13 @@ template <typename Int> static void mulOverflow_template() QCOMPARE(mul_overflow(Int(max / 2), Int(3), &r), true); QCOMPARE(mul_overflow(mid1, Int(mid2 + 1), &r), true); QCOMPARE(mul_overflow(Int(max / 2 + 2), Int(2), &r), true); + QCOMPARE(mul_overflow(Int(max - max / 2), Int(2), &r), true); QCOMPARE(mul_overflow(Int(1ULL << (std::numeric_limits<Int>::digits - 1)), Int(2), &r), true); if (min) { QCOMPARE(mul_overflow(min, Int(2), &r), true); QCOMPARE(mul_overflow(Int(min / 2), Int(3), &r), true); QCOMPARE(mul_overflow(Int(min / 2 - 1), Int(2), &r), true); - QCOMPARE(mul_overflow(Int(min + min/2), Int(2), &r), true); } #endif } diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index 7c04611823..e238be1de3 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -57,7 +57,7 @@ static const double RandomValueFP = double(0.3010463714599609); static void setRNGControl(uint v) { #ifdef QT_BUILD_INTERNAL - qt_randomdevice_control.store(v); + qt_randomdevice_control.storeRelaxed(v); #else Q_UNUSED(v); #endif @@ -511,7 +511,7 @@ void tst_QRandomGenerator::generateNonContiguous() QFETCH(uint, control); RandomGenerator rng(control); - QLinkedList<quint64> list = { 0, 0, 0, 0, 0, 0, 0, 0 }; + std::list<quint64> list(8); auto longerArrayCheck = [&] { QRandomGenerator().generate(list.begin(), list.end()); return find_if(list.begin(), list.end(), [&](quint64 cur) { diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index dca7672b8e..f459f62c91 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -36,6 +36,7 @@ #include <QDebug> +#include <algorithm> #include <cstdlib> #include <cstdio> @@ -489,13 +490,13 @@ void tst_LargeFile::mapFile() // Keep full block mapped to facilitate OS and/or internal reuse by Qt. uchar *baseAddress = largeFile.map(position, blockSize); QVERIFY( baseAddress ); - QVERIFY( qEqual(block.begin(), block.end(), reinterpret_cast<char*>(baseAddress)) ); + QVERIFY( std::equal(block.begin(), block.end(), reinterpret_cast<char*>(baseAddress)) ); for (int offset = 1; offset < blockSize; ++offset) { uchar *address = largeFile.map(position + offset, blockSize - offset); QVERIFY( address ); - if ( !qEqual(block.begin() + offset, block.end(), reinterpret_cast<char*>(address)) ) { + if ( !std::equal(block.begin() + offset, block.end(), reinterpret_cast<char*>(address)) ) { qDebug() << "Expected:" << block.toHex(); qDebug() << "Actual :" << QByteArray(reinterpret_cast<char*>(address), blockSize).toHex(); QVERIFY(false); diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 7b8b1df166..a818c6c09d 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -309,7 +309,7 @@ void tst_QDebug::stateSaver() const QDebug d = qDebug(); { QDebugStateSaver saver(d); - d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42; + d.nospace() << Qt::hex << Qt::right << qSetFieldWidth(3) << qSetPadChar('0') << 42; } d << 42; } @@ -327,7 +327,7 @@ void tst_QDebug::stateSaver() const { QDebug d = qDebug(); - d.noquote().nospace() << QStringLiteral("Hello") << hex << 42; + d.noquote().nospace() << QStringLiteral("Hello") << Qt::hex << 42; { QDebugStateSaver saver(d); d.resetFormat(); @@ -660,7 +660,7 @@ void tst_QDebug::textStreamModifiers() const QString file, function; int line = 0; MessageHandlerSetter mhs(myMessageHandler); - { qDebug() << hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); } + { qDebug() << Qt::hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); } #ifndef QT_NO_MESSAGELOGCONTEXT file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; #endif @@ -678,7 +678,7 @@ void tst_QDebug::resetFormat() const MessageHandlerSetter mhs(myMessageHandler); { QDebug d = qDebug(); - d.nospace().noquote() << hex << int(0xf); + d.nospace().noquote() << Qt::hex << int(0xf); d.resetFormat() << int(0xf) << QStringLiteral("foo"); } #ifndef QT_NO_MESSAGELOGCONTEXT diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index b703a8839f..2aebc67dcf 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -349,21 +349,21 @@ void tst_QDir::mkdirRmdir_data() QTest::addColumn<QString>("path"); QTest::addColumn<bool>("recurse"); - QStringList dirs; - dirs << "testdir/one" - << "testdir/two/three/four" - << "testdir/../testdir/three"; - QTest::newRow("plain") << QDir::currentPath() + "/" + dirs.at(0) << false; - QTest::newRow("recursive") << QDir::currentPath() + "/" + dirs.at(1) << true; - QTest::newRow("with-..") << QDir::currentPath() + "/" + dirs.at(2) << false; - - QTest::newRow("relative-plain") << dirs.at(0) << false; - QTest::newRow("relative-recursive") << dirs.at(1) << true; - QTest::newRow("relative-with-..") << dirs.at(2) << false; - - // Ensure that none of these directories already exist - for (int i = 0; i < dirs.count(); ++i) - QVERIFY(!QFile::exists(dirs.at(i))); + const struct { + const char *name; // shall have a prefix added + const char *path; // relative + bool recurse; + } cases[] = { + { "plain", "testdir/one", false }, + { "recursive", "testdir/two/three/four", true }, + { "with-..", "testdir/../testdir/three", false }, + }; + + for (const auto &it : cases) { + QVERIFY(!QFile::exists(it.path)); + QTest::addRow("absolute-%s", it.name) << (QDir::currentPath() + "/") + it.path << it.recurse; + QTest::addRow("relative-%s", it.name) << QString::fromLatin1(it.path) << it.recurse; + } } void tst_QDir::mkdirRmdir() diff --git a/tests/auto/corelib/io/qfile/test.pro b/tests/auto/corelib/io/qfile/test.pro index 95389ab3e2..7a2767bf3c 100644 --- a/tests/auto/corelib/io/qfile/test.pro +++ b/tests/auto/corelib/io/qfile/test.pro @@ -23,4 +23,4 @@ TESTDATA += \ Makefile forCopying.txt forRenaming.txt \ resources/file1.ext1 -win32:!winrt: LIBS += -lole32 -luuid +win32:!winrt: QMAKE_USE += ole32 uuid diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 678a80c3f7..4f010f37c2 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2099,7 +2099,7 @@ void tst_QFile::i18nFileName() QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData()); QTextStream ts(&file); ts.setCodec("UTF-8"); - ts << fileName << endl; + ts << fileName << Qt::endl; } { QFile file(fileName); @@ -2149,7 +2149,7 @@ void tst_QFile::longFileName() QFile file(fileName); QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData()); QTextStream ts(&file); - ts << fileName << endl; + ts << fileName << Qt::endl; } { QFile file(fileName); diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index 496729f9f1..d181d16a3e 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -5,4 +5,4 @@ SOURCES = tst_qfileinfo.cpp RESOURCES += qfileinfo.qrc \ testdata.qrc -win32:!winrt: LIBS += -ladvapi32 -lnetapi32 +win32:!winrt: QMAKE_USE += advapi32 netapi32 diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 646fb2078a..0944ec252e 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1184,7 +1184,7 @@ void tst_QFileInfo::fileTimes() QTest::qSleep(sleepTime); beforeWrite = QDateTime::currentDateTime().addMSecs(-fsClockSkew); QTextStream ts(&file); - ts << fileName << endl; + ts << fileName << Qt::endl; } { QFileInfo fileInfo(fileName); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 67ffa91e57..cdd1f6361e 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -46,11 +46,13 @@ public: tst_QFileSystemWatcher(); private slots: +#ifdef QT_BUILD_INTERNAL void basicTest_data(); void basicTest(); void watchDirectory_data(); void watchDirectory(); +#endif void addPath(); void removePath(); @@ -58,8 +60,10 @@ private slots: void removePaths(); void removePathsFilesInSameDirectory(); +#ifdef QT_BUILD_INTERNAL void watchFileAndItsDirectory_data() { basicTest_data(); } void watchFileAndItsDirectory(); +#endif void nonExistingFile(); @@ -67,8 +71,10 @@ private slots: void destroyAfterQCoreApplication(); +#ifdef QT_BUILD_INTERNAL void QTBUG2331(); void QTBUG2331_data() { basicTest_data(); } +#endif void signalsEmittedAfterFileMoved(); @@ -90,6 +96,7 @@ tst_QFileSystemWatcher::tst_QFileSystemWatcher() #endif } +#ifdef QT_BUILD_INTERNAL void tst_QFileSystemWatcher::basicTest_data() { QTest::addColumn<QString>("backend"); @@ -360,6 +367,7 @@ void tst_QFileSystemWatcher::watchDirectory() for (const auto &testDirName : testDirs) QVERIFY(temporaryDir.rmdir(testDirName)); } +#endif // QT_BUILD_INTERNAL void tst_QFileSystemWatcher::addPath() { @@ -502,6 +510,7 @@ void tst_QFileSystemWatcher::removePathsFilesInSameDirectory() QCOMPARE(watcher.files().size(), 0); } +#ifdef QT_BUILD_INTERNAL static QByteArray msgFileOperationFailed(const char *what, const QFile &f) { return what + QByteArrayLiteral(" failed on \"") @@ -601,6 +610,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QVERIFY(temporaryDir.rmdir(testDirName)); } +#endif // QT_BUILD_INTERNAL void tst_QFileSystemWatcher::nonExistingFile() { @@ -673,6 +683,7 @@ void tst_QFileSystemWatcher::destroyAfterQCoreApplication() QTest::qWait(30); } +#ifdef QT_BUILD_INTERNAL // regression test for QTBUG2331. // essentially, on windows, directories were not unwatched after being deleted // from the disk, causing all sorts of interesting problems. @@ -696,6 +707,7 @@ void tst_QFileSystemWatcher::QTBUG2331() QTRY_COMPARE(changedSpy.count(), 1); QCOMPARE(watcher.directories(), QStringList()); } +#endif // QT_BUILD_INTERNAL class SignalReceiver : public QObject { diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro index da2660fd02..e33e22b36f 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro @@ -3,4 +3,4 @@ TARGET = tst_qlockfile SOURCES += tst_qlockfile.cpp QT = core-private testlib concurrent -win32:!winrt:LIBS += -ladvapi32 +win32:!winrt: QMAKE_USE += advapi32 diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index 11a9b3f189..79ac6b0fc4 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -104,7 +104,7 @@ public: for (int a = 0; a < _configitemEntryOrder.count(); a++) { out << _configitemEntryOrder[a] << " = " - << _values.value(_configitemEntryOrder[a]) << endl; + << _values.value(_configitemEntryOrder[a]) << Qt::endl; } out.flush(); return ret.toLatin1(); @@ -369,11 +369,9 @@ private slots: } Q_LOGGING_CATEGORY(TST_MACRO_1, "tst.macro.1") -#ifdef Q_COMPILER_VARIADIC_MACROS Q_LOGGING_CATEGORY(TST_MACRO_2, "tst.macro.2", QtDebugMsg) Q_LOGGING_CATEGORY(TST_MACRO_3, "tst.macro.3", QtFatalMsg) Q_LOGGING_CATEGORY(TST_MACRO_4, "tst.macro.4", QtInfoMsg) -#endif void QLoggingCategoryMacro() { @@ -384,7 +382,6 @@ private slots: QCOMPARE(cat1.isWarningEnabled(), true); QCOMPARE(cat1.isCriticalEnabled(), true); -#ifdef Q_COMPILER_VARIADIC_MACROS const QLoggingCategory &cat2 = TST_MACRO_2(); QCOMPARE(cat2.categoryName(), "tst.macro.2"); QCOMPARE(cat2.isDebugEnabled(), true); @@ -405,7 +402,6 @@ private slots: QCOMPARE(cat4.isInfoEnabled(), true); QCOMPARE(cat4.isWarningEnabled(), true); QCOMPARE(cat4.isCriticalEnabled(), true); -#endif } void qCDebugMacros() diff --git a/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro b/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro index 935f43630c..e41ed0a425 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro +++ b/tests/auto/corelib/io/qprocess/testProcessEchoGui/testProcessEchoGui.pro @@ -1,6 +1,6 @@ win32 { SOURCES = main_win.cpp - LIBS += -luser32 + QMAKE_USE += user32 } CONFIG -= qt app_bundle diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro index 2cfcb4794e..964c47f6ae 100644 --- a/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro +++ b/tests/auto/corelib/io/qprocess/testSoftExit/testSoftExit.pro @@ -1,6 +1,6 @@ win32 { SOURCES = main_win.cpp - LIBS += -luser32 + QMAKE_USE += user32 } unix { SOURCES = main_unix.cpp diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index c51994c1c1..e4ff3c2a08 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -32,6 +32,7 @@ #include <QtTest/QtTest> #include <QtCore/QProcess> #include <QtCore/QDir> +#include <QtCore/QElapsedTimer> #include <QtCore/QFile> #include <QtCore/QThread> #include <QtCore/QTemporaryDir> @@ -420,7 +421,7 @@ void tst_QProcess::echoTest() process.write(input); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); do { QVERIFY(process.isOpen()); @@ -479,7 +480,7 @@ void tst_QProcess::echoTest2() QVERIFY(spy1.isValid()); QVERIFY(spy2.isValid()); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); forever { QTestEventLoop::instance().enterLoop(1); @@ -2072,7 +2073,7 @@ void tst_QProcess::fileWriterProcess() stdinStr += line; } - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); const QString fileName = m_temporaryDir.path() + QLatin1String("/fileWriterProcess.txt"); const QString binary = QDir::currentPath() + QLatin1String("/fileWriterProcess/fileWriterProcess"); diff --git a/tests/auto/corelib/io/qsettings/qsettings.pro b/tests/auto/corelib/io/qsettings/qsettings.pro index 79552b62df..98ea337e7f 100644 --- a/tests/auto/corelib/io/qsettings/qsettings.pro +++ b/tests/auto/corelib/io/qsettings/qsettings.pro @@ -5,7 +5,7 @@ SOURCES = tst_qsettings.cpp RESOURCES += qsettings.qrc INCLUDEPATH += $$PWD/../../kernel/qmetatype -msvc: LIBS += advapi32.lib +msvc: QMAKE_USE += advapi32 darwin: LIBS += -framework CoreFoundation DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 1379c788d1..56d924dcc6 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -32,8 +32,8 @@ #include <qstandardpaths.h> #include <qfileinfo.h> #include <qsysinfo.h> -#include <qregexp.h> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) +#include <qregularexpression.h> +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) # include <qt_windows.h> #endif @@ -131,7 +131,7 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths void tst_qstandardpaths::initTestCase() { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // Disable WOW64 redirection, see testFindExecutable() if (QSysInfo::buildCpuArchitecture() != QSysInfo::currentCpuArchitecture()) { void *oldMode; @@ -140,7 +140,7 @@ void tst_qstandardpaths::initTestCase() qErrnoWarning("Wow64DisableWow64FsRedirection() failed"); QVERIFY(disabledDisableWow64FsRedirection); } -#endif // Q_OS_WIN && !Q_OS_WINRT && !Q_OS_WINCE +#endif // Q_OS_WIN && !Q_OS_WINRT QVERIFY2(m_localConfigTempDir.isValid(), qPrintable(m_localConfigTempDir.errorString())); QVERIFY2(m_globalConfigTempDir.isValid(), qPrintable(m_globalConfigTempDir.errorString())); QVERIFY2(m_localAppTempDir.isValid(), qPrintable(m_localAppTempDir.errorString())); @@ -566,7 +566,8 @@ void tst_qstandardpaths::testAllWritableLocations() void tst_qstandardpaths::testCleanPath() { - const QRegExp filter(QStringLiteral("\\\\")); +#if QT_CONFIG(regularexpression) + const QRegularExpression filter(QStringLiteral("\\\\")); QVERIFY(filter.isValid()); for (int i = 0; i <= QStandardPaths::GenericCacheLocation; ++i) { const QStringList paths = QStandardPaths::standardLocations(QStandardPaths::StandardLocation(i)); @@ -574,6 +575,9 @@ void tst_qstandardpaths::testCleanPath() qPrintable(QString::fromLatin1("Backslash found in %1 %2") .arg(i).arg(paths.join(QLatin1Char(','))))); } +#else + QSKIP("regularexpression feature disabled"); +#endif } void tst_qstandardpaths::testXdgPathCleanup() diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index b8f67c7d37..00417fffa0 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -215,7 +215,7 @@ void tst_QTemporaryFile::fileTemplate() if (!fileTemplate.isEmpty()) file.setFileTemplate(fileTemplate); - QCOMPARE(file.open(), true); + QVERIFY2(file.open(), qPrintable(file.errorString())); QString fileName = QFileInfo(file).fileName(); if (prefix.length()) diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 9c106c7f58..3123c42326 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -136,8 +136,8 @@ private slots: void emptyQueryOrFragment(); void hasFragment_data(); void hasFragment(); - void setEncodedFragment_data(); - void setEncodedFragment(); + void setFragment_data(); + void setFragment(); void fromEncoded(); void stripTrailingSlash_data(); void stripTrailingSlash(); @@ -350,15 +350,15 @@ void tst_QUrl::comparison() // 6.2.2.1 Make sure hexdecimal characters in percent encoding are // treated case-insensitively QUrl url5; - url5.setEncodedQuery("a=%2a"); + url5.setQuery(QLatin1String("a=%2a")); QUrl url6; - url6.setEncodedQuery("a=%2A"); + url6.setQuery(QLatin1String("a=%2A")); QCOMPARE(url5, url6); QUrl url7; - url7.setEncodedQuery("a=C"); + url7.setQuery(QLatin1String("a=C")); QUrl url8; - url8.setEncodedQuery("a=c"); + url8.setQuery(QLatin1String("a=c")); QVERIFY(url7 != url8); QVERIFY(url7 < url8); @@ -502,7 +502,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString::fromLatin1("file")); QCOMPARE(url.path(), QString::fromLatin1("/")); - QVERIFY(url.encodedQuery().isEmpty()); + QVERIFY(url.query().isEmpty()); QVERIFY(url.userInfo().isEmpty()); QVERIFY(url.authority().isEmpty()); QVERIFY(url.fragment().isEmpty()); @@ -517,7 +517,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString::fromLatin1("http")); QCOMPARE(url.path(), QString()); - QVERIFY(url.encodedQuery().isEmpty()); + QVERIFY(url.query().isEmpty()); QVERIFY(url.userInfo().isEmpty()); QVERIFY(url.fragment().isEmpty()); QCOMPARE(url.host(), QString::fromLatin1("www.foo.bar")); @@ -536,7 +536,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString::fromLatin1("http")); QCOMPARE(url.path(), QString()); - QVERIFY(url.encodedQuery().isEmpty()); + QVERIFY(url.query().isEmpty()); QCOMPARE(url.userName(), QString::fromLatin1("user:")); QCOMPARE(url.password(), QString::fromLatin1("pass@")); QCOMPARE(url.userInfo(), QString::fromLatin1("user%3A:pass@")); @@ -781,7 +781,7 @@ void tst_QUrl::setUrl() QVERIFY(url.isValid()); QCOMPARE(url.scheme(), QString("http")); QCOMPARE(url.host(), QString("1.2.3.4")); - QCOMPARE(url.encodedQuery(), QByteArray("foo")); + QCOMPARE(url.query(QUrl::FullyEncoded), QLatin1String("foo")); } { QUrl url; @@ -798,13 +798,13 @@ void tst_QUrl::setUrl() QCOMPARE(url.scheme(), QString("data")); QCOMPARE(url.host(), QString()); QCOMPARE(url.path(), QString("text/javascript,d5 = 'five\\u0027s';")); - QCOMPARE(url.encodedPath().constData(), "text/javascript,d5%20%3D%20'five%5Cu0027s'%3B"); + QCOMPARE(url.path(QUrl::FullyEncoded), QLatin1String("text/javascript,d5%20%3D%20'five%5Cu0027s'%3B")); } { // invalid port number QUrl url; - url.setEncodedUrl("foo://tel:2147483648"); + url.setUrl(QLatin1String("foo://tel:2147483648"), QUrl::StrictMode); QVERIFY(!url.isValid()); } @@ -1144,7 +1144,7 @@ void tst_QUrl::toString_constructed_data() QTest::addColumn<QString>("host"); QTest::addColumn<int>("port"); QTest::addColumn<QString>("path"); - QTest::addColumn<QByteArray>("query"); + QTest::addColumn<QString>("query"); QTest::addColumn<QString>("fragment"); QTest::addColumn<QString>("asString"); QTest::addColumn<QByteArray>("asEncoded"); @@ -1153,19 +1153,19 @@ void tst_QUrl::toString_constructed_data() QString n(""); QTest::newRow("data1") << n << n << n << QString::fromLatin1("qt-project.org") << -1 << QString::fromLatin1("/index.html") - << QByteArray() << n << QString::fromLatin1("//qt-project.org/index.html") + << QString() << n << QString::fromLatin1("//qt-project.org/index.html") << QByteArray("//qt-project.org/index.html") << 0u; - QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray() + QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QString() << n << QString::fromLatin1("file:///root") << QByteArray("file:///root") << 0u; QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde") - << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n + << "kde.org" << 443 << QString::fromLatin1("/") << QString() << n << QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/") << 0u; QTest::newRow("PassWithoutUser") << QString::fromLatin1("http") << n << QString::fromLatin1("kde") - << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n + << "kde.org" << 443 << QString::fromLatin1("/") << QString() << n << QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/") << 0u; QTest::newRow("PassWithoutUser-RemovePassword") << QString::fromLatin1("http") << n << QString::fromLatin1("kde") - << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n + << "kde.org" << 443 << QString::fromLatin1("/") << QString() << n << QString::fromLatin1("http://kde.org:443/") << QByteArray("http://kde.org:443/") << uint(QUrl::RemovePassword); } @@ -1178,7 +1178,7 @@ void tst_QUrl::toString_constructed() QFETCH(QString, host); QFETCH(int, port); QFETCH(QString, path); - QFETCH(QByteArray, query); + QFETCH(QString, query); QFETCH(QString, fragment); QFETCH(QString, asString); QFETCH(QByteArray, asEncoded); @@ -1198,7 +1198,7 @@ void tst_QUrl::toString_constructed() if (!path.isEmpty()) url.setPath(path); if (!query.isEmpty()) - url.setEncodedQuery(query); + url.setQuery(query, QUrl::StrictMode); if (!fragment.isEmpty()) url.setFragment(fragment); @@ -1757,7 +1757,7 @@ void tst_QUrl::symmetry() QCOMPARE(url.host(QUrl::EncodeUnicode | QUrl::EncodeSpaces), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se")); QCOMPARE(url.path(), QString::fromLatin1("/pub")); // this will be encoded ... - QCOMPARE(url.encodedQuery().constData(), QString::fromLatin1("a=b&a=d%C3%B8&a=f").toLatin1().constData()); + QCOMPARE(url.query(QUrl::FullyEncoded), QLatin1String("a=b&a=d%C3%B8&a=f")); QCOMPARE(url.fragment(), QString::fromUtf8("vræl")); QUrl onlyHost("//qt-project.org"); @@ -2009,7 +2009,7 @@ void tst_QUrl::hasQuery() QUrl qurl(url); QCOMPARE(qurl.hasQuery(), trueFalse); - QCOMPARE(qurl.encodedQuery().isNull(), !trueFalse); + QCOMPARE(qurl.query().isNull(), !trueFalse); } void tst_QUrl::nameprep() @@ -2192,10 +2192,12 @@ void tst_QUrl::schemeValidator_data() QTest::newRow("percent-encoded") << "%68%74%%74%70://example.com" << false << "%68%74%%74%70"; static const char controls[] = "!\"$&'()*,;<=>[\\]^_`{|}~"; - for (size_t i = 0; i < sizeof(controls) - 1; ++i) - QTest::newRow(("with-" + QByteArray(1, controls[i])).constData()) - << QString("pre%1post://example.com/").arg(QLatin1Char(controls[i])) - << false << QString("pre%1post").arg(QLatin1Char(controls[i])); + for (char control : controls) { + const QString scheme = QLatin1String("pre") + QLatin1Char(control) + QLatin1String("post"); + QTest::newRow((QByteArrayLiteral("with-") + control).constData()) + << (scheme + QLatin1String("://example.com/")) + << false << scheme; + } } void tst_QUrl::schemeValidator() @@ -2342,7 +2344,7 @@ void tst_QUrl::tolerantParser() QVERIFY(url.isValid()); QVERIFY(!url.toString().isEmpty()); QCOMPARE(url.path(), QString("/path with spaces.html")); - url.setEncodedUrl("http://www.example.com/path%20with spaces.html", QUrl::StrictMode); + url.setUrl(QLatin1String("http://www.example.com/path%20with spaces.html"), QUrl::StrictMode); QVERIFY(!url.isValid()); QVERIFY(url.toString().isEmpty()); } @@ -2392,36 +2394,36 @@ void tst_QUrl::tolerantParser() QCOMPARE(url.toEncoded(), QByteArray("%25hello.com/f%25")); QCOMPARE(url.toString(), QString("%25hello.com/f%25")); - url.setEncodedUrl("http://www.host.com/foo.php?P0=[2006-3-8]"); + url.setUrl(QLatin1String("http://www.host.com/foo.php?P0=[2006-3-8]"), QUrl::StrictMode); QVERIFY(url.isValid()); QVERIFY(!url.toString().isEmpty()); - url.setEncodedUrl("http://foo.bar/[image][1].jpg"); + url.setUrl(QLatin1String("http://foo.bar/[image][1].jpg"), QUrl::StrictMode); QVERIFY(url.isValid()); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("http://foo.bar/[image][1].jpg")); QCOMPARE(url.toEncoded(), QByteArray("http://foo.bar/[image][1].jpg")); QCOMPARE(url.toString(), QString("http://foo.bar/[image][1].jpg")); - url.setEncodedUrl("http://foo.bar/%5Bimage%5D%5B1%5D.jpg"); + url.setUrl(QLatin1String("http://foo.bar/%5Bimage%5D%5B1%5D.jpg"), QUrl::StrictMode); QVERIFY(url.isValid()); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("http://foo.bar/%5Bimage%5D%5B1%5D.jpg")); QCOMPARE(url.toEncoded(), QByteArray("http://foo.bar/%5Bimage%5D%5B1%5D.jpg")); QCOMPARE(url.toString(), QString("http://foo.bar/%5Bimage%5D%5B1%5D.jpg")); - url.setEncodedUrl("//[::56:56:56:56:56:56:56]"); + url.setUrl(QLatin1String("//[::56:56:56:56:56:56:56]"), QUrl::StrictMode); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("//[0:56:56:56:56:56:56:56]")); QCOMPARE(url.toEncoded(), QByteArray("//[0:56:56:56:56:56:56:56]")); - url.setEncodedUrl("data:text/css,div%20{%20border-right:%20solid;%20}"); + url.setUrl(QLatin1String("data:text/css,div%20{%20border-right:%20solid;%20}"), QUrl::TolerantMode); QCOMPARE(url.toString(QUrl::FullyEncoded), QString("data:text/css,div%20%7B%20border-right:%20solid;%20%7D")); QCOMPARE(url.toEncoded(), QByteArray("data:text/css,div%20%7B%20border-right:%20solid;%20%7D")); QCOMPARE(url.toString(), QString("data:text/css,div %7B border-right: solid; %7D")); } { - QByteArray tsdgeos("http://google.com/c?c=Translation+%C2%BB+trunk|"); + const QString tsdgeos = QLatin1String("http://google.com/c?c=Translation+%C2%BB+trunk|"); QUrl tsdgeosQUrl; - tsdgeosQUrl.setEncodedUrl(tsdgeos, QUrl::TolerantMode); + tsdgeosQUrl.setUrl(tsdgeos, QUrl::TolerantMode); QVERIFY(tsdgeosQUrl.isValid()); // failed in Qt-4.4, works in Qt-4.5 QByteArray tsdgeosExpected("http://google.com/c?c=Translation+%C2%BB+trunk%7C"); QCOMPARE(QString(tsdgeosQUrl.toEncoded()), QString(tsdgeosExpected)); @@ -2626,31 +2628,31 @@ void tst_QUrl::emptyQueryOrFragment() // start with an empty one QUrl url("http://www.foo.bar/baz"); QVERIFY(!url.hasQuery()); - QVERIFY(url.encodedQuery().isNull()); + QVERIFY(url.query().isNull()); // add encodedQuery url.setQuery("abc=def"); QVERIFY(url.hasQuery()); QCOMPARE(url.query(), QString(QLatin1String("abc=def"))); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?abc=def"))); - url.setEncodedQuery("abc=def"); + url.setQuery(QLatin1String("abc=def")); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?abc=def"))); // remove encodedQuery url.setQuery(QString()); QVERIFY(!url.hasQuery()); - QVERIFY(url.encodedQuery().isNull()); + QVERIFY(url.query().isNull()); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz"))); - url.setEncodedQuery(QByteArray()); + url.setQuery(QString()); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz"))); // add empty encodedQuery url.setQuery(""); QVERIFY(url.hasQuery()); - QVERIFY(url.encodedQuery().isEmpty()); - QVERIFY(!url.encodedQuery().isNull()); + QVERIFY(url.query().isEmpty()); + QVERIFY(!url.query().isNull()); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?"))); - url.setEncodedQuery(""); + url.setQuery(QLatin1String("")); QCOMPARE(url.toString(), QString(QLatin1String("http://www.foo.bar/baz?"))); } } @@ -2682,35 +2684,33 @@ void tst_QUrl::hasFragment() QCOMPARE(qurl.fragment().isNull(), !trueFalse); } -void tst_QUrl::setEncodedFragment_data() +void tst_QUrl::setFragment_data() { - QTest::addColumn<QByteArray>("base"); - QTest::addColumn<QByteArray>("fragment"); - QTest::addColumn<QByteArray>("expected"); + QTest::addColumn<QString>("base"); + QTest::addColumn<QString>("fragment"); + QTest::addColumn<QString>("expected"); - typedef QByteArray BA; - QTest::newRow("null") << BA("http://www.kde.org") << BA() << BA("http://www.kde.org"); - QTest::newRow("empty") << BA("http://www.kde.org") << BA("") << BA("http://www.kde.org#"); - QTest::newRow("basic test") << BA("http://www.kde.org") << BA("abc") << BA("http://www.kde.org#abc"); - QTest::newRow("initial url has fragment") << BA("http://www.kde.org#old") << BA("new") << BA("http://www.kde.org#new"); - QTest::newRow("encoded fragment") << BA("http://www.kde.org") << BA("a%20c") << BA("http://www.kde.org#a%20c"); - QTest::newRow("with #") << BA("http://www.kde.org") << BA("a#b") << BA("http://www.kde.org#a%23b"); // toString uses "a#b" - QTest::newRow("unicode") << BA("http://www.kde.org") << BA("\xc3\xa9") << BA("http://www.kde.org#%C3%A9"); - QTest::newRow("binary") << BA("http://www.kde.org") << BA("\x00\xc0\x80", 3) << BA("http://www.kde.org#%00%C0%80"); + QTest::newRow("null") << QString::fromLatin1("http://www.kde.org") << QString() << QString::fromLatin1("http://www.kde.org"); + QTest::newRow("empty") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("") << QString::fromLatin1("http://www.kde.org#"); + QTest::newRow("basic test") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("abc") << QString::fromLatin1("http://www.kde.org#abc"); + QTest::newRow("initial url has fragment") << QString::fromLatin1("http://www.kde.org#old") << QString::fromLatin1("new") << QString::fromLatin1("http://www.kde.org#new"); + QTest::newRow("encoded fragment") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("a%20c") << QString::fromLatin1("http://www.kde.org#a%20c"); + QTest::newRow("with #") << QString::fromLatin1("http://www.kde.org") << QString::fromLatin1("a#b") << QString::fromLatin1("http://www.kde.org#a%23b"); // toString uses "a#b" + QTest::newRow("unicode") << QString::fromLatin1("http://www.kde.org") << QString::fromUtf8("\xc3\xa9") << QString::fromLatin1("http://www.kde.org#%C3%A9"); } -void tst_QUrl::setEncodedFragment() +void tst_QUrl::setFragment() { - QFETCH(QByteArray, base); - QFETCH(QByteArray, fragment); - QFETCH(QByteArray, expected); + QFETCH(QString, base); + QFETCH(QString, fragment); + QFETCH(QString, expected); QUrl u; - u.setEncodedUrl(base, QUrl::TolerantMode); + u.setUrl(base, QUrl::TolerantMode); QVERIFY(u.isValid()); - u.setEncodedFragment(fragment); + u.setFragment(fragment); QVERIFY(u.isValid()); QCOMPARE(!fragment.isNull(), u.hasFragment()); - QCOMPARE(QString::fromLatin1(u.toEncoded()), QString::fromLatin1(expected)); + QCOMPARE(QString::fromUtf8(u.toEncoded()), expected); } void tst_QUrl::fromEncoded() @@ -3258,14 +3258,14 @@ void tst_QUrl::isEmptyForEncodedUrl() { { QUrl url; - url.setEncodedUrl("LABEL=USB_STICK", QUrl::TolerantMode); + url.setUrl(QLatin1String("LABEL=USB_STICK"), QUrl::TolerantMode); QVERIFY( url.isValid() ); QCOMPARE( url.path(), QString("LABEL=USB_STICK") ); QVERIFY( !url.isEmpty() ); } { QUrl url; - url.setEncodedUrl("LABEL=USB_STICK", QUrl::TolerantMode); + url.setUrl(QLatin1String("LABEL=USB_STICK"), QUrl::TolerantMode); QVERIFY( url.isValid() ); QVERIFY( !url.isEmpty() ); QCOMPARE( url.path(), QString("LABEL=USB_STICK") ); @@ -3277,7 +3277,7 @@ void tst_QUrl::isEmptyForEncodedUrl() void tst_QUrl::toEncodedNotUsingUninitializedPath() { QUrl url; - url.setEncodedPath("/test.txt"); + url.setPath(QLatin1String("/test.txt")); url.setHost("example.com"); QCOMPARE(url.toEncoded().constData(), "//example.com/test.txt"); @@ -3657,17 +3657,6 @@ void tst_QUrl::componentEncodings() QCOMPARE(url.toString(formatting), (((QString(toString ))))); // the weird () and space is to align the output - if (formatting == QUrl::FullyEncoded) { - QCOMPARE(url.encodedUserName(), userName.toUtf8()); - QCOMPARE(url.encodedPassword(), password.toUtf8()); - // no encodedUserInfo - QCOMPARE(url.encodedHost(), host.toUtf8()); - // no encodedAuthority - QCOMPARE(url.encodedPath(), path.toUtf8()); - QCOMPARE(url.encodedQuery(), query.toUtf8()); - QCOMPARE(url.encodedFragment(), fragment.toUtf8()); - } - // repeat with the URL we got from toString QUrl url2(toString); QCOMPARE(url2.userName(formatting), userName); @@ -4087,13 +4076,12 @@ public: QVector<QUrl> m_urls; }; -static const UrlStorage * s_urlStorage = 0; +static const UrlStorage * s_urlStorage = nullptr; void tst_QUrl::testThreadingHelper() { const UrlStorage* storage = s_urlStorage; - for (int i = 0 ; i < storage->m_urls.size(); ++i ) { - const QUrl& u = storage->m_urls.at(i); + for (const auto &u : storage->m_urls) { // QVERIFY/QCOMPARE trigger race conditions in helgrind if (!u.isValid()) qFatal("invalid url"); diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index b960ca9220..3a4493474b 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -309,7 +309,8 @@ bool QtTestModel::moveColumns(const QModelIndex &sourceParent, int src, int cnt, void QtTestModel::reset() { - QAbstractItemModel::reset(); + QAbstractItemModel::beginResetModel(); + QAbstractItemModel::endResetModel(); } bool QtTestModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, @@ -1785,13 +1786,12 @@ class ModelWithCustomRole : public QStringListModel { Q_OBJECT public: - ModelWithCustomRole(QObject *parent = 0) - : QStringListModel(parent) - { - QHash<int, QByteArray> roleNames_ = roleNames(); - roleNames_.insert(Qt::UserRole + 1, "custom"); - setRoleNames(roleNames_); - } + using QStringListModel::QStringListModel; + + QHash<int, QByteArray> roleNames() const override + { + return {{Qt::UserRole + 1, QByteArrayLiteral("custom")}}; + } }; ListenerObject::ListenerObject(QAbstractProxyModel *parent) diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp index 886941bff6..adb93b7a75 100644 --- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp @@ -313,11 +313,12 @@ public: CustomRole2 }; - StandardItemModelWithCustomRoleNames() { - QHash<int, QByteArray> _roleNames = roleNames(); - _roleNames.insert(CustomRole1, "custom1"); - _roleNames.insert(CustomRole2, "custom2"); - setRoleNames(_roleNames); + QHash<int, QByteArray> roleNames() const override + { + auto result = QStandardItemModel::roleNames(); + result.insert(CustomRole1, QByteArrayLiteral("custom1")); + result.insert(CustomRole2, QByteArrayLiteral("custom2")); + return result; } }; @@ -329,11 +330,10 @@ public: AnotherCustomRole2 }; - AnotherStandardItemModelWithCustomRoleNames() { - QHash<int, QByteArray> _roleNames = roleNames(); - _roleNames.insert(AnotherCustomRole1, "another_custom1"); - _roleNames.insert(AnotherCustomRole2, "another_custom2"); - setRoleNames(_roleNames); + QHash<int, QByteArray> roleNames() const override + { + return {{AnotherCustomRole1, QByteArrayLiteral("another_custom1")}, + {AnotherCustomRole2, QByteArrayLiteral("another_custom2")}}; } }; diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp index dbc7173028..354190e754 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp @@ -153,7 +153,7 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType) QStandardItemModel *standardItemModel = new QStandardItemModel; model->setSourceModel(standardItemModel); populateTestArea(model); - model->setFilterRegExp(QRegExp("(^$|I.*)")); + model->setFilterRegularExpression(QRegularExpression("(^$|I.*)")); return model; } diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 6fbaa28d69..f78f5bc138 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -2211,8 +2211,8 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() } QModelIndex root = model.index(0,0); - QModelIndex par = root.child(0,0); - QModelIndex sel = par.child(0,0); + QModelIndex par = model.index(0, 0, root); + QModelIndex sel = model.index(0, 0, par); QItemSelectionModel selectionModel(&model); selectionModel.select(sel, QItemSelectionModel::SelectCurrent); @@ -2240,9 +2240,9 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() } } - sel = model.index(0, 0).child(0, 0); + sel = model.index(0, 0, model.index(0, 0)); selectionModel.select(sel, QItemSelectionModel::Select); - QModelIndex sel2 = model.index(1, 0).child(0, 0); + QModelIndex sel2 = model.index(0, 0, model.index(1, 0)); selectionModel.select(sel2, QItemSelectionModel::Select); QVERIFY(selectionModel.selection().contains(sel)); @@ -2264,7 +2264,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1() QCOMPARE(model.rowCount(), 3); QCOMPARE(proxy.rowCount(), 3); - proxy.setFilterRegExp( QRegExp("f")); + proxy.setFilterRegularExpression(QRegularExpression("f")); QCOMPARE(proxy.rowCount(), 2); QList<QPersistentModelIndex> indexList; @@ -2276,7 +2276,7 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected1() foreach(QPersistentModelIndex index, indexList) QVERIFY(selection.isSelected(index)); - proxy.setFilterRegExp(QRegExp()); + proxy.setFilterRegularExpression(QRegularExpression()); QCOMPARE(proxy.rowCount(), 3); //let's check the selection hasn't changed diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp index ccce5a44e5..0f7588a71a 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp @@ -3977,7 +3977,7 @@ void tst_QSortFilterProxyModel::hierarchyFilterInvalidation() QTreeView view; view.setModel(&proxy); - view.setCurrentIndex(proxy.index(2, 0).child(0, 0)); + view.setCurrentIndex(proxy.index(0, 0, proxy.index(2, 0))); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index 0b8686560c..3919472b96 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -333,7 +333,7 @@ template <class C> C sorted(C c) { std::sort(c.begin(), c.end()); - return qMove(c); + return std::move(c); } void tst_QStringListModel::setData_emits_both_roles() diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 6adb393ddd..39c90f69b4 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -611,7 +611,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() TestApplication app(argc, argv); ProcessEventsAlwaysSendsPostedEventsObject object; - QTime t; + QElapsedTimer t; t.start(); int i = 1; do { @@ -775,49 +775,49 @@ private slots: QCoreApplicationPrivate *privateClass = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp)); { - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); // Test with a lock active so that the refcount doesn't drop to zero during these tests, causing a quit. // (until we exit the scope) QEventLoopLocker locker; - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); JobObject *job1 = new JobObject(this); - QCOMPARE(privateClass->quitLockRef.load(), 2); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 2); delete job1; - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); job1 = new JobObject(this); - QCOMPARE(privateClass->quitLockRef.load(), 2); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 2); JobObject *job2 = new JobObject(this); - QCOMPARE(privateClass->quitLockRef.load(), 3); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 3); delete job1; - QCOMPARE(privateClass->quitLockRef.load(), 2); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 2); JobObject *job3 = new JobObject(job2); Q_UNUSED(job3); - QCOMPARE(privateClass->quitLockRef.load(), 3); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 3); JobObject *job4 = new JobObject(job2); Q_UNUSED(job4); - QCOMPARE(privateClass->quitLockRef.load(), 4); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 4); delete job2; - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); } - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); } }; diff --git a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro index 295a42aa9c..159761c0c6 100644 --- a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro +++ b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro @@ -3,6 +3,6 @@ TARGET = tst_qeventloop QT = core network testlib core-private SOURCES = $$PWD/tst_qeventloop.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 qtConfig(glib): DEFINES += HAVE_GLIB diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 482ed8d130..1f0b8d4b4e 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -638,16 +638,16 @@ void tst_QEventLoop::testQuitLock() QEventLoopPrivate* privateClass = static_cast<QEventLoopPrivate*>(QObjectPrivate::get(&eventLoop)); - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); JobObject *job1 = new JobObject(&eventLoop, this); job1->start(500); - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); eventLoop.exec(); - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); job1 = new JobObject(&eventLoop, this); diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp index 681a5d0146..cc67fc7884 100644 --- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp +++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp @@ -130,7 +130,7 @@ public: QString m_value; void setValue(const QString &value) { m_value = value; } QString getValue() { return m_value; } - void resetValue() { m_value = QLatin1Literal("reset"); } + void resetValue() { m_value = QLatin1String("reset"); } }; void tst_QMetaProperty::gadget() @@ -140,7 +140,7 @@ void tst_QMetaProperty::gadget() QVERIFY(valueProp.isValid()); { MyGadget g; - QString hello = QLatin1Literal("hello"); + QString hello = QLatin1String("hello"); QVERIFY(valueProp.writeOnGadget(&g, hello)); QCOMPARE(g.m_value, QLatin1String("hello")); QCOMPARE(valueProp.readOnGadget(&g), QVariant(hello)); @@ -242,7 +242,7 @@ void tst_QMetaProperty::conversion() QCOMPARE(custom.str, QString()); // or reset resetable QVERIFY(value7P.write(this, QVariant())); - QCOMPARE(value7, QLatin1Literal("reset")); + QCOMPARE(value7, QLatin1String("reset")); } QTEST_MAIN(tst_QMetaProperty) diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index e2bb7dab2a..28458c43c7 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1499,7 +1499,7 @@ public: typedef MyObject* MyObjectPtr; Q_DECLARE_METATYPE(MyObjectPtr) -#if defined(Q_COMPILER_VARIADIC_MACROS) && !defined(TST_QMETATYPE_BROKEN_COMPILER) +#if !defined(TST_QMETATYPE_BROKEN_COMPILER) static QByteArray createTypeName(const char *begin, const char *va) { QByteArray tn(begin); @@ -1697,7 +1697,7 @@ void tst_QMetaType::automaticTemplateRegistration() QVERIFY(qRegisterMetaType<UnregisteredTypeList>("UnregisteredTypeList") > 0); } -#if defined(Q_COMPILER_VARIADIC_MACROS) && !defined(TST_QMETATYPE_BROKEN_COMPILER) +#if !defined(TST_QMETATYPE_BROKEN_COMPILER) #define FOR_EACH_STATIC_PRIMITIVE_TYPE(F) \ F(bool) \ @@ -1776,7 +1776,7 @@ void tst_QMetaType::automaticTemplateRegistration() CREATE_AND_VERIFY_CONTAINER(QHash, void*, void*) CREATE_AND_VERIFY_CONTAINER(QHash, const void*, const void*) -#endif // Q_COMPILER_VARIADIC_MACROS +#endif // !defined(TST_QMETATYPE_BROKEN_COMPILER) #define TEST_OWNING_SMARTPOINTER(SMARTPOINTER, ELEMENT_TYPE, FLAG_TEST, FROMVARIANTFUNCTION) \ { \ @@ -2565,9 +2565,7 @@ Q_DECLARE_METATYPE(UndefinedFunction0); Q_DECLARE_METATYPE(UndefinedFunction1); Q_DECLARE_METATYPE(UndefinedFunction2); Q_DECLARE_METATYPE(UndefinedFunction3); -#ifdef Q_COMPILER_VARIADIC_TEMPLATES Q_DECLARE_METATYPE(UndefinedFunction4); -#endif QTEST_MAIN(tst_QMetaType) #include "tst_qmetatype.moc" diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h index 6bda9638f7..22bcb69ac9 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h @@ -236,7 +236,7 @@ template<> struct TestValueFactory<QMetaType::QRegExp> { template<> struct TestValueFactory<QMetaType::QRegularExpression> { static QRegularExpression *create() { -#ifndef QT_NO_REGEXP +#if QT_CONFIG(regularexpression) return new QRegularExpression("abc.*def"); #else return 0; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 31268c5cf3..7c9d8a476a 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -32,7 +32,6 @@ #include <qcoreapplication.h> #include <qpointer.h> #include <qtimer.h> -#include <qregexp.h> #include <qregularexpression.h> #include <qmetaobject.h> #include <qvariant.h> @@ -154,6 +153,8 @@ private slots: void mutableFunctor(); void checkArgumentsForNarrowing(); void nullReceiver(); + void functorReferencesConnection(); + void disconnectDisconnects(); }; struct QObjectCreatedOnShutdown @@ -535,91 +536,91 @@ void tst_QObject::findChildren() QObject *op = 0; - op = qFindChild<QObject*>(&o, "o1"); + op = o.findChild<QObject*>("o1"); QCOMPARE(op, &o1); - op = qFindChild<QObject*>(&o, "o2"); + op = o.findChild<QObject*>("o2"); QCOMPARE(op, &o2); - op = qFindChild<QObject*>(&o, "o11"); + op = o.findChild<QObject*>("o11"); QCOMPARE(op, &o11); - op = qFindChild<QObject*>(&o, "o12"); + op = o.findChild<QObject*>("o12"); QCOMPARE(op, &o12); - op = qFindChild<QObject*>(&o, "o111"); + op = o.findChild<QObject*>("o111"); QCOMPARE(op, &o111); - op = qFindChild<QObject*>(&o, "t1"); + op = o.findChild<QObject*>("t1"); QCOMPARE(op, static_cast<QObject *>(&t1)); - op = qFindChild<QObject*>(&o, "t121"); + op = o.findChild<QObject*>("t121"); QCOMPARE(op, static_cast<QObject *>(&t121)); - op = qFindChild<QTimer*>(&o, "t1"); + op = o.findChild<QTimer*>("t1"); QCOMPARE(op, static_cast<QObject *>(&t1)); - op = qFindChild<QTimer*>(&o, "t121"); + op = o.findChild<QTimer*>("t121"); QCOMPARE(op, static_cast<QObject *>(&t121)); - op = qFindChild<QTimer*>(&o, "o12"); + op = o.findChild<QTimer*>("o12"); QCOMPARE(op, static_cast<QObject *>(0)); - op = qFindChild<QObject*>(&o, "o"); + op = o.findChild<QObject*>("o"); QCOMPARE(op, static_cast<QObject *>(0)); - op = qFindChild<QObject*>(&o, "harry"); + op = o.findChild<QObject*>("harry"); QCOMPARE(op, static_cast<QObject *>(0)); - op = qFindChild<QObject*>(&o, "o1"); + op = o.findChild<QObject*>("o1"); QCOMPARE(op, &o1); QList<QObject*> l; QList<QTimer*> tl; - l = qFindChildren<QObject*>(&o, "o1"); + l = o.findChildren<QObject*>("o1"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o1); - l = qFindChildren<QObject*>(&o, "o2"); + l = o.findChildren<QObject*>("o2"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o2); - l = qFindChildren<QObject*>(&o, "o11"); + l = o.findChildren<QObject*>("o11"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o11); - l = qFindChildren<QObject*>(&o, "o12"); + l = o.findChildren<QObject*>("o12"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o12); - l = qFindChildren<QObject*>(&o, "o111"); + l = o.findChildren<QObject*>("o111"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o111); - l = qFindChildren<QObject*>(&o, "t1"); + l = o.findChildren<QObject*>("t1"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), static_cast<QObject *>(&t1)); - l = qFindChildren<QObject*>(&o, "t121"); + l = o.findChildren<QObject*>("t121"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), static_cast<QObject *>(&t121)); - tl = qFindChildren<QTimer*>(&o, "t1"); + tl = o.findChildren<QTimer*>("t1"); QCOMPARE(tl.size(), 1); QCOMPARE(tl.at(0), &t1); - tl = qFindChildren<QTimer*>(&o, "t121"); + tl = o.findChildren<QTimer*>("t121"); QCOMPARE(tl.size(), 1); QCOMPARE(tl.at(0), &t121); - l = qFindChildren<QObject*>(&o, "o"); + l = o.findChildren<QObject*>("o"); QCOMPARE(l.size(), 0); - l = qFindChildren<QObject*>(&o, "harry"); + l = o.findChildren<QObject*>("harry"); QCOMPARE(l.size(), 0); - tl = qFindChildren<QTimer*>(&o, "o12"); + tl = o.findChildren<QTimer*>("o12"); QCOMPARE(tl.size(), 0); - l = qFindChildren<QObject*>(&o, "o1"); + l = o.findChildren<QObject*>("o1"); QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o1); - l = qFindChildren<QObject*>(&o, QRegExp("o.*")); + l = o.findChildren<QObject*>(QRegularExpression("^o.*$")); QCOMPARE(l.size(), 5); QVERIFY(l.contains(&o1)); QVERIFY(l.contains(&o2)); QVERIFY(l.contains(&o11)); QVERIFY(l.contains(&o12)); QVERIFY(l.contains(&o111)); - l = qFindChildren<QObject*>(&o, QRegExp("t.*")); + l = o.findChildren<QObject*>(QRegularExpression("t.*")); QCOMPARE(l.size(), 2); QVERIFY(l.contains(&t1)); QVERIFY(l.contains(&t121)); - tl = qFindChildren<QTimer*>(&o, QRegExp(".*")); + tl = o.findChildren<QTimer*>(QRegularExpression("^.*$")); QCOMPARE(tl.size(), 3); QVERIFY(tl.contains(&t1)); QVERIFY(tl.contains(&t121)); - tl = qFindChildren<QTimer*>(&o, QRegExp("o.*")); + tl = o.findChildren<QTimer*>(QRegularExpression("^o.*$")); QCOMPARE(tl.size(), 0); - l = qFindChildren<QObject*>(&o, QRegExp("harry")); + l = o.findChildren<QObject*>(QRegularExpression("^harry$")); QCOMPARE(l.size(), 0); l = o.findChildren<QObject*>(QRegularExpression("o.*")); @@ -643,18 +644,18 @@ void tst_QObject::findChildren() QCOMPARE(l.size(), 0); // empty and null string check - op = qFindChild<QObject*>(&o); + op = o.findChild<QObject*>(); QCOMPARE(op, &o1); - op = qFindChild<QObject*>(&o, ""); + op = o.findChild<QObject*>(""); QCOMPARE(op, &unnamed); - op = qFindChild<QObject*>(&o, "unnamed"); + op = o.findChild<QObject*>("unnamed"); QCOMPARE(op, static_cast<QObject *>(0)); - l = qFindChildren<QObject*>(&o); + l = o.findChildren<QObject*>(); QCOMPARE(l.size(), 9); - l = qFindChildren<QObject*>(&o, ""); + l = o.findChildren<QObject*>(""); QCOMPARE(l.size(), 2); - l = qFindChildren<QObject*>(&o, "unnamed"); + l = o.findChildren<QObject*>("unnamed"); QCOMPARE(l.size(), 0); tl = o.findChildren<QTimer *>("t1"); @@ -722,19 +723,19 @@ void tst_QObject::findChildren() QCOMPARE(l.size(), 1); QCOMPARE(l.at(0), &o1); - l = o.findChildren<QObject*>(QRegExp("o.*"), Qt::FindDirectChildrenOnly); + l = o.findChildren<QObject*>(QRegularExpression("^o.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(l.size(), 2); QVERIFY(l.contains(&o1)); QVERIFY(l.contains(&o2)); - l = o.findChildren<QObject*>(QRegExp("t.*"), Qt::FindDirectChildrenOnly); + l = o.findChildren<QObject*>(QRegularExpression("^t.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(l.size(), 1); QVERIFY(l.contains(&t1)); - tl = o.findChildren<QTimer*>(QRegExp(".*"), Qt::FindDirectChildrenOnly); + tl = o.findChildren<QTimer*>(QRegularExpression("^.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(tl.size(), 2); QVERIFY(tl.contains(&t1)); - tl = o.findChildren<QTimer*>(QRegExp("o.*"), Qt::FindDirectChildrenOnly); + tl = o.findChildren<QTimer*>(QRegularExpression("^o.*$"), Qt::FindDirectChildrenOnly); QCOMPARE(tl.size(), 0); - l = o.findChildren<QObject*>(QRegExp("harry"), Qt::FindDirectChildrenOnly); + l = o.findChildren<QObject*>(QRegularExpression("^harry$"), Qt::FindDirectChildrenOnly); QCOMPARE(l.size(), 0); // empty and null string check @@ -1033,18 +1034,16 @@ public Q_SLOTS: void tst_QObject::connectNotify_connectSlotsByName() { ConnectByNameNotifyReceiverObject testObject; - QList<ConnectByNameNotifySenderObject *> senders = - qFindChildren<ConnectByNameNotifySenderObject *>(&testObject); - for (int i = 0; i < senders.size(); ++i) { - ConnectByNameNotifySenderObject *o = senders.at(i); + const QList<ConnectByNameNotifySenderObject *> senders = + testObject.findChildren<ConnectByNameNotifySenderObject *>(); + for (ConnectByNameNotifySenderObject *o : senders) { QVERIFY(o->connectedSignals.isEmpty()); QVERIFY(o->disconnectedSignals.isEmpty()); } QMetaObject::connectSlotsByName(&testObject); - for (int i = 0; i < senders.size(); ++i) { - ConnectByNameNotifySenderObject *o = senders.at(i); + for (ConnectByNameNotifySenderObject *o : senders) { QCOMPARE(o->connectedSignals.size(), 1); QCOMPARE(o->connectedSignals.at(0), QMetaMethod::fromSignal(&ConnectByNameNotifySenderObject::signal1)); QVERIFY(o->disconnectedSignals.isEmpty()); @@ -1629,7 +1628,7 @@ void tst_QObject::thread() QObject object; // thread affinity for objects with no parent should be the // current thread - QVERIFY(object.thread() != 0); + QVERIFY(object.thread() != nullptr); QCOMPARE(object.thread(), currentThread); // children inherit their parent's thread QObject child(&object); @@ -1641,7 +1640,7 @@ void tst_QObject::thread() { TestThread thr; - QVERIFY(thr.thread() != 0); + QVERIFY(thr.thread() != nullptr); QCOMPARE(thr.thread(), currentThread); thr.object = &object; @@ -1800,8 +1799,8 @@ void tst_QObject::moveToThread() QMetaObject::invokeMethod(object, "deleteLater", Qt::QueuedConnection); thread.wait(); - QVERIFY(opointer == 0); - QVERIFY(cpointer == 0); + QVERIFY(opointer == nullptr); + QVERIFY(cpointer == nullptr); } { @@ -2377,7 +2376,7 @@ void tst_QObject::testUserData() for (int i=0; i<USER_DATA_COUNT; ++i) { int id = user_data_ids[i]; CustomData *data = static_cast<CustomData *>(my_test_object.userData(id)); - QVERIFY(data != 0); + QVERIFY(data != nullptr); QCOMPARE(data->id, id); } } @@ -3409,12 +3408,11 @@ void tst_QObject::disconnectSelfInSlotAndDeleteAfterEmit() void tst_QObject::dumpObjectInfo() { QObject a, b; - QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater())); - a.disconnect(&b); + QObject::connect(&a, &QObject::destroyed, &b, &QObject::deleteLater); QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT"); QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)"); - QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>"); + QTest::ignoreMessage(QtDebugMsg, " <functor or function pointer>"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN"); QTest::ignoreMessage(QtDebugMsg, " <None>"); a.dumpObjectInfo(); // should not crash @@ -3626,7 +3624,7 @@ class OverloadObject : public QObject void sig(int i, int j = 12); void sig(QObject *o, QObject *p, QObject *q = 0, QObject *r = 0) const; void other(int a = 0); - void sig(QObject *o, OverloadObject *p = 0, QObject *q = 0, QObject *r = 0); + void sig(QObject *o, OverloadObject *p = 0, QObject *q = 0, QObject *r = nullptr); void sig(double r = 0.5); public slots: void slo(int i, int j = 43) @@ -4793,13 +4791,13 @@ class LotsOfSignalsAndSlots: public QObject public slots: void slot_v() {} - void slot_v_noexcept() Q_DECL_NOTHROW {} + void slot_v_noexcept() noexcept {} void slot_vi(int) {} - void slot_vi_noexcept() Q_DECL_NOTHROW {} + void slot_vi_noexcept() noexcept {} void slot_vii(int, int) {} void slot_viii(int, int, int) {} int slot_i() { return 0; } - int slot_i_noexcept() Q_DECL_NOTHROW { return 0; } + int slot_i_noexcept() noexcept { return 0; } int slot_ii(int) { return 0; } int slot_iii(int, int) { return 0; } int slot_iiii(int, int, int) { return 0; } @@ -4813,18 +4811,18 @@ class LotsOfSignalsAndSlots: public QObject void slot_vPFvvE(fptr) {} void const_slot_v() const {}; - void const_slot_v_noexcept() const Q_DECL_NOTHROW {} + void const_slot_v_noexcept() const noexcept {} void const_slot_vi(int) const {}; - void const_slot_vi_noexcept(int) const Q_DECL_NOTHROW {} + void const_slot_vi_noexcept(int) const noexcept {} static void static_slot_v() {} - static void static_slot_v_noexcept() Q_DECL_NOTHROW {} + static void static_slot_v_noexcept() noexcept {} static void static_slot_vi(int) {} - static void static_slot_vi_noexcept(int) Q_DECL_NOTHROW {} + static void static_slot_vi_noexcept(int) noexcept {} static void static_slot_vii(int, int) {} static void static_slot_viii(int, int, int) {} static int static_slot_i() { return 0; } - static int static_slot_i_noexcept() Q_DECL_NOTHROW { return 0; } + static int static_slot_i_noexcept() noexcept { return 0; } static int static_slot_ii(int) { return 0; } static int static_slot_iii(int, int) { return 0; } static int static_slot_iiii(int, int, int) { return 0; } @@ -4987,11 +4985,11 @@ void tst_QObject::connectCxx0xTypeMatching() } -void receiverFunction_noexcept() Q_DECL_NOTHROW {} -struct Functor_noexcept { void operator()() Q_DECL_NOTHROW {} }; +void receiverFunction_noexcept() noexcept {} +struct Functor_noexcept { void operator()() noexcept {} }; void tst_QObject::connectCxx17Noexcept() { - // this is about connecting signals to slots with the Q_DECL_NOTHROW qualifier + // this is about connecting signals to slots with the noexcept qualifier // as semantics changed due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html typedef LotsOfSignalsAndSlots Foo; Foo obj; @@ -5981,7 +5979,7 @@ void ConnectToPrivateSlot::test(SenderObject* obj1) { obj1->signal1(); QCOMPARE(d->receivedCount, 1); QCOMPARE(d->receivedValue, QVariant()); - obj1->signal7(666, QLatin1Literal("_")); + obj1->signal7(666, QLatin1String("_")); QCOMPARE(d->receivedCount, 2); QCOMPARE(d->receivedValue, QVariant(666)); QVERIFY(QObjectPrivate::connect(obj1, &SenderObject::signal2, d, &ConnectToPrivateSlotPrivate::thisIsAPrivateSlot, Qt::UniqueConnection)); @@ -6028,7 +6026,6 @@ void tst_QObject::connectFunctorArgDifference() QStringListModel model; connect(&model, &QStringListModel::rowsInserted, SlotFunctor()); -#if defined(Q_COMPILER_LAMBDA) connect(&timer, &QTimer::timeout, [=](){}); connect(&timer, &QTimer::objectNameChanged, [=](const QString &){}); connect(qApp, &QCoreApplication::aboutToQuit, [=](){}); @@ -6036,7 +6033,6 @@ void tst_QObject::connectFunctorArgDifference() connect(&timer, &QTimer::objectNameChanged, [=](){}); connect(&model, &QStringListModel::rowsInserted, [=](){}); connect(&model, &QStringListModel::rowsInserted, [=](const QModelIndex &){}); -#endif QVERIFY(true); } @@ -6074,7 +6070,6 @@ void tst_QObject::connectFunctorQueued() e.exec(); QCOMPARE(status, 2); -#if defined(Q_COMPILER_LAMBDA) status = 1; connect(&obj, &SenderObject::signal1, this, [&status] { status = 2; }, Qt::QueuedConnection); @@ -6082,7 +6077,6 @@ void tst_QObject::connectFunctorQueued() QCOMPARE(status, 1); e.exec(); QCOMPARE(status, 2); -#endif } void tst_QObject::connectFunctorWithContext() @@ -6116,7 +6110,6 @@ void tst_QObject::connectFunctorWithContext() e.exec(); QCOMPARE(status, 2); -#if defined(Q_COMPILER_LAMBDA) status = 1; connect(&obj, &SenderObject::signal1, this, [this, &status, &obj] { status = 2; QCOMPARE(sender(), &obj); }, Qt::QueuedConnection); @@ -6124,7 +6117,6 @@ void tst_QObject::connectFunctorWithContext() QCOMPARE(status, 1); e.exec(); QCOMPARE(status, 2); -#endif // Free context->deleteLater(); @@ -6434,7 +6426,7 @@ void connectFunctorOverload_impl(Signal signal, int expOverload, QList<QVariant> void tst_QObject::connectFunctorOverloads() { -#if defined (Q_COMPILER_DECLTYPE) && defined (Q_COMPILER_VARIADIC_TEMPLATES) +#if defined (Q_COMPILER_VARIADIC_TEMPLATES) connectFunctorOverload_impl<ComplexFunctor>(&FunctorArgDifferenceObject::signal_ii, 1, (QList<QVariant>() << 1 << 2)); connectFunctorOverload_impl<ComplexFunctor>(&FunctorArgDifferenceObject::signal_iiS, 1, @@ -6608,7 +6600,6 @@ void tst_QObject::disconnectDoesNotLeakFunctor() } QCOMPARE(countedStructObjectsCount, 0); { -#if defined(Q_COMPILER_LAMBDA) CountedStruct s; QCOMPARE(countedStructObjectsCount, 1); QTimer timer; @@ -6618,7 +6609,6 @@ void tst_QObject::disconnectDoesNotLeakFunctor() QCOMPARE(countedStructObjectsCount, 2); QVERIFY(QObject::disconnect(c)); QCOMPARE(countedStructObjectsCount, 1); -#endif // Q_COMPILER_LAMBDA } QCOMPARE(countedStructObjectsCount, 0); } @@ -6666,7 +6656,6 @@ void tst_QObject::contextDoesNotLeakFunctor() } QCOMPARE(countedStructObjectsCount, 0); { -#if defined(Q_COMPILER_LAMBDA) CountedStruct s; QEventLoop e; ContextObject *context = new ContextObject; @@ -6679,7 +6668,6 @@ void tst_QObject::contextDoesNotLeakFunctor() context->deleteLater(); e.exec(); QCOMPARE(countedStructObjectsCount, 1); -#endif // Q_COMPILER_LAMBDA } QCOMPARE(countedStructObjectsCount, 0); } @@ -7487,6 +7475,167 @@ void tst_QObject::nullReceiver() QVERIFY(!connect(&o, SIGNAL(destroyed()), nullObj, SLOT(deleteLater()))); } +void tst_QObject::functorReferencesConnection() +{ + countedStructObjectsCount = 0; + QMetaObject::Connection globalCon; + { + GetSenderObject obj; + CountedStruct counted(&obj); + QCOMPARE(countedStructObjectsCount, 1); + auto c = QSharedPointer<QMetaObject::Connection>::create(); + int slotCalled = 0; + *c = connect(&obj, &GetSenderObject::aSignal, &obj, [&slotCalled, c, counted] { + QObject::disconnect(*c); + slotCalled++; + }); + globalCon = *c; // keep a handle to the connection somewhere; + QVERIFY(globalCon); + QCOMPARE(countedStructObjectsCount, 2); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + QVERIFY(!globalCon); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + } + QCOMPARE(countedStructObjectsCount, 0); + + { + GetSenderObject obj; + CountedStruct counted(&obj); + QCOMPARE(countedStructObjectsCount, 1); + auto *rec = new QObject; + int slotCalled = 0; + globalCon = connect(&obj, &GetSenderObject::aSignal, rec, [&slotCalled, rec, counted] { + delete rec; + slotCalled++; + }); + QCOMPARE(countedStructObjectsCount, 2); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + QVERIFY(!globalCon); + obj.triggerSignal(); + QCOMPARE(slotCalled, 1); + QCOMPARE(countedStructObjectsCount, 1); + } + QCOMPARE(countedStructObjectsCount, 0); + { + int slotCalled = 0; + QEventLoop eventLoop; + { + // Sender will be destroyed when the labda goes out of scope lambda, so it will exit the event loop + auto sender = QSharedPointer<GetSenderObject>::create(); + connect(sender.data(), &QObject::destroyed, &eventLoop, &QEventLoop::quit, Qt::QueuedConnection); + globalCon = connect(sender.data(), &GetSenderObject::aSignal, this, [&slotCalled, sender, &globalCon, this] { + ++slotCalled; + // This signal will be connected, but should never be called as the sender will be destroyed before + auto c2 = connect(sender.data(), &GetSenderObject::aSignal, [] { QFAIL("Should not be called"); }); + QVERIFY(c2); + QVERIFY(QObject::disconnect(sender.data(), nullptr, this, nullptr)); + QVERIFY(!globalCon); // this connection has been disconnected + QVERIFY(c2); // sender should not have been deleted yet, only after the emission is done + }); + QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection); + QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection); + QMetaObject::invokeMethod(sender.data(), &GetSenderObject::triggerSignal, Qt::QueuedConnection); + } + eventLoop.exec(); + QCOMPARE(slotCalled, 1); + } + + { + GetSenderObject obj; + CountedStruct counted(&obj); + QCOMPARE(countedStructObjectsCount, 1); + auto c1 = QSharedPointer<QMetaObject::Connection>::create(); + auto c2 = QSharedPointer<QMetaObject::Connection>::create(); + int slot1Called = 0; + int slot3Called = 0; + *c1 = connect(&obj, &GetSenderObject::aSignal, &obj, [&slot1Called, &slot3Called, &obj, c1, c2, counted] { + auto c3 = connect(&obj, &GetSenderObject::aSignal, [counted, &slot3Called] { + slot3Called++; + }); + // top-level + the one in the 3 others lambdas + QCOMPARE(countedStructObjectsCount, 4); + QObject::disconnect(*c2); + slot1Called++; + }); + connect(&obj, &GetSenderObject::aSignal, [] {}); // just a dummy signal to fill the connection list + *c2 = connect(&obj, &GetSenderObject::aSignal, [counted, c2] { QFAIL("should not be called"); }); + QVERIFY(c1 && c2); + QCOMPARE(countedStructObjectsCount, 3); // top-level + c1 + c2 + obj.triggerSignal(); + QCOMPARE(slot1Called, 1); + QCOMPARE(slot3Called, 0); + QCOMPARE(countedStructObjectsCount, 3); // top-level + c1 + c3 + QObject::disconnect(*c1); + QCOMPARE(countedStructObjectsCount, 2); // top-level + c3 + obj.triggerSignal(); + QCOMPARE(slot1Called, 1); + QCOMPARE(slot3Called, 1); + } + { + struct DestroyEmit { + Q_DISABLE_COPY(DestroyEmit); + explicit DestroyEmit(SenderObject *obj) : obj(obj) {} + SenderObject *obj; + ~DestroyEmit() { + obj->emitSignal1(); + } + }; + SenderObject obj; + int slot1Called = 0; + int slot2Called = 0; + int slot3Called = 0; + auto c1 = QSharedPointer<QMetaObject::Connection>::create(); + auto de = QSharedPointer<DestroyEmit>::create(&obj); + *c1 = connect(&obj, &SenderObject::signal1, [&slot1Called, &slot3Called, de, c1, &obj] { + connect(&obj, &SenderObject::signal1, [&slot3Called] { slot3Called++; }); + slot1Called++; + QObject::disconnect(*c1); + }); + de.clear(); + connect(&obj, &SenderObject::signal1, [&slot2Called] { slot2Called++; }); + obj.emitSignal1(); + QCOMPARE(slot1Called, 1); + QCOMPARE(slot2Called, 2); // because also called from ~DestroyEmit + QCOMPARE(slot3Called, 1); + } +} + +void tst_QObject::disconnectDisconnects() +{ + // Test what happens if the destructor of an functor slot also disconnects more slot; + + SenderObject s1; + QScopedPointer<QObject> receiver(new QObject); + + auto s2 = QSharedPointer<SenderObject>::create(); + QPointer<QObject> s2_tracker = s2.data(); + int count = 0; + connect(&s1, &SenderObject::signal1, [&count] { count++; }); // α + connect(&s1, &SenderObject::signal1, receiver.data(), [s2] { QFAIL("!!"); }); // β + connect(s2.data(), &SenderObject::signal1, receiver.data(), [] { QFAIL("!!"); }); + connect(&s1, &SenderObject::signal2, receiver.data(), [] { QFAIL("!!"); }); + connect(s2.data(), &SenderObject::signal2, receiver.data(), [] { QFAIL("!!"); }); + connect(&s1, &SenderObject::signal1, [&count] { count++; }); // γ + connect(&s1, &SenderObject::signal2, [&count] { count++; }); // δ + s2.clear(); + + QVERIFY(s2_tracker); + receiver + .reset(); // this will delete the receiver which must also delete s2 as β is disconnected + QVERIFY(!s2_tracker); + // test that the data structures are still in order + s1.emitSignal1(); + QCOMPARE(count, 2); // α + γ + s1.emitSignal2(); + QCOMPARE(count, 3); // + δ +} + // Test for QtPrivate::HasQ_OBJECT_Macro Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value); Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value); diff --git a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp index 55deb8eb1a..fa2d5e3723 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp @@ -34,6 +34,7 @@ #include <QSharedMemory> #include <QTest> #include <QThread> +#include <QElapsedTimer> #define EXISTING_SHARE "existing" #define EXISTING_SIZE 1024 @@ -645,7 +646,7 @@ public: char *memory = (char*)producer.data(); memory[1] = '0'; - QTime timer; + QElapsedTimer timer; timer.start(); int i = 0; while (i < 5 && timer.elapsed() < 5000) { diff --git a/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp b/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp index fd18f00cd0..39b03ade61 100644 --- a/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp +++ b/tests/auto/corelib/kernel/qsignalblocker/tst_qsignalblocker.cpp @@ -66,7 +66,6 @@ void tst_QSignalBlocker::signalBlocking() void tst_QSignalBlocker::moveAssignment() { -#ifdef Q_COMPILER_RVALUE_REFS QObject o1, o2; // move-assignment: both block other objects @@ -157,10 +156,6 @@ void tst_QSignalBlocker::moveAssignment() QVERIFY(!o1.signalsBlocked()); QVERIFY(!o2.signalsBlocked()); - -#else - QSKIP("This compiler is not in C++11 mode or doesn't support move semantics"); -#endif // Q_COMPILER_RVALUE_REFS } QTEST_MAIN(tst_QSignalBlocker) diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 3b10547dc4..262dbea913 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -38,6 +38,7 @@ #include <qtimer.h> #include <qthread.h> +#include <qelapsedtimer.h> #if defined Q_OS_UNIX #include <unistd.h> @@ -73,7 +74,12 @@ private slots: void recurseOnTimeoutAndStopTimer(); void singleShotToFunctors(); void singleShot_chrono(); + void singleShot_static(); void crossThreadSingleShotToFunctor(); + void timerOrder(); + void timerOrder_data(); + void timerOrderBackgroundThread(); + void timerOrderBackgroundThread_data() { timerOrder_data(); } void dontBlockEvents(); void postedEventsShouldNotStarveTimers(); @@ -521,7 +527,7 @@ public: QBasicTimer m_timer; int m_interval; - QTime m_startedTime; + QElapsedTimer m_elapsedTimer; QEventLoop eventLoop; inline RestartedTimerFiresTooSoonObject() @@ -533,7 +539,7 @@ public: static int interval = 1000; m_interval = interval; - m_startedTime.start(); + m_elapsedTimer.start(); m_timer.start(interval, this); // alternate between single-shot and 1 sec @@ -547,7 +553,7 @@ public: m_timer.stop(); - int elapsed = m_startedTime.elapsed(); + int elapsed = m_elapsedTimer.elapsed(); if (elapsed < m_interval / 2) { // severely too early! @@ -585,10 +591,10 @@ public: public slots: void longLastingSlot() { - // Don't use timers for this, because we are testing them. - QTime time; - time.start(); - while (time.elapsed() < 200) { + // Don't use QTimer for this, because we are testing it. + QElapsedTimer control; + control.start(); + while (control.elapsed() < 200) { for (int c = 0; c < 100000; c++) {} // Mindless looping. } if (++count >= 2) { @@ -768,7 +774,7 @@ public: quitEventLoop_noexcept(); } - static void quitEventLoop_noexcept() Q_DECL_NOTHROW + static void quitEventLoop_noexcept() noexcept { QVERIFY(!_e.isNull()); _e->quit(); @@ -1033,5 +1039,121 @@ void tst_QTimer::callOnTimeout() QVERIFY(!connection); } -QTEST_MAIN(tst_QTimer) +class OrderHelper : public QObject +{ + Q_OBJECT +public: + enum CallType + { + String, + PMF, + Functor, + FunctorNoCtx + }; + Q_ENUM(CallType) + QVector<CallType> calls; + + void triggerCall(CallType callType) + { + switch (callType) + { + case String: + QTimer::singleShot(0, this, SLOT(stringSlot())); + break; + case PMF: + QTimer::singleShot(0, this, &OrderHelper::pmfSlot); + break; + case Functor: + QTimer::singleShot(0, this, [this]() { functorSlot(); }); + break; + case FunctorNoCtx: + QTimer::singleShot(0, [this]() { functorNoCtxSlot(); }); + break; + } + } + +public slots: + void stringSlot() { calls << String; } + void pmfSlot() { calls << PMF; } + void functorSlot() { calls << Functor; } + void functorNoCtxSlot() { calls << FunctorNoCtx; } +}; + +Q_DECLARE_METATYPE(OrderHelper::CallType) + +void tst_QTimer::timerOrder() +{ + QFETCH(QVector<OrderHelper::CallType>, calls); + + OrderHelper helper; + + for (const auto call : calls) + helper.triggerCall(call); + + QTRY_COMPARE(helper.calls, calls); +} + +void tst_QTimer::timerOrder_data() +{ + QTest::addColumn<QVector<OrderHelper::CallType>>("calls"); + + QVector<OrderHelper::CallType> calls = { + OrderHelper::String, OrderHelper::PMF, + OrderHelper::Functor, OrderHelper::FunctorNoCtx + }; + std::sort(calls.begin(), calls.end()); + + int permutation = 0; + do { + QTest::addRow("permutation=%d", permutation) << calls; + ++permutation; + } while (std::next_permutation(calls.begin(), calls.end())); +} + +void tst_QTimer::timerOrderBackgroundThread() +{ +#if !QT_CONFIG(cxx11_future) + QSKIP("This test requires QThread::create"); +#else + auto *thread = QThread::create([this]() { timerOrder(); }); + thread->start(); + QVERIFY(thread->wait()); + delete thread; +#endif +} + +struct StaticSingleShotUser +{ + StaticSingleShotUser() + { + for (auto call : calls()) + helper.triggerCall(call); + } + OrderHelper helper; + + static QVector<OrderHelper::CallType> calls() + { + return {OrderHelper::String, OrderHelper::PMF, + OrderHelper::Functor, OrderHelper::FunctorNoCtx}; + } +}; + +static StaticSingleShotUser *s_staticSingleShotUser = nullptr; + +void tst_QTimer::singleShot_static() +{ + QCoreApplication::processEvents(); + QCOMPARE(s_staticSingleShotUser->helper.calls, s_staticSingleShotUser->calls()); +} + +// NOTE: to prevent any static initialization order fiasco, we handle QTEST_MAIN +// ourselves, but instantiate the staticSingleShotUser before qApp + +int main(int argc, char *argv[]) +{ + StaticSingleShotUser staticSingleShotUser; + s_staticSingleShotUser = &staticSingleShotUser; + QTEST_MAIN_IMPL(tst_QTimer) +} + #include "tst_qtimer.moc" diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp index 40a29c723c..b3efa97dbd 100644 --- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp +++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp @@ -310,7 +310,7 @@ struct TranslateThread : public QThread void run() { bool startSignalled = false; - while (terminate.load() == 0) { + while (terminate.loadRelaxed() == 0) { const QString result = QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 0); if (!startSignalled) { diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 4da34c407e..c75e4ef035 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -59,12 +59,6 @@ class CustomNonQObject; -#if defined(Q_COMPILER_CLASS_ENUM) -#define ENUM_SIZE(X) : X -#else -#define ENUM_SIZE(X) -#endif - class tst_QVariant : public QObject { Q_OBJECT @@ -82,15 +76,15 @@ public: enum MetaEnumTest_Enum1 : qint64 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 }; Q_ENUM(MetaEnumTest_Enum1) - enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 }; + enum MetaEnumTest_Enum3 : qint64 { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 }; Q_ENUM(MetaEnumTest_Enum3) - enum MetaEnumTest_Enum4 ENUM_SIZE(quint64) { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; + enum MetaEnumTest_Enum4 : quint64 { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; Q_ENUM(MetaEnumTest_Enum4) - enum MetaEnumTest_Enum5 ENUM_SIZE(uint) { MetaEnumTest_Enum5_value = 47 }; + enum MetaEnumTest_Enum5 : uint { MetaEnumTest_Enum5_value = 47 }; Q_ENUM(MetaEnumTest_Enum5) - enum MetaEnumTest_Enum6 ENUM_SIZE(uchar) { MetaEnumTest_Enum6_value = 47 }; + enum MetaEnumTest_Enum6 : uchar { MetaEnumTest_Enum6_value = 47 }; Q_ENUM(MetaEnumTest_Enum6) - enum MetaEnumTest_Enum8 ENUM_SIZE(short) { MetaEnumTest_Enum8_value = 47 }; + enum MetaEnumTest_Enum8 : short { MetaEnumTest_Enum8_value = 47 }; Q_ENUM(MetaEnumTest_Enum8) private slots: @@ -385,8 +379,10 @@ void tst_QVariant::isNull() QString str1; QVariant var1( str1 ); QVERIFY( var1.isNull() ); - +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QVariant var2( QString::null ); +QT_WARNING_POP QVERIFY( var2.isNull() ); QVariant var3( QString( "blah" ) ); @@ -406,9 +402,15 @@ void tst_QVariant::isNull() QVERIFY( var6.isNull() ); QVariant varLL( (qlonglong)0 ); QVERIFY( !varLL.isNull() ); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QVariant var7(QString::null); +QT_WARNING_POP QVERIFY(var7.isNull()); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED var7 = QVariant::fromValue<QString>(QString::null); +QT_WARNING_POP QVERIFY(var7.isNull()); QVariant var8(QMetaType::Nullptr, nullptr); @@ -1728,281 +1730,281 @@ void tst_QVariant::compareNumbers_data() const QTest::newRow("bool3") << QVariant(false) << QVariant(true) << -1; QTest::newRow("bool4") << QVariant(true) << QVariant(false) << +1; - QTest::newRow("char1") << qVariantFromValue(char(0)) << qVariantFromValue(char(0)) << 0; - QTest::newRow("char2") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(CHAR_MAX) << 0; - QTest::newRow("char3") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(CHAR_MIN) << 0; - QTest::newRow("char4") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(CHAR_MAX) << -1; - QTest::newRow("char5") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(CHAR_MIN) << +1; - - QTest::newRow("schar1") << qVariantFromValue(schar(0)) << qVariantFromValue(schar(0)) << 0; - QTest::newRow("schar2") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(SCHAR_MAX) << 0; - QTest::newRow("schar3") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(SCHAR_MIN) << 0; - QTest::newRow("schar4") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(SCHAR_MAX) << -1; - QTest::newRow("schar5") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(SCHAR_MIN) << +1; - - QTest::newRow("uchar1") << qVariantFromValue(uchar(0)) << qVariantFromValue(uchar(0)) << 0; - QTest::newRow("uchar2") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(UCHAR_MAX) << 0; - QTest::newRow("uchar3") << qVariantFromValue(uchar(0)) << qVariantFromValue(UCHAR_MAX) << -1; - QTest::newRow("uchar4") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(uchar(0)) << +1; - - QTest::newRow("short1") << qVariantFromValue(short(0)) << qVariantFromValue(short(0)) << 0; - QTest::newRow("short2") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(SHRT_MAX) << 0; - QTest::newRow("short3") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(SHRT_MIN) << 0; - QTest::newRow("short4") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(SHRT_MAX) << -1; - QTest::newRow("short5") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(SHRT_MIN) << +1; - - QTest::newRow("ushort1") << qVariantFromValue(ushort(0)) << qVariantFromValue(ushort(0)) << 0; - QTest::newRow("ushort2") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(USHRT_MAX) << 0; - QTest::newRow("ushort3") << qVariantFromValue(ushort(0)) << qVariantFromValue(USHRT_MAX) << -1; - QTest::newRow("ushort4") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(ushort(0)) << +1; - - QTest::newRow("int1") << qVariantFromValue(int(0)) << qVariantFromValue(int(0)) << 0; - QTest::newRow("int2") << qVariantFromValue(INT_MAX) << qVariantFromValue(INT_MAX) << 0; - QTest::newRow("int3") << qVariantFromValue(INT_MIN) << qVariantFromValue(INT_MIN) << 0; - QTest::newRow("int4") << qVariantFromValue(INT_MIN) << qVariantFromValue(INT_MAX) << -1; - QTest::newRow("int5") << qVariantFromValue(INT_MAX) << qVariantFromValue(INT_MIN) << +1; - - QTest::newRow("uint1") << qVariantFromValue(uint(0)) << qVariantFromValue(uint(0)) << 0; - QTest::newRow("uint2") << qVariantFromValue(UINT_MAX) << qVariantFromValue(UINT_MAX) << 0; - QTest::newRow("uint3") << qVariantFromValue(uint(0)) << qVariantFromValue(UINT_MAX) << -1; - QTest::newRow("uint4") << qVariantFromValue(UINT_MAX) << qVariantFromValue(uint(0)) << +1; - - QTest::newRow("long1") << qVariantFromValue(long(0)) << qVariantFromValue(long(0)) << 0; - QTest::newRow("long2") << qVariantFromValue(LONG_MAX) << qVariantFromValue(LONG_MAX) << 0; - QTest::newRow("long3") << qVariantFromValue(LONG_MIN) << qVariantFromValue(LONG_MIN) << 0; - QTest::newRow("long4") << qVariantFromValue(LONG_MIN) << qVariantFromValue(LONG_MAX) << -1; - QTest::newRow("long5") << qVariantFromValue(LONG_MAX) << qVariantFromValue(LONG_MIN) << +1; - - QTest::newRow("ulong1") << qVariantFromValue(ulong(0)) << qVariantFromValue(ulong(0)) << 0; - QTest::newRow("ulong2") << qVariantFromValue(ULONG_MAX) << qVariantFromValue(ULONG_MAX) << 0; - QTest::newRow("ulong3") << qVariantFromValue(ulong(0)) << qVariantFromValue(ULONG_MAX) << -1; - QTest::newRow("ulong4") << qVariantFromValue(ULONG_MAX) << qVariantFromValue(ulong(0)) << +1; - - QTest::newRow("llong1") << qVariantFromValue(qlonglong(0)) << qVariantFromValue(qlonglong(0)) << 0; - QTest::newRow("llong2") << qVariantFromValue(LLONG_MAX) << qVariantFromValue(LLONG_MAX) << 0; - QTest::newRow("llong3") << qVariantFromValue(LLONG_MIN) << qVariantFromValue(LLONG_MIN) << 0; - QTest::newRow("llong4") << qVariantFromValue(LLONG_MIN) << qVariantFromValue(LLONG_MAX) << -1; - QTest::newRow("llong5") << qVariantFromValue(LLONG_MAX) << qVariantFromValue(LLONG_MIN) << +1; - - QTest::newRow("ullong1") << qVariantFromValue(qulonglong(0)) << qVariantFromValue(qulonglong(0)) << 0; - QTest::newRow("ullong2") << qVariantFromValue(ULLONG_MAX) << qVariantFromValue(ULLONG_MAX) << 0; - QTest::newRow("ullong3") << qVariantFromValue(qulonglong(0)) << qVariantFromValue(ULLONG_MAX) << -1; - QTest::newRow("ullong4") << qVariantFromValue(ULLONG_MAX) << qVariantFromValue(qulonglong(0)) << +1; - - QTest::newRow("float1") << qVariantFromValue(0.f) << qVariantFromValue(0.f) << 0; - QTest::newRow("float2") << qVariantFromValue(-1.f) << qVariantFromValue(0.f) << -1; - QTest::newRow("float3") << qVariantFromValue(0.f) << qVariantFromValue(-1.f) << +1; - QTest::newRow("float4") << qVariantFromValue(-float(qInf())) << qVariantFromValue(0.f) << -1; - QTest::newRow("float5") << qVariantFromValue(0.f) << qVariantFromValue(-float(qInf())) << +1; - QTest::newRow("float6") << qVariantFromValue(-float(qInf())) << qVariantFromValue(-float(qInf())) << 0; - QTest::newRow("float7") << qVariantFromValue(float(qInf())) << qVariantFromValue(float(qInf())) << 0; - - QTest::newRow("double1") << qVariantFromValue(0.) << qVariantFromValue(0.) << 0; - QTest::newRow("double2") << qVariantFromValue(-1.) << qVariantFromValue(0.) << -1; - QTest::newRow("double3") << qVariantFromValue(0.) << qVariantFromValue(-1.) << +1; - QTest::newRow("double4") << qVariantFromValue(-qInf()) << qVariantFromValue(0.) << -1; - QTest::newRow("double5") << qVariantFromValue(0.) << qVariantFromValue(-qInf()) << +1; - QTest::newRow("double6") << qVariantFromValue(-double(qInf())) << qVariantFromValue(-qInf()) << 0; - QTest::newRow("double7") << qVariantFromValue(qInf()) << qVariantFromValue(qInf()) << 0; - QTest::newRow("double8") << qVariantFromValue(-qInf()) << qVariantFromValue(qInf()) << -1; - QTest::newRow("double9") << qVariantFromValue(qQNaN()) << qVariantFromValue(0.) << INT_MAX; - QTest::newRow("double10") << qVariantFromValue(0.) << qVariantFromValue(qQNaN()) << INT_MAX; - QTest::newRow("double11") << qVariantFromValue(qQNaN()) << qVariantFromValue(qQNaN()) << INT_MAX; + QTest::newRow("char1") << QVariant::fromValue(char(0)) << QVariant::fromValue(char(0)) << 0; + QTest::newRow("char2") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(CHAR_MAX) << 0; + QTest::newRow("char3") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(CHAR_MIN) << 0; + QTest::newRow("char4") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(CHAR_MAX) << -1; + QTest::newRow("char5") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(CHAR_MIN) << +1; + + QTest::newRow("schar1") << QVariant::fromValue(schar(0)) << QVariant::fromValue(schar(0)) << 0; + QTest::newRow("schar2") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(SCHAR_MAX) << 0; + QTest::newRow("schar3") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(SCHAR_MIN) << 0; + QTest::newRow("schar4") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(SCHAR_MAX) << -1; + QTest::newRow("schar5") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(SCHAR_MIN) << +1; + + QTest::newRow("uchar1") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(uchar(0)) << 0; + QTest::newRow("uchar2") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(UCHAR_MAX) << 0; + QTest::newRow("uchar3") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(UCHAR_MAX) << -1; + QTest::newRow("uchar4") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(uchar(0)) << +1; + + QTest::newRow("short1") << QVariant::fromValue(short(0)) << QVariant::fromValue(short(0)) << 0; + QTest::newRow("short2") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(SHRT_MAX) << 0; + QTest::newRow("short3") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(SHRT_MIN) << 0; + QTest::newRow("short4") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(SHRT_MAX) << -1; + QTest::newRow("short5") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(SHRT_MIN) << +1; + + QTest::newRow("ushort1") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(ushort(0)) << 0; + QTest::newRow("ushort2") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(USHRT_MAX) << 0; + QTest::newRow("ushort3") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(USHRT_MAX) << -1; + QTest::newRow("ushort4") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(ushort(0)) << +1; + + QTest::newRow("int1") << QVariant::fromValue(int(0)) << QVariant::fromValue(int(0)) << 0; + QTest::newRow("int2") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(INT_MAX) << 0; + QTest::newRow("int3") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(INT_MIN) << 0; + QTest::newRow("int4") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(INT_MAX) << -1; + QTest::newRow("int5") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(INT_MIN) << +1; + + QTest::newRow("uint1") << QVariant::fromValue(uint(0)) << QVariant::fromValue(uint(0)) << 0; + QTest::newRow("uint2") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(UINT_MAX) << 0; + QTest::newRow("uint3") << QVariant::fromValue(uint(0)) << QVariant::fromValue(UINT_MAX) << -1; + QTest::newRow("uint4") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(uint(0)) << +1; + + QTest::newRow("long1") << QVariant::fromValue(long(0)) << QVariant::fromValue(long(0)) << 0; + QTest::newRow("long2") << QVariant::fromValue(LONG_MAX) << QVariant::fromValue(LONG_MAX) << 0; + QTest::newRow("long3") << QVariant::fromValue(LONG_MIN) << QVariant::fromValue(LONG_MIN) << 0; + QTest::newRow("long4") << QVariant::fromValue(LONG_MIN) << QVariant::fromValue(LONG_MAX) << -1; + QTest::newRow("long5") << QVariant::fromValue(LONG_MAX) << QVariant::fromValue(LONG_MIN) << +1; + + QTest::newRow("ulong1") << QVariant::fromValue(ulong(0)) << QVariant::fromValue(ulong(0)) << 0; + QTest::newRow("ulong2") << QVariant::fromValue(ULONG_MAX) << QVariant::fromValue(ULONG_MAX) << 0; + QTest::newRow("ulong3") << QVariant::fromValue(ulong(0)) << QVariant::fromValue(ULONG_MAX) << -1; + QTest::newRow("ulong4") << QVariant::fromValue(ULONG_MAX) << QVariant::fromValue(ulong(0)) << +1; + + QTest::newRow("llong1") << QVariant::fromValue(qlonglong(0)) << QVariant::fromValue(qlonglong(0)) << 0; + QTest::newRow("llong2") << QVariant::fromValue(LLONG_MAX) << QVariant::fromValue(LLONG_MAX) << 0; + QTest::newRow("llong3") << QVariant::fromValue(LLONG_MIN) << QVariant::fromValue(LLONG_MIN) << 0; + QTest::newRow("llong4") << QVariant::fromValue(LLONG_MIN) << QVariant::fromValue(LLONG_MAX) << -1; + QTest::newRow("llong5") << QVariant::fromValue(LLONG_MAX) << QVariant::fromValue(LLONG_MIN) << +1; + + QTest::newRow("ullong1") << QVariant::fromValue(qulonglong(0)) << QVariant::fromValue(qulonglong(0)) << 0; + QTest::newRow("ullong2") << QVariant::fromValue(ULLONG_MAX) << QVariant::fromValue(ULLONG_MAX) << 0; + QTest::newRow("ullong3") << QVariant::fromValue(qulonglong(0)) << QVariant::fromValue(ULLONG_MAX) << -1; + QTest::newRow("ullong4") << QVariant::fromValue(ULLONG_MAX) << QVariant::fromValue(qulonglong(0)) << +1; + + QTest::newRow("float1") << QVariant::fromValue(0.f) << QVariant::fromValue(0.f) << 0; + QTest::newRow("float2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0.f) << -1; + QTest::newRow("float3") << QVariant::fromValue(0.f) << QVariant::fromValue(-1.f) << +1; + QTest::newRow("float4") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(0.f) << -1; + QTest::newRow("float5") << QVariant::fromValue(0.f) << QVariant::fromValue(-float(qInf())) << +1; + QTest::newRow("float6") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(-float(qInf())) << 0; + QTest::newRow("float7") << QVariant::fromValue(float(qInf())) << QVariant::fromValue(float(qInf())) << 0; + + QTest::newRow("double1") << QVariant::fromValue(0.) << QVariant::fromValue(0.) << 0; + QTest::newRow("double2") << QVariant::fromValue(-1.) << QVariant::fromValue(0.) << -1; + QTest::newRow("double3") << QVariant::fromValue(0.) << QVariant::fromValue(-1.) << +1; + QTest::newRow("double4") << QVariant::fromValue(-qInf()) << QVariant::fromValue(0.) << -1; + QTest::newRow("double5") << QVariant::fromValue(0.) << QVariant::fromValue(-qInf()) << +1; + QTest::newRow("double6") << QVariant::fromValue(-double(qInf())) << QVariant::fromValue(-qInf()) << 0; + QTest::newRow("double7") << QVariant::fromValue(qInf()) << QVariant::fromValue(qInf()) << 0; + QTest::newRow("double8") << QVariant::fromValue(-qInf()) << QVariant::fromValue(qInf()) << -1; + QTest::newRow("double9") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(0.) << INT_MAX; + QTest::newRow("double10") << QVariant::fromValue(0.) << QVariant::fromValue(qQNaN()) << INT_MAX; + QTest::newRow("double11") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(qQNaN()) << INT_MAX; // mixed comparisons // fp + fp - QTest::newRow("float+double1") << qVariantFromValue(0.f) << qVariantFromValue(0.) << 0; - QTest::newRow("float+double2") << qVariantFromValue(-1.f) << qVariantFromValue(0.) << -1; - QTest::newRow("float+double3") << qVariantFromValue(0.f) << qVariantFromValue(-1.) << +1; - QTest::newRow("float+double4") << qVariantFromValue(-float(qInf())) << qVariantFromValue(0.) << -1; - QTest::newRow("float+double5") << qVariantFromValue(0.f) << qVariantFromValue(-qInf()) << +1; - QTest::newRow("float+double6") << qVariantFromValue(-float(qInf())) << qVariantFromValue(-qInf()) << 0; - QTest::newRow("float+double7") << qVariantFromValue(float(qInf())) << qVariantFromValue(qInf()) << 0; - QTest::newRow("float+double8") << qVariantFromValue(-float(qInf())) << qVariantFromValue(qInf()) << -1; - QTest::newRow("float+double9") << qVariantFromValue(qQNaN()) << qVariantFromValue(0.) << INT_MAX; - QTest::newRow("float+double10") << qVariantFromValue(0.) << qVariantFromValue(qQNaN()) << INT_MAX; - QTest::newRow("float+double11") << qVariantFromValue(qQNaN()) << qVariantFromValue(qQNaN()) << INT_MAX; + QTest::newRow("float+double1") << QVariant::fromValue(0.f) << QVariant::fromValue(0.) << 0; + QTest::newRow("float+double2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0.) << -1; + QTest::newRow("float+double3") << QVariant::fromValue(0.f) << QVariant::fromValue(-1.) << +1; + QTest::newRow("float+double4") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(0.) << -1; + QTest::newRow("float+double5") << QVariant::fromValue(0.f) << QVariant::fromValue(-qInf()) << +1; + QTest::newRow("float+double6") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(-qInf()) << 0; + QTest::newRow("float+double7") << QVariant::fromValue(float(qInf())) << QVariant::fromValue(qInf()) << 0; + QTest::newRow("float+double8") << QVariant::fromValue(-float(qInf())) << QVariant::fromValue(qInf()) << -1; + QTest::newRow("float+double9") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(0.) << INT_MAX; + QTest::newRow("float+double10") << QVariant::fromValue(0.) << QVariant::fromValue(qQNaN()) << INT_MAX; + QTest::newRow("float+double11") << QVariant::fromValue(qQNaN()) << QVariant::fromValue(qQNaN()) << INT_MAX; // fp + int - QTest::newRow("float+int1") << qVariantFromValue(0.f) << qVariantFromValue(0) << 0; - QTest::newRow("double+int1") << qVariantFromValue(0.) << qVariantFromValue(0) << 0; - QTest::newRow("float+int2") << qVariantFromValue(-1.f) << qVariantFromValue(0) << -1; - QTest::newRow("double+int2") << qVariantFromValue(-1.) << qVariantFromValue(0) << -1; - QTest::newRow("float+int3") << qVariantFromValue(0.f) << qVariantFromValue(-1) << +1; - QTest::newRow("double+int3") << qVariantFromValue(0.) << qVariantFromValue(-1) << +1; - QTest::newRow("float+int4") << qVariantFromValue(1.5f) << qVariantFromValue(1) << +1; - QTest::newRow("double+int4") << qVariantFromValue(1.5) << qVariantFromValue(1) << +1; - QTest::newRow("double+int5") << qVariantFromValue(qInf()) << qVariantFromValue(1) << +1; + QTest::newRow("float+int1") << QVariant::fromValue(0.f) << QVariant::fromValue(0) << 0; + QTest::newRow("double+int1") << QVariant::fromValue(0.) << QVariant::fromValue(0) << 0; + QTest::newRow("float+int2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0) << -1; + QTest::newRow("double+int2") << QVariant::fromValue(-1.) << QVariant::fromValue(0) << -1; + QTest::newRow("float+int3") << QVariant::fromValue(0.f) << QVariant::fromValue(-1) << +1; + QTest::newRow("double+int3") << QVariant::fromValue(0.) << QVariant::fromValue(-1) << +1; + QTest::newRow("float+int4") << QVariant::fromValue(1.5f) << QVariant::fromValue(1) << +1; + QTest::newRow("double+int4") << QVariant::fromValue(1.5) << QVariant::fromValue(1) << +1; + QTest::newRow("double+int5") << QVariant::fromValue(qInf()) << QVariant::fromValue(1) << +1; // fp + uint - QTest::newRow("float+uint1") << qVariantFromValue(0.f) << qVariantFromValue(0U) << 0; - QTest::newRow("double+uint1") << qVariantFromValue(0.) << qVariantFromValue(0U) << 0; - QTest::newRow("float+uint2") << qVariantFromValue(-1.f) << qVariantFromValue(0U) << -1; - QTest::newRow("double+uint2") << qVariantFromValue(-1.) << qVariantFromValue(0U) << -1; - QTest::newRow("float+uint3") << qVariantFromValue(0.f) << qVariantFromValue(1U) << -1; - QTest::newRow("double+uint3") << qVariantFromValue(0.) << qVariantFromValue(1U) << -1; - QTest::newRow("float+uint4") << qVariantFromValue(1.5f) << qVariantFromValue(1U) << +1; - QTest::newRow("double+uint4") << qVariantFromValue(1.5) << qVariantFromValue(1U) << +1; + QTest::newRow("float+uint1") << QVariant::fromValue(0.f) << QVariant::fromValue(0U) << 0; + QTest::newRow("double+uint1") << QVariant::fromValue(0.) << QVariant::fromValue(0U) << 0; + QTest::newRow("float+uint2") << QVariant::fromValue(-1.f) << QVariant::fromValue(0U) << -1; + QTest::newRow("double+uint2") << QVariant::fromValue(-1.) << QVariant::fromValue(0U) << -1; + QTest::newRow("float+uint3") << QVariant::fromValue(0.f) << QVariant::fromValue(1U) << -1; + QTest::newRow("double+uint3") << QVariant::fromValue(0.) << QVariant::fromValue(1U) << -1; + QTest::newRow("float+uint4") << QVariant::fromValue(1.5f) << QVariant::fromValue(1U) << +1; + QTest::newRow("double+uint4") << QVariant::fromValue(1.5) << QVariant::fromValue(1U) << +1; // lower ranked + int - QTest::newRow("bool+int1") << qVariantFromValue(false) << qVariantFromValue(0) << 0; - QTest::newRow("bool+int2") << qVariantFromValue(false) << qVariantFromValue(1) << -1; - QTest::newRow("bool+int3") << qVariantFromValue(true) << qVariantFromValue(0) << +1; - QTest::newRow("bool+int4") << qVariantFromValue(true) << qVariantFromValue(1) << 0; - QTest::newRow("bool+int5") << qVariantFromValue(true) << qVariantFromValue(2) << -1; - - QTest::newRow("char+int1") << qVariantFromValue(char(0)) << qVariantFromValue(0) << 0; - QTest::newRow("char+int2") << qVariantFromValue(char(0)) << qVariantFromValue(1) << -1; - QTest::newRow("char+int3") << qVariantFromValue(char(1)) << qVariantFromValue(0) << +1; - QTest::newRow("char+int4") << qVariantFromValue(char(1)) << qVariantFromValue(1) << 0; + QTest::newRow("bool+int1") << QVariant::fromValue(false) << QVariant::fromValue(0) << 0; + QTest::newRow("bool+int2") << QVariant::fromValue(false) << QVariant::fromValue(1) << -1; + QTest::newRow("bool+int3") << QVariant::fromValue(true) << QVariant::fromValue(0) << +1; + QTest::newRow("bool+int4") << QVariant::fromValue(true) << QVariant::fromValue(1) << 0; + QTest::newRow("bool+int5") << QVariant::fromValue(true) << QVariant::fromValue(2) << -1; + + QTest::newRow("char+int1") << QVariant::fromValue(char(0)) << QVariant::fromValue(0) << 0; + QTest::newRow("char+int2") << QVariant::fromValue(char(0)) << QVariant::fromValue(1) << -1; + QTest::newRow("char+int3") << QVariant::fromValue(char(1)) << QVariant::fromValue(0) << +1; + QTest::newRow("char+int4") << QVariant::fromValue(char(1)) << QVariant::fromValue(1) << 0; if (std::numeric_limits<char>::is_signed) { - QTest::newRow("char+int5") << qVariantFromValue(char(-1)) << qVariantFromValue(0) << -1; - QTest::newRow("char+int6") << qVariantFromValue(char(-1)) << qVariantFromValue(-1) << 0; - } - - QTest::newRow("schar+int1") << qVariantFromValue(schar(0)) << qVariantFromValue(0) << 0; - QTest::newRow("schar+int2") << qVariantFromValue(schar(0)) << qVariantFromValue(1) << -1; - QTest::newRow("schar+int3") << qVariantFromValue(schar(1)) << qVariantFromValue(0) << +1; - QTest::newRow("schar+int4") << qVariantFromValue(schar(1)) << qVariantFromValue(1) << 0; - QTest::newRow("schar+int5") << qVariantFromValue(schar(-1)) << qVariantFromValue(0) << -1; - QTest::newRow("schar+int6") << qVariantFromValue(schar(-1)) << qVariantFromValue(-1) << 0; - - QTest::newRow("uchar+int1") << qVariantFromValue(uchar(0)) << qVariantFromValue(0) << 0; - QTest::newRow("uchar+int2") << qVariantFromValue(uchar(0)) << qVariantFromValue(1) << -1; - QTest::newRow("uchar+int3") << qVariantFromValue(uchar(1)) << qVariantFromValue(0) << +1; - QTest::newRow("uchar+int4") << qVariantFromValue(uchar(1)) << qVariantFromValue(1) << 0; - - QTest::newRow("short+int1") << qVariantFromValue(short(0)) << qVariantFromValue(0) << 0; - QTest::newRow("short+int2") << qVariantFromValue(short(0)) << qVariantFromValue(1) << -1; - QTest::newRow("short+int3") << qVariantFromValue(short(1)) << qVariantFromValue(0) << +1; - QTest::newRow("short+int4") << qVariantFromValue(short(1)) << qVariantFromValue(1) << 0; - QTest::newRow("short+int5") << qVariantFromValue(short(-1)) << qVariantFromValue(0) << -1; - QTest::newRow("short+int6") << qVariantFromValue(short(-1)) << qVariantFromValue(-1) << 0; - - QTest::newRow("ushort+int1") << qVariantFromValue(ushort(0)) << qVariantFromValue(0) << 0; - QTest::newRow("ushort+int2") << qVariantFromValue(ushort(0)) << qVariantFromValue(1) << -1; - QTest::newRow("ushort+int3") << qVariantFromValue(ushort(1)) << qVariantFromValue(0) << +1; - QTest::newRow("ushort+int4") << qVariantFromValue(ushort(1)) << qVariantFromValue(1) << 0; + QTest::newRow("char+int5") << QVariant::fromValue(char(-1)) << QVariant::fromValue(0) << -1; + QTest::newRow("char+int6") << QVariant::fromValue(char(-1)) << QVariant::fromValue(-1) << 0; + } + + QTest::newRow("schar+int1") << QVariant::fromValue(schar(0)) << QVariant::fromValue(0) << 0; + QTest::newRow("schar+int2") << QVariant::fromValue(schar(0)) << QVariant::fromValue(1) << -1; + QTest::newRow("schar+int3") << QVariant::fromValue(schar(1)) << QVariant::fromValue(0) << +1; + QTest::newRow("schar+int4") << QVariant::fromValue(schar(1)) << QVariant::fromValue(1) << 0; + QTest::newRow("schar+int5") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(0) << -1; + QTest::newRow("schar+int6") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(-1) << 0; + + QTest::newRow("uchar+int1") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(0) << 0; + QTest::newRow("uchar+int2") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(1) << -1; + QTest::newRow("uchar+int3") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(0) << +1; + QTest::newRow("uchar+int4") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(1) << 0; + + QTest::newRow("short+int1") << QVariant::fromValue(short(0)) << QVariant::fromValue(0) << 0; + QTest::newRow("short+int2") << QVariant::fromValue(short(0)) << QVariant::fromValue(1) << -1; + QTest::newRow("short+int3") << QVariant::fromValue(short(1)) << QVariant::fromValue(0) << +1; + QTest::newRow("short+int4") << QVariant::fromValue(short(1)) << QVariant::fromValue(1) << 0; + QTest::newRow("short+int5") << QVariant::fromValue(short(-1)) << QVariant::fromValue(0) << -1; + QTest::newRow("short+int6") << QVariant::fromValue(short(-1)) << QVariant::fromValue(-1) << 0; + + QTest::newRow("ushort+int1") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(0) << 0; + QTest::newRow("ushort+int2") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(1) << -1; + QTest::newRow("ushort+int3") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(0) << +1; + QTest::newRow("ushort+int4") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(1) << 0; // lower ranked + uint (without sign change) - QTest::newRow("bool+uint1") << qVariantFromValue(false) << qVariantFromValue(0U) << 0; - QTest::newRow("bool+uint2") << qVariantFromValue(false) << qVariantFromValue(1U) << -1; - QTest::newRow("bool+uint3") << qVariantFromValue(true) << qVariantFromValue(0U) << +1; - QTest::newRow("bool+uint4") << qVariantFromValue(true) << qVariantFromValue(1U) << 0; - QTest::newRow("bool+uint5") << qVariantFromValue(true) << qVariantFromValue(2U) << -1; - - QTest::newRow("char+uint1") << qVariantFromValue(char(0)) << qVariantFromValue(0U) << 0; - QTest::newRow("char+uint2") << qVariantFromValue(char(0)) << qVariantFromValue(1U) << -1; - QTest::newRow("char+uint3") << qVariantFromValue(char(1)) << qVariantFromValue(0U) << +1; - QTest::newRow("char+uint4") << qVariantFromValue(char(1)) << qVariantFromValue(1U) << 0; - - QTest::newRow("schar+uint1") << qVariantFromValue(schar(0)) << qVariantFromValue(0U) << 0; - QTest::newRow("schar+uint2") << qVariantFromValue(schar(0)) << qVariantFromValue(1U) << -1; - QTest::newRow("schar+uint3") << qVariantFromValue(schar(1)) << qVariantFromValue(0U) << +1; - QTest::newRow("schar+uint4") << qVariantFromValue(schar(1)) << qVariantFromValue(1U) << 0; - - QTest::newRow("uchar+uint1") << qVariantFromValue(uchar(0)) << qVariantFromValue(0U) << 0; - QTest::newRow("uchar+uint2") << qVariantFromValue(uchar(0)) << qVariantFromValue(1U) << -1; - QTest::newRow("uchar+uint3") << qVariantFromValue(uchar(1)) << qVariantFromValue(0U) << +1; - QTest::newRow("uchar+uint4") << qVariantFromValue(uchar(1)) << qVariantFromValue(1U) << 0; - - QTest::newRow("short+uint1") << qVariantFromValue(short(0)) << qVariantFromValue(0U) << 0; - QTest::newRow("short+uint2") << qVariantFromValue(short(0)) << qVariantFromValue(1U) << -1; - QTest::newRow("short+uint3") << qVariantFromValue(short(1)) << qVariantFromValue(0U) << +1; - QTest::newRow("short+uint4") << qVariantFromValue(short(1)) << qVariantFromValue(1U) << 0; - - QTest::newRow("ushort+uint1") << qVariantFromValue(ushort(0)) << qVariantFromValue(0U) << 0; - QTest::newRow("ushort+uint2") << qVariantFromValue(ushort(0)) << qVariantFromValue(1U) << -1; - QTest::newRow("ushort+uint3") << qVariantFromValue(ushort(1)) << qVariantFromValue(0U) << +1; - QTest::newRow("ushort+uint4") << qVariantFromValue(ushort(1)) << qVariantFromValue(1U) << 0; + QTest::newRow("bool+uint1") << QVariant::fromValue(false) << QVariant::fromValue(0U) << 0; + QTest::newRow("bool+uint2") << QVariant::fromValue(false) << QVariant::fromValue(1U) << -1; + QTest::newRow("bool+uint3") << QVariant::fromValue(true) << QVariant::fromValue(0U) << +1; + QTest::newRow("bool+uint4") << QVariant::fromValue(true) << QVariant::fromValue(1U) << 0; + QTest::newRow("bool+uint5") << QVariant::fromValue(true) << QVariant::fromValue(2U) << -1; + + QTest::newRow("char+uint1") << QVariant::fromValue(char(0)) << QVariant::fromValue(0U) << 0; + QTest::newRow("char+uint2") << QVariant::fromValue(char(0)) << QVariant::fromValue(1U) << -1; + QTest::newRow("char+uint3") << QVariant::fromValue(char(1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("char+uint4") << QVariant::fromValue(char(1)) << QVariant::fromValue(1U) << 0; + + QTest::newRow("schar+uint1") << QVariant::fromValue(schar(0)) << QVariant::fromValue(0U) << 0; + QTest::newRow("schar+uint2") << QVariant::fromValue(schar(0)) << QVariant::fromValue(1U) << -1; + QTest::newRow("schar+uint3") << QVariant::fromValue(schar(1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("schar+uint4") << QVariant::fromValue(schar(1)) << QVariant::fromValue(1U) << 0; + + QTest::newRow("uchar+uint1") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(0U) << 0; + QTest::newRow("uchar+uint2") << QVariant::fromValue(uchar(0)) << QVariant::fromValue(1U) << -1; + QTest::newRow("uchar+uint3") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("uchar+uint4") << QVariant::fromValue(uchar(1)) << QVariant::fromValue(1U) << 0; + + QTest::newRow("short+uint1") << QVariant::fromValue(short(0)) << QVariant::fromValue(0U) << 0; + QTest::newRow("short+uint2") << QVariant::fromValue(short(0)) << QVariant::fromValue(1U) << -1; + QTest::newRow("short+uint3") << QVariant::fromValue(short(1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("short+uint4") << QVariant::fromValue(short(1)) << QVariant::fromValue(1U) << 0; + + QTest::newRow("ushort+uint1") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(0U) << 0; + QTest::newRow("ushort+uint2") << QVariant::fromValue(ushort(0)) << QVariant::fromValue(1U) << -1; + QTest::newRow("ushort+uint3") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("ushort+uint4") << QVariant::fromValue(ushort(1)) << QVariant::fromValue(1U) << 0; // int + qlonglong - QTest::newRow("int+qlonglong1") << qVariantFromValue(0) << qVariantFromValue(Q_INT64_C(0)) << 0; - QTest::newRow("int+qlonglong2") << qVariantFromValue(1) << qVariantFromValue(Q_INT64_C(0)) << +1; - QTest::newRow("int+qlonglong3") << qVariantFromValue(0) << qVariantFromValue(Q_INT64_C(1)) << -1; - QTest::newRow("int+qlonglong4") << qVariantFromValue(1) << qVariantFromValue(Q_INT64_C(1)) << 0; - QTest::newRow("int+qlonglong5") << qVariantFromValue(0) << qVariantFromValue(Q_INT64_C(-1)) << +1; - QTest::newRow("int+qlonglong6") << qVariantFromValue(-1) << qVariantFromValue(Q_INT64_C(0)) << -1; - QTest::newRow("int+qlonglong7") << qVariantFromValue(-1) << qVariantFromValue(Q_INT64_C(-1)) << 0; + QTest::newRow("int+qlonglong1") << QVariant::fromValue(0) << QVariant::fromValue(Q_INT64_C(0)) << 0; + QTest::newRow("int+qlonglong2") << QVariant::fromValue(1) << QVariant::fromValue(Q_INT64_C(0)) << +1; + QTest::newRow("int+qlonglong3") << QVariant::fromValue(0) << QVariant::fromValue(Q_INT64_C(1)) << -1; + QTest::newRow("int+qlonglong4") << QVariant::fromValue(1) << QVariant::fromValue(Q_INT64_C(1)) << 0; + QTest::newRow("int+qlonglong5") << QVariant::fromValue(0) << QVariant::fromValue(Q_INT64_C(-1)) << +1; + QTest::newRow("int+qlonglong6") << QVariant::fromValue(-1) << QVariant::fromValue(Q_INT64_C(0)) << -1; + QTest::newRow("int+qlonglong7") << QVariant::fromValue(-1) << QVariant::fromValue(Q_INT64_C(-1)) << 0; // uint + qulonglong - QTest::newRow("uint+qulonglong1") << qVariantFromValue(0U) << qVariantFromValue(Q_UINT64_C(0)) << 0; - QTest::newRow("uint+qulonglong2") << qVariantFromValue(1U) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("uint+qulonglong3") << qVariantFromValue(0U) << qVariantFromValue(Q_UINT64_C(1)) << -1; - QTest::newRow("uint+qulonglong4") << qVariantFromValue(1U) << qVariantFromValue(Q_UINT64_C(1)) << 0; + QTest::newRow("uint+qulonglong1") << QVariant::fromValue(0U) << QVariant::fromValue(Q_UINT64_C(0)) << 0; + QTest::newRow("uint+qulonglong2") << QVariant::fromValue(1U) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("uint+qulonglong3") << QVariant::fromValue(0U) << QVariant::fromValue(Q_UINT64_C(1)) << -1; + QTest::newRow("uint+qulonglong4") << QVariant::fromValue(1U) << QVariant::fromValue(Q_UINT64_C(1)) << 0; // int + uint (without sign change) - QTest::newRow("int+uint1") << qVariantFromValue(0) << qVariantFromValue(0U) << 0; - QTest::newRow("int+uint2") << qVariantFromValue(1) << qVariantFromValue(0U) << +1; - QTest::newRow("int+uint3") << qVariantFromValue(0) << qVariantFromValue(1U) << -1; - QTest::newRow("int+uint4") << qVariantFromValue(1) << qVariantFromValue(1U) << 0; + QTest::newRow("int+uint1") << QVariant::fromValue(0) << QVariant::fromValue(0U) << 0; + QTest::newRow("int+uint2") << QVariant::fromValue(1) << QVariant::fromValue(0U) << +1; + QTest::newRow("int+uint3") << QVariant::fromValue(0) << QVariant::fromValue(1U) << -1; + QTest::newRow("int+uint4") << QVariant::fromValue(1) << QVariant::fromValue(1U) << 0; // uint + qlonglong - QTest::newRow("uint+qlonglong1") << qVariantFromValue(0U) << qVariantFromValue(Q_INT64_C(0)) << 0; - QTest::newRow("uint+qlonglong2") << qVariantFromValue(1U) << qVariantFromValue(Q_INT64_C(0)) << +1; - QTest::newRow("uint+qlonglong3") << qVariantFromValue(0U) << qVariantFromValue(Q_INT64_C(1)) << -1; - QTest::newRow("uint+qlonglong4") << qVariantFromValue(1U) << qVariantFromValue(Q_INT64_C(1)) << 0; - QTest::newRow("uint+qlonglong5") << qVariantFromValue(0U) << qVariantFromValue(Q_INT64_C(-1)) << +1; + QTest::newRow("uint+qlonglong1") << QVariant::fromValue(0U) << QVariant::fromValue(Q_INT64_C(0)) << 0; + QTest::newRow("uint+qlonglong2") << QVariant::fromValue(1U) << QVariant::fromValue(Q_INT64_C(0)) << +1; + QTest::newRow("uint+qlonglong3") << QVariant::fromValue(0U) << QVariant::fromValue(Q_INT64_C(1)) << -1; + QTest::newRow("uint+qlonglong4") << QVariant::fromValue(1U) << QVariant::fromValue(Q_INT64_C(1)) << 0; + QTest::newRow("uint+qlonglong5") << QVariant::fromValue(0U) << QVariant::fromValue(Q_INT64_C(-1)) << +1; // boundary conditions - QTest::newRow("charmax+intmax") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(INT_MAX) << -1; - QTest::newRow("charmax+uintmax") << qVariantFromValue(CHAR_MAX) << qVariantFromValue(UINT_MAX) << -1; - QTest::newRow("scharmax+intmax") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(INT_MAX) << -1; - QTest::newRow("scharmax+uintmax") << qVariantFromValue(SCHAR_MAX) << qVariantFromValue(UINT_MAX) << -1; - QTest::newRow("ucharmax+intmax") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(INT_MAX) << -1; - QTest::newRow("ucharmax+uintmax") << qVariantFromValue(UCHAR_MAX) << qVariantFromValue(UINT_MAX) << -1; - QTest::newRow("shortmax+intmax") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(INT_MAX) << -1; - QTest::newRow("shortmax+uintmax") << qVariantFromValue(SHRT_MAX) << qVariantFromValue(UINT_MAX) << -1; - QTest::newRow("ushortmax+intmax") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(INT_MAX) << -1; - QTest::newRow("ushortmax+uintmax") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(UINT_MAX) << -1; - - QTest::newRow("intmin+qlonglongmin") << qVariantFromValue(INT_MIN) << qVariantFromValue(LLONG_MIN) << +1; - QTest::newRow("intmax+uintmax") << qVariantFromValue(INT_MAX) << qVariantFromValue(UINT_MAX) << -1; - QTest::newRow("intmax+qlonglongmax") << qVariantFromValue(INT_MAX) << qVariantFromValue(LLONG_MAX) << -1; - QTest::newRow("uintmax+qlonglongmax") << qVariantFromValue(UINT_MAX) << qVariantFromValue(LLONG_MAX) << -1; - QTest::newRow("intmax+qulonglongmax") << qVariantFromValue(INT_MAX) << qVariantFromValue(ULLONG_MAX) << -1; - QTest::newRow("qlonglongmax+qulonglongmax") << qVariantFromValue(LLONG_MAX) << qVariantFromValue(ULLONG_MAX) << -1; - QTest::newRow("uintmax+qlonglongmin") << qVariantFromValue(UINT_MAX) << qVariantFromValue(LLONG_MIN) << +1; + QTest::newRow("charmax+intmax") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(INT_MAX) << -1; + QTest::newRow("charmax+uintmax") << QVariant::fromValue(CHAR_MAX) << QVariant::fromValue(UINT_MAX) << -1; + QTest::newRow("scharmax+intmax") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(INT_MAX) << -1; + QTest::newRow("scharmax+uintmax") << QVariant::fromValue(SCHAR_MAX) << QVariant::fromValue(UINT_MAX) << -1; + QTest::newRow("ucharmax+intmax") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(INT_MAX) << -1; + QTest::newRow("ucharmax+uintmax") << QVariant::fromValue(UCHAR_MAX) << QVariant::fromValue(UINT_MAX) << -1; + QTest::newRow("shortmax+intmax") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(INT_MAX) << -1; + QTest::newRow("shortmax+uintmax") << QVariant::fromValue(SHRT_MAX) << QVariant::fromValue(UINT_MAX) << -1; + QTest::newRow("ushortmax+intmax") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(INT_MAX) << -1; + QTest::newRow("ushortmax+uintmax") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(UINT_MAX) << -1; + + QTest::newRow("intmin+qlonglongmin") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(LLONG_MIN) << +1; + QTest::newRow("intmax+uintmax") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(UINT_MAX) << -1; + QTest::newRow("intmax+qlonglongmax") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(LLONG_MAX) << -1; + QTest::newRow("uintmax+qlonglongmax") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(LLONG_MAX) << -1; + QTest::newRow("intmax+qulonglongmax") << QVariant::fromValue(INT_MAX) << QVariant::fromValue(ULLONG_MAX) << -1; + QTest::newRow("qlonglongmax+qulonglongmax") << QVariant::fromValue(LLONG_MAX) << QVariant::fromValue(ULLONG_MAX) << -1; + QTest::newRow("uintmax+qlonglongmin") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(LLONG_MIN) << +1; // check for no sign-extension issues - QTest::newRow("ushortmax+intzero") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(0) << +1; - QTest::newRow("ushortmax+qlonglongzero") << qVariantFromValue(USHRT_MAX) << qVariantFromValue(Q_INT64_C(0)) << +1; - QTest::newRow("uintmax+qlonglongzero") << qVariantFromValue(UINT_MAX) << qVariantFromValue(Q_INT64_C(0)) << +1; + QTest::newRow("ushortmax+intzero") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(0) << +1; + QTest::newRow("ushortmax+qlonglongzero") << QVariant::fromValue(USHRT_MAX) << QVariant::fromValue(Q_INT64_C(0)) << +1; + QTest::newRow("uintmax+qlonglongzero") << QVariant::fromValue(UINT_MAX) << QVariant::fromValue(Q_INT64_C(0)) << +1; // sign changes // the tests below check that a signed negative number sign-changes to a non-zero unsigned number and that // signed -1 sign-changes to unsigned maximum (all bits set, ~0). This works on two's complement machines // (all that Qt supports), and would also work on one's complement. if (std::numeric_limits<char>::is_signed) { - QTest::newRow("signchange-char+uint") << qVariantFromValue(char(-1)) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-char+uintmax") << qVariantFromValue(char(-1)) << qVariantFromValue(UINT_MAX) << 0; - QTest::newRow("signchange-charmin+uint") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-char+qulonglong") << qVariantFromValue(char(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-char+qulonglongmax") << qVariantFromValue(char(-1)) << qVariantFromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-charmin+qulonglong") << qVariantFromValue(CHAR_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1; - } - QTest::newRow("signchange-schar+uint") << qVariantFromValue(schar(-1)) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-schar+uintmax") << qVariantFromValue(schar(-1)) << qVariantFromValue(UINT_MAX) << 0; - QTest::newRow("signchange-scharmin+uint") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-schar+qulonglong") << qVariantFromValue(schar(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-schar+qulonglongmax") << qVariantFromValue(schar(-1)) << qVariantFromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-scharmin+qulonglong") << qVariantFromValue(SCHAR_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-short+uint") << qVariantFromValue(short(-1)) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-short+uintmax") << qVariantFromValue(short(-1)) << qVariantFromValue(UINT_MAX) << 0; - QTest::newRow("signchange-shortmin+uint") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-short+qulonglong") << qVariantFromValue(short(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-short+qulonglongmax") << qVariantFromValue(short(-1)) << qVariantFromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-shortmin+qulonglong") << qVariantFromValue(SHRT_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-int+uint") << qVariantFromValue(-1) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-int+uintmax") << qVariantFromValue(-1) << qVariantFromValue(UINT_MAX) << 0; - QTest::newRow("signchange-intmin+uint") << qVariantFromValue(INT_MIN) << qVariantFromValue(0U) << +1; - QTest::newRow("signchange-int+qulonglong") << qVariantFromValue(-1) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-int+qulonglongmax") << qVariantFromValue(-1) << qVariantFromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-intmin+qulonglong") << qVariantFromValue(INT_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-char+uint") << QVariant::fromValue(char(-1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-char+uintmax") << QVariant::fromValue(char(-1)) << QVariant::fromValue(UINT_MAX) << 0; + QTest::newRow("signchange-charmin+uint") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-char+qulonglong") << QVariant::fromValue(char(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-char+qulonglongmax") << QVariant::fromValue(char(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; + QTest::newRow("signchange-charmin+qulonglong") << QVariant::fromValue(CHAR_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + } + QTest::newRow("signchange-schar+uint") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-schar+uintmax") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(UINT_MAX) << 0; + QTest::newRow("signchange-scharmin+uint") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-schar+qulonglong") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-schar+qulonglongmax") << QVariant::fromValue(schar(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; + QTest::newRow("signchange-scharmin+qulonglong") << QVariant::fromValue(SCHAR_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-short+uint") << QVariant::fromValue(short(-1)) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-short+uintmax") << QVariant::fromValue(short(-1)) << QVariant::fromValue(UINT_MAX) << 0; + QTest::newRow("signchange-shortmin+uint") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-short+qulonglong") << QVariant::fromValue(short(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-short+qulonglongmax") << QVariant::fromValue(short(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; + QTest::newRow("signchange-shortmin+qulonglong") << QVariant::fromValue(SHRT_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-int+uint") << QVariant::fromValue(-1) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-int+uintmax") << QVariant::fromValue(-1) << QVariant::fromValue(UINT_MAX) << 0; + QTest::newRow("signchange-intmin+uint") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(0U) << +1; + QTest::newRow("signchange-int+qulonglong") << QVariant::fromValue(-1) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-int+qulonglongmax") << QVariant::fromValue(-1) << QVariant::fromValue(ULLONG_MAX) << 0; + QTest::newRow("signchange-intmin+qulonglong") << QVariant::fromValue(INT_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; // no qlonglong+uint, since that should promote to qlonglong and then the comparison is signed (tested above) - QTest::newRow("signchange-qlonglong+qulonglong") << qVariantFromValue(Q_INT64_C(-1)) << qVariantFromValue(Q_UINT64_C(0)) << +1; - QTest::newRow("signchange-qlonglong+qulonglongmax") << qVariantFromValue(Q_INT64_C(-1)) << qVariantFromValue(ULLONG_MAX) << 0; - QTest::newRow("signchange-qlonglongmin+qulonglong") << qVariantFromValue(LLONG_MIN) << qVariantFromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-qlonglong+qulonglong") << QVariant::fromValue(Q_INT64_C(-1)) << QVariant::fromValue(Q_UINT64_C(0)) << +1; + QTest::newRow("signchange-qlonglong+qulonglongmax") << QVariant::fromValue(Q_INT64_C(-1)) << QVariant::fromValue(ULLONG_MAX) << 0; + QTest::newRow("signchange-qlonglongmin+qulonglong") << QVariant::fromValue(LLONG_MIN) << QVariant::fromValue(Q_UINT64_C(0)) << +1; } void tst_QVariant::compareNumbers() const @@ -2761,6 +2763,14 @@ void tst_QVariant::qvariant_cast_QObject_derived() QCOMPARE(data.value<CustomQObjectDerived *>(), object); QCOMPARE(data.value<CustomQObject *>(), object); } + { + QObject *object = new CustomQObjectDerivedNoMetaType(this); + QVariant data = QVariant::fromValue(object); + QVERIFY(data.canConvert<CustomQObjectDerivedNoMetaType*>()); + QVERIFY(data.convert(qMetaTypeId<CustomQObjectDerivedNoMetaType*>())); + QCOMPARE(data.value<CustomQObjectDerivedNoMetaType*>(), object); + QCOMPARE(data.isNull(), false); + } } struct QObjectWrapper @@ -2863,7 +2873,10 @@ void tst_QVariant::qvariant_cast_QObject_wrapper() } { QFile *f = new QFile(this); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QWeakPointer<QFile> sp(f); +QT_WARNING_POP QVariant spVar = QVariant::fromValue(sp); QVERIFY(spVar.canConvert<QObject*>()); QCOMPARE(f, spVar.value<QObject*>()); @@ -3943,7 +3956,7 @@ void tst_QVariant::userConversion() QVERIFY(!(QMetaType::hasRegisteredConverterFunction<QString, Convertible>())); Convertible c = { 123 }; - QVariant v = qVariantFromValue(c); + QVariant v = QVariant::fromValue(c); bool ok; v.toInt(&ok); @@ -3977,7 +3990,7 @@ void tst_QVariant::userConversion() QVERIFY(!(QMetaType::hasRegisteredConverterFunction<QString, BigConvertible>())); BigConvertible c = { 123, 0, 0 }; - QVariant v = qVariantFromValue(c); + QVariant v = QVariant::fromValue(c); bool ok; v.toInt(&ok); @@ -4692,7 +4705,6 @@ Q_DECLARE_METATYPE(EnumTest_Enum0) enum EnumTest_Enum1 : qint64 { 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 }; @@ -4705,7 +4717,6 @@ 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<typename Enum> void testVariant(Enum value, bool *ok) { @@ -4764,7 +4775,6 @@ void tst_QVariant::enums() 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); @@ -4783,7 +4793,6 @@ void tst_QVariant::enums() QVERIFY(ok); testVariant(EnumTest_Enum3::EnumTest_Enum3_value, &ok); QVERIFY(ok); -#endif } template<typename Enum> void testVariantMeta(Enum value, bool *ok, const char *string) diff --git a/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp b/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp index c74bce3b5b..e1357245f3 100644 --- a/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp +++ b/tests/auto/corelib/mimetypes/qmimetype/tst_qmimetype.cpp @@ -91,11 +91,7 @@ static QStringList qMimeTypeGlobPatterns() // ------------------------------------------------------------------------------------------------ -#ifndef Q_COMPILER_RVALUE_REFS -QMIMETYPE_BUILDER -#else QMIMETYPE_BUILDER_FROM_RVALUE_REFS -#endif // ------------------------------------------------------------------------------------------------ diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index c9c9202a80..e0d09b0813 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -30,7 +30,7 @@ #include <QtTest/QtTest> #include <qdir.h> #include <qlibrary.h> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> // Helper macros to let us know if some suffixes and prefixes are valid @@ -414,10 +414,12 @@ void tst_QLibrary::errorString() QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation))); break; } - QRegExp re(errorString); +#if QT_CONFIG(regularexpression) + QRegularExpression re(QRegularExpression::anchoredPattern(errorString)); QString libErrorString = lib.errorString(); + QVERIFY2(re.match(libErrorString).hasMatch(), qPrintable(libErrorString)); +#endif QVERIFY(!lib.isLoaded() || lib.unload()); - QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString)); QCOMPARE(ok, success); } diff --git a/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp index d891839b1e..6d163ea336 100644 --- a/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp @@ -31,7 +31,7 @@ class StaticPlugin : public QObject { Q_OBJECT - Q_PLUGIN_METADATA(IID "SomeIID") + Q_PLUGIN_METADATA(IID "SomeIID" URI "qt.test.pluginloader.staticplugin") public: StaticPlugin() {} }; diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 4316ea14ea..b06000d9c4 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -552,6 +552,7 @@ void tst_QPluginLoader::staticPlugins() QCOMPARE(metaData.value("version").toInt(), QT_VERSION); QCOMPARE(metaData.value("IID").toString(), "SomeIID"); QCOMPARE(metaData.value("ExtraMetaData"), QJsonArray({ "StaticPlugin", "foo" })); + QCOMPARE(metaData.value("URI").toString(), "qt.test.pluginloader.staticplugin"); } diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp index 8907704a33..1cbe0cae48 100644 --- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp +++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp @@ -2755,9 +2755,6 @@ void tst_QtJson::testJsonValueRefDefault() void tst_QtJson::arrayInitializerList() { -#ifndef Q_COMPILER_INITIALIZER_LISTS - QSKIP("initializer_list is enabled only with c++11 support"); -#else QVERIFY(QJsonArray{}.isEmpty()); QCOMPARE(QJsonArray{"one"}.count(), 1); QCOMPARE(QJsonArray{1}.count(), 1); @@ -2803,14 +2800,10 @@ void tst_QtJson::arrayInitializerList() QCOMPARE(QJsonValue(a43["one"]), QJsonValue(1)); } } -#endif } void tst_QtJson::objectInitializerList() { -#ifndef Q_COMPILER_INITIALIZER_LISTS - QSKIP("initializer_list is enabled only with c++11 support"); -#else QVERIFY(QJsonObject{}.isEmpty()); { // one property @@ -2850,7 +2843,6 @@ void tst_QtJson::objectInitializerList() QCOMPARE(QJsonValue(nested[0]), QJsonValue("innerValue")); QCOMPARE(QJsonValue(nested[1]), QJsonValue(2.1)); } -#endif } void tst_QtJson::unicodeKeys() diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 3ad1794176..b8778e4e98 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -113,6 +113,11 @@ private slots: void stream_QRegExp_data(); void stream_QRegExp(); +#if QT_CONFIG(regularexpression) + void stream_QRegularExpression_data(); + void stream_QRegularExpression(); +#endif + void stream_Map_data(); void stream_Map(); @@ -181,6 +186,8 @@ private slots: void streamRealDataTypes(); + void enumTest(); + void floatingPointPrecision(); void compatibility_Qt5(); @@ -219,6 +226,9 @@ private: void writeQSize(QDataStream *s); void writeQString(QDataStream* dev); void writeQRegExp(QDataStream* dev); +#if QT_CONFIG(regularexpression) + void writeQRegularExpression(QDataStream *dev); +#endif void writeMap(QDataStream* dev); void writeHash(QDataStream* dev); void writeqint64(QDataStream *s); @@ -248,6 +258,9 @@ private: void readQSize(QDataStream *s); void readQString(QDataStream *s); void readQRegExp(QDataStream *s); +#if QT_CONFIG(regularexpression) + void readQRegularExpression(QDataStream *s); +#endif void readMap(QDataStream *s); void readHash(QDataStream *s); void readqint64(QDataStream *s); @@ -559,6 +572,69 @@ void tst_QDataStream::readQRegExp(QDataStream *s) // ************************************ +#if QT_CONFIG(regularexpression) +static QRegularExpression QRegularExpressionData(int index) +{ + switch (index) { + case 0: return QRegularExpression(); + case 1: return QRegularExpression(""); + case 2: return QRegularExpression("A", QRegularExpression::CaseInsensitiveOption); + case 3: return QRegularExpression(QRegularExpression::wildcardToRegularExpression("ABCDE FGHI")); + case 4: return QRegularExpression(QRegularExpression::anchoredPattern("This is a long string"), QRegularExpression::CaseInsensitiveOption); + case 5: return QRegularExpression("And again a string with a \nCRLF", QRegularExpression::CaseInsensitiveOption); + case 6: return QRegularExpression("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRESTUVWXYZ 1234567890 ~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", QRegularExpression::InvertedGreedinessOption); + } + return QRegularExpression("foo"); +} +#define MAX_QREGULAREXPRESSION_DATA 7 + +void tst_QDataStream::stream_QRegularExpression_data() +{ + stream_data(MAX_QREGULAREXPRESSION_DATA); +} + +void tst_QDataStream::stream_QRegularExpression() +{ + STREAM_IMPL(QRegularExpression); +} + +void tst_QDataStream::writeQRegularExpression(QDataStream* s) +{ + QRegularExpression test(QRegularExpressionData(dataIndex(QTest::currentDataTag()))); + *s << test; + *s << QString("Her er det noe tekst"); + *s << test; + *s << QString("nonempty"); + *s << test; + *s << QVariant(test); +} + +void tst_QDataStream::readQRegularExpression(QDataStream *s) +{ + QRegularExpression R; + QString S; + QVariant V; + QRegularExpression test(QRegularExpressionData(dataIndex(QTest::currentDataTag()))); + + *s >> R; + + QCOMPARE(R, test); + *s >> S; + QCOMPARE(S, QString("Her er det noe tekst")); + *s >> R; + QCOMPARE(R, test); + *s >> S; + QCOMPARE(S, QString("nonempty")); + *s >> R; + QCOMPARE(R, test); + *s >> V; + QCOMPARE(V.type(), QVariant::RegularExpression); + QCOMPARE(V.toRegularExpression(), test); +} +#endif //QT_CONFIG(regularexpression) + +// ************************************ + typedef QMap<int, QString> Map; static Map MapData(int index) @@ -3441,6 +3517,90 @@ void tst_QDataStream::floatingPointNaN() } } +void tst_QDataStream::enumTest() +{ + QByteArray ba; + + enum class E1 : qint8 + { + A, + B, + C + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E1::A; + QCOMPARE(ba.size(), int(sizeof(E1))); + } + { + QDataStream stream(ba); + E1 e; + stream >> e; + QCOMPARE(e, E1::A); + } + ba.clear(); + + enum class E2 : qint16 + { + A, + B, + C + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E2::B; + QCOMPARE(ba.size(), int(sizeof(E2))); + } + { + QDataStream stream(ba); + E2 e; + stream >> e; + QCOMPARE(e, E2::B); + } + ba.clear(); + + enum class E4 : qint32 + { + A, + B, + C + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E4::C; + QCOMPARE(ba.size(), int(sizeof(E4))); + } + { + QDataStream stream(ba); + E4 e; + stream >> e; + QCOMPARE(e, E4::C); + } + ba.clear(); + + + enum E + { + A, + B, + C, + D + }; + { + QDataStream stream(&ba, QIODevice::WriteOnly); + stream << E::D; + QCOMPARE(ba.size(), 4); + } + { + QDataStream stream(ba); + E e; + stream >> e; + QCOMPARE(e, E::D); + } + ba.clear(); + +} + void tst_QDataStream::floatingPointPrecision() { QByteArray ba; diff --git a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp index 41ea5e56f0..2d4aa452ca 100644 --- a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp +++ b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/main.cpp @@ -41,7 +41,7 @@ int main(int argc, char **argv) do { line = qin.readLine(); if (!line.isNull()) - qerr << line << flush; + qerr << line << Qt::flush; } while (!line.isNull()); return 0; } diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index 8bb35554c8..32306e8003 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -35,6 +35,7 @@ #include <QBuffer> #include <QByteArray> #include <QDebug> +#include <QElapsedTimer> #include <QFile> #include <QTcpSocket> #include <QTemporaryDir> @@ -245,7 +246,7 @@ private: void runOnExit() { QByteArray buffer; - QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << endl; + QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << Qt::endl; } Q_DESTRUCTOR_FUNCTION(runOnExit) @@ -996,7 +997,7 @@ struct CompareIndicesForArray void tst_QTextStream::performance() { // Phase #1 - test speed of reading a huge text file with QFile. - QTime stopWatch; + QElapsedTimer stopWatch; const int N = 3; const char * readMethods[N] = { @@ -1102,7 +1103,7 @@ void tst_QTextStream::hexTest() QByteArray array; QTextStream stream(&array); - stream << showbase << hex << number; + stream << Qt::showbase << Qt::hex << number; stream.flush(); QCOMPARE(array, data); } @@ -1132,7 +1133,7 @@ void tst_QTextStream::binTest() QByteArray array; QTextStream stream(&array); - stream << showbase << bin << number; + stream << Qt::showbase << Qt::bin << number; stream.flush(); QCOMPARE(array.constData(), data.constData()); } @@ -1155,7 +1156,7 @@ void tst_QTextStream::octTest() QByteArray array; QTextStream stream(&array); - stream << showbase << oct << number; + stream << Qt::showbase << Qt::oct << number; stream.flush(); QCOMPARE(array, data); } @@ -1196,7 +1197,7 @@ void tst_QTextStream::ws_manipulator() QTextStream stream(&string); char a, b, c, d; - stream >> a >> ws >> b >> ws >> c >> ws >> d; + stream >> a >> Qt::ws >> b >> Qt::ws >> c >> Qt::ws >> d; QCOMPARE(a, 'a'); QCOMPARE(b, 'b'); QCOMPARE(c, 'c'); @@ -1506,9 +1507,9 @@ void tst_QTextStream::readStdin() stdinProcess.setReadChannel(QProcess::StandardError); QTextStream stream(&stdinProcess); - stream << "1" << endl; - stream << "2" << endl; - stream << "3" << endl; + stream << "1" << Qt::endl; + stream << "2" << Qt::endl; + stream << "3" << Qt::endl; stdinProcess.closeWriteChannel(); @@ -1534,7 +1535,7 @@ void tst_QTextStream::readAllFromStdin() QTextStream stream(&stdinProcess); stream.setCodec("ISO-8859-1"); - stream << "hello world" << flush; + stream << "hello world" << Qt::flush; stdinProcess.closeWriteChannel(); @@ -1623,18 +1624,18 @@ void tst_QTextStream::forcePoint() { QString str; QTextStream stream(&str); - stream << fixed << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; + stream << Qt::fixed << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; QCOMPARE(str, QString("1.000000 1 0 -1.000000 -1")); str.clear(); stream.seek(0); - stream << scientific << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; + stream << Qt::scientific << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; QCOMPARE(str, QString("1.000000e+00 1 0 -1.000000e+00 -1")); str.clear(); stream.seek(0); stream.setRealNumberNotation(QTextStream::SmartNotation); - stream << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; + stream << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1; QCOMPARE(str, QString("1.00000 1 0 -1.00000 -1")); } @@ -1644,7 +1645,7 @@ void tst_QTextStream::forceSign() { QString str; QTextStream stream(&str); - stream << forcesign << 1.2 << ' ' << -1.2 << ' ' << 0; + stream << Qt::forcesign << 1.2 << ' ' << -1.2 << ' ' << 0; QCOMPARE(str, QString("+1.2 -1.2 +0")); } @@ -1663,19 +1664,22 @@ void tst_QTextStream::read0d0d0a() Q_DECLARE_METATYPE(QTextStreamFunction); +// Also tests that we can have namespaces that conflict with our QTextStream constants. +namespace ws { QTextStream &noop(QTextStream &s) { return s; } +} void tst_QTextStream::numeralCase_data() { - QTextStreamFunction noop_ = noop; - QTextStreamFunction bin_ = bin; - QTextStreamFunction oct_ = oct; - QTextStreamFunction hex_ = hex; - QTextStreamFunction base = showbase; - QTextStreamFunction ucb = uppercasebase; - QTextStreamFunction lcb = lowercasebase; - QTextStreamFunction ucd = uppercasedigits; - QTextStreamFunction lcd = lowercasedigits; + QTextStreamFunction noop_ = ws::noop; + QTextStreamFunction bin = Qt::bin; + QTextStreamFunction oct = Qt::oct; + QTextStreamFunction hex = Qt::hex; + QTextStreamFunction base = Qt::showbase; + QTextStreamFunction ucb = Qt::uppercasebase; + QTextStreamFunction lcb = Qt::lowercasebase; + QTextStreamFunction ucd = Qt::uppercasedigits; + QTextStreamFunction lcd = Qt::lowercasedigits; QTest::addColumn<QTextStreamFunction>("func1"); QTest::addColumn<QTextStreamFunction>("func2"); @@ -1686,30 +1690,30 @@ void tst_QTextStream::numeralCase_data() QTest::newRow("dec 1") << noop_ << noop_ << noop_ << noop_ << 31 << "31"; QTest::newRow("dec 2") << noop_ << base << noop_ << noop_ << 31 << "31"; - QTest::newRow("hex 1") << hex_ << noop_ << noop_ << noop_ << 31 << "1f"; - QTest::newRow("hex 2") << hex_ << noop_ << noop_ << lcd << 31 << "1f"; - QTest::newRow("hex 3") << hex_ << noop_ << ucb << noop_ << 31 << "1f"; - QTest::newRow("hex 4") << hex_ << noop_ << noop_ << ucd << 31 << "1F"; - QTest::newRow("hex 5") << hex_ << noop_ << lcb << ucd << 31 << "1F"; - QTest::newRow("hex 6") << hex_ << noop_ << ucb << ucd << 31 << "1F"; - QTest::newRow("hex 7") << hex_ << base << noop_ << noop_ << 31 << "0x1f"; - QTest::newRow("hex 8") << hex_ << base << lcb << lcd << 31 << "0x1f"; - QTest::newRow("hex 9") << hex_ << base << ucb << noop_ << 31 << "0X1f"; - QTest::newRow("hex 10") << hex_ << base << ucb << lcd << 31 << "0X1f"; - QTest::newRow("hex 11") << hex_ << base << noop_ << ucd << 31 << "0x1F"; - QTest::newRow("hex 12") << hex_ << base << lcb << ucd << 31 << "0x1F"; - QTest::newRow("hex 13") << hex_ << base << ucb << ucd << 31 << "0X1F"; - - QTest::newRow("bin 1") << bin_ << noop_ << noop_ << noop_ << 31 << "11111"; - QTest::newRow("bin 2") << bin_ << base << noop_ << noop_ << 31 << "0b11111"; - QTest::newRow("bin 3") << bin_ << base << lcb << noop_ << 31 << "0b11111"; - QTest::newRow("bin 4") << bin_ << base << ucb << noop_ << 31 << "0B11111"; - QTest::newRow("bin 5") << bin_ << base << noop_ << ucd << 31 << "0b11111"; - QTest::newRow("bin 6") << bin_ << base << lcb << ucd << 31 << "0b11111"; - QTest::newRow("bin 7") << bin_ << base << ucb << ucd << 31 << "0B11111"; - - QTest::newRow("oct 1") << oct_ << noop_ << noop_ << noop_ << 31 << "37"; - QTest::newRow("oct 2") << oct_ << base << noop_ << noop_ << 31 << "037"; + QTest::newRow("hex 1") << hex << noop_ << noop_ << noop_ << 31 << "1f"; + QTest::newRow("hex 2") << hex << noop_ << noop_ << lcd << 31 << "1f"; + QTest::newRow("hex 3") << hex << noop_ << ucb << noop_ << 31 << "1f"; + QTest::newRow("hex 4") << hex << noop_ << noop_ << ucd << 31 << "1F"; + QTest::newRow("hex 5") << hex << noop_ << lcb << ucd << 31 << "1F"; + QTest::newRow("hex 6") << hex << noop_ << ucb << ucd << 31 << "1F"; + QTest::newRow("hex 7") << hex << base << noop_ << noop_ << 31 << "0x1f"; + QTest::newRow("hex 8") << hex << base << lcb << lcd << 31 << "0x1f"; + QTest::newRow("hex 9") << hex << base << ucb << noop_ << 31 << "0X1f"; + QTest::newRow("hex 10") << hex << base << ucb << lcd << 31 << "0X1f"; + QTest::newRow("hex 11") << hex << base << noop_ << ucd << 31 << "0x1F"; + QTest::newRow("hex 12") << hex << base << lcb << ucd << 31 << "0x1F"; + QTest::newRow("hex 13") << hex << base << ucb << ucd << 31 << "0X1F"; + + QTest::newRow("bin 1") << bin << noop_ << noop_ << noop_ << 31 << "11111"; + QTest::newRow("bin 2") << bin << base << noop_ << noop_ << 31 << "0b11111"; + QTest::newRow("bin 3") << bin << base << lcb << noop_ << 31 << "0b11111"; + QTest::newRow("bin 4") << bin << base << ucb << noop_ << 31 << "0B11111"; + QTest::newRow("bin 5") << bin << base << noop_ << ucd << 31 << "0b11111"; + QTest::newRow("bin 6") << bin << base << lcb << ucd << 31 << "0b11111"; + QTest::newRow("bin 7") << bin << base << ucb << ucd << 31 << "0B11111"; + + QTest::newRow("oct 1") << oct << noop_ << noop_ << noop_ << 31 << "37"; + QTest::newRow("oct 2") << oct << base << noop_ << noop_ << 31 << "037"; } void tst_QTextStream::numeralCase() @@ -1782,9 +1786,9 @@ void tst_QTextStream::nanInf() QString s; QTextStream out(&s); out << qInf() << ' ' << -qInf() << ' ' << qQNaN() - << uppercasedigits << ' ' + << Qt::uppercasedigits << ' ' << qInf() << ' ' << -qInf() << ' ' << qQNaN() - << flush; + << Qt::flush; QCOMPARE(s, QString("inf -inf nan INF -INF NAN")); } @@ -1821,7 +1825,7 @@ void tst_QTextStream::utf8IncompleteAtBufferBoundary() out.setFieldWidth(3); for (int i = 0; i < 1000; ++i) { - out << i << lineContents << endl; + out << i << lineContents << Qt::endl; } } data.close(); @@ -1859,9 +1863,9 @@ void tst_QTextStream::writeSeekWriteNoBOM() int number = 0; QString sizeStr = QLatin1String("Size=") + QString::number(number).rightJustified(10, QLatin1Char('0')); - stream << sizeStr << endl; - stream << "Version=" << QString::number(14) << endl; - stream << "blah blah blah" << endl; + stream << sizeStr << Qt::endl; + stream << "Version=" << QString::number(14) << Qt::endl; + stream << "blah blah blah" << Qt::endl; stream.flush(); QCOMPARE(out.buffer().constData(), "Size=0000000000\nVersion=14\nblah blah blah\n"); @@ -1871,7 +1875,7 @@ void tst_QTextStream::writeSeekWriteNoBOM() stream.seek(0); sizeStr = QLatin1String("Size=") + QString::number(number).rightJustified(10, QLatin1Char('0')); - stream << sizeStr << endl; + stream << sizeStr << Qt::endl; stream.flush(); // Check buffer is still OK @@ -2723,7 +2727,7 @@ void tst_QTextStream::generateBOM() QTextStream stream(&file); stream.setCodec(QTextCodec::codecForName("UTF-16LE")); - stream << "Hello" << endl; + stream << "Hello" << Qt::endl; file.close(); QVERIFY(file.open(QFile::ReadOnly)); @@ -2737,7 +2741,7 @@ void tst_QTextStream::generateBOM() QTextStream stream(&file); stream.setCodec(QTextCodec::codecForName("UTF-16LE")); - stream << bom << "Hello" << endl; + stream << Qt::bom << "Hello" << Qt::endl; file.close(); QVERIFY(file.open(QFile::ReadOnly)); diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index 8fdf91b090..92a0d8bbfa 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -115,7 +115,7 @@ static QByteArray makeCanonical(const QString &filename, writeDtd << "<!DOCTYPE "; writeDtd << docType; writeDtd << " ["; - writeDtd << endl; + writeDtd << Qt::endl; for (const QXmlStreamNotationDeclaration ¬ation : sorted_by_name(notationDeclarations)) { writeDtd << "<!NOTATION "; writeDtd << notation.name().toString(); @@ -134,11 +134,11 @@ static QByteArray makeCanonical(const QString &filename, } } writeDtd << '>'; - writeDtd << endl; + writeDtd << Qt::endl; } writeDtd << "]>"; - writeDtd << endl; + writeDtd << Qt::endl; writer.writeDTD(dtd); } } else if (reader.isStartElement()) { @@ -253,7 +253,7 @@ public: qFatal("%s: aId must not be an empty string", Q_FUNC_INFO); } - void swap(MissedBaseline &other) Q_DECL_NOTHROW + void swap(MissedBaseline &other) noexcept { qSwap(id, other.id); qSwap(expected, other.expected); @@ -740,7 +740,7 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) const auto attributes = reader.attributes(); if (attributes.size()) { for (const QXmlStreamAttribute &attribute : attributes) { - writer << endl << " Attribute("; + writer << Qt::endl << " Attribute("; if (!attribute.name().isEmpty()) writer << " name=\"" << attribute.name().toString() << '"'; if (!attribute.namespaceUri().isEmpty()) @@ -751,37 +751,37 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " prefix=\"" << attribute.prefix().toString() << '"'; if (!attribute.value().isEmpty()) writer << " value=\"" << attribute.value().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } const auto namespaceDeclarations = reader.namespaceDeclarations(); if (namespaceDeclarations.size()) { for (const QXmlStreamNamespaceDeclaration &namespaceDeclaration : namespaceDeclarations) { - writer << endl << " NamespaceDeclaration("; + writer << Qt::endl << " NamespaceDeclaration("; if (!namespaceDeclaration.prefix().isEmpty()) writer << " prefix=\"" << namespaceDeclaration.prefix().toString() << '"'; if (!namespaceDeclaration.namespaceUri().isEmpty()) writer << " namespaceUri=\"" << namespaceDeclaration.namespaceUri().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } const auto notationDeclarations = reader.notationDeclarations(); if (notationDeclarations.size()) { for (const QXmlStreamNotationDeclaration ¬ationDeclaration : notationDeclarations) { - writer << endl << " NotationDeclaration("; + writer << Qt::endl << " NotationDeclaration("; if (!notationDeclaration.name().isEmpty()) writer << " name=\"" << notationDeclaration.name().toString() << '"'; if (!notationDeclaration.systemId().isEmpty()) writer << " systemId=\"" << notationDeclaration.systemId().toString() << '"'; if (!notationDeclaration.publicId().isEmpty()) writer << " publicId=\"" << notationDeclaration.publicId().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } const auto entityDeclarations = reader.entityDeclarations(); if (entityDeclarations.size()) { for (const QXmlStreamEntityDeclaration &entityDeclaration : entityDeclarations) { - writer << endl << " EntityDeclaration("; + writer << Qt::endl << " EntityDeclaration("; if (!entityDeclaration.name().isEmpty()) writer << " name=\"" << entityDeclaration.name().toString() << '"'; if (!entityDeclaration.notationName().isEmpty()) @@ -792,13 +792,13 @@ QByteArray tst_QXmlStream::readFile(const QString &filename) writer << " publicId=\"" << entityDeclaration.publicId().toString() << '"'; if (!entityDeclaration.value().isEmpty()) writer << " value=\"" << entityDeclaration.value().toString() << '"'; - writer << " )" << endl; + writer << " )" << Qt::endl; } } - writer << " )" << endl; + writer << " )" << Qt::endl; } if (reader.hasError()) - writer << "ERROR: " << reader.errorString() << endl; + writer << "ERROR: " << reader.errorString() << Qt::endl; return outarray; } @@ -1169,7 +1169,7 @@ int main(int argc, char *argv[]) bool error = false; QByteArray canonical = makeCanonical(argv[2], "doc", error); QTextStream myStdOut(stdout); - myStdOut << canonical << endl; + myStdOut << canonical << Qt::endl; exit(0); } diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 810698fb4e..72a6f0360d 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -336,7 +336,9 @@ void tst_QStateMachine::transitionToRootState() TEST_ACTIVE_CHANGED(initialState, 1); machine.postEvent(new QEvent(QEvent::User)); - QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 'initial'"); + QTest::ignoreMessage(QtWarningMsg, + "Unrecoverable error detected in running state machine: " + "Child mode of state machine 'machine' is not 'ExclusiveStates'!"); QCoreApplication::processEvents(); QVERIFY(machine.configuration().isEmpty()); QVERIFY(!machine.isRunning()); @@ -1061,7 +1063,8 @@ void tst_QStateMachine::transitionToStateNotInGraph() initialState->addTransition(&independentState); machine.start(); - QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 'initialState'"); + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: " + "Child mode of state machine '' is not 'ExclusiveStates'!"); QCoreApplication::processEvents(); QCOMPARE(machine.isRunning(), false); @@ -1734,13 +1737,13 @@ protected: if (e->type() != QEvent::Type(QEvent::User+2)) return false; StringEvent *se = static_cast<StringEvent*>(e); - return (m_value == se->value) && (!m_cond.isValid() || (m_cond.indexIn(m_value) != -1)); + return (m_value == se->value) && (!m_cond.isValid() || m_cond.match(m_value).hasMatch()); } virtual void onTransition(QEvent *) {} private: QString m_value; - QRegExp m_cond; + QRegularExpression m_cond; }; class StringEventPoster : public QState @@ -2099,6 +2102,8 @@ void tst_QStateMachine::parallelRootState() QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: " + "Child mode of state machine '' is not 'ExclusiveStates'!"); QTRY_COMPARE(startedSpy.count(), 1); QCOMPARE(machine.configuration().size(), 4); QVERIFY(machine.configuration().contains(s1)); @@ -3310,14 +3315,15 @@ void tst_QStateMachine::targetStateWithNoParent() QVERIFY(runningSpy.isValid()); machine.start(); - QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'"); + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: " + "Child mode of state machine '' is not 'ExclusiveStates'!"); TEST_ACTIVE_CHANGED(s1, 2); QTRY_COMPARE(startedSpy.count(), 1); QCOMPARE(machine.isRunning(), false); QCOMPARE(stoppedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); TEST_RUNNING_CHANGED_STARTED_STOPPED; - QCOMPARE(machine.error(), QStateMachine::NoCommonAncestorForTransitionError); + QCOMPARE(machine.error(), QStateMachine::StateMachineChildModeSetToParallelError); } void tst_QStateMachine::targetStateDeleted() @@ -6680,13 +6686,13 @@ void tst_QStateMachine::dontProcessSlotsWhenMachineIsNotRunning() } emitter; initialState.addTransition(&emitter, &Emitter::signalWithNoArg, &finalState); - QTimer::singleShot(0, [&]() { - metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); - metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); - }); machine.addState(&initialState); machine.addState(&finalState); machine.setInitialState(&initialState); + connect(&machine, &QStateMachine::started, &emitter, [&]() { + metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); + metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); + }); connect(&machine, &QStateMachine::finished, &emitter.thread, &QThread::quit); machine.start(); QSignalSpy emittedSpy(&emitter, &SignalEmitter::signalWithNoArg); diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index cc197cabba..bef491d5f0 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -31,6 +31,7 @@ #include <QAtomicInt> #include <QCoreApplication> +#include <QElapsedTimer> #include <limits.h> @@ -104,12 +105,12 @@ static void warningFreeHelperTemplate() assemblyMarker<1>(&i); // the loads sometimes generate no assembly output - i.load(); + i.loadRelaxed(); assemblyMarker<11>(&i); i.loadAcquire(); assemblyMarker<12>(&i); - i.store(newValue); + i.storeRelaxed(newValue); assemblyMarker<21>(&i); i.storeRelease(newValue); assemblyMarker<22>(&i); @@ -281,9 +282,9 @@ void tst_QAtomicInt::constructor() { QFETCH(int, value); QAtomicInt atomic1(value); - QCOMPARE(atomic1.load(), value); + QCOMPARE(atomic1.loadRelaxed(), value); QAtomicInt atomic2 = value; - QCOMPARE(atomic2.load(), value); + QCOMPARE(atomic2.loadRelaxed(), value); } void tst_QAtomicInt::copy_constructor_data() @@ -293,16 +294,16 @@ void tst_QAtomicInt::copy_constructor() { QFETCH(int, value); QAtomicInt atomic1(value); - QCOMPARE(atomic1.load(), value); + QCOMPARE(atomic1.loadRelaxed(), value); QAtomicInt atomic2(atomic1); - QCOMPARE(atomic2.load(), value); + QCOMPARE(atomic2.loadRelaxed(), value); QAtomicInt atomic3 = atomic1; - QCOMPARE(atomic3.load(), value); + QCOMPARE(atomic3.loadRelaxed(), value); QAtomicInt atomic4(atomic2); - QCOMPARE(atomic4.load(), value); + QCOMPARE(atomic4.loadRelaxed(), value); QAtomicInt atomic5 = atomic2; - QCOMPARE(atomic5.load(), value); + QCOMPARE(atomic5.loadRelaxed(), value); } void tst_QAtomicInt::assignment_operator_data() @@ -326,13 +327,13 @@ void tst_QAtomicInt::assignment_operator() { QAtomicInt atomic1 = value; atomic1 = newval; - QCOMPARE(atomic1.load(), newval); + QCOMPARE(atomic1.loadRelaxed(), newval); atomic1 = value; - QCOMPARE(atomic1.load(), value); + QCOMPARE(atomic1.loadRelaxed(), value); QAtomicInt atomic2 = newval; atomic1 = atomic2; - QCOMPARE(atomic1.load(), atomic2.load()); + QCOMPARE(atomic1.loadRelaxed(), atomic2.loadRelaxed()); } } @@ -400,7 +401,7 @@ void tst_QAtomicInt::ref() QFETCH(int, value); QAtomicInt x = value; QTEST(x.ref() ? 1 : 0, "result"); - QTEST(x.load(), "expected"); + QTEST(x.loadRelaxed(), "expected"); } void tst_QAtomicInt::deref_data() @@ -419,7 +420,7 @@ void tst_QAtomicInt::deref() QFETCH(int, value); QAtomicInt x = value; QTEST(x.deref() ? 1 : 0, "result"); - QTEST(x.load(), "expected"); + QTEST(x.loadRelaxed(), "expected"); } void tst_QAtomicInt::isTestAndSetNative() @@ -635,25 +636,25 @@ void tst_QAtomicInt::fetchAndStore() { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreRelaxed(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreAcquire(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreRelease(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreOrdered(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } } @@ -772,28 +773,28 @@ void tst_QAtomicInt::fetchAndAdd() QAtomicInt atomic = value1; result = atomic.fetchAndAddRelaxed(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } { QAtomicInt atomic = value1; result = atomic.fetchAndAddAcquire(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } { QAtomicInt atomic = value1; result = atomic.fetchAndAddRelease(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } { QAtomicInt atomic = value1; result = atomic.fetchAndAddOrdered(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } } @@ -851,14 +852,14 @@ void tst_QAtomicInt::operators() void tst_QAtomicInt::testAndSet_loop() { - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); int iterations = 10000000; QAtomicInt val=0; for (int i = 0; i < iterations; ++i) { - int v = val.load(); + int v = val.loadRelaxed(); QVERIFY(val.testAndSetRelaxed(v, v+1)); if ((i % 1000) == 999) { if (stopWatch.elapsed() > 60 * 1000) { @@ -881,7 +882,7 @@ void tst_QAtomicInt::fetchAndAdd_loop() QAtomicInt val=0; for (int i = 0; i < iterations; ++i) { const int prev = val.fetchAndAddRelaxed(1); - QCOMPARE(prev, val.load() -1); + QCOMPARE(prev, val.loadRelaxed() -1); } } @@ -919,7 +920,7 @@ void tst_QAtomicInt::fetchAndAdd_threadedLoop() t1.wait(); t2.wait(); - QCOMPARE(val.load(), 0); + QCOMPARE(val.loadRelaxed(), 0); } QTEST_MAIN(tst_QAtomicInt) diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp index 32e5b8ee56..bfe2a60088 100644 --- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp +++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp @@ -270,13 +270,13 @@ void tst_QAtomicIntegerXX::constructor() QFETCH(LargeInt, value); QAtomicInteger<T> atomic(value); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QAtomicInteger<T> atomic2 = value; - QCOMPARE(atomic2.load(), T(value)); + QCOMPARE(atomic2.loadRelaxed(), T(value)); - QVERIFY(atomic.load() >= std::numeric_limits<T>::min()); - QVERIFY(atomic.load() <= std::numeric_limits<T>::max()); + QVERIFY(atomic.loadRelaxed() >= std::numeric_limits<T>::min()); + QVERIFY(atomic.loadRelaxed() <= std::numeric_limits<T>::max()); } void tst_QAtomicIntegerXX::copy() @@ -285,17 +285,17 @@ void tst_QAtomicIntegerXX::copy() QAtomicInteger<T> atomic(value); QAtomicInteger<T> copy(atomic); - QCOMPARE(copy.load(), atomic.load()); + QCOMPARE(copy.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger<T> copy2 = atomic; - QCOMPARE(copy2.load(), atomic.load()); + QCOMPARE(copy2.loadRelaxed(), atomic.loadRelaxed()); // move - QAtomicInteger<T> copy3(qMove(copy)); - QCOMPARE(copy3.load(), atomic.load()); + QAtomicInteger<T> copy3(std::move(copy)); + QCOMPARE(copy3.loadRelaxed(), atomic.loadRelaxed()); - QAtomicInteger<T> copy4 = qMove(copy2); - QCOMPARE(copy4.load(), atomic.load()); + QAtomicInteger<T> copy4 = std::move(copy2); + QCOMPARE(copy4.loadRelaxed(), atomic.loadRelaxed()); } void tst_QAtomicIntegerXX::assign() @@ -305,24 +305,24 @@ void tst_QAtomicIntegerXX::assign() QAtomicInteger<T> atomic(value); QAtomicInteger<T> copy; copy = atomic; - QCOMPARE(copy.load(), atomic.load()); + QCOMPARE(copy.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger<T> copy2; copy2 = atomic; // operator=(const QAtomicInteger &) - QCOMPARE(copy2.load(), atomic.load()); + QCOMPARE(copy2.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger<T> copy2bis; - copy2bis = atomic.load(); // operator=(T) - QCOMPARE(copy2bis.load(), atomic.load()); + copy2bis = atomic.loadRelaxed(); // operator=(T) + QCOMPARE(copy2bis.loadRelaxed(), atomic.loadRelaxed()); // move QAtomicInteger<T> copy3; - copy3 = qMove(copy); - QCOMPARE(copy3.load(), atomic.load()); + copy3 = std::move(copy); + QCOMPARE(copy3.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger<T> copy4; - copy4 = qMove(copy2); - QCOMPARE(copy4.load(), atomic.load()); + copy4 = std::move(copy2); + QCOMPARE(copy4.loadRelaxed(), atomic.loadRelaxed()); } void tst_QAtomicIntegerXX::operatorInteger() @@ -331,7 +331,7 @@ void tst_QAtomicIntegerXX::operatorInteger() QAtomicInteger<T> atomic(value); T val2 = atomic; - QCOMPARE(val2, atomic.load()); + QCOMPARE(val2, atomic.loadRelaxed()); QCOMPARE(val2, T(value)); } @@ -346,7 +346,7 @@ void tst_QAtomicIntegerXX::loadAcquireStoreRelease() QCOMPARE(atomic.loadAcquire(), T(~value)); atomic.storeRelease(value); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); } void tst_QAtomicIntegerXX::refDeref() @@ -364,16 +364,16 @@ void tst_QAtomicIntegerXX::refDeref() QAtomicInteger<T> atomic(value); if (!needToPreventOverflow) { QCOMPARE(atomic.ref(), (nextValue != 0)); - QCOMPARE(atomic.load(), nextValue); + QCOMPARE(atomic.loadRelaxed(), nextValue); QCOMPARE(atomic.deref(), (value != 0)); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.deref(), (prevValue != 0)); - QCOMPARE(atomic.load(), prevValue); + QCOMPARE(atomic.loadRelaxed(), prevValue); QCOMPARE(atomic.ref(), (value != 0)); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(++atomic, nextValue); @@ -392,7 +392,7 @@ void tst_QAtomicIntegerXX::refDeref() QCOMPARE(atomic--, T(value)); QCOMPARE(atomic++, prevValue); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); } void tst_QAtomicIntegerXX::testAndSet() @@ -402,16 +402,16 @@ void tst_QAtomicIntegerXX::testAndSet() QAtomicInteger<T> atomic(value); QVERIFY(atomic.testAndSetRelaxed(value, newValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetRelaxed(value, newValue)); QVERIFY(atomic.testAndSetRelaxed(newValue, value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetAcquire(value, newValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetAcquire(value, newValue)); QVERIFY(atomic.testAndSetAcquire(newValue, value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetRelease(value, newValue)); QCOMPARE(atomic.loadAcquire(), newValue); @@ -434,18 +434,18 @@ void tst_QAtomicIntegerXX::testAndSet3() QAtomicInteger<T> atomic(value); QVERIFY(atomic.testAndSetRelaxed(value, newValue, oldValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetRelaxed(value, newValue, oldValue)); QCOMPARE(oldValue, newValue); QVERIFY(atomic.testAndSetRelaxed(newValue, value, oldValue)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetAcquire(value, newValue, oldValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetAcquire(value, newValue, oldValue)); QCOMPARE(oldValue, newValue); QVERIFY(atomic.testAndSetAcquire(newValue, value, oldValue)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetRelease(value, newValue, oldValue)); QCOMPARE(atomic.loadAcquire(), newValue); @@ -469,14 +469,14 @@ void tst_QAtomicIntegerXX::fetchAndStore() QAtomicInteger<T> atomic(value); QCOMPARE(atomic.fetchAndStoreRelaxed(newValue), T(value)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QCOMPARE(atomic.fetchAndStoreRelaxed(value), newValue); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndStoreAcquire(newValue), T(value)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QCOMPARE(atomic.fetchAndStoreAcquire(value), newValue); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndStoreRelease(newValue), T(value)); QCOMPARE(atomic.loadAcquire(), newValue); @@ -509,29 +509,29 @@ void tst_QAtomicIntegerXX::fetchAndAdd() if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndAddAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndAddAcquire(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndAddAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndAddAcquire(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndAddRelease(parcel1), T(value)); @@ -590,29 +590,29 @@ void tst_QAtomicIntegerXX::fetchAndSub() if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndSubAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndSubAcquire(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndSubAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndSubAcquire(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndSubRelease(parcel1), T(value)); @@ -662,32 +662,32 @@ void tst_QAtomicIntegerXX::fetchAndOr() QCOMPARE(atomic.fetchAndOrRelaxed(zero), T(value)); QCOMPARE(atomic.fetchAndOrRelaxed(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrRelaxed(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndOrAcquire(zero), T(value)); QCOMPARE(atomic.fetchAndOrAcquire(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrAcquire(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndOrRelease(zero), T(value)); QCOMPARE(atomic.fetchAndOrRelease(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrRelease(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndOrOrdered(zero), T(value)); QCOMPARE(atomic.fetchAndOrOrdered(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrOrdered(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic |= zero, T(value)); QCOMPARE(atomic |= one, T(value | 1)); QCOMPARE(atomic |= minusOne, minusOne); @@ -703,37 +703,37 @@ void tst_QAtomicIntegerXX::fetchAndAnd() T minusOne = T(~0); QCOMPARE(atomic.fetchAndAndRelaxed(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndRelaxed(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndRelaxed(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndAndAcquire(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndAcquire(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndAcquire(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndAndRelease(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndRelease(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndRelease(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndAndOrdered(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndOrdered(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndOrdered(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic &= minusOne, T(value)); QCOMPARE(atomic &= f, T(value & 0xf)); QCOMPARE(atomic &= zero, zero); @@ -749,48 +749,48 @@ void tst_QAtomicIntegerXX::fetchAndXor() T minusOne = T(~0); QCOMPARE(atomic.fetchAndXorRelaxed(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorAcquire(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelease(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorOrdered(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic ^= zero, T(value)); QCOMPARE(atomic ^= pattern, T(value ^ pattern)); diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp index 0200473cae..a699cf6202 100644 --- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp @@ -75,7 +75,7 @@ void tst_QAtomicPointer::warningFreeHelper() QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0); - p.load()->bar(); + p.loadRelaxed()->bar(); WFHC *expectedValue = 0; WFHC *newValue = 0; @@ -119,15 +119,15 @@ void tst_QAtomicPointer::constructor() { void *one = this; QAtomicPointer<void> atomic1 = one; - QCOMPARE(atomic1.load(), one); + QCOMPARE(atomic1.loadRelaxed(), one); void *two = &one; QAtomicPointer<void> atomic2 = two; - QCOMPARE(atomic2.load(), two); + QCOMPARE(atomic2.loadRelaxed(), two); void *three = &two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic3.loadRelaxed(), three); } void tst_QAtomicPointer::copy_constructor() @@ -135,20 +135,20 @@ void tst_QAtomicPointer::copy_constructor() void *one = this; QAtomicPointer<void> atomic1 = one; QAtomicPointer<void> atomic1_copy = atomic1; - QCOMPARE(atomic1_copy.load(), one); - QCOMPARE(atomic1_copy.load(), atomic1.load()); + QCOMPARE(atomic1_copy.loadRelaxed(), one); + QCOMPARE(atomic1_copy.loadRelaxed(), atomic1.loadRelaxed()); void *two = &one; QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic2_copy = atomic2; - QCOMPARE(atomic2_copy.load(), two); - QCOMPARE(atomic2_copy.load(), atomic2.load()); + QCOMPARE(atomic2_copy.loadRelaxed(), two); + QCOMPARE(atomic2_copy.loadRelaxed(), atomic2.loadRelaxed()); void *three = &two; QAtomicPointer<void> atomic3 = three; QAtomicPointer<void> atomic3_copy = atomic3; - QCOMPARE(atomic3_copy.load(), three); - QCOMPARE(atomic3_copy.load(), atomic3.load()); + QCOMPARE(atomic3_copy.loadRelaxed(), three); + QCOMPARE(atomic3_copy.loadRelaxed(), atomic3.loadRelaxed()); } void tst_QAtomicPointer::assignment_operator() @@ -161,17 +161,17 @@ void tst_QAtomicPointer::assignment_operator() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); atomic1 = two; atomic2 = three; atomic3 = one; - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } void tst_QAtomicPointer::isTestAndSetNative() @@ -234,17 +234,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetRelaxed(one, two)); QVERIFY(atomic2.testAndSetRelaxed(two, three)); QVERIFY(atomic3.testAndSetRelaxed(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -252,17 +252,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetAcquire(one, two)); QVERIFY(atomic2.testAndSetAcquire(two, three)); QVERIFY(atomic3.testAndSetAcquire(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -270,17 +270,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetRelease(one, two)); QVERIFY(atomic2.testAndSetRelease(two, three)); QVERIFY(atomic3.testAndSetRelease(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -288,17 +288,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetOrdered(one, two)); QVERIFY(atomic2.testAndSetOrdered(two, three)); QVERIFY(atomic3.testAndSetOrdered(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } } @@ -362,17 +362,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreRelaxed(two), one); QCOMPARE(atomic2.fetchAndStoreRelaxed(three), two); QCOMPARE(atomic3.fetchAndStoreRelaxed(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -380,17 +380,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreAcquire(two), one); QCOMPARE(atomic2.fetchAndStoreAcquire(three), two); QCOMPARE(atomic3.fetchAndStoreAcquire(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -398,17 +398,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreRelease(two), one); QCOMPARE(atomic2.fetchAndStoreRelease(three), two); QCOMPARE(atomic3.fetchAndStoreRelease(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -416,17 +416,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer<void> atomic2 = two; QAtomicPointer<void> atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreOrdered(two), one); QCOMPARE(atomic2.fetchAndStoreOrdered(three), two); QCOMPARE(atomic3.fetchAndStoreOrdered(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } } @@ -530,60 +530,60 @@ void tst_QAtomicPointer::fetchAndAdd() // cast to void* in order to avoid QCOMPARE to compare string content of the char* QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelaxed(valueToAdd)), static_cast<void*>(pc)); QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelaxed(-valueToAdd)), static_cast<void*>(pc + valueToAdd)); - QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc)); + QCOMPARE(static_cast<void*>(pointer1.loadRelaxed()), static_cast<void*>(pc)); QAtomicPointer<short> pointer2 = ps; QCOMPARE(pointer2.fetchAndAddRelaxed(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddRelaxed(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer<int> pointer3 = pi; QCOMPARE(pointer3.fetchAndAddRelaxed(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddRelaxed(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } { QAtomicPointer<char> pointer1 = pc; QCOMPARE(static_cast<void*>(pointer1.fetchAndAddAcquire(valueToAdd)), static_cast<void*>(pc)); QCOMPARE(static_cast<void*>(pointer1.fetchAndAddAcquire(-valueToAdd)), static_cast<void*>(pc + valueToAdd)); - QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc)); + QCOMPARE(static_cast<void*>(pointer1.loadRelaxed()), static_cast<void*>(pc)); QAtomicPointer<short> pointer2 = ps; QCOMPARE(pointer2.fetchAndAddAcquire(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddAcquire(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer<int> pointer3 = pi; QCOMPARE(pointer3.fetchAndAddAcquire(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddAcquire(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } { QAtomicPointer<char> pointer1 = pc; QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelease(valueToAdd)), static_cast<void*>(pc)); QCOMPARE(static_cast<void*>(pointer1.fetchAndAddRelease(-valueToAdd)), static_cast<void*>(pc + valueToAdd)); - QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc)); + QCOMPARE(static_cast<void*>(pointer1.loadRelaxed()), static_cast<void*>(pc)); QAtomicPointer<short> pointer2 = ps; QCOMPARE(pointer2.fetchAndAddRelease(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddRelease(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer<int> pointer3 = pi; QCOMPARE(pointer3.fetchAndAddRelease(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddRelease(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } { QAtomicPointer<char> pointer1 = pc; QCOMPARE(static_cast<void*>(pointer1.fetchAndAddOrdered(valueToAdd)), static_cast<void*>(pc)); QCOMPARE(static_cast<void*>(pointer1.fetchAndAddOrdered(-valueToAdd)), static_cast<void*>(pc + valueToAdd)); - QCOMPARE(static_cast<void*>(pointer1.load()), static_cast<void*>(pc)); + QCOMPARE(static_cast<void*>(pointer1.loadRelaxed()), static_cast<void*>(pc)); QAtomicPointer<short> pointer2 = ps; QCOMPARE(pointer2.fetchAndAddOrdered(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddOrdered(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer<int> pointer3 = pi; QCOMPARE(pointer3.fetchAndAddOrdered(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddOrdered(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } } @@ -598,34 +598,34 @@ template <typename T> void constAndVolatile_helper() QAtomicPointer<T> atomic2 = two; QAtomicPointer<T> atomic3 = three; - QVERIFY(atomic1.load() == one); - QVERIFY(atomic2.load() == two); - QVERIFY(atomic3.load() == three); + QVERIFY(atomic1.loadRelaxed() == one); + QVERIFY(atomic2.loadRelaxed() == two); + QVERIFY(atomic3.loadRelaxed() == three); QVERIFY(atomic1.fetchAndStoreRelaxed(two) == one); QVERIFY(atomic2.fetchAndStoreRelaxed(three) == two); QVERIFY(atomic3.fetchAndStoreRelaxed(one) == three); - QVERIFY(atomic1.load() == two); - QVERIFY(atomic2.load() == three); - QVERIFY(atomic3.load() == one); + QVERIFY(atomic1.loadRelaxed() == two); + QVERIFY(atomic2.loadRelaxed() == three); + QVERIFY(atomic3.loadRelaxed() == one); } { QAtomicPointer<T> atomic1 = one; QAtomicPointer<T> atomic2 = two; QAtomicPointer<T> atomic3 = three; - QVERIFY(atomic1.load() == one); - QVERIFY(atomic2.load() == two); - QVERIFY(atomic3.load() == three); + QVERIFY(atomic1.loadRelaxed() == one); + QVERIFY(atomic2.loadRelaxed() == two); + QVERIFY(atomic3.loadRelaxed() == three); QVERIFY(atomic1.testAndSetRelaxed(one, two)); QVERIFY(atomic2.testAndSetRelaxed(two, three)); QVERIFY(atomic3.testAndSetRelaxed(three, one)); - QVERIFY(atomic1.load() == two); - QVERIFY(atomic2.load() == three); - QVERIFY(atomic3.load() == one); + QVERIFY(atomic1.loadRelaxed() == two); + QVERIFY(atomic2.loadRelaxed() == three); + QVERIFY(atomic3.loadRelaxed() == one); } } diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index b8c82c2ea0..a42454124e 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -49,6 +49,24 @@ struct ResultStoreInt : QtPrivate::ResultStoreBase ~ResultStoreInt() { clear<int>(); } }; +class LambdaThread : public QThread +{ +public: + LambdaThread(std::function<void ()> fn) + :m_fn(fn) + { + + } + + void run() override + { + m_fn(); + } + +private: + std::function<void ()> m_fn; +}; + class tst_QFuture: public QObject { Q_OBJECT @@ -67,6 +85,7 @@ private slots: void resultsAsList(); void implicitConversions(); void iterators(); + void iteratorsThread(); void pause(); void throttling(); void voidConversions(); @@ -1144,6 +1163,54 @@ void tst_QFuture::iterators() } } } +void tst_QFuture::iteratorsThread() +{ + const int expectedResultCount = 10; + const int delay = 10; + QFutureInterface<int> futureInterface; + + // Create result producer thread. The results are + // produced with delays in order to make the consumer + // wait. + QSemaphore sem; + LambdaThread thread = {[=, &futureInterface, &sem](){ + for (int i = 1; i <= expectedResultCount; i += 2) { + int result = i; + futureInterface.reportResult(&result); + result = i + 1; + futureInterface.reportResult(&result); + } + + sem.acquire(2); + futureInterface.reportFinished(); + }}; + + futureInterface.reportStarted(); + QFuture<int> future = futureInterface.future(); + + // Iterate over results while the thread is producing them. + thread.start(); + int resultCount = 0; + int resultSum = 0; + for (int result : future) { + sem.release(); + ++resultCount; + resultSum += result; + } + thread.wait(); + + QCOMPARE(resultCount, expectedResultCount); + QCOMPARE(resultSum, expectedResultCount * (expectedResultCount + 1) / 2); + + // Reverse iterate + resultSum = 0; + QFutureIterator<int> it(future); + it.toBack(); + while (it.hasPrevious()) + resultSum += it.previous(); + + QCOMPARE(resultSum, expectedResultCount * (expectedResultCount + 1) / 2); +} class SignalSlotObject : public QObject { diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index b2ef516b4e..a322a1c11d 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include <QCoreApplication> #include <QDebug> +#include <QElapsedTimer> #include <QtTest/QtTest> #include <QtConcurrent> @@ -878,7 +879,7 @@ void tst_QFutureWatcher::incrementalFilterResults() void tst_QFutureWatcher::qfutureSynchronizer() { int taskCount = 1000; - QTime t; + QElapsedTimer t; t.start(); { diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 7fb9a861d7..37c5874c02 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -1132,7 +1132,7 @@ void tst_QMutex::stressTest() for (int i = 1; i < threadCount; ++i) QVERIFY(threads[i].wait(10000)); QCOMPARE(StressTestThread::errorCount, 0); - qDebug("locked %d times", int(StressTestThread::lockCount.load())); + qDebug("locked %d times", int(StressTestThread::lockCount.loadRelaxed())); } class TryLockRaceThread : public QThread @@ -1286,28 +1286,28 @@ public: quint64 i = 0; while (t.elapsed() < one_minute) { i++; - uint nb = (i * 9 + lockCount.load() * 13) % threadCount; + uint nb = (i * 9 + lockCount.loadRelaxed() * 13) % threadCount; QMutexLocker locker(&mutex[nb]); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); if (sentinel[nb].fetchAndAddRelaxed(5)) errorCount.ref(); if (!sentinel[nb].testAndSetRelaxed(5, 0)) errorCount.ref(); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); lockCount.ref(); - nb = (nb * 17 + i * 5 + lockCount.load() * 3) % threadCount; + nb = (nb * 17 + i * 5 + lockCount.loadRelaxed() * 3) % threadCount; if (mutex[nb].tryLock()) { - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); if (sentinel[nb].fetchAndAddRelaxed(16)) errorCount.ref(); if (!sentinel[nb].testAndSetRelaxed(16, 0)) errorCount.ref(); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); lockCount.ref(); mutex[nb].unlock(); } - nb = (nb * 15 + i * 47 + lockCount.load() * 31) % threadCount; + nb = (nb * 15 + i * 47 + lockCount.loadRelaxed() * 31) % threadCount; if (mutex[nb].tryLock(2)) { - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); if (sentinel[nb].fetchAndAddRelaxed(53)) errorCount.ref(); if (!sentinel[nb].testAndSetRelaxed(53, 0)) errorCount.ref(); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); lockCount.ref(); mutex[nb].unlock(); } @@ -1327,8 +1327,8 @@ void tst_QMutex::moreStress() QVERIFY(threads[0].wait(one_minute + 10000)); for (int i = 1; i < threadCount; ++i) QVERIFY(threads[i].wait(10000)); - qDebug("locked %d times", MoreStressTestThread::lockCount.load()); - QCOMPARE(MoreStressTestThread::errorCount.load(), 0); + qDebug("locked %d times", MoreStressTestThread::lockCount.loadRelaxed()); + QCOMPARE(MoreStressTestThread::errorCount.loadRelaxed(), 0); } diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index 8e97229752..47bae585a1 100644 --- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <qcoreapplication.h> #include <qreadwritelock.h> +#include <qelapsedtimer.h> #include <qmutex.h> #include <qthread.h> #include <qwaitcondition.h> @@ -237,7 +238,7 @@ void tst_QReadWriteLock::tryReadLock() testsTurn.release(); threadsTurn.acquire(); - QTime timer; + QElapsedTimer timer; timer.start(); QVERIFY(!readWriteLock.tryLockForRead(1000)); QVERIFY(timer.elapsed() >= 1000); @@ -457,7 +458,7 @@ public: void run() { testRwlock.lockForWrite(); - while(release.load()==false) { + while (release.loadRelaxed() == false) { RWTESTSLEEP } testRwlock.unlock(); @@ -477,7 +478,7 @@ public: void run() { testRwlock.lockForRead(); - while(release.load()==false) { + while (release.loadRelaxed() == false) { RWTESTSLEEP } testRwlock.unlock(); @@ -500,7 +501,7 @@ public: int holdTime; int waitTime; bool print; - QTime t; + QElapsedTimer t; inline ReadLockLoopThread(QReadWriteLock &l, int runTime, int holdTime=0, int waitTime=0, bool print=false) :testRwlock(l) ,runTime(runTime) @@ -536,7 +537,7 @@ public: int holdTime; int waitTime; bool print; - QTime t; + QElapsedTimer t; inline WriteLockLoopThread(QReadWriteLock &l, int runTime, int holdTime=0, int waitTime=0, bool print=false) :testRwlock(l) ,runTime(runTime) @@ -574,7 +575,7 @@ public: int runTime; int waitTime; int maxval; - QTime t; + QElapsedTimer t; inline WriteLockCountThread(QReadWriteLock &l, int runTime, int waitTime, int maxval) :testRwlock(l) ,runTime(runTime) @@ -615,7 +616,7 @@ public: QReadWriteLock &testRwlock; int runTime; int waitTime; - QTime t; + QElapsedTimer t; inline ReadLockCountThread(QReadWriteLock &l, int runTime, int waitTime) :testRwlock(l) ,runTime(runTime) @@ -676,7 +677,7 @@ void tst_QReadWriteLock::multipleReadersBlockRelease() { QReadWriteLock testLock; - release.store(false); + release.storeRelaxed(false); threadDone=false; ReadLockReleasableThread rlt1(testLock); ReadLockReleasableThread rlt2(testLock); @@ -686,7 +687,7 @@ void tst_QReadWriteLock::multipleReadersBlockRelease() WriteLockThread wlt(testLock); wlt.start(); sleep(1); - release.store(true); + release.storeRelaxed(true); wlt.wait(); rlt1.wait(); rlt2.wait(); @@ -873,7 +874,7 @@ void tst_QReadWriteLock::deleteOnUnlock() DeleteOnUnlockThread thread2(&lock, &startup, &waitMutex); - QTime t; + QElapsedTimer t; t.start(); while(t.elapsed() < 4000) { lock = new QReadWriteLock(); @@ -899,7 +900,7 @@ void tst_QReadWriteLock::uncontendedLocks() uint count=0; int millisecs=1000; { - QTime t; + QElapsedTimer t; t.start(); while(t.elapsed() <millisecs) { @@ -908,7 +909,7 @@ void tst_QReadWriteLock::uncontendedLocks() } { QReadWriteLock rwlock; - QTime t; + QElapsedTimer t; t.start(); while(t.elapsed() <millisecs) { @@ -919,7 +920,7 @@ void tst_QReadWriteLock::uncontendedLocks() } { QReadWriteLock rwlock; - QTime t; + QElapsedTimer t; t.start(); while(t.elapsed() <millisecs) { diff --git a/tests/auto/corelib/thread/qthread/BLACKLIST b/tests/auto/corelib/thread/qthread/BLACKLIST index d75249454f..ccf530362c 100644 --- a/tests/auto/corelib/thread/qthread/BLACKLIST +++ b/tests/auto/corelib/thread/qthread/BLACKLIST @@ -1,2 +1,4 @@ [wait3_slowDestructor] windows +[sleep] +windows ci diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index d73dcc1b6d..baec4a22a5 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -29,7 +29,7 @@ #include <QtTest/QtTest> #include <qcoreapplication.h> -#include <qdatetime.h> +#include <qelapsedtimer.h> #include <qmutex.h> #include <qthread.h> #include <qtimer.h> @@ -121,7 +121,7 @@ public: { } bool wasActivated() - { return activationCount.load() > 0; } + { return activationCount.loadRelaxed() > 0; } public slots: void slot(); @@ -244,8 +244,8 @@ public: QMutexLocker locker(&mutex); elapsed = 0; - QTime time; - time.start(); + QElapsedTimer timer; + timer.start(); switch (sleepType) { case Second: sleep(interval); @@ -257,7 +257,7 @@ public: usleep(interval); break; } - elapsed = time.elapsed(); + elapsed = timer.elapsed(); cond.wakeOne(); } @@ -601,8 +601,7 @@ void tst_QThread::msleep() thread.interval = 120; thread.start(); QVERIFY(thread.wait(five_minutes)); -#if defined (Q_OS_WIN) - // Since the resolution of QTime is so coarse... +#if defined (Q_OS_WIN) // May no longer be needed QVERIFY(thread.elapsed >= 100); #else QVERIFY(thread.elapsed >= 120); @@ -616,8 +615,7 @@ void tst_QThread::usleep() thread.interval = 120000; thread.start(); QVERIFY(thread.wait(five_minutes)); -#if defined (Q_OS_WIN) - // Since the resolution of QTime is so coarse... +#if defined (Q_OS_WIN) // May no longer be needed QVERIFY(thread.elapsed >= 100); #else QVERIFY(thread.elapsed >= 120); @@ -902,7 +900,7 @@ void tst_QThread::adoptMultipleThreads() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(recorder.activationCount.load(), numThreads); + QCOMPARE(recorder.activationCount.loadRelaxed(), numThreads); } void tst_QThread::adoptMultipleThreadsOverlap() @@ -939,7 +937,7 @@ void tst_QThread::adoptMultipleThreadsOverlap() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(recorder.activationCount.load(), numThreads); + QCOMPARE(recorder.activationCount.loadRelaxed(), numThreads); } // Disconnects on WinCE @@ -948,9 +946,9 @@ void tst_QThread::stressTest() if (EmulationDetector::isRunningArmOnX86()) QSKIP("Qemu uses too much memory for each thread. Test would run out of memory."); - QTime t; - t.start(); - while (t.elapsed() < one_minute) { + QElapsedTimer timer; + timer.start(); + while (timer.elapsed() < one_minute) { Current_Thread t; t.start(); t.wait(one_minute); @@ -1210,7 +1208,7 @@ class DummyEventDispatcher : public QAbstractEventDispatcher { public: DummyEventDispatcher() : QAbstractEventDispatcher() {} bool processEvents(QEventLoop::ProcessEventsFlags) { - visited.store(true); + visited.storeRelaxed(true); emit awake(); QCoreApplication::sendPostedEvents(); return false; @@ -1272,7 +1270,7 @@ void tst_QThread::customEventDispatcher() QMetaObject::invokeMethod(&obj, "visit", Qt::QueuedConnection); loop.exec(); // test that the ED has really been used - QVERIFY(ed->visited.load()); + QVERIFY(ed->visited.loadRelaxed()); QPointer<DummyEventDispatcher> weak_ed(ed); QVERIFY(!weak_ed.isNull()); @@ -1330,6 +1328,8 @@ void tst_QThread::quitLock() QCOMPARE(job->thread(), &thread); loop.exec(); QVERIFY(exitThreadCalled); + + delete job; } void tst_QThread::create() diff --git a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp index a9af182ed8..710288af9e 100644 --- a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp @@ -56,7 +56,7 @@ class SingletonObject: public QObject Q_OBJECT public: static int runCount; - SingletonObject() { val.store(42); ++runCount; } + SingletonObject() { val.storeRelaxed(42); ++runCount; } ~SingletonObject() { } QBasicAtomicInt val; @@ -112,7 +112,7 @@ void tst_QThreadOnce::sameThread() QCOMPARE(controlVariable, 1); static QSingleton<SingletonObject> s; - QTEST((int)s->val.load(), "expectedValue"); + QTEST((int)s->val.loadRelaxed(), "expectedValue"); s->val.ref(); QCOMPARE(SingletonObject::runCount, 1); @@ -134,7 +134,7 @@ void tst_QThreadOnce::multipleThreads() QCOMPARE(controlVariable, 0); // nothing must have set them yet SingletonObject::runCount = 0; - IncrementThread::runCount.store(0); + IncrementThread::runCount.storeRelaxed(0); // wait for all of them to be ready sem2.acquire(NumberOfThreads); @@ -145,7 +145,7 @@ void tst_QThreadOnce::multipleThreads() delete parent; QCOMPARE(controlVariable, 1); - QCOMPARE((int)IncrementThread::runCount.load(), NumberOfThreads); + QCOMPARE((int)IncrementThread::runCount.loadRelaxed(), NumberOfThreads); QCOMPARE(SingletonObject::runCount, 1); } diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 838431cd5a..112c36952c 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -27,7 +27,7 @@ ** ****************************************************************************/ #include <QtTest/QtTest> -#include <qdatetime.h> +#include <qelapsedtimer.h> #include <qthreadpool.h> #include <qstring.h> #include <qmutex.h> @@ -220,16 +220,16 @@ class TestTask : public QRunnable public: void run() { - ran.store(true); + ran.storeRelaxed(true); } }; void tst_QThreadPool::runTask() { QThreadPool manager; - ran.store(false); + ran.storeRelaxed(false); manager.start(new TestTask()); - QTRY_VERIFY(ran.load()); + QTRY_VERIFY(ran.loadRelaxed()); } /* @@ -237,9 +237,9 @@ void tst_QThreadPool::runTask() */ void tst_QThreadPool::singleton() { - ran.store(false); + ran.storeRelaxed(false); QThreadPool::globalInstance()->start(new TestTask()); - QTRY_VERIFY(ran.load()); + QTRY_VERIFY(ran.loadRelaxed()); } QAtomicInt *value = 0; @@ -344,7 +344,7 @@ void tst_QThreadPool::expiryTimeout() // run the task threadPool.start(&task); QVERIFY(task.semaphore.tryAcquire(1, 10000)); - QCOMPARE(task.runCount.load(), 1); + QCOMPARE(task.runCount.loadRelaxed(), 1); QVERIFY(!task.thread->wait(100)); // thread should expire QThread *firstThread = task.thread; @@ -353,7 +353,7 @@ void tst_QThreadPool::expiryTimeout() // run task again, thread should be restarted threadPool.start(&task); QVERIFY(task.semaphore.tryAcquire(1, 10000)); - QCOMPARE(task.runCount.load(), 2); + QCOMPARE(task.runCount.loadRelaxed(), 2); QVERIFY(!task.thread->wait(100)); // thread should expire again QVERIFY(task.thread->wait(10000)); @@ -382,7 +382,7 @@ void tst_QThreadPool::expiryTimeoutRace() // QTBUG-3786 QThread::msleep(50); // exactly the same as the expiry timeout } QVERIFY(task.semaphore.tryAcquire(numTasks, 10000)); - QCOMPARE(task.runCount.load(), numTasks); + QCOMPARE(task.runCount.loadRelaxed(), numTasks); QVERIFY(threadPool.waitForDone(2000)); } @@ -685,7 +685,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051 QCOMPARE(threadpool->activeThreadCount(), 2); task->waitForStarted.acquire(); task->waitBeforeDone.release(); - QTRY_COMPARE(task->count.load(), 1); + QTRY_COMPARE(task->count.loadRelaxed(), 1); QTRY_COMPARE(threadpool->activeThreadCount(), 1); // now the thread is waiting, but tryStart() will fail since activeThreadCount() >= maxThreadCount() @@ -698,7 +698,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051 QTRY_COMPARE(threadpool->activeThreadCount(), 2); task->waitForStarted.acquire(); task->waitBeforeDone.release(); - QTRY_COMPARE(task->count.load(), 2); + QTRY_COMPARE(task->count.loadRelaxed(), 2); QTRY_COMPARE(threadpool->activeThreadCount(), 1); threadpool->releaseThread(); @@ -721,14 +721,14 @@ class CountingRunnable : public QRunnable void tst_QThreadPool::start() { const int runs = 1000; - count.store(0); + count.storeRelaxed(0); { QThreadPool threadPool; for (int i = 0; i< runs; ++i) { threadPool.start(new CountingRunnable()); } } - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); } void tst_QThreadPool::tryStart() @@ -747,7 +747,7 @@ void tst_QThreadPool::tryStart() } }; - count.store(0); + count.storeRelaxed(0); WaitingTask task; QThreadPool threadPool; @@ -757,7 +757,7 @@ void tst_QThreadPool::tryStart() QVERIFY(!threadPool.tryStart(&task)); task.semaphore.release(threadPool.maxThreadCount()); threadPool.waitForDone(); - QCOMPARE(count.load(), threadPool.maxThreadCount()); + QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount()); } QMutex mutex; @@ -775,7 +775,7 @@ void tst_QThreadPool::tryStartPeakThreadCount() { QMutexLocker lock(&mutex); activeThreads.ref(); - peakActiveThreads.store(qMax(peakActiveThreads.load(), activeThreads.load())); + peakActiveThreads.storeRelaxed(qMax(peakActiveThreads.loadRelaxed(), activeThreads.loadRelaxed())); } QTest::qWait(100); @@ -793,13 +793,13 @@ void tst_QThreadPool::tryStartPeakThreadCount() if (threadPool.tryStart(&task) == false) QTest::qWait(10); } - QCOMPARE(peakActiveThreads.load(), QThread::idealThreadCount()); + QCOMPARE(peakActiveThreads.loadRelaxed(), QThread::idealThreadCount()); for (int i = 0; i < 20; ++i) { if (threadPool.tryStart(&task) == false) QTest::qWait(10); } - QCOMPARE(peakActiveThreads.load(), QThread::idealThreadCount()); + QCOMPARE(peakActiveThreads.loadRelaxed(), QThread::idealThreadCount()); } void tst_QThreadPool::tryStartCount() @@ -877,27 +877,27 @@ void tst_QThreadPool::priorityStart() sem.release(); QVERIFY(threadPool.waitForDone()); - QCOMPARE(firstStarted.load(), expected); + QCOMPARE(firstStarted.loadRelaxed(), expected); } void tst_QThreadPool::waitForDone() { - QTime total, pass; + QElapsedTimer total, pass; total.start(); QThreadPool threadPool; while (total.elapsed() < 10000) { int runs; - count.store(runs = 0); + count.storeRelaxed(runs = 0); pass.restart(); while (pass.elapsed() < 100) { threadPool.start(new CountingRunnable()); ++runs; } threadPool.waitForDone(); - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); - count.store(runs = 0); + count.storeRelaxed(runs = 0); pass.restart(); while (pass.elapsed() < 100) { threadPool.start(new CountingRunnable()); @@ -905,7 +905,7 @@ void tst_QThreadPool::waitForDone() runs += 2; } threadPool.waitForDone(); - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); } } @@ -953,14 +953,14 @@ void tst_QThreadPool::clear() QThreadPool threadPool; threadPool.setMaxThreadCount(10); int runs = 2 * threadPool.maxThreadCount(); - count.store(0); + count.storeRelaxed(0); for (int i = 0; i <= runs; i++) { threadPool.start(new BlockingRunnable(sem)); } threadPool.clear(); sem.release(threadPool.maxThreadCount()); threadPool.waitForDone(); - QCOMPARE(count.load(), threadPool.maxThreadCount()); + QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount()); } void tst_QThreadPool::cancel() @@ -1008,7 +1008,7 @@ void tst_QThreadPool::cancel() // and cause an early return: const QSemaphoreReleaser semReleaser(sem, runs); - count.store(0); + count.storeRelaxed(0); QAtomicInt dtorCounter = 0; QAtomicInt runCounter = 0; for (int i = 0; i < runs; i++) { @@ -1025,12 +1025,12 @@ void tst_QThreadPool::cancel() } runnables[0]->dummy = 0; //valgrind will catch this if cancel() is crazy enough to delete currently running jobs runnables[runs-1]->dummy = 0; - QCOMPARE(dtorCounter.load(), runs - threadPool.maxThreadCount() - 1); + QCOMPARE(dtorCounter.loadRelaxed(), runs - threadPool.maxThreadCount() - 1); sem.release(threadPool.maxThreadCount()); threadPool.waitForDone(); - QCOMPARE(runCounter.load(), threadPool.maxThreadCount()); - QCOMPARE(count.load(), threadPool.maxThreadCount()); - QCOMPARE(dtorCounter.load(), runs - 2); + QCOMPARE(runCounter.loadRelaxed(), threadPool.maxThreadCount()); + QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount()); + QCOMPARE(dtorCounter.loadRelaxed(), runs - 2); delete runnables[0]; //if the pool deletes them then we'll get double-free crash delete runnables[runs-1]; } @@ -1080,7 +1080,7 @@ void tst_QThreadPool::tryTake() // and cause an early return: const QSemaphoreReleaser semReleaser(sem, Runs); - count.store(0); + count.storeRelaxed(0); QAtomicInt dtorCounter = 0; QAtomicInt runCounter = 0; for (int i = 0; i < Runs; i++) { @@ -1102,23 +1102,23 @@ void tst_QThreadPool::tryTake() } runnables[0]->dummy = 0; // valgrind will catch this if tryTake() is crazy enough to delete currently running jobs - QCOMPARE(dtorCounter.load(), int(Runs - MaxThreadCount)); + QCOMPARE(dtorCounter.loadRelaxed(), int(Runs - MaxThreadCount)); sem.release(MaxThreadCount); threadPool.waitForDone(); - QCOMPARE(runCounter.load(), int(MaxThreadCount)); - QCOMPARE(count.load(), int(MaxThreadCount)); - QCOMPARE(dtorCounter.load(), int(Runs - 1)); + QCOMPARE(runCounter.loadRelaxed(), int(MaxThreadCount)); + QCOMPARE(count.loadRelaxed(), int(MaxThreadCount)); + QCOMPARE(dtorCounter.loadRelaxed(), int(Runs - 1)); delete runnables[0]; // if the pool deletes them then we'll get double-free crash } void tst_QThreadPool::destroyingWaitsForTasksToFinish() { - QTime total, pass; + QElapsedTimer total, pass; total.start(); while (total.elapsed() < 10000) { int runs; - count.store(runs = 0); + count.storeRelaxed(runs = 0); { QThreadPool threadPool; pass.restart(); @@ -1127,9 +1127,9 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish() ++runs; } } - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); - count.store(runs = 0); + count.storeRelaxed(runs = 0); { QThreadPool threadPool; pass.restart(); @@ -1139,7 +1139,7 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish() runs += 2; } } - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); } } @@ -1204,7 +1204,7 @@ void tst_QThreadPool::stressTest() } }; - QTime total; + QElapsedTimer total; total.start(); while (total.elapsed() < 30000) { Task t; @@ -1322,6 +1322,7 @@ void tst_QThreadPool::waitForDoneAfterTake() QRunnable *runnable = createTask(emptyFunct); manager.start(runnable); QVERIFY(manager.tryTake(runnable)); + delete runnable; } // Add another runnable that will not be removed diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index ef5d3452d5..3538d90803 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -359,7 +359,7 @@ void tst_QThreadStorage::leakInDestructor() QVERIFY(tls.hasLocalData()); } }; - int c = SPointer::count.load(); + int c = SPointer::count.loadRelaxed(); QThreadStorage<ThreadStorageLocalDataTester *> tls; @@ -383,7 +383,7 @@ void tst_QThreadStorage::leakInDestructor() QVERIFY(t3.wait()); //check all the constructed things have been destructed - QCOMPARE(int(SPointer::count.load()), c); + QCOMPARE(int(SPointer::count.loadRelaxed()), c); } class ThreadStorageResetLocalDataTester { @@ -411,7 +411,7 @@ void tst_QThreadStorage::resetInDestructor() QVERIFY(ThreadStorageResetLocalDataTesterTls()->hasLocalData()); } }; - int c = SPointer::count.load(); + int c = SPointer::count.loadRelaxed(); Thread t1; Thread t2; @@ -424,7 +424,7 @@ void tst_QThreadStorage::resetInDestructor() QVERIFY(t3.wait()); //check all the constructed things have been destructed - QCOMPARE(int(SPointer::count.load()), c); + QCOMPARE(int(SPointer::count.loadRelaxed()), c); } @@ -475,7 +475,7 @@ void tst_QThreadStorage::valueBased() QThreadStorage<QString> tlsString; QThreadStorage<int> tlsInt; - int c = SPointer::count.load(); + int c = SPointer::count.loadRelaxed(); Thread t1(tlsSPointer, tlsString, tlsInt); Thread t2(tlsSPointer, tlsString, tlsInt); @@ -495,7 +495,7 @@ void tst_QThreadStorage::valueBased() QVERIFY(t2.wait()); QVERIFY(t3.wait()); - QCOMPARE(c, int(SPointer::count.load())); + QCOMPARE(c, int(SPointer::count.loadRelaxed())); } diff --git a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp index 126cb6b180..5363231895 100644 --- a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp @@ -481,7 +481,7 @@ void tst_QWaitCondition::wakeOne() } mutex.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; ++x) { @@ -502,10 +502,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 1); - QCOMPARE(count.load(), ThreadCount - (x + 1)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 1)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); // QReadWriteLock QReadWriteLock readWriteLock; @@ -530,7 +530,7 @@ void tst_QWaitCondition::wakeOne() } readWriteLock.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; ++x) { @@ -551,10 +551,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 1); - QCOMPARE(count.load(), ThreadCount - (x + 1)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 1)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } // wake up threads, two at a time @@ -585,7 +585,7 @@ void tst_QWaitCondition::wakeOne() } mutex.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; x += 2) { @@ -608,10 +608,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 2); - QCOMPARE(count.load(), ThreadCount - (x + 2)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 2)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); // QReadWriteLock QReadWriteLock readWriteLock; @@ -636,7 +636,7 @@ void tst_QWaitCondition::wakeOne() } readWriteLock.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; x += 2) { @@ -659,10 +659,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 2); - QCOMPARE(count.load(), ThreadCount - (x + 2)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 2)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } } @@ -692,7 +692,7 @@ void tst_QWaitCondition::wakeAll() } mutex.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up all threads at once mutex.lock(); @@ -707,7 +707,7 @@ void tst_QWaitCondition::wakeAll() } QCOMPARE(exited, ThreadCount); - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); // QReadWriteLock QReadWriteLock readWriteLock; @@ -728,7 +728,7 @@ void tst_QWaitCondition::wakeAll() } readWriteLock.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up all threads at once readWriteLock.lockForWrite(); @@ -743,7 +743,7 @@ void tst_QWaitCondition::wakeAll() } QCOMPARE(exited, ThreadCount); - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } } diff --git a/tests/auto/corelib/tools/qdate/.gitignore b/tests/auto/corelib/time/qdate/.gitignore index 70945d4a86..70945d4a86 100644 --- a/tests/auto/corelib/tools/qdate/.gitignore +++ b/tests/auto/corelib/time/qdate/.gitignore diff --git a/tests/auto/corelib/tools/qdate/qdate.pro b/tests/auto/corelib/time/qdate/qdate.pro index dd7c6cb888..925c3b4c78 100644 --- a/tests/auto/corelib/tools/qdate/qdate.pro +++ b/tests/auto/corelib/time/qdate/qdate.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qdate -QT = core testlib +QT = core-private testlib SOURCES = tst_qdate.cpp diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index ce1e5730dd..0ef494b229 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -27,6 +27,7 @@ ** ****************************************************************************/ +#include <private/qglobal_p.h> // for the icu feature test #include <QtTest/QtTest> #include <qdatetime.h> #include <qlocale.h> @@ -54,6 +55,13 @@ private slots: void weekNumber_invalid(); void weekNumber_data(); void weekNumber(); +#if QT_CONFIG(timezone) + void startOfDay_endOfDay_data(); + void startOfDay_endOfDay(); +#endif + void startOfDay_endOfDay_fixed_data(); + void startOfDay_endOfDay_fixed(); + void startOfDay_endOfDay_bounds(); void julianDaysLimits(); void addDays_data(); void addDays(); @@ -83,6 +91,7 @@ private slots: void negativeYear() const; void printNegativeYear() const; void roundtripGermanLocale() const; +#if QT_CONFIG(textdate) void shortDayName() const; void standaloneShortDayName() const; void longDayName() const; @@ -91,6 +100,7 @@ private slots: void standaloneShortMonthName() const; void longMonthName() const; void standaloneLongMonthName() const; +#endif // textdate void roundtrip() const; void qdebug() const; private: @@ -456,6 +466,164 @@ void tst_QDate::weekNumber_invalid() QCOMPARE( dt.weekNumber( &yearNumber ), 0 ); } +#if QT_CONFIG(timezone) +void tst_QDate::startOfDay_endOfDay_data() +{ + QTest::addColumn<QDate>("date"); // Typically a spring-forward. + // A zone in which that date's start and end are worth checking: + QTest::addColumn<QByteArray>("zoneName"); + // The start and end times in that zone: + QTest::addColumn<QTime>("start"); + QTest::addColumn<QTime>("end"); + + const QTime initial(0, 0), final(23, 59, 59, 999), invalid(QDateTime().time()); + + QTest::newRow("epoch") + << QDate(1970, 1, 1) << QByteArray("UTC") + << initial << final; + QTest::newRow("Brazil") + << QDate(2008, 10, 19) << QByteArray("America/Sao_Paulo") + << QTime(1, 0) << final; +#if QT_CONFIG(icu) || !defined(Q_OS_WIN) // MS's TZ APIs lack data + QTest::newRow("Sofia") + << QDate(1994, 3, 27) << QByteArray("Europe/Sofia") + << QTime(1, 0) << final; +#endif + QTest::newRow("Kiritimati") + << QDate(1994, 12, 31) << QByteArray("Pacific/Kiritimati") + << invalid << invalid; + QTest::newRow("Samoa") + << QDate(2011, 12, 30) << QByteArray("Pacific/Apia") + << invalid << invalid; + // TODO: find other zones with transitions at/crossing midnight. +} + +void tst_QDate::startOfDay_endOfDay() +{ + QFETCH(QDate, date); + QFETCH(QByteArray, zoneName); + QFETCH(QTime, start); + QFETCH(QTime, end); + const QTimeZone zone(zoneName); + const bool isSystem = QTimeZone::systemTimeZone() == zone; + QDateTime front(date.startOfDay(zone)), back(date.endOfDay(zone)); + if (end.isValid()) + QCOMPARE(date.addDays(1).startOfDay(zone).addMSecs(-1), back); + if (start.isValid()) + QCOMPARE(date.addDays(-1).endOfDay(zone).addMSecs(1), front); + do { // Avoids duplicating these tests for local-time when it *is* zone: + if (start.isValid()) { + QCOMPARE(front.date(), date); + QCOMPARE(front.time(), start); + } + if (end.isValid()) { + QCOMPARE(back.date(), date); + QCOMPARE(back.time(), end); + } + if (front.timeSpec() == Qt::LocalTime) + break; + front = date.startOfDay(Qt::LocalTime); + back = date.endOfDay(Qt::LocalTime); + } while (isSystem); + if (end.isValid()) + QCOMPARE(date.addDays(1).startOfDay(Qt::LocalTime).addMSecs(-1), back); + if (start.isValid()) + QCOMPARE(date.addDays(-1).endOfDay(Qt::LocalTime).addMSecs(1), front); + if (!isSystem) { + // These might fail if system zone coincides with zone; but only if it + // did something similarly unusual on the date picked for this test. + if (start.isValid()) { + QCOMPARE(front.date(), date); + QCOMPARE(front.time(), QTime(0, 0)); + } + if (end.isValid()) { + QCOMPARE(back.date(), date); + QCOMPARE(back.time(), QTime(23, 59, 59, 999)); + } + } +} +#endif // timezone + +void tst_QDate::startOfDay_endOfDay_fixed_data() +{ + const qint64 kilo(1000); + using Bounds = std::numeric_limits<qint64>; + const QDateTime + first(QDateTime::fromMSecsSinceEpoch(Bounds::min() + 1, Qt::UTC)), + start32sign(QDateTime::fromMSecsSinceEpoch(-0x80000000L * kilo, Qt::UTC)), + end32sign(QDateTime::fromMSecsSinceEpoch(0x80000000L * kilo, Qt::UTC)), + end32unsign(QDateTime::fromMSecsSinceEpoch(0x100000000L * kilo, Qt::UTC)), + last(QDateTime::fromMSecsSinceEpoch(Bounds::max(), Qt::UTC)); + + const struct { + const char *name; + QDate date; + } data[] = { + { "epoch", QDate(1970, 1, 1) }, + { "y2k-leap-day", QDate(2000, 2, 29) }, + // Just outside the start and end of 32-bit time_t: + { "pre-sign32", QDate(start32sign.date().year(), 1, 1) }, + { "post-sign32", QDate(end32sign.date().year(), 12, 31) }, + { "post-uint32", QDate(end32unsign.date().year(), 12, 31) }, + // Just inside the start and end of QDateTime's range: + { "first-full", first.date().addDays(1) }, + { "last-full", last.date().addDays(-1) } + }; + + QTest::addColumn<QDate>("date"); + for (const auto &r : data) + QTest::newRow(r.name) << r.date; +} + +void tst_QDate::startOfDay_endOfDay_fixed() +{ + const QTime early(0, 0), late(23, 59, 59, 999); + QFETCH(QDate, date); + + QDateTime start(date.startOfDay(Qt::UTC)); + QDateTime end(date.endOfDay(Qt::UTC)); + QCOMPARE(start.date(), date); + QCOMPARE(end.date(), date); + QCOMPARE(start.time(), early); + QCOMPARE(end.time(), late); + QCOMPARE(date.addDays(1).startOfDay(Qt::UTC).addMSecs(-1), end); + QCOMPARE(date.addDays(-1).endOfDay(Qt::UTC).addMSecs(1), start); + for (int offset = -60 * 16; offset <= 60 * 16; offset += 65) { + start = date.startOfDay(Qt::OffsetFromUTC, offset); + end = date.endOfDay(Qt::OffsetFromUTC, offset); + QCOMPARE(start.date(), date); + QCOMPARE(end.date(), date); + QCOMPARE(start.time(), early); + QCOMPARE(end.time(), late); + QCOMPARE(date.addDays(1).startOfDay(Qt::OffsetFromUTC, offset).addMSecs(-1), end); + QCOMPARE(date.addDays(-1).endOfDay(Qt::OffsetFromUTC, offset).addMSecs(1), start); + } +} + +void tst_QDate::startOfDay_endOfDay_bounds() +{ + // Check the days in which QDateTime's range starts and ends: + using Bounds = std::numeric_limits<qint64>; + const QDateTime + first(QDateTime::fromMSecsSinceEpoch(Bounds::min(), Qt::UTC)), + last(QDateTime::fromMSecsSinceEpoch(Bounds::max(), Qt::UTC)), + epoch(QDateTime::fromMSecsSinceEpoch(0, Qt::UTC)); + // First, check these *are* the start and end of QDateTime's range: + QVERIFY(first.isValid()); + QVERIFY(last.isValid()); + QVERIFY(first < epoch); + QVERIFY(last > epoch); + // QDateTime's addMSecs doesn't check against {und,ov}erflow ... + QVERIFY(!first.addMSecs(-1).isValid() || first.addMSecs(-1) > first); + QVERIFY(!last.addMSecs(1).isValid() || last.addMSecs(1) < last); + + // Now test start/end methods with them: + QCOMPARE(first.date().endOfDay(Qt::UTC).time(), QTime(23, 59, 59, 999)); + QCOMPARE(last.date().startOfDay(Qt::UTC).time(), QTime(0, 0)); + QVERIFY(!first.date().startOfDay(Qt::UTC).isValid()); + QVERIFY(!last.date().endOfDay(Qt::UTC).isValid()); +} + void tst_QDate::julianDaysLimits() { qint64 min = std::numeric_limits<qint64>::min(); @@ -1038,18 +1206,18 @@ void tst_QDate::fromStringFormat_data() // Undo this (inline the C-locale versions) for ### Qt 6 // Get localized names: - QString january = QDate::longMonthName(1); - QString february = QDate::longMonthName(2); - QString march = QDate::longMonthName(3); - QString august = QDate::longMonthName(8); - QString mon = QDate::shortDayName(1); - QString monday = QDate::longDayName(1); - QString tuesday = QDate::longDayName(2); - QString wednesday = QDate::longDayName(3); - QString thursday = QDate::longDayName(4); - QString friday = QDate::longDayName(5); - QString saturday = QDate::longDayName(6); - QString sunday = QDate::longDayName(7); + QString january = QLocale::system().monthName(1, QLocale::LongFormat); + QString february = QLocale::system().monthName(2, QLocale::LongFormat); + QString march = QLocale::system().monthName(3, QLocale::LongFormat); + QString august = QLocale::system().monthName(8, QLocale::LongFormat); + QString mon = QLocale::system().dayName(1, QLocale::ShortFormat); + QString monday = QLocale::system().dayName(1, QLocale::LongFormat); + QString tuesday = QLocale::system().dayName(2, QLocale::LongFormat); + QString wednesday = QLocale::system().dayName(3, QLocale::LongFormat); + QString thursday = QLocale::system().dayName(4, QLocale::LongFormat); + QString friday = QLocale::system().dayName(5, QLocale::LongFormat); + QString saturday = QLocale::system().dayName(6, QLocale::LongFormat); + QString sunday = QLocale::system().dayName(7, QLocale::LongFormat); QTest::newRow("data0") << QString("") << QString("") << defDate(); QTest::newRow("data1") << QString(" ") << QString("") << invalidDate(); @@ -1305,6 +1473,10 @@ void tst_QDate::roundtripGermanLocale() const theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate); } +#if QT_CONFIG(textdate) +QT_WARNING_PUSH // the methods tested here are all deprecated +QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") + void tst_QDate::shortDayName() const { QCOMPARE(QDate::shortDayName(0), QString()); @@ -1432,6 +1604,8 @@ void tst_QDate::standaloneLongMonthName() const QCOMPARE(QDate::longMonthName(i, QDate::StandaloneFormat), locale.standaloneMonthName(i, QLocale::LongFormat)); } } +QT_WARNING_POP +#endif // textdate void tst_QDate::roundtrip() const { diff --git a/tests/auto/corelib/tools/qdatetime/.gitignore b/tests/auto/corelib/time/qdatetime/.gitignore index 7784f3a3eb..7784f3a3eb 100644 --- a/tests/auto/corelib/tools/qdatetime/.gitignore +++ b/tests/auto/corelib/time/qdatetime/.gitignore diff --git a/tests/auto/corelib/tools/qdatetime/BLACKLIST b/tests/auto/corelib/time/qdatetime/BLACKLIST index 3a42ee066b..3a42ee066b 100644 --- a/tests/auto/corelib/tools/qdatetime/BLACKLIST +++ b/tests/auto/corelib/time/qdatetime/BLACKLIST diff --git a/tests/auto/corelib/tools/qdatetime/qdatetime.pro b/tests/auto/corelib/time/qdatetime/qdatetime.pro index 742eb47075..742eb47075 100644 --- a/tests/auto/corelib/tools/qdatetime/qdatetime.pro +++ b/tests/auto/corelib/time/qdatetime/qdatetime.pro diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index ce7cacf966..c5377379ea 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -1005,7 +1005,6 @@ void tst_QDateTime::toString_enumformat() { QDateTime dt1(QDate(1995, 5, 20), QTime(12, 34, 56)); - QString str1 = dt1.toString(Qt::TextDate); QVERIFY(!str1.isEmpty()); // It's locale dependent everywhere @@ -2779,9 +2778,9 @@ void tst_QDateTime::getDate() int y = -33, m = -44, d = -55; QDate date; date.getDate(&y, &m, &d); - QVERIFY(date.year() == y); - QVERIFY(date.month() == m); - QVERIFY(date.day() == d); + QCOMPARE(date.year(), y); + QCOMPARE(date.month(), m); + QCOMPARE(date.day(), d); date.getDate(0, 0, 0); } @@ -2793,9 +2792,9 @@ void tst_QDateTime::getDate() date.getDate(&y, 0, 0); date.getDate(0, 0, &d); - QVERIFY(date.year() == y); - QVERIFY(date.month() == m); - QVERIFY(date.day() == d); + QCOMPARE(date.year(), y); + QCOMPARE(date.month(), m); + QCOMPARE(date.day(), d); } } diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm b/tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm index f73c7b9d5d..f73c7b9d5d 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm diff --git a/tests/auto/corelib/tools/qtime/.gitignore b/tests/auto/corelib/time/qtime/.gitignore index 26a4c65cc2..26a4c65cc2 100644 --- a/tests/auto/corelib/tools/qtime/.gitignore +++ b/tests/auto/corelib/time/qtime/.gitignore diff --git a/tests/auto/corelib/tools/qtime/qtime.pro b/tests/auto/corelib/time/qtime/qtime.pro index 0973b7a9ef..0973b7a9ef 100644 --- a/tests/auto/corelib/tools/qtime/qtime.pro +++ b/tests/auto/corelib/time/qtime/qtime.pro diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp index 3e5724213e..3403c5bf7f 100644 --- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/time/qtime/tst_qtime.cpp @@ -95,8 +95,9 @@ void tst_QTime::addSecs_data() QTest::newRow("Data0") << QTime(0,0,0) << 200 << QTime(0,3,20); QTest::newRow("Data1") << QTime(0,0,0) << 20 << QTime(0,0,20); - QTest::newRow("overflow") << QTime(0,0,0) << (INT_MAX / 1000 + 1) - << QTime(0,0,0).addSecs((INT_MAX / 1000 + 1) % 86400); + QTest::newRow("overflow") + << QTime(0,0,0) << (INT_MAX / 1000 + 1) + << QTime::fromMSecsSinceStartOfDay(((INT_MAX / 1000 + 1) % 86400) * 1000); } void tst_QTime::addSecs() diff --git a/tests/auto/corelib/tools/qtimezone/BLACKLIST b/tests/auto/corelib/time/qtimezone/BLACKLIST index 840c3b1181..840c3b1181 100644 --- a/tests/auto/corelib/tools/qtimezone/BLACKLIST +++ b/tests/auto/corelib/time/qtimezone/BLACKLIST diff --git a/tests/auto/corelib/tools/qtimezone/qtimezone.pro b/tests/auto/corelib/time/qtimezone/qtimezone.pro index 5ec8d008e7..5ec8d008e7 100644 --- a/tests/auto/corelib/tools/qtimezone/qtimezone.pro +++ b/tests/auto/corelib/time/qtimezone/qtimezone.pro diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index bb6c48a2ed..9904719f7c 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp @@ -480,11 +480,10 @@ void tst_QTimeZone::transitionEachZone_data() { 1288488600, -4, 8, 2010 } // 2010-10-31 01:30 UTC; Europe, Russia }; - QString name; const auto zones = QTimeZone::availableTimeZoneIds(); for (int k = sizeof(table) / sizeof(table[0]); k-- > 0; ) { for (const QByteArray &zone : zones) { - name.sprintf("%s@%d", zone.constData(), table[k].year); + const QString name = QString::asprintf("%s@%d", zone.constData(), table[k].year); QTest::newRow(name.toUtf8().constData()) << zone << table[k].baseSecs @@ -916,6 +915,14 @@ void tst_QTimeZone::tzTest() QTzTimeZonePrivate tzp("Europe/Berlin"); QVERIFY(tzp.isValid()); + // Test POSIX-format value for $TZ: + QTzTimeZonePrivate tzposix("MET-1METDST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"); + QVERIFY(tzposix.isValid()); + + QTimeZone tzBrazil("BRT+3"); // parts of Northern Brazil, as a POSIX rule + QVERIFY(tzBrazil.isValid()); + QCOMPARE(tzBrazil.offsetFromUtc(QDateTime(QDate(1111, 11, 11).startOfDay())), -10800); + // Test display names by type, either ICU or abbreviation only QLocale enUS("en_US"); // Only test names in debug mode, names used can vary by ICU version installed diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm b/tests/auto/corelib/time/qtimezone/tst_qtimezone_darwin.mm index de801e55d0..de801e55d0 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone_darwin.mm diff --git a/tests/auto/corelib/time/time.pro b/tests/auto/corelib/time/time.pro new file mode 100644 index 0000000000..6f9ff038db --- /dev/null +++ b/tests/auto/corelib/time/time.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qdate \ + qdatetime \ + qtime \ + qtimezone diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index b40b1f0624..b911be3ffb 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -76,7 +76,7 @@ void foo() #include "qlist.h" #include "qmap.h" #include "qpair.h" -#include "qregexp.h" +#include "qregularexpression.h" #include "qset.h" #include "qstack.h" #include "qstring.h" @@ -105,7 +105,9 @@ private slots: void map(); void bitArray(); void cache(); +#if QT_CONFIG(regularexpression) void regexp(); +#endif void pair(); void sharableQList(); void sharableQLinkedList(); @@ -580,73 +582,73 @@ void tst_Collections::list() list1 << 0 << 1 << 2 << 3; list1.removeFirst(); - list1.swap(0, 0); + list1.swapItemsAt(0, 0); QVERIFY(list1 == QList<int>() << 1 << 2 << 3); - list1.swap(1, 1); + list1.swapItemsAt(1, 1); QVERIFY(list1 == QList<int>() << 1 << 2 << 3); - list1.swap(2, 2); + list1.swapItemsAt(2, 2); QVERIFY(list1 == QList<int>() << 1 << 2 << 3); - list1.swap(0, 1); + list1.swapItemsAt(0, 1); QVERIFY(list1 == QList<int>() << 2 << 1 << 3); - list1.swap(0, 2); + list1.swapItemsAt(0, 2); QVERIFY(list1 == QList<int>() << 3 << 1 << 2); - list1.swap(1, 2); + list1.swapItemsAt(1, 2); QVERIFY(list1 == QList<int>() << 3 << 2 << 1); - list1.swap(1, 2); + list1.swapItemsAt(1, 2); QVERIFY(list1 == QList<int>() << 3 << 1 << 2); QList<QString> list2; list2 << "1" << "2" << "3"; - list2.swap(0, 0); + list2.swapItemsAt(0, 0); QVERIFY(list2 == QList<QString>() << "1" << "2" << "3"); - list2.swap(1, 1); + list2.swapItemsAt(1, 1); QVERIFY(list2 == QList<QString>() << "1" << "2" << "3"); - list2.swap(2, 2); + list2.swapItemsAt(2, 2); QVERIFY(list2 == QList<QString>() << "1" << "2" << "3"); - list2.swap(0, 1); + list2.swapItemsAt(0, 1); QVERIFY(list2 == QList<QString>() << "2" << "1" << "3"); - list2.swap(0, 2); + list2.swapItemsAt(0, 2); QVERIFY(list2 == QList<QString>() << "3" << "1" << "2"); - list2.swap(1, 2); + list2.swapItemsAt(1, 2); QVERIFY(list2 == QList<QString>() << "3" << "2" << "1"); - list2.swap(1, 2); + list2.swapItemsAt(1, 2); QVERIFY(list2 == QList<QString>() << "3" << "1" << "2"); QList<double> list3; list3 << 1.0 << 2.0 << 3.0; - list3.swap(0, 0); + list3.swapItemsAt(0, 0); QVERIFY(list3 == QList<double>() << 1.0 << 2.0 << 3.0); - list3.swap(1, 1); + list3.swapItemsAt(1, 1); QVERIFY(list3 == QList<double>() << 1.0 << 2.0 << 3.0); - list3.swap(2, 2); + list3.swapItemsAt(2, 2); QVERIFY(list3 == QList<double>() << 1.0 << 2.0 << 3.0); - list3.swap(0, 1); + list3.swapItemsAt(0, 1); QVERIFY(list3 == QList<double>() << 2.0 << 1.0 << 3.0); - list3.swap(0, 2); + list3.swapItemsAt(0, 2); QVERIFY(list3 == QList<double>() << 3.0 << 1.0 << 2.0); - list3.swap(1, 2); + list3.swapItemsAt(1, 2); QVERIFY(list3 == QList<double>() << 3.0 << 2.0 << 1.0); - list3.swap(1, 2); + list3.swapItemsAt(1, 2); QVERIFY(list3 == QList<double>() << 3.0 << 1.0 << 2.0); } @@ -2285,13 +2287,15 @@ void tst_Collections::cache() } +#if QT_CONFIG(regularexpression) void tst_Collections::regexp() { - QRegExp rx("^\\d\\d?$"); - QVERIFY(rx.indexIn("123") == -1); - QVERIFY(rx.indexIn("-6") == -1); - QVERIFY(rx.indexIn("6") == 0) ; + QRegularExpression rx("^\\d\\d?$"); + QVERIFY(!rx.match("123").hasMatch()); + QVERIFY(!rx.match("-6").hasMatch()); + QVERIFY(rx.match("6").hasMatch()) ; } +#endif void tst_Collections::pair() { @@ -2425,7 +2429,7 @@ void testContainer() c1 = newInstance<Container>(); QVERIFY(c1.size() == 4); QVERIFY(c1 == newInstance<Container>()); - Container c2 = qMove(c1); + Container c2 = std::move(c1); QVERIFY(c2.size() == 4); QVERIFY(c2 == newInstance<Container>()); } @@ -2531,14 +2535,18 @@ void tst_Collections::conversions() QCOMPARE(list2.size(), 4); QVERIFY(list2 == (QList<QString>() << STUFF)); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QSet<QString> set1 = list1.toSet(); +#else + QSet<QString> set1(list1.begin(), list1.end()); +#endif QCOMPARE(set1.size(), 3); QVERIFY(set1.contains("A")); QVERIFY(set1.contains("B")); QVERIFY(set1.contains("C")); QVERIFY(!set1.contains("D")); - QList<QString> list3 = set1.toList(); + QList<QString> list3 = set1.values(); QCOMPARE(list3.size(), 3); QVERIFY(list3.contains("A")); QVERIFY(list3.contains("B")); @@ -2546,9 +2554,11 @@ void tst_Collections::conversions() QVERIFY(!list3.contains("D")); QVERIFY(QList<int>().toVector().isEmpty()); - QVERIFY(QList<int>().toSet().isEmpty()); QVERIFY(QVector<int>().toList().isEmpty()); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QVERIFY(QList<int>().toSet().isEmpty()); QVERIFY(QSet<int>().toList().isEmpty()); +#endif } { @@ -2563,14 +2573,22 @@ void tst_Collections::conversions() QCOMPARE(list2.size(), 4); QVERIFY(list2 == (QList<QString>() << STUFF)); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QSet<QString> set1 = QSet<QString>::fromList(list1); +#else + QSet<QString> set1(list1.begin(), list1.end()); +#endif QCOMPARE(set1.size(), 3); QVERIFY(set1.contains("A")); QVERIFY(set1.contains("B")); QVERIFY(set1.contains("C")); QVERIFY(!set1.contains("D")); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QList<QString> list3 = QList<QString>::fromSet(set1); +#else + QList<QString> list3 = set1.values(); +#endif QCOMPARE(list3.size(), 3); QVERIFY(list3.contains("A")); QVERIFY(list3.contains("B")); @@ -2578,9 +2596,11 @@ void tst_Collections::conversions() QVERIFY(!list3.contains("D")); QVERIFY(QVector<int>::fromList(QList<int>()).isEmpty()); - QVERIFY(QSet<int>::fromList(QList<int>()).isEmpty()); QVERIFY(QList<int>::fromVector(QVector<int>()).isEmpty()); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QVERIFY(QSet<int>::fromList(QList<int>()).isEmpty()); QVERIFY(QList<int>::fromSet(QSet<int>()).isEmpty()); +#endif } #undef STUFF } @@ -2776,15 +2796,21 @@ void tst_Collections::vector_stl() for (int i = 0; i < elements.count(); ++i) vector << elements.at(i); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) std::vector<QString> stdVector = vector.toStdVector(); - +#else + std::vector<QString> stdVector(vector.begin(), vector.end()); +#endif QCOMPARE(int(stdVector.size()), elements.size()); std::vector<QString>::const_iterator it = stdVector.begin(); for (uint j = 0; j < stdVector.size() && it != stdVector.end(); ++j, ++it) QCOMPARE(*it, vector[j]); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QCOMPARE(QVector<QString>::fromStdVector(stdVector), vector); +#endif + QCOMPARE(QVector<QString>(stdVector.begin(), stdVector.end()), vector); } void tst_Collections::linkedlist_stl_data() @@ -2830,7 +2856,11 @@ void tst_Collections::list_stl() for (int i = 0; i < elements.count(); ++i) list << elements.at(i); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) std::list<QString> stdList = list.toStdList(); +#else + std::list<QString> stdList(list.begin(), list.end()); +#endif QCOMPARE(int(stdList.size()), elements.size()); @@ -2838,7 +2868,10 @@ void tst_Collections::list_stl() for (uint j = 0; j < stdList.size() && it != stdList.end(); ++j, ++it) QCOMPARE(*it, list[j]); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QCOMPARE(QList<QString>::fromStdList(stdList), list); +#endif + QCOMPARE(QList<QString>(stdList.begin(), stdList.end()), list); } template <typename T> diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp index 3b8111f1a3..4b085d387d 100644 --- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp +++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp @@ -34,13 +34,446 @@ #include "qstring.h" #include "qvarlengtharray.h" #include "qvector.h" +#include "qhash.h" +#include "qdebug.h" +#include <algorithm> +#include <functional> #include <vector> // for reference +#include <list> +#include <set> +#include <map> + +// MSVC has these containers from the Standard Library, but it lacks +// a __has_include mechanism (that we need to use for other stdlibs). +// For the sake of increasing our test coverage, work around the issue. + +#ifdef Q_CC_MSVC +#define COMPILER_HAS_STDLIB_INCLUDE(x) 1 +#else +#define COMPILER_HAS_STDLIB_INCLUDE(x) QT_HAS_INCLUDE(x) +#endif + +#if COMPILER_HAS_STDLIB_INCLUDE(<forward_list>) +#include <forward_list> +#endif +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) +#include <unordered_set> +#endif +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_map>) +#include <unordered_map> +#endif + +struct Movable +{ + explicit Movable(int i = 0) Q_DECL_NOTHROW + : i(i) + { + ++instanceCount; + } + + Movable(const Movable &m) + : i(m.i) + { + ++instanceCount; + } + + ~Movable() + { + --instanceCount; + } + + int i; + static int instanceCount; +}; + +int Movable::instanceCount = 0; +bool operator==(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i == rhs.i; } +bool operator!=(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i != rhs.i; } +bool operator<(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i < rhs.i; } + +uint qHash(Movable m, uint seed = 0) Q_DECL_NOTHROW { return qHash(m.i, seed); } +QDebug &operator<<(QDebug &d, Movable m) +{ + const QDebugStateSaver saver(d); + return d.nospace() << "Movable(" << m.i << ")"; +} + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(Movable, Q_MOVABLE_TYPE); +QT_END_NAMESPACE + +struct Complex +{ + explicit Complex(int i = 0) Q_DECL_NOTHROW + : i(i) + { + ++instanceCount; + } + + Complex(const Complex &c) + : i(c.i) + { + ++instanceCount; + } + + ~Complex() + { + --instanceCount; + } + + int i; + static int instanceCount; +}; + +int Complex::instanceCount = 0; +bool operator==(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i == rhs.i; } +bool operator!=(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i != rhs.i; } +bool operator<(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i < rhs.i; } + +uint qHash(Complex c, uint seed = 0) Q_DECL_NOTHROW { return qHash(c.i, seed); } +QDebug &operator<<(QDebug &d, Complex c) +{ + const QDebugStateSaver saver(d); + return d.nospace() << "Complex(" << c.i << ")"; +} + + +struct DuplicateStrategyTestType +{ + explicit DuplicateStrategyTestType(int i = 0) Q_DECL_NOTHROW + : i(i), + j(++counter) + { + } + + int i; + int j; + + static int counter; +}; + +int DuplicateStrategyTestType::counter = 0; + +// only look at the i member, not j. j allows us to identify which instance +// gets inserted in containers that don't allow for duplicates +bool operator==(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i == rhs.i; +} + +bool operator!=(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i != rhs.i; +} + +bool operator<(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i < rhs.i; +} + +uint qHash(DuplicateStrategyTestType c, uint seed = 0) Q_DECL_NOTHROW +{ + return qHash(c.i, seed); +} + +bool reallyEqual(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_DECL_NOTHROW +{ + return lhs.i == rhs.i && lhs.j == rhs.j; +} + +QDebug &operator<<(QDebug &d, DuplicateStrategyTestType c) +{ + const QDebugStateSaver saver(d); + return d.nospace() << "DuplicateStrategyTestType(" << c.i << "," << c.j << ")"; +} + + +namespace std { +template<> +struct hash<Movable> +{ + std::size_t operator()(Movable m) const Q_DECL_NOTHROW + { + return hash<int>()(m.i); + } +}; + +template<> +struct hash<Complex> +{ + std::size_t operator()(Complex m) const Q_DECL_NOTHROW + { + return hash<int>()(m.i); + } +}; + +template<> +struct hash<DuplicateStrategyTestType> +{ + std::size_t operator()(DuplicateStrategyTestType m) const Q_DECL_NOTHROW + { + return hash<int>()(m.i); + } +}; +} + +// work around the fact that QVarLengthArray has a non-type +// template parameter, and that breaks non_associative_container_duplicates_strategy +template<typename T> +class VarLengthArray : public QVarLengthArray<T> +{ +public: +#ifdef Q_COMPILER_INHERITING_CONSTRUCTORS + using QVarLengthArray<T>::QVarLengthArray; +#else + template<typename InputIterator> + VarLengthArray(InputIterator first, InputIterator last) + : QVarLengthArray<T>(first, last) + { + } + + VarLengthArray(std::initializer_list<T> args) + : QVarLengthArray<T>(args) + { + } +#endif +}; class tst_ContainerApiSymmetry : public QObject { Q_OBJECT + int m_movableInstanceCount; + int m_complexInstanceCount; + +private Q_SLOTS: + void init(); + void cleanup(); + +private: + template <typename Container> + void ranged_ctor_non_associative_impl() const; + + template<template<typename ... T> class Container> + void non_associative_container_duplicates_strategy() const; + + template <typename Container> + void ranged_ctor_associative_impl() const; + +private Q_SLOTS: + // non associative + void ranged_ctor_std_vector_int() { ranged_ctor_non_associative_impl<std::vector<int>>(); } + void ranged_ctor_std_vector_char() { ranged_ctor_non_associative_impl<std::vector<char>>(); } + void ranged_ctor_std_vector_QChar() { ranged_ctor_non_associative_impl<std::vector<QChar>>(); } + void ranged_ctor_std_vector_Movable() { ranged_ctor_non_associative_impl<std::vector<Movable>>(); } + void ranged_ctor_std_vector_Complex() { ranged_ctor_non_associative_impl<std::vector<Complex>>(); } + void ranged_ctor_std_vector_duplicates_strategy() { non_associative_container_duplicates_strategy<std::vector>(); } + + void ranged_ctor_QVector_int() { ranged_ctor_non_associative_impl<QVector<int>>(); } + void ranged_ctor_QVector_char() { ranged_ctor_non_associative_impl<QVector<char>>(); } + void ranged_ctor_QVector_QChar() { ranged_ctor_non_associative_impl<QVector<QChar>>(); } + void ranged_ctor_QVector_Movable() { ranged_ctor_non_associative_impl<QVector<Movable>>(); } + void ranged_ctor_QVector_Complex() { ranged_ctor_non_associative_impl<QVector<Complex>>(); } + void ranged_ctor_QVector_duplicates_strategy() { non_associative_container_duplicates_strategy<QVector>(); } + + void ranged_ctor_QVarLengthArray_int() { ranged_ctor_non_associative_impl<QVarLengthArray<int>>(); } + void ranged_ctor_QVarLengthArray_Movable() { ranged_ctor_non_associative_impl<QVarLengthArray<Movable>>(); } + void ranged_ctor_QVarLengthArray_Complex() { ranged_ctor_non_associative_impl<QVarLengthArray<Complex>>(); } + void ranged_ctor_QVarLengthArray_duplicates_strategy() { non_associative_container_duplicates_strategy<VarLengthArray>(); } // note the VarLengthArray passed + + void ranged_ctor_QList_int() { ranged_ctor_non_associative_impl<QList<int>>(); } + void ranged_ctor_QList_Movable() { ranged_ctor_non_associative_impl<QList<Movable>>(); } + void ranged_ctor_QList_Complex() { ranged_ctor_non_associative_impl<QList<Complex>>(); } + void ranged_ctor_QList_duplicates_strategy() { non_associative_container_duplicates_strategy<QList>(); } + + void ranged_ctor_std_list_int() { ranged_ctor_non_associative_impl<std::list<int>>(); } + void ranged_ctor_std_list_Movable() { ranged_ctor_non_associative_impl<std::list<Movable>>(); } + void ranged_ctor_std_list_Complex() { ranged_ctor_non_associative_impl<std::list<Complex>>(); } + void ranged_ctor_std_list_duplicates_strategy() { non_associative_container_duplicates_strategy<std::list>(); } + + void ranged_ctor_std_forward_list_int() { +#if COMPILER_HAS_STDLIB_INCLUDE(<forward_list>) + ranged_ctor_non_associative_impl<std::forward_list<int>>(); +#else + QSKIP("<forward_list> is needed for this test"); +#endif + } + + void ranged_ctor_std_forward_list_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE(<forward_list>) + ranged_ctor_non_associative_impl<std::forward_list<Movable>>(); +#else + QSKIP("<forward_list> is needed for this test"); +#endif + } + + void ranged_ctor_std_forward_list_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE(<forward_list>) + ranged_ctor_non_associative_impl<std::forward_list<Complex>>(); +#else + QSKIP("<forward_list> is needed for this test"); +#endif + } + + void ranged_ctor_std_forward_list_duplicates_strategy() { +#if COMPILER_HAS_STDLIB_INCLUDE(<forward_list>) + non_associative_container_duplicates_strategy<std::forward_list>(); +#else + QSKIP("<forward_list> is needed for this test"); +#endif + } + + void ranged_ctor_QLinkedList_int() { ranged_ctor_non_associative_impl<QLinkedList<int>>(); } + void ranged_ctor_QLinkedList_Movable() { ranged_ctor_non_associative_impl<QLinkedList<Movable>>(); } + void ranged_ctor_QLinkedList_Complex() { ranged_ctor_non_associative_impl<QLinkedList<Complex>>(); } + void ranged_ctor_QLinkedList_duplicates_strategy() { non_associative_container_duplicates_strategy<QLinkedList>(); } + + void ranged_ctor_std_set_int() { ranged_ctor_non_associative_impl<std::set<int>>(); } + void ranged_ctor_std_set_Movable() { ranged_ctor_non_associative_impl<std::set<Movable>>(); } + void ranged_ctor_std_set_Complex() { ranged_ctor_non_associative_impl<std::set<Complex>>(); } + void ranged_ctor_std_set_duplicates_strategy() { non_associative_container_duplicates_strategy<std::set>(); } + + void ranged_ctor_std_multiset_int() { ranged_ctor_non_associative_impl<std::multiset<int>>(); } + void ranged_ctor_std_multiset_Movable() { ranged_ctor_non_associative_impl<std::multiset<Movable>>(); } + void ranged_ctor_std_multiset_Complex() { ranged_ctor_non_associative_impl<std::multiset<Complex>>(); } + void ranged_ctor_std_multiset_duplicates_strategy() { non_associative_container_duplicates_strategy<std::multiset>(); } + + void ranged_ctor_std_unordered_set_int() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + ranged_ctor_non_associative_impl<std::unordered_set<int>>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_set_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + ranged_ctor_non_associative_impl<std::unordered_set<Movable>>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_set_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + ranged_ctor_non_associative_impl<std::unordered_set<Complex>>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + void ranged_ctor_unordered_set_duplicates_strategy() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + non_associative_container_duplicates_strategy<std::unordered_set>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + + void ranged_ctor_std_unordered_multiset_int() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + ranged_ctor_non_associative_impl<std::unordered_multiset<int>>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_multiset_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + ranged_ctor_non_associative_impl<std::unordered_multiset<Movable>>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_multiset_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + ranged_ctor_non_associative_impl<std::unordered_multiset<Complex>>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + void ranged_ctor_std_unordered_multiset_duplicates_strategy() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) + non_associative_container_duplicates_strategy<std::unordered_multiset>(); +#else + QSKIP("<unordered_set> is needed for this test"); +#endif + } + + void ranged_ctor_QSet_int() { ranged_ctor_non_associative_impl<QSet<int>>(); } + void ranged_ctor_QSet_Movable() { ranged_ctor_non_associative_impl<QSet<Movable>>(); } + void ranged_ctor_QSet_Complex() { ranged_ctor_non_associative_impl<QSet<Complex>>(); } + void ranged_ctor_QSet_duplicates_strategy() { non_associative_container_duplicates_strategy<QSet>(); } + + // associative + void ranged_ctor_std_map_int() { ranged_ctor_associative_impl<std::map<int, int>>(); } + void ranged_ctor_std_map_Movable() { ranged_ctor_associative_impl<std::map<Movable, int>>(); } + void ranged_ctor_std_map_Complex() { ranged_ctor_associative_impl<std::map<Complex, int>>(); } + + void ranged_ctor_std_multimap_int() { ranged_ctor_associative_impl<std::multimap<int, int>>(); } + void ranged_ctor_std_multimap_Movable() { ranged_ctor_associative_impl<std::multimap<Movable, int>>(); } + void ranged_ctor_std_multimap_Complex() { ranged_ctor_associative_impl<std::multimap<Complex, int>>(); } + + void ranged_ctor_unordered_map_int() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_map>) + ranged_ctor_associative_impl<std::unordered_map<int, int>>(); +#else + QSKIP("<unordered_map> is needed for this test"); +#endif + } + + void ranged_ctor_unordered_map_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_map>) + ranged_ctor_associative_impl<std::unordered_map<Movable, Movable>>(); +#else + QSKIP("<unordered_map> is needed for this test"); +#endif + } + + void ranged_ctor_unordered_map_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_map>) + ranged_ctor_associative_impl<std::unordered_map<Complex, Complex>>(); +#else + QSKIP("<unordered_map> is needed for this test"); +#endif + } + + void ranged_ctor_QHash_int() { ranged_ctor_associative_impl<QHash<int, int>>(); } + void ranged_ctor_QHash_Movable() { ranged_ctor_associative_impl<QHash<Movable, int>>(); } + void ranged_ctor_QHash_Complex() { ranged_ctor_associative_impl<QHash<Complex, int>>(); } + + void ranged_ctor_unordered_multimap_int() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_map>) + ranged_ctor_associative_impl<std::unordered_multimap<int, int>>(); +#else + QSKIP("<unordered_map> is needed for this test"); +#endif + } + + void ranged_ctor_unordered_multimap_Movable() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_map>) + ranged_ctor_associative_impl<std::unordered_multimap<Movable, Movable>>(); +#else + QSKIP("<unordered_map> is needed for this test"); +#endif + } + + void ranged_ctor_unordered_multimap_Complex() { +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_map>) + ranged_ctor_associative_impl<std::unordered_multimap<Complex, Complex>>(); +#else + QSKIP("<unordered_map> is needed for this test"); +#endif + } + + void ranged_ctor_QMultiHash_int() { ranged_ctor_associative_impl<QMultiHash<int, int>>(); } + void ranged_ctor_QMultiHash_Movable() { ranged_ctor_associative_impl<QMultiHash<Movable, int>>(); } + void ranged_ctor_QMultiHash_Complex() { ranged_ctor_associative_impl<QMultiHash<Complex, int>>(); } + private: template <typename Container> void front_back_impl() const; @@ -58,6 +491,296 @@ private Q_SLOTS: void front_back_QByteArray() { front_back_impl<QByteArray>(); } }; +void tst_ContainerApiSymmetry::init() +{ + m_movableInstanceCount = Movable::instanceCount; + m_complexInstanceCount = Complex::instanceCount; +} + +void tst_ContainerApiSymmetry::cleanup() +{ + // very simple leak check + QCOMPARE(Movable::instanceCount, m_movableInstanceCount); + QCOMPARE(Complex::instanceCount, m_complexInstanceCount); +} + +template <typename Container> +Container createContainerReference() +{ + using V = typename Container::value_type; + + return {V(0), V(1), V(2), V(0)}; +} + +template <typename Container> +void tst_ContainerApiSymmetry::ranged_ctor_non_associative_impl() const +{ + using V = typename Container::value_type; + + // the double V(0) is deliberate + const auto reference = createContainerReference<Container>(); + + // plain array + const V values1[] = { V(0), V(1), V(2), V(0) }; + + const Container c1(values1, values1 + sizeof(values1)/sizeof(values1[0])); + + // from QList + QList<V> l2; + l2 << V(0) << V(1) << V(2) << V(0); + + const Container c2a(l2.begin(), l2.end()); + const Container c2b(l2.cbegin(), l2.cend()); + + // from std::list + std::list<V> l3; + l3.push_back(V(0)); + l3.push_back(V(1)); + l3.push_back(V(2)); + l3.push_back(V(0)); + const Container c3a(l3.begin(), l3.end()); + + // from const std::list + const std::list<V> l3c = l3; + const Container c3b(l3c.begin(), l3c.end()); + + // from itself + const Container c4(reference.begin(), reference.end()); + + QCOMPARE(c1, reference); + QCOMPARE(c2a, reference); + QCOMPARE(c2b, reference); + QCOMPARE(c3a, reference); + QCOMPARE(c3b, reference); + QCOMPARE(c4, reference); +} + + +// type traits for detecting whether a non-associative container +// accepts duplicated values, and if it doesn't, whether construction/insertion +// prefer the new values (overwriting) or the old values (rejecting) + +struct ContainerAcceptsDuplicateValues {}; +struct ContainerOverwritesDuplicateValues {}; +struct ContainerRejectsDuplicateValues {}; + +template<typename Container> +struct ContainerDuplicatedValuesStrategy {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<std::vector<T...>> : ContainerAcceptsDuplicateValues {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<QVector<T...>> : ContainerAcceptsDuplicateValues {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<QVarLengthArray<T...>> : ContainerAcceptsDuplicateValues {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<VarLengthArray<T...>> : ContainerAcceptsDuplicateValues {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<QList<T...>> : ContainerAcceptsDuplicateValues {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<std::list<T...>> : ContainerAcceptsDuplicateValues {}; + +#if COMPILER_HAS_STDLIB_INCLUDE(<forward_list>) +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<std::forward_list<T...>> : ContainerAcceptsDuplicateValues {}; +#endif + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<QLinkedList<T...>> : ContainerAcceptsDuplicateValues {}; + +// assuming https://cplusplus.github.io/LWG/lwg-active.html#2844 resolution +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<std::set<T...>> : ContainerRejectsDuplicateValues {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<std::multiset<T...>> : ContainerAcceptsDuplicateValues {}; + +#if COMPILER_HAS_STDLIB_INCLUDE(<unordered_set>) +// assuming https://cplusplus.github.io/LWG/lwg-active.html#2844 resolution +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<std::unordered_set<T...>> : ContainerRejectsDuplicateValues {}; + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<std::unordered_multiset<T...>> : ContainerAcceptsDuplicateValues {}; +#endif + +template<typename ... T> +struct ContainerDuplicatedValuesStrategy<QSet<T...>> : ContainerRejectsDuplicateValues {}; + +template<typename Container> +void non_associative_container_check_duplicates_impl(const std::initializer_list<DuplicateStrategyTestType> &reference, const Container &c, ContainerAcceptsDuplicateValues) +{ + // do a deep check for equality, not ordering + QVERIFY(std::distance(reference.begin(), reference.end()) == std::distance(c.begin(), c.end())); + QVERIFY(std::is_permutation(reference.begin(), reference.end(), c.begin(), &reallyEqual)); +} + +enum class IterationOnReference +{ + ForwardIteration, + ReverseIteration +}; + +template<typename Container> +void non_associative_container_check_duplicates_impl_no_duplicates(const std::initializer_list<DuplicateStrategyTestType> &reference, const Container &c, IterationOnReference ior) +{ + std::vector<DuplicateStrategyTestType> valuesAlreadySeen; + + // iterate on reference forward or backwards, depending on ior. this will give + // us the expected semantics when checking for duplicated values into c + auto it = [&reference, ior]() { + switch (ior) { + case IterationOnReference::ForwardIteration: return reference.begin(); + case IterationOnReference::ReverseIteration: return reference.end() - 1; + }; + return std::initializer_list<DuplicateStrategyTestType>::const_iterator(); + }(); + + const auto &end = [&reference, ior]() { + switch (ior) { + case IterationOnReference::ForwardIteration: return reference.end(); + case IterationOnReference::ReverseIteration: return reference.begin() - 1; + }; + return std::initializer_list<DuplicateStrategyTestType>::const_iterator(); + }(); + + while (it != end) { + const auto &value = *it; + + // check that there is indeed the same value in the container (using operator==) + const auto &valueInContainerIterator = std::find(c.begin(), c.end(), value); + QVERIFY(valueInContainerIterator != c.end()); + QVERIFY(value == *valueInContainerIterator); + + // if the value is a duplicate, we don't expect to find it in the container + // (when doing a deep comparison). otherwise it should be there + + const auto &valuesAlreadySeenIterator = std::find(valuesAlreadySeen.cbegin(), valuesAlreadySeen.cend(), value); + const bool valueIsDuplicated = (valuesAlreadySeenIterator != valuesAlreadySeen.cend()); + + const auto &reallyEqualCheck = [&value](const DuplicateStrategyTestType &v) { return reallyEqual(value, v); }; + QCOMPARE(std::find_if(c.begin(), c.end(), reallyEqualCheck) == c.end(), valueIsDuplicated); + + valuesAlreadySeen.push_back(value); + + switch (ior) { + case IterationOnReference::ForwardIteration: + ++it; + break; + case IterationOnReference::ReverseIteration: + --it; + break; + }; + } + +} + +template<typename Container> +void non_associative_container_check_duplicates_impl(const std::initializer_list<DuplicateStrategyTestType> &reference, const Container &c, ContainerRejectsDuplicateValues) +{ + non_associative_container_check_duplicates_impl_no_duplicates(reference, c, IterationOnReference::ForwardIteration); +} + +template<typename Container> +void non_associative_container_check_duplicates_impl(const std::initializer_list<DuplicateStrategyTestType> &reference, const Container &c, ContainerOverwritesDuplicateValues) +{ + non_associative_container_check_duplicates_impl_no_duplicates(reference, c, IterationOnReference::ReverseIteration); +} + +template<typename Container> +void non_associative_container_check_duplicates(const std::initializer_list<DuplicateStrategyTestType> &reference, const Container &c) +{ + non_associative_container_check_duplicates_impl(reference, c, ContainerDuplicatedValuesStrategy<Container>()); +} + +template<template<class ... T> class Container> +void tst_ContainerApiSymmetry::non_associative_container_duplicates_strategy() const +{ + // first and last are "duplicates" -- they compare equal for operator==, + // but they differ when using reallyEqual + const std::initializer_list<DuplicateStrategyTestType> reference{ DuplicateStrategyTestType{0}, + DuplicateStrategyTestType{1}, + DuplicateStrategyTestType{2}, + DuplicateStrategyTestType{0} }; + Container<DuplicateStrategyTestType> c1{reference}; + non_associative_container_check_duplicates(reference, c1); + + Container<DuplicateStrategyTestType> c2{reference.begin(), reference.end()}; + non_associative_container_check_duplicates(reference, c2); +} + +template <typename Container> +void tst_ContainerApiSymmetry::ranged_ctor_associative_impl() const +{ + using K = typename Container::key_type; + using V = typename Container::mapped_type; + + // The double K(0) is deliberate. The order of the elements matters: + // * for unique-key STL containers, the first one should be the one inserted (cf. LWG 2844) + // * for unique-key Qt containers, the last one should be the one inserted + // * for multi-key sorted containers, the order of insertion of identical keys is also the + // iteration order (which establishes the equality of the containers) + // (although nothing of this is being tested here, that deserves its own testing) + const Container reference{ + { K(0), V(1000) }, + { K(1), V(1001) }, + { K(2), V(1002) }, + { K(0), V(1003) } + }; + + // Note that using anything not convertible to std::pair doesn't work for + // std containers. Their ranged construction is defined in terms of + // insert(value_type), which for std associative containers is + // std::pair<const K, T>. + + // plain array + const std::pair<K, V> values1[] = { + std::make_pair(K(0), V(1000)), + std::make_pair(K(1), V(1001)), + std::make_pair(K(2), V(1002)), + std::make_pair(K(0), V(1003)) + }; + + const Container c1(values1, values1 + sizeof(values1)/sizeof(values1[0])); + + // from QList + QList<std::pair<K, V>> l2; + l2 << std::make_pair(K(0), V(1000)) + << std::make_pair(K(1), V(1001)) + << std::make_pair(K(2), V(1002)) + << std::make_pair(K(0), V(1003)); + + const Container c2a(l2.begin(), l2.end()); + const Container c2b(l2.cbegin(), l2.cend()); + + // from std::list + std::list<std::pair<K, V>> l3; + l3.push_back(std::make_pair(K(0), V(1000))); + l3.push_back(std::make_pair(K(1), V(1001))); + l3.push_back(std::make_pair(K(2), V(1002))); + l3.push_back(std::make_pair(K(0), V(1003))); + const Container c3a(l3.begin(), l3.end()); + + // from const std::list + const std::list<std::pair<K, V>> l3c = l3; + const Container c3b(l3c.begin(), l3c.end()); + + // from itself + const Container c4(reference.begin(), reference.end()); + + QCOMPARE(c1, reference); + QCOMPARE(c2a, reference); + QCOMPARE(c2b, reference); + QCOMPARE(c3a, reference); + QCOMPARE(c3b, reference); + QCOMPARE(c4, reference); +} + template <typename Container> Container make(int size) { diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 72299402f0..06db0e8546 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -208,7 +208,7 @@ void printHeader(QStringList &headers) for (int h = 0; h < headers.count(); ++h) { cout << setw(20) << setiosflags(ios_base::left) << headers.at(h).toLatin1().constData(); } - cout << endl; + cout << Qt::endl; } template <typename ContainerType> @@ -220,7 +220,7 @@ void print(ContainerType testContainer) cout << value << " "; } - cout << endl; + cout << Qt::endl; } template <typename Algorithm, typename DataType> @@ -252,7 +252,7 @@ void testAlgorithm(Algorithm algorithm, QStringList &dataSetTypes) lessThan << setiosflags(ios_base::left) << setw(10) << result.lessThanRefCount / result.numSorts; cout << numSorts.str() << lessThan.str(); } - cout << endl; + cout << Qt::endl; } } #endif @@ -765,21 +765,21 @@ public: #if Q_TEST_PERFORMANCE void tst_QAlgorithms::performance() { - cout << endl << "Quick sort" << endl; + cout << Qt::endl << "Quick sort" << Qt::endl; testAlgorithm<QuickSortHelper<TestInt>, TestInt>(QuickSortHelper<TestInt>(), dataSetTypes); - cout << endl << "stable sort" << endl; + cout << Qt::endl << "stable sort" << Qt::endl; testAlgorithm<StableSortHelper<TestInt>, TestInt>(StableSortHelper<TestInt>(), dataSetTypes); - cout << endl << "std::sort" << endl; + cout << Qt::endl << "std::sort" << Qt::endl; testAlgorithm<StlSortHelper<TestInt>, TestInt>(StlSortHelper<TestInt>(), dataSetTypes); - cout << endl << "std::stable_sort" << endl; + cout << Qt::endl << "std::stable_sort" << Qt::endl; testAlgorithm<StlStableSortHelper<TestInt>, TestInt>(StlStableSortHelper<TestInt>(), dataSetTypes); /* - cout << endl << "Sorting lists of ints" << endl; - cout << endl << "Quick sort" << endl; + cout << Qt::endl << "Sorting lists of ints" << Qt::endl; + cout << Qt::endl << "Quick sort" << Qt::endl; testAlgorithm<QuickSortHelper<int>, int>(QuickSortHelper<int>(), dataSetTypes); - cout << endl << "std::sort" << endl; + cout << Qt::endl << "std::sort" << Qt::endl; testAlgorithm<StlSortHelper<int>, int>(StlSortHelper<int>(), dataSetTypes); - cout << endl << "std::stable_sort" << endl; + cout << Qt::endl << "std::stable_sort" << Qt::endl; testAlgorithm<StlStableSortHelper<int>, int>(StlStableSortHelper<int>(), dataSetTypes); */ } diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index a00c962510..7db7d71b1f 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -78,12 +78,8 @@ private slots: void fromRawData_data(); void fromRawData(); void literals(); -#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA) void variadicLiterals(); -#endif -#ifdef Q_COMPILER_RVALUE_REFS void rValueReferences(); -#endif void grow(); }; @@ -95,7 +91,7 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to 1 (owned) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(1) }, 0, 0, 0, 0 }; - QCOMPARE(array.ref.atomic.load(), 1); + QCOMPARE(array.ref.atomic.loadRelaxed(), 1); QVERIFY(!array.ref.isStatic()); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) @@ -103,19 +99,19 @@ void tst_QArrayData::referenceCounting() #endif QVERIFY(array.ref.ref()); - QCOMPARE(array.ref.atomic.load(), 2); + QCOMPARE(array.ref.atomic.loadRelaxed(), 2); QVERIFY(array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 1); + QCOMPARE(array.ref.atomic.loadRelaxed(), 1); QVERIFY(array.ref.ref()); - QCOMPARE(array.ref.atomic.load(), 2); + QCOMPARE(array.ref.atomic.loadRelaxed(), 2); QVERIFY(array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 1); + QCOMPARE(array.ref.atomic.loadRelaxed(), 1); QVERIFY(!array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); // Now would be a good time to free/release allocated data } @@ -125,17 +121,17 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to 0 (non-sharable) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 }; - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); QVERIFY(!array.ref.isStatic()); QVERIFY(!array.ref.isSharable()); QVERIFY(!array.ref.ref()); // Reference counting fails, data should be copied - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); QVERIFY(!array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); // Free/release data } @@ -145,7 +141,7 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to -1 (static read-only data) QArrayData array = { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, 0 }; - QCOMPARE(array.ref.atomic.load(), -1); + QCOMPARE(array.ref.atomic.loadRelaxed(), -1); QVERIFY(array.ref.isStatic()); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) @@ -153,10 +149,10 @@ void tst_QArrayData::referenceCounting() #endif QVERIFY(array.ref.ref()); - QCOMPARE(array.ref.atomic.load(), -1); + QCOMPARE(array.ref.atomic.loadRelaxed(), -1); QVERIFY(array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), -1); + QCOMPARE(array.ref.atomic.loadRelaxed(), -1); } } @@ -172,8 +168,8 @@ void tst_QArrayData::sharedNullEmpty() QVERIFY(empty->ref.isStatic()); QVERIFY(empty->ref.isShared()); - QCOMPARE(null->ref.atomic.load(), -1); - QCOMPARE(empty->ref.atomic.load(), -1); + QCOMPARE(null->ref.atomic.loadRelaxed(), -1); + QCOMPARE(empty->ref.atomic.loadRelaxed(), -1); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(null->ref.isSharable()); @@ -183,14 +179,14 @@ void tst_QArrayData::sharedNullEmpty() QVERIFY(null->ref.ref()); QVERIFY(empty->ref.ref()); - QCOMPARE(null->ref.atomic.load(), -1); - QCOMPARE(empty->ref.atomic.load(), -1); + QCOMPARE(null->ref.atomic.loadRelaxed(), -1); + QCOMPARE(empty->ref.atomic.loadRelaxed(), -1); QVERIFY(null->ref.deref()); QVERIFY(empty->ref.deref()); - QCOMPARE(null->ref.atomic.load(), -1); - QCOMPARE(empty->ref.atomic.load(), -1); + QCOMPARE(null->ref.atomic.loadRelaxed(), -1); + QCOMPARE(empty->ref.atomic.loadRelaxed(), -1); QVERIFY(null != empty); @@ -1618,9 +1614,7 @@ void tst_QArrayData::literals() QCOMPARE(v.size(), size_t(11)); // v.capacity() is unspecified, for now -#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA) QVERIFY(v.isStatic()); -#endif #if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); @@ -1633,7 +1627,6 @@ void tst_QArrayData::literals() } } -#if defined(Q_COMPILER_VARIADIC_MACROS) && defined(Q_COMPILER_LAMBDA) // Variadic Q_ARRAY_LITERAL need to be available in the current configuration. void tst_QArrayData::variadicLiterals() { @@ -1682,9 +1675,7 @@ void tst_QArrayData::variadicLiterals() QCOMPARE(const_(v)[i], i); } } -#endif -#ifdef Q_COMPILER_RVALUE_REFS // std::remove_reference is in C++11, but requires library support template <class T> struct RemoveReference { typedef T Type; }; template <class T> struct RemoveReference<T &> { typedef T Type; }; @@ -1767,7 +1758,6 @@ void tst_QArrayData::rValueReferences() QCOMPARE(v3.size(), size_t(1)); QCOMPARE(v3.front(), 42); } -#endif void tst_QArrayData::grow() { diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 1ed41793dc..90dfcaef25 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -138,9 +138,7 @@ private slots: void reserveExtended(); void movablity_data(); void movablity(); -#if defined(Q_COMPILER_LAMBDA) void literals(); -#endif void toUpperLower_data(); void toUpperLower(); void isUpper(); @@ -1361,6 +1359,9 @@ void tst_QByteArray::toDouble_data() QTest::newRow("trailing spaces") << QByteArray("1.2345 \n\r\t") << 1.2345 << true; QTest::newRow("leading junk") << QByteArray("x1.2345") << 0.0 << false; QTest::newRow("trailing junk") << QByteArray("1.2345x") << 0.0 << false; + + QTest::newRow("raw, null plus junk") << QByteArray::fromRawData("1.2\0 junk", 9) << 0.0 << false; + QTest::newRow("raw, null-terminator not included") << QByteArray::fromRawData("2.3", 3) << 2.3 << true; } void tst_QByteArray::toDouble() @@ -1934,7 +1935,7 @@ void tst_QByteArray::repeatedSignature() const { /* repated() should be a const member. */ const QByteArray string; - string.repeated(3); + (void)string.repeated(3); } void tst_QByteArray::repeated() const @@ -2126,7 +2127,7 @@ void tst_QByteArray::movablity() { QFETCH(QByteArray, array); - QVERIFY(!QTypeInfo<QByteArray>::isStatic); + Q_STATIC_ASSERT(!QTypeInfo<QByteArray>::isStatic); const int size = array.size(); const bool isEmpty = array.isEmpty(); @@ -2138,7 +2139,7 @@ void tst_QByteArray::movablity() // we need only memory space not the instance memSpace.~QByteArray(); // move array -> memSpace - memcpy(&memSpace, &array, sizeof(QByteArray)); + memcpy((void *)&memSpace, (const void *)&array, sizeof(QByteArray)); // reconstruct empty QByteArray new (&array) QByteArray; @@ -2148,8 +2149,8 @@ void tst_QByteArray::movablity() QCOMPARE(memSpace.capacity(), capacity); // try to not crash - memSpace.toLower(); - memSpace.toUpper(); + (void)memSpace.toLower(); + (void)memSpace.toUpper(); memSpace.prepend('a'); memSpace.append("b", 1); memSpace.squeeze(); @@ -2165,7 +2166,7 @@ void tst_QByteArray::movablity() // move back memSpace -> array array.~QByteArray(); - memcpy(&array, &memSpace, sizeof(QByteArray)); + memcpy((void *)&array, (const void *)&memSpace, sizeof(QByteArray)); // reconstruct empty QByteArray new (&memSpace) QByteArray; @@ -2189,7 +2190,6 @@ void tst_QByteArray::movablity() QVERIFY(true); } -#if defined(Q_COMPILER_LAMBDA) // Only tested on c++0x compliant compiler or gcc void tst_QByteArray::literals() { @@ -2210,7 +2210,6 @@ void tst_QByteArray::literals() QVERIFY(str2.constData() == s); QVERIFY(str2.data() != s); } -#endif void tst_QByteArray::toUpperLower_data() { @@ -2242,28 +2241,28 @@ void tst_QByteArray::toUpperLower() QCOMPARE(input.toLower(), lower); QByteArray copy = input; - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); copy = input; copy.detach(); - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); copy = input; - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = input; copy.detach(); - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = lower; - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = lower; copy.detach(); - QCOMPARE(qMove(copy).toLower(), lower); + QCOMPARE(std::move(copy).toLower(), lower); copy = upper; - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); copy = upper; copy.detach(); - QCOMPARE(qMove(copy).toUpper(), upper); + QCOMPARE(std::move(copy).toUpper(), upper); } void tst_QByteArray::isUpper() diff --git a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp index 2d2c536453..09ce41337e 100644 --- a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp +++ b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp @@ -194,22 +194,22 @@ void tst_QByteArrayList::operator_plus() const { QByteArrayList bal1 = lhs; const QByteArrayList bal2 = rhs; - QCOMPARE(qMove(bal1) + bal2, expectedResult); + QCOMPARE(std::move(bal1) + bal2, expectedResult); } { QList<QByteArray> lba1 = lhs; const QByteArrayList bal2 = rhs; - QCOMPARE(qMove(lba1) + bal2, expectedResult); + QCOMPARE(std::move(lba1) + bal2, expectedResult); } { QByteArrayList bal1 = lhs; const QList<QByteArray> lba2 = rhs; - QCOMPARE(qMove(bal1) + lba2, expectedResult); + QCOMPARE(std::move(bal1) + lba2, expectedResult); } { QList<QByteArray> lba1 = lhs; const QList<QByteArray> lba2 = rhs; - QCOMPARE(qMove(lba1) + lba2, QList<QByteArray>(expectedResult)); // check we don't mess with old code + QCOMPARE(std::move(lba1) + lba2, QList<QByteArray>(expectedResult)); // check we don't mess with old code } // operator += for const lvalues @@ -232,7 +232,7 @@ void tst_QByteArrayList::operator_plus() const QByteArrayList t1 = lhs; QByteArrayList t2 = rhs; - QCOMPARE(qMove(t1) + t2, expectedResult); + QCOMPARE(std::move(t1) + t2, expectedResult); } void tst_QByteArrayList::operator_plus_data() const @@ -287,7 +287,6 @@ void tst_QByteArrayList::indexOf() const void tst_QByteArrayList::initializerList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS // constructor QByteArrayList v1 = {QByteArray("hello"),"world",QByteArray("plop")}; QCOMPARE(v1, (QByteArrayList() << "hello" << "world" << "plop")); @@ -296,9 +295,6 @@ void tst_QByteArrayList::initializerList() const QByteArrayList v2; v2 = {QByteArray("hello"),"world",QByteArray("plop")}; QCOMPARE(v2, v1); -#else - QSKIP("This test requires C++11 initializer_list support in the compiler."); -#endif } QTEST_APPLESS_MAIN(tst_QByteArrayList) diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp index 72f88a235d..2ae9c6e159 100644 --- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp +++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp @@ -47,7 +47,6 @@ private Q_SLOTS: void state(); }; -#ifdef Q_COMPILER_RVALUE_REFS static bool dpointer_is_null(QCollator &c) { char mem[sizeof c]; @@ -58,11 +57,9 @@ static bool dpointer_is_null(QCollator &c) 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); @@ -78,9 +75,6 @@ void tst_QCollator::moveSemantics() 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 } diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 7980f1f8f4..1e87c76d2f 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -44,6 +44,7 @@ private slots: // In-process tests void testInvalidOptions(); + void testDuplicateOption(); void testPositionalArguments(); void testBooleanOption_data(); void testBooleanOption(); @@ -75,6 +76,8 @@ private slots: void testHelpOption(); void testQuoteEscaping(); void testUnknownOption(); + void testHelpAll_data(); + void testHelpAll(); }; static char *empty_argv[] = { 0 }; @@ -104,6 +107,15 @@ void tst_QCommandLineParser::testInvalidOptions() QVERIFY(!parser.addOption(QCommandLineOption(QStringLiteral("-v"), QStringLiteral("Displays version information.")))); } +void tst_QCommandLineParser::testDuplicateOption() +{ + QCoreApplication app(empty_argc, empty_argv); + QCommandLineParser parser; + QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("h"), QStringLiteral("Hostname."), QStringLiteral("hostname")))); + QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: already having an option named \"h\""); + parser.addHelpOption(); +} + void tst_QCommandLineParser::testPositionalArguments() { QCoreApplication app(empty_argc, empty_argv); @@ -489,7 +501,7 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes() void tst_QCommandLineParser::testCpp11StyleInitialization() { -#if defined(Q_COMPILER_INITIALIZER_LISTS) && defined(Q_COMPILER_UNIFORM_INIT) +#if defined(Q_COMPILER_UNIFORM_INIT) QCoreApplication app(empty_argc, empty_argv); QCommandLineParser parser; @@ -532,7 +544,8 @@ void tst_QCommandLineParser::testVersionOption() static const char expectedOptionsHelp[] = "Options:\n" - " -h, --help Displays this help.\n" + " -h, --help Displays help on commandline options.\n" + " --help-all Displays help including Qt specific options.\n" " -v, --version Displays version information.\n" " --load <url> Load file from URL.\n" " -o, --output <file> Set output file.\n" @@ -566,8 +579,8 @@ void tst_QCommandLineParser::testHelpOption_data() " parsingMode The parsing mode to test.\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"); + expectedOutput.replace(" -h, --help Displays help on commandline options.\n", + " -?, -h, --help Displays help on commandline options.\n"); expectedOutput.replace("testhelper/", "testhelper\\"); #endif @@ -615,8 +628,8 @@ void tst_QCommandLineParser::testHelpOption() "Arguments:\n" " resize Resize the object to a new size.\n"; #ifdef Q_OS_WIN - expectedResizeHelp.replace(" -h, --help Displays this help.\n", - " -?, -h, --help Displays this help.\n"); + expectedResizeHelp.replace(" -h, --help Displays help on commandline options.\n", + " -?, -h, --help Displays help on commandline options.\n"); expectedResizeHelp.replace("testhelper/", "testhelper\\"); #endif QCOMPARE(output, QString(expectedResizeHelp)); @@ -670,6 +683,60 @@ void tst_QCommandLineParser::testUnknownOption() #endif // QT_CONFIG(process) } +void tst_QCommandLineParser::testHelpAll_data() +{ + QTest::addColumn<QCommandLineParser::SingleDashWordOptionMode>("parsingMode"); + QTest::addColumn<QString>("expectedHelpOutput"); + + QString expectedOutput = QString::fromLatin1( + "Usage: testhelper/qcommandlineparser_test_helper [options] parsingMode command\n" + "Test helper\n" + "\n") + + QString::fromLatin1(expectedOptionsHelp) + + QString::fromLatin1( + " --qmljsdebugger <value> Activates the QML/JS debugger with a specified\n" + " port. The value must be of format\n" + " port:1234[,block]. \"block\" makes the application\n" + " wait for a connection.\n" + "\n" + "Arguments:\n" + " parsingMode The parsing mode to test.\n" + " command The command to execute.\n"); +#ifdef Q_OS_WIN + expectedOutput.replace(" -h, --help Displays help on commandline options.\n", + " -?, -h, --help Displays help on commandline options.\n"); + expectedOutput.replace("testhelper/", "testhelper\\"); +#endif + + QTest::newRow("collapsed") << QCommandLineParser::ParseAsCompactedShortOptions << expectedOutput; + QTest::newRow("long") << QCommandLineParser::ParseAsLongOptions << expectedOutput; +} + +void tst_QCommandLineParser::testHelpAll() +{ +#if !QT_CONFIG(process) + QSKIP("This test requires QProcess support"); +#else +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) + QSKIP("Deploying executable applications to file system on Android not supported."); +#endif + + QFETCH(QCommandLineParser::SingleDashWordOptionMode, parsingMode); + QFETCH(QString, expectedHelpOutput); + QCoreApplication app(empty_argc, empty_argv); + QProcess process; + process.start("testhelper/qcommandlineparser_test_helper", QStringList() << QString::number(parsingMode) << "--help-all"); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QString output = process.readAll(); +#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); +#endif // QT_CONFIG(process) +} + QTEST_APPLESS_MAIN(tst_QCommandLineParser) #include "tst_qcommandlineparser.moc" diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index 31a5f93822..f305d63d46 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -68,7 +68,7 @@ void tst_QContiguousCache::assignment() // copy: cc1 = cc2; // move: - cc1 = qMove(cc2); + cc1 = std::move(cc2); } void tst_QContiguousCache::empty() @@ -244,7 +244,7 @@ public: return *this; } - int refCount() const { return d->ref.load(); } + int refCount() const { return d->ref.loadRelaxed(); } private: RefCountingClassData *d; }; diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 0196dd2d23..3af6132695 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -30,9 +30,7 @@ #include <qeasingcurve.h> -#ifdef Q_COMPILER_RVALUE_REFS // cpp11() slot -# include <utility> // for std::move() -#endif +#include <utility> // for std::move() class tst_QEasingCurve : public QObject { @@ -55,6 +53,8 @@ private slots: void testCbrtFloat(); void cpp11(); void quadraticEquation(); + void streamInOut_data(); + void streamInOut(); }; void tst_QEasingCurve::type() @@ -792,7 +792,6 @@ void tst_QEasingCurve::testCbrtFloat() void tst_QEasingCurve::cpp11() { -#ifdef Q_COMPILER_RVALUE_REFS { QEasingCurve ec( QEasingCurve::InOutBack ); QEasingCurve copy = std::move(ec); // move ctor @@ -807,7 +806,6 @@ void tst_QEasingCurve::cpp11() QCOMPARE( copy.type(), QEasingCurve::InOutBack ); QCOMPARE( ec.type(), type ); } -#endif } void tst_QEasingCurve::quadraticEquation() { @@ -879,5 +877,36 @@ void tst_QEasingCurve::quadraticEquation() { } } +void tst_QEasingCurve::streamInOut_data() +{ + QTest::addColumn<int>("version"); + QTest::addColumn<bool>("equality"); + + QTest::newRow("5.11") << int(QDataStream::Qt_5_11) << false; + QTest::newRow("5.13") << int(QDataStream::Qt_5_13) << true; +} + +void tst_QEasingCurve::streamInOut() +{ + QFETCH(int, version); + QFETCH(bool, equality); + + QEasingCurve orig; + orig.addCubicBezierSegment(QPointF(0.43, 0.0025), QPointF(0.38, 0.51), QPointF(0.57, 0.99)); + + QEasingCurve copy; + + QByteArray data; + QDataStream dsw(&data,QIODevice::WriteOnly); + QDataStream dsr(&data,QIODevice::ReadOnly); + + dsw.setVersion(version); + dsr.setVersion(version); + dsw << orig; + dsr >> copy; + + QCOMPARE(copy == orig, equality); +} + QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 0015efacfa..d70d488e96 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1480,7 +1480,6 @@ void tst_QHash::twoArguments_qHash() void tst_QHash::initializerList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS QHash<int, QString> hash = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(hash.count(), 2); QCOMPARE(hash[1], QString("hello")); @@ -1507,9 +1506,6 @@ void tst_QHash::initializerList() QMultiHash<int, float> emptyPairs2{{}, {}}; QVERIFY(!emptyPairs2.isEmpty()); -#else - QSKIP("Compiler doesn't support initializer lists"); -#endif } void tst_QHash::eraseValidIteratorOnSharedHash() diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index 124e3cdf00..f76f3aa0c6 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -34,6 +34,8 @@ #include <sstream> #include <algorithm> +#include <unordered_set> + class tst_QHashFunctions : public QObject { Q_OBJECT @@ -59,6 +61,8 @@ private Q_SLOTS: void range(); void rangeCommutative(); + void stdHash(); + void setGlobalQHashSeed(); }; @@ -281,6 +285,38 @@ void tst_QHashFunctions::rangeCommutative() (void)qHashRangeCommutative(hashables, hashables + numHashables, seed); } +void tst_QHashFunctions::stdHash() +{ + { + std::unordered_set<QString> s = {QStringLiteral("Hello"), QStringLiteral("World")}; + QCOMPARE(s.size(), 2UL); + s.insert(QStringLiteral("Hello")); + QCOMPARE(s.size(), 2UL); + } + + { + std::unordered_set<QStringView> s = {QStringLiteral("Hello"), QStringLiteral("World")}; + QCOMPARE(s.size(), 2UL); + s.insert(QStringLiteral("Hello")); + QCOMPARE(s.size(), 2UL); + } + + { + std::unordered_set<QLatin1String> s = {QLatin1String("Hello"), QLatin1String("World")}; + QCOMPARE(s.size(), 2UL); + s.insert(QLatin1String("Hello")); + QCOMPARE(s.size(), 2UL); + } + + { + std::unordered_set<QByteArray> s = {QByteArrayLiteral("Hello"), QByteArrayLiteral("World")}; + QCOMPARE(s.size(), 2UL); + s.insert(QByteArray("Hello")); + QCOMPARE(s.size(), 2UL); + } + +} + void tst_QHashFunctions::setGlobalQHashSeed() { // Setter works as advertised diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp index dcfb0aa042..cf46159251 100644 --- a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp +++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp @@ -45,6 +45,7 @@ class tst_QLatin1String : public QObject private Q_SLOTS: void at(); + void arg() const; void midLeftRight(); void nullString(); void emptyString(); @@ -63,6 +64,47 @@ void tst_QLatin1String::at() QCOMPARE(l1[l1.size() - 1], QLatin1Char('d')); } +void tst_QLatin1String::arg() const +{ +#define CHECK1(pattern, arg1, expected) \ + do { \ + auto p = QLatin1String(pattern); \ + QCOMPARE(p.arg(QLatin1String(arg1)), expected); \ + QCOMPARE(p.arg(QStringViewLiteral(arg1)), expected); \ + QCOMPARE(p.arg(QStringLiteral(arg1)), expected); \ + QCOMPARE(p.arg(QString(QLatin1String(arg1))), expected); \ + } while (false) \ + /*end*/ +#define CHECK2(pattern, arg1, arg2, expected) \ + do { \ + auto p = QLatin1String(pattern); \ + QCOMPARE(p.arg(QLatin1String(arg1), QLatin1String(arg2)), expected); \ + QCOMPARE(p.arg(QStringViewLiteral(arg1), QLatin1String(arg2)), expected); \ + QCOMPARE(p.arg(QLatin1String(arg1), QStringViewLiteral(arg2)), expected); \ + QCOMPARE(p.arg(QStringViewLiteral(arg1), QStringViewLiteral(arg2)), expected); \ + } while (false) \ + /*end*/ + + CHECK1("", "World", ""); + CHECK1("%1", "World", "World"); + CHECK1("!%1?", "World", "!World?"); + CHECK1("%1%1", "World", "WorldWorld"); + CHECK1("%1%2", "World", "World%2"); + CHECK1("%2%1", "World", "%2World"); + + CHECK2("", "Hello", "World", ""); + CHECK2("%1", "Hello", "World", "Hello"); + CHECK2("!%1, %2?", "Hello", "World", "!Hello, World?"); + CHECK2("%1%1", "Hello", "World", "HelloHello"); + CHECK2("%1%2", "Hello", "World", "HelloWorld"); + CHECK2("%2%1", "Hello", "World", "WorldHello"); + +#undef CHECK2 +#undef CHECK1 + + QCOMPARE(QLatin1String(" %2 %2 %1 %3 ").arg(QLatin1Char('c'), QChar::CarriageReturn, u'C'), " \r \r c C "); +} + void tst_QLatin1String::midLeftRight() { const QLatin1String l1("Hello World"); diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index ae65d8f697..915a24a1f6 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -205,7 +205,7 @@ void tst_QLine::testIntersection() QPointF ip; - QLineF::IntersectType itype = a.intersect(b, &ip); + QLineF::IntersectionType itype = a.intersect(b, &ip); QCOMPARE(int(itype), type); if (type != QLineF::NoIntersection) { diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index f17d6695f0..deb3b68c5c 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -1005,7 +1005,6 @@ void tst_QLinkedList::testSTLIteratorsComplex() const void tst_QLinkedList::initializeList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS QLinkedList<int> v1 { 2, 3, 4 }; QCOMPARE(v1, QLinkedList<int>() << 2 << 3 << 4); QCOMPARE(v1, (QLinkedList<int> { 2, 3, 4})); @@ -1014,7 +1013,6 @@ void tst_QLinkedList::initializeList() const QLinkedList<QLinkedList<int>> v3; v3 << v1 << (QLinkedList<int>() << 1) << QLinkedList<int>() << v1; QCOMPARE(v3, v2); -#endif } diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index b3f8130d27..5a485e88d2 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -364,12 +364,14 @@ private slots: void takeLastOptimal() const; void takeLastMovable() const; void takeLastComplex() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void toSetOptimal() const; void toSetMovable() const; void toSetComplex() const; void toStdListOptimal() const; void toStdListMovable() const; void toStdListComplex() const; +#endif void toVectorOptimal() const; void toVectorMovable() const; void toVectorComplex() const; @@ -426,8 +428,10 @@ private: template<typename T> void takeAt() const; template<typename T> void takeFirst() const; template<typename T> void takeLast() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template<typename T> void toSet() const; template<typename T> void toStdList() const; +#endif template<typename T> void toVector() const; template<typename T> void value() const; @@ -1457,11 +1461,11 @@ void tst_QList::swap() const list << T_FOO << T_BAR << T_BAZ; // swap - list.swap(0, 2); + list.swapItemsAt(0, 2); QCOMPARE(list, QList<T>() << T_BAZ << T_BAR << T_FOO); // swap again - list.swap(1, 2); + list.swapItemsAt(1, 2); QCOMPARE(list, QList<T>() << T_BAZ << T_FOO << T_BAR); QList<T> list2; @@ -1595,6 +1599,7 @@ void tst_QList::takeLastComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) template<typename T> void tst_QList::toSet() const { @@ -1669,6 +1674,7 @@ void tst_QList::toStdListComplex() const toStdList<Complex>(); QCOMPARE(liveCount, Complex::getLiveCount()); } +#endif template<typename T> void tst_QList::toVector() const @@ -1871,7 +1877,6 @@ void tst_QList::testSTLIteratorsComplex() const void tst_QList::initializeList() const { -#ifdef Q_COMPILER_INITIALIZER_LISTS QList<int> v1{2,3,4}; QCOMPARE(v1, QList<int>() << 2 << 3 << 4); QCOMPARE(v1, (QList<int>{2,3,4})); @@ -1880,7 +1885,6 @@ void tst_QList::initializeList() const QList<QList<int>> v3; v3 << v1 << (QList<int>() << 1) << QList<int>() << v1; QCOMPARE(v3, v2); -#endif } template<typename T> diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index be2e2a2e08..ec8f2fc047 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -423,6 +423,7 @@ void tst_QLocale::defaulted_ctor() } QLocale::setDefault(QLocale(QLocale::C)); + const QString empty; TEST_CTOR("C", C, AnyCountry) TEST_CTOR("bla", C, AnyCountry) @@ -431,7 +432,7 @@ void tst_QLocale::defaulted_ctor() TEST_CTOR("zz...", C, AnyCountry) TEST_CTOR("", C, AnyCountry) TEST_CTOR("en/", C, AnyCountry) - TEST_CTOR(QString::null, C, AnyCountry) + TEST_CTOR(empty, C, AnyCountry) TEST_CTOR("en", English, UnitedStates) TEST_CTOR("en", English, UnitedStates) TEST_CTOR("en.", English, UnitedStates) diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index b39444e76f..d66fd28779 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1319,7 +1319,6 @@ void tst_QMap::checkMostLeftNode() void tst_QMap::initializerList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS QMap<int, QString> map = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(map.count(), 2); QCOMPARE(map[1], QString("hello")); @@ -1346,9 +1345,6 @@ void tst_QMap::initializerList() QMultiMap<float, float> emptyPairs2{{}, {}}; QVERIFY(!emptyPairs2.isEmpty()); -#else - QSKIP("Compiler doesn't support initializer lists"); -#endif } void tst_QMap::testInsertWithHint() diff --git a/tests/auto/corelib/tools/qpair/qpair.pro b/tests/auto/corelib/tools/qpair/qpair.pro index 659be887d3..d684a24a57 100644 --- a/tests/auto/corelib/tools/qpair/qpair.pro +++ b/tests/auto/corelib/tools/qpair/qpair.pro @@ -2,3 +2,6 @@ CONFIG += testcase TARGET = tst_qpair QT = core testlib SOURCES = tst_qpair.cpp + +# Force C++17 if available (needed due to Q_COMPILER_DEDUCTION_GUIDES) +contains(QT_CONFIG, c++1z): CONFIG += c++1z diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp index dedc353e67..3c972329bc 100644 --- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp +++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp @@ -39,6 +39,7 @@ private Q_SLOTS: void testConstexpr(); void testConversions(); void taskQTBUG_48780_pairContainingCArray(); + void testDeducationRules(); }; class C { C() {} char _[4]; }; @@ -202,5 +203,30 @@ void tst_QPair::taskQTBUG_48780_pairContainingCArray() Q_UNUSED(pair); } +void tst_QPair::testDeducationRules() +{ +#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606 + QPair p1{1, 2}; + static_assert(std::is_same<decltype(p1)::first_type, decltype(1)>::value); + static_assert(std::is_same<decltype(p1)::second_type, decltype(2)>::value); + QCOMPARE(p1.first, 1); + QCOMPARE(p1.second, 2); + + QPair p2{QString("string"), 2}; + static_assert(std::is_same<decltype(p2)::first_type, QString>::value); + static_assert(std::is_same<decltype(p2)::second_type, decltype(2)>::value); + QCOMPARE(p2.first, "string"); + QCOMPARE(p2.second, 2); + + QPair p3(p2); + static_assert(std::is_same<decltype(p3)::first_type, decltype(p2)::first_type>::value); + static_assert(std::is_same<decltype(p3)::second_type, decltype(p2)::second_type>::value); + QCOMPARE(p3.first, "string"); + QCOMPARE(p3.second, 2); +#else + QSKIP("Unsupported"); +#endif +} + QTEST_APPLESS_MAIN(tst_QPair) #include "tst_qpair.moc" diff --git a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp index b943b04e23..ea94cc2999 100644 --- a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp @@ -327,7 +327,7 @@ struct RefCounted ~RefCounted() { - QVERIFY( ref.load() == 0 ); + QVERIFY( ref.loadRelaxed() == 0 ); instanceCount.deref(); } @@ -369,13 +369,13 @@ void scopedPointerComparisonTest(const A1 &a1, const A2 &a2, const B &b) void tst_QScopedPointer::comparison() { - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); { RefCounted *a = new RefCounted; RefCounted *b = new RefCounted; - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); QScopedPointer<RefCounted> pa1(a); QScopedPointer<RefCounted> pa2(a); @@ -387,16 +387,16 @@ void tst_QScopedPointer::comparison() pa2.take(); - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); } - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); { RefCounted *a = new RefCounted[42]; RefCounted *b = new RefCounted[43]; - QCOMPARE( RefCounted::instanceCount.load(), 85 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 85 ); QScopedArrayPointer<RefCounted> pa1(a); QScopedArrayPointer<RefCounted> pa2(a); @@ -406,10 +406,10 @@ void tst_QScopedPointer::comparison() pa2.take(); - QCOMPARE( RefCounted::instanceCount.load(), 85 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 85 ); } - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); { // QScopedSharedPointer is an internal helper class -- it is unsupported! @@ -417,42 +417,42 @@ void tst_QScopedPointer::comparison() RefCounted *a = new RefCounted; RefCounted *b = new RefCounted; - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); QSharedDataPointer<RefCounted> pa1(a); QSharedDataPointer<RefCounted> pa2(a); QSharedDataPointer<RefCounted> pb(b); - QCOMPARE( a->ref.load(), 2 ); - QCOMPARE( b->ref.load(), 1 ); - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( a->ref.loadRelaxed(), 2 ); + QCOMPARE( b->ref.loadRelaxed(), 1 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); scopedPointerComparisonTest(pa1, pa2, pb); - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); } - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); } void tst_QScopedPointer::array() { - int instCount = RefCounted::instanceCount.load(); + int instCount = RefCounted::instanceCount.loadRelaxed(); { QScopedArrayPointer<RefCounted> array; array.reset(new RefCounted[42]); - QCOMPARE(instCount + 42, RefCounted::instanceCount.load()); + QCOMPARE(instCount + 42, RefCounted::instanceCount.loadRelaxed()); } - QCOMPARE(instCount, RefCounted::instanceCount.load()); + QCOMPARE(instCount, RefCounted::instanceCount.loadRelaxed()); { QScopedArrayPointer<RefCounted> array(new RefCounted[42]); - QCOMPARE(instCount + 42, RefCounted::instanceCount.load()); + QCOMPARE(instCount + 42, RefCounted::instanceCount.loadRelaxed()); array.reset(new RefCounted[28]); - QCOMPARE(instCount + 28, RefCounted::instanceCount.load()); + QCOMPARE(instCount + 28, RefCounted::instanceCount.loadRelaxed()); array.reset(0); - QCOMPARE(instCount, RefCounted::instanceCount.load()); + QCOMPARE(instCount, RefCounted::instanceCount.loadRelaxed()); } - QCOMPARE(instCount, RefCounted::instanceCount.load()); + QCOMPARE(instCount, RefCounted::instanceCount.loadRelaxed()); } diff --git a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp index 656dd6a6e3..9b607db608 100644 --- a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp +++ b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp @@ -46,6 +46,7 @@ private Q_SLOTS: void rollbackToPreviousCommit(); void exceptions(); void earlyExitScope(); + void moveOnly(); private: void earlyExitScope_helper(int exitpoint, int &member); }; @@ -190,5 +191,17 @@ void tst_QScopedValueRollback::earlyExitScope_helper(int exitpoint, int& member) r.commit(); } +void tst_QScopedValueRollback::moveOnly() +{ + std::unique_ptr<int> uniquePtr; + std::unique_ptr<int> newVal(new int(5)); + QVERIFY(!uniquePtr); + { + QScopedValueRollback<std::unique_ptr<int>> r(uniquePtr, std::move(newVal)); + QVERIFY(uniquePtr); + } + QVERIFY(!uniquePtr); +} + QTEST_MAIN(tst_QScopedValueRollback) #include "tst_qscopedvaluerollback.moc" diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 0b60350380..31b4c0449e 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -955,7 +955,6 @@ void tst_QSet::makeSureTheComfortFunctionsCompile() void tst_QSet::initializerList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS QSet<int> set = {1, 1, 2, 3, 4, 5}; QCOMPARE(set.count(), 5); QVERIFY(set.contains(1)); @@ -976,9 +975,6 @@ void tst_QSet::initializerList() QSet<int> set3{{}, {}, {}}; QVERIFY(!set3.isEmpty()); -#else - QSKIP("Compiler doesn't support initializer lists"); -#endif } void tst_QSet::qhash() @@ -1011,15 +1007,7 @@ void tst_QSet::qhash() // check that sets of sets work: // { -#ifdef Q_COMPILER_INITIALIZER_LISTS QSet<QSet<int> > intSetSet = { { 0, 1, 2 }, { 0, 1 }, { 1, 2 } }; -#else - QSet<QSet<int> > intSetSet; - QSet<int> intSet01, intSet12; - intSet01 << 0 << 1; - intSet12 << 1 << 2; - intSetSet << intSet01 << intSet12 << (intSet01|intSet12); -#endif QCOMPARE(intSetSet.size(), 3); } } diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index e97848fb1c..187b73eeec 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -79,6 +79,7 @@ private slots: void sharedPointerFromQObjectWithWeak(); void weakQObjectFromSharedPointer(); void objectCast(); + void objectCastStdSharedPtr(); void differentPointers(); void virtualBaseDifferentPointers(); #ifndef QTEST_NO_RTTI @@ -90,9 +91,7 @@ private slots: #endif void constCorrectness(); void customDeleter(); -#ifdef Q_COMPILER_LAMBDA void lambdaCustomDeleter(); -#endif void creating(); void creatingCvQualified(); void creatingVariadic(); @@ -227,7 +226,6 @@ struct NoDefaultConstructorConstRef2 NoDefaultConstructorConstRef2(const QByteArray &ba, int i = 42) : str(QString::fromLatin1(ba)), i(i) {} }; -#ifdef Q_COMPILER_RVALUE_REFS struct NoDefaultConstructorRRef1 { int &i; @@ -239,7 +237,6 @@ struct NoDefaultConstructorRRef2 std::unique_ptr<int> i; NoDefaultConstructorRRef2(std::unique_ptr<int> &&i) : i(std::move(i)) {} }; -#endif void tst_QSharedPointer::basics_data() { @@ -297,8 +294,8 @@ void tst_QSharedPointer::basics() QVERIFY(! (ptr == otherData)); QVERIFY(! (otherData == ptr)); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create another object: @@ -310,8 +307,8 @@ void tst_QSharedPointer::basics() // otherData is deleted here } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create a copy: @@ -328,8 +325,8 @@ void tst_QSharedPointer::basics() QCOMPARE(copy.get(), aData); QVERIFY(copy == aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create a weak reference: @@ -361,8 +358,8 @@ void tst_QSharedPointer::basics() QCOMPARE(strong.data(), aData); QCOMPARE(strong.get(), aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); // aData is deleted here } @@ -508,7 +505,6 @@ void tst_QSharedPointer::swap() void tst_QSharedPointer::moveSemantics() { -#ifdef Q_COMPILER_RVALUE_REFS QSharedPointer<int> p1, p2(new int(42)), control = p2; QVERIFY(p1 != control); QVERIFY(p1.isNull()); @@ -561,9 +557,6 @@ void tst_QSharedPointer::moveSemantics() QVERIFY(w1.isNull()); QVERIFY(w2.isNull()); QVERIFY(w3.isNull()); -#else - QSKIP("This test requires C++11 rvalue/move semantics support in the compiler."); -#endif } void tst_QSharedPointer::useOfForwardDeclared() @@ -580,10 +573,10 @@ void tst_QSharedPointer::useOfForwardDeclared() // move assignment: QSharedPointer<ForwardDeclared> sp4; - sp4 = qMove(sp); + sp4 = std::move(sp); // and move constuction: - QSharedPointer<ForwardDeclared> sp5 = qMove(sp2); + QSharedPointer<ForwardDeclared> sp5 = std::move(sp2); // swapping: sp4.swap(sp3); @@ -850,15 +843,15 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<DerivedData> derivedptr = qWeakPointerCast<DerivedData>(baseptr); QVERIFY(baseptr == derivedptr); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -866,16 +859,16 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DerivedData> derivedptr = baseptr.staticCast<DerivedData>(); QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } class OtherObject: public QObject @@ -1122,6 +1115,60 @@ void tst_QSharedPointer::objectCast() safetyCheck(); } + +void tst_QSharedPointer::objectCastStdSharedPtr() +{ + { + OtherObject *data = new OtherObject; + std::shared_ptr<QObject> baseptr = std::shared_ptr<QObject>(data); + QVERIFY(baseptr.get() == data); + + // perform successful object cast + std::shared_ptr<OtherObject> ptr = qobject_pointer_cast<OtherObject>(baseptr); + QVERIFY(ptr.get()); + QVERIFY(ptr.get() == data); + + QVERIFY(baseptr.get() == data); + } + + { + OtherObject *data = new OtherObject; + std::shared_ptr<QObject> baseptr = std::shared_ptr<QObject>(data); + QVERIFY(baseptr.get() == data); + + // perform successful object cast + std::shared_ptr<OtherObject> ptr = qobject_pointer_cast<OtherObject>(std::move(baseptr)); + QVERIFY(ptr.get()); + QVERIFY(ptr.get() == data); + + QVERIFY(!baseptr.get()); + } + + { + QObject *data = new QObject; + std::shared_ptr<QObject> baseptr = std::shared_ptr<QObject>(data); + QVERIFY(baseptr.get() == data); + + // perform unsuccessful object cast + std::shared_ptr<OtherObject> ptr = qobject_pointer_cast<OtherObject>(baseptr); + QVERIFY(!ptr.get()); + + QVERIFY(baseptr.get() == data); + } + + { + QObject *data = new QObject; + std::shared_ptr<QObject> baseptr = std::shared_ptr<QObject>(data); + QVERIFY(baseptr.get() == data); + + // perform unsuccessful object cast + std::shared_ptr<OtherObject> ptr = qobject_pointer_cast<OtherObject>(std::move(baseptr)); + QVERIFY(!ptr.get()); + + QVERIFY(baseptr.get() == data); + } +} + void tst_QSharedPointer::differentPointers() { { @@ -1250,8 +1297,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -1260,8 +1307,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>(); @@ -1269,8 +1316,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastDifferentPointers() @@ -1285,8 +1332,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -1295,8 +1342,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DiffPtrDerivedData> derivedptr = baseptr.dynamicCast<DiffPtrDerivedData>(); @@ -1304,8 +1351,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { Stuffing *nakedptr = dynamic_cast<Stuffing *>(baseptr.data()); @@ -1330,8 +1377,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer<Data> weakptr = baseptr; @@ -1340,8 +1387,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<VirtualDerived> derivedptr = baseptr.dynamicCast<VirtualDerived>(); @@ -1349,8 +1396,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastFailure() @@ -1362,15 +1409,15 @@ void tst_QSharedPointer::dynamicCastFailure() QSharedPointer<DerivedData> derivedptr = qSharedPointerDynamicCast<DerivedData>(baseptr); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>(); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastFailureNoLeak() @@ -1677,7 +1724,6 @@ void tst_QSharedPointer::customDeleter() safetyCheck(); } -#ifdef Q_COMPILER_LAMBDA // The compiler needs to be in C++11 mode and to support lambdas void tst_QSharedPointer::lambdaCustomDeleter() { @@ -1705,7 +1751,6 @@ void tst_QSharedPointer::lambdaCustomDeleter() } safetyCheck(); } -#endif void customQObjectDeleterFn(QObject *obj) { @@ -1741,8 +1786,8 @@ void tst_QSharedPointer::creating() QCOMPARE(Data::destructorCounter, 1); // valgrind will complain here if something happened to the pointer - QVERIFY(d->weakref.load() == 1); - QVERIFY(d->strongref.load() == 0); + QVERIFY(d->weakref.loadRelaxed() == 1); + QVERIFY(d->strongref.loadRelaxed() == 0); } safetyCheck(); @@ -1977,7 +2022,7 @@ void tst_QSharedPointer::threadStressTest() for (int r = 0; r < 5; ++r) { QVector<QThread*> allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0); QSharedPointer<ThreadData> base = QSharedPointer<ThreadData>(new ThreadData(&counter)); - counter.store(0); + counter.storeRelaxed(0); // set the pointers for (int i = 0; i < strongThreadCount; ++i) { @@ -2011,8 +2056,8 @@ void tst_QSharedPointer::threadStressTest() // verify that the count is the right range int minValue = strongThreadCount; int maxValue = strongThreadCount + weakThreadCount; - QVERIFY(counter.load() >= minValue); - QVERIFY(counter.load() <= maxValue); + QVERIFY(counter.loadRelaxed() >= minValue); + QVERIFY(counter.loadRelaxed() <= maxValue); } } @@ -2245,11 +2290,9 @@ void tst_QSharedPointer::invalidConstructs_data() << &QTest::QExternalTest::tryCompileFail << "struct IncompatibleCustomDeleter { void operator()(int *); };\n" "QSharedPointer<Data> ptr(new Data, IncompatibleCustomDeleter());\n"; -#ifdef Q_COMPILER_LAMBDA QTest::newRow("incompatible-custom-lambda-deleter") << &QTest::QExternalTest::tryCompileFail << "QSharedPointer<Data> ptr(new Data, [](int *) {});\n"; -#endif } void tst_QSharedPointer::invalidConstructs() diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index e8ed22e427..79f5a8c46d 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -482,8 +482,8 @@ private slots: void indexOf2(); void indexOf3_data(); // void indexOf3(); - void sprintf(); - void sprintfS(); + void asprintf(); + void asprintfS(); void fill(); void truncate(); void chop_data(); @@ -578,7 +578,7 @@ private slots: #ifdef QT_USE_ICU void toUpperLower_icu(); #endif -#if !defined(QT_NO_UNICODE_LITERAL) && defined(Q_COMPILER_LAMBDA) +#if !defined(QT_NO_UNICODE_LITERAL) void literals(); #endif void eightBitLiterals_data(); @@ -612,7 +612,7 @@ QString verifyZeroTermination(const QString &str) int strSize = str.size(); QChar strTerminator = str.constData()[strSize]; if (QChar('\0') != strTerminator) - return QString::fromAscii( + return QString::fromLatin1( "*** Result ('%1') not null-terminated: 0x%2 ***").arg(str) .arg(strTerminator.unicode(), 4, 16, QChar('0')); @@ -625,11 +625,11 @@ QString verifyZeroTermination(const QString &str) const_cast<QChar *>(strData)[strSize] = QChar('x'); if (QChar('x') != str.constData()[strSize]) { - return QString::fromAscii("*** Failed to replace null-terminator in " + return QString::fromLatin1("*** Failed to replace null-terminator in " "result ('%1') ***").arg(str); } if (str != strCopy) { - return QString::fromAscii( "*** Result ('%1') differs from its copy " + return QString::fromLatin1( "*** Result ('%1') differs from its copy " "after null-terminator was replaced ***").arg(str); } const_cast<QChar *>(strData)[strSize] = QChar('\0'); // Restore sanity @@ -1075,9 +1075,8 @@ void tst_QString::isNull() QString a; QVERIFY(a.isNull()); - const char *zero = 0; - a.sprintf( zero ); - QVERIFY(!a.isNull()); + const char *zero = nullptr; + QVERIFY(!QString::asprintf(zero).isNull()); } QT_WARNING_POP @@ -1263,75 +1262,66 @@ static inline const void *ptrValue(quintptr v) return reinterpret_cast<const void *>(v); } -void tst_QString::sprintf() +void tst_QString::asprintf() { QString a; - a.sprintf("COMPARE"); - QCOMPARE(a, QLatin1String("COMPARE")); - a.sprintf("%%%d",1); - QCOMPARE(a, QLatin1String("%1")); - QCOMPARE(a.sprintf("X%dY",2), QLatin1String("X2Y")); - QCOMPARE(a.sprintf("X%9iY", 50000 ), QLatin1String("X 50000Y")); - QCOMPARE(a.sprintf("X%-9sY","hello"), QLatin1String("Xhello Y")); - QCOMPARE(a.sprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y")); - QCOMPARE(a.sprintf("%lf", 1.23), QLatin1String("1.230000")); - QCOMPARE(a.sprintf("%lf", 1.23456789), QLatin1String("1.234568")); - QCOMPARE(a.sprintf("%p", ptrValue(0xbfffd350)), QLatin1String("0xbfffd350")); - QCOMPARE(a.sprintf("%p", ptrValue(0)), QLatin1String("0x0")); + QCOMPARE(QString::asprintf("COMPARE"), QLatin1String("COMPARE")); + QCOMPARE(QString::asprintf("%%%d", 1), QLatin1String("%1")); + QCOMPARE(QString::asprintf("X%dY",2), QLatin1String("X2Y")); + QCOMPARE(QString::asprintf("X%9iY", 50000 ), QLatin1String("X 50000Y")); + QCOMPARE(QString::asprintf("X%-9sY","hello"), QLatin1String("Xhello Y")); + QCOMPARE(QString::asprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y")); + QCOMPARE(QString::asprintf("%lf", 1.23), QLatin1String("1.230000")); + QCOMPARE(QString::asprintf("%lf", 1.23456789), QLatin1String("1.234568")); + QCOMPARE(QString::asprintf("%p", ptrValue(0xbfffd350)), QLatin1String("0xbfffd350")); + QCOMPARE(QString::asprintf("%p", ptrValue(0)), QLatin1String("0x0")); int i = 6; long l = -2; float f = 4.023f; - QString S1; - S1.sprintf("%d %ld %f",i,l,f); - QCOMPARE(S1, QLatin1String("6 -2 4.023000")); + QCOMPARE(QString::asprintf("%d %ld %f", i, l, f), QLatin1String("6 -2 4.023000")); double d = -514.25683; - S1.sprintf("%f",d); - QCOMPARE(S1, QLatin1String("-514.256830")); + QCOMPARE(QString::asprintf("%f", d), QLatin1String("-514.256830")); } -void tst_QString::sprintfS() +void tst_QString::asprintfS() { - QString a; - QCOMPARE(a.sprintf("%.3s", "Hello" ), QLatin1String("Hel")); - QCOMPARE(a.sprintf("%10.3s", "Hello" ), QLatin1String(" Hel")); - QCOMPARE(a.sprintf("%.10s", "Hello" ), QLatin1String("Hello")); - QCOMPARE(a.sprintf("%10.10s", "Hello" ), QLatin1String(" Hello")); - QCOMPARE(a.sprintf("%-10.10s", "Hello" ), QLatin1String("Hello ")); - QCOMPARE(a.sprintf("%-10.3s", "Hello" ), QLatin1String("Hel ")); - QCOMPARE(a.sprintf("%-5.5s", "Hello" ), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%.3s", "Hello" ), QLatin1String("Hel")); + QCOMPARE(QString::asprintf("%10.3s", "Hello" ), QLatin1String(" Hel")); + QCOMPARE(QString::asprintf("%.10s", "Hello" ), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%10.10s", "Hello" ), QLatin1String(" Hello")); + QCOMPARE(QString::asprintf("%-10.10s", "Hello" ), QLatin1String("Hello ")); + QCOMPARE(QString::asprintf("%-10.3s", "Hello" ), QLatin1String("Hel ")); + QCOMPARE(QString::asprintf("%-5.5s", "Hello" ), QLatin1String("Hello")); // Check utf8 conversion for %s - QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305")); + QCOMPARE(QString::asprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305")); int n1; - a.sprintf("%s%n%s", "hello", &n1, "goodbye"); + QCOMPARE(QString::asprintf("%s%n%s", "hello", &n1, "goodbye"), QString("hellogoodbye")); QCOMPARE(n1, 5); - QCOMPARE(a, QString("hellogoodbye")); qlonglong n2; - a.sprintf("%s%s%lln%s", "foo", "bar", &n2, "whiz"); + QCOMPARE(QString::asprintf("%s%s%lln%s", "foo", "bar", &n2, "whiz"), QString("foobarwhiz")); QCOMPARE((int)n2, 6); - QCOMPARE(a, QString("foobarwhiz")); { // %ls - QCOMPARE(a.sprintf("%.3ls", qUtf16Printable("Hello")), QLatin1String("Hel")); - QCOMPARE(a.sprintf("%10.3ls", qUtf16Printable("Hello")), QLatin1String(" Hel")); - QCOMPARE(a.sprintf("%.10ls", qUtf16Printable("Hello")), QLatin1String("Hello")); - QCOMPARE(a.sprintf("%10.10ls", qUtf16Printable("Hello")), QLatin1String(" Hello")); - QCOMPARE(a.sprintf("%-10.10ls", qUtf16Printable("Hello")), QLatin1String("Hello ")); - QCOMPARE(a.sprintf("%-10.3ls", qUtf16Printable("Hello")), QLatin1String("Hel ")); - QCOMPARE(a.sprintf("%-5.5ls", qUtf16Printable("Hello")), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%.3ls", qUtf16Printable("Hello")), QLatin1String("Hel")); + QCOMPARE(QString::asprintf("%10.3ls", qUtf16Printable("Hello")), QLatin1String(" Hel")); + QCOMPARE(QString::asprintf("%.10ls", qUtf16Printable("Hello")), QLatin1String("Hello")); + QCOMPARE(QString::asprintf("%10.10ls", qUtf16Printable("Hello")), QLatin1String(" Hello")); + QCOMPARE(QString::asprintf("%-10.10ls", qUtf16Printable("Hello")), QLatin1String("Hello ")); + QCOMPARE(QString::asprintf("%-10.3ls", qUtf16Printable("Hello")), QLatin1String("Hel ")); + QCOMPARE(QString::asprintf("%-5.5ls", qUtf16Printable("Hello")), QLatin1String("Hello")); // Check utf16 is preserved for %ls - QCOMPARE(a.sprintf("%ls", + QCOMPARE(QString::asprintf("%ls", qUtf16Printable("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")), QLatin1String("\366\344\374\326\304\334\370\346\345\330\306\305")); int n; - a.sprintf("%ls%n%s", qUtf16Printable("hello"), &n, "goodbye"); + QCOMPARE(QString::asprintf("%ls%n%s", qUtf16Printable("hello"), &n, "goodbye"), QLatin1String("hellogoodbye")); QCOMPARE(n, 5); - QCOMPARE(a, QLatin1String("hellogoodbye")); } } @@ -2212,12 +2202,12 @@ void tst_QString::toUpper() // call rvalue-ref while shared (the original mustn't change) QString copy = s; - QCOMPARE(qMove(copy).toUpper(), QString("GROSSSTRASSE")); + QCOMPARE(std::move(copy).toUpper(), QString("GROSSSTRASSE")); QCOMPARE(s, QString::fromUtf8("Gro\xc3\x9fstra\xc3\x9f""e")); // call rvalue-ref version on detached case copy.clear(); - QCOMPARE(qMove(s).toUpper(), QString("GROSSSTRASSE")); + QCOMPARE(std::move(s).toUpper(), QString("GROSSSTRASSE")); } QString lower, upper; @@ -2427,11 +2417,11 @@ void tst_QString::trimmed() QCOMPARE(a.trimmed(), QLatin1String("a")); a="Text"; - QCOMPARE(qMove(a).trimmed(), QLatin1String("Text")); + QCOMPARE(std::move(a).trimmed(), QLatin1String("Text")); a=" "; - QCOMPARE(qMove(a).trimmed(), QLatin1String("")); + QCOMPARE(std::move(a).trimmed(), QLatin1String("")); a=" a "; - QCOMPARE(qMove(a).trimmed(), QLatin1String("a")); + QCOMPARE(std::move(a).trimmed(), QLatin1String("a")); } void tst_QString::simplified_data() @@ -2486,13 +2476,13 @@ void tst_QString::simplified() // without detaching: QString copy1 = full; - QCOMPARE(qMove(full).simplified(), simple); + QCOMPARE(std::move(full).simplified(), simple); QCOMPARE(full, orig_full); // force a detach if (!full.isEmpty()) full[0] = full[0]; - QCOMPARE(qMove(full).simplified(), simple); + QCOMPARE(std::move(full).simplified(), simple); } void tst_QString::insert_data(bool emptyIsNoop) @@ -3789,7 +3779,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith("C") ); QVERIFY( !a.startsWith("ABCDEF") ); QVERIFY( a.startsWith("") ); - QVERIFY( a.startsWith(QString::null) ); + QVERIFY( a.startsWith(QString()) ); QVERIFY( a.startsWith('A') ); QVERIFY( a.startsWith(QLatin1Char('A')) ); QVERIFY( a.startsWith(QChar('A')) ); @@ -3816,7 +3806,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith("c", Qt::CaseInsensitive) ); QVERIFY( !a.startsWith("abcdef", Qt::CaseInsensitive) ); QVERIFY( a.startsWith("", Qt::CaseInsensitive) ); - QVERIFY( a.startsWith(QString::null, Qt::CaseInsensitive) ); + QVERIFY( a.startsWith(QString(), Qt::CaseInsensitive) ); QVERIFY( a.startsWith('a', Qt::CaseInsensitive) ); QVERIFY( a.startsWith('A', Qt::CaseInsensitive) ); QVERIFY( a.startsWith(QLatin1Char('a'), Qt::CaseInsensitive) ); @@ -3855,7 +3845,7 @@ void tst_QString::startsWith() a = ""; QVERIFY( a.startsWith("") ); - QVERIFY( a.startsWith(QString::null) ); + QVERIFY( a.startsWith(QString()) ); QVERIFY( !a.startsWith("ABC") ); QVERIFY( a.startsWith(QLatin1String("")) ); @@ -3868,7 +3858,7 @@ void tst_QString::startsWith() a = QString(); QVERIFY( !a.startsWith("") ); - QVERIFY( a.startsWith(QString::null) ); + QVERIFY( a.startsWith(QString()) ); QVERIFY( !a.startsWith("ABC") ); QVERIFY( !a.startsWith(QLatin1String("")) ); @@ -3897,7 +3887,7 @@ void tst_QString::endsWith() QVERIFY( !a.endsWith("C") ); QVERIFY( !a.endsWith("ABCDEF") ); QVERIFY( a.endsWith("") ); - QVERIFY( a.endsWith(QString::null) ); + QVERIFY( a.endsWith(QString()) ); QVERIFY( a.endsWith('B') ); QVERIFY( a.endsWith(QLatin1Char('B')) ); QVERIFY( a.endsWith(QChar('B')) ); @@ -3924,7 +3914,7 @@ void tst_QString::endsWith() QVERIFY( !a.endsWith("c", Qt::CaseInsensitive) ); QVERIFY( !a.endsWith("abcdef", Qt::CaseInsensitive) ); QVERIFY( a.endsWith("", Qt::CaseInsensitive) ); - QVERIFY( a.endsWith(QString::null, Qt::CaseInsensitive) ); + QVERIFY( a.endsWith(QString(), Qt::CaseInsensitive) ); QVERIFY( a.endsWith('b', Qt::CaseInsensitive) ); QVERIFY( a.endsWith('B', Qt::CaseInsensitive) ); QVERIFY( a.endsWith(QLatin1Char('b'), Qt::CaseInsensitive) ); @@ -3966,7 +3956,7 @@ void tst_QString::endsWith() a = ""; QVERIFY( a.endsWith("") ); - QVERIFY( a.endsWith(QString::null) ); + QVERIFY( a.endsWith(QString()) ); QVERIFY( !a.endsWith("ABC") ); QVERIFY( !a.endsWith(QLatin1Char(0)) ); QVERIFY( !a.endsWith(QLatin1Char('x')) ); @@ -3978,7 +3968,7 @@ void tst_QString::endsWith() a = QString(); QVERIFY( !a.endsWith("") ); - QVERIFY( a.endsWith(QString::null) ); + QVERIFY( a.endsWith(QString()) ); QVERIFY( !a.endsWith("ABC") ); QVERIFY( !a.endsWith(QLatin1String("")) ); @@ -4534,7 +4524,7 @@ void tst_QString::toLatin1Roundtrip() // try the rvalue version of toLatin1() QString s = unicodesrc; - QCOMPARE(qMove(s).toLatin1(), latin1); + QCOMPARE(std::move(s).toLatin1(), latin1); // and verify that the moved-from object can still be used s = "foo"; @@ -4838,7 +4828,7 @@ void tst_QString::arg() QCOMPARE( QString("%1").arg("hello", 10), QLatin1String(" hello") ); QCOMPARE( QString("%1%1").arg("hello"), QLatin1String("hellohello") ); QCOMPARE( QString("%2%1").arg("hello"), QLatin1String("%2hello") ); - QCOMPARE( QString("%1%1").arg(QString::null), QLatin1String("") ); + QCOMPARE( QString("%1%1").arg(QString()), QLatin1String("") ); QCOMPARE( QString("%2%1").arg(""), QLatin1String("%2") ); QCOMPARE( QString("%2 %L1").arg(12345.6789).arg(12345.6789), @@ -4934,9 +4924,7 @@ void tst_QString::doubleOut() QCOMPARE(QString::number(micro), expect); QCOMPARE(QString("%1").arg(micro), expect); { - QString text; - text.sprintf("%g", micro); - QCOMPARE(text, expect); + QCOMPARE(QString::asprintf("%g", micro), expect); } { QString text; @@ -5480,8 +5468,6 @@ void tst_QString::tortureSprintfDouble() { const SprintfDoubleData *data = g_sprintf_double_data; - QString s; - for (; data->fmt != 0; ++data) { double d; char *buff = (char *)&d; @@ -5496,7 +5482,7 @@ void tst_QString::tortureSprintfDouble() for (uint i = 0; i < 8; ++i) buff[7 - i] = data->bytes[i]; # endif - s.sprintf(data->fmt, d); + const QString s = QString::asprintf(data->fmt, d); #ifdef QT_NO_FPU // reduced precision when running with hardfloats in qemu if (d - 0.1 < 1e12) QSKIP("clib sprintf doesn't fill with 0's on this platform"); @@ -6450,32 +6436,24 @@ void tst_QString::QCharRefDetaching() const void tst_QString::sprintfZU() const { { - QString string; size_t s = 6; - string.sprintf("%zu", s); - QCOMPARE(string, QString::fromLatin1("6")); + QCOMPARE(QString::asprintf("%zu", s), QString::fromLatin1("6")); } { - QString string; - string.sprintf("%s\n", "foo"); - QCOMPARE(string, QString::fromLatin1("foo\n")); + QCOMPARE(QString::asprintf("%s\n", "foo"), QString::fromLatin1("foo\n")); } { /* This code crashed. I don't know how to reduce it further. In other words, * both %zu and %s needs to be present. */ size_t s = 6; - QString string; - string.sprintf("%zu%s", s, "foo"); - QCOMPARE(string, QString::fromLatin1("6foo")); + QCOMPARE(QString::asprintf("%zu%s", s, "foo"), QString::fromLatin1("6foo")); } { size_t s = 6; - QString string; - string.sprintf("%zu %s\n", s, "foo"); - QCOMPARE(string, QString::fromLatin1("6 foo\n")); + QCOMPARE(QString::asprintf("%zu %s\n", s, "foo"), QString::fromLatin1("6 foo\n")); } } @@ -6643,7 +6621,7 @@ void tst_QString::toUpperLower_icu() } #endif -#if !defined(QT_NO_UNICODE_LITERAL) && defined(Q_COMPILER_LAMBDA) +#if !defined(QT_NO_UNICODE_LITERAL) // Only tested on c++0x compliant compiler or gcc void tst_QString::literals() { diff --git a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp index 82d58becfe..24382a2b61 100644 --- a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +** Copyright (C) 2019 Mail.ru Group. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -48,6 +49,14 @@ QString toQString(const T &t) { return QString(t); } QString toQString(const QStringRef &ref) { return ref.toString(); } QString toQString(QStringView view) { return view.toString(); } +template <typename Iterable> +QStringList toQStringList(const Iterable &i) { + QStringList result; + for (auto &e : i) + result.push_back(toQString(e)); + return result; +} + // FIXME: these are missing at the time of writing, add them, then remove the dummies here: #define MAKE_RELOP(op, A1, A2) \ static bool operator op (A1 lhs, A2 rhs) \ @@ -293,6 +302,26 @@ private Q_SLOTS: void endsWith_QLatin1String_QChar() { endsWith_impl<QLatin1String, QChar>(); } private: + void split_data(bool rhsHasVariableLength = true); + template <typename Haystack, typename Needle> void split_impl() const; + +private Q_SLOTS: + // test all combinations of {QString, QStringRef} x {QString, QLatin1String, QChar}: + void split_QString_QString_data() { split_data(); } + void split_QString_QString() { split_impl<QString, QString>(); } + void split_QString_QLatin1String_data() { split_data(); } + void split_QString_QLatin1String() { split_impl<QString, QLatin1String>(); } + void split_QString_QChar_data() { split_data(false); } + void split_QString_QChar() { split_impl<QString, QChar>(); } + + void split_QStringRef_QString_data() { split_data(); } + void split_QStringRef_QString() { split_impl<QStringRef, QString>(); } + void split_QStringRef_QLatin1String_data() { split_data(); } + void split_QStringRef_QLatin1String() { split_impl<QStringRef, QLatin1String>(); } + void split_QStringRef_QChar_data() { split_data(false); } + void split_QStringRef_QChar() { split_impl<QStringRef, QChar>(); } + +private: void mid_data(); template <typename String> void mid_impl(); @@ -416,6 +445,129 @@ private Q_SLOTS: void toUcs4_QStringRef() { toUcs4_impl<QStringRef>(); } void toUcs4_QStringView_data() { toUcs4_data(); } void toUcs4_QStringView() { toUcs4_impl<QStringView>(); } + +private: + template <typename Haystack, typename Needle> void indexOf_impl() const; + void indexOf_data(); + +private Q_SLOTS: + void indexOf_QString_QString_data() { indexOf_data(); } + void indexOf_QString_QString() { indexOf_impl<QString, QString>(); } + void indexOf_QString_QLatin1String_data() { indexOf_data(); } + void indexOf_QString_QLatin1String() { indexOf_impl<QString, QLatin1String>(); } + void indexOf_QString_QStringRef_data() { indexOf_data(); } + void indexOf_QString_QStringRef() { indexOf_impl<QString, QStringRef>(); } + void indexOf_QString_QStringView_data() { indexOf_data(); } + void indexOf_QString_QStringView() { indexOf_impl<QString, QStringView>(); } + + void indexOf_QLatin1String_QString_data() { indexOf_data(); } + void indexOf_QLatin1String_QString() { indexOf_impl<QLatin1String, QString>(); } + void indexOf_QLatin1String_QLatin1String_data() { indexOf_data(); } + void indexOf_QLatin1String_QLatin1String() { indexOf_impl<QLatin1String, QLatin1String>(); } + void indexOf_QLatin1String_QStringRef_data() { indexOf_data(); } + void indexOf_QLatin1String_QStringRef() { indexOf_impl<QLatin1String, QStringRef>(); } + void indexOf_QLatin1String_QStringView_data() { indexOf_data(); } + void indexOf_QLatin1String_QStringView() { indexOf_impl<QLatin1String, QStringView>(); } + + void indexOf_QStringRef_QString_data() { indexOf_data(); } + void indexOf_QStringRef_QString() { indexOf_impl<QStringRef, QString>(); } + void indexOf_QStringRef_QLatin1String_data() { indexOf_data(); } + void indexOf_QStringRef_QLatin1String() { indexOf_impl<QStringRef, QLatin1String>(); } + void indexOf_QStringRef_QStringRef_data() { indexOf_data(); } + void indexOf_QStringRef_QStringRef() { indexOf_impl<QStringRef, QStringRef>(); } + void indexOf_QStringRef_QStringView_data() { indexOf_data(); } + void indexOf_QStringRef_QStringView() { indexOf_impl<QStringRef, QStringView>(); } + + void indexOf_QStringView_QString_data() { indexOf_data(); } + void indexOf_QStringView_QString() { indexOf_impl<QStringView, QString>(); } + void indexOf_QStringView_QLatin1String_data() { indexOf_data(); } + void indexOf_QStringView_QLatin1String() { indexOf_impl<QStringView, QLatin1String>(); } + void indexOf_QStringView_QStringRef_data() { indexOf_data(); } + void indexOf_QStringView_QStringRef() { indexOf_impl<QStringView, QStringRef>(); } + void indexOf_QStringView_QStringView_data() { indexOf_data(); } + void indexOf_QStringView_QStringView() { indexOf_impl<QStringView, QStringView>(); } + +private: + template <typename Haystack, typename Needle> void contains_impl() const; + void contains_data(); + +private Q_SLOTS: + void contains_QString_QString_data() { contains_data(); } + void contains_QString_QString() { contains_impl<QString, QString>(); } + void contains_QString_QLatin1String_data() { contains_data(); } + void contains_QString_QLatin1String() { contains_impl<QString, QLatin1String>(); } + void contains_QString_QStringRef_data() { contains_data(); } + void contains_QString_QStringRef() { contains_impl<QString, QStringRef>(); } + void contains_QString_QStringView_data() { contains_data(); } + void contains_QString_QStringView() { contains_impl<QString, QStringView>(); } + + void contains_QLatin1String_QString_data() { contains_data(); } + void contains_QLatin1String_QString() { contains_impl<QLatin1String, QString>(); } + void contains_QLatin1String_QLatin1String_data() { contains_data(); } + void contains_QLatin1String_QLatin1String() { contains_impl<QLatin1String, QLatin1String>(); } + void contains_QLatin1String_QStringRef_data() { contains_data(); } + void contains_QLatin1String_QStringRef() { contains_impl<QLatin1String, QStringRef>(); } + void contains_QLatin1String_QStringView_data() { contains_data(); } + void contains_QLatin1String_QStringView() { contains_impl<QLatin1String, QStringView>(); } + + void contains_QStringRef_QString_data() { contains_data(); } + void contains_QStringRef_QString() { contains_impl<QStringRef, QString>(); } + void contains_QStringRef_QLatin1String_data() { contains_data(); } + void contains_QStringRef_QLatin1String() { contains_impl<QStringRef, QLatin1String>(); } + void contains_QStringRef_QStringRef_data() { contains_data(); } + void contains_QStringRef_QStringRef() { contains_impl<QStringRef, QStringRef>(); } + void contains_QStringRef_QStringView_data() { contains_data(); } + void contains_QStringRef_QStringView() { contains_impl<QStringRef, QStringView>(); } + + void contains_QStringView_QString_data() { contains_data(); } + void contains_QStringView_QString() { contains_impl<QStringView, QString>(); } + void contains_QStringView_QLatin1String_data() { contains_data(); } + void contains_QStringView_QLatin1String() { contains_impl<QStringView, QLatin1String>(); } + void contains_QStringView_QStringRef_data() { contains_data(); } + void contains_QStringView_QStringRef() { contains_impl<QStringView, QStringRef>(); } + void contains_QStringView_QStringView_data() { contains_data(); } + void contains_QStringView_QStringView() { contains_impl<QStringView, QStringView>(); } + +private: + template <typename Haystack, typename Needle> void lastIndexOf_impl() const; + void lastIndexOf_data(); + +private Q_SLOTS: + void lastIndexOf_QString_QString_data() { lastIndexOf_data(); } + void lastIndexOf_QString_QString() { lastIndexOf_impl<QString, QString>(); } + void lastIndexOf_QString_QLatin1String_data() { lastIndexOf_data(); } + void lastIndexOf_QString_QLatin1String() { lastIndexOf_impl<QString, QLatin1String>(); } + void lastIndexOf_QString_QStringRef_data() { lastIndexOf_data(); } + void lastIndexOf_QString_QStringRef() { lastIndexOf_impl<QString, QStringRef>(); } + void lastIndexOf_QString_QStringView_data() { lastIndexOf_data(); } + void lastIndexOf_QString_QStringView() { lastIndexOf_impl<QString, QStringView>(); } + + void lastIndexOf_QLatin1String_QString_data() { lastIndexOf_data(); } + void lastIndexOf_QLatin1String_QString() { lastIndexOf_impl<QLatin1String, QString>(); } + void lastIndexOf_QLatin1String_QLatin1String_data() { lastIndexOf_data(); } + void lastIndexOf_QLatin1String_QLatin1String() { lastIndexOf_impl<QLatin1String, QLatin1String>(); } + void lastIndexOf_QLatin1String_QStringRef_data() { lastIndexOf_data(); } + void lastIndexOf_QLatin1String_QStringRef() { lastIndexOf_impl<QLatin1String, QStringRef>(); } + void lastIndexOf_QLatin1String_QStringView_data() { lastIndexOf_data(); } + void lastIndexOf_QLatin1String_QStringView() { lastIndexOf_impl<QLatin1String, QStringView>(); } + + void lastIndexOf_QStringRef_QString_data() { lastIndexOf_data(); } + void lastIndexOf_QStringRef_QString() { lastIndexOf_impl<QStringRef, QString>(); } + void lastIndexOf_QStringRef_QLatin1String_data() { lastIndexOf_data(); } + void lastIndexOf_QStringRef_QLatin1String() { lastIndexOf_impl<QStringRef, QLatin1String>(); } + void lastIndexOf_QStringRef_QStringRef_data() { lastIndexOf_data(); } + void lastIndexOf_QStringRef_QStringRef() { lastIndexOf_impl<QStringRef, QStringRef>(); } + void lastIndexOf_QStringRef_QStringView_data() { lastIndexOf_data(); } + void lastIndexOf_QStringRef_QStringView() { lastIndexOf_impl<QStringRef, QStringView>(); } + + void lastIndexOf_QStringView_QString_data() { lastIndexOf_data(); } + void lastIndexOf_QStringView_QString() { lastIndexOf_impl<QStringView, QString>(); } + void lastIndexOf_QStringView_QLatin1String_data() { lastIndexOf_data(); } + void lastIndexOf_QStringView_QLatin1String() { lastIndexOf_impl<QStringView, QLatin1String>(); } + void lastIndexOf_QStringView_QStringRef_data() { lastIndexOf_data(); } + void lastIndexOf_QStringView_QStringRef() { lastIndexOf_impl<QStringView, QStringRef>(); } + void lastIndexOf_QStringView_QStringView_data() { lastIndexOf_data(); } + void lastIndexOf_QStringView_QStringView() { lastIndexOf_impl<QStringView, QStringView>(); } }; void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty) @@ -540,6 +692,7 @@ void tst_QStringApiSymmetry::compare_impl() const } static QString empty = QLatin1String(""); +static QString null; // the tests below rely on the fact that these objects' names match their contents: static QString a = QStringLiteral("a"); static QString A = QStringLiteral("A"); @@ -547,6 +700,14 @@ static QString b = QStringLiteral("b"); static QString B = QStringLiteral("B"); static QString c = QStringLiteral("c"); static QString C = QStringLiteral("C"); +static QString d = QStringLiteral("d"); +static QString D = QStringLiteral("D"); +static QString e = QStringLiteral("e"); +static QString E = QStringLiteral("E"); +static QString f = QStringLiteral("f"); +static QString F = QStringLiteral("F"); +static QString g = QStringLiteral("g"); +static QString G = QStringLiteral("G"); static QString ab = QStringLiteral("ab"); static QString aB = QStringLiteral("aB"); static QString Ab = QStringLiteral("Ab"); @@ -738,6 +899,119 @@ void tst_QStringApiSymmetry::endsWith_impl() const QCOMPARE(haystack.endsWith(needle, Qt::CaseInsensitive), resultCIS); } +void tst_QStringApiSymmetry::split_data(bool rhsHasVariableLength) +{ + QTest::addColumn<QStringRef>("haystackU16"); + QTest::addColumn<QLatin1String>("haystackL1"); + QTest::addColumn<QStringRef>("needleU16"); + QTest::addColumn<QLatin1String>("needleL1"); + QTest::addColumn<QStringList>("resultCS"); + QTest::addColumn<QStringList>("resultCIS"); + + if (rhsHasVariableLength) { + QTest::addRow("null ~= null$") << QStringRef{} << QLatin1String{} + << QStringRef{} << QLatin1String{} + << QStringList{{}, {}} << QStringList{{}, {}}; + QTest::addRow("empty ~= null$") << QStringRef{&empty} << QLatin1String("") + << QStringRef{} << QLatin1String{} + << QStringList{empty, empty} << QStringList{empty, empty}; + QTest::addRow("a ~= null$") << QStringRef{&a} << QLatin1String{"a"} + << QStringRef{} << QLatin1String{} + << QStringList{empty, a, empty} << QStringList{empty, a, empty}; + QTest::addRow("null ~= empty$") << QStringRef{} << QLatin1String{} + << QStringRef{&empty} << QLatin1String{""} + << QStringList{{}, {}} << QStringList{{}, {}}; + QTest::addRow("a ~= empty$") << QStringRef{&a} << QLatin1String{"a"} + << QStringRef{&empty} << QLatin1String{""} + << QStringList{empty, a, empty} << QStringList{empty, a, empty}; + QTest::addRow("empty ~= empty$") << QStringRef{&empty} << QLatin1String{""} + << QStringRef{&empty} << QLatin1String{""} + << QStringList{empty, empty} << QStringList{empty, empty}; + } + QTest::addRow("null ~= a$") << QStringRef{} << QLatin1String{} + << QStringRef{&a} << QLatin1String{"a"} + << QStringList{{}} << QStringList{{}}; + QTest::addRow("empty ~= a$") << QStringRef{&empty} << QLatin1String{""} + << QStringRef{&a} << QLatin1String{"a"} + << QStringList{empty} << QStringList{empty}; + +#define ROW(h, n, cs, cis) \ + QTest::addRow("%s ~= %s$", #h, #n) << QStringRef(&h) << QLatin1String(#h) \ + << QStringRef(&n) << QLatin1String(#n) \ + << QStringList cs << QStringList cis + ROW(a, a, ({empty, empty}), ({empty, empty})); + ROW(a, A, {a}, ({empty, empty})); + ROW(a, b, {a}, {a}); + + if (rhsHasVariableLength) + ROW(b, ab, {b}, {b}); + + ROW(ab, b, ({a, empty}), ({a, empty})); + if (rhsHasVariableLength) { + ROW(ab, ab, ({empty, empty}), ({empty, empty})); + ROW(ab, aB, {ab}, ({empty, empty})); + ROW(ab, Ab, {ab}, ({empty, empty})); + } + ROW(ab, c, {ab}, {ab}); + + if (rhsHasVariableLength) + ROW(bc, abc, {bc}, {bc}); + + ROW(Abc, c, ({Ab, empty}), ({Ab, empty})); +#if 0 + if (rhsHasVariableLength) { + ROW(Abc, bc, 1, 1); + ROW(Abc, bC, 0, 1); + ROW(Abc, Bc, 0, 1); + ROW(Abc, BC, 0, 1); + ROW(aBC, bc, 0, 1); + ROW(aBC, bC, 0, 1); + ROW(aBC, Bc, 0, 1); + ROW(aBC, BC, 1, 1); + } +#endif + ROW(ABC, b, {ABC}, ({A, C})); + ROW(ABC, a, {ABC}, ({empty, BC})); +#undef ROW +} + +static QStringList skipped(const QStringList &sl) +{ + QStringList result; + result.reserve(sl.size()); + for (const QString &s : sl) { + if (!s.isEmpty()) + result.push_back(s); + } + return result; +} + +template <typename Haystack, typename Needle> +void tst_QStringApiSymmetry::split_impl() const +{ + QFETCH(const QStringRef, haystackU16); + QFETCH(const QLatin1String, haystackL1); + QFETCH(const QStringRef, needleU16); + QFETCH(const QLatin1String, needleL1); + QFETCH(const QStringList, resultCS); + QFETCH(const QStringList, resultCIS); + + const QStringList skippedResultCS = skipped(resultCS); + const QStringList skippedResultCIS = skipped(resultCIS); + + const auto haystackU8 = haystackU16.toUtf8(); + const auto needleU8 = needleU16.toUtf8(); + + const auto haystack = make<Haystack>(haystackU16, haystackL1, haystackU8); + const auto needle = make<Needle>(needleU16, needleL1, needleU8); + + QCOMPARE(toQStringList(haystack.split(needle)), resultCS); + QCOMPARE(toQStringList(haystack.split(needle, Qt::KeepEmptyParts, Qt::CaseSensitive)), resultCS); + QCOMPARE(toQStringList(haystack.split(needle, Qt::KeepEmptyParts, Qt::CaseInsensitive)), resultCIS); + QCOMPARE(toQStringList(haystack.split(needle, Qt::SkipEmptyParts, Qt::CaseSensitive)), skippedResultCS); + QCOMPARE(toQStringList(haystack.split(needle, Qt::SkipEmptyParts, Qt::CaseInsensitive)), skippedResultCIS); +} + void tst_QStringApiSymmetry::mid_data() { QTest::addColumn<QStringRef>("unicode"); @@ -1216,6 +1490,296 @@ void tst_QStringApiSymmetry::toUcs4_impl() QCOMPARE(unicode.isEmpty(), ucs4.isEmpty()); } +void tst_QStringApiSymmetry::indexOf_data() +{ + QTest::addColumn<QString>("haystackU16"); + QTest::addColumn<QLatin1String>("haystackL1"); + QTest::addColumn<QString>("needleU16"); + QTest::addColumn<QLatin1String>("needleL1"); + QTest::addColumn<qsizetype>("startpos"); + QTest::addColumn<qsizetype>("resultCS"); + QTest::addColumn<qsizetype>("resultCIS"); + + constexpr qsizetype zeroPos = 0; + constexpr qsizetype minus1Pos = -1; + + QTest::addRow("haystack: null, needle: null") << null << QLatin1String() + << null << QLatin1String() << zeroPos << zeroPos << zeroPos; + QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") + << null << QLatin1String() << zeroPos << zeroPos << zeroPos; + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + << null << QLatin1String() << zeroPos << zeroPos << zeroPos; + QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() + << empty << QLatin1String("") << zeroPos << zeroPos << zeroPos; + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + << empty << QLatin1String("") << zeroPos << zeroPos << zeroPos; + QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") + << empty << QLatin1String("") << zeroPos << zeroPos << zeroPos; + QTest::addRow("haystack: empty, needle: a") << empty << QLatin1String("") + << a << QLatin1String("a") << zeroPos << minus1Pos << minus1Pos; + QTest::addRow("haystack: null, needle: a") << null << QLatin1String() + << a << QLatin1String("a") << zeroPos << minus1Pos << minus1Pos; + + +#define ROW(h, n, st, cs, cis) \ + QTest::addRow("haystack: %s, needle: %s", #h, #n) << h << QLatin1String(#h) \ + << n << QLatin1String(#n) \ + << qsizetype(st) << qsizetype(cs) << qsizetype(cis) + + ROW(abc, a, 0, 0, 0); + ROW(abc, A, 0, -1, 0); + ROW(abc, a, 1, -1, -1); + ROW(abc, A, 1, -1, -1); + ROW(abc, b, 0, 1, 1); + ROW(abc, B, 0, -1, 1); + ROW(abc, b, 1, 1, 1); + ROW(abc, B, 1, -1, 1); + ROW(abc, B, 2, -1, -1); + + ROW(ABC, A, 0, 0, 0); + ROW(ABC, a, 0, -1, 0); + ROW(ABC, A, 1, -1, -1); + ROW(ABC, a, 1, -1, -1); + ROW(ABC, B, 0, 1, 1); + ROW(ABC, b, 0, -1, 1); + ROW(ABC, B, 1, 1, 1); + ROW(ABC, b, 1, -1, 1); + ROW(ABC, B, 2, -1, -1); + + ROW(aBc, bc, 0, -1, 1); + ROW(aBc, Bc, 0, 1, 1); + ROW(aBc, bC, 0, -1, 1); + ROW(aBc, BC, 0, -1, 1); + + ROW(AbC, bc, 0, -1, 1); + ROW(AbC, Bc, 0, -1, 1); + ROW(AbC, bC, 0, 1, 1); + ROW(AbC, BC, 0, -1, 1); + ROW(AbC, BC, 1, -1, 1); + ROW(AbC, BC, 2, -1, -1); +#undef ROW + +} + +template <typename Haystack, typename Needle> +void tst_QStringApiSymmetry::indexOf_impl() const +{ + QFETCH(const QString, haystackU16); + QFETCH(const QLatin1String, haystackL1); + QFETCH(const QString, needleU16); + QFETCH(const QLatin1String, needleL1); + QFETCH(const qsizetype, startpos); + QFETCH(const qsizetype, resultCS); + QFETCH(const qsizetype, resultCIS); + + const auto haystackU8 = haystackU16.toUtf8(); + const auto needleU8 = needleU16.toUtf8(); + + const auto haystack = make<Haystack>(QStringRef(&haystackU16), haystackL1, haystackU8); + const auto needle = make<Needle>(QStringRef(&needleU16), needleL1, needleU8); + + using size_type = typename Haystack::size_type; + + QCOMPARE(haystack.indexOf(needle, startpos), size_type(resultCS)); + QCOMPARE(haystack.indexOf(needle, startpos, Qt::CaseSensitive), size_type(resultCS)); + QCOMPARE(haystack.indexOf(needle, startpos, Qt::CaseInsensitive), size_type(resultCIS)); + + if (needle.size() == 1) + { + QCOMPARE(haystack.indexOf(needle[0], startpos), size_type(resultCS)); + QCOMPARE(haystack.indexOf(needle[0], startpos, Qt::CaseSensitive), size_type(resultCS)); + QCOMPARE(haystack.indexOf(needle[0], startpos, Qt::CaseInsensitive), size_type(resultCIS)); + } +} + +static QString ABCDEFGHIEfGEFG = QStringLiteral("ABCDEFGHIEfGEFG"); +static QString EFG = QStringLiteral("EFG"); +static QString efg = QStringLiteral("efg"); +static QString asd = QStringLiteral("asd"); +static QString asdf = QStringLiteral("asdf"); +static QString Z = QStringLiteral("Z"); + +void tst_QStringApiSymmetry::contains_data() +{ + QTest::addColumn<QString>("haystackU16"); + QTest::addColumn<QLatin1String>("haystackL1"); + QTest::addColumn<QString>("needleU16"); + QTest::addColumn<QLatin1String>("needleL1"); + QTest::addColumn<bool>("resultCS"); + QTest::addColumn<bool>("resultCIS"); + + QTest::addRow("haystack: null, needle: null") << null << QLatin1String() + << null << QLatin1String() << true << true; + QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") + << null << QLatin1String() << true << true; + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + << null << QLatin1String() << true << true; + QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() + << empty << QLatin1String("") << true << true; + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + << empty << QLatin1String("") << true << true;; + QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") + << empty << QLatin1String("") << true << true; + QTest::addRow("haystack: empty, needle: a") << empty << QLatin1String("") + << a << QLatin1String("a") << false << false; + QTest::addRow("haystack: null, needle: a") << null << QLatin1String() + << a << QLatin1String("a") << false << false; + +#define ROW(h, n, cs, cis) \ + QTest::addRow("haystack: %s, needle: %s", #h, #n) << h << QLatin1String(#h) \ + << n << QLatin1String(#n) \ + << cs << cis + + ROW(ABCDEFGHIEfGEFG, A, true, true); + ROW(ABCDEFGHIEfGEFG, a, false, true); + ROW(ABCDEFGHIEfGEFG, Z, false, false); + ROW(ABCDEFGHIEfGEFG, EFG, true, true); + ROW(ABCDEFGHIEfGEFG, efg, false, true); + ROW(ABCDEFGHIEfGEFG, E, true, true); + ROW(ABCDEFGHIEfGEFG, e, false, true); +#undef ROW +} + +template <typename Haystack, typename Needle> +void tst_QStringApiSymmetry::contains_impl() const +{ + QFETCH(const QString, haystackU16); + QFETCH(const QLatin1String, haystackL1); + QFETCH(const QString, needleU16); + QFETCH(const QLatin1String, needleL1); + QFETCH(const bool, resultCS); + QFETCH(const bool, resultCIS); + + const auto haystackU8 = haystackU16.toUtf8(); + const auto needleU8 = needleU16.toUtf8(); + + const auto haystack = make<Haystack>(QStringRef(&haystackU16), haystackL1, haystackU8); + const auto needle = make<Needle>(QStringRef(&needleU16), needleL1, needleU8); + + QCOMPARE(haystack.contains(needle), resultCS); + QCOMPARE(haystack.contains(needle, Qt::CaseSensitive), resultCS); + QCOMPARE(haystack.contains(needle, Qt::CaseInsensitive), resultCIS); + + if (needle.size() == 1) + { + QCOMPARE(haystack.contains(needle[0]), resultCS); + QCOMPARE(haystack.contains(needle[0], Qt::CaseSensitive), resultCS); + QCOMPARE(haystack.contains(needle[0], Qt::CaseInsensitive), resultCIS); + } +} + +void tst_QStringApiSymmetry::lastIndexOf_data() +{ + QTest::addColumn<QString>("haystackU16"); + QTest::addColumn<QLatin1String>("haystackL1"); + QTest::addColumn<QString>("needleU16"); + QTest::addColumn<QLatin1String>("needleL1"); + QTest::addColumn<qsizetype>("startpos"); + QTest::addColumn<qsizetype>("resultCS"); + QTest::addColumn<qsizetype>("resultCIS"); + + constexpr qsizetype zeroPos = 0; + constexpr qsizetype minus1Pos = -1; + + QTest::addRow("haystack: null, needle: null") << null << QLatin1String() + << null << QLatin1String() << minus1Pos << minus1Pos << minus1Pos; + QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") + << null << QLatin1String() << minus1Pos << minus1Pos << minus1Pos; + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + << null << QLatin1String() << minus1Pos << zeroPos << zeroPos; + QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() + << empty << QLatin1String("") << minus1Pos << minus1Pos << minus1Pos; + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + << empty << QLatin1String("") << minus1Pos << zeroPos << zeroPos; + QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") + << empty << QLatin1String("") << minus1Pos << minus1Pos << minus1Pos; + QTest::addRow("haystack: empty, needle: a") << empty << QLatin1String("") + << a << QLatin1String("a") << minus1Pos << minus1Pos << minus1Pos; + QTest::addRow("haystack: null, needle: a") << null << QLatin1String() + << a << QLatin1String("a") << minus1Pos << minus1Pos << minus1Pos; + + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + << null << QLatin1String() << qsizetype(1) << qsizetype(1) << qsizetype(1); + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + << empty << QLatin1String("") << qsizetype(1) << qsizetype(1) << qsizetype(1); + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + << null << QLatin1String() << qsizetype(2) << minus1Pos << minus1Pos; + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + << empty << QLatin1String("") << qsizetype(2) << minus1Pos << minus1Pos; + +#define ROW(h, n, st, cs, cis) \ + QTest::addRow("haystack: %s, needle: %s", #h, #n) << h << QLatin1String(#h) \ + << n << QLatin1String(#n) \ + << qsizetype(st) << qsizetype(cs) << qsizetype(cis) + + ROW(asd, asdf, -1, -1, -1); + + ROW(ABCDEFGHIEfGEFG, G, -1, 14, 14); + ROW(ABCDEFGHIEfGEFG, g, -1, -1, 14); + ROW(ABCDEFGHIEfGEFG, G, -3, 11, 11); + ROW(ABCDEFGHIEfGEFG, g, -3, -1, 11); + ROW(ABCDEFGHIEfGEFG, G, -5, 6, 6); + ROW(ABCDEFGHIEfGEFG, g, -5, -1, 6); + ROW(ABCDEFGHIEfGEFG, G, 14, 14, 14); + ROW(ABCDEFGHIEfGEFG, g, 14, -1, 14); + ROW(ABCDEFGHIEfGEFG, G, 13, 11, 11); + ROW(ABCDEFGHIEfGEFG, g, 13, -1, 11); + ROW(ABCDEFGHIEfGEFG, G, 15, -1, -1); + ROW(ABCDEFGHIEfGEFG, g, 15, -1, -1); + ROW(ABCDEFGHIEfGEFG, B, 14, 1, 1); + ROW(ABCDEFGHIEfGEFG, b, 14, -1, 1); + ROW(ABCDEFGHIEfGEFG, B, -1, 1, 1); + ROW(ABCDEFGHIEfGEFG, b, -1, -1, 1); + ROW(ABCDEFGHIEfGEFG, B, 1, 1, 1); + ROW(ABCDEFGHIEfGEFG, b, 1, -1, 1); + ROW(ABCDEFGHIEfGEFG, B, 0, -1, -1); + ROW(ABCDEFGHIEfGEFG, b, 0, -1, -1); + ROW(ABCDEFGHIEfGEFG, A, 0, 0, 0); + ROW(ABCDEFGHIEfGEFG, a, 0, -1, 0); + ROW(ABCDEFGHIEfGEFG, A, -15, 0, 0); + ROW(ABCDEFGHIEfGEFG, a, -15, -1, 0); + + ROW(ABCDEFGHIEfGEFG, efg, 0, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, 15, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, -15, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, 14, -1, 12); + ROW(ABCDEFGHIEfGEFG, efg, 12, -1, 12); + ROW(ABCDEFGHIEfGEFG, efg, -12, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, 11, -1, 9); +#undef ROW +} + +template <typename Haystack, typename Needle> +void tst_QStringApiSymmetry::lastIndexOf_impl() const +{ + QFETCH(const QString, haystackU16); + QFETCH(const QLatin1String, haystackL1); + QFETCH(const QString, needleU16); + QFETCH(const QLatin1String, needleL1); + QFETCH(const qsizetype, startpos); + QFETCH(const qsizetype, resultCS); + QFETCH(const qsizetype, resultCIS); + + const auto haystackU8 = haystackU16.toUtf8(); + const auto needleU8 = needleU16.toUtf8(); + + const auto haystack = make<Haystack>(QStringRef(&haystackU16), haystackL1, haystackU8); + const auto needle = make<Needle>(QStringRef(&needleU16), needleL1, needleU8); + + using size_type = typename Haystack::size_type; + + QCOMPARE(haystack.lastIndexOf(needle, startpos), size_type(resultCS)); + QCOMPARE(haystack.lastIndexOf(needle, startpos, Qt::CaseSensitive), size_type(resultCS)); + QCOMPARE(haystack.lastIndexOf(needle, startpos, Qt::CaseInsensitive), size_type(resultCIS)); + + if (needle.size() == 1) + { + QCOMPARE(haystack.lastIndexOf(needle[0], startpos), size_type(resultCS)); + QCOMPARE(haystack.lastIndexOf(needle[0], startpos, Qt::CaseSensitive), size_type(resultCS)); + QCOMPARE(haystack.lastIndexOf(needle[0], startpos, Qt::CaseInsensitive), size_type(resultCIS)); + } +} + QTEST_APPLESS_MAIN(tst_QStringApiSymmetry) #include "tst_qstringapisymmetry.moc" diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 42bdf62a93..2b5aa8e98b 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -30,13 +30,17 @@ #include <qregexp.h> #include <qregularexpression.h> #include <qstringlist.h> +#include <qvector.h> #include <locale.h> +#include <algorithm> + class tst_QStringList : public QObject { Q_OBJECT private slots: + void constructors(); void sort(); void filter(); void replaceInStrings(); @@ -59,13 +63,44 @@ private slots: void joinChar() const; void joinChar_data() const; -#ifdef Q_COMPILER_INITIALIZER_LISTS void initializeList() const; -#endif }; extern const char email[]; +void tst_QStringList::constructors() +{ + { + QStringList list; + QVERIFY(list.isEmpty()); + QCOMPARE(list.size(), 0); + QVERIFY(list == QStringList()); + } + { + QString str = "abc"; + QStringList list(str); + QVERIFY(!list.isEmpty()); + QCOMPARE(list.size(), 1); + QCOMPARE(list.at(0), str); + } + { + QStringList list{ "a", "b", "c" }; + QVERIFY(!list.isEmpty()); + QCOMPARE(list.size(), 3); + QCOMPARE(list.at(0), "a"); + QCOMPARE(list.at(1), "b"); + QCOMPARE(list.at(2), "c"); + } + { + const QVector<QString> reference{ "a", "b", "c" }; + QCOMPARE(reference.size(), 3); + + QStringList list(reference.cbegin(), reference.cend()); + QCOMPARE(list.size(), reference.size()); + QVERIFY(std::equal(list.cbegin(), list.cend(), reference.cbegin())); + } +} + void tst_QStringList::indexOf_regExp() { QStringList list; @@ -482,8 +517,6 @@ void tst_QStringList::joinEmptiness() const QVERIFY(string.isNull()); } -#ifdef Q_COMPILER_INITIALIZER_LISTS -// C++0x support is required void tst_QStringList::initializeList() const { @@ -491,7 +524,6 @@ void tst_QStringList::initializeList() const QCOMPARE(v1, (QStringList() << "hello" << "world" << "plop")); QCOMPARE(v1, (QStringList{"hello","world","plop"})); } -#endif QTEST_APPLESS_MAIN(tst_QStringList) #include "tst_qstringlist.moc" diff --git a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp index 8a55f54449..2d577bb0ab 100644 --- a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp +++ b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp @@ -100,6 +100,11 @@ void tst_QStringMatcher::indexIn() matcher.setPattern(needle); QCOMPARE(matcher.indexIn(haystack, from), indexIn); + + const auto needleSV = QStringView(needle); + QStringMatcher matcherSV(needleSV); + + QCOMPARE(matcherSV.indexIn(QStringView(haystack), from), indexIn); } void tst_QStringMatcher::setCaseSensitivity_data() @@ -128,6 +133,7 @@ void tst_QStringMatcher::setCaseSensitivity() matcher.setCaseSensitivity(static_cast<Qt::CaseSensitivity> (cs)); QCOMPARE(matcher.indexIn(haystack, from), indexIn); + QCOMPARE(matcher.indexIn(QStringView(haystack), from), indexIn); } void tst_QStringMatcher::assignOperator() diff --git a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp index e800a0d794..794f39708a 100644 --- a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp @@ -134,6 +134,8 @@ private Q_SLOTS: void literals() const; void at() const; + void arg() const; + void fromQString() const; void fromQStringRef() const; @@ -425,6 +427,47 @@ void tst_QStringView::at() const QCOMPARE(sv.at(4), QChar('o')); QCOMPARE(sv[4], QChar('o')); } +void tst_QStringView::arg() const +{ +#define CHECK1(pattern, arg1, expected) \ + do { \ + auto p = QStringViewLiteral(pattern); \ + QCOMPARE(p.arg(QLatin1String(arg1)), expected); \ + QCOMPARE(p.arg(QStringViewLiteral(arg1)), expected); \ + QCOMPARE(p.arg(QStringLiteral(arg1)), expected); \ + QCOMPARE(p.arg(QString(QLatin1String(arg1))), expected); \ + } while (false) \ + /*end*/ +#define CHECK2(pattern, arg1, arg2, expected) \ + do { \ + auto p = QStringViewLiteral(pattern); \ + QCOMPARE(p.arg(QLatin1String(arg1), QLatin1String(arg2)), expected); \ + QCOMPARE(p.arg(QStringViewLiteral(arg1), QLatin1String(arg2)), expected); \ + QCOMPARE(p.arg(QLatin1String(arg1), QStringViewLiteral(arg2)), expected); \ + QCOMPARE(p.arg(QStringViewLiteral(arg1), QStringViewLiteral(arg2)), expected); \ + } while (false) \ + /*end*/ + + CHECK1("", "World", ""); + CHECK1("%1", "World", "World"); + CHECK1("!%1?", "World", "!World?"); + CHECK1("%1%1", "World", "WorldWorld"); + CHECK1("%1%2", "World", "World%2"); + CHECK1("%2%1", "World", "%2World"); + + CHECK2("", "Hello", "World", ""); + CHECK2("%1", "Hello", "World", "Hello"); + CHECK2("!%1, %2?", "Hello", "World", "!Hello, World?"); + CHECK2("%1%1", "Hello", "World", "HelloHello"); + CHECK2("%1%2", "Hello", "World", "HelloWorld"); + CHECK2("%2%1", "Hello", "World", "WorldHello"); + +#undef CHECK2 +#undef CHECK1 + + QCOMPARE(QStringViewLiteral(" %2 %2 %1 %3 ").arg(QLatin1Char('c'), QChar::CarriageReturn, u'C'), " \r \r c C "); +} + void tst_QStringView::fromQString() const { QString null; diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 5737db760c..fff8c75a90 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -908,7 +908,6 @@ void tst_QVarLengthArray::initializeListComplex() template<typename T> void tst_QVarLengthArray::initializeList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS T val1(110); T val2(105); T val3(101); @@ -945,9 +944,6 @@ void tst_QVarLengthArray::initializeList() v6 = {}; // assign empty QCOMPARE(v6.size(), 0); -#else - QSKIP("This tests requires a compiler that supports initializer lists."); -#endif } void tst_QVarLengthArray::insertMove() diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index a7faeb5ca5..3256130472 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -206,6 +206,9 @@ private slots: void assignmentInt() const; void assignmentMovable() const; void assignmentCustom() const; + void assignFromInitializerListInt() const; + void assignFromInitializerListMovable() const; + void assignFromInitializerListCustom() const; void addInt() const; void addMovable() const; void addCustom() const; @@ -254,7 +257,6 @@ private slots: void fromListInt() const; void fromListMovable() const; void fromListCustom() const; - void fromStdVector() const; void indexOf() const; void insertInt() const; void insertMovable() const; @@ -293,7 +295,10 @@ private slots: void swapMovable() const; void swapCustom() const; void toList() const; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + void fromStdVector() const; void toStdVector() const; +#endif void value() const; void testOperators() const; @@ -326,10 +331,13 @@ private slots: void insertMove() const; + void swapItemsAt() const; + private: template<typename T> void copyConstructor() const; template<typename T> void add() const; template<typename T> void append() const; + template<typename T> void assignFromInitializerList() const; template<typename T> void capacity() const; template<typename T> void clear() const; template<typename T> void count() const; @@ -543,6 +551,40 @@ void tst_QVector::assignmentCustom() const } template<typename T> +void tst_QVector::assignFromInitializerList() const +{ + T val1(SimpleValue<T>::at(1)); + T val2(SimpleValue<T>::at(2)); + T val3(SimpleValue<T>::at(3)); + + QVector<T> v1 = {val1, val2, val3}; + QCOMPARE(v1, QVector<T>() << val1 << val2 << val3); + QCOMPARE(v1, (QVector<T> {val1, val2, val3})); + + v1 = {}; + QCOMPARE(v1.size(), 0); +} + +void tst_QVector::assignFromInitializerListInt() const +{ + assignFromInitializerList<int>(); +} + +void tst_QVector::assignFromInitializerListMovable() const +{ + const int instancesCount = Movable::counter.loadAcquire(); + assignFromInitializerList<Movable>(); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); +} + +void tst_QVector::assignFromInitializerListCustom() const +{ + const int instancesCount = Custom::counter.loadAcquire(); + assignFromInitializerList<Custom>(); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); +} + +template<typename T> void tst_QVector::add() const { { @@ -667,7 +709,6 @@ void tst_QVector::appendCustom() const void tst_QVector::appendRvalue() const { -#ifdef Q_COMPILER_RVALUE_REFS QVector<QString> v; v.append("hello"); QString world = "world"; @@ -675,9 +716,6 @@ void tst_QVector::appendRvalue() const QVERIFY(world.isEmpty()); QCOMPARE(v.front(), QString("hello")); QCOMPARE(v.back(), QString("world")); -#else - QSKIP("This test requires that C++11 move semantics support is enabled in the compiler"); -#endif } void tst_QVector::at() const @@ -1392,6 +1430,7 @@ void tst_QVector::fromListCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void tst_QVector::fromStdVector() const { // stl = :( @@ -1405,6 +1444,7 @@ void tst_QVector::fromStdVector() const // test it converts ok QCOMPARE(myvec, QVector<QString>() << "aaa" << "bbb" << "ninjas" << "pirates"); } +#endif void tst_QVector::indexOf() const { @@ -2297,6 +2337,7 @@ void tst_QVector::toList() const QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C"); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void tst_QVector::toStdVector() const { QVector<QString> myvec; @@ -2309,6 +2350,7 @@ void tst_QVector::toStdVector() const QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C"); } +#endif void tst_QVector::value() const { @@ -2515,7 +2557,6 @@ void tst_QVector::reallocAfterCopy() template<typename T> void tst_QVector::initializeList() { -#ifdef Q_COMPILER_INITIALIZER_LISTS T val1(SimpleValue<T>::at(1)); T val2(SimpleValue<T>::at(2)); T val3(SimpleValue<T>::at(3)); @@ -2532,7 +2573,6 @@ void tst_QVector::initializeList() QVector<T> v4({}); QCOMPARE(v4.size(), 0); -#endif } void tst_QVector::initializeListInt() @@ -2842,7 +2882,7 @@ void tst_QVector::detachThreadSafety() const struct : QThread { void run() override { - QVector<T> copy(*detachThreadSafetyData<T>()->load()); + QVector<T> copy(*detachThreadSafetyData<T>()->loadRelaxed()); QVERIFY(!copy.isDetached()); detachThreadSafetyLock.release(); detachThreadSafetyLock.acquire(100); @@ -2952,5 +2992,22 @@ void tst_QVector::insertMove() const QCOMPARE(Movable::counter.loadAcquire(), instancesCount); } +void tst_QVector::swapItemsAt() const +{ + QVector<int> v; + v << 0 << 1 << 2 << 3; + + v.swapItemsAt(0, 2); + QCOMPARE(v.at(0), 2); + QCOMPARE(v.at(2), 0); + + auto copy = v; + copy.swapItemsAt(0, 2); + QCOMPARE(v.at(0), 2); + QCOMPARE(v.at(2), 0); + QCOMPARE(copy.at(0), 0); + QCOMPARE(copy.at(2), 2); +} + QTEST_MAIN(tst_QVector) #include "tst_qvector.moc" diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index 05579dce6e..7c4d1071ce 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -260,12 +260,10 @@ void tst_QVersionNumber::constructorExplicit() QCOMPARE(v5.segments(), v6.segments()); -#ifdef Q_COMPILER_INITIALIZER_LISTS QVersionNumber v7(4, 5, 6); QVersionNumber v8 = {4, 5, 6}; QCOMPARE(v7.segments(), v8.segments()); -#endif } void tst_QVersionNumber::constructorCopy_data() @@ -436,7 +434,7 @@ void tst_QVersionNumber::normalized() QFETCH(QVersionNumber, expected); QCOMPARE(version.normalized(), expected); - QCOMPARE(qMove(version).normalized(), expected); + QCOMPARE(std::move(version).normalized(), expected); } void tst_QVersionNumber::isNormalized_data() @@ -586,30 +584,28 @@ void tst_QVersionNumber::serialize() void tst_QVersionNumber::moveSemantics() { -#ifdef Q_COMPILER_RVALUE_REFS // QVersionNumber(QVersionNumber &&) { QVersionNumber v1(1, 2, 3); - QVersionNumber v2 = qMove(v1); + QVersionNumber v2 = std::move(v1); QCOMPARE(v2, QVersionNumber(1, 2, 3)); } // QVersionNumber &operator=(QVersionNumber &&) { QVersionNumber v1(1, 2, 3); QVersionNumber v2; - v2 = qMove(v1); + v2 = std::move(v1); QCOMPARE(v2, QVersionNumber(1, 2, 3)); } // QVersionNumber(QVector<int> &&) { QVector<int> segments = QVector<int>() << 1 << 2 << 3; QVersionNumber v1(segments); - QVersionNumber v2(qMove(segments)); + QVersionNumber v2(std::move(segments)); QVERIFY(!v1.isNull()); QVERIFY(!v2.isNull()); QCOMPARE(v1, v2); } -#endif #ifdef Q_COMPILER_REF_QUALIFIERS // normalized() { @@ -620,7 +616,7 @@ void tst_QVersionNumber::moveSemantics() QVERIFY(!v.isNull()); QVERIFY(!nv.isNull()); QVERIFY(nv.isNormalized()); - nv = qMove(v).normalized(); + nv = std::move(v).normalized(); QVERIFY(!nv.isNull()); QVERIFY(nv.isNormalized()); } @@ -632,13 +628,10 @@ void tst_QVersionNumber::moveSemantics() segments = v.segments(); QVERIFY(!v.isNull()); QVERIFY(!segments.empty()); - segments = qMove(v).segments(); + segments = std::move(v).segments(); QVERIFY(!segments.empty()); } #endif -#if !defined(Q_COMPILER_RVALUE_REFS) && !defined(Q_COMPILER_REF_QUALIFIERS) - QSKIP("This test requires C++11 move semantics support in the compiler."); -#endif } void tst_QVersionNumber::qtVersion() diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 2a975e67d1..243e7e96f5 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -16,8 +16,6 @@ SUBDIRS=\ qcommandlineparser \ qcontiguouscache \ qcryptographichash \ - qdate \ - qdatetime \ qeasingcurve \ qexplicitlyshareddatapointer \ qfreelist \ @@ -46,6 +44,7 @@ SUBDIRS=\ qringbuffer \ qscopedpointer \ qscopedvaluerollback \ + qscopeguard \ qset \ qsharedpointer \ qsize \ @@ -61,8 +60,6 @@ SUBDIRS=\ qstringref \ qstringview \ qtextboundaryfinder \ - qtime \ - qtimezone \ qtimeline \ qvarlengtharray \ qvector \ diff --git a/tests/auto/dbus/qdbusthreading/tst_qdbusthreading.cpp b/tests/auto/dbus/qdbusthreading/tst_qdbusthreading.cpp index 018b7c2a35..b4690268c8 100644 --- a/tests/auto/dbus/qdbusthreading/tst_qdbusthreading.cpp +++ b/tests/auto/dbus/qdbusthreading/tst_qdbusthreading.cpp @@ -197,8 +197,8 @@ tst_QDBusThreading::tst_QDBusThreading() void tst_QDBusThreading::joinThreads() { - threadJoin.acquire(threadJoinCount.load()); - threadJoinCount.store(0); + threadJoin.acquire(threadJoinCount.loadRelaxed()); + threadJoinCount.storeRelaxed(0); } bool tst_QDBusThreading::waitForSignal(QObject *obj, const char *signal, int delay) diff --git a/tests/auto/gui/gui.pro b/tests/auto/gui/gui.pro index e0c8123f26..c90fc48251 100644 --- a/tests/auto/gui/gui.pro +++ b/tests/auto/gui/gui.pro @@ -13,6 +13,7 @@ SUBDIRS = \ text \ util \ itemmodels \ + rhi !qtConfig(opengl)|winrt: SUBDIRS -= qopengl qopenglconfig diff --git a/tests/auto/gui/image/qimage/qimage.pro b/tests/auto/gui/image/qimage/qimage.pro index b40866892e..0593cfbc23 100644 --- a/tests/auto/gui/image/qimage/qimage.pro +++ b/tests/auto/gui/image/qimage/qimage.pro @@ -7,7 +7,7 @@ qtConfig(c++11): CONFIG += c++11 android:!android-embedded: RESOURCES += qimage.qrc -win32:!winrt: LIBS += -lgdi32 -luser32 +win32:!winrt: QMAKE_USE += user32 gdi32 darwin: LIBS += -framework CoreGraphics TESTDATA += images/* diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 4d41b5e873..441ec17412 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -1852,7 +1852,9 @@ void tst_QImage::smoothScale4_data() QTest::addColumn<QImage::Format>("format"); QTest::newRow("RGB32") << QImage::Format_RGB32; +#if QT_CONFIG(raster_64bit) QTest::newRow("RGBx64") << QImage::Format_RGBX64; +#endif } void tst_QImage::smoothScale4() @@ -3403,7 +3405,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("rgb32 -> rgb666 (dithering)") << rgb32 << QImage::Format_RGB666 << int(Qt::PreferDither | Qt::OrderedDither) << 129; // Test we get the same results for opaque input in the ARGBPM implementation. - rgb32 = qMove(rgb32).convertToFormat(QImage::Format_ARGB32_Premultiplied); + rgb32 = std::move(rgb32).convertToFormat(QImage::Format_ARGB32_Premultiplied); QTest::newRow("argb32pm -> argb4444pm (no dither)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << 0 << 16; QTest::newRow("argb32pm -> rgb444 (dithering)") << rgb32 << QImage::Format_RGB444 << int(Qt::PreferDither | Qt::OrderedDither) << 33; QTest::newRow("argb32pm -> argb4444pm (dithering)") << rgb32 << QImage::Format_ARGB4444_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 33; @@ -3412,6 +3414,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("argb32pm -> argb6666pm (no dither)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << 0 << 64; QTest::newRow("argb32pm -> argb6666pm (dithering)") << rgb32 << QImage::Format_ARGB6666_Premultiplied << int(Qt::PreferDither | Qt::OrderedDither) << 129; +#if QT_CONFIG(raster_64bit) QImage rgb30(1024, 16, QImage::Format_RGB30); QLinearGradient gradient30(QRectF(rgb30.rect()).topLeft(), QRectF(rgb30.rect()).topRight()); gradient30.setColorAt(0.0, QColor(0, 0, 0)); @@ -3424,6 +3427,7 @@ void tst_QImage::ditherGradient_data() QTest::newRow("rgb30 -> rgb32 (dithering)") << rgb30 << QImage::Format_RGB32 << int(Qt::PreferDither | Qt::OrderedDither) << 513; QTest::newRow("rgb30 -> rgb888 (no dither)") << rgb30 << QImage::Format_RGB888 << 0 << 256; QTest::newRow("rgb30 -> rgb888 (dithering)") << rgb30 << QImage::Format_RGB888 << int(Qt::PreferDither | Qt::OrderedDither) << 513; +#endif } void tst_QImage::ditherGradient() diff --git a/tests/auto/gui/image/qpixmap/qpixmap.pro b/tests/auto/gui/image/qpixmap/qpixmap.pro index e6a020af1a..c9219dad1d 100644 --- a/tests/auto/gui/image/qpixmap/qpixmap.pro +++ b/tests/auto/gui/image/qpixmap/qpixmap.pro @@ -5,7 +5,7 @@ QT += core-private gui-private testlib qtHaveModule(widgets): QT += widgets widgets-private SOURCES += tst_qpixmap.cpp -win32:!winrt:LIBS += -lgdi32 -luser32 +win32:!winrt: QMAKE_USE += user32 gdi32 RESOURCES += qpixmap.qrc TESTDATA += convertFromImage/* convertFromToHICON/* loadFromData/* images/* diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index 550f70890e..bc8bc38da6 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -734,7 +734,7 @@ void tst_QStandardItemModel::data() currentRoles.clear(); // bad args m_model->setData(QModelIndex(), "bla", Qt::DisplayRole); - QCOMPARE(currentRoles, {}); + QCOMPARE(currentRoles, QVector<int>{}); QIcon icon; for (int r=0; r < m_model->rowCount(); ++r) { @@ -742,9 +742,9 @@ void tst_QStandardItemModel::data() m_model->setData(m_model->index(r,c), "initialitem", Qt::DisplayRole); QCOMPARE(currentRoles, QVector<int>({Qt::DisplayRole, Qt::EditRole})); m_model->setData(m_model->index(r,c), "tooltip", Qt::ToolTipRole); - QCOMPARE(currentRoles, {Qt::ToolTipRole}); + QCOMPARE(currentRoles, QVector<int>{Qt::ToolTipRole}); m_model->setData(m_model->index(r,c), icon, Qt::DecorationRole); - QCOMPARE(currentRoles, {Qt::DecorationRole}); + QCOMPARE(currentRoles, QVector<int>{Qt::DecorationRole}); } } @@ -761,7 +761,7 @@ void tst_QStandardItemModel::clearItemData() { currentRoles.clear(); QVERIFY(!m_model->clearItemData(QModelIndex())); - QCOMPARE(currentRoles, {}); + QCOMPARE(currentRoles, QVector<int>{}); const QModelIndex idx = m_model->index(0, 0); const QMap<int, QVariant> oldData = m_model->itemData(idx); m_model->setData(idx, QLatin1String("initialitem"), Qt::DisplayRole); @@ -773,7 +773,7 @@ void tst_QStandardItemModel::clearItemData() QCOMPARE(idx.data(Qt::ToolTipRole), QVariant()); QCOMPARE(idx.data(Qt::DisplayRole), QVariant()); QCOMPARE(idx.data(Qt::EditRole), QVariant()); - QCOMPARE(currentRoles, {}); + QCOMPARE(currentRoles, QVector<int>{}); m_model->setItemData(idx, oldData); currentRoles.clear(); } diff --git a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro index 7e98704aea..293a6a8581 100644 --- a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro +++ b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro @@ -5,4 +5,4 @@ QT += core-private network gui-private testlib SOURCES += tst_noqteventloop.cpp -qtConfig(dynamicgl):win32:!winrt: LIBS += -luser32 +qtConfig(dynamicgl):win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro index 895c2a0307..34b75a8397 100644 --- a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro +++ b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro @@ -6,6 +6,7 @@ INCLUDEPATH += $$CORE_TEST_PATH TARGET = tst_qguiapplication QT += gui-private +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050E00 SOURCES += tst_qguiapplication.cpp RESOURCES = tst_qguiapplication.qrc diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index a304981cd1..5ee25677bf 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -184,7 +184,7 @@ void tst_QGuiApplication::windowIcon() class DummyWindow : public QWindow { public: - DummyWindow() : m_focusObject(0) {} + DummyWindow() : m_focusObject(nullptr) {} virtual QObject *focusObject() const { @@ -204,7 +204,7 @@ public: void tst_QGuiApplication::focusObject() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) QSKIP("QWindow::requestActivate() is not supported."); @@ -271,15 +271,15 @@ void tst_QGuiApplication::focusObject() void tst_QGuiApplication::allWindows() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); QWindow *window1 = new QWindow; QWindow *window2 = new QWindow(window1); QVERIFY(app.allWindows().contains(window1)); QVERIFY(app.allWindows().contains(window2)); QCOMPARE(app.allWindows().count(), 2); delete window1; - window1 = 0; - window2 = 0; + window1 = nullptr; + window2 = nullptr; QVERIFY(!app.allWindows().contains(window2)); QVERIFY(!app.allWindows().contains(window1)); QCOMPARE(app.allWindows().count(), 0); @@ -288,15 +288,15 @@ void tst_QGuiApplication::allWindows() void tst_QGuiApplication::topLevelWindows() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); QWindow *window1 = new QWindow; QWindow *window2 = new QWindow(window1); QVERIFY(app.topLevelWindows().contains(window1)); QVERIFY(!app.topLevelWindows().contains(window2)); QCOMPARE(app.topLevelWindows().count(), 1); delete window1; - window1 = 0; - window2 = 0; + window1 = nullptr; + window2 = nullptr; QVERIFY(!app.topLevelWindows().contains(window2)); QVERIFY(!app.topLevelWindows().contains(window1)); QCOMPARE(app.topLevelWindows().count(), 0); @@ -306,7 +306,7 @@ class ShowCloseShowWindow : public QWindow { Q_OBJECT public: - ShowCloseShowWindow(bool showAgain, QWindow *parent = 0) + ShowCloseShowWindow(bool showAgain, QWindow *parent = nullptr) : QWindow(parent), showAgain(showAgain) { QTimer::singleShot(0, this, SLOT(doClose())); @@ -331,7 +331,7 @@ private: void tst_QGuiApplication::abortQuitOnShow() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QScopedPointer<QWindow> window1(new ShowCloseShowWindow(false)); @@ -366,7 +366,7 @@ protected: } public: - FocusChangeWindow() : QWindow(), windowDuringFocusAboutToChange(0), windowDuringFocusOut(0) {} + FocusChangeWindow() : QWindow(), windowDuringFocusAboutToChange(nullptr), windowDuringFocusOut(nullptr) {} QWindow *windowDuringFocusAboutToChange; QWindow *windowDuringFocusOut; @@ -378,7 +378,7 @@ void tst_QGuiApplication::changeFocusWindow() QSKIP("WinRt does not support multiple native windows."); #endif int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) QSKIP("QWindow::requestActivate() is not supported."); @@ -430,7 +430,7 @@ void tst_QGuiApplication::changeFocusWindow() void tst_QGuiApplication::keyboardModifiers() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QScopedPointer<QWindow> window(new QWindow); @@ -564,7 +564,7 @@ public: int leaves; int enters; - inline explicit BlockableWindow(QWindow *parent = 0) + inline explicit BlockableWindow(QWindow *parent = nullptr) : QWindow(parent), blocked(false), leaves(0), enters(0) {} bool event(QEvent *e) @@ -601,7 +601,7 @@ void tst_QGuiApplication::modalWindow() QSKIP("WinRt does not support multiple native windows."); #endif int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); int x = screenGeometry.left() + spacing; @@ -654,7 +654,7 @@ void tst_QGuiApplication::modalWindow() window2->show(); QVERIFY(QTest::qWaitForWindowExposed(window1.data())); QVERIFY(QTest::qWaitForWindowExposed(window2.data())); - QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0)); + QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(childWindow1->blocked, 0); QCOMPARE(window2->blocked, 0); @@ -698,7 +698,7 @@ void tst_QGuiApplication::modalWindow() // everything is unblocked when applicationModalWindow1 is hidden applicationModalWindow1->hide(); - QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0)); + QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(childWindow1->blocked, 0); // QTBUG-32242, blocked status needs to be set on children as well. QCOMPARE(window2->blocked, 0); @@ -750,7 +750,7 @@ void tst_QGuiApplication::modalWindow() // hide windowModalWindow2, windowModalWindow1 and window1 are unblocked windowModalWindow2->hide(); - QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0)); + QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(window2->blocked, 0); QCOMPARE(windowModalWindow1->blocked, 0); @@ -815,7 +815,7 @@ void tst_QGuiApplication::modalWindow() // hide windowModalWindow1, everything is unblocked windowModalWindow1->hide(); - QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0)); + QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr)); QCOMPARE(window1->blocked, 0); QCOMPARE(window2->blocked, 0); QCOMPARE(windowModalWindow1->blocked, 0); @@ -829,7 +829,7 @@ void tst_QGuiApplication::modalWindow() void tst_QGuiApplication::quitOnLastWindowClosed() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QTimer timer; @@ -869,7 +869,7 @@ void tst_QGuiApplication::quitOnLastWindowClosed() void tst_QGuiApplication::quitOnLastWindowClosedMulti() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); QTimer timer; @@ -909,7 +909,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti() void tst_QGuiApplication::dontQuitOnLastWindowClosed() { int argc = 0; - QGuiApplication app(argc, 0); + QGuiApplication app(argc, nullptr); app.setQuitOnLastWindowClosed(false); QTimer timer; @@ -959,7 +959,7 @@ public: { if (key == "testplugin") return new TestPlugin; - return 0; + return nullptr; } }; @@ -989,9 +989,13 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents() QCoreApplication::postEvent(&testReceiver, new QEvent(QEvent::User)); QCOMPARE(testReceiver.customEvents, 0); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QStaticPlugin testPluginInfo(qt_plugin_instance, qt_plugin_query_metadata); +#else QStaticPlugin testPluginInfo; testPluginInfo.instance = qt_plugin_instance; testPluginInfo.rawMetaData = qt_plugin_query_metadata; +#endif qRegisterStaticPluginFunction(testPluginInfo); int argc = 3; char *argv[] = { const_cast<char*>(QTest::currentAppName()), const_cast<char*>("-plugin"), const_cast<char*>("testplugin") }; @@ -1065,7 +1069,7 @@ void tst_QGuiApplication::testSetPaletteAttribute() QVERIFY(!QCoreApplication::testAttribute(Qt::AA_SetPalette)); QPalette palette; - palette.setColor(QPalette::Foreground, Qt::red); + palette.setColor(QPalette::WindowText, Qt::red); QGuiApplication::setPalette(palette); QVERIFY(QCoreApplication::testAttribute(Qt::AA_SetPalette)); @@ -1122,7 +1126,7 @@ void tst_QGuiApplication::settableStyleHints() int argc = 0; QScopedPointer<QGuiApplication> app; if (appInstance) - app.reset(new QGuiApplication(argc, 0)); + app.reset(new QGuiApplication(argc, nullptr)); const int keyboardInputInterval = 555; QGuiApplication::styleHints()->setKeyboardInputInterval(keyboardInputInterval); diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index bad021c3b0..9a4c560a08 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -121,7 +121,7 @@ static QByteArray modifiersTestRowName(const QString &keySequence) if (uc > 32 && uc < 128) str << '"' << c << '"'; else - str << "U+" << hex << uc << dec; + str << "U+" << Qt::hex << uc << Qt::dec; if (i < size - 1) str << ','; } diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index 7f29b1c24e..6ce6422f48 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -141,21 +141,20 @@ void tst_QPalette::copySemantics() void tst_QPalette::moveSemantics() { -#ifdef Q_COMPILER_RVALUE_REFS QPalette src(Qt::red), dst; const QPalette control = src; QVERIFY(src != dst); QCOMPARE(src, control); QVERIFY(!dst.isCopyOf(src)); QVERIFY(!dst.isCopyOf(control)); - dst = qMove(src); // move assignment + dst = std::move(src); // move assignment QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too QVERIFY(dst.isCopyOf(control)); QCOMPARE(dst, control); src = control; // check moved-from 'src' can still be assigned to (doesn't crash) QVERIFY(src.isCopyOf(dst)); QVERIFY(src.isCopyOf(control)); - QPalette dst2(qMove(src)); // move construction + QPalette dst2(std::move(src)); // move construction QVERIFY(!src.isCopyOf(dst)); QVERIFY(!src.isCopyOf(dst2)); QVERIFY(!src.isCopyOf(control)); @@ -163,9 +162,6 @@ void tst_QPalette::moveSemantics() QVERIFY(dst2.isCopyOf(dst)); QVERIFY(dst2.isCopyOf(control)); // check moved-from 'src' can still be destroyed (doesn't crash) -#else - QSKIP("Compiler doesn't support C++11 move semantics"); -#endif } void tst_QPalette::setBrush() diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index 844b3e8507..e7931ca773 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -5,4 +5,4 @@ QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp -qtConfig(dynamicgl):win32:!winrt: LIBS += -luser32 +qtConfig(dynamicgl):win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/gui/painting/painting.pro b/tests/auto/gui/painting/painting.pro index 831fffab30..26e84c1b15 100644 --- a/tests/auto/gui/painting/painting.pro +++ b/tests/auto/gui/painting/painting.pro @@ -3,6 +3,7 @@ SUBDIRS=\ qpainterpath \ qpainterpathstroker \ qcolor \ + qcolorspace \ qbrush \ qregion \ qpagelayout \ diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index ce6ce15767..f35d4f330b 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -338,9 +338,9 @@ void tst_QBrush::gradientPresets() QCOMPARE(lg->finalStop(), QPointF(1, 0)); QCOMPARE(lg->stops().size(), 3); - QCOMPARE(lg->stops().at(0), QGradientStop(0, QColor(QLatin1Literal("#ff9a9e")))); - QCOMPARE(lg->stops().at(1), QGradientStop(0.99, QColor(QLatin1Literal("#fad0c4")))); - QCOMPARE(lg->stops().at(2), QGradientStop(1, QColor(QLatin1Literal("#fad0c4")))); + QCOMPARE(lg->stops().at(0), QGradientStop(0, QColor(QLatin1String("#ff9a9e")))); + QCOMPARE(lg->stops().at(1), QGradientStop(0.99, QColor(QLatin1String("#fad0c4")))); + QCOMPARE(lg->stops().at(2), QGradientStop(1, QColor(QLatin1String("#fad0c4")))); QGradient invalidPreset(QGradient::Preset(-1)); diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 17289e0b85..90a216e14a 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -33,7 +33,7 @@ #include <qcolor.h> #include <qdebug.h> -#include <private/qcolorprofile_p.h> +#include <private/qcolortrclut_p.h> #include <private/qdrawingprimitive_sse2_p.h> #include <qrgba64.h> @@ -70,6 +70,7 @@ private slots: void setBlue(); void setRgb(); + void setRgbF(); void setRgba(); void setHsv(); void setCmyk(); @@ -93,8 +94,8 @@ private slots: void convertTo(); - void light(); - void dark(); + void lighter(); + void darker(); void specConstructor_data(); void specConstructor(); @@ -187,28 +188,28 @@ void tst_QColor::getSetCheck() // void QColor::setRedF(qreal) obj1.setRedF(0.0); QCOMPARE(obj1.redF(), qreal(0.0)); - obj1.setRedF(-0.2); - QCOMPARE(obj1.redF(), qreal(0.0)); // range<0.0, 1.0 - obj1.setRedF(1.1); - QCOMPARE(obj1.redF(), qreal(1.0)); // range<0.0, 1.0 + obj1.setRedF(-0.25); + QCOMPARE(obj1.redF(), qreal(-0.25)); + obj1.setRedF(1.25); + QCOMPARE(obj1.redF(), qreal(1.25)); // qreal QColor::greenF() // void QColor::setGreenF(qreal) obj1.setGreenF(0.0); QCOMPARE(obj1.greenF(), qreal(0.0)); - obj1.setGreenF(-0.2); - QCOMPARE(obj1.greenF(), qreal(0.0)); // range<0.0, 1.0 - obj1.setGreenF(1.1); - QCOMPARE(obj1.greenF(), qreal(1.0)); // range<0.0, 1.0 + obj1.setGreenF(-0.25); + QCOMPARE(obj1.greenF(), qreal(-0.25)); + obj1.setGreenF(1.5); + QCOMPARE(obj1.greenF(), qreal(1.5)); // qreal QColor::blueF() // void QColor::setBlueF(qreal) obj1.setBlueF(0.0); QCOMPARE(obj1.blueF(), qreal(0.0)); - obj1.setBlueF(-0.2); - QCOMPARE(obj1.blueF(), qreal(0.0)); // range<0.0, 1.0 - obj1.setBlueF(1.1); - QCOMPARE(obj1.blueF(), qreal(1.0)); // range<0.0, 1.0 + obj1.setBlueF(-0.5); + QCOMPARE(obj1.blueF(), qreal(-0.5)); + obj1.setBlueF(2.0); + QCOMPARE(obj1.blueF(), qreal(2.0)); // QRgb QColor::rgba() // void QColor::setRgba(QRgb) @@ -677,30 +678,81 @@ void tst_QColor::setRgb() { QColor color; - for (int A = 0; A <= USHRT_MAX; ++A) { - { - // 0-255 - int a = A >> 8; - QRgb rgb = qRgba(0, 0, 0, a); + for (int a = 0; a <= 255; ++a) { + QRgb rgb = qRgba(0, 0, 0, a); - color.setRgb(0, 0, 0, a); - QCOMPARE(color.alpha(), a); - QCOMPARE(color.rgb(), qRgb(0, 0, 0)); + color.setRgb(0, 0, 0, a); + QCOMPARE(color.alpha(), a); + QCOMPARE(color.rgb(), qRgb(0, 0, 0)); - color.setRgb(rgb); - QCOMPARE(color.alpha(), 255); - QCOMPARE(color.rgb(), qRgb(0, 0, 0)); + color.setRgb(rgb); + QCOMPARE(color.alpha(), 255); + QCOMPARE(color.rgb(), qRgb(0, 0, 0)); - int r, g, b, a2; - color.setRgb(0, 0, 0, a); - color.getRgb(&r, &g, &b, &a2); - QCOMPARE(a2, a); + int r, g, b, a2; + color.setRgb(0, 0, 0, a); + color.getRgb(&r, &g, &b, &a2); + QCOMPARE(a2, a); - QColor c(0, 0, 0); - c.setAlpha(a); - QCOMPARE(c.alpha(), a); - } + QColor c(0, 0, 0); + c.setAlpha(a); + QCOMPARE(c.alpha(), a); + } + for (int r = 0; r <= 255; ++r) { + QRgb rgb = qRgb(r, 0, 0); + + color.setRgb(r, 0, 0); + QCOMPARE(color.red(), r); + QCOMPARE(color.rgb(), rgb); + + color.setRgb(rgb); + QCOMPARE(color.red(), r); + QCOMPARE(color.rgb(), rgb); + + int r2, g, b, a; + color.getRgb(&r2, &g, &b, &a); + QCOMPARE(r2, r); + } + + for (int g = 0; g <= 255; ++g) { + QRgb rgb = qRgb(0, g, 0); + + color.setRgb(0, g, 0); + QCOMPARE(color.green(), g); + QCOMPARE(color.rgb(), rgb); + + color.setRgb(rgb); + QCOMPARE(color.green(), g); + QCOMPARE(color.rgb(), rgb); + + int r, g2, b, a; + color.getRgb(&r, &g2, &b, &a); + QCOMPARE(g2, g); + } + + for (int b = 0; b <= 255; ++b) { + QRgb rgb = qRgb(0, 0, b); + + color.setRgb(0, 0, b); + QCOMPARE(color.blue(), b); + QCOMPARE(color.rgb(), rgb); + + color.setRgb(rgb); + QCOMPARE(color.blue(), b); + QCOMPARE(color.rgb(), rgb); + + int r, g, b2, a; + color.getRgb(&r, &g, &b2, &a); + QCOMPARE(b2, b); + } +} + +void tst_QColor::setRgbF() +{ + QColor color; + + for (int A = 0; A <= USHRT_MAX; ++A) { { // 0.0-1.0 qreal a = A / qreal(USHRT_MAX); @@ -720,24 +772,6 @@ void tst_QColor::setRgb() for (int R = 0; R <= USHRT_MAX; ++R) { { - // 0-255 - int r = R >> 8; - QRgb rgb = qRgb(r, 0, 0); - - color.setRgb(r, 0, 0); - QCOMPARE(color.red(), r); - QCOMPARE(color.rgb(), rgb); - - color.setRgb(rgb); - QCOMPARE(color.red(), r); - QCOMPARE(color.rgb(), rgb); - - int r2, g, b, a; - color.getRgb(&r2, &g, &b, &a); - QCOMPARE(r2, r); - } - - { // 0.0-1.0 qreal r = R / qreal(USHRT_MAX); color.setRgbF(r, 0.0, 0.0); @@ -751,24 +785,6 @@ void tst_QColor::setRgb() for (int G = 0; G <= USHRT_MAX; ++G) { { - // 0-255 - int g = G >> 8; - QRgb rgb = qRgb(0, g, 0); - - color.setRgb(0, g, 0); - QCOMPARE(color.green(), g); - QCOMPARE(color.rgb(), rgb); - - color.setRgb(rgb); - QCOMPARE(color.green(), g); - QCOMPARE(color.rgb(), rgb); - - int r, g2, b, a; - color.getRgb(&r, &g2, &b, &a); - QCOMPARE(g2, g); - } - - { // 0.0-1.0 qreal g = G / qreal(USHRT_MAX); color.setRgbF(0.0, g, 0.0); @@ -782,32 +798,53 @@ void tst_QColor::setRgb() for (int B = 0; B <= USHRT_MAX; ++B) { { - // 0-255 - int b = B >> 8; - QRgb rgb = qRgb(0, 0, b); + // 0.0-1.0 + qreal b = B / qreal(USHRT_MAX); + color.setRgbF(0.0, 0.0, b); + QCOMPARE(color.blueF(), b); - color.setRgb(0, 0, b); - QCOMPARE(color.blue(), b); - QCOMPARE(color.rgb(), rgb); + qreal r, g, b2, a; + color.getRgbF(&r, &g, &b2, &a); + QCOMPARE(b2, b); + } + } - color.setRgb(rgb); - QCOMPARE(color.blue(), b); - QCOMPARE(color.rgb(), rgb); + for (int R = -128; R <= 512; ++R) { + { + // extended RGB + qreal r = R / qreal(256); + color.setRgbF(r, 0.0, 0.0); + QCOMPARE(qfloat16(color.redF()), qfloat16(r)); - int r, g, b2, a; - color.getRgb(&r, &g, &b2, &a); - QCOMPARE(b2, b); + qreal r2, g, b, a; + color.getRgbF(&r2, &g, &b, &a); + QCOMPARE(qfloat16(r2), qfloat16(r)); } + } + for (int G = -128; G <= 512; ++G) { { - // 0.0-1.0 - qreal b = B / qreal(USHRT_MAX); + // extended RGB + qreal g = G / qreal(256); + color.setRgbF(0.0, g, 0.0); + QCOMPARE(qfloat16(color.greenF()), qfloat16(g)); + + qreal r, g2, b, a; + color.getRgbF(&r, &g2, &b, &a); + QCOMPARE(qfloat16(g2), qfloat16(g)); + } + } + + for (int B = -128; B <= 512; ++B) { + { + // extended RGB + qreal b = B / qreal(256); color.setRgbF(0.0, 0.0, b); - QCOMPARE(color.blueF(), b); + QCOMPARE(qfloat16(color.blueF()), qfloat16(b)); qreal r, g, b2, a; color.getRgbF(&r, &g, &b2, &a); - QCOMPARE(b2, b); + QCOMPARE(qfloat16(b2), qfloat16(b)); } } } @@ -1382,17 +1419,17 @@ void tst_QColor::convertTo() QCOMPARE(invalid.spec(), QColor::Invalid); } -void tst_QColor::light() +void tst_QColor::lighter() { QColor gray(Qt::gray); - QColor lighter = gray.light(); + QColor lighter = gray.lighter(); QVERIFY(lighter.value() > gray.value()); } -void tst_QColor::dark() +void tst_QColor::darker() { QColor gray(Qt::gray); - QColor darker = gray.dark(); + QColor darker = gray.darker(); QVERIFY(darker.value() < gray.value()); } @@ -1632,14 +1669,13 @@ void tst_QColor::qcolorprofile_data() QTest::newRow("gamma=1.7") << qreal(1.7) << 2; QTest::newRow("gamma=2.0") << qreal(2.0) << 8; QTest::newRow("gamma=2.31") << qreal(2.31) << 33; - QTest::newRow("SRgb") << qreal(0.0) << 7; } void tst_QColor::qcolorprofile() { QFETCH(qreal, gammaC); QFETCH(int, tolerance); - QColorProfile *cp = (gammaC == 0) ? QColorProfile::fromSRgb(): QColorProfile::fromGamma(gammaC); + QColorTrcLut *cp = QColorTrcLut::fromGamma(gammaC); // Test we are accurate for most values after converting through gamma-correction. int error = 0; diff --git a/tests/auto/gui/painting/qcolorspace/qcolorspace.pro b/tests/auto/gui/painting/qcolorspace/qcolorspace.pro new file mode 100644 index 0000000000..14bd699bf7 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/qcolorspace.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +QT += testlib gui-private core-private + +TARGET = tst_qcolorspace +SOURCES += tst_qcolorspace.cpp + +RESOURCES += $$files(resources/*) + +TESTDATA += resources/* diff --git a/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg b/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg Binary files differnew file mode 100644 index 0000000000..481d35ca8e --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/resources/ProPhoto.jpg diff --git a/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc b/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc Binary files differnew file mode 100644 index 0000000000..49afbfef10 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/resources/sRGB2014.icc diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp new file mode 100644 index 0000000000..7a88eb18b2 --- /dev/null +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -0,0 +1,361 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QtTest> + +#include <qcolorspace.h> +#include <qimage.h> +#include <qimagereader.h> + +#include <private/qcolorspace_p.h> + +Q_DECLARE_METATYPE(QColorSpace::ColorSpaceId) +Q_DECLARE_METATYPE(QColorSpace::Gamut) +Q_DECLARE_METATYPE(QColorSpace::TransferFunction) + +class tst_QColorSpace : public QObject +{ + Q_OBJECT + +public: + tst_QColorSpace(); + +private slots: + void namedColorSpaces_data(); + void namedColorSpaces(); + + void toIccProfile_data(); + void toIccProfile(); + + void fromIccProfile(); + + void imageConversion_data(); + void imageConversion(); + + void loadImage(); + + void gamut(); + void primariesXyz(); + void primaries2_data(); + void primaries2(); + void invalidPrimaries(); +}; + +tst_QColorSpace::tst_QColorSpace() +{ } + + +void tst_QColorSpace::namedColorSpaces_data() +{ + QTest::addColumn<QColorSpace::ColorSpaceId>("colorSpaceId"); + QTest::addColumn<QColorSpace::Gamut>("gamutId"); + QTest::addColumn<QColorSpace::TransferFunction>("transferFunctionId"); + + QTest::newRow("sRGB") << QColorSpace::SRgb + << QColorSpace::Gamut::SRgb + << QColorSpace::TransferFunction::SRgb; + QTest::newRow("sRGB Linear") << QColorSpace::SRgbLinear + << QColorSpace::Gamut::SRgb + << QColorSpace::TransferFunction::Linear; + QTest::newRow("Adobe RGB") << QColorSpace::AdobeRgb + << QColorSpace::Gamut::AdobeRgb + << QColorSpace::TransferFunction::Gamma; + QTest::newRow("Display-P3") << QColorSpace::DisplayP3 + << QColorSpace::Gamut::DciP3D65 + << QColorSpace::TransferFunction::SRgb; + QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb + << QColorSpace::Gamut::ProPhotoRgb + << QColorSpace::TransferFunction::ProPhotoRgb; + QTest::newRow("BT.2020") << QColorSpace::Bt2020 + << QColorSpace::Gamut::Bt2020 + << QColorSpace::TransferFunction::Bt2020; +} + +void tst_QColorSpace::namedColorSpaces() +{ + QFETCH(QColorSpace::ColorSpaceId, colorSpaceId); + QFETCH(QColorSpace::Gamut, gamutId); + QFETCH(QColorSpace::TransferFunction, transferFunctionId); + + QColorSpace colorSpace = colorSpaceId; + + QVERIFY(colorSpace.isValid()); + + QCOMPARE(colorSpace.colorSpaceId(), colorSpaceId); + QCOMPARE(colorSpace.gamut(), gamutId); + QCOMPARE(colorSpace.transferFunction(), transferFunctionId); +} + + +void tst_QColorSpace::toIccProfile_data() +{ + namedColorSpaces_data(); +} + +void tst_QColorSpace::toIccProfile() +{ + QFETCH(QColorSpace::ColorSpaceId, colorSpaceId); + QFETCH(QColorSpace::Gamut, gamutId); + QFETCH(QColorSpace::TransferFunction, transferFunctionId); + + Q_UNUSED(gamutId); + Q_UNUSED(transferFunctionId); + + QColorSpace colorSpace = colorSpaceId; + QByteArray iccProfile = colorSpace.iccProfile(); + QVERIFY(!iccProfile.isEmpty()); + + QColorSpace colorSpace2 = QColorSpace::fromIccProfile(iccProfile); + QVERIFY(colorSpace2.isValid()); + + QCOMPARE(colorSpace2, colorSpace); + + QByteArray iccProfile2 = colorSpace2.iccProfile(); + QVERIFY(!iccProfile2.isEmpty()); + + QCOMPARE(iccProfile2, iccProfile); +} + +void tst_QColorSpace::fromIccProfile() +{ + // Read the official sRGB ICCv2 profile: + QString prefix = QFINDTESTDATA("resources/"); + QFile file(prefix + "sRGB2014.icc"); + file.open(QIODevice::ReadOnly); + QByteArray iccProfile = file.readAll(); + QColorSpace stdSRgb = QColorSpace::fromIccProfile(iccProfile); + QVERIFY(stdSRgb.isValid()); + + QCOMPARE(stdSRgb.gamut(), QColorSpace::Gamut::SRgb); + QCOMPARE(stdSRgb.transferFunction(), QColorSpace::TransferFunction::SRgb); + QCOMPARE(stdSRgb.colorSpaceId(), QColorSpace::SRgb); + + QCOMPARE(stdSRgb, QColorSpace(QColorSpace::SRgb)); +} + +void tst_QColorSpace::imageConversion_data() +{ + QTest::addColumn<QColorSpace::ColorSpaceId>("fromColorSpace"); + QTest::addColumn<QColorSpace::ColorSpaceId>("toColorSpace"); + QTest::addColumn<int>("tolerance"); + + QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3 << 0; + QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb << 2; + QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0; + QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb << 2; + QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb << 2; + QTest::newRow("Display-P3 -> BT.2020") << QColorSpace::DisplayP3 << QColorSpace::Bt2020 << 4; + QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear << 0; +} + +void tst_QColorSpace::imageConversion() +{ + QFETCH(QColorSpace::ColorSpaceId, fromColorSpace); + QFETCH(QColorSpace::ColorSpaceId, toColorSpace); + QFETCH(int, tolerance); + + QImage testImage(256, 1, QImage::Format_RGB32); + + for (int i = 0; i < 256; ++i) + testImage.setPixel(i, 0, qRgb(i, i, i)); + + testImage.setColorSpace(fromColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace)); + + testImage.convertToColorSpace(toColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(toColorSpace)); + + int lastRed = 0; + int lastGreen = 0; + int lastBlue = 0; + for (int i = 0; i < 256; ++i) { + QRgb p = testImage.pixel(i, 0); + QVERIFY(qRed(p) >= lastRed); + QVERIFY(qGreen(p) >= lastGreen); + QVERIFY(qBlue(p) >= lastBlue); + lastRed = qRed(p); + lastGreen = qGreen(p); + lastBlue = qBlue(p); + } + + lastRed = 0; + lastGreen = 0; + lastBlue = 0; + testImage.convertToColorSpace(fromColorSpace); + QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace)); + for (int i = 0; i < 256; ++i) { + QRgb p = testImage.pixel(i, 0); + QVERIFY(qAbs(qRed(p) - qGreen(p)) <= tolerance); + QVERIFY(qAbs(qRed(p) - qBlue(p)) <= tolerance); + QVERIFY((lastRed - qRed(p)) <= (tolerance / 2)); + QVERIFY((lastGreen - qGreen(p)) <= (tolerance / 2)); + QVERIFY((lastBlue - qBlue(p)) <= (tolerance / 2)); + lastRed = qRed(p); + lastGreen = qGreen(p); + lastBlue = qBlue(p); + } +} + + +void tst_QColorSpace::loadImage() +{ + QString prefix = QFINDTESTDATA("resources/"); + QImageReader reader(prefix + "ProPhoto.jpg"); + QImage image = reader.read(); + + QVERIFY(!image.isNull()); + QVERIFY(image.colorSpace().isValid()); + QCOMPARE(image.colorSpace().colorSpaceId(), QColorSpace::ProPhotoRgb); + QVERIFY(!image.colorSpace().iccProfile().isEmpty()); + + QColorSpace defaultProPhotoRgb = QColorSpace::ProPhotoRgb; + QVERIFY(!defaultProPhotoRgb.iccProfile().isEmpty()); + + // Test the iccProfile getter returns the ICC profile from the image + // which since we didn't write it, isn't identical to our defaults. + QVERIFY(defaultProPhotoRgb.iccProfile() != image.colorSpace().iccProfile()); + + QColorTransform transform = image.colorSpace().transformationToColorSpace(QColorSpace::SRgb); + qreal maxRed = 0; + qreal maxBlue = 0; + qreal maxRed2 = 0; + qreal maxBlue2 = 0; + for (int y = 0; y < image.height(); ++y) { + for (int x = 0; x < image.width(); ++x) { + QColor p = image.pixelColor(x, y); + maxRed = std::max(maxRed, p.redF()); + maxBlue = std::max(maxBlue, p.blueF()); + p = transform.map(p); + maxRed2 = std::max(maxRed2, p.redF()); + maxBlue2 = std::max(maxBlue2, p.blueF()); + + } + } + // ProPhotoRgb can be a lot more red and blue than SRgb can, so it will have lower values. + QVERIFY(maxRed2 > maxRed); + QVERIFY(maxBlue2 > maxBlue); +} + +void tst_QColorSpace::gamut() +{ + QColor black = QColor::fromRgbF(0.0, 0.0, 0.0); + QColor white = QColor::fromRgbF(1.0, 1.0, 1.0); + QColor red = QColor::fromRgbF(1.0, 0.0, 0.0); + QColor green = QColor::fromRgbF(0.0, 1.0, 0.0); + QColor blue = QColor::fromRgbF(0.0, 0.0, 1.0); + + QColorTransform toAdobeRgb = QColorSpace(QColorSpace::SRgb).transformationToColorSpace(QColorSpace::AdobeRgb); + + QColor tblack = toAdobeRgb.map(black); + QColor twhite = toAdobeRgb.map(white); + QColor tred = toAdobeRgb.map(red); + QColor tgreen = toAdobeRgb.map(green); + QColor tblue = toAdobeRgb.map(blue); + + // Black is black + QCOMPARE(tblack, black); + + // This white hasn't changed + QCOMPARE(twhite, white); + + // Adobe's red and blue gamut corners are the same as sRGB's + // So, a color in the red corner, will stay in the red corner + // the same for blue, but not for green. + QVERIFY(tred.greenF() < 0.001); + QVERIFY(tred.blueF() < 0.001); + QVERIFY(tblue.redF() < 0.001); + QVERIFY(tblue.greenF() < 0.001); + QVERIFY(tgreen.redF() > 0.2); + QVERIFY(tgreen.blueF() > 0.2); +} + +void tst_QColorSpace::primariesXyz() +{ + QColorSpace sRgb = QColorSpace::SRgb; + QColorSpace adobeRgb = QColorSpace::AdobeRgb; + QColorSpace displayP3 = QColorSpace::DisplayP3; + QColorSpace proPhotoRgb = QColorSpace::ProPhotoRgb; + QColorSpace bt2020 = QColorSpace::Bt2020; + + // Check if our calculated matrices, match the precalculated ones. + QCOMPARE(sRgb.d_func()->toXyz, QColorMatrix::toXyzFromSRgb()); + QCOMPARE(adobeRgb.d_func()->toXyz, QColorMatrix::toXyzFromAdobeRgb()); + QCOMPARE(displayP3.d_func()->toXyz, QColorMatrix::toXyzFromDciP3D65()); + QCOMPARE(proPhotoRgb.d_func()->toXyz, QColorMatrix::toXyzFromProPhotoRgb()); + QCOMPARE(bt2020.d_func()->toXyz, QColorMatrix::toXyzFromBt2020()); +} + +void tst_QColorSpace::primaries2_data() +{ + QTest::addColumn<QColorSpace::Gamut>("gamut"); + + QTest::newRow("sRGB") << QColorSpace::Gamut::SRgb; + QTest::newRow("DCI-P3 (D65)") << QColorSpace::Gamut::DciP3D65; + QTest::newRow("Adobe RGB (1998)") << QColorSpace::Gamut::AdobeRgb; + QTest::newRow("ProPhoto RGB") << QColorSpace::Gamut::ProPhotoRgb; + QTest::newRow("BT.2020") << QColorSpace::Gamut::Bt2020; +} + +void tst_QColorSpace::primaries2() +{ + QFETCH(QColorSpace::Gamut, gamut); + QColorSpacePrimaries primaries(gamut); + + QColorSpace original(gamut, QColorSpace::TransferFunction::Linear); + QColorSpace custom1(primaries.whitePoint, primaries.redPoint, + primaries.greenPoint, primaries.bluePoint, QColorSpace::TransferFunction::Linear); + QCOMPARE(original, custom1); + + // A custom color swizzled color-space: + QColorSpace custom2(primaries.whitePoint, primaries.bluePoint, + primaries.greenPoint, primaries.redPoint, QColorSpace::TransferFunction::Linear); + + QVERIFY(custom1 != custom2); + QColor color1(255, 127, 63); + QColor color2 = custom1.transformationToColorSpace(custom2).map(color1); + QCOMPARE(color2.red(), color1.blue()); + QCOMPARE(color2.green(), color1.green()); + QCOMPARE(color2.blue(), color1.red()); + QCOMPARE(color2.alpha(), color1.alpha()); + QColor color3 = custom2.transformationToColorSpace(custom1).map(color2); + QCOMPARE(color3.red(), color1.red()); + QCOMPARE(color3.green(), color1.green()); + QCOMPARE(color3.blue(), color1.blue()); + QCOMPARE(color3.alpha(), color1.alpha()); +} + +void tst_QColorSpace::invalidPrimaries() +{ + QColorSpace custom(QPointF(), QPointF(), QPointF(), QPointF(), QColorSpace::TransferFunction::Linear); + QVERIFY(!custom.isValid()); + QCOMPARE(custom.colorSpaceId(), QColorSpace::Undefined); +} + +QTEST_MAIN(tst_QColorSpace) +#include "tst_qcolorspace.moc" diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index bc0baed15c..2b53169a45 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -185,10 +185,12 @@ private slots: void gradientPixelFormat_data(); void gradientPixelFormat(); +#if QT_CONFIG(raster_64bit) void linearGradientRgb30_data(); void linearGradientRgb30(); void radialGradientRgb30_data(); void radialGradientRgb30(); +#endif void fpe_pixmapTransform(); void fpe_zeroLengthLines(); @@ -368,10 +370,10 @@ void tst_QPainter::getSetCheck() // bool QPainter::matrixEnabled() // void QPainter::setMatrixEnabled(bool) - obj1.setMatrixEnabled(false); - QCOMPARE(false, obj1.matrixEnabled()); - obj1.setMatrixEnabled(true); - QCOMPARE(true, obj1.matrixEnabled()); + obj1.setWorldMatrixEnabled(false); + QCOMPARE(false, obj1.worldMatrixEnabled()); + obj1.setWorldMatrixEnabled(true); + QCOMPARE(true, obj1.worldMatrixEnabled()); // bool QPainter::viewTransformEnabled() // void QPainter::setViewTransformEnabled(bool) @@ -697,7 +699,7 @@ void tst_QPainter::initFrom() QCOMPARE(p.font(), font); QCOMPARE(p.pen().color(), pal.color(QPalette::Foreground)); - QCOMPARE(p.background(), pal.background()); + QCOMPARE(p.background(), pal.window()); delete widget; } @@ -3195,7 +3197,7 @@ void tst_QPainter::largeImagePainting() p.translate(4, 0); } - p.resetMatrix(); + p.resetTransform(); for (int i = 4; i < img.height(); i += 4) { p.translate(0, 4); @@ -3946,6 +3948,7 @@ void tst_QPainter::gradientInterpolation() } } +#if QT_CONFIG(raster_64bit) void tst_QPainter::linearGradientRgb30_data() { QTest::addColumn<QColor>("stop0"); @@ -4004,6 +4007,7 @@ void tst_QPainter::radialGradientRgb30() QVERIFY(qGray(p1.rgb()) >= qGray(p2.rgb())); } } +#endif void tst_QPainter::drawPolygon() { @@ -4884,14 +4888,18 @@ void tst_QPainter::blendARGBonRGB_data() << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB_PM over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85; +#if QT_CONFIG(raster_64bit) QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85; +#endif QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85; +#if QT_CONFIG(raster_64bit) QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170; +#endif QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85; QTest::newRow("ARGB_PM source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp index c1a8f7f0de..9e9b0db366 100644 --- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp +++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp @@ -154,12 +154,7 @@ void tst_QPdfWriter::testPageMetrics() if (setMargins) { // Setup the given margins - QPdfWriter::Margins margins; - margins.left = leftMMf; - margins.right = rightMMf; - margins.top = topMMf; - margins.bottom = bottomMMf; - writer.setMargins(margins); + writer.setPageMargins({leftMMf, topMMf, rightMMf, bottomMMf}, QPageLayout::Millimeter); QCOMPARE(writer.margins().left, leftMMf); QCOMPARE(writer.margins().right, rightMMf); QCOMPARE(writer.margins().top, topMMf); @@ -169,7 +164,7 @@ void tst_QPdfWriter::testPageMetrics() // Set the given size, in Portrait mode if (pageSize < 0) { - writer.setPageSizeMM(sizeMMf); + writer.setPageSize(QPageSize(sizeMMf, QPageSize::Millimeter)); QCOMPARE(writer.pageSize(), QPdfWriter::Custom); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom); } else { @@ -221,7 +216,7 @@ void tst_QPdfWriter::testPageMetrics() // Now while in Landscape mode, set the size again, results should be the same if (pageSize < 0) { - writer.setPageSizeMM(sizeMMf); + writer.setPageSize(QPageSize(sizeMMf, QPageSize::Millimeter)); QCOMPARE(writer.pageSize(), QPdfWriter::Custom); QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom); } else { @@ -255,7 +250,7 @@ void tst_QPdfWriter::qtbug59443() QTemporaryFile file; QVERIFY2(file.open(), qPrintable(file.errorString())); QPdfWriter writer(file.fileName()); - writer.setPageSize(QPdfWriter::A4); + writer.setPageSize(QPageSize(QPageSize::A4)); QTextDocument doc; doc.documentLayout()->setPaintDevice(&writer); diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp index ef65d653ce..295ae27d17 100644 --- a/tests/auto/gui/painting/qpen/tst_qpen.cpp +++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp @@ -95,7 +95,7 @@ void tst_QPen::move() QPen p1(Qt::black); // check that moving does the right thing: - QPen p2 = qMove(p1); // could be move or copy construction, so don't check p1's state + QPen p2 = std::move(p1); // could be move or copy construction, so don't check p1's state QCOMPARE(p2.color(), QColor(Qt::black)); // this, executed ehre, would crash: @@ -110,7 +110,7 @@ void tst_QPen::move() QCOMPARE(p1.color(), QColor(Qt::yellow)); // check that moved-from QPens p2, p3 can still be safely destroyed: - QPen p5 = qMove(p2); + QPen p5 = std::move(p2); // intentionally no more statements beyond this point } @@ -120,7 +120,7 @@ void tst_QPen::move_assign() QPen p1(Qt::black), p2(Qt::white); // check that moving does the right thing: - p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state + p2 = std::move(p1); // could be move or copy assignment, so don't check p1's state QCOMPARE(p2.color(), QColor(Qt::black)); // check that move-assigned-from QPen p1 can still be used, albeit @@ -137,7 +137,7 @@ void tst_QPen::move_assign() // check that moved-from QPens p2, p3 can still be safely destroyed: QPen p5; - p5 = qMove(p2); + p5 = std::move(p2); // intentionally no more statements beyond this point } diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp index f8dfdbd3b0..b82b277781 100644 --- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp +++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp @@ -200,7 +200,7 @@ static void dumpGlConfiguration(QOpenGLContext &context, QTextStream &str) << "\nShading language : " << reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION)) << "\nFormat : " << context.format(); - QList<QByteArray> extensionList = context.extensions().toList(); + QList<QByteArray> extensionList = context.extensions().values(); std::sort(extensionList.begin(), extensionList.end()); const int extensionCount = extensionList.size(); str << "\n\nFound " << extensionCount << " extensions:\n"; @@ -233,9 +233,9 @@ void tst_QOpenGlConfig::testGlConfiguration() static inline QByteArray msgSetMismatch(const QSet<QString> &expected, const QSet<QString> &actual) { - const QString result = QStringList(expected.toList()).join(QLatin1Char(',')) + const QString result = QStringList(expected.values()).join(QLatin1Char(',')) + QLatin1String(" != ") - + QStringList(actual.toList()).join(QLatin1Char(',')); + + QStringList(actual.values()).join(QLatin1Char(',')); return result.toLatin1(); } diff --git a/tests/auto/gui/rhi/qrhi/data/texture.frag b/tests/auto/gui/rhi/qrhi/data/texture.frag new file mode 100644 index 0000000000..e6021fe905 --- /dev/null +++ b/tests/auto/gui/rhi/qrhi/data/texture.frag @@ -0,0 +1,12 @@ +#version 440 + +layout(location = 0) in vec2 v_texcoord; + +layout(location = 0) out vec4 fragColor; + +layout(binding = 1) uniform sampler2D tex; + +void main() +{ + fragColor = texture(tex, v_texcoord); +} diff --git a/tests/auto/gui/rhi/qrhi/data/texture.vert b/tests/auto/gui/rhi/qrhi/data/texture.vert new file mode 100644 index 0000000000..de486cb772 --- /dev/null +++ b/tests/auto/gui/rhi/qrhi/data/texture.vert @@ -0,0 +1,18 @@ +#version 440 + +layout(location = 0) in vec4 position; +layout(location = 1) in vec2 texcoord; + +layout(location = 0) out vec2 v_texcoord; + +layout(std140, binding = 0) uniform buf { + mat4 mvp; +} ubuf; + +out gl_PerVertex { vec4 gl_Position; }; + +void main() +{ + v_texcoord = texcoord; + gl_Position = ubuf.mvp * position; +} diff --git a/tests/auto/gui/rhi/qrhi/qrhi.pro b/tests/auto/gui/rhi/qrhi/qrhi.pro new file mode 100644 index 0000000000..58000ed514 --- /dev/null +++ b/tests/auto/gui/rhi/qrhi/qrhi.pro @@ -0,0 +1,8 @@ +TARGET = tst_qrhi +CONFIG += testcase + +QT += testlib gui-private + +SOURCES += tst_qrhi.cpp + +RESOURCES += qrhi.qrc diff --git a/tests/auto/gui/rhi/qrhi/qrhi.qrc b/tests/auto/gui/rhi/qrhi/qrhi.qrc new file mode 100644 index 0000000000..f161d8aad6 --- /dev/null +++ b/tests/auto/gui/rhi/qrhi/qrhi.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>data</file> + </qresource> +</RCC> diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp new file mode 100644 index 0000000000..897613d525 --- /dev/null +++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QThread> +#include <QFile> +#include <QOffscreenSurface> +#include <QtGui/private/qrhi_p.h> +#include <QtGui/private/qrhinull_p.h> + +#if QT_CONFIG(opengl) +# include <QtGui/private/qrhigles2_p.h> +# define TST_GL +#endif + +#if QT_CONFIG(vulkan) +# include <QVulkanInstance> +# include <QtGui/private/qrhivulkan_p.h> +# define TST_VK +#endif + +#ifdef Q_OS_WIN +#include <QtGui/private/qrhid3d11_p.h> +# define TST_D3D11 +#endif + +#ifdef Q_OS_DARWIN +# include <QtGui/private/qrhimetal_p.h> +# define TST_MTL +#endif + +Q_DECLARE_METATYPE(QRhi::Implementation) +Q_DECLARE_METATYPE(QRhiInitParams *) + +class tst_QRhi : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void create_data(); + void create(); + +private: + struct { + QRhiNullInitParams null; +#ifdef TST_GL + QRhiGles2InitParams gl; +#endif +#ifdef TST_VK + QRhiVulkanInitParams vk; +#endif +#ifdef TST_D3D11 + QRhiD3D11InitParams d3d; +#endif +#ifdef TST_MTL + QRhiMetalInitParams mtl; +#endif + } initParams; + +#ifdef TST_VK + QVulkanInstance vulkanInstance; +#endif + QOffscreenSurface *fallbackSurface = nullptr; +}; + +void tst_QRhi::initTestCase() +{ +#ifdef TST_GL + fallbackSurface = QRhiGles2InitParams::newFallbackSurface(); + initParams.gl.fallbackSurface = fallbackSurface; +#endif + +#ifdef TST_VK + vulkanInstance.create(); + initParams.vk.inst = &vulkanInstance; +#endif +} + +void tst_QRhi::cleanupTestCase() +{ +#ifdef TST_VK + vulkanInstance.destroy(); +#endif + + delete fallbackSurface; +} + +void tst_QRhi::create_data() +{ + QTest::addColumn<QRhi::Implementation>("impl"); + QTest::addColumn<QRhiInitParams *>("initParams"); + + QTest::newRow("Null") << QRhi::Null << static_cast<QRhiInitParams *>(&initParams.null); +#ifdef TST_GL + QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl); +#endif +#ifdef TST_VK + if (vulkanInstance.isValid()) + QTest::newRow("Vulkan") << QRhi::Vulkan << static_cast<QRhiInitParams *>(&initParams.vk); +#endif +#ifdef TST_D3D11 + QTest::newRow("Direct3D 11") << QRhi::D3D11 << static_cast<QRhiInitParams *>(&initParams.d3d); +#endif +#ifdef TST_MTL + QTest::newRow("Metal") << QRhi::Metal << static_cast<QRhiInitParams *>(&initParams.mtl); +#endif +} + +static int aligned(int v, int a) +{ + return (v + a - 1) & ~(a - 1); +} + +void tst_QRhi::create() +{ + // Merely attempting to create a QRhi should survive, with an error when + // not supported. (of course, there is always a chance we encounter a crash + // due to some random graphics stack...) + + QFETCH(QRhi::Implementation, impl); + QFETCH(QRhiInitParams *, initParams); + + QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr)); + + if (rhi) { + QCOMPARE(rhi->backend(), impl); + QCOMPARE(rhi->thread(), QThread::currentThread()); + + int cleanupOk = 0; + QRhi *rhiPtr = rhi.data(); + auto cleanupFunc = [rhiPtr, &cleanupOk](QRhi *dyingRhi) { + if (rhiPtr == dyingRhi) + cleanupOk += 1; + }; + rhi->addCleanupCallback(cleanupFunc); + rhi->runCleanup(); + QCOMPARE(cleanupOk, 1); + cleanupOk = 0; + rhi->addCleanupCallback(cleanupFunc); + + QRhiResourceUpdateBatch *resUpd = rhi->nextResourceUpdateBatch(); + QVERIFY(resUpd); + resUpd->release(); + + QVERIFY(!rhi->supportedSampleCounts().isEmpty()); + QVERIFY(rhi->supportedSampleCounts().contains(1)); + + QVERIFY(rhi->ubufAlignment() > 0); + QCOMPARE(rhi->ubufAligned(123), aligned(123, rhi->ubufAlignment())); + + QCOMPARE(rhi->mipLevelsForSize(QSize(512, 300)), 10); + QCOMPARE(rhi->sizeForMipLevel(0, QSize(512, 300)), QSize(512, 300)); + QCOMPARE(rhi->sizeForMipLevel(1, QSize(512, 300)), QSize(256, 150)); + QCOMPARE(rhi->sizeForMipLevel(2, QSize(512, 300)), QSize(128, 75)); + QCOMPARE(rhi->sizeForMipLevel(9, QSize(512, 300)), QSize(1, 1)); + + const bool fbUp = rhi->isYUpInFramebuffer(); + const bool ndcUp = rhi->isYUpInNDC(); + const bool d0to1 = rhi->isClipDepthZeroToOne(); + const QMatrix4x4 corrMat = rhi->clipSpaceCorrMatrix(); + if (impl == QRhi::OpenGLES2) { + QVERIFY(fbUp); + QVERIFY(ndcUp); + QVERIFY(!d0to1); + QVERIFY(corrMat.isIdentity()); + } else if (impl == QRhi::Vulkan) { + QVERIFY(!fbUp); + QVERIFY(!ndcUp); + QVERIFY(d0to1); + QVERIFY(!corrMat.isIdentity()); + } else if (impl == QRhi::D3D11) { + QVERIFY(!fbUp); + QVERIFY(ndcUp); + QVERIFY(d0to1); + QVERIFY(!corrMat.isIdentity()); + } else if (impl == QRhi::Metal) { + QVERIFY(!fbUp); + QVERIFY(ndcUp); + QVERIFY(d0to1); + QVERIFY(!corrMat.isIdentity()); + } + + const int texMin = rhi->resourceLimit(QRhi::TextureSizeMin); + const int texMax = rhi->resourceLimit(QRhi::TextureSizeMax); + const int maxAtt = rhi->resourceLimit(QRhi::MaxColorAttachments); + QVERIFY(texMin >= 1); + QVERIFY(texMax >= texMin); + QVERIFY(maxAtt >= 1); + + QVERIFY(rhi->nativeHandles()); + QVERIFY(rhi->profiler()); + + const QRhi::Feature features[] = { + QRhi::MultisampleTexture, + QRhi::MultisampleRenderBuffer, + QRhi::DebugMarkers, + QRhi::Timestamps, + QRhi::Instancing, + QRhi::CustomInstanceStepRate, + QRhi::PrimitiveRestart, + QRhi::NonDynamicUniformBuffers, + QRhi::NonFourAlignedEffectiveIndexBufferOffset, + QRhi::NPOTTextureRepeat, + QRhi::RedOrAlpha8IsRed, + QRhi::ElementIndexUint + }; + for (size_t i = 0; i <sizeof(features) / sizeof(QRhi::Feature); ++i) + rhi->isFeatureSupported(features[i]); + + QVERIFY(rhi->isTextureFormatSupported(QRhiTexture::RGBA8)); + + rhi.reset(); + QCOMPARE(cleanupOk, 1); + } +} + +#include <tst_qrhi.moc> +QTEST_MAIN(tst_QRhi) diff --git a/tests/auto/gui/rhi/qshader/data/color.vert b/tests/auto/gui/rhi/qshader/data/color.vert new file mode 100644 index 0000000000..c92f71b9e1 --- /dev/null +++ b/tests/auto/gui/rhi/qshader/data/color.vert @@ -0,0 +1,18 @@ +#version 440 + +layout(location = 0) in vec4 position; +layout(location = 1) in vec3 color; +layout(location = 0) out vec3 v_color; + +layout(std140, binding = 0) uniform buf { + mat4 mvp; + float opacity; +} ubuf; + +out gl_PerVertex { vec4 gl_Position; }; + +void main() +{ + v_color = color; + gl_Position = ubuf.mvp * position; +} diff --git a/tests/auto/gui/rhi/qshader/data/color.vert.qsb b/tests/auto/gui/rhi/qshader/data/color.vert.qsb Binary files differnew file mode 100644 index 0000000000..7d02d823d2 --- /dev/null +++ b/tests/auto/gui/rhi/qshader/data/color.vert.qsb diff --git a/tests/auto/gui/rhi/qshader/data/color_simple.vert.qsb b/tests/auto/gui/rhi/qshader/data/color_simple.vert.qsb Binary files differnew file mode 100644 index 0000000000..c82ba7e8e7 --- /dev/null +++ b/tests/auto/gui/rhi/qshader/data/color_simple.vert.qsb diff --git a/tests/auto/gui/rhi/qshader/qshader.pro b/tests/auto/gui/rhi/qshader/qshader.pro new file mode 100644 index 0000000000..5d9ef8304d --- /dev/null +++ b/tests/auto/gui/rhi/qshader/qshader.pro @@ -0,0 +1,8 @@ +TARGET = tst_qshader +CONFIG += testcase + +QT += testlib gui-private + +SOURCES += tst_qshader.cpp + +RESOURCES += qshader.qrc diff --git a/tests/auto/gui/rhi/qshader/qshader.qrc b/tests/auto/gui/rhi/qshader/qshader.qrc new file mode 100644 index 0000000000..f161d8aad6 --- /dev/null +++ b/tests/auto/gui/rhi/qshader/qshader.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>data</file> + </qresource> +</RCC> diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp new file mode 100644 index 0000000000..21f0cc7895 --- /dev/null +++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QFile> +#include <QtGui/private/qshaderdescription_p_p.h> +#include <QtGui/private/qshader_p_p.h> + +class tst_QShader : public QObject +{ + Q_OBJECT + +private slots: + void simpleCompileCheckResults(); + void genVariants(); + void shaderDescImplicitSharing(); + void bakedShaderImplicitSharing(); +}; + +static QShader getShader(const QString &name) +{ + QFile f(name); + if (f.open(QIODevice::ReadOnly)) + return QShader::fromSerialized(f.readAll()); + + return QShader(); +} + +void tst_QShader::simpleCompileCheckResults() +{ + QShader s = getShader(QLatin1String(":/data/color_simple.vert.qsb")); + QVERIFY(s.isValid()); + QCOMPARE(s.availableShaders().count(), 1); + + const QShaderCode shader = s.shader(QShaderKey(QShader::SpirvShader, + QShaderVersion(100))); + QVERIFY(!shader.shader().isEmpty()); + QCOMPARE(shader.entryPoint(), QByteArrayLiteral("main")); + + const QShaderDescription desc = s.description(); + QVERIFY(desc.isValid()); + QCOMPARE(desc.inputVariables().count(), 2); + for (const QShaderDescription::InOutVariable &v : desc.inputVariables()) { + switch (v.location) { + case 0: + QCOMPARE(v.name, QLatin1String("position")); + QCOMPARE(v.type, QShaderDescription::Vec4); + break; + case 1: + QCOMPARE(v.name, QLatin1String("color")); + QCOMPARE(v.type, QShaderDescription::Vec3); + break; + default: + QVERIFY(false); + break; + } + } + QCOMPARE(desc.outputVariables().count(), 1); + for (const QShaderDescription::InOutVariable &v : desc.outputVariables()) { + switch (v.location) { + case 0: + QCOMPARE(v.name, QLatin1String("v_color")); + QCOMPARE(v.type, QShaderDescription::Vec3); + break; + default: + QVERIFY(false); + break; + } + } + QCOMPARE(desc.uniformBlocks().count(), 1); + const QShaderDescription::UniformBlock blk = desc.uniformBlocks().first(); + QCOMPARE(blk.blockName, QLatin1String("buf")); + QCOMPARE(blk.structName, QLatin1String("ubuf")); + QCOMPARE(blk.size, 68); + QCOMPARE(blk.binding, 0); + QCOMPARE(blk.descriptorSet, 0); + QCOMPARE(blk.members.count(), 2); + for (int i = 0; i < blk.members.count(); ++i) { + const QShaderDescription::BlockVariable v = blk.members[i]; + switch (i) { + case 0: + QCOMPARE(v.offset, 0); + QCOMPARE(v.size, 64); + QCOMPARE(v.name, QLatin1String("mvp")); + QCOMPARE(v.type, QShaderDescription::Mat4); + QCOMPARE(v.matrixStride, 16); + break; + case 1: + QCOMPARE(v.offset, 64); + QCOMPARE(v.size, 4); + QCOMPARE(v.name, QLatin1String("opacity")); + QCOMPARE(v.type, QShaderDescription::Float); + break; + default: + QVERIFY(false); + break; + } + } +} + +void tst_QShader::genVariants() +{ + QShader s = getShader(QLatin1String(":/data/color.vert.qsb")); + // spirv, glsl 100, glsl 330, glsl 120, hlsl 50, msl 12 + // + batchable variants + QVERIFY(s.isValid()); + QCOMPARE(s.availableShaders().count(), 2 * 6); + + int batchableVariantCount = 0; + int batchableGlslVariantCount = 0; + for (const QShaderKey &key : s.availableShaders()) { + if (key.sourceVariant() == QShader::BatchableVertexShader) { + ++batchableVariantCount; + if (key.source() == QShader::GlslShader) { + ++batchableGlslVariantCount; + const QByteArray src = s.shader(key).shader(); + QVERIFY(src.contains(QByteArrayLiteral("_qt_order * "))); + } + } + } + QCOMPARE(batchableVariantCount, 6); + QCOMPARE(batchableGlslVariantCount, 3); +} + +void tst_QShader::shaderDescImplicitSharing() +{ + QShader s = getShader(QLatin1String(":/data/color_simple.vert.qsb")); + QVERIFY(s.isValid()); + QCOMPARE(s.availableShaders().count(), 1); + QVERIFY(s.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + + QShaderDescription d0 = s.description(); + QVERIFY(d0.isValid()); + QCOMPARE(d0.inputVariables().count(), 2); + QCOMPARE(d0.outputVariables().count(), 1); + QCOMPARE(d0.uniformBlocks().count(), 1); + + QShaderDescription d1 = d0; + QVERIFY(QShaderDescriptionPrivate::get(&d0) == QShaderDescriptionPrivate::get(&d1)); + QCOMPARE(d0.inputVariables().count(), 2); + QCOMPARE(d0.outputVariables().count(), 1); + QCOMPARE(d0.uniformBlocks().count(), 1); + QCOMPARE(d1.inputVariables().count(), 2); + QCOMPARE(d1.outputVariables().count(), 1); + QCOMPARE(d1.uniformBlocks().count(), 1); + + d1.detach(); + QVERIFY(QShaderDescriptionPrivate::get(&d0) != QShaderDescriptionPrivate::get(&d1)); + QCOMPARE(d0.inputVariables().count(), 2); + QCOMPARE(d0.outputVariables().count(), 1); + QCOMPARE(d0.uniformBlocks().count(), 1); + QCOMPARE(d1.inputVariables().count(), 2); + QCOMPARE(d1.outputVariables().count(), 1); + QCOMPARE(d1.uniformBlocks().count(), 1); +} + +void tst_QShader::bakedShaderImplicitSharing() +{ + QShader s0 = getShader(QLatin1String(":/data/color_simple.vert.qsb")); + QVERIFY(s0.isValid()); + QCOMPARE(s0.availableShaders().count(), 1); + QVERIFY(s0.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + + { + QShader s1 = s0; + QVERIFY(QShaderPrivate::get(&s0) == QShaderPrivate::get(&s1)); + QCOMPARE(s0.availableShaders().count(), 1); + QVERIFY(s0.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + QCOMPARE(s1.availableShaders().count(), 1); + QVERIFY(s1.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + QCOMPARE(s0.stage(), s1.stage()); + QCOMPARE(s0, s1); + + s1.detach(); + QVERIFY(QShaderPrivate::get(&s0) != QShaderPrivate::get(&s1)); + QCOMPARE(s0.availableShaders().count(), 1); + QVERIFY(s0.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + QCOMPARE(s1.availableShaders().count(), 1); + QVERIFY(s1.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + QCOMPARE(s0.stage(), s1.stage()); + QCOMPARE(s0, s1); + } + + { + QShader s1 = s0; + QVERIFY(QShaderPrivate::get(&s0) == QShaderPrivate::get(&s1)); + QCOMPARE(s0.stage(), s1.stage()); + + s1.setStage(QShader::FragmentStage); // call a setter to trigger a detach + QVERIFY(QShaderPrivate::get(&s0) != QShaderPrivate::get(&s1)); + QCOMPARE(s0.availableShaders().count(), 1); + QVERIFY(s0.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + QCOMPARE(s1.availableShaders().count(), 1); + QVERIFY(s1.availableShaders().contains(QShaderKey(QShader::SpirvShader, QShaderVersion(100)))); + QShaderDescription d0 = s0.description(); + QCOMPARE(d0.inputVariables().count(), 2); + QCOMPARE(d0.outputVariables().count(), 1); + QCOMPARE(d0.uniformBlocks().count(), 1); + QShaderDescription d1 = s1.description(); + QCOMPARE(d1.inputVariables().count(), 2); + QCOMPARE(d1.outputVariables().count(), 1); + QCOMPARE(d1.uniformBlocks().count(), 1); + QVERIFY(s0 != s1); + } +} + +#include <tst_qshader.moc> +QTEST_MAIN(tst_QShader) diff --git a/tests/auto/gui/rhi/rhi.pro b/tests/auto/gui/rhi/rhi.pro new file mode 100644 index 0000000000..cc548b7b8a --- /dev/null +++ b/tests/auto/gui/rhi/rhi.pro @@ -0,0 +1,4 @@ +TEMPLATE=subdirs +SUBDIRS= \ + qshader \ + qrhi diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 9acf877790..901284e131 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -609,37 +609,37 @@ void tst_QFont::sharing() QFont f; f.setStyleHint(QFont::Serif); f.exactMatch(); // loads engine - QCOMPARE(QFontPrivate::get(f)->ref.load(), 1); + QCOMPARE(QFontPrivate::get(f)->ref.loadRelaxed(), 1); QVERIFY(QFontPrivate::get(f)->engineData); - QCOMPARE(QFontPrivate::get(f)->engineData->ref.load(), 1 + refs_by_cache); + QCOMPARE(QFontPrivate::get(f)->engineData->ref.loadRelaxed(), 1 + refs_by_cache); QFont f2(f); QCOMPARE(QFontPrivate::get(f2), QFontPrivate::get(f)); - QCOMPARE(QFontPrivate::get(f2)->ref.load(), 2); + QCOMPARE(QFontPrivate::get(f2)->ref.loadRelaxed(), 2); QVERIFY(QFontPrivate::get(f2)->engineData); QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData); - QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 1 + refs_by_cache); + QCOMPARE(QFontPrivate::get(f2)->engineData->ref.loadRelaxed(), 1 + refs_by_cache); f2.setKerning(!f.kerning()); QVERIFY(QFontPrivate::get(f2) != QFontPrivate::get(f)); - QCOMPARE(QFontPrivate::get(f2)->ref.load(), 1); + QCOMPARE(QFontPrivate::get(f2)->ref.loadRelaxed(), 1); QVERIFY(QFontPrivate::get(f2)->engineData); QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData); - QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 2 + refs_by_cache); + QCOMPARE(QFontPrivate::get(f2)->engineData->ref.loadRelaxed(), 2 + refs_by_cache); f2 = f; QCOMPARE(QFontPrivate::get(f2), QFontPrivate::get(f)); - QCOMPARE(QFontPrivate::get(f2)->ref.load(), 2); + QCOMPARE(QFontPrivate::get(f2)->ref.loadRelaxed(), 2); QVERIFY(QFontPrivate::get(f2)->engineData); QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData); - QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 1 + refs_by_cache); + QCOMPARE(QFontPrivate::get(f2)->engineData->ref.loadRelaxed(), 1 + refs_by_cache); if (f.pointSize() > 0) f2.setPointSize(f.pointSize() * 2 / 3); else f2.setPixelSize(f.pixelSize() * 2 / 3); QVERIFY(QFontPrivate::get(f2) != QFontPrivate::get(f)); - QCOMPARE(QFontPrivate::get(f2)->ref.load(), 1); + QCOMPARE(QFontPrivate::get(f2)->ref.loadRelaxed(), 1); QVERIFY(!QFontPrivate::get(f2)->engineData); QVERIFY(QFontPrivate::get(f2)->engineData != QFontPrivate::get(f)->engineData); } diff --git a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp index 785cc3fef2..3d3211c7a2 100644 --- a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp +++ b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp @@ -217,7 +217,7 @@ void tst_QFontCache::clear() #ifdef QT_BUILD_INTERNAL QList<QFontEngine *> leakedEngines = QFontEngine_stopCollectingEngines(); -for (int i = 0; i < leakedEngines.size(); ++i) qWarning() << i << leakedEngines.at(i) << leakedEngines.at(i)->ref.load(); +for (int i = 0; i < leakedEngines.size(); ++i) qWarning() << i << leakedEngines.at(i) << leakedEngines.at(i)->ref.loadRelaxed(); // and we are not leaking! QCOMPARE(leakedEngines.size(), 0); #endif diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 064e37f73c..2b69801b59 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -211,8 +211,8 @@ void tst_QFontDatabase::widthTwoTimes() f.setPixelSize(pixelSize); QFontMetrics fm(f); - int w1 = fm.charWidth(text, 0); - int w2 = fm.charWidth(text, 0); + int w1 = fm.horizontalAdvance(text, 0); + int w2 = fm.horizontalAdvance(text, 0); QCOMPARE(w1, w2); } diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index d00dc251d8..b091edb64d 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -681,7 +681,7 @@ static bool checkPixels(const QImage &image, if (pixel != expectedRgb1 && pixel != expectedRgb2) { QString message; QDebug(&message) << "Color mismatch in image" << image - << "at" << x << ',' << y << ':' << showbase << hex << pixel + << "at" << x << ',' << y << ':' << Qt::showbase << Qt::hex << pixel << "(expected: " << expectedRgb1 << ',' << expectedRgb2 << ')'; *errorMessage = message.toLocal8Bit(); return false; diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index fe0b6dae49..664ca98a3f 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -34,6 +34,7 @@ #include <qtextdocumentfragment.h> #include <qtexttable.h> #include <qtextlist.h> +#include <qregularexpression.h> #include <qdebug.h> #include <private/qtextdocument_p.h> @@ -944,7 +945,7 @@ void tst_QTextDocumentFragment::namedAnchorFragments3() QCOMPARE(it.fragment().text(), QString::fromLatin1("T")); QVERIFY(it.fragment().charFormat().isAnchor()); - QCOMPARE(it.fragment().charFormat().anchorName(), QString("target")); + QCOMPARE(it.fragment().charFormat().anchorNames().constFirst(), QLatin1String("target")); QStringList targets; targets << "target" << "target2"; QCOMPARE(it.fragment().charFormat().anchorNames(), targets); @@ -1925,7 +1926,7 @@ void tst_QTextDocumentFragment::html_nobr() QString text = doc->begin().begin().fragment().text(); QString expectedText = input; - expectedText.replace(QRegExp("\\s+"), QString(QChar::Nbsp)); + expectedText.replace(QRegularExpression("\\s+"), QString(QChar::Nbsp)); QCOMPARE(text, expectedText); } diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 9c477589f9..aee2f970fe 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -138,6 +138,7 @@ private slots: void noModificationOfInputString(); void superscriptCrash_qtbug53911(); void showLineAndParagraphSeparatorsCrash(); + void koreanWordWrap(); private: QFont testFont; @@ -2227,7 +2228,6 @@ void tst_QTextLayout::superscriptCrash_qtbug53911() for (int j = 0; j < 4; ++j) { QTextLayout* newTextLayout = new QTextLayout(); newTextLayout->setText(layoutText); - QList<QTextLayout::FormatRange> formatRanges; QTextLayout::FormatRange formatRange; formatRange.format.setFont(QFont()); @@ -2256,8 +2256,7 @@ void tst_QTextLayout::superscriptCrash_qtbug53911() formatRange.start = 0; formatRange.length = layoutText.size(); - formatRanges << formatRange; - newTextLayout->setAdditionalFormats(formatRanges); + newTextLayout->setFormats({formatRange}); textLayouts.push_front(newTextLayout); } @@ -2288,10 +2287,7 @@ void tst_QTextLayout::nbspWithFormat() formatRange.length = 1; formatRange.format.setFontUnderline(true); - QList<QTextLayout::FormatRange> overrides; - overrides.append(formatRange); - - layout.setAdditionalFormats(overrides); + layout.setFormats({formatRange}); layout.beginLayout(); forever { @@ -2309,5 +2305,30 @@ void tst_QTextLayout::nbspWithFormat() QCOMPARE(layout.lineAt(1).textLength(), s2.length() + 1 + s3.length()); } +void tst_QTextLayout::koreanWordWrap() +{ + QString s = QString::fromUtf8("안녕하세요 여러분!"); + QTextLayout layout; + QTextOption option = layout.textOption(); + option.setWrapMode(QTextOption::WordWrap); + option.setFlags(QTextOption::Flag(QTextOption::IncludeTrailingSpaces)); + layout.setTextOption(option); + layout.setText(s); + + QFontMetrics metrics(layout.font()); + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + line.setLineWidth(metrics.horizontalAdvance(s) * 0.8); + } + layout.endLayout(); + QCOMPARE(layout.lineCount(), 2); + QCOMPARE(layout.lineAt(0).textLength(), 6); + QCOMPARE(layout.lineAt(1).textLength(), 4); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" diff --git a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp index d623ce4044..93e40e7f23 100644 --- a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp +++ b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp @@ -314,7 +314,7 @@ void tst_QTextList::partialRemoval() selection.deleteChar(); // deletes the second list QVERIFY(!secondList); - QVERIFY(!firstList->isEmpty()); + QVERIFY(firstList->count() > 0); doc->undo(); } diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/headingBulletsContinuations.md b/tests/auto/gui/text/qtextmarkdownimporter/data/headingBulletsContinuations.md new file mode 100644 index 0000000000..99eb633d17 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/data/headingBulletsContinuations.md @@ -0,0 +1,28 @@ +# heading +- bullet 1 + continuation line 1, indented via tab +- bullet 2 + continuation line 2, indented via 4 spaces +- bullet 3 + + continuation paragraph 3, indented via tab + + - bullet 3.1 + + continuation paragraph 3.1, indented via 4 spaces + + - bullet 3.2 + continuation line, indented via 2 tabs +- bullet 4 + + continuation paragraph 4, indented via 4 spaces + and continuing onto another line too + +- bullet 5 + + continuation paragraph 5, indented via 2 spaces and continuing onto another + line too + +- bullet 6 + +plain old paragraph at the end diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md b/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md new file mode 100644 index 0000000000..7a0d5388ad --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md @@ -0,0 +1,17 @@ +Heading +------- +*** +stars +- bullet + ** not a bullet or a rule, just two stars +- [ ] unchecked + + --- indented too far, so not a rule +* * * +stars with tabs between +*** +stars with whitespace after +--- +hyphens with whitespace after +_____ +underscores with whitespace after diff --git a/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro new file mode 100644 index 0000000000..7b7fb61244 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/qtextmarkdownimporter.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qtextmarkdownimporter +QT += core-private gui-private testlib +SOURCES += tst_qtextmarkdownimporter.cpp +TESTDATA += \ + data/thematicBreaks.md \ + data/headingBulletsContinuations.md \ + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp new file mode 100644 index 0000000000..8f51a7a474 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QTextDocument> +#include <QTextCursor> +#include <QTextBlock> +#include <QTextList> +#include <QTextTable> +#include <QBuffer> +#include <QDebug> + +#include <private/qtextmarkdownimporter_p.h> + +// #define DEBUG_WRITE_HTML + +Q_LOGGING_CATEGORY(lcTests, "qt.text.tests") + +static const QChar LineBreak = QChar(0x2028); +static const QChar Tab = QLatin1Char('\t'); +static const QChar Space = QLatin1Char(' '); +static const QChar Period = QLatin1Char('.'); + +class tst_QTextMarkdownImporter : public QObject +{ + Q_OBJECT + +private slots: + void headingBulletsContinuations(); + void thematicBreaks(); +}; + +void tst_QTextMarkdownImporter::headingBulletsContinuations() +{ + const QStringList expectedBlocks = QStringList() << + "" << // we could do without this blank line before the heading, but currently it happens + "heading" << + "bullet 1 continuation line 1, indented via tab" << + "bullet 2 continuation line 2, indented via 4 spaces" << + "bullet 3" << + "continuation paragraph 3, indented via tab" << + "bullet 3.1" << + "continuation paragraph 3.1, indented via 4 spaces" << + "bullet 3.2 continuation line, indented via 2 tabs" << + "bullet 4" << + "continuation paragraph 4, indented via 4 spaces and continuing onto another line too" << + "bullet 5" << + // indenting by only 2 spaces is perhaps non-standard but currently is OK + "continuation paragraph 5, indented via 2 spaces and continuing onto another line too" << + "bullet 6" << + "plain old paragraph at the end"; + + QFile f(QFINDTESTDATA("data/headingBulletsContinuations.md")); + QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text)); + QString md = QString::fromUtf8(f.readAll()); + f.close(); + + QTextDocument doc; + QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, md); + QTextFrame::iterator iterator = doc.rootFrame()->begin(); + QTextFrame *currentFrame = iterator.currentFrame(); + QStringList::const_iterator expectedIt = expectedBlocks.constBegin(); + int i = 0; + while (!iterator.atEnd()) { + // There are no child frames + QCOMPARE(iterator.currentFrame(), currentFrame); + // Check whether we got the right child block + QTextBlock block = iterator.currentBlock(); + QCOMPARE(block.text().contains(LineBreak), false); + QCOMPARE(block.text().contains(Tab), false); + QVERIFY(!block.text().startsWith(Space)); + int expectedIndentation = 0; + if (block.text().contains(QLatin1String("continuation paragraph"))) + expectedIndentation = (block.text().contains(Period) ? 2 : 1); + qCDebug(lcTests) << i << "child block" << block.text() << "indentation" << block.blockFormat().indent(); + QVERIFY(expectedIt != expectedBlocks.constEnd()); + QCOMPARE(block.text(), *expectedIt); + if (i > 2) + QCOMPARE(block.blockFormat().indent(), expectedIndentation); + ++iterator; + ++expectedIt; + ++i; + } + QCOMPARE(expectedIt, expectedBlocks.constEnd()); + +#ifdef DEBUG_WRITE_HTML + { + QFile out("/tmp/headingBulletsContinuations.html"); + out.open(QFile::WriteOnly); + out.write(doc.toHtml().toLatin1()); + out.close(); + } +#endif +} + +void tst_QTextMarkdownImporter::thematicBreaks() +{ + int horizontalRuleCount = 0; + int textLinesCount = 0; + + QFile f(QFINDTESTDATA("data/thematicBreaks.md")); + QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text)); + QString md = QString::fromUtf8(f.readAll()); + f.close(); + + QTextDocument doc; + QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, md); + QTextFrame::iterator iterator = doc.rootFrame()->begin(); + QTextFrame *currentFrame = iterator.currentFrame(); + int i = 0; + while (!iterator.atEnd()) { + // There are no child frames + QCOMPARE(iterator.currentFrame(), currentFrame); + // Check whether the block is text or a horizontal rule + QTextBlock block = iterator.currentBlock(); + if (block.blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) + ++horizontalRuleCount; + else if (!block.text().isEmpty()) + ++textLinesCount; + qCDebug(lcTests) << i << (block.blockFormat().hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth) ? QLatin1String("- - -") : block.text()); + ++iterator; + ++i; + } + QCOMPARE(horizontalRuleCount, 5); + QCOMPARE(textLinesCount, 9); + +#ifdef DEBUG_WRITE_HTML + { + QFile out("/tmp/thematicBreaks.html"); + out.open(QFile::WriteOnly); + out.write(doc.toHtml().toLatin1()); + out.close(); + } +#endif +} + +QTEST_MAIN(tst_QTextMarkdownImporter) +#include "tst_qtextmarkdownimporter.moc" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST b/tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST new file mode 100644 index 0000000000..fc9e5a9efe --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST @@ -0,0 +1,3 @@ +[rewriteDocument] +winrt # QTBUG-54623 + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md new file mode 100644 index 0000000000..6336d0219f --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md @@ -0,0 +1,62 @@ +In 1958, Mahatma Gandhi was quoted as follows: + +> The Earth provides enough to satisfy every man's need but not for every man's +> greed. + +In [The CommonMark Specification](https://spec.commonmark.org/0.29/) John +MacFarlane writes: + +> What distinguishes Markdown from many other lightweight markup syntaxes, +> which are often easier to write, is its readability. As Gruber writes: + +> > The overriding design goal for Markdown's formatting syntax is to make it +> > as readable as possible. The idea is that a Markdown-formatted document should +> > be publishable as-is, as plain text, without looking like it's been marked up +> > with tags or formatting instructions. ( +> > [http://daringfireball.net/projects/markdown/](http://daringfireball.net/projects/markdown/) +> > ) + +> The point can be illustrated by comparing a sample of AsciiDoc with an +> equivalent sample of Markdown. Here is a sample of AsciiDoc from the AsciiDoc +> manual: + +> ``` AsciiDoc +> 1. List item one. +> + +> List item one continued with a second paragraph followed by an +> Indented block. +> + +> ................. +> $ ls *.sh +> $ mv *.sh ~/tmp +> ................. +> + +> List item continued with a third paragraph. +> +> 2. List item two continued with an open block. +> ... +> ``` +The quotation includes an embedded quotation and a code quotation and ends with +an ellipsis due to being incomplete. + +Now let's have an indented code block: + + #include <stdio.h> + + int main(void) + { + printf("# hello markdown\n"); + return 0; + } + +and end with a fenced code block: +~~~ pseudocode +#include <something.h> +#include <else.h> + +a block { + a statement; + another statement; +} +~~~ + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md new file mode 100644 index 0000000000..0c3f34e09d --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md @@ -0,0 +1,95 @@ +# QTextEdit + +The QTextEdit widget is an advanced editor that supports formatted rich text. +It can be used to display HTML and other rich document formats. Internally, +QTextEdit uses the QTextDocument class to describe both the high-level +structure of each document and the low-level formatting of paragraphs. + +If you are viewing this document in the textedit example, you can edit this +document to explore Qt's rich text editing features. We have included some +comments in each of the following sections to encourage you to experiment. + +## Font and Paragraph Styles + +QTextEdit supports **bold**, *italic*, and ~~strikethrough~~ font styles, and can +display multicolored text. Font families such as Times New Roman and `Courier` +can also be used directly. *If you place the cursor in a region of styled text, +the controls in the tool bars will change to reflect the current style.* + +Paragraphs can be formatted so that the text is left-aligned, right-aligned, +centered, or fully justified. + +*Try changing the alignment of some text and resize the editor to see how the +text layout changes.* + +## Lists + +Different kinds of lists can be included in rich text documents. Standard +bullet lists can be nested, using different symbols for each level of the list: + +- Disc symbols are typically used for top-level list items. + * Circle symbols can be used to distinguish between items in lower-level + lists. + + Square symbols provide a reasonable alternative to discs and circles. + +Ordered lists can be created that can be used for tables of contents. Different +characters can be used to enumerate items, and we can use both Roman and Arabic +numerals in the same list structure: + +1. Introduction +2. Qt Tools + 1) Qt Assistant + 2) Qt Designer + 1. Form Editor + 2. Component Architecture + 3) Qt Linguist + +The list will automatically be renumbered if you add or remove items. *Try +adding new sections to the above list or removing existing item to see the +numbers change.* + +## Images + +Inline images are treated like ordinary ranges of characters in the text +editor, so they flow with the surrounding text. Images can also be selected in +the same way as text, making it easy to cut, copy, and paste them. + +![image](images/logo32.png) *Try to select this image by clicking and dragging +over it with the mouse, or use the text cursor to select it by holding down +Shift and using the arrow keys. You can then cut or copy it, and paste it into +different parts of this document.* + +## Tables + +QTextEdit can arrange and format tables, supporting features such as row and +column spans, text formatting within cells, and size constraints for columns. + + +| |Development Tools |Programming Techniques |Graphical User Interfaces| +|-------------|------------------------------------|---------------------------|-------------------------| +|9:00 - 11:00 |Introduction to Qt ||| +|11:00 - 13:00|Using qmake |Object-oriented Programming|Layouts in Qt | +|13:00 - 15:00|Qt Designer Tutorial |Extreme Programming |Writing Custom Styles | +|15:00 - 17:00|Qt Linguist and Internationalization| | | + +*Try adding text to the cells in the table and experiment with the alignment of +the paragraphs.* + +## Hyperlinks + +QTextEdit is designed to support hyperlinks between documents, and this feature +is used extensively in +[Qt Assistant](http://doc.qt.io/qt-5/qtassistant-index.html). Hyperlinks are +automatically created when an HTML file is imported into an editor. Since the +rich text framework supports hyperlinks natively, they can also be created +programatically. + +## Undo and Redo + +Full support for undo and redo operations is built into QTextEdit and the +underlying rich text framework. Operations on a document can be packaged +together to make editing a more comfortable experience for the user. + +*Try making changes to this document and press `Ctrl+Z` to undo them. You can +always recover the original contents of the document.* + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/headingsAndLists.md b/tests/auto/gui/text/qtextmarkdownwriter/data/headingsAndLists.md new file mode 100644 index 0000000000..d5d14fb168 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/headingsAndLists.md @@ -0,0 +1,12 @@ +# heading 1 + +- list item 1 +- list item 2 + +## heading 2 + +1) list item 1 +2) list item 2 + +the end paragraph + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/wordWrap.md b/tests/auto/gui/text/qtextmarkdownwriter/data/wordWrap.md new file mode 100644 index 0000000000..dacb0acf77 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/wordWrap.md @@ -0,0 +1,13 @@ +[The CommonMark Specification](https://spec.commonmark.org/0.29/) is the +conservative formal specification of the Markdown format, while +[GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) +adds extra features such as task lists and tables. + +Qt owes thanks to the authors of the [MD4C parser](https://github.com/mity/md4c) +for making markdown import possible. The QTextMarkdownWriter class does not +have such dependencies, and also has not yet been tested as extensively, so we +do not yet guarantee that we are able to rewrite every Markdown document that +you are able to read and display with Text or QTextEdit. But you are free to +write [bugs](https://bugreports.qt.io) about any troublesome cases that you +encounter. + diff --git a/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro b/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro new file mode 100644 index 0000000000..6144710b99 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/qtextmarkdownwriter.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qtextmarkdownwriter +QT += core-private gui-private testlib +SOURCES += tst_qtextmarkdownwriter.cpp +TESTDATA += \ + data/example.md \ + data/blockquotes.md \ + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp new file mode 100644 index 0000000000..8d38cbb18a --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -0,0 +1,464 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QTextDocument> +#include <QTextCursor> +#include <QTextBlock> +#include <QTextList> +#include <QTextTable> +#include <QBuffer> +#include <QDebug> + +#include <private/qtextmarkdownwriter_p.h> + +// #define DEBUG_WRITE_OUTPUT + +class tst_QTextMarkdownWriter : public QObject +{ + Q_OBJECT +public slots: + void init(); + void cleanup(); + +private slots: + void testWriteParagraph_data(); + void testWriteParagraph(); + void testWriteList(); + void testWriteNestedBulletLists_data(); + void testWriteNestedBulletLists(); + void testWriteNestedNumericLists(); + void testWriteTable(); + void rewriteDocument_data(); + void rewriteDocument(); + void fromHtml_data(); + void fromHtml(); + +private: + QString documentToUnixMarkdown(); + +private: + QTextDocument *document; +}; + +void tst_QTextMarkdownWriter::init() +{ + document = new QTextDocument(); +} + +void tst_QTextMarkdownWriter::cleanup() +{ + delete document; +} + +void tst_QTextMarkdownWriter::testWriteParagraph_data() +{ + QTest::addColumn<QString>("input"); + QTest::addColumn<QString>("output"); + + QTest::newRow("empty") << "" << + ""; + QTest::newRow("spaces") << "foobar word" << + "foobar word\n\n"; + QTest::newRow("starting spaces") << " starting spaces" << + " starting spaces\n\n"; + QTest::newRow("trailing spaces") << "trailing spaces " << + "trailing spaces \n\n"; + QTest::newRow("tab") << "word\ttab x" << + "word\ttab x\n\n"; + QTest::newRow("tab2") << "word\t\ttab\tx" << + "word\t\ttab\tx\n\n"; + QTest::newRow("misc") << "foobar word\ttab x" << + "foobar word\ttab x\n\n"; + QTest::newRow("misc2") << "\t \tFoo" << + "\t \tFoo\n\n"; +} + +void tst_QTextMarkdownWriter::testWriteParagraph() +{ + QFETCH(QString, input); + QFETCH(QString, output); + + QTextCursor cursor(document); + cursor.insertText(input); + + QCOMPARE(documentToUnixMarkdown(), output); +} + +void tst_QTextMarkdownWriter::testWriteList() +{ + QTextCursor cursor(document); + QTextList *list = cursor.createList(QTextListFormat::ListDisc); + cursor.insertText("ListItem 1"); + list->add(cursor.block()); + cursor.insertBlock(); + cursor.insertText("ListItem 2"); + list->add(cursor.block()); + + QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1( + "- ListItem 1\n- ListItem 2\n")); +} + +void tst_QTextMarkdownWriter::testWriteNestedBulletLists_data() +{ + QTest::addColumn<bool>("checkbox"); + QTest::addColumn<bool>("checked"); + QTest::addColumn<bool>("continuationLine"); + QTest::addColumn<bool>("continuationParagraph"); + QTest::addColumn<QString>("expectedOutput"); + + QTest::newRow("plain bullets") << false << false << false << false << + "- ListItem 1\n * ListItem 2\n + ListItem 3\n- ListItem 4\n * ListItem 5\n"; + QTest::newRow("bullets with continuation lines") << false << false << true << false << + "- ListItem 1\n * ListItem 2\n + ListItem 3 with text that won't fit on one line and thus needs a\n continuation\n- ListItem 4\n * ListItem 5 with text that won't fit on one line and thus needs a\n continuation\n"; + QTest::newRow("bullets with continuation paragraphs") << false << false << false << true << + "- ListItem 1\n\n * ListItem 2\n + ListItem 3\n\n continuation\n\n- ListItem 4\n\n * ListItem 5\n\n continuation\n\n"; + QTest::newRow("unchecked") << true << false << false << false << + "- [ ] ListItem 1\n * [ ] ListItem 2\n + [ ] ListItem 3\n- [ ] ListItem 4\n * [ ] ListItem 5\n"; + QTest::newRow("checked") << true << true << false << false << + "- [x] ListItem 1\n * [x] ListItem 2\n + [x] ListItem 3\n- [x] ListItem 4\n * [x] ListItem 5\n"; + QTest::newRow("checked with continuation lines") << true << true << true << false << + "- [x] ListItem 1\n * [x] ListItem 2\n + [x] ListItem 3 with text that won't fit on one line and thus needs a\n continuation\n- [x] ListItem 4\n * [x] ListItem 5 with text that won't fit on one line and thus needs a\n continuation\n"; + QTest::newRow("checked with continuation paragraphs") << true << true << false << true << + "- [x] ListItem 1\n\n * [x] ListItem 2\n + [x] ListItem 3\n\n continuation\n\n- [x] ListItem 4\n\n * [x] ListItem 5\n\n continuation\n\n"; +} + +void tst_QTextMarkdownWriter::testWriteNestedBulletLists() +{ + QFETCH(bool, checkbox); + QFETCH(bool, checked); + QFETCH(bool, continuationParagraph); + QFETCH(bool, continuationLine); + QFETCH(QString, expectedOutput); + + QTextCursor cursor(document); + QTextBlockFormat blockFmt = cursor.blockFormat(); + if (checkbox) { + blockFmt.setMarker(checked ? QTextBlockFormat::Checked : QTextBlockFormat::Unchecked); + cursor.setBlockFormat(blockFmt); + } + + QTextList *list1 = cursor.createList(QTextListFormat::ListDisc); + cursor.insertText("ListItem 1"); + list1->add(cursor.block()); + + QTextListFormat fmt2; + fmt2.setStyle(QTextListFormat::ListCircle); + fmt2.setIndent(2); + QTextList *list2 = cursor.insertList(fmt2); + cursor.insertText("ListItem 2"); + + QTextListFormat fmt3; + fmt3.setStyle(QTextListFormat::ListSquare); + fmt3.setIndent(3); + cursor.insertList(fmt3); + cursor.insertText(continuationLine ? + "ListItem 3 with text that won't fit on one line and thus needs a continuation" : + "ListItem 3"); + if (continuationParagraph) { + QTextBlockFormat blockFmt; + blockFmt.setIndent(2); + cursor.insertBlock(blockFmt); + cursor.insertText("continuation"); + } + + cursor.insertBlock(blockFmt); + cursor.insertText("ListItem 4"); + list1->add(cursor.block()); + + cursor.insertBlock(); + cursor.insertText(continuationLine ? + "ListItem 5 with text that won't fit on one line and thus needs a continuation" : + "ListItem 5"); + list2->add(cursor.block()); + if (continuationParagraph) { + QTextBlockFormat blockFmt; + blockFmt.setIndent(2); + cursor.insertBlock(blockFmt); + cursor.insertText("continuation"); + } + + QString output = documentToUnixMarkdown(); +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".md"); + out.open(QFile::WriteOnly); + out.write(output.toUtf8()); + out.close(); + } +#endif + QCOMPARE(documentToUnixMarkdown(), expectedOutput); +} + +void tst_QTextMarkdownWriter::testWriteNestedNumericLists() +{ + QTextCursor cursor(document); + + QTextList *list1 = cursor.createList(QTextListFormat::ListDecimal); + cursor.insertText("ListItem 1"); + list1->add(cursor.block()); + + QTextListFormat fmt2; + fmt2.setStyle(QTextListFormat::ListLowerAlpha); + fmt2.setNumberSuffix(QLatin1String(")")); + fmt2.setIndent(2); + QTextList *list2 = cursor.insertList(fmt2); + cursor.insertText("ListItem 2"); + + QTextListFormat fmt3; + fmt3.setStyle(QTextListFormat::ListDecimal); + fmt3.setIndent(3); + cursor.insertList(fmt3); + cursor.insertText("ListItem 3"); + + cursor.insertBlock(); + cursor.insertText("ListItem 4"); + list1->add(cursor.block()); + + cursor.insertBlock(); + cursor.insertText("ListItem 5"); + list2->add(cursor.block()); + + // There's no QTextList API to set the starting number so we hard-coded all lists to start at 1 (QTBUG-65384) + QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1( + "1. ListItem 1\n 1) ListItem 2\n 1. ListItem 3\n2. ListItem 4\n 2) ListItem 5\n")); +} + +void tst_QTextMarkdownWriter::testWriteTable() +{ + QTextCursor cursor(document); + QTextTable * table = cursor.insertTable(4, 3); + cursor = table->cellAt(0, 0).firstCursorPosition(); + // valid Markdown tables need headers, but QTextTable doesn't make that distinction + // so QTextMarkdownWriter assumes the first row of any table is a header + cursor.insertText("one"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("two"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("three"); + cursor.movePosition(QTextCursor::NextCell); + + cursor.insertText("alice"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("bob"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("carl"); + cursor.movePosition(QTextCursor::NextCell); + + cursor.insertText("dennis"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("eric"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("fiona"); + cursor.movePosition(QTextCursor::NextCell); + + cursor.insertText("gina"); + /* + |one |two |three| + |------|----|-----| + |alice |bob |carl | + |dennis|eric|fiona| + |gina | | | + */ + + QString md = documentToUnixMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/table.md"); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); + } +#endif + + QString expected = QString::fromLatin1( + "\n|one |two |three|\n|------|----|-----|\n|alice |bob |carl |\n|dennis|eric|fiona|\n|gina | | |\n\n"); + QCOMPARE(md, expected); + + // create table with merged cells + document->clear(); + cursor = QTextCursor(document); + table = cursor.insertTable(3, 3); + table->mergeCells(0, 0, 1, 2); + table->mergeCells(1, 1, 1, 2); + cursor = table->cellAt(0, 0).firstCursorPosition(); + cursor.insertText("a"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("b"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("c"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("d"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("e"); + cursor.movePosition(QTextCursor::NextCell); + cursor.insertText("f"); + /* + +---+-+ + |a |b| + +---+-+ + |c| d| + +-+-+-+ + |e|f| | + +-+-+-+ + + generates + + |a ||b| + |-|-|-| + |c|d || + |e|f| | + + */ + + md = documentToUnixMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/table-merged-cells.md"); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); + } +#endif + + QCOMPARE(md, QString::fromLatin1("\n|a ||b|\n|-|-|-|\n|c|d ||\n|e|f| |\n\n")); +} + +void tst_QTextMarkdownWriter::rewriteDocument_data() +{ + QTest::addColumn<QString>("inputFile"); + + QTest::newRow("block quotes") << "blockquotes.md"; + QTest::newRow("example") << "example.md"; + QTest::newRow("list items after headings") << "headingsAndLists.md"; + QTest::newRow("word wrap") << "wordWrap.md"; +} + +void tst_QTextMarkdownWriter::rewriteDocument() +{ + QFETCH(QString, inputFile); + QTextDocument doc; + QFile f(QFINDTESTDATA("data/" + inputFile)); + QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text)); + QString orig = QString::fromUtf8(f.readAll()); + f.close(); + doc.setMarkdown(orig); + QString md = doc.toMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + QFile out("/tmp/rewrite-" + inputFile); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); +#endif + + QCOMPARE(md, orig); +} + +void tst_QTextMarkdownWriter::fromHtml_data() +{ + QTest::addColumn<QString>("expectedInput"); + QTest::addColumn<QString>("expectedOutput"); + + QTest::newRow("long URL") << + "<span style=\"font-style:italic;\">https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/</span>" << + "*https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/*\n\n"; + QTest::newRow("non-emphasis inline asterisk") << "3 * 4" << "3 * 4\n\n"; + QTest::newRow("arithmetic") << "(2 * a * x + b)^2 = b^2 - 4 * a * c" << "(2 * a * x + b)^2 = b^2 - 4 * a * c\n\n"; + QTest::newRow("escaped asterisk after newline") << + "The first sentence of this paragraph holds 80 characters, then there's a star. * This is wrapped, but is <em>not</em> a bullet point." << + "The first sentence of this paragraph holds 80 characters, then there's a star.\n\\* This is wrapped, but is *not* a bullet point.\n\n"; + QTest::newRow("escaped plus after newline") << + "The first sentence of this paragraph holds 80 characters, then there's a plus. + This is wrapped, but is <em>not</em> a bullet point." << + "The first sentence of this paragraph holds 80 characters, then there's a plus.\n\\+ This is wrapped, but is *not* a bullet point.\n\n"; + QTest::newRow("escaped hyphen after newline") << + "The first sentence of this paragraph holds 80 characters, then there's a minus. - This is wrapped, but is <em>not</em> a bullet point." << + "The first sentence of this paragraph holds 80 characters, then there's a minus.\n\\- This is wrapped, but is *not* a bullet point.\n\n"; + QTest::newRow("list items with indented continuations") << + "<ul><li>bullet<p>continuation paragraph</p></li><li>another bullet<br/>continuation line</li></ul>" << + "- bullet\n\n continuation paragraph\n\n- another bullet\n continuation line\n"; + QTest::newRow("nested list items with continuations") << + "<ul><li>bullet<p>continuation paragraph</p></li><li>another bullet<br/>continuation line</li><ul><li>bullet<p>continuation paragraph</p></li><li>another bullet<br/>continuation line</li></ul></ul>" << + "- bullet\n\n continuation paragraph\n\n- another bullet\n continuation line\n\n - bullet\n\n continuation paragraph\n\n - another bullet\n continuation line\n"; + QTest::newRow("nested ordered list items with continuations") << + "<ol><li>item<p>continuation paragraph</p></li><li>another item<br/>continuation line</li><ol><li>item<p>continuation paragraph</p></li><li>another item<br/>continuation line</li></ol><li>another</li><li>another</li></ol>" << + "1. item\n\n continuation paragraph\n\n2. another item\n continuation line\n\n 1. item\n\n continuation paragraph\n\n 2. another item\n continuation line\n\n3. another\n4. another\n"; + QTest::newRow("thematic break") << + "something<hr/>something else" << + "something\n\n- - -\nsomething else\n\n"; + QTest::newRow("block quote") << + "<p>In 1958, Mahatma Gandhi was quoted as follows:</p><blockquote>The Earth provides enough to satisfy every man's need but not for every man's greed.</blockquote>" << + "In 1958, Mahatma Gandhi was quoted as follows:\n\n> The Earth provides enough to satisfy every man's need but not for every man's\n> greed.\n\n"; + QTest::newRow("image") << + "<img src=\"/url\" alt=\"foo\" title=\"title\"/>" << + "![foo](/url \"title\")\n\n"; + QTest::newRow("code") << + "<pre class=\"language-pseudocode\">\n#include \"foo.h\"\n\nblock {\n statement();\n}\n\n</pre>" << + "``` pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n"; + // TODO +// QTest::newRow("escaped number and paren after double newline") << +// "<p>(The first sentence of this paragraph is a line, the next paragraph has a number</p>13) but that's not part of an ordered list" << +// "(The first sentence of this paragraph is a line, the next paragraph has a number\n\n13\\) but that's not part of an ordered list\n\n"; +// QTest::newRow("preformats with embedded backticks") << +// "<pre>none `one` ``two``</pre><pre>```three``` ````four````</pre>plain" << +// "``` none `one` ``two`` ```\n\n````` ```three``` ````four```` `````\n\nplain\n\n"; +} + +void tst_QTextMarkdownWriter::fromHtml() +{ + QFETCH(QString, expectedInput); + QFETCH(QString, expectedOutput); + + document->setHtml(expectedInput); + QString output = documentToUnixMarkdown(); + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".md"); + out.open(QFile::WriteOnly); + out.write(output.toUtf8()); + out.close(); + } +#endif + + QCOMPARE(output, expectedOutput); +} + +QString tst_QTextMarkdownWriter::documentToUnixMarkdown() +{ + QString ret; + QTextStream ts(&ret, QIODevice::WriteOnly); + QTextMarkdownWriter writer(ts, QTextDocument::MarkdownDialectGitHub); + writer.writeAll(document); + return ret; +} + +QTEST_MAIN(tst_QTextMarkdownWriter) +#include "tst_qtextmarkdownwriter.moc" diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro index 6b033fb506..794d9ea8d3 100644 --- a/tests/auto/gui/text/text.pro +++ b/tests/auto/gui/text/text.pro @@ -28,12 +28,16 @@ SUBDIRS=\ win32:SUBDIRS -= qtextpiecetable +qtConfig(textmarkdownreader): SUBDIRS += qtextmarkdownimporter +qtConfig(textmarkdownwriter): SUBDIRS += qtextmarkdownwriter + !qtConfig(private_tests): SUBDIRS -= \ qfontcache \ qcssparser \ qtextlayout \ qtextpiecetable \ qzip \ + qtextmarkdownwriter \ qtextodfwriter !qtHaveModule(xml): SUBDIRS -= \ diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index f162c3ae9f..77298342af 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -72,15 +72,20 @@ public: } #ifdef QT_NETWORK_LIB - static QHostAddress serverIP() + static QHostAddress getServerIpImpl(const QString &serverName) { - const QHostInfo info = QHostInfo::fromName(serverName()); + const QHostInfo info = QHostInfo::fromName(serverName); if (info.error()) { QTest::qFail(qPrintable(info.errorString()), __FILE__, __LINE__); return QHostAddress(); } return info.addresses().constFirst(); } + + static QHostAddress serverIP() + { + return getServerIpImpl(serverName()); + } #endif static bool compareReplyIMAP(QByteArray const& actual) @@ -104,8 +109,8 @@ public: static bool compareReplyFtp(QByteArray const& actual) { // output would be e.g. "220 (vsFTPd 2.3.5)\r\n221 Goodbye.\r\n" - QRegExp ftpVersion(QStringLiteral("220 \\(vsFTPd \\d+\\.\\d+.\\d+\\)\\r\\n221 Goodbye.\\r\\n")); - return ftpVersion.exactMatch(actual); + QRegularExpression ftpVersion(QRegularExpression::anchoredPattern(QStringLiteral("220 \\(vsFTPd \\d+\\.\\d+.\\d+\\)\\r\\n221 Goodbye.\\r\\n"))); + return ftpVersion.match(actual).hasMatch(); } static bool hasIPv6() @@ -214,4 +219,67 @@ public: return serverName(); #endif } + static QString imapServerName() + { +#ifdef QT_TEST_SERVER_NAME + return QString("cyrus.") % serverDomainName(); +#else + return serverName(); +#endif + } + + static QString echoServerName() + { +#ifdef QT_TEST_SERVER_NAME + return QString("echo.") % serverDomainName(); +#else + return serverName(); +#endif + } + + static QString firewallServerName() + { +#ifdef QT_TEST_SERVER_NAME + return QString("iptables.") % serverDomainName(); +#else + return serverName(); +#endif + } + +#ifdef QT_NETWORK_LIB + static QHostAddress imapServerIp() + { + return getServerIpImpl(imapServerName()); + } + + static QHostAddress httpServerIp() + { + return getServerIpImpl(httpServerName()); + } + + static QHostAddress httpProxyServerIp() + { + return getServerIpImpl(httpProxyServerName()); + } + + static QHostAddress socksProxyServerIp() + { + return getServerIpImpl(socksProxyServerName()); + } + + static QHostAddress ftpProxyServerIp() + { + return getServerIpImpl(ftpProxyServerName()); + } + + static QHostAddress ftpServerIp() + { + return getServerIpImpl(ftpServerName()); + } + + static QHostAddress firewallServerIp() + { + return getServerIpImpl(firewallServerName()); + } +#endif }; diff --git a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro index 1874f001ab..c722100ead 100644 --- a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro +++ b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro @@ -5,3 +5,5 @@ SOURCES += tst_qabstractnetworkcache.cpp TESTDATA += tests/* +CONFIG += unsupported/testserver +QT_TEST_SERVER_LIST = apache2 diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index b8d9adf7a1..182e3e9547 100644 --- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -39,7 +39,7 @@ #include <algorithm> -#define TESTFILE QLatin1String("http://") + QtNetworkSettings::serverName() + QLatin1String("/qtest/cgi-bin/") +#define TESTFILE QLatin1String("http://") + QtNetworkSettings::httpServerName() + QLatin1String("/qtest/cgi-bin/") class tst_QAbstractNetworkCache : public QObject { @@ -127,8 +127,13 @@ Q_DECLARE_METATYPE(QNetworkRequest::CacheLoadControl) void tst_QAbstractNetworkCache::initTestCase() { +#if defined(QT_TEST_SERVER) + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif + #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); networkConfiguration = netConfMan->defaultConfiguration(); diff --git a/tests/auto/network/access/qftp/qftp.pro b/tests/auto/network/access/qftp/qftp.pro index 1959c1acac..c78020c5f8 100644 --- a/tests/auto/network/access/qftp/qftp.pro +++ b/tests/auto/network/access/qftp/qftp.pro @@ -4,3 +4,6 @@ SOURCES += tst_qftp.cpp requires(qtConfig(private_tests)) QT = core network network-private testlib + +CONFIG += unsupported/testserver +QT_TEST_SERVER_LIST = vsftpd ftp-proxy squid danted diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index 1a8f264c28..a04c2ae01d 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -43,6 +43,7 @@ #include <QtNetwork/private/qnetworksession_p.h> #include <QTcpServer> #include <QHostInfo> +#include <QElapsedTimer> #include <QTcpSocket> #include "../../../network-settings.h" @@ -133,8 +134,8 @@ private: bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString() ); bool dirExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &cdDir, const QString &dirToCreate ); - void renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile ); - void renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete ); + void renameInit( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &createFile ); + void renameCleanup( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &fileToDelete ); QFtp *ftp; #ifndef QT_NO_BEARERMANAGEMENT @@ -208,7 +209,14 @@ void tst_QFtp::initTestCase_data() void tst_QFtp::initTestCase() { +#if defined(QT_TEST_SERVER) + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpServerName(), 21)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif #ifndef QT_NO_BEARERMANAGEMENT QNetworkConfigurationManager manager; networkSessionImplicit = QSharedPointer<QNetworkSession>::create(manager.defaultConfiguration()); @@ -235,9 +243,9 @@ void tst_QFtp::init() if (setProxy) { #ifndef QT_NO_NETWORKPROXY if (proxyType == QNetworkProxy::Socks5Proxy) { - QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); } else if (proxyType == QNetworkProxy::HttpProxy) { - QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128)); } #else // !QT_NO_NETWORKPROXY Q_UNUSED(proxyType); @@ -316,8 +324,8 @@ void tst_QFtp::connectToHost_data() QTest::addColumn<uint>("port"); QTest::addColumn<int>("state"); - QTest::newRow( "ok01" ) << QtNetworkSettings::serverName() << (uint)21 << (int)QFtp::Connected; - QTest::newRow( "error01" ) << QtNetworkSettings::serverName() << (uint)2222 << (int)QFtp::Unconnected; + QTest::newRow( "ok01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << (int)QFtp::Connected; + QTest::newRow( "error01" ) << QtNetworkSettings::ftpServerName() << (uint)2222 << (int)QFtp::Unconnected; QTest::newRow( "error02" ) << QString("foo.bar") << (uint)21 << (int)QFtp::Unconnected; } @@ -328,7 +336,11 @@ static QByteArray msgTimedOut(const QString &host, quint16 port = 0) result += ':'; result += QByteArray::number(port); } - return result; + + if (host == QtNetworkSettings::ftpServerName()) + return "(QTBUG-75549) Flaky results: " % result; + else + return result; } void tst_QFtp::connectToHost() @@ -343,7 +355,7 @@ void tst_QFtp::connectToHost() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); QTEST( connectToHost_state, "state" ); @@ -402,13 +414,13 @@ void tst_QFtp::login_data() QTest::addColumn<QString>("password"); QTest::addColumn<int>("success"); - QTest::newRow( "ok01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << 1; - QTest::newRow( "ok02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftp") << QString("") << 1; - QTest::newRow( "ok03" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftp") << QString("foo") << 1; - QTest::newRow( "ok04" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << 1; + QTest::newRow( "ok01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << 1; + QTest::newRow( "ok02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftp") << QString("") << 1; + QTest::newRow( "ok03" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftp") << QString("foo") << 1; + QTest::newRow( "ok04" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << 1; - QTest::newRow( "error01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("foo") << QString("") << 0; - QTest::newRow( "error02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("foo") << QString("bar") << 0; + QTest::newRow( "error01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("foo") << QString("") << 0; + QTest::newRow( "error02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("foo") << QString("bar") << 0; } void tst_QFtp::login() @@ -426,7 +438,7 @@ void tst_QFtp::login() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Login ); QVERIFY( it != resultMap.end() ); @@ -448,12 +460,12 @@ void tst_QFtp::close_data() QTest::addColumn<QString>("password"); QTest::addColumn<bool>("login"); - QTest::newRow( "login01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << true; - QTest::newRow( "login02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftp") << QString() << true; - QTest::newRow( "login03" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftp") << QString("foo") << true; - QTest::newRow( "login04" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << true; + QTest::newRow( "login01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << true; + QTest::newRow( "login02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftp") << QString() << true; + QTest::newRow( "login03" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftp") << QString("foo") << true; + QTest::newRow( "login04" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << true; - QTest::newRow( "no-login01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("") << QString("") << false; + QTest::newRow( "no-login01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("") << QString("") << false; } void tst_QFtp::close() @@ -474,7 +486,7 @@ void tst_QFtp::close() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); QCOMPARE( close_state, (int)QFtp::Unconnected ); @@ -503,17 +515,17 @@ void tst_QFtp::list_data() flukeQtest << "rfc3252.txt"; flukeQtest << "upload"; - QTest::newRow( "workDir01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString() << 1 << flukeRoot; - QTest::newRow( "workDir02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << QString() << 1 << flukeRoot; + QTest::newRow( "workDir01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString() << 1 << flukeRoot; + QTest::newRow( "workDir02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString() << 1 << flukeRoot; - QTest::newRow( "relPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("qtest") << 1 << flukeQtest; - QTest::newRow( "relPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest") << 1 << flukeQtest; + QTest::newRow( "relPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("qtest") << 1 << flukeQtest; + QTest::newRow( "relPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest") << 1 << flukeQtest; - QTest::newRow( "absPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("/qtest") << 1 << flukeQtest; - QTest::newRow( "absPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << QString("/var/ftp/qtest") << 1 << flukeQtest; + QTest::newRow( "absPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/qtest") << 1 << flukeQtest; + QTest::newRow( "absPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("/var/ftp/qtest") << 1 << flukeQtest; - QTest::newRow( "nonExist01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("foo") << 1 << QStringList(); - QTest::newRow( "nonExist02" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("/foo") << 1 << QStringList(); + QTest::newRow( "nonExist01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("foo") << 1 << QStringList(); + QTest::newRow( "nonExist02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/foo") << 1 << QStringList(); // ### The microsoft server does not seem to work properly at the moment -- // I am also not able to open a data connection with other, non-Qt FTP // clients to it. @@ -542,7 +554,7 @@ void tst_QFtp::list() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::List ); QVERIFY( it != resultMap.end() ); @@ -573,14 +585,14 @@ void tst_QFtp::cd_data() flukeQtest << "rfc3252.txt"; flukeQtest << "upload"; - QTest::newRow( "relPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("qtest") << 1 << flukeQtest; - QTest::newRow( "relPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest") << 1 << flukeQtest; + QTest::newRow( "relPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("qtest") << 1 << flukeQtest; + QTest::newRow( "relPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest") << 1 << flukeQtest; - QTest::newRow( "absPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("/qtest") << 1 << flukeQtest; - QTest::newRow( "absPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << QString("/var/ftp/qtest") << 1 << flukeQtest; + QTest::newRow( "absPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/qtest") << 1 << flukeQtest; + QTest::newRow( "absPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("/var/ftp/qtest") << 1 << flukeQtest; - QTest::newRow( "nonExist01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("foo") << 0 << QStringList(); - QTest::newRow( "nonExist03" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("/foo") << 0 << QStringList(); + QTest::newRow( "nonExist01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("foo") << 0 << QStringList(); + QTest::newRow( "nonExist03" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/foo") << 0 << QStringList(); } void tst_QFtp::cd() @@ -603,7 +615,7 @@ void tst_QFtp::cd() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) { - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); } ResMapIt it = resultMap.find( QFtp::Cd ); @@ -635,19 +647,19 @@ void tst_QFtp::get_data() // test the two get() overloads in one routine for ( int i=0; i<2; i++ ) { const QByteArray iB = QByteArray::number(i); - QTest::newRow(("relPath01_" + iB).constData()) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow(("relPath01_" + iB).constData()) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << "qtest/rfc3252" << 1 << rfc3252 << (bool)(i==1); - QTest::newRow(("relPath02_" + iB).constData()) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow(("relPath02_" + iB).constData()) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << "qtest/rfc3252" << 1 << rfc3252 << (bool)(i==1); - QTest::newRow(("absPath01_" + iB).constData()) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow(("absPath01_" + iB).constData()) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << "/qtest/rfc3252" << 1 << rfc3252 << (bool)(i==1); - QTest::newRow(("absPath02_" + iB).constData()) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow(("absPath02_" + iB).constData()) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << "/var/ftp/qtest/rfc3252" << 1 << rfc3252 << (bool)(i==1); - QTest::newRow(("nonExist01_" + iB).constData()) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow(("nonExist01_" + iB).constData()) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("foo") << 0 << QByteArray() << (bool)(i==1); - QTest::newRow(("nonExist02_" + iB).constData()) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow(("nonExist02_" + iB).constData()) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/foo") << 0 << QByteArray() << (bool)(i==1); } } @@ -680,7 +692,7 @@ void tst_QFtp::get() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Get ); QVERIFY( it != resultMap.end() ); @@ -727,31 +739,31 @@ void tst_QFtp::put_data() // test the two put() overloads in one routine with a file name containing // U+0x00FC (latin small letter u with diaeresis) for QTBUG-52303, testing UTF-8 for ( int i=0; i<2; i++ ) { - QTest::newRow(("relPath01_" + QByteArray::number(i)).constData()) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow(("relPath01_" + QByteArray::number(i)).constData()) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << (QLatin1String("qtest/upload/rel01_") + QChar(0xfc) + QLatin1String("%1")) << rfc3252 << (bool)(i==1) << 1; /* - QTest::newRow( QString("relPath02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow( QString("relPath02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest/upload/rel02_%1") << rfc3252 << (bool)(i==1) << 1; - QTest::newRow( QString("relPath03_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow( QString("relPath03_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest/upload/rel03_%1") << QByteArray() << (bool)(i==1) << 1; - QTest::newRow( QString("relPath04_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow( QString("relPath04_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest/upload/rel04_%1") << bigData << (bool)(i==1) << 1; - QTest::newRow( QString("absPath01_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow( QString("absPath01_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/qtest/upload/abs01_%1") << rfc3252 << (bool)(i==1) << 1; - QTest::newRow( QString("absPath02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow( QString("absPath02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("/srv/ftp/qtest/upload/abs02_%1") << rfc3252 << (bool)(i==1) << 1; - QTest::newRow( QString("nonExist01_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow( QString("nonExist01_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("foo") << QByteArray() << (bool)(i==1) << 0; - QTest::newRow( QString("nonExist02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow( QString("nonExist02_%1").arg(i).toLatin1().constData() ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/foo") << QByteArray() << (bool)(i==1) << 0; */ @@ -807,7 +819,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Put ); QVERIFY( it != resultMap.end() ); @@ -840,7 +852,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); QCOMPARE( done_success, 1 ); QTEST( buf.buffer(), "fileData" ); @@ -858,7 +870,7 @@ void tst_QFtp::put() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -877,22 +889,22 @@ void tst_QFtp::mkdir_data() QTest::addColumn<QString>("dirToCreate"); QTest::addColumn<int>("success"); - QTest::newRow( "relPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow( "relPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << "qtest/upload" << QString("rel01_%1") << 1; - QTest::newRow( "relPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow( "relPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << "qtest/upload" << QString("rel02_%1") << 1; - QTest::newRow( "relPath03" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow( "relPath03" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << "qtest/upload" << QString("rel03_%1") << 1; - QTest::newRow( "absPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow( "absPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << "." << QString("/qtest/upload/abs01_%1") << 1; - QTest::newRow( "absPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") + QTest::newRow( "absPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << "." << QString("/var/ftp/qtest/upload/abs02_%1") << 1; - // QTest::newRow( "nonExist01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("foo") << 0; - QTest::newRow( "nonExist01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + // QTest::newRow( "nonExist01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("foo") << 0; + QTest::newRow( "nonExist01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << "." << QString("foo") << 0; - QTest::newRow( "nonExist02" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() + QTest::newRow( "nonExist02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << "." << QString("/foo") << 0; } @@ -922,7 +934,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( QFtp::Mkdir ); QVERIFY( it != resultMap.end() ); @@ -947,7 +959,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Mkdir ); QVERIFY( it != resultMap.end() ); @@ -967,7 +979,7 @@ void tst_QFtp::mkdir() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Rmdir ); QVERIFY( it != resultMap.end() ); @@ -979,7 +991,7 @@ void tst_QFtp::mkdir() void tst_QFtp::mkdir2() { ftp = new QFtp; - ftp->connectToHost(QtNetworkSettings::serverName()); + ftp->connectToHost(QtNetworkSettings::ftpServerName()); ftp->login(); current_id = ftp->cd("kake/test"); @@ -1026,47 +1038,48 @@ void tst_QFtp::rename_data() QTest::addColumn<QString>("renamedFile"); QTest::addColumn<int>("success"); - QTest::newRow("relPath01") << QtNetworkSettings::serverName() << QString() << QString() + QTest::newRow("relPath01") << QtNetworkSettings::ftpServerName() << QString() << QString() << "qtest/upload" << QString("rel_old01_%1") << QString("rel_new01_%1") << QString("qtest/upload/rel_old01_%1") << QString("qtest/upload/rel_new01_%1") << 1; - QTest::newRow("relPath02") << QtNetworkSettings::serverName() << QString("ftptest") << "password" + QTest::newRow("relPath02") << QtNetworkSettings::ftpServerName() << QString("ftptest") << "password" << "qtest/upload" << QString("rel_old02_%1") << QString("rel_new02_%1") << QString("qtest/upload/rel_old02_%1") << QString("qtest/upload/rel_new02_%1") << 1; - QTest::newRow("relPath03") << QtNetworkSettings::serverName() << QString("ftptest") << "password" + QTest::newRow("relPath03") << QtNetworkSettings::ftpServerName() << QString("ftptest") << "password" << "qtest/upload" << QString("rel_old03_%1")<< QString("rel_new03_%1") << QString("qtest/upload/rel_old03_%1") << QString("qtest/upload/rel_new03_%1") << 1; - QTest::newRow("absPath01") << QtNetworkSettings::serverName() << QString() << QString() + QTest::newRow("absPath01") << QtNetworkSettings::ftpServerName() << QString() << QString() << QString() << QString("/qtest/upload/abs_old01_%1") << QString("/qtest/upload/abs_new01_%1") << QString("/qtest/upload/abs_old01_%1") << QString("/qtest/upload/abs_new01_%1") << 1; - QTest::newRow("absPath02") << QtNetworkSettings::serverName() << QString("ftptest") << "password" + QTest::newRow("absPath02") << QtNetworkSettings::ftpServerName() << QString("ftptest") << "password" << QString() << QString("/var/ftp/qtest/upload/abs_old02_%1") << QString("/var/ftp/qtest/upload/abs_new02_%1") << QString("/var/ftp/qtest/upload/abs_old02_%1") << QString("/var/ftp/qtest/upload/abs_new02_%1") << 1; - QTest::newRow("nonExist01") << QtNetworkSettings::serverName() << QString() << QString() + QTest::newRow("nonExist01") << QtNetworkSettings::ftpServerName() << QString() << QString() << QString() << QString("foo") << "new_foo" << QString() << QString() << 0; - QTest::newRow("nonExist02") << QtNetworkSettings::serverName() << QString() << QString() + QTest::newRow("nonExist02") << QtNetworkSettings::ftpServerName() << QString() << QString() << QString() << QString("/foo") << QString("/new_foo") << QString() << QString() << 0; } -void tst_QFtp::renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile ) +void tst_QFtp::renameInit( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &createFile ) { + isSuccess = false; if ( !createFile.isNull() ) { // upload the file init(); @@ -1080,7 +1093,7 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Put ); QVERIFY( it != resultMap.end() ); @@ -1088,10 +1101,12 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri QVERIFY( fileExists( host, 21, user, password, createFile ) ); } + isSuccess = true; } -void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete ) +void tst_QFtp::renameCleanup( bool &isSuccess, const QString &host, const QString &user, const QString &password, const QString &fileToDelete ) { + isSuccess = false; if ( !fileToDelete.isNull() ) { // cleanup (i.e. remove the file) init(); @@ -1105,7 +1120,7 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -1113,6 +1128,7 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS QVERIFY( !fileExists( host, 21, user, password, fileToDelete ) ); } + isSuccess = true; } void tst_QFtp::rename() @@ -1135,7 +1151,10 @@ void tst_QFtp::rename() if(renamedFile.contains('%')) renamedFile = renamedFile.arg(uniqueExtension); - renameInit( host, user, password, createFile ); + bool isSuccess = true; + renameInit(isSuccess, host, user, password, createFile); + if (!isSuccess) + QSKIP("(QTBUG-75549) abort test when there is an error in helper functions"); init(); ftp = newFtp(); @@ -1150,7 +1169,7 @@ void tst_QFtp::rename() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); ResMapIt it = resultMap.find( QFtp::Rename ); QVERIFY( it != resultMap.end() ); @@ -1165,7 +1184,9 @@ void tst_QFtp::rename() QVERIFY( !fileExists( host, 21, user, password, renamedFile ) ); } - renameCleanup( host, user, password, renamedFile ); + renameCleanup(isSuccess, host, user, password, renamedFile); + if (!isSuccess) + QSKIP("(QTBUG-75549) abort test when there is an error in helper functions"); } /* @@ -1220,7 +1241,7 @@ void tst_QFtp::commandSequence_data() { // some "constants" QStringList argConnectToHost01; - argConnectToHost01 << QtNetworkSettings::serverName() << "21"; + argConnectToHost01 << QtNetworkSettings::ftpServerName() << "21"; QStringList argLogin01, argLogin02, argLogin03, argLogin04; argLogin01 << QString() << QString(); @@ -1339,7 +1360,7 @@ void tst_QFtp::commandSequence() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + QSKIP( msgTimedOut(host) ); QTEST( commandSequence_success, "success" ); } @@ -1351,13 +1372,13 @@ void tst_QFtp::abort_data() QTest::addColumn<QString>("file"); QTest::addColumn<QByteArray>("uploadData"); - QTest::newRow( "get_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/bigfile") << QByteArray(); - QTest::newRow( "get_fluke02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/rfc3252") << QByteArray(); + QTest::newRow( "get_fluke01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("qtest/bigfile") << QByteArray(); + QTest::newRow( "get_fluke02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("qtest/rfc3252") << QByteArray(); // Qt/CE test environment has too little memory for this test QByteArray bigData( 10*1024*1024, 0 ); bigData.fill( 'B' ); - QTest::newRow( "put_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/upload/abort_put") << bigData; + QTest::newRow( "put_fluke01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("qtest/upload/abort_put") << bigData; } void tst_QFtp::abort() @@ -1394,7 +1415,7 @@ void tst_QFtp::abort() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); ResMapIt it = resultMap.find( cmd ); QVERIFY( it != resultMap.end() ); @@ -1402,7 +1423,7 @@ void tst_QFtp::abort() if ( it.value().success ) { // The FTP server on fluke is sadly returning a success, even when // the operation was aborted. So we have to use some heuristics. - if ( host == QtNetworkSettings::serverName() ) { + if ( host == QtNetworkSettings::ftpServerName() ) { if ( cmd == QFtp::Get ) { QVERIFY2(bytesDone <= bytesTotal, msgComparison(bytesDone, "<=", bytesTotal)); } else { @@ -1432,7 +1453,7 @@ void tst_QFtp::abort() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); @@ -1449,11 +1470,11 @@ void tst_QFtp::bytesAvailable_data() QTest::addColumn<qlonglong>("bytesAvailFinished"); QTest::addColumn<qlonglong>("bytesAvailDone"); - QTest::newRow( "fluke01" ) << QtNetworkSettings::serverName() << QString("qtest/bigfile") << 0 << (qlonglong)519240 << (qlonglong)519240 << (qlonglong)519240; - QTest::newRow( "fluke02" ) << QtNetworkSettings::serverName() << QString("qtest/rfc3252") << 0 << (qlonglong)25962 << (qlonglong)25962 << (qlonglong)25962; + QTest::newRow( "fluke01" ) << QtNetworkSettings::ftpServerName() << QString("qtest/bigfile") << 0 << (qlonglong)519240 << (qlonglong)519240 << (qlonglong)519240; + QTest::newRow( "fluke02" ) << QtNetworkSettings::ftpServerName() << QString("qtest/rfc3252") << 0 << (qlonglong)25962 << (qlonglong)25962 << (qlonglong)25962; - QTest::newRow( "fluke03" ) << QtNetworkSettings::serverName() << QString("qtest/bigfile") << 1 << (qlonglong)519240 << (qlonglong)0 << (qlonglong)0; - QTest::newRow( "fluke04" ) << QtNetworkSettings::serverName() << QString("qtest/rfc3252") << 1 << (qlonglong)25962 << (qlonglong)0 << (qlonglong)0; + QTest::newRow( "fluke03" ) << QtNetworkSettings::ftpServerName() << QString("qtest/bigfile") << 1 << (qlonglong)519240 << (qlonglong)0 << (qlonglong)0; + QTest::newRow( "fluke04" ) << QtNetworkSettings::ftpServerName() << QString("qtest/rfc3252") << 1 << (qlonglong)25962 << (qlonglong)0 << (qlonglong)0; } void tst_QFtp::bytesAvailable() @@ -1470,8 +1491,11 @@ void tst_QFtp::bytesAvailable() addCommand( QFtp::Close, ftp->close() ); QTestEventLoop::instance().enterLoop( 40 ); - if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(host) ); + if ( QTestEventLoop::instance().timeout() ) { + delete ftp; + ftp = 0; + QSKIP( msgTimedOut(host) ); + } ResMapIt it = resultMap.find( QFtp::Get ); QVERIFY( it != resultMap.end() ); @@ -1498,7 +1522,7 @@ void tst_QFtp::activeMode() file.open(QIODevice::ReadWrite); QFtp ftp; ftp.setTransferMode(QFtp::Active); - ftp.connectToHost(QtNetworkSettings::serverName(), 21); + ftp.connectToHost(QtNetworkSettings::ftpServerName(), 21); ftp.login(); ftp.list(); ftp.get("/qtest/rfc3252.txt", &file); @@ -1534,14 +1558,14 @@ void tst_QFtp::proxy_data() flukeQtest << "rfc3252.txt"; flukeQtest << "upload"; - QTest::newRow( "proxy_relPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("qtest") << 1 << flukeQtest; - QTest::newRow( "proxy_relPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest") << 1 << flukeQtest; + QTest::newRow( "proxy_relPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("qtest") << 1 << flukeQtest; + QTest::newRow( "proxy_relPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("qtest") << 1 << flukeQtest; - QTest::newRow( "proxy_absPath01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("/qtest") << 1 << flukeQtest; - QTest::newRow( "proxy_absPath02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("ftptest") << QString("password") << QString("/var/ftp/qtest") << 1 << flukeQtest; + QTest::newRow( "proxy_absPath01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/qtest") << 1 << flukeQtest; + QTest::newRow( "proxy_absPath02" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString("ftptest") << QString("password") << QString("/var/ftp/qtest") << 1 << flukeQtest; - QTest::newRow( "proxy_nonExist01" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("foo") << 0 << QStringList(); - QTest::newRow( "proxy_nonExist03" ) << QtNetworkSettings::serverName() << (uint)21 << QString() << QString() << QString("/foo") << 0 << QStringList(); + QTest::newRow( "proxy_nonExist01" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("foo") << 0 << QStringList(); + QTest::newRow( "proxy_nonExist03" ) << QtNetworkSettings::ftpServerName() << (uint)21 << QString() << QString() << QString("/foo") << 0 << QStringList(); } void tst_QFtp::proxy() @@ -1553,7 +1577,7 @@ void tst_QFtp::proxy() QFETCH( QString, dir ); ftp = newFtp(); - addCommand( QFtp::SetProxy, ftp->setProxy( QtNetworkSettings::serverName(), 2121 ) ); + addCommand( QFtp::SetProxy, ftp->setProxy( QtNetworkSettings::ftpProxyServerName(), 2121 ) ); addCommand( QFtp::ConnectToHost, ftp->connectToHost( host, port ) ); addCommand( QFtp::Login, ftp->login( user, password ) ); addCommand( QFtp::Cd, ftp->cd( dir ) ); @@ -1564,7 +1588,7 @@ void tst_QFtp::proxy() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) { - QFAIL( msgTimedOut(host, port) ); + QSKIP( msgTimedOut(host, port) ); } ResMapIt it = resultMap.find( QFtp::Cd ); @@ -1589,7 +1613,7 @@ void tst_QFtp::binaryAscii() init(); ftp = newFtp(); - addCommand(QFtp::ConnectToHost, ftp->connectToHost(QtNetworkSettings::serverName(), 21)); + addCommand(QFtp::ConnectToHost, ftp->connectToHost(QtNetworkSettings::ftpServerName(), 21)); addCommand(QFtp::Login, ftp->login("ftptest", "password")); addCommand(QFtp::Cd, ftp->cd("qtest/upload")); addCommand(QFtp::Put, ftp->put(putData, file, QFtp::Ascii)); @@ -1599,7 +1623,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(QtNetworkSettings::serverName()) ); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); ResMapIt it = resultMap.find(QFtp::Put); QVERIFY(it != resultMap.end()); @@ -1611,7 +1635,7 @@ void tst_QFtp::binaryAscii() init(); ftp = newFtp(); - addCommand(QFtp::ConnectToHost, ftp->connectToHost(QtNetworkSettings::serverName(), 21)); + addCommand(QFtp::ConnectToHost, ftp->connectToHost(QtNetworkSettings::ftpServerName(), 21)); addCommand(QFtp::Login, ftp->login("ftptest", "password")); addCommand(QFtp::Cd, ftp->cd("qtest/upload")); addCommand(QFtp::Get, ftp->get(file, &getBuf, QFtp::Binary)); @@ -1621,7 +1645,7 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(QtNetworkSettings::serverName()) ); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); ResMapIt it2 = resultMap.find(QFtp::Get); QVERIFY(it2 != resultMap.end()); @@ -1634,7 +1658,7 @@ void tst_QFtp::binaryAscii() // cleanup (i.e. remove the file) -- this also tests the remove command init(); ftp = newFtp(); - addCommand(QFtp::ConnectToHost, ftp->connectToHost(QtNetworkSettings::serverName(), 21)); + addCommand(QFtp::ConnectToHost, ftp->connectToHost(QtNetworkSettings::ftpServerName(), 21)); addCommand(QFtp::Login, ftp->login("ftptest", "password")); addCommand(QFtp::Cd, ftp->cd("qtest/upload")); addCommand(QFtp::Remove, ftp->remove(file)); @@ -1644,13 +1668,13 @@ void tst_QFtp::binaryAscii() delete ftp; ftp = 0; if ( QTestEventLoop::instance().timeout() ) - QFAIL( msgTimedOut(QtNetworkSettings::serverName()) ); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); it = resultMap.find( QFtp::Remove ); QVERIFY( it != resultMap.end() ); QCOMPARE( it.value().success, 1 ); - QVERIFY(!fileExists(QtNetworkSettings::serverName(), 21, "ftptest", "password", file)); + QVERIFY(!fileExists(QtNetworkSettings::ftpServerName(), 21, "ftptest", "password", file)); } @@ -2067,7 +2091,7 @@ void tst_QFtp::doneSignal() QFtp ftp; QSignalSpy spy(&ftp, SIGNAL(done(bool))); - ftp.connectToHost(QtNetworkSettings::serverName()); + ftp.connectToHost(QtNetworkSettings::ftpServerName()); ftp.login("anonymous"); ftp.list(); ftp.close(); @@ -2076,7 +2100,7 @@ void tst_QFtp::doneSignal() connect(&ftp, SIGNAL(done(bool)), &(QTestEventLoop::instance()), SLOT(exitLoop())); QTestEventLoop::instance().enterLoop(61); if (QTestEventLoop::instance().timeout()) - QFAIL("Network operation timed out"); + QSKIP( msgTimedOut(QtNetworkSettings::ftpServerName()) ); QCOMPARE(spy.count(), 1); QCOMPARE(spy.first().first().toBool(), false); @@ -2137,7 +2161,7 @@ void tst_QFtp::qtbug7359Crash() QFtp ftp; ftp.connectToHost("127.0.0.1"); - QTime t; + QElapsedTimer t; int elapsed; t.start(); diff --git a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro index d32b651b86..84e6f857a1 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -4,3 +4,6 @@ SOURCES += tst_qhttpnetworkconnection.cpp requires(qtConfig(private_tests)) QT = core-private network-private testlib + +CONFIG += unsupported/testserver +QT_TEST_SERVER_LIST = apache2 diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 84766f5484..0a9320118d 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -50,6 +50,7 @@ private: bool finishedCalled; bool finishedWithErrorCalled; QNetworkReply::NetworkError netErrorCode; + QString (*httpServerName)() = QtNetworkSettings::httpServerName; private Q_SLOTS: void initTestCase(); @@ -101,7 +102,11 @@ private Q_SLOTS: void tst_QHttpNetworkConnection::initTestCase() { +#if defined(QT_TEST_SERVER) + QVERIFY(QtNetworkSettings::verifyConnection(httpServerName(), 80)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } void tst_QHttpNetworkConnection::options_data() @@ -126,10 +131,9 @@ void tst_QHttpNetworkConnection::head_data() QTest::addColumn<QString>("statusString"); QTest::addColumn<int>("contentLength"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962; - - QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1; - QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1; + QTest::newRow("success-internal") << "http://" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962; + QTest::newRow("failure-path") << "http://" << httpServerName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1; + QTest::newRow("failure-protocol") << "" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1; } void tst_QHttpNetworkConnection::head() @@ -175,10 +179,10 @@ void tst_QHttpNetworkConnection::get_data() QTest::addColumn<int>("contentLength"); QTest::addColumn<int>("downloadSize"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; + QTest::newRow("success-internal") << "http://" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; - QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << -1; - QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << -1; + QTest::newRow("failure-path") << "http://" << httpServerName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << -1; + QTest::newRow("failure-protocol") << "" << httpServerName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << -1; } void tst_QHttpNetworkConnection::get() @@ -244,8 +248,8 @@ void tst_QHttpNetworkConnection::put_data() QTest::addColumn<QString>("data"); QTest::addColumn<bool>("succeed"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/dav/file1.txt" << ushort(80) << false << "Hello World\nEnd of file\n"<<true; - QTest::newRow("fail-internal") << "http://" << QtNetworkSettings::serverName() << "/dav2/file1.txt" << ushort(80) << false << "Hello World\nEnd of file\n"<<false; + QTest::newRow("success-internal") << "http://" << httpServerName() << "/dav/file1.txt" << ushort(80) << false << "Hello World\nEnd of file\n"<<true; + QTest::newRow("fail-internal") << "http://" << httpServerName() << "/dav2/file1.txt" << ushort(80) << false << "Hello World\nEnd of file\n"<<false; QTest::newRow("fail-host") << "http://" << "invalid.test.qt-project.org" << "/dav2/file1.txt" << ushort(80) << false << "Hello World\nEnd of file\n"<<false; } @@ -324,8 +328,8 @@ void tst_QHttpNetworkConnection::post_data() QTest::addColumn<int>("contentLength"); QTest::addColumn<int>("downloadSize"); - QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/cgi-bin/echo.cgi" << ushort(80) << false << "7 bytes" << 200 << "OK" << 7 << 7; - QTest::newRow("failure-internal") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << -1; + QTest::newRow("success-internal") << "http://" << httpServerName() << "/qtest/cgi-bin/echo.cgi" << ushort(80) << false << "7 bytes" << 200 << "OK" << 7 << 7; + QTest::newRow("failure-internal") << "http://" << httpServerName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << -1; } void tst_QHttpNetworkConnection::post() @@ -449,11 +453,11 @@ void tst_QHttpNetworkConnection::get401_data() QTest::addColumn<QString>("password"); QTest::addColumn<int>("statusCode"); - QTest::newRow("no-credentials") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << false << "" << ""<<401; - QTest::newRow("invalid-credentials") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "test" << "test"<<401; - QTest::newRow("valid-credentials") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; - QTest::newRow("digest-authentication-invalid") << "http://" << QtNetworkSettings::serverName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "wrong" << "wrong"<<401; - QTest::newRow("digest-authentication-valid") << "http://" << QtNetworkSettings::serverName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; + QTest::newRow("no-credentials") << "http://" << httpServerName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << false << "" << ""<<401; + QTest::newRow("invalid-credentials") << "http://" << httpServerName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "test" << "test"<<401; + QTest::newRow("valid-credentials") << "http://" << httpServerName() << "/qtest/rfcs-auth/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; + QTest::newRow("digest-authentication-invalid") << "http://" << httpServerName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "wrong" << "wrong"<<401; + QTest::newRow("digest-authentication-valid") << "http://" << httpServerName() << "/qtest/auth-digest/index.html" << ushort(80) << false << true << "httptest" << "httptest"<<200; } void tst_QHttpNetworkConnection::get401() @@ -508,9 +512,9 @@ void tst_QHttpNetworkConnection::compression_data() QTest::addColumn<bool>("autoCompress"); QTest::addColumn<QString>("contentCoding"); - QTest::newRow("success-autogzip-temp") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << -1 << 418321 << true << ""; - QTest::newRow("success-nogzip-temp") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << 418321 << 418321 << false << "identity"; - QTest::newRow("success-manualgzip-temp") << "http://" << QtNetworkSettings::serverName() << "/qtest/deflate/rfc2616.html" << ushort(80) << false << 200 << "OK" << 119124 << 119124 << false << "gzip"; + QTest::newRow("success-autogzip-temp") << "http://" << httpServerName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << -1 << 418321 << true << ""; + QTest::newRow("success-nogzip-temp") << "http://" << httpServerName() << "/qtest/rfcs/rfc2616.html" << ushort(80) << false << 200 << "OK" << 418321 << 418321 << false << "identity"; + QTest::newRow("success-manualgzip-temp") << "http://" << httpServerName() << "/qtest/deflate/rfc2616.html" << ushort(80) << false << 200 << "OK" << 119124 << 119124 << false << "gzip"; } @@ -586,9 +590,9 @@ void tst_QHttpNetworkConnection::ignoresslerror_data() // fluke's certificate is signed by a non-standard authority. // Since we don't introduce that CA into the SSL verification chain, // connecting should fail. - QTest::newRow("success-init") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true << true << false << 200; - QTest::newRow("success-fromSignal") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true << false << true << 200; - QTest::newRow("failure") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true << false << false << 100; + QTest::newRow("success-init") << "https://" << httpServerName() << "/" << ushort(443) << true << true << false << 200; + QTest::newRow("success-fromSignal") << "https://" << httpServerName() << "/" << ushort(443) << true << false << true << 200; + QTest::newRow("failure") << "https://" << httpServerName() << "/" << ushort(443) << true << false << false << 100; } void tst_QHttpNetworkConnection::ignoresslerror() @@ -635,7 +639,7 @@ void tst_QHttpNetworkConnection::nossl_data() QTest::addColumn<bool>("encrypt"); QTest::addColumn<QNetworkReply::NetworkError>("networkError"); - QTest::newRow("protocol-error") << "https://" << QtNetworkSettings::serverName() << "/" << ushort(443) << true <<QNetworkReply::ProtocolUnknownError; + QTest::newRow("protocol-error") << "https://" << httpServerName() << "/" << ushort(443) << true <<QNetworkReply::ProtocolUnknownError; } void tst_QHttpNetworkConnection::nossl() @@ -696,7 +700,7 @@ void tst_QHttpNetworkConnection::getMultiple() QFETCH(bool, pipeliningAllowed); QFETCH(int, requestCount); - QHttpNetworkConnection connection(connectionCount, QtNetworkSettings::serverName()); + QHttpNetworkConnection connection(connectionCount, httpServerName()); QList<QHttpNetworkRequest*> requests; QList<QHttpNetworkReply*> replies; @@ -705,7 +709,7 @@ void tst_QHttpNetworkConnection::getMultiple() // depending on what you use the results will vary. // for the "real" results, use a URL that has "internet latency" for you. Then (6 connections, pipelining) will win. // for LAN latency, you will possibly get that (1 connection, no pipelining) is the fastest - QHttpNetworkRequest *request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QHttpNetworkRequest *request = new QHttpNetworkRequest("http://" + httpServerName() + "/qtest/rfc3252.txt"); if (pipeliningAllowed) request->setPipeliningAllowed(true); requests.append(request); @@ -723,7 +727,7 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( quint16 requestCount = 100; // use 2 connections. - QHttpNetworkConnection connection(2, QtNetworkSettings::serverName()); + QHttpNetworkConnection connection(2, httpServerName()); QList<QHttpNetworkRequest*> requests; QList<QHttpNetworkReply*> replies; @@ -731,9 +735,9 @@ void tst_QHttpNetworkConnection::getMultipleWithPipeliningAndMultiplePriorities( for (int i = 0; i < requestCount; i++) { QHttpNetworkRequest *request = 0; if (i % 3) - request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Get); + request = new QHttpNetworkRequest("http://" + httpServerName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Get); else - request = new QHttpNetworkRequest("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Head); + request = new QHttpNetworkRequest("http://" + httpServerName() + "/qtest/rfc3252.txt", QHttpNetworkRequest::Head); if (i % 2 || i % 3) request->setPipeliningAllowed(true); @@ -800,9 +804,9 @@ void tst_QHttpNetworkConnection::getMultipleWithPriorities() { quint16 requestCount = 100; // use 2 connections. - QHttpNetworkConnection connection(2, QtNetworkSettings::serverName()); + QHttpNetworkConnection connection(2, httpServerName()); GetMultipleWithPrioritiesReceiver receiver(requestCount); - QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QUrl url("http://" + httpServerName() + "/qtest/rfc3252.txt"); QList<QHttpNetworkRequest*> requests; QList<QHttpNetworkReply*> replies; @@ -854,10 +858,10 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining() { quint16 requestCount = 50; // use 2 connections. - QHttpNetworkConnection connection(2, QtNetworkSettings::serverName()); + QHttpNetworkConnection connection(2, httpServerName()); GetEmptyWithPipeliningReceiver receiver(requestCount); - QUrl url("http://" + QtNetworkSettings::serverName() + "/cgi-bin/echo.cgi"); // a get on this = getting an empty file + QUrl url("http://" + httpServerName() + "/cgi-bin/echo.cgi"); // a get on this = getting an empty file QList<QHttpNetworkRequest*> requests; QList<QHttpNetworkReply*> replies; @@ -901,8 +905,8 @@ void tst_QHttpNetworkConnection::getAndEverythingShouldBePipelined() { quint16 requestCount = 100; // use 1 connection. - QHttpNetworkConnection connection(1, QtNetworkSettings::serverName()); - QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QHttpNetworkConnection connection(1, httpServerName()); + QUrl url("http://" + httpServerName() + "/qtest/rfc3252.txt"); QList<QHttpNetworkRequest*> requests; QList<QHttpNetworkReply*> replies; @@ -937,8 +941,8 @@ void tst_QHttpNetworkConnection::getAndThenDeleteObject_data() void tst_QHttpNetworkConnection::getAndThenDeleteObject() { // yes, this will leak if the testcase fails. I don't care. It must not fail then :P - QHttpNetworkConnection *connection = new QHttpNetworkConnection(QtNetworkSettings::serverName()); - QHttpNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QHttpNetworkConnection *connection = new QHttpNetworkConnection(httpServerName()); + QHttpNetworkRequest request("http://" + httpServerName() + "/qtest/bigfile"); QHttpNetworkReply *reply = connection->sendRequest(request); reply->setDownstreamLimited(true); diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 6c3443a735..1ef2c118b9 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -60,12 +60,13 @@ private slots: class MyCookieJar: public QNetworkCookieJar { public: - inline QList<QNetworkCookie> allCookies() const - { return QNetworkCookieJar::allCookies(); } - inline void setAllCookies(const QList<QNetworkCookie> &cookieList) - { QNetworkCookieJar::setAllCookies(cookieList); } + ~MyCookieJar() override; + using QNetworkCookieJar::allCookies; + using QNetworkCookieJar::setAllCookies; }; +MyCookieJar::~MyCookieJar() = default; + void tst_QNetworkCookieJar::getterSetter() { MyCookieJar jar; diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro index 9d36352abc..4cc1f6431e 100644 --- a/tests/auto/network/access/qnetworkreply/test/test.pro +++ b/tests/auto/network/access/qnetworkreply/test/test.pro @@ -15,5 +15,5 @@ TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \ !android:!winrt: TEST_HELPER_INSTALLS = ../echo/echo +CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = vsftpd apache2 ftp-proxy danted squid -include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8627a37e12..1afd8af7b0 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -32,8 +32,11 @@ #include <QtCore/QDataStream> #include <QtCore/QUrl> #include <QtCore/QEventLoop> +#include <QtCore/QElapsedTimer> #include <QtCore/QFile> #include <QtCore/QRandomGenerator> +#include <QtCore/QRegularExpression> +#include <QtCore/QRegularExpressionMatch> #include <QtCore/QSharedPointer> #include <QtCore/QScopedPointer> #include <QtCore/QTemporaryFile> @@ -123,7 +126,7 @@ class tst_QNetworkReply: public QObject if (!seedCreated) { seedCreated = true; // not thread-safe, but who cares } - return QString::number(QTime(0, 0, 0).msecsTo(QTime::currentTime())) + return QString::number(QTime::currentTime().msecsSinceStartOfDay()) + QLatin1Char('-') + QString::number(QCoreApplication::applicationPid()) + QLatin1Char('-') + QString::number(QRandomGenerator::global()->generate()); } @@ -503,6 +506,11 @@ private Q_SLOTS: void putWithServerClosingConnectionImmediately(); #endif + void autoDeleteRepliesAttribute_data(); + void autoDeleteRepliesAttribute(); + void autoDeleteReplies_data(); + void autoDeleteReplies(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); private: @@ -1142,7 +1150,7 @@ protected: } // now write in "blocking mode", this is where the rate measuring starts - QTime timer; + QElapsedTimer timer; timer.start(); //const qint64 writtenBefore = dataIndex; //qint64 measuredTotalBytes = wantedSize - writtenBefore; @@ -1241,7 +1249,7 @@ protected: } qint64 bytesRead = 0; - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); do { if (device->bytesAvailable() == 0) { @@ -1552,7 +1560,7 @@ void tst_QNetworkReply::initTestCase() QDir::setSearchPaths("testdata", QStringList() << testDataDir); #ifndef QT_NO_SSL - QSslSocket::defaultCaCertificates(); //preload certificates + QSslConfiguration::defaultConfiguration().caCertificates(); //preload certificates #endif #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); @@ -4142,10 +4150,10 @@ void tst_QNetworkReply::ioGetFromHttpWithCache() request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false); QFETCH(QStringList, extraHttpHeaders); - QStringListIterator it(extraHttpHeaders); - while (it.hasNext()) { - QString header = it.next(); - QString value = it.next(); + QVERIFY(extraHttpHeaders.size() % 2 == 0); + for (auto it = extraHttpHeaders.cbegin(), end = extraHttpHeaders.cend(); it != end; /*double-stepping*/) { + QString header = *it++; + QString value = *it++; request.setRawHeader(header.toLatin1(), value.toLatin1()); // To latin1? Deal with it! } @@ -5143,8 +5151,8 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp() const int rate = 200; // in kB per sec RateControlledReader reader(server, reply.data(), rate, bufferSize); - QTime loopTime; - loopTime.start(); + QElapsedTimer loopTimer; + loopTimer.start(); const int result = waitForFinish(reply); if (notEnoughDataForFastSender) { @@ -5154,7 +5162,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp() QVERIFY2(result == Success, msgWaitForFinished(reply)); - const int elapsedTime = loopTime.elapsed(); + const int elapsedTime = loopTimer.elapsed(); server.wait(); reader.wrapUp(); @@ -5440,12 +5448,12 @@ void tst_QNetworkReply::rateControl() RateControlledReader reader(sender, reply.data(), rate, 20); // this test is designed to run for 25 seconds at most - QTime loopTime; - loopTime.start(); + QElapsedTimer loopTimer; + loopTimer.start(); QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); - int elapsedTime = loopTime.elapsed(); + int elapsedTime = loopTimer.elapsed(); if (!errorSpy.isEmpty()) { qDebug() << "ERROR!" << errorSpy[0][0] << reply->errorString(); @@ -6115,8 +6123,8 @@ void tst_QNetworkReply::httpConnectionCount() } int pendingConnectionCount = 0; - QTime time; - time.start(); + QElapsedTimer timer; + timer.start(); while(pendingConnectionCount <= 20) { QTestEventLoop::instance().enterLoop(1); @@ -6128,7 +6136,7 @@ void tst_QNetworkReply::httpConnectionCount() } // at max. wait 10 sec - if (time.elapsed() > 10000) + if (timer.elapsed() > 10000) break; } @@ -7905,9 +7913,10 @@ void tst_QNetworkReply::synchronousAuthenticationCache() "Content-Type: text/plain\r\n" "\r\n" "auth"; - QRegExp rx("Authorization: Basic ([^\r\n]*)\r\n"); - if (rx.indexIn(receivedData) > 0) { - if (QByteArray::fromBase64(rx.cap(1).toLatin1()) == "login:password") { + QRegularExpression rx("Authorization: Basic ([^\r\n]*)\r\n"); + QRegularExpressionMatch match = rx.match(receivedData); + if (match.hasMatch()) { + if (QByteArray::fromBase64(match.captured(1).toLatin1()) == "login:password") { dataToTransmit = "HTTP/1.0 200 OK\r\n" "Content-Type: text/plain\r\n" @@ -8143,16 +8152,17 @@ void tst_QNetworkReply::backgroundRequest() SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif - const QWeakPointer<const QNetworkSession> session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); - QVERIFY(session); - QNetworkSession::UsagePolicies original = session.data()->usagePolicies(); - QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), QNetworkSession::UsagePolicies(policy)); + const QWeakPointer<const QNetworkSession> sessionWeakPtr = QNetworkAccessManagerPrivate::getNetworkSession(&manager); + QVERIFY(!sessionWeakPtr.isNull()); + auto session = const_cast<QNetworkSession *>(sessionWeakPtr.toStrongRef().data()); + QNetworkSession::UsagePolicies original = session->usagePolicies(); + QNetworkSessionPrivate::setUsagePolicies(*session, QNetworkSession::UsagePolicies(policy)); QNetworkReplyPtr reply(manager.get(request)); QVERIFY(waitForFinish(reply) != Timeout); if (session) - QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), original); + QNetworkSessionPrivate::setUsagePolicies(*session, original); QVERIFY(reply->isFinished()); QCOMPARE(reply->error(), error); @@ -8207,10 +8217,11 @@ void tst_QNetworkReply::backgroundRequestInterruption() SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif - const QWeakPointer<const QNetworkSession> session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); - QVERIFY(session); - QNetworkSession::UsagePolicies original = session.data()->usagePolicies(); - QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), QNetworkSession::NoPolicy); + const QWeakPointer<const QNetworkSession> sessionWeakPtr = QNetworkAccessManagerPrivate::getNetworkSession(&manager); + QVERIFY(!sessionWeakPtr.isNull()); + auto session = const_cast<QNetworkSession *>(sessionWeakPtr.toStrongRef().data()); + QNetworkSession::UsagePolicies original = session->usagePolicies(); + QNetworkSessionPrivate::setUsagePolicies(*session, QNetworkSession::NoPolicy); request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 8192); QNetworkReplyPtr reply(manager.get(request)); @@ -8219,14 +8230,14 @@ void tst_QNetworkReply::backgroundRequestInterruption() QSignalSpy spy(reply.data(), SIGNAL(readyRead())); QTRY_VERIFY(spy.count() > 0); - QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), QNetworkSession::NoBackgroundTrafficPolicy); + QNetworkSessionPrivate::setUsagePolicies(*session, QNetworkSession::NoBackgroundTrafficPolicy); // After we have changed the policy we can download at full speed. reply->setReadBufferSize(0); QVERIFY(waitForFinish(reply) != Timeout); if (session) - QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), original); + QNetworkSessionPrivate::setUsagePolicies(*session, original); QVERIFY(reply->isFinished()); QCOMPARE(reply->error(), error); @@ -8266,8 +8277,8 @@ void tst_QNetworkReply::backgroundRequestConnectInBackground() QWeakPointer<const QNetworkSession> session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); //force QNAM to reopen the session. - if (session && session.data()->isOpen()) { - const_cast<QNetworkSession *>(session.data())->close(); + if (session && session.toStrongRef().data()->isOpen()) { + const_cast<QNetworkSession *>(session.toStrongRef().data())->close(); QCoreApplication::processEvents(); //let signals propagate inside QNAM } @@ -8276,19 +8287,19 @@ void tst_QNetworkReply::backgroundRequestConnectInBackground() session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); QVERIFY(session); - QNetworkSession::UsagePolicies original = session.data()->usagePolicies(); - QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), QNetworkSession::NoPolicy); + QNetworkSession::UsagePolicies original = session.toStrongRef().data()->usagePolicies(); + QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.toStrongRef().data()), QNetworkSession::NoPolicy); QNetworkReplyPtr reply(manager.get(request)); QVERIFY(waitForFinish(reply) != Timeout); session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); if (session) { - QVariant cib = session.data()->sessionProperty(QStringLiteral("ConnectInBackground")); + QVariant cib = session.toStrongRef().data()->sessionProperty(QStringLiteral("ConnectInBackground")); if (!cib.isValid()) QSKIP("inconclusive - ConnectInBackground session property not supported by the bearer plugin"); QCOMPARE(cib.toBool(), background); - QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), original); + QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.toStrongRef().data()), original); } else { QSKIP("inconclusive - network session has been destroyed"); } @@ -9167,6 +9178,166 @@ void tst_QNetworkReply::putWithServerClosingConnectionImmediately() #endif +void tst_QNetworkReply::autoDeleteRepliesAttribute_data() +{ + QTest::addColumn<QUrl>("destination"); + + QTest::newRow("http") << QUrl("http://QInvalidDomain.qt/test"); + QTest::newRow("https") << QUrl("https://QInvalidDomain.qt/test"); + QTest::newRow("ftp") << QUrl("ftp://QInvalidDomain.qt/test"); + QTest::newRow("file") << QUrl("file:///thisfolderdoesn'texist/probably.txt"); +#ifdef Q_OS_WIN + // Only supported on windows. + QTest::newRow("remote-file") << QUrl("file://QInvalidHost/thisfolderdoesn'texist/probably.txt"); +#endif + QTest::newRow("qrc") << QUrl("qrc:///path/to/nowhere"); + QTest::newRow("data") << QUrl("data:,Some%20plaintext%20data"); +} + +void tst_QNetworkReply::autoDeleteRepliesAttribute() +{ + QFETCH(QUrl, destination); + { + // Get + QNetworkRequest request(destination); + request.setAttribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, true); + QNetworkReply *reply = manager.get(request); + QSignalSpy finishedSpy(reply, &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply, &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QVERIFY(destroyedSpy.wait()); + } + { + // Post + QNetworkRequest request(destination); + request.setAttribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, true); + QNetworkReply *reply = manager.post(request, QByteArrayLiteral("datastring")); + QSignalSpy finishedSpy(reply, &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply, &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QVERIFY(destroyedSpy.wait()); + } + // Now repeated, but without the attribute to make sure it does not get deleted automatically. + // We need two calls to processEvents to test that the QNetworkReply doesn't get deleted. + // The first call executes a metacall event which adds the deleteLater meta event which + // would be executed in the second call. But that shouldn't happen without the attribute. + { + // Get + QNetworkRequest request(destination); + QScopedPointer<QNetworkReply> reply(manager.get(request)); + QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QCoreApplication::processEvents(); + QCoreApplication::processEvents(); + QCOMPARE(destroyedSpy.count(), 0); + } + { + // Post + QNetworkRequest request(destination); + QScopedPointer<QNetworkReply> reply(manager.post(request, QByteArrayLiteral("datastring"))); + QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QCoreApplication::processEvents(); + QCoreApplication::processEvents(); + QCOMPARE(destroyedSpy.count(), 0); + } +} + +void tst_QNetworkReply::autoDeleteReplies_data() +{ + autoDeleteRepliesAttribute_data(); +} + +void tst_QNetworkReply::autoDeleteReplies() +{ + QFETCH(QUrl, destination); + manager.setAutoDeleteReplies(true); + auto cleanup = qScopeGuard([this] { manager.setAutoDeleteReplies(false); }); + { + // Get + QNetworkRequest request(destination); + QNetworkReply *reply = manager.get(request); + QSignalSpy finishedSpy(reply, &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply, &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QVERIFY(destroyedSpy.wait()); + } + { + // Post + QNetworkRequest request(destination); + QNetworkReply *reply = manager.post(request, QByteArrayLiteral("datastring")); + QSignalSpy finishedSpy(reply, &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply, &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QVERIFY(destroyedSpy.wait()); + } + // Here we repeat the test, but override the auto-deletion in the QNetworkRequest + // We need two calls to processEvents to test that the QNetworkReply doesn't get deleted. + // The first call executes a metacall event which adds the deleteLater meta event which + // would be executed in the second call. But that shouldn't happen in this case. + { + // Get + QNetworkRequest request(destination); + request.setAttribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, false); + QScopedPointer<QNetworkReply> reply(manager.get(request)); + QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QCoreApplication::processEvents(); + QCoreApplication::processEvents(); + QCOMPARE(destroyedSpy.count(), 0); + } + { + // Post + QNetworkRequest request(destination); + request.setAttribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, false); + QScopedPointer<QNetworkReply> reply(manager.post(request, QByteArrayLiteral("datastring"))); + QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QCoreApplication::processEvents(); + QCoreApplication::processEvents(); + QCOMPARE(destroyedSpy.count(), 0); + } + // Now we repeat the test with autoDeleteReplies set to false + cleanup.dismiss(); + manager.setAutoDeleteReplies(false); + { + // Get + QNetworkRequest request(destination); + QScopedPointer<QNetworkReply> reply(manager.get(request)); + QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QCoreApplication::processEvents(); + QCoreApplication::processEvents(); + QCOMPARE(destroyedSpy.count(), 0); + } + { + // Post + QNetworkRequest request(destination); + QScopedPointer<QNetworkReply> reply(manager.post(request, QByteArrayLiteral("datastring"))); + QSignalSpy finishedSpy(reply.data(), &QNetworkReply::finished); + QSignalSpy destroyedSpy(reply.data(), &QObject::destroyed); + QVERIFY(finishedSpy.wait()); + QCOMPARE(destroyedSpy.count(), 0); + QCoreApplication::processEvents(); + QCoreApplication::processEvents(); + QCOMPARE(destroyedSpy.count(), 0); + } +} + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 55053842dc..8cef351554 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -93,7 +93,7 @@ void tst_QAuthenticator::basicAuth() QCOMPARE(priv->phase, QAuthenticatorPrivate::Start); - QCOMPARE(priv->calculateResponse("GET", "/").constData(), QByteArray("Basic " + expectedReply).constData()); + QCOMPARE(priv->calculateResponse("GET", "/", "").constData(), QByteArray("Basic " + expectedReply).constData()); } void tst_QAuthenticator::ntlmAuth_data() @@ -133,9 +133,9 @@ void tst_QAuthenticator::ntlmAuth() headers << qMakePair<QByteArray, QByteArray>("WWW-Authenticate", "NTLM"); priv->parseHttpResponse(headers, /*isProxy = */ false); if (sso) - QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM ")); + QVERIFY(priv->calculateResponse("GET", "/", "").startsWith("NTLM ")); else - QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABYIIAAAAAAAAAAAAAAAAAAAAAAA="); + QCOMPARE(priv->calculateResponse("GET", "/", "").constData(), "NTLM TlRMTVNTUAABAAAABYIIAAAAAAAAAAAAAAAAAAAAAAA="); // NTLM phase 2: challenge headers.clear(); @@ -146,7 +146,7 @@ void tst_QAuthenticator::ntlmAuth() QEXPECT_FAIL("with-realm-sso", "NTLM authentication code doesn't extract the realm", Continue); QCOMPARE(auth.realm(), realm); - QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM ")); + QVERIFY(priv->calculateResponse("GET", "/", "").startsWith("NTLM ")); } void tst_QAuthenticator::equalityOperators() diff --git a/tests/auto/network/kernel/qhostaddress/qhostaddress.pro b/tests/auto/network/kernel/qhostaddress/qhostaddress.pro index b5d6ea6459..d170d879e6 100644 --- a/tests/auto/network/kernel/qhostaddress/qhostaddress.pro +++ b/tests/auto/network/kernel/qhostaddress/qhostaddress.pro @@ -4,4 +4,4 @@ SOURCES += tst_qhostaddress.cpp QT = core network-private testlib -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 diff --git a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro index 3d8457dd46..d358cdf52c 100644 --- a/tests/auto/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/auto/network/kernel/qhostinfo/qhostinfo.pro @@ -6,6 +6,6 @@ SOURCES += tst_qhostinfo.cpp requires(qtConfig(private_tests)) QT = core-private network-private testlib -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 winrt: WINRT_MANIFEST.capabilities += internetClientServer diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 0a130d363e..da6e02210b 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -179,7 +179,6 @@ void tst_QHostInfo::staticInformation() void tst_QHostInfo::initTestCase() { - QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); #ifndef QT_NO_BEARERMANAGEMENT //start the default network netConfMan = new QNetworkConfigurationManager(this); @@ -240,8 +239,6 @@ void tst_QHostInfo::lookupIPv4_data() QTest::addColumn<QString>("addresses"); QTest::addColumn<int>("err"); - // Test server lookup - QTest::newRow("lookup_01") << QtNetworkSettings::serverName() << QtNetworkSettings::serverIP().toString() << int(QHostInfo::NoError); QTest::newRow("empty") << "" << "" << int(QHostInfo::HostNotFound); QTest::newRow("single_ip4") << "a-single" TEST_DOMAIN << "192.0.2.1" << int(QHostInfo::NoError); diff --git a/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp index 5eedd1043b..cd6019090f 100644 --- a/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp +++ b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp @@ -131,7 +131,7 @@ void tst_QNetworkDatagram::makeReply() QNetworkDatagram copy = dgram; copy.setData(copy.data()); { - QNetworkDatagram reply = qMove(copy).makeReply("World"); + QNetworkDatagram reply = std::move(copy).makeReply("World"); QCOMPARE(reply.data(), QByteArray("World")); QCOMPARE(reply.senderAddress(), QHostAddress(localAddress)); QCOMPARE(reply.senderPort(), localAddress.isEmpty() ? -1 : dgram.destinationPort()); diff --git a/tests/auto/network/socket/platformsocketengine/BLACKLIST b/tests/auto/network/socket/platformsocketengine/BLACKLIST index 8e1a55995e..154c5cc5b2 100644 --- a/tests/auto/network/socket/platformsocketengine/BLACKLIST +++ b/tests/auto/network/socket/platformsocketengine/BLACKLIST @@ -1 +1,8 @@ +[tcpLoopbackPerformance] +windows +[receiveUrgentData] +windows +[serverTest] +windows +[tcpLoopbackPerformance] windows diff --git a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri index 46c722deba..868439de6a 100644 --- a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri +++ b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri @@ -4,7 +4,7 @@ QNETWORK_SRC = $$QT_SOURCE_TREE/src/network INCLUDEPATH += $$QNETWORK_SRC -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 unix:qtConfig(reduce_exports) { SOURCES += $$QNETWORK_SRC/socket/qnativesocketengine_unix.cpp diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp index 01168cc0d6..ffc63ee46a 100644 --- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp +++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp @@ -32,7 +32,7 @@ #include <qcoreapplication.h> #include <qdatastream.h> #include <qhostaddress.h> -#include <qdatetime.h> +#include <qelapsedtimer.h> #ifdef Q_OS_UNIX #include <unistd.h> @@ -403,7 +403,7 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance() QHostAddress localhost = QHostAddress::LocalHost; qlonglong readBytes = 0; - QTime timer; + QElapsedTimer timer; timer.start(); while (timer.elapsed() < 5000) { udpSocket2.write(message1.data(), message1.size()); @@ -462,7 +462,7 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance() QByteArray message1(messageSize, '@'); QByteArray answer(messageSize, '@'); - QTime timer; + QElapsedTimer timer; timer.start(); qlonglong readBytes = 0; while (timer.elapsed() < 5000) { diff --git a/tests/auto/network/socket/qhttpsocketengine/BLACKLIST b/tests/auto/network/socket/qhttpsocketengine/BLACKLIST index 8e1a55995e..991d01dd00 100644 --- a/tests/auto/network/socket/qhttpsocketengine/BLACKLIST +++ b/tests/auto/network/socket/qhttpsocketengine/BLACKLIST @@ -1 +1,6 @@ +[passwordAuth] +windows +[downloadBigFile] +windows +[ensureEofTriggersNotification] windows diff --git a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro index 56a4fb8aee..63f41f4eb7 100644 --- a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro +++ b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro @@ -10,3 +10,8 @@ MOC_DIR=tmp requires(qtConfig(private_tests)) QT = core-private network-private testlib +# TODO: For now linux-only, because cyrus is linux-only atm ... +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = squid danted cyrus apache2 +} diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp index 68f3ea059b..64241014d7 100644 --- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -38,6 +38,7 @@ #include <qhostaddress.h> #include <qtcpsocket.h> #include <qdebug.h> +#include <qelapsedtimer.h> #include <qtcpserver.h> #include "../../../network-settings.h" @@ -122,7 +123,14 @@ public slots: void tst_QHttpSocketEngine::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } void tst_QHttpSocketEngine::init() @@ -171,7 +179,7 @@ void tst_QHttpSocketEngine::errorTest_data() QTest::newRow("proxy-host-not-found") << "this-host-does-not-exist." << 1080 << QString() << QString() << int(QAbstractSocket::ProxyNotFoundError); - QTest::newRow("proxy-connection-refused") << QtNetworkSettings::serverName() << 2 << QString() + QTest::newRow("proxy-connection-refused") << QtNetworkSettings::socksProxyServerName() << 2 << QString() << QString() << int(QAbstractSocket::ProxyConnectionRefusedError); @@ -278,13 +286,12 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); - - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); QVERIFY(!socketDevice.localAddress().isNull()); QVERIFY(socketDevice.localPort() > 0); @@ -292,10 +299,10 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.waitForRead()); // Read the greeting - qint64 available = socketDevice.bytesAvailable(); + qint64 available = int(socketDevice.bytesAvailable()); QVERIFY(available > 0); QByteArray array; - array.resize(available); + array.resize(int(available)); QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be @@ -310,9 +317,9 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() // Wait for the response QVERIFY(socketDevice.waitForRead()); - available = socketDevice.bytesAvailable(); + available = int(socketDevice.bytesAvailable()); QVERIFY(available > 0); - array.resize(available); + array.resize(int(available)); QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be @@ -321,7 +328,7 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() // Wait for the response QVERIFY(socketDevice.waitForRead()); char c; - QCOMPARE(socketDevice.read(&c, sizeof(c)), (qint64) -1); + QCOMPARE(socketDevice.read(&c, sizeof(c)), qint64(-1)); QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } @@ -335,10 +342,10 @@ void tst_QHttpSocketEngine::simpleErrorsAndStates() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverName()), 8088)); + QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::socksProxyServerName()), 8088)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); if (socketDevice.waitForWrite(30000)) { QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState || @@ -391,7 +398,7 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance() QByteArray message1(messageSize, '@'); QByteArray answer(messageSize, '@'); - QTime timer; + QElapsedTimer timer; timer.start(); qlonglong readBytes = 0; while (timer.elapsed() < 30000) { @@ -422,7 +429,7 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() QTcpSocket socket; // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.waitForConnected()); QCOMPARE(socket.state(), QTcpSocket::ConnectedState); @@ -479,7 +486,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() tcpSocketNonBlocking_socket = &socket; // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.state() == QTcpSocket::HostLookupState || socket.state() == QTcpSocket::ConnectingState); @@ -607,13 +614,13 @@ void tst_QHttpSocketEngine::downloadBigFile() connect(tmpSocket, SIGNAL(connected()), SLOT(exitLoopSlot())); connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot())); - tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80); + tmpSocket->connectToHost(QtNetworkSettings::httpServerName(), 80); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); - QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); + QByteArray hostName = QtNetworkSettings::httpServerName().toLatin1(); QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("Host: ") > 0); @@ -623,7 +630,7 @@ void tst_QHttpSocketEngine::downloadBigFile() bytesAvailable = 0; - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); QTestEventLoop::instance().enterLoop(60); @@ -664,13 +671,13 @@ void tst_QHttpSocketEngine::passwordAuth() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128, "qsockstest", "password")); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128, "qsockstest", "password")); - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 45ab275510..732f7eef00 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -32,6 +32,7 @@ #include <qtextstream.h> #include <qdatastream.h> +#include <qelapsedtimer.h> #include <QtNetwork/qlocalsocket.h> #include <QtNetwork/qlocalserver.h> @@ -552,7 +553,7 @@ void tst_QLocalSocket::sendData() QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState); QTextStream out(serverSocket); QTextStream in(&socket); - out << testLine << endl; + out << testLine << Qt::endl; bool wrote = serverSocket->waitForBytesWritten(3000); if (!socket.canReadLine()) { @@ -877,7 +878,7 @@ public: QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); QTextStream out(serverSocket); - out << testLine << endl; + out << testLine << Qt::endl; QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState); QVERIFY2(serverSocket->waitForBytesWritten(), serverSocket->errorString().toLatin1().constData()); QCOMPARE(serverSocket->errorString(), QString("Unknown error")); @@ -1031,7 +1032,7 @@ void tst_QLocalSocket::waitForDisconnect() QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); socket.disconnectFromServer(); - QTime timer; + QElapsedTimer timer; timer.start(); QVERIFY(serverSocket->waitForDisconnected(3000)); QVERIFY(timer.elapsed() < 2000); diff --git a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST index 60526827bf..8af3cea8dc 100644 --- a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST +++ b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST @@ -2,6 +2,9 @@ * [passwordAuth] * +# QTBUG-74162 +[passwordAuth2] +* [serverTest] windows [downloadBigFile] diff --git a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro index 71ceafa133..243eab9480 100644 --- a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro @@ -11,3 +11,9 @@ MOC_DIR=tmp QT = core-private network-private testlib requires(qtConfig(private_tests)) + +# Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = danted apache2 cyrus +} diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index 1212ea20e5..464054f8a6 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -137,7 +137,13 @@ private slots: void tst_QSocks5SocketEngine::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } //--------------------------------------------------------------------------- @@ -293,13 +299,13 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -347,10 +353,10 @@ void tst_QSocks5SocketEngine::simpleErrorsAndStates() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - QVERIFY(!socketDevice.connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first(), 8088)); + QVERIFY(!socketDevice.connectToHost(QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses().first(), 8088)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); if (socketDevice.waitForWrite(15000)) { QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState || @@ -433,7 +439,7 @@ void tst_QSocks5SocketEngine::serverTest() // Initialize a Tcp socket QVERIFY(server.initialize(QAbstractSocket::TcpSocket)); - QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); server.setProxy(proxy); @@ -510,7 +516,7 @@ void tst_QSocks5SocketEngine::udpTest() QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket)); QVERIFY(udpSocket.isValid()); - QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); udpSocket.setProxy(proxy); @@ -564,7 +570,7 @@ void tst_QSocks5SocketEngine::tcpSocketBlockingTest() QTcpSocket socket; // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.waitForConnected()); QCOMPARE(socket.state(), QTcpSocket::ConnectedState); @@ -635,7 +641,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() }); // Connect - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.state() == QTcpSocket::HostLookupState || socket.state() == QTcpSocket::ConnectingState); @@ -754,13 +760,13 @@ void tst_QSocks5SocketEngine::downloadBigFile() << " (" << stopWatch.elapsed() << "ms)"; }); - socket.connectToHost(QtNetworkSettings::serverName(), 80); + socket.connectToHost(QtNetworkSettings::httpServerName(), 80); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); - QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); + QByteArray hostName = QtNetworkSettings::httpServerName().toLatin1(); QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); QVERIFY(socket.write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(socket.write("HOST: ") > 0); @@ -791,13 +797,13 @@ void tst_QSocks5SocketEngine::passwordAuth() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password")); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080, "qsockstest", "password")); // Connect to imap.trolltech.com's IP - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); - if (!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)) { + if (!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)) { qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); } QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); @@ -857,19 +863,19 @@ void tst_QSocks5SocketEngine::passwordAuth2() QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); - socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081)); + socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081)); socketDevice.setReceiver(this); - QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); + QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143)); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); while (socketDevice.state() == QAbstractSocket::ConnectingState) { QVERIFY(socketDevice.waitForWrite()); - socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143); + socketDevice.connectToHost(QtNetworkSettings::imapServerIp(), 143); } if (socketDevice.state() != QAbstractSocket::ConnectedState) qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); - QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::imapServerIp()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); diff --git a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp index 1a8e7920d3..5c66ef6520 100644 --- a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp +++ b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp @@ -29,14 +29,14 @@ #include <QtCore> #include <QtNetwork> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && defined(Q_CC_MSVC) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && defined(Q_CC_MSVC) # include <crtdbg.h> #endif int main(int argc, char *argv[]) { // Windows: Suppress crash notification dialog. -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && defined(Q_CC_MSVC) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && defined(Q_CC_MSVC) _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); #endif QCoreApplication app(argc, argv); diff --git a/tests/auto/network/socket/qtcpserver/test/test.pro b/tests/auto/network/socket/qtcpserver/test/test.pro index 4491523383..7e2e60a1e3 100644 --- a/tests/auto/network/socket/qtcpserver/test/test.pro +++ b/tests/auto/network/socket/qtcpserver/test/test.pro @@ -1,7 +1,7 @@ CONFIG += testcase SOURCES += ../tst_qtcpserver.cpp -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 TARGET = ../tst_qtcpserver @@ -16,3 +16,9 @@ win32 { QT = core network testlib MOC_DIR=tmp + +# Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = danted cyrus squid ftp-proxy +} diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 161d94d642..22ac9aa076 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -160,8 +160,15 @@ void tst_QTcpServer::initTestCase_data() void tst_QTcpServer::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif #ifndef QT_NO_BEARERMANAGEMENT QNetworkConfigurationManager man; networkSession = new QNetworkSession(man.defaultConfiguration(), this); @@ -177,7 +184,7 @@ void tst_QTcpServer::init() #ifndef QT_NO_NETWORKPROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { - QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); } #else // !QT_NO_NETWORKPROXY QSKIP("No proxy support"); @@ -513,7 +520,7 @@ void tst_QTcpServer::waitForConnectionTest() } QTcpSocket findLocalIpSocket; - findLocalIpSocket.connectToHost(QtNetworkSettings::serverName(), 143); + findLocalIpSocket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(findLocalIpSocket.waitForConnected(5000)); QTcpServer server; @@ -668,16 +675,18 @@ void tst_QTcpServer::invalidProxy_data() QTest::addColumn<int>("port"); QTest::addColumn<int>("expectedError"); - QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); - QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << fluke << 143 + const QString imapIp = QtNetworkSettings::imapServerIp().toString(); + const QString httpProxyIp = QtNetworkSettings::httpProxyServerIp().toString(); + const QString socksIp = QtNetworkSettings::socksProxyServerIp().toString(); + QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << imapIp << 143 << int(QAbstractSocket::UnsupportedSocketOperationError); - QTest::newRow("http-proxy") << int(QNetworkProxy::HttpProxy) << fluke << 3128 + QTest::newRow("http-proxy") << int(QNetworkProxy::HttpProxy) << httpProxyIp << 3128 << int(QAbstractSocket::UnsupportedSocketOperationError); QTest::newRow("no-such-host") << int(QNetworkProxy::Socks5Proxy) << "invalid.test.qt-project.org" << 1080 << int(QAbstractSocket::ProxyNotFoundError); - QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << fluke << 3128 + QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << httpProxyIp << 3128 << int(QAbstractSocket::SocketTimeoutError); } @@ -740,48 +749,48 @@ void tst_QTcpServer::proxyFactory_data() // tests that do get to listen - proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); QTest::newRow("socks5") << proxyList << proxyList.at(0) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); QTest::newRow("cachinghttp+socks5") << proxyList << proxyList.at(1) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080); QTest::newRow("ftp+cachinghttp+socks5") << proxyList << proxyList.at(2) << false << int(QAbstractSocket::UnknownSocketError); // tests that fail to listen proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128); + proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3128); QTest::newRow("http") << proxyList << proxyList.at(0) << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128); QTest::newRow("cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121); QTest::newRow("ftp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3128); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3128); QTest::newRow("ftp+cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 337e75b372..4c07b1ec66 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -2,8 +2,8 @@ CONFIG += testcase QT = core-private network-private testlib SOURCES += ../tst_qtcpsocket.cpp -win32:LIBS += -lws2_32 +win32: QMAKE_USE += ws2_32 TARGET = tst_qtcpsocket win32 { @@ -15,3 +15,9 @@ win32 { } else { DESTDIR = ../ } + +# Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = danted squid apache2 ftp-proxy vsftpd iptables cyrus +} diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index c473230246..c500c6b3c3 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -66,7 +66,7 @@ #endif #include <QTextStream> #include <QThread> -#include <QTime> +#include <QElapsedTimer> #include <QTimer> #include <QDebug> // RVCT compiles also unused inline methods @@ -237,7 +237,6 @@ private: qint64 bytesAvailable; qint64 expectedLength; bool readingBody; - QTime timer; QByteArray expectedReplyIMAP_cached; @@ -317,7 +316,7 @@ tst_QTcpSocket::tst_QTcpSocket() connect(earlyConstructedSockets->endPoints[1], SIGNAL(bytesWritten(qint64)), this, SLOT(earlySocketBytesSent(qint64))); earlyConstructedSockets->endPoints[1]->write("hello work"); - firstFailInfo.setAddresses(QList<QHostAddress>() << QHostAddress("224.0.0.0") << QtNetworkSettings::serverIP()); + firstFailInfo.setAddresses(QList<QHostAddress>() << QHostAddress("224.0.0.0") << QtNetworkSettings::httpServerIp()); } void tst_QTcpSocket::initTestCase_data() @@ -326,7 +325,6 @@ void tst_QTcpSocket::initTestCase_data() QTest::addColumn<int>("proxyType"); QTest::addColumn<bool>("ssl"); - qDebug() << QtNetworkSettings::serverName(); QTest::newRow("WithoutProxy") << false << 0 << false; //QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385 //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385 @@ -352,7 +350,17 @@ void tst_QTcpSocket::initTestCase_data() void tst_QTcpSocket::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); + //QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::firewallServerName(), 1357)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpServerName(), 21)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } void tst_QTcpSocket::init() @@ -361,30 +369,33 @@ void tst_QTcpSocket::init() if (setProxy) { #ifndef QT_NO_NETWORKPROXY QFETCH_GLOBAL(int, proxyType); - QList<QHostAddress> addresses = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses(); - QVERIFY2(addresses.count() > 0, "failed to get ip address for test server"); - QString fluke = addresses.first().toString(); + QList<QHostAddress> socks5Addresses = QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses(); + QList<QHostAddress> httpProxyAddresses = QHostInfo::fromName(QtNetworkSettings::httpProxyServerName()).addresses(); + QVERIFY2(socks5Addresses.count() > 0, "failed to get ip address for SOCKS5 proxy server"); + QVERIFY2(httpProxyAddresses.count() > 0, "failed to get ip address for HTTP proxy server"); + QString socks5Address = socks5Addresses.first().toString(); + QString httpProxyAddress = httpProxyAddresses.first().toString(); QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socks5Address, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socks5Address, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); @@ -644,8 +655,8 @@ void tst_QTcpSocket::bind() void tst_QTcpSocket::bindThenResolveHost_data() { QTest::addColumn<QString>("hostName"); - QTest::newRow("ip-literal") << QtNetworkSettings::serverIP().toString(); - QTest::newRow("name") << QtNetworkSettings::serverName(); + QTest::newRow("ip-literal") << QtNetworkSettings::httpServerIp().toString(); + QTest::newRow("name") << QtNetworkSettings::httpServerName(); QTest::newRow("first-fail") << firstFailName; } @@ -715,7 +726,7 @@ void tst_QTcpSocket::setSocketDescriptor() #ifdef Q_OS_WIN // need the dummy to ensure winsock is started QTcpSocket *dummy = newSocket(); - dummy->connectToHost(QtNetworkSettings::serverName(), 143); + dummy->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(dummy->waitForConnected()); SOCKET sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -737,7 +748,7 @@ void tst_QTcpSocket::setSocketDescriptor() QCOMPARE(socket->socketDescriptor(), (qintptr)sock); qt_qhostinfo_clear_cache(); //avoid the HostLookupState being skipped due to address being in cache from previous test. - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); QCOMPARE(socket->state(), QTcpSocket::HostLookupState); QCOMPARE(socket->socketDescriptor(), (qintptr)sock); QVERIFY(socket->waitForConnected(10000)); @@ -758,7 +769,7 @@ void tst_QTcpSocket::socketDescriptor() QTcpSocket *socket = newSocket(); QCOMPARE(socket->socketDescriptor(), (qintptr)-1); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->state() == QAbstractSocket::HostLookupState || socket->state() == QAbstractSocket::ConnectingState); QVERIFY(socket->waitForConnected(10000)); @@ -775,7 +786,7 @@ void tst_QTcpSocket::blockingIMAP() QTcpSocket *socket = newSocket(); // Connect - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QCOMPARE(socket->state(), QTcpSocket::ConnectedState); QVERIFY(socket->isValid()); @@ -852,6 +863,14 @@ void tst_QTcpSocket::hostNotFound() socket->connectToHost("nosuchserver.qt-project.org", 80); QVERIFY(!socket->waitForConnected()); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); +#ifdef QT_TEST_SERVER + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) { + QEXPECT_FAIL("", "QTBUG-73953: The version of Squid in the docker container behaves " + "differently to the one in the network testing server, returning 503 " + "when we expect 404", Continue); + } +#endif QCOMPARE(int(socket->error()), int(QTcpSocket::HostNotFoundError)); delete socket; @@ -861,8 +880,8 @@ void tst_QTcpSocket::hostNotFound() void tst_QTcpSocket::timeoutConnect_data() { QTest::addColumn<QString>("address"); - QTest::newRow("host") << QtNetworkSettings::serverName(); - QTest::newRow("ip") << QtNetworkSettings::serverIP().toString(); + QTest::newRow("host") << QtNetworkSettings::firewallServerName(); + QTest::newRow("ip") << QtNetworkSettings::firewallServerIp().toString(); } void tst_QTcpSocket::timeoutConnect() @@ -910,7 +929,7 @@ void tst_QTcpSocket::nonBlockingIMAP() nonBlockingIMAP_socket = socket; // Connect - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->state() == QTcpSocket::HostLookupState || socket->state() == QTcpSocket::ConnectingState); @@ -1036,7 +1055,7 @@ void tst_QTcpSocket::delayedClose() connect(socket, SIGNAL(connected()), SLOT(nonBlockingIMAP_connected())); connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); enterLoop(30); if (timeout()) @@ -1082,7 +1101,7 @@ QByteArray tst_QTcpSocket::expectedReplyIMAP() void tst_QTcpSocket::fetchExpectedReplyIMAP() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QVERIFY2(socket->state() == QTcpSocket::ConnectedState, qPrintable(socket->errorString())); @@ -1101,7 +1120,7 @@ void tst_QTcpSocket::fetchExpectedReplyIMAP() void tst_QTcpSocket::partialRead() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QCOMPARE(socket->state(), QTcpSocket::ConnectedState); char buf[512]; @@ -1125,7 +1144,7 @@ void tst_QTcpSocket::partialRead() void tst_QTcpSocket::unget() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QCOMPARE(socket->state(), QTcpSocket::ConnectedState); char buf[512]; @@ -1162,7 +1181,7 @@ void tst_QTcpSocket::readRegularFile_readyRead() void tst_QTcpSocket::readAllAfterClose() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); connect(socket, SIGNAL(readyRead()), SLOT(readRegularFile_readyRead())); enterLoop(10); if (timeout()) @@ -1202,7 +1221,7 @@ void tst_QTcpSocket::openCloseOpenClose() QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); socket->close(); } @@ -1225,7 +1244,7 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect() QCOMPARE(int(socket->peerPort()), 0); QCOMPARE(socket->peerAddress(), QHostAddress()); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForReadyRead(10000)); QCOMPARE(QString::fromLatin1(socket->read(4)), QString("* OK")); @@ -1429,7 +1448,7 @@ void tst_QTcpSocket::disconnectWhileLookingUp() // just connect and disconnect, then make sure nothing weird happened QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 21); + socket->connectToHost(QtNetworkSettings::ftpServerName(), 21); // check that connect is in progress QVERIFY(socket->state() != QAbstractSocket::UnconnectedState); @@ -1477,7 +1496,7 @@ void tst_QTcpSocket::downloadBigFile() connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot())); connect(tmpSocket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); - tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80); + tmpSocket->connectToHost(QtNetworkSettings::httpServerName(), 80); enterLoop(30); if (timeout()) { @@ -1486,7 +1505,7 @@ void tst_QTcpSocket::downloadBigFile() QFAIL("Network operation timed out"); } - QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); + QByteArray hostName = QtNetworkSettings::httpServerName().toLatin1(); QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); @@ -1498,7 +1517,7 @@ void tst_QTcpSocket::downloadBigFile() expectedLength = 0; readingBody = false; - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); enterLoop(600); @@ -1552,7 +1571,7 @@ void tst_QTcpSocket::downloadBigFileSlot() void tst_QTcpSocket::readLine() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); while (!socket->canReadLine()) @@ -1601,7 +1620,7 @@ void tst_QTcpSocket::readLine() void tst_QTcpSocket::readLineString() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForReadyRead(10000)); QByteArray arr = socket->readLine(); @@ -1614,7 +1633,7 @@ void tst_QTcpSocket::readLineString() void tst_QTcpSocket::readChunks() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForReadyRead(5000)); @@ -1634,7 +1653,7 @@ void tst_QTcpSocket::readChunks() void tst_QTcpSocket::waitForBytesWritten() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); QVERIFY(socket->waitForConnected(10000)); socket->write("GET / HTTP/1.0\r\n\r\n"); @@ -1652,7 +1671,7 @@ void tst_QTcpSocket::waitForBytesWrittenMinusOne() QSKIP("QTBUG-24451 - indefinite wait may hang"); #endif QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); QVERIFY(socket->waitForConnected(10000)); socket->write("GET / HTTP/1.0\r\n\r\n"); @@ -1667,7 +1686,7 @@ void tst_QTcpSocket::waitForBytesWrittenMinusOne() void tst_QTcpSocket::waitForReadyRead() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\n\r\n"); QVERIFY(socket->waitForReadyRead(5000)); delete socket; @@ -1680,7 +1699,7 @@ void tst_QTcpSocket::waitForReadyReadMinusOne() QSKIP("QTBUG-24451 - indefinite wait may hang"); #endif QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\n\r\n"); QVERIFY(socket->waitForReadyRead(-1)); delete socket; @@ -1693,7 +1712,7 @@ void tst_QTcpSocket::flush() socket->flush(); connect(socket, SIGNAL(connected()), SLOT(exitLoopSlot())); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); enterLoop(60); QVERIFY(socket->isOpen()); @@ -1710,7 +1729,7 @@ void tst_QTcpSocket::flush() void tst_QTcpSocket::synchronousApi() { QTcpSocket *ftpSocket = newSocket(); - ftpSocket->connectToHost(QtNetworkSettings::serverName(), 21); + ftpSocket->connectToHost(QtNetworkSettings::ftpServerName(), 21); ftpSocket->write("QUIT\r\n"); QVERIFY(ftpSocket->waitForDisconnected(10000)); QVERIFY(ftpSocket->bytesAvailable() > 0); @@ -1757,10 +1776,10 @@ void tst_QTcpSocket::recursiveReadyRead() QSignalSpy spy(testSocket, SIGNAL(readyRead())); - testSocket->connectToHost(QtNetworkSettings::serverName(), 143); + testSocket->connectToHost(QtNetworkSettings::imapServerName(), 143); enterLoop(30); QVERIFY2(!timeout(), - "Timed out when connecting to QtNetworkSettings::serverName()."); + "Timed out when connecting to QtNetworkSettings::imapServerName()."); enterLoop(30); QVERIFY2(!timeout(), @@ -1794,7 +1813,7 @@ void tst_QTcpSocket::recursiveReadyReadSlot() void tst_QTcpSocket::atEnd() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 21); + socket->connectToHost(QtNetworkSettings::ftpServerName(), 21); QVERIFY(socket->waitForReadyRead(15000)); QTextStream stream(socket); @@ -1802,9 +1821,15 @@ void tst_QTcpSocket::atEnd() QString greeting = stream.readLine(); QVERIFY(stream.atEnd()); +#ifdef QT_TEST_SERVER + // Test server must use some vsFTPd 3.x.x version + QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 3.x.x)")-1, qPrintable(greeting)); + QVERIFY2(greeting.startsWith("220 (vsFTPd 3."), qPrintable(greeting)); +#else // Test server must use some vsFTPd 2.x.x version QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting)); QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting)); +#endif QVERIFY2(greeting.endsWith(QLatin1Char(')')), qPrintable(greeting)); delete socket; @@ -1835,7 +1860,7 @@ protected: connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection); - socket->connectToHost(QtNetworkSettings::serverName(), 21); + socket->connectToHost(QtNetworkSettings::ftpServerName(), 21); socket->write("QUIT\r\n"); exec(); @@ -1909,7 +1934,7 @@ void tst_QTcpSocket::waitForReadyReadInASlot() tmpSocket = socket; connect(socket, SIGNAL(connected()), this, SLOT(waitForReadyReadInASlotSlot())); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\n\r\n"); enterLoop(30); @@ -2073,7 +2098,7 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot() timer.start(15000); connect(tmpSocket, SIGNAL(hostFound()), this, SLOT(hostLookupSlot())); - tmpSocket->connectToHost(QtNetworkSettings::serverName(), 143); + tmpSocket->connectToHost(QtNetworkSettings::imapServerName(), 143); // only execute the loop if not already connected if (tmpSocket->state() != QAbstractSocket::ConnectedState) @@ -2128,7 +2153,7 @@ public slots: inline void doIt() { attemptedToConnect = true; - sock->connectToHost(QtNetworkSettings::serverName(), 80); + sock->connectToHost(QtNetworkSettings::httpServerName(), 80); #if defined(Q_OS_MAC) pthread_yield_np(); @@ -2179,7 +2204,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() QSignalSpy readyReadSpy(socket, SIGNAL(readyRead())); // Connect - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); // Wait for the read QVERIFY(socket->waitForReadyRead(10000)); @@ -2315,7 +2340,7 @@ void tst_QTcpSocket::localAddressEmptyOnBSD() void tst_QTcpSocket::zeroAndMinusOneReturns() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->connectToHost(QtNetworkSettings::httpServerName(), 80); socket->write("GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n"); QVERIFY(socket->waitForReadyRead(15000)); @@ -2376,7 +2401,7 @@ void tst_QTcpSocket::connectionRefused() connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - socket->connectToHost(QtNetworkSettings::serverName(), 144); + socket->connectToHost(QtNetworkSettings::httpServerName(), 144); enterLoop(10); disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), @@ -2456,7 +2481,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect() QEventLoop loop; connect(&serverProcess, SIGNAL(finished(int)), &loop, SLOT(quit())); connect(&clientProcess, SIGNAL(finished(int)), &loop, SLOT(quit())); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); QTimer::singleShot(20000, &loop, SLOT(quit())); @@ -2496,7 +2521,7 @@ void tst_QTcpSocket::connectToMultiIP() // rationale: this domain resolves to 3 A-records, 2 of them are // invalid. QTcpSocket should never spend more than 30 seconds per IP, and // 30s*2 = 60s. - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); socket->connectToHost("multi.dev.qt-project.org", 80); QVERIFY(socket->waitForConnected(60500)); @@ -2523,7 +2548,7 @@ void tst_QTcpSocket::moveToThread0() { // Case 1: Moved after connecting, before waiting for connection. QTcpSocket *socket = newSocket();; - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); socket->moveToThread(0); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); @@ -2535,7 +2560,7 @@ void tst_QTcpSocket::moveToThread0() // Case 2: Moved before connecting QTcpSocket *socket = newSocket(); socket->moveToThread(0); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); @@ -2545,7 +2570,7 @@ void tst_QTcpSocket::moveToThread0() { // Case 3: Moved after writing, while waiting for bytes to be written. QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); socket->moveToThread(0); @@ -2556,7 +2581,7 @@ void tst_QTcpSocket::moveToThread0() { // Case 4: Moved after writing, while waiting for response. QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 143); + socket->connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket->waitForConnected(5000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); @@ -2687,8 +2712,8 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected() // use waitForConnected, e.g. this should use a synchronous select() on the OS level QTcpSocket socket; - socket.connectToHost(QtNetworkSettings::serverName(), 12346); - QTime timer; + socket.connectToHost(QtNetworkSettings::httpServerName(), 12346); + QElapsedTimer timer; timer.start(); socket.waitForConnected(10000); QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong"); @@ -2707,7 +2732,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop() // This testcase uses an event loop QTcpSocket socket; connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - socket.connectToHost(QtNetworkSettings::serverName(), 12346); + socket.connectToHost(QtNetworkSettings::httpServerName(), 12346); QTestEventLoop::instance().enterLoop(10); QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong"); @@ -2720,7 +2745,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY(socket->waitForConnected(5*1000)); QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError); @@ -2749,10 +2774,12 @@ void tst_QTcpSocket::invalidProxy_data() QTest::addColumn<bool>("failsAtConnect"); QTest::addColumn<int>("expectedError"); - QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); - QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << fluke << 21 << true + const QString ftpAddress = QtNetworkSettings::ftpServerIp().toString(); + const QString httpProxyAddress = QtNetworkSettings::httpProxyServerIp().toString(); + const QString socksProxyAddress = QtNetworkSettings::socksProxyServerIp().toString(); + QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << ftpAddress << 21 << true << int(QAbstractSocket::UnsupportedSocketOperationError); - QTest::newRow("http-caching-proxy") << int(QNetworkProxy::HttpCachingProxy) << fluke << 3128 << true + QTest::newRow("http-caching-proxy") << int(QNetworkProxy::HttpCachingProxy) << httpProxyAddress << 3128 << true << int(QAbstractSocket::UnsupportedSocketOperationError); QTest::newRow("no-such-host-socks5") << int(QNetworkProxy::Socks5Proxy) << "this-host-will-never-exist.qt-project.org" << 1080 << false @@ -2760,9 +2787,9 @@ void tst_QTcpSocket::invalidProxy_data() QTest::newRow("no-such-host-http") << int(QNetworkProxy::HttpProxy) << "this-host-will-never-exist.qt-project.org" << 3128 << false << int(QAbstractSocket::ProxyNotFoundError); - QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << fluke << 1080 << false + QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << socksProxyAddress << 1080 << false << int(QAbstractSocket::ProxyConnectionClosedError); - QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << fluke << 3128 << false + QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << httpProxyAddress << 3128 << false << int(QAbstractSocket::SocketTimeoutError); } @@ -2781,7 +2808,7 @@ void tst_QTcpSocket::invalidProxy() QTcpSocket *socket = newSocket(); socket->setProxy(proxy); - socket->connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(), 80); + socket->connectToHost(QtNetworkSettings::httpServerIp().toString(), 80); if (failsAtConnect) { QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); @@ -2833,48 +2860,48 @@ void tst_QTcpSocket::proxyFactory_data() // tests that do connect - proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3129); + proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3129); QTest::newRow("http") << proxyList << proxyList.at(0) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); + proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081); QTest::newRow("socks5") << proxyList << proxyList.at(0) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081); QTest::newRow("cachinghttp+socks5") << proxyList << proxyList.at(1) << false << int(QAbstractSocket::UnknownSocketError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129) - << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129) + << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081); QTest::newRow("ftp+cachinghttp+socks5") << proxyList << proxyList.at(2) << false << int(QAbstractSocket::UnknownSocketError); // tests that fail to connect proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129); + proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129); QTest::newRow("cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121); QTest::newRow("ftp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); proxyList.clear(); - proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) - << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129); + proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121) + << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129); QTest::newRow("ftp+cachinghttp") << proxyList << QNetworkProxy() << true << int(QAbstractSocket::UnsupportedSocketOperationError); @@ -2895,7 +2922,7 @@ void tst_QTcpSocket::proxyFactory() QNetworkProxyFactory::setApplicationProxyFactory(factory); QTcpSocket *socket = newSocket(); - QString host = QtNetworkSettings::serverName(); + QString host = QtNetworkSettings::httpServerName(); socket->connectToHost(host, 80); // Verify that the factory was called properly diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index e856776ddc..969e4d72cf 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -17,3 +17,9 @@ win32 { } TARGET = tst_qudpsocket + +# Only on Linux until 'echo' has been added to docker-compose-for-{windows,macOS}.yml and tested +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = danted echo +} diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 707c1acf48..0f419e9de4 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -40,6 +40,7 @@ #include <qhostinfo.h> #include <qtcpsocket.h> #include <qmap.h> +#include <qelapsedtimer.h> #include <qnetworkdatagram.h> #include <QNetworkProxy> #include <QNetworkInterface> @@ -235,6 +236,7 @@ void tst_QUdpSocket::initTestCase_data() // hack: we only enable the Socks5 over UDP tests on the old // test server, because they fail on the new one. See QTBUG-35490 bool newTestServer = true; +#ifndef QT_TEST_SERVER QTcpSocket socket; socket.connectToHost(QtNetworkSettings::serverName(), 22); if (socket.waitForConnected(10000)) { @@ -244,6 +246,7 @@ void tst_QUdpSocket::initTestCase_data() newTestServer = false; socket.disconnectFromHost(); } +#endif QTest::addColumn<bool>("setProxy"); QTest::addColumn<int>("proxyType"); @@ -257,8 +260,13 @@ void tst_QUdpSocket::initTestCase_data() void tst_QUdpSocket::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::echoServerName(), 7)); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif allAddresses = QNetworkInterface::allAddresses(); m_skipUnsupportedIPv6Tests = shouldSkipIpv6TestsForBrokenSetsockopt(); @@ -300,7 +308,7 @@ void tst_QUdpSocket::init() #if QT_CONFIG(socks5) QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { - QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); + QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1080)); } #else QSKIP("No proxy support"); @@ -915,7 +923,7 @@ void tst_QUdpSocket::performance() client.connectToHost(serverAddress, server.localPort()); QVERIFY(client.waitForConnected(10000)); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qint64 nbytes = 0; @@ -981,7 +989,7 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data() QTest::addColumn<bool>("bind"); QTest::addColumn<QHostAddress>("peerAddress"); QHostAddress localhost(QHostAddress::LocalHost); - QList<QHostAddress> serverAddresses(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses()); + QList<QHostAddress> serverAddresses(QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses()); if (serverAddresses.isEmpty()) return; @@ -995,7 +1003,7 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data() void tst_QUdpSocket::writeDatagramToNonExistingPeer() { - if (QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().isEmpty()) + if (QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses().isEmpty()) QFAIL("Could not find test server address"); QFETCH(bool, bind); QFETCH(QHostAddress, peerAddress); @@ -1015,7 +1023,7 @@ void tst_QUdpSocket::writeToNonExistingPeer_data() { QTest::addColumn<QHostAddress>("peerAddress"); QHostAddress localhost(QHostAddress::LocalHost); - QList<QHostAddress> serverAddresses(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses()); + QList<QHostAddress> serverAddresses(QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses()); if (serverAddresses.isEmpty()) return; @@ -1028,7 +1036,7 @@ void tst_QUdpSocket::writeToNonExistingPeer_data() void tst_QUdpSocket::writeToNonExistingPeer() { QSKIP("Connected-mode UDP sockets and their behaviour are erratic"); - if (QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().isEmpty()) + if (QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses().isEmpty()) QFAIL("Could not find test server address"); QFETCH(QHostAddress, peerAddress); quint16 peerPort = 34534; @@ -1551,7 +1559,7 @@ void tst_QUdpSocket::echo_data() void tst_QUdpSocket::echo() { QFETCH(bool, connect); - QHostInfo info = QHostInfo::fromName(QtNetworkSettings::serverName()); + QHostInfo info = QHostInfo::fromName(QtNetworkSettings::echoServerName()); QVERIFY(info.addresses().count()); QHostAddress remote = info.addresses().first(); diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 88be13f41d..efc0c26076 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -401,9 +401,7 @@ void tst_QSslCertificate::subjectAlternativeNames() certificate.subjectAlternativeNames(); // verify that each entry in subjAltNames is present in fileContents - QMapIterator<QSsl::AlternativeNameEntryType, QString> it(altSubjectNames); - while (it.hasNext()) { - it.next(); + for (auto it = altSubjectNames.cbegin(), end = altSubjectNames.cend(); it != end; ++it) { QByteArray type; if (it.key() == QSsl::EmailEntry) type = "email"; @@ -814,7 +812,7 @@ void tst_QSslCertificate::task256066toPem() void tst_QSslCertificate::nulInCN() { -#if defined(QT_SECURETRANSPORT) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) +#if QT_CONFIG(securetransport) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) QSKIP("Generic QSslCertificatePrivate fails this test"); #endif QList<QSslCertificate> certList = @@ -833,7 +831,7 @@ void tst_QSslCertificate::nulInCN() void tst_QSslCertificate::nulInSan() { -#if defined(QT_SECURETRANSPORT) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) +#if QT_CONFIG(securetransport) || defined(Q_OS_WINRT) || QT_CONFIG(schannel) QSKIP("Generic QSslCertificatePrivate fails this test"); #endif QList<QSslCertificate> certList = @@ -968,7 +966,7 @@ void tst_QSslCertificate::subjectAndIssuerAttributes() void tst_QSslCertificate::verify() { -#ifdef QT_SECURETRANSPORT +#if QT_CONFIG(securetransport) QSKIP("Not implemented in SecureTransport"); #endif QList<QSslError> errors; diff --git a/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes128.pem b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes128.pem new file mode 100644 index 0000000000..1a8751874e --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes128.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,A2A6F6BA67CFB2A992BA4FD3A0984B59 + +L5G1mwcXwW30lFty1HaEHlswFXAGk9+qf0TdYYNAAvVrsTMgfMq/6xM5XWo3IgbN +gG4K6T57gQkAywn+upqMHobB+7qc3DRzYlrm89gb74gHOe95l/iUJp4ii+ROLcmY +fg/vNmDSB/D0eM91WfwId7ticYD29+BUbbnqSYyY2S7K7DytYLpXqg3u335GYCdT +JwOsgcgbOICytkgK6c9ZDF3IrkzvWospVuiG5IfpLQkUXlJO3YGJ/oGf1BXnRd/b +kTzUiimUVunX62muHaUXKkAmXS8FCdB0puI+52pzLJ5FHdFxCcnwSG09TmoXbwwa +KoNM+IshNHPBGM7QxflVbSDxDaF1FWLwWSb8+Fhb2fTpfEGMxRCQ8HB1ZeMV4E5W +DSiNhih8ziC0k957ZYv8iuLanoM1YYIdToHeBwjyBJA836eIcq/ElY2QtKUq5PRw ++sU1BdG+f9rf4iAPHpgWZAKFmJ42ya71bEEVAmfysAOPuc4hpn3SsDTtihm9RKc9 +l7LWJHaTnTu6yJA+vMJwAmPWg+IdG5vntbb93X4cgl5ZadBySRtv37wWyQPnQcFh +ytX8z2CJNIFJb0ik8bXc39zOxExoTu/o86IuVJ87jFdS1wz3PRek6dJdl15icx76 +yAT0YB2/ZlRcRrO9hSm0D6P+sLOh//dyhhFAlUrDxqrKngI3KF4kgIrSlva3wmx2 +t16SiUKu6FGQZk6/KYOV27Cy+8UJEqlrNJzy+wSFi26d6e6xWTIR2ItzQCxhYDmq +Tpx0Mh0ml2+bgrKRoDAL5z6UNy0Pc6bYQjvMznIeiuGvL8bAKTDUFwbmrZqNScsl +tW7yNZG9iSJnAZGMTxuOhSvJRpQkxIcLICd+lsUxWZ2YvFxtSORuRNSwaC7oxtTD +gIXV08ayoDbDmcguqTXWuCxtguxNANjhsUOetNHL8iP8QFrzAd5Ith9FgASCIBJJ +3X7vL2YGc3E6DlAJE01loqySU/cnu6/zQapLB9BIzdtoLliwdrJ7PS8FSsBDfZ2X +i6/7gb1jxYkJAS1NqrUMJw6BphRAwF8ny+FtPJ23Oaf+1vRIGiHsh8qw6XBfwFw9 +vtsUUL19r+8zMpvIB6gf34TLuM7AW7idu3c/486EWgZBDL3mOTd3fsyADKv/HCk7 +c8M2dsafxI6QkTlWsB8G5vkZ8lCGKHjrmPWjfD7NXi+CvXIrDY+gOeVN3PlQCU/2 +zF2vIxKtR0CXuxLzIjFhIgTYR5G5ZnddMmHeVkZdPRl7szGtrxOA4QGJQ6ZT4W2e +O1whVU2KB0aBYskhClimapM5ypRkcNQ97cUR6/iNgdgSLqxGHCGeMR9bEyLl7/wr +M0XeDjdVfm/Tj548oHgb0SKLsfL6nnKwqB2viKj81moK9A/wO1Ec9RNaw0jtp2j3 +VIUnPj0GqEjnkHc2jWY2yt4SD6e2AZHwLyWi1q3pixZo1CFiEgFXxwNyYwyeJ6jV +CJHPRzoNjZ8dkvgRjsXdnWwN316JBNVcH8k7CCmg/8Gq3yAojXG1z8VJZ06GHckd +meCL1t89OgwIAmIsysKu7+DrKtSlhkQclZmdG6IrQzuPKaHzTPTDgg3ef3jQ4YQO +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes192.pem b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes192.pem new file mode 100644 index 0000000000..db74877a5a --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes192.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-192-CBC,B408346ADE790F8CF0C902A4F0712B34 + +SwzPBGxmwW2JddOyug1LrWjlZn8siSp5yezjK1x/z2+J2r/vvH8OjGnA387tFtae +WVTmhT1ixQXMDI1UJuKx0gzrG2449c+BUVe2VXFPLZ2ocSgoXbBpVkfhEqtLAn91 +MSOpQMxvobQKltKhxgXGvuBJwhwfT7yK5HamohFGbxLUh4Dh+NBXwoYH4Qt+kM7C +kV8VIKvkr/QAL/SRxNoY8rVResPgYvUjdtiGSNZ6CZhNRu42Q2FqbH817cE0NDsN +il/xvWu4T/6VY1KpwMad/v6BhO45EeKz7YjbF/3Y5jj2JV9r45uf79lM9htMBw0d +L+Cc3YHeFffgU8NZo0+iUoroXcb7mjWNmgYksbkaZPbLG383YXAXwbkQS7zDMVIx +QhXn9w+78hNmEV/7PQ8mGXHEFwnfSR05phXoj8IyL5v0grRMA2dsjfxCgfQjH+kc +Miwr5pD/Flw175OpPFCb2qladdTKoIWiVShspbteoRC0EuiWHzkl5z6Tneyb/sam +yduLmSYD+RA6OBgUPY95Xm4AowlFFsuV/fxYZ53rFf4cZn9Z6VBVmvIEmapV7CtB +JzyIVclocwM0ag5u/esdEt/jndJq9chZlIsDS30y3gP6Rlqk5mj90DAs98l28FVG +WY9jP0babk8mxjYCcnAy7ikUc0D+vJVO6OTmfO3dkGjLpMBM6OlvfhN/0qeXrMDI +nU2qOshUrVna2kRe6FrcvosFTD8wvQ1/BjmCp1iWWsGdc/q1BqI3pgOlgq3TYfl6 +iUJoji3V2iexH+GPkHsrs+kii1clsO2tgIP7doIooSVkcTsRTHHxKeeHn3qL2028 +pTvieIFD/T4biLZ9Q8sX3XWiHNmXZlCx8lX8MDjTavWES8gY4H5Sr6FjRMy1qpZY +5w1aAyJ9YZ0J/jLPmFxt8mWgqHPiPlrQkryBBE3l1MSQ/hCEwlf9dP8a+ayINfd7 +3yNkHKjZ5fuoA+TZUQb/fyVM5o1zJ8ML01PaXWrMEgr3b36QL+Ivo2Rpnp9FpwuH +E405cwCEy5fNSyhHFqqatCbsPl80nkP8OpW6jdWvNy9u0Ap9PS+MbHGq/pfkaazl +fbKGOckrENzEXi6Uj/yY/0sMtbTJuC70n09X3edHyhl/RJPPUoNnwDM5W1FHfS3r +qqSOl/r3y5pEErRdBpR4wEgB7DCLBALGDPfXNAAga4ez/Z2X9Zj234+4ZbUzWoLN +1ER0QYyxLN7oz1qMA15J7nRyRIhDXNlXjyISOqy26T6/d4X0M+6RhNWfT/MHAjJ8 +6ogoGlQUITV3gPO4R6+FGZMF4R6zZXuKVtOXyzRwWnCLfo4gzBHmq+5mmCjGWRq8 +rSSkc6334bYuZOaEoR5EM5sh6ewkjSDPRrKR7EHO02YbiscyT/99TwT5pdIOPK3u +2T6/40fSmCWQyBLuWxV9CMD+rB/q8Ja5KisEseck7PgI2pMmHfiD5yQXhKR9eDrB +sRqZxjgRYxup+/0CIBshL8s1R88xelhXyIKyqFfVudM09yAZxEJLQhpDZ27g45ea +FMX2Ve+ah2NjYBgzAhwKouWg5RyWb6X99NsrCEU75fn/ek86LGs3FxRgB4Uv7Udv +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes256.pem b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes256.pem new file mode 100644 index 0000000000..3d96b3166e --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-aes256.pem @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,0F2F4695C8FFA35F4076FA0273A3A4E3 + +GCnMcAhhGuNkJ7SSMBrgNOaDfRtG22J0mdf/0VbrMOJF40P13YBjN3Kd6LpTqBya +TCIaxQqtfjH1ffhJk8qhwG7uJFGgcY9i0dkrEYklgThzTVqHp7FsQ2jjgJs5HKpc +euuVD1bxtuc9qI2hq4miA7Z/uDe3M34n+3xcpqccWS1dLFNFZ+fIDwIazfDCu3ah +fUQHDeWLwOqYiQxhUjjrHpZkI1FE2JYZFaf4zIagIIgzI2O+33fgbrTSoeN5meRs +F7V2fhDpyEoIlchwAmp6HE6ngtKP4Ecju00yn99AO42fn097yEVwvGFClQTaIzur +aPEtuKZ4kdc/lmzL2tqNcZckq28ZxpeMq0Fgdcpeg5sDcut811scOjQLFs551On1 +j3E1WfiLoBLKgd9cgmCrZb8hMO+UjcCaV7Jv3T9vDrbvhWs/YhTTwo8UFVplh7Vx +R1h3cKfzlbtOC5WHXGNK5dBu7SnpEk0+pscY5cxTrzN0odjMbbsjZQmKDZXbmZON +USzG3Qtafm6Nw/jwQeIjeqaxSho6xGdadTteGaURw6iGio3h0c6/dHayCsxye4tk +vODa0ZdJASwVh1605qDk9n/iYUT5B46KJCYwO/iN2kUmOcUcZeBqEfV1GfRmepZJ +bwM4sipzE15hOJ5DKSkHWnSlByRMAdSrMxZWraKUczn5frEBAqEFLlBAvf/FnjWa +yZJitgryCI2Y2bww1DEMnTCX345kUQIFmmjbzTIXnM28gW+fR3Br9dCf2FAsLNKr +tru1cYXocPaCUHEqS+XZqVb6BQVQ11YAAde0+x9RknJgsBc9Y7TLobaDBvrV5/nK +T3vm8el08upum6qPTPh6Z0zBbjx4sp6DYT977N1dYeH4n+0JqcSwIeZg/VAdG0RL +GzgZVADpiRlStmy65W95KExBjbO0tRTVk/nB1U1nfLbsswp9EKxXgwtpE/ECeTOi +hzeJBSsXGZ/ZXu/y+NlIu0B/GasFbfrHKslSSrUPTjGEtaEbLNiOEu2Etu3lRcMZ +oDtMxgNR0TUgCS5nte8lLauYYfB6IuxZXpvJdcI5ushqdOJvvYgJ9Yb2ZPlY8Bt5 +C92Ga69aPcMYk24BPpe15eBbXMsFF8RF+CprVoUPCc+PcuROtxdt+rqoqjQeZPmV +WQqq+pT2bychpwD7U5jxQnu4u2m+zeBXyk80euBbwEld9BCgfk9mFj6CdBJSEiGV +qL0ivxd3mDaIKPGd5tcbrOMK2uD7duZY7FrQpAYgryoQJoUHccL7cr9fDC75akHg +AbrG1+vAYEla/y+SlOg5VTHhiuIl17ZGMViXSqh7iqnnD0dNsZ/HDvk3XouhNxQy +RQmfdqyIqLuAcfWwQxCQ2E/oMUIHjNhyYmfLVLVGsfxuevMa1eJv7rZ5vIkD2Vpe +4VveZkNDSpCCNqnvub8+bMW+UXyzbxEZbK5PLkRp7cvtKdA5CUbTlT4060IV0YZ1 +vfMtzXRw8JDD9c1F1WF14afk+y9kvZN88XOH12bSKj+Re06Xx7OzuYU8fclq/pZB +UZVtRETFnLgb8neMuz3vCoPWK/DSHDZGAAicxq7vTljyoU/QP71Dw7UJIAuYx6Mc +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 28476fce5b..f94756ed73 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -30,6 +30,7 @@ #include <QtTest/QtTest> #include <qsslkey.h> #include <qsslsocket.h> +#include <QScopeGuard> #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qnetworkproxy.h> @@ -233,15 +234,50 @@ void tst_QSslKey::constructorHandle() QByteArray passphrase; if (QByteArray(QTest::currentDataTag()).contains("-pkcs8-")) passphrase = "1234"; + BIO* bio = q_BIO_new(q_BIO_s_mem()); q_BIO_write(bio, pem.constData(), pem.length()); - QSslKey key(func(bio, nullptr, nullptr, static_cast<void *>(passphrase.data())), type); + EVP_PKEY *origin = func(bio, nullptr, nullptr, static_cast<void *>(passphrase.data())); +#if QT_CONFIG(opensslv11) + q_EVP_PKEY_up_ref(origin); +#endif + QSslKey key(origin, type); +#if !QT_CONFIG(opensslv11) + q_BIO_write(bio, pem.constData(), pem.length()); + origin = func(bio, nullptr, nullptr, static_cast<void *>(passphrase.data())); +#endif q_BIO_free(bio); + EVP_PKEY *handle = q_EVP_PKEY_new(); + switch (algorithm) { + case QSsl::Rsa: + q_EVP_PKEY_set1_RSA(handle, static_cast<RSA *>(key.handle())); + break; + case QSsl::Dsa: + q_EVP_PKEY_set1_DSA(handle, static_cast<DSA *>(key.handle())); + break; + case QSsl::Dh: + q_EVP_PKEY_set1_DH(handle, static_cast<DH *>(key.handle())); + break; +#ifndef OPENSSL_NO_EC + case QSsl::Ec: + q_EVP_PKEY_set1_EC_KEY(handle, static_cast<EC_KEY *>(key.handle())); + break; +#endif + default: + break; + } + + auto cleanup = qScopeGuard([origin, handle] { + q_EVP_PKEY_free(origin); + q_EVP_PKEY_free(handle); + }); + QVERIFY(!key.isNull()); QCOMPARE(key.algorithm(), algorithm); QCOMPARE(key.type(), type); QCOMPARE(key.length(), length); + QCOMPARE(q_EVP_PKEY_cmp(origin, handle), 1); #endif } @@ -430,15 +466,25 @@ void tst_QSslKey::toEncryptedPemOrDer() void tst_QSslKey::passphraseChecks_data() { QTest::addColumn<QString>("fileName"); - - QTest::newRow("DES") << (testDataDir + "rsa-with-passphrase-des.pem"); - QTest::newRow("3DES") << (testDataDir + "rsa-with-passphrase-3des.pem"); - QTest::newRow("RC2") << (testDataDir + "rsa-with-passphrase-rc2.pem"); + QTest::addColumn<QByteArray>("passphrase"); + + const QByteArray pass("123"); + const QByteArray aesPass("1234"); + + QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass; + QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem") << pass; + QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass; +#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || (defined(QT_NO_OPENSSL) && QT_CONFIG(ssl)) + QTest::newRow("AES128") << QString(testDataDir + "rsa-with-passphrase-aes128.pem") << aesPass; + QTest::newRow("AES192") << QString(testDataDir + "rsa-with-passphrase-aes192.pem") << aesPass; + QTest::newRow("AES256") << QString(testDataDir + "rsa-with-passphrase-aes256.pem") << aesPass; +#endif // (OpenSSL && AES) || generic backend } void tst_QSslKey::passphraseChecks() { QFETCH(QString, fileName); + QFETCH(QByteArray, passphrase); QFile keyFile(fileName); QVERIFY(keyFile.exists()); @@ -471,7 +517,7 @@ void tst_QSslKey::passphraseChecks() keyFile.open(QIODevice::ReadOnly); else keyFile.reset(); - QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "123"); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, passphrase); QVERIFY(!key.isNull()); // correct passphrase } } @@ -516,79 +562,135 @@ void tst_QSslKey::encrypt_data() QTest::addColumn<QByteArray>("key"); QTest::addColumn<QByteArray>("plainText"); QTest::addColumn<QByteArray>("cipherText"); + QTest::addColumn<QByteArray>("iv"); + QByteArray iv("abcdefgh"); QTest::newRow("DES-CBC, length 0") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray() - << QByteArray::fromHex("956585228BAF9B1F"); + << QByteArray::fromHex("956585228BAF9B1F") + << iv; QTest::newRow("DES-CBC, length 1") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(1, 'a') - << QByteArray::fromHex("E6880AF202BA3C12"); + << QByteArray::fromHex("E6880AF202BA3C12") + << iv; QTest::newRow("DES-CBC, length 2") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(2, 'a') - << QByteArray::fromHex("A82492386EED6026"); + << QByteArray::fromHex("A82492386EED6026") + << iv; QTest::newRow("DES-CBC, length 3") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(3, 'a') - << QByteArray::fromHex("90B76D5B79519CBA"); + << QByteArray::fromHex("90B76D5B79519CBA") + << iv; QTest::newRow("DES-CBC, length 4") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(4, 'a') - << QByteArray::fromHex("63E3DD6FED87052A"); + << QByteArray::fromHex("63E3DD6FED87052A") + << iv; QTest::newRow("DES-CBC, length 5") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(5, 'a') - << QByteArray::fromHex("03ACDB0EACBDFA94"); + << QByteArray::fromHex("03ACDB0EACBDFA94") + << iv; QTest::newRow("DES-CBC, length 6") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(6, 'a') - << QByteArray::fromHex("7D95024E42A3A88A"); + << QByteArray::fromHex("7D95024E42A3A88A") + << iv; QTest::newRow("DES-CBC, length 7") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(7, 'a') - << QByteArray::fromHex("5003436B8A8E42E9"); + << QByteArray::fromHex("5003436B8A8E42E9") + << iv; QTest::newRow("DES-CBC, length 8") << QSslKeyPrivate::DesCbc << QByteArray("01234567") << QByteArray(8, 'a') - << QByteArray::fromHex("E4C1F054BF5521C0A4A0FD4A2BC6C1B1"); + << QByteArray::fromHex("E4C1F054BF5521C0A4A0FD4A2BC6C1B1") + << iv; QTest::newRow("DES-EDE3-CBC, length 0") << QSslKeyPrivate::DesEde3Cbc << QByteArray("0123456789abcdefghijklmn") << QByteArray() - << QByteArray::fromHex("3B2B4CD0B0FD495F"); + << QByteArray::fromHex("3B2B4CD0B0FD495F") + << iv; QTest::newRow("DES-EDE3-CBC, length 8") << QSslKeyPrivate::DesEde3Cbc << QByteArray("0123456789abcdefghijklmn") << QByteArray(8, 'a') - << QByteArray::fromHex("F2A5A87763C54A72A3224103D90CDB03"); + << QByteArray::fromHex("F2A5A87763C54A72A3224103D90CDB03") + << iv; QTest::newRow("RC2-40-CBC, length 0") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234") << QByteArray() - << QByteArray::fromHex("6D05D52392FF6E7A"); + << QByteArray::fromHex("6D05D52392FF6E7A") + << iv; QTest::newRow("RC2-40-CBC, length 8") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234") << QByteArray(8, 'a') - << QByteArray::fromHex("75768E64C5749072A5D168F3AFEB0005"); + << QByteArray::fromHex("75768E64C5749072A5D168F3AFEB0005") + << iv; QTest::newRow("RC2-64-CBC, length 0") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234567") << QByteArray() - << QByteArray::fromHex("ADAE6BF70F420130"); + << QByteArray::fromHex("ADAE6BF70F420130") + << iv; QTest::newRow("RC2-64-CBC, length 8") << QSslKeyPrivate::Rc2Cbc << QByteArray("01234567") << QByteArray(8, 'a') - << QByteArray::fromHex("C7BF5C80AFBE9FBEFBBB9FD935F6D0DF"); + << QByteArray::fromHex("C7BF5C80AFBE9FBEFBBB9FD935F6D0DF") + << iv; QTest::newRow("RC2-128-CBC, length 0") << QSslKeyPrivate::Rc2Cbc << QByteArray("012345679abcdefg") << QByteArray() - << QByteArray::fromHex("1E965D483A13C8FB"); + << QByteArray::fromHex("1E965D483A13C8FB") + << iv; QTest::newRow("RC2-128-CBC, length 8") << QSslKeyPrivate::Rc2Cbc << QByteArray("012345679abcdefg") << QByteArray(8, 'a') - << QByteArray::fromHex("5AEC1A5B295660B02613454232F7DECE"); + << QByteArray::fromHex("5AEC1A5B295660B02613454232F7DECE") + << iv; + +#if (!defined(QT_NO_OPENSSL) && !defined(OPENSSL_NO_AES)) || (defined(QT_NO_OPENSSL) && QT_CONFIG(ssl)) + // AES needs a longer IV + iv = QByteArray("abcdefghijklmnop"); + QTest::newRow("AES-128-CBC, length 0") + << QSslKeyPrivate::Aes128Cbc << QByteArray("012345679abcdefg") + << QByteArray() + << QByteArray::fromHex("28DE1A9AA26601C30DD2527407121D1A") + << iv; + QTest::newRow("AES-128-CBC, length 8") + << QSslKeyPrivate::Aes128Cbc << QByteArray("012345679abcdefg") + << QByteArray(8, 'a') + << QByteArray::fromHex("08E880B1BA916F061C1E801D7F44D0EC") + << iv; + + QTest::newRow("AES-192-CBC, length 0") + << QSslKeyPrivate::Aes192Cbc << QByteArray("0123456789abcdefghijklmn") + << QByteArray() + << QByteArray::fromHex("E169E0E205CDC2BA895B7CF6097673B1") + << iv; + QTest::newRow("AES-192-CBC, length 8") + << QSslKeyPrivate::Aes192Cbc << QByteArray("0123456789abcdefghijklmn") + << QByteArray(8, 'a') + << QByteArray::fromHex("3A227D6A3A13237316D30AA17FF9B0A7") + << iv; + + QTest::newRow("AES-256-CBC, length 0") + << QSslKeyPrivate::Aes256Cbc << QByteArray("0123456789abcdefghijklmnopqrstuv") + << QByteArray() + << QByteArray::fromHex("4BAACAA0D22199C97DE206C465B7B14A") + << iv; + QTest::newRow("AES-256-CBC, length 8") + << QSslKeyPrivate::Aes256Cbc << QByteArray("0123456789abcdefghijklmnopqrstuv") + << QByteArray(8, 'a') + << QByteArray::fromHex("879C8C25EC135CDF0B14490A0A7C2F67") + << iv; +#endif // (OpenSSL && AES) || generic backend } void tst_QSslKey::encrypt() @@ -597,7 +699,7 @@ void tst_QSslKey::encrypt() QFETCH(QByteArray, key); QFETCH(QByteArray, plainText); QFETCH(QByteArray, cipherText); - QByteArray iv("abcdefgh"); + QFETCH(QByteArray, iv); #if defined(Q_OS_WINRT) || QT_CONFIG(schannel) QEXPECT_FAIL("RC2-40-CBC, length 0", "WinRT/Schannel treats RC2 as 128-bit", Abort); diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index 555822d1e6..3ecd3d9dbb 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -1,7 +1,23 @@ +[abortOnSslErrors] +windows +[deprecatedProtocols] +windows +[disabledProtocols] +windows +[protocol] +windows +[qtbug18498_peek] +windows +[setReadBufferSize] +windows +[spontaneousWrite] +windows +[sslErrors] windows [connectToHostEncrypted] osx-10.13 [setSslConfiguration] +windows osx-10.13 [connectToHostEncryptedWithVerificationPeerName] osx-10.13 diff --git a/tests/auto/network/ssl/qsslsocket/certs/qt-test-server-cert.pem b/tests/auto/network/ssl/qsslsocket/certs/qt-test-server-cert.pem new file mode 100644 index 0000000000..43c8794ce2 --- /dev/null +++ b/tests/auto/network/ssl/qsslsocket/certs/qt-test-server-cert.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIIClTCCAf4CCQC2xMhNhwvATDANBgkqhkiG9w0BAQQFADCBjjELMAkGA1UEChMC +UXQxGTAXBgNVBAsTEENvcmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5v +Ym9keS5xdC5pbzENMAsGA1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UE +BhMCTk8xHDAaBgNVBAMUEyoudGVzdC1uZXQucXQubG9jYWwwHhcNMTgwNzAxMTgz +NjI3WhcNNDgwNjIzMTgzNjI3WjCBjjELMAkGA1UEChMCUXQxGTAXBgNVBAsTEENv +cmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5vYm9keS5xdC5pbzENMAsG +A1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UEBhMCTk8xHDAaBgNVBAMU +EyoudGVzdC1uZXQucXQubG9jYWwwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB +AM2q22/WNMmn8cC+5EEYGeICySLmp9W6Ay6eKHr0Xxp3X3epETuPfvAuxp7rOtkS +18EMUegkUj8jw0IMEcbyHKFC/rTCaYOt93CxGBXMIChiMPAsFeYzGa/D6xzAkfcR +aJRQ+Ek3CDLXPnXfo7xpABXezYcPXAJrgsgBfWrwHdxzAgMBAAEwDQYJKoZIhvcN +AQEEBQADgYEAZu/lQPy8PXeyyYGamOVms/FZKJ48BH1y8KC3BeBU5FYnhvgG7pz8 +Wz9JKvt2t/r45wQeAkNL6HnGUBhPJsHMjPHl5KktqN+db3D+FQygBeS2V1+zmC0X +UZNRE4aWiHvt1Lq+pTx89SOMOpfqWfh4qTQKiE5jC2V4DeCNQ3u7uI8= +-----END CERTIFICATE----- diff --git a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro index 1260dc9410..51fcff9a8d 100644 --- a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro +++ b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro @@ -18,3 +18,10 @@ TESTDATA += certs DEFINES += SRCDIR=\\\"$$PWD/\\\" requires(qtConfig(private_tests)) + +# DOCKERTODO: it's 'linux' because it requires cyrus, which +# is linux-only for now ... +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = squid danted cyrus apache2 echo +} diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 1a9cab3e24..b05f989b5c 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -29,6 +29,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qthread.h> +#include <QtCore/qelapsedtimer.h> #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostinfo.h> #include <QtNetwork/qnetworkproxy.h> @@ -310,6 +311,21 @@ Q_DECLARE_METATYPE(tst_QSslSocket::PskConnectTestType) int tst_QSslSocket::loopLevel = 0; +namespace { + +QString httpServerCertChainPath() +{ + // DOCKERTODO: note how we use CA certificate on the real server. The docker container + // is using a different cert with a "special" CN. Check if it's important! +#ifdef QT_TEST_SERVER + return tst_QSslSocket::testDataDir + QStringLiteral("certs/qt-test-server-cert.pem"); +#else + return tst_QSslSocket::testDataDir + QStringLiteral("certs/qt-test-server-cacert.pem"); +#endif // QT_TEST_SERVER +} + +} // unnamed namespace + tst_QSslSocket::tst_QSslSocket() { #ifndef QT_NO_SSL @@ -363,8 +379,19 @@ void tst_QSslSocket::initTestCase() qDebug("Using SSL library %s (%ld)", qPrintable(QSslSocket::sslLibraryVersionString()), QSslSocket::sslLibraryVersionNumber()); +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1081)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 443)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 993)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::echoServerName(), 13)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); -#endif +#endif // QT_TEST_SERVER +#endif // QT_NO_SSL } void tst_QSslSocket::init() @@ -373,28 +400,29 @@ void tst_QSslSocket::init() if (setProxy) { #ifndef QT_NO_NETWORKPROXY QFETCH_GLOBAL(int, proxyType); - QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + const QString socksProxyAddr = QtNetworkSettings::socksProxyServerIp().toString(); + const QString httpProxyAddr = QtNetworkSettings::httpProxyServerIp().toString(); QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksProxyAddr, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksProxyAddr, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddr, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddr, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddr, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); @@ -555,7 +583,7 @@ void tst_QSslSocket::simpleConnect() connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(exitLoop())); // Start connecting - socket.connectToHost(QtNetworkSettings::serverName(), 993); + socket.connectToHost(QtNetworkSettings::imapServerName(), 993); QCOMPARE(socket.state(), QAbstractSocket::HostLookupState); enterLoop(10); @@ -610,7 +638,7 @@ void tst_QSslSocket::simpleConnectWithIgnore() connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(exitLoop())); // Start connecting - socket.connectToHost(QtNetworkSettings::serverName(), 993); + socket.connectToHost(QtNetworkSettings::imapServerName(), 993); QVERIFY(socket.state() != QAbstractSocket::UnconnectedState); // something must be in progress enterLoop(10); @@ -642,7 +670,7 @@ void tst_QSslSocket::sslErrors_data() QString name = QtNetworkSettings::serverLocalName(); QTest::newRow(qPrintable(name)) << name << 993; - name = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + name = QtNetworkSettings::httpServerIp().toString(); QTest::newRow(qPrintable(name)) << name << 443; } @@ -659,7 +687,20 @@ void tst_QSslSocket::sslErrors() QSignalSpy sslErrorsSpy(socket.data(), SIGNAL(sslErrors(QList<QSslError>))); QSignalSpy peerVerifyErrorSpy(socket.data(), SIGNAL(peerVerifyError(QSslError))); - socket->connectToHostEncrypted(host, port); +#ifdef QT_TEST_SERVER + // On the old test server we had the same certificate on different services. + // The idea of this test is to fail with 'HostNameMismatch', when we're using + // either serverLocalName() or IP address directly. With Docker we connect + // to IMAP server, and we have to connect using imapServerName() and passing + // 'host' as peerVerificationName to the overload of connectToHostEncrypted(). + if (port == 993) { + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), port, host); + } else +#endif // QT_TEST_SERVER + { + socket->connectToHostEncrypted(host, port); + } + if (!socket->waitForConnected()) QSKIP("Skipping flaky test - See QTBUG-29941"); socket->waitForEncrypted(10000); @@ -739,13 +780,13 @@ void tst_QSslSocket::connectToHostEncrypted() socket->setProtocol(QSsl::SslProtocol::TlsV1_1); #endif this->socket = socket.data(); - QVERIFY(socket->addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem")); + QVERIFY(socket->addCaCertificates(httpServerCertChainPath())); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); #endif - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); // This should pass unconditionally when using fluke's CA certificate. // or use untrusted certificate workaround @@ -758,7 +799,7 @@ void tst_QSslSocket::connectToHostEncrypted() QCOMPARE(socket->mode(), QSslSocket::SslClientMode); - socket->connectToHost(QtNetworkSettings::serverName(), 13); + socket->connectToHost(QtNetworkSettings::echoServerName(), 13); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); @@ -776,14 +817,18 @@ void tst_QSslSocket::connectToHostEncryptedWithVerificationPeerName() #endif this->socket = socket.data(); - socket->addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem"); + socket->addCaCertificates(httpServerCertChainPath()); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); #endif - // connect to the server with its local name, but use the full name for verification. - socket->connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443, QtNetworkSettings::serverName()); +#ifdef QT_TEST_SERVER + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443, QtNetworkSettings::httpServerName()); +#else + // Connect to the server with its local name, but use the full name for verification. + socket->connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443, QtNetworkSettings::httpServerName()); +#endif // This should pass unconditionally when using fluke's CA certificate. QFETCH_GLOBAL(bool, setProxy); @@ -805,7 +850,7 @@ void tst_QSslSocket::sessionCipher() this->socket = socket.data(); connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); QVERIFY(socket->sessionCipher().isNull()); - socket->connectToHost(QtNetworkSettings::serverName(), 443 /* https */); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443 /* https */); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QVERIFY(socket->sessionCipher().isNull()); socket->startClientEncryption(); @@ -840,12 +885,12 @@ void tst_QSslSocket::localCertificate() // values. This test should just run the codepath inside qsslsocket_openssl.cpp QSslSocketPtr socket = newSocket(); - QList<QSslCertificate> localCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(httpServerCertChainPath()); socket->setCaCertificates(localCert); socket->setLocalCertificate(testDataDir + "certs/fluke.cert"); socket->setPrivateKey(testDataDir + "certs/fluke.key"); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -868,8 +913,7 @@ void tst_QSslSocket::peerCertificateChain() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - - QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(httpServerCertChainPath()); QCOMPARE(caCertificates.count(), 1); socket->addCaCertificates(caCertificates); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND @@ -877,7 +921,7 @@ void tst_QSslSocket::peerCertificateChain() this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); #endif - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); QVERIFY(socket->peerCertificateChain().isEmpty()); QFETCH_GLOBAL(bool, setProxy); @@ -906,7 +950,7 @@ void tst_QSslSocket::peerCertificateChain() QVERIFY(socket->waitForDisconnected()); // now do it again back to the original server - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode); QVERIFY(socket->peerCertificateChain().isEmpty()); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); @@ -945,13 +989,13 @@ void tst_QSslSocket::privateKeyOpaque() // values. This test should just run the codepath inside qsslsocket_openssl.cpp QSslSocketPtr socket = newSocket(); - QList<QSslCertificate> localCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(httpServerCertChainPath()); socket->setCaCertificates(localCert); socket->setLocalCertificate(testDataDir + "certs/fluke.cert"); socket->setPrivateKey(QSslKey(reinterpret_cast<Qt::HANDLE>(pkey))); socket->setPeerVerifyMode(QSslSocket::QueryPeer); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -965,7 +1009,7 @@ void tst_QSslSocket::protocol() QSslSocketPtr socket = newSocket(); this->socket = socket.data(); - QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> certs = QSslCertificate::fromPath(httpServerCertChainPath()); socket->setCaCertificates(certs); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND @@ -979,13 +1023,13 @@ void tst_QSslSocket::protocol() // qt-test-server allows TLSV1. socket->setProtocol(QSsl::TlsV1_0); QCOMPARE(socket->protocol(), QSsl::TlsV1_0); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_0); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_0); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -998,13 +1042,13 @@ void tst_QSslSocket::protocol() // qt-test-server probably doesn't allow TLSV1.1 socket->setProtocol(QSsl::TlsV1_1); QCOMPARE(socket->protocol(), QSsl::TlsV1_1); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_1); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_1); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1016,13 +1060,13 @@ void tst_QSslSocket::protocol() // qt-test-server probably doesn't allows TLSV1.2 socket->setProtocol(QSsl::TlsV1_2); QCOMPARE(socket->protocol(), QSsl::TlsV1_2); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_2); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_2); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1036,13 +1080,13 @@ void tst_QSslSocket::protocol() // qt-test-server probably doesn't allow TLSV1.3 socket->setProtocol(QSsl::TlsV1_3); QCOMPARE(socket->protocol(), QSsl::TlsV1_3); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("TLS 1.3 is not supported by the test server or the test is flaky - see QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1_3); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1_3); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1055,13 +1099,13 @@ void tst_QSslSocket::protocol() // qt-test-server allows SSLV3, so it allows AnyProtocol. socket->setProtocol(QSsl::AnyProtocol); QCOMPARE(socket->protocol(), QSsl::AnyProtocol); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::AnyProtocol); socket->abort(); QCOMPARE(socket->protocol(), QSsl::AnyProtocol); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket->waitForConnected(), qPrintable(socket->errorString())); socket->startClientEncryption(); if (setProxy && !socket->waitForEncrypted()) @@ -1073,13 +1117,13 @@ void tst_QSslSocket::protocol() // qt-test-server allows TlsV1, so it allows TlsV1SslV3 socket->setProtocol(QSsl::TlsV1SslV3); QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3); socket->abort(); QCOMPARE(socket->protocol(), QSsl::TlsV1SslV3); - socket->connectToHost(QtNetworkSettings::serverName(), 443); + socket->connectToHost(QtNetworkSettings::httpServerName(), 443); if (setProxy && !socket->waitForConnected()) QSKIP("Skipping flaky test - See QTBUG-29941"); socket->startClientEncryption(); @@ -1491,7 +1535,7 @@ void tst_QSslSocket::setSslConfiguration_data() QTest::newRow("empty") << QSslConfiguration() << false; QSslConfiguration conf = QSslConfiguration::defaultConfiguration(); QTest::newRow("default") << conf << false; // does not contain test server cert - QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(httpServerCertChainPath()); conf.setCaCertificates(testServerCert); QTest::newRow("set-root-cert") << conf << true; conf.setProtocol(QSsl::SecureProtocols); @@ -1510,7 +1554,7 @@ void tst_QSslSocket::setSslConfiguration() socket->setProtocol(QSsl::SslProtocol::TlsV1_1); #endif this->socket = socket.data(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH(bool, works); QFETCH_GLOBAL(bool, setProxy); if (setProxy && (socket->waitForEncrypted(10000) != works)) @@ -1530,7 +1574,7 @@ void tst_QSslSocket::waitForEncrypted() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) @@ -1549,7 +1593,7 @@ void tst_QSslSocket::waitForEncryptedMinusOne() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(-1)) @@ -1565,7 +1609,7 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QFETCH_GLOBAL(bool, setProxy); @@ -1597,7 +1641,7 @@ void tst_QSslSocket::addDefaultCaCertificate() // Reset the global CA chain QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates()); - QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(httpServerCertChainPath()); QCOMPARE(flukeCerts.size(), 1); QList<QSslCertificate> globalCerts = QSslSocket::defaultCaCertificates(); QVERIFY(!globalCerts.contains(flukeCerts.first())); @@ -1946,7 +1990,7 @@ public slots: QTestEventLoop::instance().exitLoop(); } void waitSomeMore(QSslSocket *socket) { - QTime t; + QElapsedTimer t; t.start(); while (!socket->encryptedBytesAvailable()) { QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 250); @@ -1968,7 +2012,7 @@ void tst_QSslSocket::setReadBufferSize_task_250027() QSslSocketPtr socket = newSocket(); socket->setReadBufferSize(1000); // limit to 1 kb/sec socket->ignoreSslErrors(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); socket->ignoreSslErrors(); QVERIFY2(socket->waitForConnected(10*1000), qPrintable(socket->errorString())); if (setProxy && !socket->waitForEncrypted(10*1000)) @@ -1981,7 +2025,7 @@ void tst_QSslSocket::setReadBufferSize_task_250027() // provoke a response by sending a request socket->write("GET /qtest/fluke.gif HTTP/1.0\n"); // this file is 27 KB socket->write("Host: "); - socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write(QtNetworkSettings::httpServerName().toLocal8Bit().constData()); socket->write("\n"); socket->write("Connection: close\n"); socket->write("\n"); @@ -2232,7 +2276,7 @@ void tst_QSslSocket::verifyMode() socket.setPeerVerifyMode(QSslSocket::VerifyPeer); QCOMPARE(socket.peerVerifyMode(), QSslSocket::VerifyPeer); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); if (socket.waitForEncrypted()) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -2271,7 +2315,7 @@ void tst_QSslSocket::verifyDepth() void tst_QSslSocket::disconnectFromHostWhenConnecting() { QSslSocketPtr socket = newSocket(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); socket->ignoreSslErrors(); socket->write("XXXX LOGOUT\r\n"); QAbstractSocket::SocketState state = socket->state(); @@ -2300,7 +2344,7 @@ void tst_QSslSocket::disconnectFromHostWhenConnecting() void tst_QSslSocket::disconnectFromHostWhenConnected() { QSslSocketPtr socket = newSocket(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket->connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); socket->ignoreSslErrors(); if (!socket->waitForEncrypted(5000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -2387,13 +2431,13 @@ void tst_QSslSocket::resetProxy() // make sure the connection works, and then set a nonsense proxy, and then // make sure it does not work anymore QSslSocket socket; - socket.addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem"); + socket.addCaCertificates(httpServerCertChainPath()); socket.setProxy(goodProxy); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString())); socket.abort(); socket.setProxy(badProxy); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY(! socket.waitForConnected(10000)); // don't forget to login @@ -2406,13 +2450,13 @@ void tst_QSslSocket::resetProxy() // set the nonsense proxy and make sure the connection does not work, // and then set the right proxy and make sure it works QSslSocket socket2; - socket2.addCaCertificates(testDataDir + "certs/qt-test-server-cacert.pem"); + socket2.addCaCertificates(httpServerCertChainPath()); socket2.setProxy(badProxy); - socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket2.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY(! socket2.waitForConnected(10000)); socket2.abort(); socket2.setProxy(goodProxy); - socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket2.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QVERIFY2(socket2.waitForConnected(10000), qPrintable(socket.errorString())); #endif // QT_NO_NETWORKPROXY } @@ -2425,7 +2469,7 @@ void tst_QSslSocket::ignoreSslErrorsList_data() // construct the list of errors that we will get with the SSL handshake and that we will ignore QList<QSslError> expectedSslErrors; // fromPath gives us a list of certs, but it actually only contains one - QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> certs = QSslCertificate::fromPath(httpServerCertChainPath()); QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0)); QSslError wrongError(FLUKE_CERTIFICATE_ERROR); @@ -2456,7 +2500,7 @@ void tst_QSslSocket::ignoreSslErrorsList() QFETCH(int, expectedSslErrorSignalCount); QSignalSpy sslErrorsSpy(&socket, SIGNAL(error(QAbstractSocket::SocketError))); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); bool expectEncryptionSuccess = (expectedSslErrorSignalCount == 0); if (socket.waitForEncrypted(10000) != expectEncryptionSuccess) @@ -2487,7 +2531,7 @@ void tst_QSslSocket::ignoreSslErrorsListWithSlot() this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorListSlot(QList<QSslError>))); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH(int, expectedSslErrorSignalCount); bool expectEncryptionSuccess = (expectedSslErrorSignalCount == 0); @@ -2529,14 +2573,14 @@ void tst_QSslSocket::readFromClosedSocket() socket->setProtocol(QSsl::SslProtocol::TlsV1_1); #endif socket->ignoreSslErrors(); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); socket->ignoreSslErrors(); socket->waitForConnected(); socket->waitForEncrypted(); // provoke a response by sending a request socket->write("GET /qtest/fluke.gif HTTP/1.1\n"); socket->write("Host: "); - socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write(QtNetworkSettings::httpServerName().toLocal8Bit().constData()); socket->write("\n"); socket->write("\n"); socket->waitForBytesWritten(); @@ -2560,7 +2604,7 @@ void tst_QSslSocket::writeBigChunk() this->socket = socket.data(); connect(this->socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QByteArray data; data.resize(1024*1024*10); // 10 MB @@ -2720,7 +2764,9 @@ void tst_QSslSocket::resume_data() QTest::newRow("DoNotIgnoreErrors") << false << QList<QSslError>() << false; QTest::newRow("ignoreAllErrors") << true << QList<QSslError>() << true; - QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "certs/qt-test-server-cacert.pem"); + // Note, httpServerCertChainPath() it's ... because we use the same certificate on + // different services. We'll be actually connecting to IMAP server. + QList<QSslCertificate> certs = QSslCertificate::fromPath(httpServerCertChainPath()); QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0)); QSslError wrongError(FLUKE_CERTIFICATE_ERROR); errorsList.append(wrongError); @@ -2753,7 +2799,7 @@ void tst_QSslSocket::resume() this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 993); + socket.connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993); QTestEventLoop::instance().enterLoop(10); QFETCH_GLOBAL(bool, setProxy); if (setProxy && QTestEventLoop::instance().timeout()) @@ -3256,14 +3302,14 @@ void tst_QSslSocket::verifyClientCertificate_data() void tst_QSslSocket::verifyClientCertificate() { -#ifdef QT_SECURETRANSPORT +#if QT_CONFIG(securetransport) // We run both client and server on the same machine, // this means, client can update keychain with client's certificates, // and server later will use the same certificates from the same // keychain thus making tests fail (wrong number of certificates, // success instead of failure etc.). QSKIP("This test can not work with Secure Transport"); -#endif +#endif // QT_CONFIG(securetransport) #ifdef Q_OS_WINRT QSKIP("Server-side encryption is not implemented on WinRT."); #endif @@ -3345,7 +3391,7 @@ void tst_QSslSocket::verifyClientCertificate() void tst_QSslSocket::readBufferMaxSize() { -#if defined(QT_SECURETRANSPORT) || QT_CONFIG(schannel) +#if QT_CONFIG(securetransport) || QT_CONFIG(schannel) // QTBUG-55170: // SecureTransport back-end was ignoring read-buffer // size limit, resulting (potentially) in a constantly @@ -3402,7 +3448,7 @@ void tst_QSslSocket::readBufferMaxSize() QCOMPARE(client->bytesAvailable() + readSoFar, message.size()); #else // Not needed, QSslSocket works correctly with other back-ends. -#endif +#endif // QT_CONFIG(securetransport) || QT_CONFIG(schannel) } void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, as it has some side effects @@ -3419,7 +3465,7 @@ void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, socket = client.data(); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); - socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QFETCH_GLOBAL(bool, setProxy); if (setProxy && socket->waitForEncrypted(4000)) QSKIP("Skipping flaky test - See QTBUG-29941"); @@ -4118,7 +4164,7 @@ void tst_QSslSocket::forwardReadChannelFinished() }); connect(&socket, &QSslSocket::readChannelFinished, &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); - socket.connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443); + socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); enterLoop(10); QVERIFY(readChannelFinishedSpy.count()); } diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro index 05755ff606..8585a3c861 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro @@ -17,3 +17,9 @@ win32 { DEFINES += SRCDIR=\\\"$$PWD/\\\" requires(qtConfig(private_tests)) + +# DOCKERTODO: linux, docker is disabled on macOS/Windows. +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = squid danted +} diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp index 25c2701f69..4199c0f465 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp @@ -102,7 +102,15 @@ void tst_QSslSocket_onDemandCertificates_member::initTestCase_data() void tst_QSslSocket_onDemandCertificates_member::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1081)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif // QT_TEST_SERVER } void tst_QSslSocket_onDemandCertificates_member::init() @@ -110,28 +118,29 @@ void tst_QSslSocket_onDemandCertificates_member::init() QFETCH_GLOBAL(bool, setProxy); if (setProxy) { QFETCH_GLOBAL(int, proxyType); - QString testServer = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + const auto socksAddr = QtNetworkSettings::socksProxyServerIp().toString(); + const auto squidAddr = QtNetworkSettings::httpProxyServerIp().toString(); QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro index c345d7379f..158ecbee37 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro @@ -16,3 +16,9 @@ win32 { DEFINES += SRCDIR=\\\"$$PWD/\\\" requires(qtConfig(private_tests)) + +#DOCKERTODO Linux, docker is disabled on macOS and Windows. +linux { + CONFIG += unsupported/testserver + QT_TEST_SERVER_LIST = squid danted +} diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp index 503edc0bff..671a21b1c2 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/tst_qsslsocket_onDemandCertificates_static.cpp @@ -98,7 +98,15 @@ void tst_QSslSocket_onDemandCertificates_static::initTestCase_data() void tst_QSslSocket_onDemandCertificates_static::initTestCase() { +#ifdef QT_TEST_SERVER + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1081)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); +#else QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif // QT_TEST_SERVER } void tst_QSslSocket_onDemandCertificates_static::init() @@ -106,28 +114,30 @@ void tst_QSslSocket_onDemandCertificates_static::init() QFETCH_GLOBAL(bool, setProxy); if (setProxy) { QFETCH_GLOBAL(int, proxyType); - QString testServer = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); + const auto socksAddr = QtNetworkSettings::socksProxyServerIp().toString(); + const auto squidAddr = QtNetworkSettings::httpProxyServerIp().toString(); + QNetworkProxy proxy; switch (proxyType) { case Socks5Proxy: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1080); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1080); break; case Socks5Proxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, testServer, 1081); + proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socksAddr, 1081); break; case HttpProxy | NoAuth: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3128); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3128); break; case HttpProxy | AuthBasic: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3129); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3129); break; case HttpProxy | AuthNtlm: - proxy = QNetworkProxy(QNetworkProxy::HttpProxy, testServer, 3130); + proxy = QNetworkProxy(QNetworkProxy::HttpProxy, squidAddr, 3130); break; } QNetworkProxy::setApplicationProxy(proxy); diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index b7b5b505a0..8a38d0f517 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -33,6 +33,7 @@ #include <qpa/qplatformintegration.h> #include <QtWidgets/QApplication> #include <QtOpenGL/QtOpenGL> +#include <qelapsedtimer.h> #include "tst_qglthreads.h" #ifndef QT_OPENGL_ES_2 @@ -74,9 +75,9 @@ public: } void run() { - QTime time; - time.start(); - while (time.elapsed() < RUNNING_TIME) { + QElapsedTimer timer; + timer.start(); + while (timer.elapsed() < RUNNING_TIME) { lock(); waitForReadyToSwap(); @@ -291,11 +292,11 @@ public: } void run() { - QTime time; - time.start(); + QElapsedTimer timer; + timer.start(); failure = false; - while (time.elapsed() < RUNNING_TIME && !failure) { + while (timer.elapsed() < RUNNING_TIME && !failure) { m_widget->makeCurrent(); @@ -466,13 +467,13 @@ public: public slots: void draw() { bool beginFailed = false; - QTime time; - time.start(); + QElapsedTimer timer; + timer.start(); int rotAngle = 10; device->prepareDevice(); QPaintDevice *paintDevice = device->realPaintDevice(); QSize s(paintDevice->width(), paintDevice->height()); - while (time.elapsed() < RUNNING_TIME) { + while (timer.elapsed() < RUNNING_TIME) { QPainter p; if (!p.begin(paintDevice)) { beginFailed = true; diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index b2b45bb237..de15f4c62d 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -842,7 +842,7 @@ void tst_Compiler::cxx11_constexpr() static constexpr QBasicAtomicInt atomic = Q_BASIC_ATOMIC_INITIALIZER(1); static constexpr int i = constexprValue(); QCOMPARE(i, constexprValue()); - QCOMPARE(atomic.load(), 1); + QCOMPARE(atomic.loadRelaxed(), 1); #endif } diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index dc353d2090..1b125d8825 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <QtNetwork/QtNetwork> #include <QtCore/QDateTime> +#include <QtCore/QElapsedTimer> #include <QtCore/QTextStream> #include <QtCore/QRandomGenerator> #include <QtCore/QStandardPaths> @@ -195,7 +196,7 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) #ifndef QT_NO_SSL QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket); #endif - QTime timer; + QElapsedTimer timer; timer.start(); int t = timeout; forever { @@ -421,7 +422,7 @@ void tst_NetworkSelfTest::serverReachability() QTcpSocket socket; socket.connectToHost(QtNetworkSettings::serverName(), 12346); - QTime timer; + QElapsedTimer timer; timer.start(); socket.waitForConnected(10000); QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong"); diff --git a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp index fc979bce2d..c8698242d5 100644 --- a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp +++ b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp @@ -80,13 +80,9 @@ qint64 DynamicTreeModel::findParentId(qint64 searchId) const if (searchId <= 0) return -1; - QHashIterator<qint64, QList<QList<qint64> > > i(m_childItems); - while (i.hasNext()) { - i.next(); - QListIterator<QList<qint64> > j(i.value()); - while (j.hasNext()) { - QList<qint64> l = j.next(); - if (l.contains(searchId)) + for (auto i = m_childItems.cbegin(), end = m_childItems.cend(); i != end; ++i) { + for (const auto &list : i.value()) { + if (list.contains(searchId)) return i.key(); } } @@ -163,13 +159,12 @@ ModelChangeCommand::ModelChangeCommand(DynamicTreeModel *model, QObject *parent) { } -QModelIndex ModelChangeCommand::findIndex(QList<int> rows) +QModelIndex ModelChangeCommand::findIndex(const QList<int> &rows) const { const int col = 0; QModelIndex parent = QModelIndex(); - QListIterator<int> i(rows); - while (i.hasNext()) { - parent = m_model->index(i.next(), col, parent); + for (int row : rows) { + parent = m_model->index(row, col, parent); if (!parent.isValid()) qFatal("%s: parent must be valid", Q_FUNC_INFO); } diff --git a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h index 709751dd27..0807ffbe94 100644 --- a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h +++ b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h @@ -97,7 +97,7 @@ public: m_rowNumbers = rowNumbers; } - QModelIndex findIndex(QList<int> rows); + QModelIndex findIndex(const QList<int> &rows) const; void setStartRow(int row) { diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 3587c38e76..6f3740a24f 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -11,5 +11,6 @@ win32 { !winrt { QT += windowsuiautomation_support-private } - LIBS += -luuid -loleacc -loleaut32 -lole32 + LIBS += -loleacc -loleaut32 + QMAKE_USE += ole32 uuid } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index bc45487599..7d7fa6403b 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -2580,6 +2580,7 @@ void tst_QAccessibility::dialogButtonBoxTest() case QDialogButtonBox::GnomeLayout: case QDialogButtonBox::KdeLayout: case QDialogButtonBox::MacLayout: + case QDialogButtonBox::AndroidLayout: expectedOrder << QDialogButtonBox::tr("Help") << QDialogButtonBox::tr("Reset") << QDialogButtonBox::tr("OK"); diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp index 0d656e223c..e09d304ff3 100644 --- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp @@ -85,7 +85,7 @@ class RaceThread : public QThread { Q_OBJECT RaceObject *object; - QTime stopWatch; + QElapsedTimer stopWatch; public: RaceThread() @@ -378,6 +378,10 @@ public: connect(timer, &QTimer::timeout, this, &DeleteReceiverRaceReceiver::onTimeout); timer->start(1); } + ~DeleteReceiverRaceReceiver() + { + delete receiver; + } void onTimeout() { @@ -410,7 +414,7 @@ void tst_QObjectRace::disconnectRace() { enum { ThreadCount = 20, TimeLimit = 3000 }; - QCOMPARE(countedStructObjectsCount.load(), 0u); + QCOMPARE(countedStructObjectsCount.loadRelaxed(), 0u); { QScopedPointer<DisconnectRaceSenderObject> sender(new DisconnectRaceSenderObject()); @@ -428,15 +432,15 @@ void tst_QObjectRace::disconnectRace() for (int i = 0; i < ThreadCount; ++i) { threads[i]->requestInterruption(); - QVERIFY(threads[i]->wait(300)); + QVERIFY(threads[i]->wait()); delete threads[i]; } senderThread->quit(); - QVERIFY(senderThread->wait(300)); + QVERIFY(senderThread->wait()); } - QCOMPARE(countedStructObjectsCount.load(), 0u); + QCOMPARE(countedStructObjectsCount.loadRelaxed(), 0u); { QScopedPointer<DisconnectRaceSenderObject> sender(new DisconnectRaceSenderObject()); @@ -453,16 +457,16 @@ void tst_QObjectRace::disconnectRace() QTest::qWait(TimeLimit); senderThread->requestInterruption(); - QVERIFY(senderThread->wait(300)); + QVERIFY(senderThread->wait()); for (int i = 0; i < ThreadCount; ++i) { threads[i]->quit(); - QVERIFY(threads[i]->wait(300)); + QVERIFY(threads[i]->wait()); delete threads[i]; } } - QCOMPARE(countedStructObjectsCount.load(), 0u); + QCOMPARE(countedStructObjectsCount.loadRelaxed(), 0u); } QTEST_MAIN(tst_QObjectRace) diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index f31a755f9e..8c129adaf3 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -126,9 +126,9 @@ void tst_toolsupport::offsets_data() #ifdef Q_PROCESSOR_X86 // x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in // qglobal.h for more details. - data << 168 << 248; + data << 152 << 224; #else - data << 172 << 248; + data << 156 << 224; #endif } #endif diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index abe4325278..7529bad833 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -1315,7 +1315,9 @@ void tst_QPrinter::pageSize() // Test set/get QPrinter::PaperSize expected = QPrinter::A4; QPrinterInfo info = QPrinterInfo::printerInfo(native.printerName()); - foreach (QPrinter::PaperSize supported, info.supportedPaperSizes()) { + const auto &pageSizes = info.supportedPageSizes(); + for (const auto &pageSize : pageSizes) { + const QPrinter::PaperSize supported = QPrinter::PaperSize(pageSize.id()); if (supported != QPrinter::Custom && supported != native.paperSize()) { expected = supported; break; @@ -1359,7 +1361,9 @@ void tst_QPrinter::paperSize() // Test set/get QPrinter::PaperSize expected = QPrinter::A4; QPrinterInfo info = QPrinterInfo::printerInfo(native.printerName()); - foreach (QPrinter::PaperSize supported, info.supportedPaperSizes()) { + const auto &pageSizes = info.supportedPageSizes(); + for (const auto &pageSize : pageSizes) { + const QPrinter::PaperSize supported = QPrinter::PaperSize(pageSize.id()); if (supported != QPrinter::Custom && supported != native.paperSize()) { expected = supported; break; diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index 92a06cda00..d1b4ed8bcd 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -94,17 +94,16 @@ QString tst_QPrinterInfo::getDefaultPrinterFromSystem() command << "lpstat" << "-d"; QString output = getOutputFromCommand(command); - QRegExp noDefaultReg("[^:]*no .*default"); - int pos = noDefaultReg.indexIn(output); - if (pos >= 0) { + QRegularExpression noDefaultReg("[^:]*no .*default"); + QRegularExpressionMatch match; + match = noDefaultReg.match(output); + if (match.hasMatch()) return QString(); - } - QRegExp defaultReg("default.*: *([a-zA-Z0-9_-]+)"); - defaultReg.indexIn(output); - printer = defaultReg.cap(1); + QRegularExpression defaultReg("default.*: *([a-zA-Z0-9_-]+)"); + match = defaultReg.match(output); + printer = match.captured(1); #endif // Q_OS_UNIX - return printer; } @@ -121,10 +120,12 @@ QStringList tst_QPrinterInfo::getPrintersFromSystem() QString output = getOutputFromCommand(command); QStringList list = output.split(QChar::fromLatin1('\n')); - QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9-_@]+)"); + QRegularExpression reg("^[Pp]rinter ([.a-zA-Z0-9-_@]+)"); + QRegularExpressionMatch match; for (int c = 0; c < list.size(); ++c) { - if (reg.indexIn(list[c]) >= 0) { - QString printer = reg.cap(1); + match = reg.match(list[c]); + if (match.hasMatch()) { + QString printer = match.captured(1); ans << printer; } } @@ -300,8 +301,11 @@ void tst_QPrinterInfo::testConstructors() QCOMPARE(copy1.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes()); QCOMPARE(copy1.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize()); QCOMPARE(copy1.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize()); - QCOMPARE(copy1.supportedPaperSizes(), printers.at(i).supportedPaperSizes()); + QCOMPARE(copy1.supportedPageSizes(), printers.at(i).supportedPageSizes()); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(copy1.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames()); +QT_WARNING_POP QCOMPARE(copy1.supportedResolutions(), printers.at(i).supportedResolutions()); QCOMPARE(copy1.defaultDuplexMode(), printers.at(i).defaultDuplexMode()); QCOMPARE(copy1.supportedDuplexModes(), printers.at(i).supportedDuplexModes()); @@ -321,8 +325,11 @@ void tst_QPrinterInfo::testConstructors() QCOMPARE(copy2.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes()); QCOMPARE(copy2.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize()); QCOMPARE(copy2.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize()); - QCOMPARE(copy2.supportedPaperSizes(), printers.at(i).supportedPaperSizes()); + QCOMPARE(copy2.supportedPageSizes(), printers.at(i).supportedPageSizes()); + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED QCOMPARE(copy2.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames()); + QT_WARNING_POP QCOMPARE(copy2.supportedResolutions(), printers.at(i).supportedResolutions()); QCOMPARE(copy2.defaultDuplexMode(), printers.at(i).defaultDuplexMode()); QCOMPARE(copy2.supportedDuplexModes(), printers.at(i).supportedDuplexModes()); diff --git a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp index 08c6039e37..be0285537e 100644 --- a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp +++ b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp @@ -46,6 +46,7 @@ private slots: void construction(); void moveOperator(); void operators(); + void qtbug_74575(); }; tst_QSqlError::tst_QSqlError() @@ -113,6 +114,7 @@ void tst_QSqlError::construction() QVERIFY(!obj4.isValid()); QCOMPARE(obj4.driverText(), QString()); QCOMPARE(obj4.databaseText(), QString()); + QCOMPARE(obj4.text(), QString()); QCOMPARE(obj4.type(), QSqlError::NoError); QCOMPARE(obj4.number(), -1); QCOMPARE(obj4.nativeErrorCode(), QString()); @@ -180,6 +182,28 @@ void tst_QSqlError::operators() QVERIFY(error1 != error3); } +void tst_QSqlError::qtbug_74575() +{ + const QString driverText(QStringLiteral("drivertext")); + const QString databaseText(QStringLiteral("databasetext")); + const QString databaseTextNewline(QStringLiteral("databasetext\n")); + + QSqlError error1(driverText, databaseText, + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error1.text(), databaseText + QLatin1Char(' ') + driverText); + + QSqlError error2(QString(), databaseText, + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error2.text(), databaseText); + + QSqlError error3(driverText, QString(), + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error3.text(), driverText); + + QSqlError error4(driverText, databaseTextNewline, + QSqlError::UnknownError, QStringLiteral("123")); + QCOMPARE(error4.text(), databaseTextNewline + driverText); +} QTEST_MAIN(tst_QSqlError) #include "tst_qsqlerror.moc" diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp index 09a842eb83..aa2cc05b56 100644 --- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp @@ -345,7 +345,7 @@ void tst_QSqlThread::cleanupTestCase() void tst_QSqlThread::init() { threadFinishedCount = 0; - counter.store(4); + counter.storeRelaxed(4); } void tst_QSqlThread::cleanup() diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index b617151a36..44dd4a74cf 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -32,6 +32,7 @@ #include <QtSql> #include <QtSql/private/qsqltablemodel_p.h> #include <QThread> +#include <QElapsedTimer> const QString test(qTableName("test", __FILE__, QSqlDatabase())), test2(qTableName("test2", __FILE__, QSqlDatabase())), @@ -1804,12 +1805,12 @@ void tst_QSqlTableModel::sqlite_bigTable() QSqlQuery q(db); QVERIFY_SQL( q, exec("create table "+bigtable+"(id int primary key, name varchar)")); QVERIFY_SQL( q, prepare("insert into "+bigtable+"(id, name) values (?, ?)")); - QTime startTime; - startTime.start(); + QElapsedTimer timing; + timing.start(); for (int i = 0; i < 10000; ++i) { q.addBindValue(i); q.addBindValue(QString::number(i)); - if(i%1000 == 0 && startTime.elapsed() > 5000) + if (i % 1000 == 0 && timing.elapsed() > 5000) qDebug() << i << "records written"; QVERIFY_SQL( q, exec()); } diff --git a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp index 60aa350145..b305eee0ec 100644 --- a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp +++ b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp @@ -63,7 +63,7 @@ void tst_QAbstractItemModelTester::stringListModel() model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c"); proxy.setDynamicSortFilter(true); - proxy.setFilterRegExp(QRegExp("[^b]")); + proxy.setFilterRegularExpression(QRegularExpression("[^b]")); } void tst_QAbstractItemModelTester::treeWidgetModel() diff --git a/tests/auto/testlib/selftests/alive/.gitignore b/tests/auto/testlib/selftests/alive/.gitignore deleted file mode 100644 index 561285c5d0..0000000000 --- a/tests/auto/testlib/selftests/alive/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_alive diff --git a/tests/auto/testlib/selftests/alive/alive.pro b/tests/auto/testlib/selftests/alive/alive.pro deleted file mode 100644 index bda0db2282..0000000000 --- a/tests/auto/testlib/selftests/alive/alive.pro +++ /dev/null @@ -1,10 +0,0 @@ -SOURCES += tst_alive.cpp -QT = core testlib - -mac:CONFIG -= app_bundle -CONFIG -= debug_and_release_target - - -TARGET = alive - -include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/alive/qtestalive.cpp b/tests/auto/testlib/selftests/alive/qtestalive.cpp deleted file mode 100644 index 0200f2a563..0000000000 --- a/tests/auto/testlib/selftests/alive/qtestalive.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <qcoreapplication.h> -#include <qcoreevent.h> -#include <qthread.h> - -class QTestAliveEvent: public QEvent -{ -public: - - enum { AliveEventType = QEvent::User + 422 }; - - explicit inline QTestAliveEvent(int aSequenceId) - : QEvent(QEvent::Type(AliveEventType)), seqId(aSequenceId) - {} - inline int sequenceId() const { return seqId; } - -private: - int seqId; -}; - -class QTestAlivePinger: public QObject -{ -public: - QTestAlivePinger(QObject *receiver, QObject *parent = 0); - bool event(QEvent *e); - -protected: - void timerEvent(QTimerEvent *event); - -private: - QObject *rec; - int timerId; - int currentSequenceId; - int lastSequenceId; -}; - -QTestAlivePinger::QTestAlivePinger(QObject *receiver, QObject *parent) - : QObject(parent), rec(receiver), currentSequenceId(0), lastSequenceId(0) -{ - if (!rec) - qFatal("Null receiver object passed to QTestAlivePinger::QTestAlivePinger()"); - timerId = startTimer(850); -} - -bool QTestAlivePinger::event(QEvent *event) -{ - // pong received - if (int(event->type()) == QTestAliveEvent::AliveEventType) { - QTestAliveEvent *e = static_cast<QTestAliveEvent *>(event); - //qDebug("PONG %d received", e->sequenceId()); - // if the events are not delivered in order, we don't care. - if (e->sequenceId() > lastSequenceId) - lastSequenceId = e->sequenceId(); - return true; - } - return QObject::event(event); -} - -void QTestAlivePinger::timerEvent(QTimerEvent *event) -{ - if (event->timerId() != timerId) - return; - - if (lastSequenceId < currentSequenceId - 2) { - qWarning("TEST LAGS %d PINGS behind!", currentSequenceId - lastSequenceId); - } - ++currentSequenceId; - //qDebug("PING %d", currentSequenceId); - QCoreApplication::postEvent(rec, new QTestAliveEvent(currentSequenceId)); -} - -class QTestAlive: public QThread -{ -public: - QTestAlive(QObject *parent = 0); - ~QTestAlive(); - void run(); - - bool event(QEvent *e); - -private: - QTestAlivePinger *pinger; -}; - -QTestAlive::QTestAlive(QObject *parent) - : QThread(parent), pinger(0) -{ -} - -QTestAlive::~QTestAlive() -{ - quit(); - while (isRunning()); -} - -bool QTestAlive::event(QEvent *e) -{ - if (int(e->type()) == QTestAliveEvent::AliveEventType && pinger) { - // ping received, send back the pong - //qDebug("PONG %d", static_cast<QTestAliveEvent *>(e)->sequenceId()); - QCoreApplication::postEvent(pinger, - new QTestAliveEvent(static_cast<QTestAliveEvent *>(e)->sequenceId())); - return true; - } - return QThread::event(e); -} - -void QTestAlive::run() -{ - if (!QCoreApplication::instance()) - qFatal("QTestAlive::run(): Cannot start QTestAlive without a QCoreApplication instance."); - - QTestAlivePinger p(this); - pinger = &p; - exec(); - pinger = 0; -} - - diff --git a/tests/auto/testlib/selftests/alive/tst_alive.cpp b/tests/auto/testlib/selftests/alive/tst_alive.cpp deleted file mode 100644 index eeb77b18c0..0000000000 --- a/tests/auto/testlib/selftests/alive/tst_alive.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <QtTest/QtTest> -#include <QWidget> - -#include "qtestalive.cpp" - -class tst_Alive: public QObject -{ - Q_OBJECT - -private slots: - void alive(); - void addMouseDClick() const; -}; - -void tst_Alive::alive() -{ - QTestAlive a; - a.start(); - - sleep(5); - QCoreApplication::processEvents(); - qDebug("CUT"); - sleep(5); -} - -void tst_Alive::addMouseDClick() const -{ - class DClickListener : public QWidget - { - public: - DClickListener() : isTested(false) - { - } - - bool isTested; - protected: - virtual void mouseDoubleClickEvent(QMouseEvent * event) - { - isTested = true; - QCOMPARE(event->type(), QEvent::MouseButtonDblClick); - } - }; - - DClickListener listener; - - QTestEventList list; - list.addMouseDClick(Qt::LeftButton); - - list.simulate(&listener); - /* Check that we have been called at all. */ - QVERIFY(listener.isTested); -} - -QTEST_MAIN(tst_Alive) -#include "tst_alive.moc" diff --git a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp index 2f6d633e9d..49c08982ad 100644 --- a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp +++ b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp @@ -75,6 +75,17 @@ void tst_Blacklisted::xpass() QVERIFY2(true, "This test should BXPASS"); } +#ifndef Q_OS_WIN +#include <signal.h> +#include <setjmp.h> + +static jmp_buf state; +static void abort_handler(int signal) +{ + longjmp(state, 1); +} +#endif + void tst_Blacklisted::messages() { qWarning("This is a warning that should not appear in silent test output"); @@ -83,7 +94,15 @@ void tst_Blacklisted::messages() qCritical("This is a critical message that should not appear in silent test output"); qInfo("This is an info message that should not appear in silent test output"); QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); - qFatal("This is a fatal error message that should still appear in silent test output"); + +#ifndef Q_OS_WIN + // We're testing qFatal, but we don't want to actually std::abort() ! + auto prior = signal(SIGABRT, abort_handler); + if (setjmp(state)) + signal(SIGABRT, prior); + else +#endif + qFatal("This is a fatal error message that should still appear in silent test output"); } QTEST_MAIN(tst_Blacklisted) diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 8e2c7694a5..467c53088e 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -256,7 +256,7 @@ void tst_Cmptest::compare_boolfuncs() namespace { template <typename T> -T *null() Q_DECL_NOTHROW { return nullptr; } +T *null() noexcept { return nullptr; } } void tst_Cmptest::compare_to_nullptr() diff --git a/tests/auto/testlib/selftests/expected_crashes_5.txt b/tests/auto/testlib/selftests/expected_crashes_5.txt new file mode 100644 index 0000000000..088b9c5324 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_crashes_5.txt @@ -0,0 +1,5 @@ +********* Start testing of tst_Crashes ********* +Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +PASS : tst_Crashes::initTestCase() +QFATAL : tst_Crashes::crash() Received signal 11 + Function time: ms Total time: ms diff --git a/tests/auto/testlib/selftests/expected_float.lightxml b/tests/auto/testlib/selftests/expected_float.lightxml index 458f2277e6..5f5114bb2e 100644 --- a/tests/auto/testlib/selftests/expected_float.lightxml +++ b/tests/auto/testlib/selftests/expected_float.lightxml @@ -8,15 +8,15 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="doubleComparisons"> -<Incident type="pass" file="" line="0"> - <DataTag><![CDATA[should PASS 1]]></DataTag> -</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 1]]></DataTag> <Description><![CDATA[Compared doubles are not the same (fuzzy compare) Actual (operandLeft) : 1 Expected (operandRight): 3]]></Description> </Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 1]]></DataTag> +</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared doubles are not the same (fuzzy compare) @@ -428,21 +428,24 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="float16Comparisons"> -<Incident type="pass" file="" line="0"> - <DataTag><![CDATA[should SUCCEED 1]]></DataTag> -</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 1]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 1 Expected (operandRight): 3]]></Description> </Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 1]]></DataTag> +</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 0.0001 Expected (operandRight): 0.0003]]></Description> </Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 2]]></DataTag> +</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 3]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) @@ -450,7 +453,187 @@ Expected (operandRight): 99]]></Description> </Incident> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[should SUCCEED 2]]></DataTag> + <DataTag><![CDATA[should PASS 3]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 4]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.93e-05 + Expected (operandRight): 5.87e-05]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 4]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 5]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.94e+04 + Expected (operandRight): 5.88e+04]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS: NaN == NaN]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: NaN != 0]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 0]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 0 != NaN]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: NaN != 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 1]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 1 != NaN]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS: inf == inf]]></DataTag> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS: -inf == -inf]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != nan]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: nan != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != nan]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: nan != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != 0]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 0]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 0 != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != 0]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 0]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 0 != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 1]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 1 != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 1]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 1 != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != -max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: max != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -max != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != -max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): -6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: max != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -max != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): -inf]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> diff --git a/tests/auto/testlib/selftests/expected_float.tap b/tests/auto/testlib/selftests/expected_float.tap index 277dd2b1d4..9da51b93b3 100644 --- a/tests/auto/testlib/selftests/expected_float.tap +++ b/tests/auto/testlib/selftests/expected_float.tap @@ -1,8 +1,7 @@ TAP version 13 # tst_float ok 1 - initTestCase() -ok 2 - doubleComparisons(should PASS 1) -not ok 3 - doubleComparisons(should FAIL 1) +not ok 2 - doubleComparisons(should FAIL 1) --- type: QCOMPARE message: Compared doubles are not the same (fuzzy compare) @@ -10,10 +9,11 @@ not ok 3 - doubleComparisons(should FAIL 1) found: 1 (operandLeft) expected: 3 (operandRight) actual: 1 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... +ok 3 - doubleComparisons(should PASS 1) not ok 4 - doubleComparisons(should FAIL 2) --- type: QCOMPARE @@ -22,9 +22,9 @@ not ok 4 - doubleComparisons(should FAIL 2) found: 1e-07 (operandLeft) expected: 3e-07 (operandRight) actual: 1e-07 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... ok 5 - doubleComparisons(should PASS 2) not ok 6 - doubleComparisons(should FAIL 3) @@ -35,9 +35,9 @@ not ok 6 - doubleComparisons(should FAIL 3) found: 999999999999 (operandLeft) expected: 999999999998 (operandRight) actual: 999999999999 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... ok 7 - doubleComparisons(should PASS 3) not ok 8 - doubleComparisons(should FAIL 4) @@ -48,9 +48,9 @@ not ok 8 - doubleComparisons(should FAIL 4) found: 9.99999999999e-311 (operandLeft) expected: 9.99999999997e-311 (operandRight) actual: 9.99999999999e-311 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... ok 9 - doubleComparisons(should PASS 4) not ok 10 - doubleComparisons(should FAIL 5) @@ -61,9 +61,9 @@ not ok 10 - doubleComparisons(should FAIL 5) found: 9.99999999999e+306 (operandLeft) expected: 9.99999999997e+306 (operandRight) actual: 9.99999999999e+306 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... ok 11 - doubleComparisons(should PASS: NaN == NaN) not ok 12 - doubleComparisons(should FAIL: NaN != 0) @@ -74,9 +74,9 @@ not ok 12 - doubleComparisons(should FAIL: NaN != 0) found: nan (operandLeft) expected: 0 (operandRight) actual: nan (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 13 - doubleComparisons(should FAIL: 0 != NaN) --- @@ -86,9 +86,9 @@ not ok 13 - doubleComparisons(should FAIL: 0 != NaN) found: 0 (operandLeft) expected: nan (operandRight) actual: 0 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 14 - doubleComparisons(should FAIL: NaN != 1) --- @@ -98,9 +98,9 @@ not ok 14 - doubleComparisons(should FAIL: NaN != 1) found: nan (operandLeft) expected: 1 (operandRight) actual: nan (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 15 - doubleComparisons(should FAIL: 1 != NaN) --- @@ -110,9 +110,9 @@ not ok 15 - doubleComparisons(should FAIL: 1 != NaN) found: 1 (operandLeft) expected: nan (operandRight) actual: 1 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... ok 16 - doubleComparisons(should PASS: inf == inf) ok 17 - doubleComparisons(should PASS: -inf == -inf) @@ -124,9 +124,9 @@ not ok 18 - doubleComparisons(should FAIL: inf != -inf) found: inf (operandLeft) expected: -inf (operandRight) actual: inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 19 - doubleComparisons(should FAIL: -inf != inf) --- @@ -136,9 +136,9 @@ not ok 19 - doubleComparisons(should FAIL: -inf != inf) found: -inf (operandLeft) expected: inf (operandRight) actual: -inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 20 - doubleComparisons(should FAIL: inf != nan) --- @@ -148,9 +148,9 @@ not ok 20 - doubleComparisons(should FAIL: inf != nan) found: inf (operandLeft) expected: nan (operandRight) actual: inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 21 - doubleComparisons(should FAIL: nan != inf) --- @@ -160,9 +160,9 @@ not ok 21 - doubleComparisons(should FAIL: nan != inf) found: nan (operandLeft) expected: inf (operandRight) actual: nan (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 22 - doubleComparisons(should FAIL: -inf != nan) --- @@ -172,9 +172,9 @@ not ok 22 - doubleComparisons(should FAIL: -inf != nan) found: -inf (operandLeft) expected: nan (operandRight) actual: -inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 23 - doubleComparisons(should FAIL: nan != -inf) --- @@ -184,9 +184,9 @@ not ok 23 - doubleComparisons(should FAIL: nan != -inf) found: nan (operandLeft) expected: -inf (operandRight) actual: nan (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 24 - doubleComparisons(should FAIL: inf != 0) --- @@ -196,9 +196,9 @@ not ok 24 - doubleComparisons(should FAIL: inf != 0) found: inf (operandLeft) expected: 0 (operandRight) actual: inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 25 - doubleComparisons(should FAIL: 0 != inf) --- @@ -208,9 +208,9 @@ not ok 25 - doubleComparisons(should FAIL: 0 != inf) found: 0 (operandLeft) expected: inf (operandRight) actual: 0 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 26 - doubleComparisons(should FAIL: -inf != 0) --- @@ -220,9 +220,9 @@ not ok 26 - doubleComparisons(should FAIL: -inf != 0) found: -inf (operandLeft) expected: 0 (operandRight) actual: -inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 27 - doubleComparisons(should FAIL: 0 != -inf) --- @@ -232,9 +232,9 @@ not ok 27 - doubleComparisons(should FAIL: 0 != -inf) found: 0 (operandLeft) expected: -inf (operandRight) actual: 0 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 28 - doubleComparisons(should FAIL: inf != 1) --- @@ -244,9 +244,9 @@ not ok 28 - doubleComparisons(should FAIL: inf != 1) found: inf (operandLeft) expected: 1 (operandRight) actual: inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 29 - doubleComparisons(should FAIL: 1 != inf) --- @@ -256,9 +256,9 @@ not ok 29 - doubleComparisons(should FAIL: 1 != inf) found: 1 (operandLeft) expected: inf (operandRight) actual: 1 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 30 - doubleComparisons(should FAIL: -inf != 1) --- @@ -268,9 +268,9 @@ not ok 30 - doubleComparisons(should FAIL: -inf != 1) found: -inf (operandLeft) expected: 1 (operandRight) actual: -inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 31 - doubleComparisons(should FAIL: 1 != -inf) --- @@ -280,9 +280,9 @@ not ok 31 - doubleComparisons(should FAIL: 1 != -inf) found: 1 (operandLeft) expected: -inf (operandRight) actual: 1 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 32 - doubleComparisons(should FAIL: inf != max) --- @@ -292,9 +292,9 @@ not ok 32 - doubleComparisons(should FAIL: inf != max) found: inf (operandLeft) expected: 1.79769313486e+308 (operandRight) actual: inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 33 - doubleComparisons(should FAIL: inf != -max) --- @@ -304,9 +304,9 @@ not ok 33 - doubleComparisons(should FAIL: inf != -max) found: inf (operandLeft) expected: -1.79769313486e+308 (operandRight) actual: inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 34 - doubleComparisons(should FAIL: max != inf) --- @@ -316,9 +316,9 @@ not ok 34 - doubleComparisons(should FAIL: max != inf) found: 1.79769313486e+308 (operandLeft) expected: inf (operandRight) actual: 1.79769313486e+308 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 35 - doubleComparisons(should FAIL: -max != inf) --- @@ -328,9 +328,9 @@ not ok 35 - doubleComparisons(should FAIL: -max != inf) found: -1.79769313486e+308 (operandLeft) expected: inf (operandRight) actual: -1.79769313486e+308 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 36 - doubleComparisons(should FAIL: -inf != max) --- @@ -340,9 +340,9 @@ not ok 36 - doubleComparisons(should FAIL: -inf != max) found: -inf (operandLeft) expected: 1.79769313486e+308 (operandRight) actual: -inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 37 - doubleComparisons(should FAIL: -inf != -max) --- @@ -352,9 +352,9 @@ not ok 37 - doubleComparisons(should FAIL: -inf != -max) found: -inf (operandLeft) expected: -1.79769313486e+308 (operandRight) actual: -inf (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 38 - doubleComparisons(should FAIL: max != -inf) --- @@ -364,9 +364,9 @@ not ok 38 - doubleComparisons(should FAIL: max != -inf) found: 1.79769313486e+308 (operandLeft) expected: -inf (operandRight) actual: 1.79769313486e+308 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 39 - doubleComparisons(should FAIL: -max != -inf) --- @@ -376,9 +376,9 @@ not ok 39 - doubleComparisons(should FAIL: -max != -inf) found: -1.79769313486e+308 (operandLeft) expected: -inf (operandRight) actual: -1.79769313486e+308 (operandLeft) - at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:54) + at: tst_float::doubleComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:103) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 54 + line: 103 ... not ok 40 - floatComparisons(should FAIL 1) --- @@ -388,9 +388,9 @@ not ok 40 - floatComparisons(should FAIL 1) found: 1 (operandLeft) expected: 3 (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... ok 41 - floatComparisons(should PASS 1) not ok 42 - floatComparisons(should FAIL 2) @@ -401,9 +401,9 @@ not ok 42 - floatComparisons(should FAIL 2) found: 1e-07 (operandLeft) expected: 3e-07 (operandRight) actual: 1e-07 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... ok 43 - floatComparisons(should PASS 2) not ok 44 - floatComparisons(should FAIL 3) @@ -414,9 +414,9 @@ not ok 44 - floatComparisons(should FAIL 3) found: 99999 (operandLeft) expected: 99998 (operandRight) actual: 99999 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... ok 45 - floatComparisons(should PASS 3) not ok 46 - floatComparisons(should FAIL 4) @@ -427,9 +427,9 @@ not ok 46 - floatComparisons(should FAIL 4) found: 9.9999e-40 (operandLeft) expected: 9.99971e-40 (operandRight) actual: 9.9999e-40 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... ok 47 - floatComparisons(should PASS 4) not ok 48 - floatComparisons(should FAIL 5) @@ -440,9 +440,9 @@ not ok 48 - floatComparisons(should FAIL 5) found: 9.9999e+37 (operandLeft) expected: 9.9997e+37 (operandRight) actual: 9.9999e+37 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... ok 49 - floatComparisons(should PASS: NaN == NaN) not ok 50 - floatComparisons(should FAIL: NaN != 0) @@ -453,9 +453,9 @@ not ok 50 - floatComparisons(should FAIL: NaN != 0) found: nan (operandLeft) expected: 0 (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 51 - floatComparisons(should FAIL: 0 != NaN) --- @@ -465,9 +465,9 @@ not ok 51 - floatComparisons(should FAIL: 0 != NaN) found: 0 (operandLeft) expected: nan (operandRight) actual: 0 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 52 - floatComparisons(should FAIL: NaN != 1) --- @@ -477,9 +477,9 @@ not ok 52 - floatComparisons(should FAIL: NaN != 1) found: nan (operandLeft) expected: 1 (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 53 - floatComparisons(should FAIL: 1 != NaN) --- @@ -489,9 +489,9 @@ not ok 53 - floatComparisons(should FAIL: 1 != NaN) found: 1 (operandLeft) expected: nan (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... ok 54 - floatComparisons(should PASS: inf == inf) ok 55 - floatComparisons(should PASS: -inf == -inf) @@ -503,9 +503,9 @@ not ok 56 - floatComparisons(should FAIL: inf != -inf) found: inf (operandLeft) expected: -inf (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 57 - floatComparisons(should FAIL: -inf != inf) --- @@ -515,9 +515,9 @@ not ok 57 - floatComparisons(should FAIL: -inf != inf) found: -inf (operandLeft) expected: inf (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 58 - floatComparisons(should FAIL: inf != nan) --- @@ -527,9 +527,9 @@ not ok 58 - floatComparisons(should FAIL: inf != nan) found: inf (operandLeft) expected: nan (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 59 - floatComparisons(should FAIL: nan != inf) --- @@ -539,9 +539,9 @@ not ok 59 - floatComparisons(should FAIL: nan != inf) found: nan (operandLeft) expected: inf (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 60 - floatComparisons(should FAIL: -inf != nan) --- @@ -551,9 +551,9 @@ not ok 60 - floatComparisons(should FAIL: -inf != nan) found: -inf (operandLeft) expected: nan (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 61 - floatComparisons(should FAIL: nan != -inf) --- @@ -563,9 +563,9 @@ not ok 61 - floatComparisons(should FAIL: nan != -inf) found: nan (operandLeft) expected: -inf (operandRight) actual: nan (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 62 - floatComparisons(should FAIL: inf != 0) --- @@ -575,9 +575,9 @@ not ok 62 - floatComparisons(should FAIL: inf != 0) found: inf (operandLeft) expected: 0 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 63 - floatComparisons(should FAIL: 0 != inf) --- @@ -587,9 +587,9 @@ not ok 63 - floatComparisons(should FAIL: 0 != inf) found: 0 (operandLeft) expected: inf (operandRight) actual: 0 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 64 - floatComparisons(should FAIL: -inf != 0) --- @@ -599,9 +599,9 @@ not ok 64 - floatComparisons(should FAIL: -inf != 0) found: -inf (operandLeft) expected: 0 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 65 - floatComparisons(should FAIL: 0 != -inf) --- @@ -611,9 +611,9 @@ not ok 65 - floatComparisons(should FAIL: 0 != -inf) found: 0 (operandLeft) expected: -inf (operandRight) actual: 0 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 66 - floatComparisons(should FAIL: inf != 1) --- @@ -623,9 +623,9 @@ not ok 66 - floatComparisons(should FAIL: inf != 1) found: inf (operandLeft) expected: 1 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 67 - floatComparisons(should FAIL: 1 != inf) --- @@ -635,9 +635,9 @@ not ok 67 - floatComparisons(should FAIL: 1 != inf) found: 1 (operandLeft) expected: inf (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 68 - floatComparisons(should FAIL: -inf != 1) --- @@ -647,9 +647,9 @@ not ok 68 - floatComparisons(should FAIL: -inf != 1) found: -inf (operandLeft) expected: 1 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 69 - floatComparisons(should FAIL: 1 != -inf) --- @@ -659,9 +659,9 @@ not ok 69 - floatComparisons(should FAIL: 1 != -inf) found: 1 (operandLeft) expected: -inf (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 70 - floatComparisons(should FAIL: inf != max) --- @@ -671,9 +671,9 @@ not ok 70 - floatComparisons(should FAIL: inf != max) found: inf (operandLeft) expected: 3.40282e+38 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 71 - floatComparisons(should FAIL: inf != -max) --- @@ -683,9 +683,9 @@ not ok 71 - floatComparisons(should FAIL: inf != -max) found: inf (operandLeft) expected: -3.40282e+38 (operandRight) actual: inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 72 - floatComparisons(should FAIL: max != inf) --- @@ -695,9 +695,9 @@ not ok 72 - floatComparisons(should FAIL: max != inf) found: 3.40282e+38 (operandLeft) expected: inf (operandRight) actual: 3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 73 - floatComparisons(should FAIL: -max != inf) --- @@ -707,9 +707,9 @@ not ok 73 - floatComparisons(should FAIL: -max != inf) found: -3.40282e+38 (operandLeft) expected: inf (operandRight) actual: -3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 74 - floatComparisons(should FAIL: -inf != max) --- @@ -719,9 +719,9 @@ not ok 74 - floatComparisons(should FAIL: -inf != max) found: -inf (operandLeft) expected: 3.40282e+38 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 75 - floatComparisons(should FAIL: -inf != -max) --- @@ -731,9 +731,9 @@ not ok 75 - floatComparisons(should FAIL: -inf != -max) found: -inf (operandLeft) expected: -3.40282e+38 (operandRight) actual: -inf (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 76 - floatComparisons(should FAIL: max != -inf) --- @@ -743,9 +743,9 @@ not ok 76 - floatComparisons(should FAIL: max != -inf) found: 3.40282e+38 (operandLeft) expected: -inf (operandRight) actual: 3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... not ok 77 - floatComparisons(should FAIL: -max != -inf) --- @@ -755,12 +755,11 @@ not ok 77 - floatComparisons(should FAIL: -max != -inf) found: -3.40282e+38 (operandLeft) expected: -inf (operandRight) actual: -3.40282e+38 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:127) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:137) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 127 + line: 137 ... -ok 78 - float16Comparisons(should SUCCEED 1) -not ok 79 - float16Comparisons(should FAIL 1) +not ok 78 - float16Comparisons(should FAIL 1) --- type: QCOMPARE message: Compared qfloat16s are not the same (fuzzy compare) @@ -768,10 +767,11 @@ not ok 79 - float16Comparisons(should FAIL 1) found: 1 (operandLeft) expected: 3 (operandRight) actual: 1 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:200) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 200 + line: 171 ... +ok 79 - float16Comparisons(should PASS 1) not ok 80 - float16Comparisons(should FAIL 2) --- type: QCOMPARE @@ -780,11 +780,12 @@ not ok 80 - float16Comparisons(should FAIL 2) found: 0.0001 (operandLeft) expected: 0.0003 (operandRight) actual: 0.0001 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:200) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 200 + line: 171 ... -not ok 81 - float16Comparisons(should FAIL 3) +ok 81 - float16Comparisons(should PASS 2) +not ok 82 - float16Comparisons(should FAIL 3) --- type: QCOMPARE message: Compared qfloat16s are not the same (fuzzy compare) @@ -792,12 +793,352 @@ not ok 81 - float16Comparisons(should FAIL 3) found: 98 (operandLeft) expected: 99 (operandRight) actual: 98 (operandLeft) - at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:200) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 200 + line: 171 ... -ok 82 - float16Comparisons(should SUCCEED 2) -not ok 83 - compareFloatTests(1e0) +ok 83 - float16Comparisons(should PASS 3) +not ok 84 - float16Comparisons(should FAIL 4) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 5.87e-05 (operandRight) + found: 5.93e-05 (operandLeft) + expected: 5.87e-05 (operandRight) + actual: 5.93e-05 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +ok 85 - float16Comparisons(should PASS 4) +not ok 86 - float16Comparisons(should FAIL 5) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 5.88e+04 (operandRight) + found: 5.94e+04 (operandLeft) + expected: 5.88e+04 (operandRight) + actual: 5.94e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +ok 87 - float16Comparisons(should PASS: NaN == NaN) +not ok 88 - float16Comparisons(should FAIL: NaN != 0) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 0 (operandRight) + found: nan (operandLeft) + expected: 0 (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 89 - float16Comparisons(should FAIL: 0 != NaN) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: 0 (operandLeft) + expected: nan (operandRight) + actual: 0 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 90 - float16Comparisons(should FAIL: NaN != 1) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 1 (operandRight) + found: nan (operandLeft) + expected: 1 (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 91 - float16Comparisons(should FAIL: 1 != NaN) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: 1 (operandLeft) + expected: nan (operandRight) + actual: 1 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +ok 92 - float16Comparisons(should PASS: inf == inf) +ok 93 - float16Comparisons(should PASS: -inf == -inf) +not ok 94 - float16Comparisons(should FAIL: inf != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: inf (operandLeft) + expected: -inf (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 95 - float16Comparisons(should FAIL: -inf != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: -inf (operandLeft) + expected: inf (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 96 - float16Comparisons(should FAIL: inf != nan) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: inf (operandLeft) + expected: nan (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 97 - float16Comparisons(should FAIL: nan != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: nan (operandLeft) + expected: inf (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 98 - float16Comparisons(should FAIL: -inf != nan) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: nan (operandRight) + found: -inf (operandLeft) + expected: nan (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 99 - float16Comparisons(should FAIL: nan != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: nan (operandLeft) + expected: -inf (operandRight) + actual: nan (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 100 - float16Comparisons(should FAIL: inf != 0) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 0 (operandRight) + found: inf (operandLeft) + expected: 0 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 101 - float16Comparisons(should FAIL: 0 != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: 0 (operandLeft) + expected: inf (operandRight) + actual: 0 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 102 - float16Comparisons(should FAIL: -inf != 0) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 0 (operandRight) + found: -inf (operandLeft) + expected: 0 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 103 - float16Comparisons(should FAIL: 0 != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: 0 (operandLeft) + expected: -inf (operandRight) + actual: 0 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 104 - float16Comparisons(should FAIL: inf != 1) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 1 (operandRight) + found: inf (operandLeft) + expected: 1 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 105 - float16Comparisons(should FAIL: 1 != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: 1 (operandLeft) + expected: inf (operandRight) + actual: 1 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 106 - float16Comparisons(should FAIL: -inf != 1) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 1 (operandRight) + found: -inf (operandLeft) + expected: 1 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 107 - float16Comparisons(should FAIL: 1 != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: 1 (operandLeft) + expected: -inf (operandRight) + actual: 1 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 108 - float16Comparisons(should FAIL: inf != max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 6.55e+04 (operandRight) + found: inf (operandLeft) + expected: 6.55e+04 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 109 - float16Comparisons(should FAIL: inf != -max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -6.55e+04 (operandRight) + found: inf (operandLeft) + expected: -6.55e+04 (operandRight) + actual: inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 110 - float16Comparisons(should FAIL: max != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: 6.55e+04 (operandLeft) + expected: inf (operandRight) + actual: 6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 111 - float16Comparisons(should FAIL: -max != inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: inf (operandRight) + found: -6.55e+04 (operandLeft) + expected: inf (operandRight) + actual: -6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 112 - float16Comparisons(should FAIL: -inf != max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 6.55e+04 (operandRight) + found: -inf (operandLeft) + expected: 6.55e+04 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 113 - float16Comparisons(should FAIL: -inf != -max) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -6.55e+04 (operandRight) + found: -inf (operandLeft) + expected: -6.55e+04 (operandRight) + actual: -inf (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 114 - float16Comparisons(should FAIL: max != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: 6.55e+04 (operandLeft) + expected: -inf (operandRight) + actual: 6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 115 - float16Comparisons(should FAIL: -max != -inf) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: -inf (operandRight) + found: -6.55e+04 (operandLeft) + expected: -inf (operandRight) + actual: -6.55e+04 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:171) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 171 + ... +not ok 116 - compareFloatTests(1e0) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -805,11 +1146,11 @@ not ok 83 - compareFloatTests(1e0) found: 1 (t1) expected: 3 (t3) actual: 1 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:245) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 245 + line: 210 ... -not ok 84 - compareFloatTests(1e-7) +not ok 117 - compareFloatTests(1e-7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -817,11 +1158,11 @@ not ok 84 - compareFloatTests(1e-7) found: 1e-07 (t1) expected: 3e-07 (t3) actual: 1e-07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:245) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 245 + line: 210 ... -not ok 85 - compareFloatTests(1e+7) +not ok 118 - compareFloatTests(1e+7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -829,12 +1170,12 @@ not ok 85 - compareFloatTests(1e+7) found: 1e+07 (t1) expected: 3e+07 (t3) actual: 1e+07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:245) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:210) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 245 + line: 210 ... -ok 86 - cleanupTestCase() -1..86 -# tests 86 -# pass 18 -# fail 68 +ok 119 - cleanupTestCase() +1..119 +# tests 119 +# pass 23 +# fail 96 diff --git a/tests/auto/testlib/selftests/expected_float.teamcity b/tests/auto/testlib/selftests/expected_float.teamcity index e23bc722b1..af81296c42 100644 --- a/tests/auto/testlib/selftests/expected_float.teamcity +++ b/tests/auto/testlib/selftests/expected_float.teamcity @@ -1,11 +1,11 @@ ##teamcity[testSuiteStarted name='tst_float' flowId='tst_float'] ##teamcity[testStarted name='initTestCase()' flowId='tst_float'] ##teamcity[testFinished name='initTestCase()' flowId='tst_float'] -##teamcity[testStarted name='doubleComparisons(should PASS 1)' flowId='tst_float'] -##teamcity[testFinished name='doubleComparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testStarted name='doubleComparisons(should FAIL 1)' flowId='tst_float'] ##teamcity[testFailed name='doubleComparisons(should FAIL 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared doubles are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): 3' flowId='tst_float'] ##teamcity[testFinished name='doubleComparisons(should FAIL 1)' flowId='tst_float'] +##teamcity[testStarted name='doubleComparisons(should PASS 1)' flowId='tst_float'] +##teamcity[testFinished name='doubleComparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testStarted name='doubleComparisons(should FAIL 2)' flowId='tst_float'] ##teamcity[testFailed name='doubleComparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared doubles are not the same (fuzzy compare)|n Actual (operandLeft) : 1e-07|n Expected (operandRight): 3e-07' flowId='tst_float'] ##teamcity[testFinished name='doubleComparisons(should FAIL 2)' flowId='tst_float'] @@ -215,19 +215,113 @@ ##teamcity[testStarted name='floatComparisons(should FAIL: -max != -inf)' flowId='tst_float'] ##teamcity[testFailed name='floatComparisons(should FAIL: -max != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (operandLeft) : -3.40282e+38|n Expected (operandRight): -inf' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should FAIL: -max != -inf)' flowId='tst_float'] -##teamcity[testStarted name='float16Comparisons(should SUCCEED 1)' flowId='tst_float'] -##teamcity[testFinished name='float16Comparisons(should SUCCEED 1)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 1)' flowId='tst_float'] ##teamcity[testFailed name='float16Comparisons(should FAIL 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): 3' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 1)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 1)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 2)' flowId='tst_float'] ##teamcity[testFailed name='float16Comparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0.0001|n Expected (operandRight): 0.0003' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 2)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 2)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 2)' flowId='tst_float'] ##teamcity[testStarted name='float16Comparisons(should FAIL 3)' flowId='tst_float'] ##teamcity[testFailed name='float16Comparisons(should FAIL 3)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 98|n Expected (operandRight): 99' flowId='tst_float'] ##teamcity[testFinished name='float16Comparisons(should FAIL 3)' flowId='tst_float'] -##teamcity[testStarted name='float16Comparisons(should SUCCEED 2)' flowId='tst_float'] -##teamcity[testFinished name='float16Comparisons(should SUCCEED 2)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 3)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 3)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL 4)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 4)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 5.93e-05|n Expected (operandRight): 5.87e-05' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL 4)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS 4)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS 4)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL 5)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 5)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 5.94e+04|n Expected (operandRight): 5.88e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL 5)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS: NaN == NaN)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS: NaN == NaN)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: NaN != 0)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: NaN != 0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): 0' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: NaN != 0)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 0 != NaN)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 0 != NaN)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 0 != NaN)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: NaN != 1)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: NaN != 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): 1' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: NaN != 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 1 != NaN)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 1 != NaN)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 1 != NaN)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS: inf == inf)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS: inf == inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should PASS: -inf == -inf)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should PASS: -inf == -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != nan)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != nan)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != nan)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: nan != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: nan != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: nan != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != nan)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != nan)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): nan' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != nan)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: nan != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: nan != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : nan|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: nan != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != 0)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != 0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): 0' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != 0)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 0 != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 0 != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 0 != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != 0)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != 0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): 0' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != 0)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 0 != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 0 != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 0 != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != 1)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): 1' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 1 != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 1 != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 1 != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != 1)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): 1' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: 1 != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: 1 != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: 1 != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): 6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: inf != -max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: inf != -max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : inf|n Expected (operandRight): -6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: inf != -max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: max != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: max != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 6.55e+04|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: max != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -max != inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -max != inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -6.55e+04|n Expected (operandRight): inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -max != inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): 6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -inf != -max)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -inf != -max)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -inf|n Expected (operandRight): -6.55e+04' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -inf != -max)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: max != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: max != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 6.55e+04|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: max != -inf)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL: -max != -inf)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL: -max != -inf)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : -6.55e+04|n Expected (operandRight): -inf' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL: -max != -inf)' flowId='tst_float'] ##teamcity[testStarted name='compareFloatTests(1e0)' flowId='tst_float'] ##teamcity[testFailed name='compareFloatTests(1e0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1|n Expected (t3): 3' flowId='tst_float'] ##teamcity[testFinished name='compareFloatTests(1e0)' flowId='tst_float'] diff --git a/tests/auto/testlib/selftests/expected_float.txt b/tests/auto/testlib/selftests/expected_float.txt index 6419a13f86..d22a52a63d 100644 --- a/tests/auto/testlib/selftests/expected_float.txt +++ b/tests/auto/testlib/selftests/expected_float.txt @@ -1,11 +1,11 @@ ********* Start testing of tst_float ********* Config: Using QtTest library PASS : tst_float::initTestCase() -PASS : tst_float::doubleComparisons(should PASS 1) FAIL! : tst_float::doubleComparisons(should FAIL 1) Compared doubles are not the same (fuzzy compare) Actual (operandLeft) : 1 Expected (operandRight): 3 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::doubleComparisons(should PASS 1) FAIL! : tst_float::doubleComparisons(should FAIL 2) Compared doubles are not the same (fuzzy compare) Actual (operandLeft) : 1e-07 Expected (operandRight): 3e-07 @@ -263,20 +263,137 @@ FAIL! : tst_float::floatComparisons(should FAIL: -max != -inf) Compared floats Actual (operandLeft) : -3.40282e+38 Expected (operandRight): -inf Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] -PASS : tst_float::float16Comparisons(should SUCCEED 1) FAIL! : tst_float::float16Comparisons(should FAIL 1) Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 1 Expected (operandRight): 3 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS 1) FAIL! : tst_float::float16Comparisons(should FAIL 2) Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 0.0001 Expected (operandRight): 0.0003 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS 2) FAIL! : tst_float::float16Comparisons(should FAIL 3) Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 98 Expected (operandRight): 99 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] -PASS : tst_float::float16Comparisons(should SUCCEED 2) +PASS : tst_float::float16Comparisons(should PASS 3) +FAIL! : tst_float::float16Comparisons(should FAIL 4) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.93e-05 + Expected (operandRight): 5.87e-05 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS 4) +FAIL! : tst_float::float16Comparisons(should FAIL 5) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.94e+04 + Expected (operandRight): 5.88e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS: NaN == NaN) +FAIL! : tst_float::float16Comparisons(should FAIL: NaN != 0) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 0 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 0 != NaN) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: NaN != 1) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 1 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 1 != NaN) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should PASS: inf == inf) +PASS : tst_float::float16Comparisons(should PASS: -inf == -inf) +FAIL! : tst_float::float16Comparisons(should FAIL: inf != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != nan) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: nan != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != nan) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): nan + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: nan != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != 0) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 0 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 0 != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != 0) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 0 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 0 != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != 1) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 1 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 1 != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != 1) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 1 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: 1 != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: inf != -max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: max != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -max != inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -inf != -max) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): -6.55e+04 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: max != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL: -max != -inf) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): -inf + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuzzy compare) Actual (t1): 1 Expected (t3): 3 @@ -290,5 +407,5 @@ FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fu Expected (t3): 3e+07 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::cleanupTestCase() -Totals: 18 passed, 68 failed, 0 skipped, 0 blacklisted, 0ms +Totals: 23 passed, 96 failed, 0 skipped, 0 blacklisted, 0ms ********* Finished testing of tst_float ********* diff --git a/tests/auto/testlib/selftests/expected_float.xml b/tests/auto/testlib/selftests/expected_float.xml index 65d2c5ad96..247bce9577 100644 --- a/tests/auto/testlib/selftests/expected_float.xml +++ b/tests/auto/testlib/selftests/expected_float.xml @@ -10,15 +10,15 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="doubleComparisons"> -<Incident type="pass" file="" line="0"> - <DataTag><![CDATA[should PASS 1]]></DataTag> -</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 1]]></DataTag> <Description><![CDATA[Compared doubles are not the same (fuzzy compare) Actual (operandLeft) : 1 Expected (operandRight): 3]]></Description> </Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 1]]></DataTag> +</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared doubles are not the same (fuzzy compare) @@ -430,21 +430,24 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="float16Comparisons"> -<Incident type="pass" file="" line="0"> - <DataTag><![CDATA[should SUCCEED 1]]></DataTag> -</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 1]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 1 Expected (operandRight): 3]]></Description> </Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 1]]></DataTag> +</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 2]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 0.0001 Expected (operandRight): 0.0003]]></Description> </Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 2]]></DataTag> +</Incident> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[should FAIL 3]]></DataTag> <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) @@ -452,7 +455,187 @@ Expected (operandRight): 99]]></Description> </Incident> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[should SUCCEED 2]]></DataTag> + <DataTag><![CDATA[should PASS 3]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 4]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.93e-05 + Expected (operandRight): 5.87e-05]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS 4]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 5]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.94e+04 + Expected (operandRight): 5.88e+04]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS: NaN == NaN]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: NaN != 0]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 0]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 0 != NaN]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: NaN != 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 1]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 1 != NaN]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS: inf == inf]]></DataTag> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should PASS: -inf == -inf]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != nan]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: nan != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != nan]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): nan]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: nan != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != 0]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 0]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 0 != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != 0]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 0]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 0 != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 1]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 1 != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 1]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: 1 != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: inf != -max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: max != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -max != inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -inf != -max]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): -6.55e+04]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: max != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): -inf]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL: -max != -inf]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): -inf]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> diff --git a/tests/auto/testlib/selftests/expected_float.xunitxml b/tests/auto/testlib/selftests/expected_float.xunitxml index 9b2af9b616..602f9252a4 100644 --- a/tests/auto/testlib/selftests/expected_float.xunitxml +++ b/tests/auto/testlib/selftests/expected_float.xunitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite errors="0" failures="68" tests="6" name="tst_float"> +<testsuite errors="0" failures="96" tests="6" name="tst_float"> <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> @@ -206,6 +206,90 @@ <failure tag="should FAIL 3" message="Compared qfloat16s are not the same (fuzzy compare) Actual (operandLeft) : 98 Expected (operandRight): 99" result="fail"/> + <failure tag="should FAIL 4" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.93e-05 + Expected (operandRight): 5.87e-05" result="fail"/> + <failure tag="should FAIL 5" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 5.94e+04 + Expected (operandRight): 5.88e+04" result="fail"/> + <failure tag="should FAIL: NaN != 0" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 0" result="fail"/> + <failure tag="should FAIL: 0 != NaN" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): nan" result="fail"/> + <failure tag="should FAIL: NaN != 1" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): 1" result="fail"/> + <failure tag="should FAIL: 1 != NaN" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): nan" result="fail"/> + <failure tag="should FAIL: inf != -inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -inf" result="fail"/> + <failure tag="should FAIL: -inf != inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): inf" result="fail"/> + <failure tag="should FAIL: inf != nan" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): nan" result="fail"/> + <failure tag="should FAIL: nan != inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): inf" result="fail"/> + <failure tag="should FAIL: -inf != nan" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): nan" result="fail"/> + <failure tag="should FAIL: nan != -inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : nan + Expected (operandRight): -inf" result="fail"/> + <failure tag="should FAIL: inf != 0" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 0" result="fail"/> + <failure tag="should FAIL: 0 != inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): inf" result="fail"/> + <failure tag="should FAIL: -inf != 0" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 0" result="fail"/> + <failure tag="should FAIL: 0 != -inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0 + Expected (operandRight): -inf" result="fail"/> + <failure tag="should FAIL: inf != 1" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 1" result="fail"/> + <failure tag="should FAIL: 1 != inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): inf" result="fail"/> + <failure tag="should FAIL: -inf != 1" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 1" result="fail"/> + <failure tag="should FAIL: 1 != -inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): -inf" result="fail"/> + <failure tag="should FAIL: inf != max" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): 6.55e+04" result="fail"/> + <failure tag="should FAIL: inf != -max" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : inf + Expected (operandRight): -6.55e+04" result="fail"/> + <failure tag="should FAIL: max != inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): inf" result="fail"/> + <failure tag="should FAIL: -max != inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): inf" result="fail"/> + <failure tag="should FAIL: -inf != max" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): 6.55e+04" result="fail"/> + <failure tag="should FAIL: -inf != -max" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -inf + Expected (operandRight): -6.55e+04" result="fail"/> + <failure tag="should FAIL: max != -inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 6.55e+04 + Expected (operandRight): -inf" result="fail"/> + <failure tag="should FAIL: -max != -inf" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : -6.55e+04 + Expected (operandRight): -inf" result="fail"/> </testcase> <testcase result="fail" name="compareFloatTests"> <failure tag="1e0" message="Compared floats are not the same (fuzzy compare) diff --git a/tests/auto/testlib/selftests/expected_globaldata.lightxml b/tests/auto/testlib/selftests/expected_globaldata.lightxml index f66c4c552d..1212e4b364 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.lightxml +++ b/tests/auto/testlib/selftests/expected_globaldata.lightxml @@ -12,174 +12,195 @@ </TestFunction> <TestFunction name="testGlobal"> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[init testGlobal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[init testGlobal local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[global: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[local: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=false]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[init testGlobal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[init testGlobal local=true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> <Description><![CDATA[global: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> <Description><![CDATA[local: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=true]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[init testGlobal local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[init testGlobal local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> + <DataTag><![CDATA[global=true:local=false]]></DataTag> <Description><![CDATA[global: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> + <DataTag><![CDATA[global=true:local=false]]></DataTag> <Description><![CDATA[local: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=false]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> + <DataTag><![CDATA[global=true:local=false]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[init testGlobal local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[init testGlobal local=true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> <Description><![CDATA[global: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> <Description><![CDATA[local: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=true]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="skip"> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[1]]></DataTag> + <DataTag><![CDATA[global=false]]></DataTag> <Description><![CDATA[skipping]]></Description> </Message> <Duration msecs="0"/> </TestFunction> <TestFunction name="skipLocal"> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[init skipLocal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[init skipLocal local=false]]></Description> </Message> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[cleanup skipLocal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[init skipLocal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[init skipLocal local=true]]></Description> </Message> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> <Description><![CDATA[skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[cleanup skipLocal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=true]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[init skipLocal local=false]]></Description> +</Message> +<Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[skipping]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=false]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[init skipLocal local=true]]></Description> +</Message> +<Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[skipping]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=true]]></Description> </Message> <Duration msecs="0"/> </TestFunction> <TestFunction name="skipSingle"> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[init skipSingle local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[init skipSingle local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[global: false local: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=false]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[init skipSingle local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[init skipSingle local=true]]></Description> </Message> -<Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[global: false local: true]]></Description> +<Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[Skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=true]]></Description> </Message> -<Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> -</Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[init skipSingle local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[init skipSingle local=false]]></Description> </Message> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[skipping]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[Skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[init skipSingle local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[init skipSingle local=true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> <Description><![CDATA[global: true local: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=true]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> </Incident> <Duration msecs="0"/> </TestFunction> diff --git a/tests/auto/testlib/selftests/expected_globaldata.tap b/tests/auto/testlib/selftests/expected_globaldata.tap index 580cf3a7a8..4d61b7437b 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.tap +++ b/tests/auto/testlib/selftests/expected_globaldata.tap @@ -2,51 +2,56 @@ TAP version 13 # tst_globaldata # initTestCase initTestCase (null) ok 1 - initTestCase() -# init testGlobal local 1 +# init testGlobal local=false # global: false # local: false -# cleanup testGlobal local 1 -ok 2 - testGlobal(1:local 1) -# init testGlobal local 2 +# cleanup testGlobal local=false +ok 2 - testGlobal(global=false:local=false) +# init testGlobal local=true # global: false # local: true -# cleanup testGlobal local 2 -ok 3 - testGlobal(1:local 2) -# init testGlobal local 1 +# cleanup testGlobal local=true +ok 3 - testGlobal(global=false:local=true) +# init testGlobal local=false # global: true # local: false -# cleanup testGlobal local 1 -ok 4 - testGlobal(2:local 1) -# init testGlobal local 2 +# cleanup testGlobal local=false +ok 4 - testGlobal(global=true:local=false) +# init testGlobal local=true # global: true # local: true -# cleanup testGlobal local 2 -ok 5 - testGlobal(2:local 2) -ok 6 - skip(1) # SKIP skipping -# init skipLocal local 1 -ok 7 - skipLocal(1:local 1) # SKIP skipping -# cleanup skipLocal local 1 -# init skipLocal local 2 -ok 8 - skipLocal(1:local 2) # SKIP skipping -# cleanup skipLocal local 2 -# init skipSingle local 1 +# cleanup testGlobal local=true +ok 5 - testGlobal(global=true:local=true) +ok 6 - skip(global=false) # SKIP skipping +# init skipLocal local=false +ok 7 - skipLocal(global=false:local=false) # SKIP skipping +# cleanup skipLocal local=false +# init skipLocal local=true +ok 8 - skipLocal(global=false:local=true) # SKIP skipping +# cleanup skipLocal local=true +# init skipLocal local=false +ok 9 - skipLocal(global=true:local=false) # SKIP skipping +# cleanup skipLocal local=false +# init skipLocal local=true +ok 10 - skipLocal(global=true:local=true) # SKIP skipping +# cleanup skipLocal local=true +# init skipSingle local=false # global: false local: false -# cleanup skipSingle local 1 -ok 9 - skipSingle(1:local 1) -# init skipSingle local 2 -# global: false local: true -# cleanup skipSingle local 2 -ok 10 - skipSingle(1:local 2) -# init skipSingle local 1 -ok 11 - skipSingle(2:local 1) # SKIP skipping -# cleanup skipSingle local 1 -# init skipSingle local 2 +# cleanup skipSingle local=false +ok 11 - skipSingle(global=false:local=false) +# init skipSingle local=true +ok 12 - skipSingle(global=false:local=true) # SKIP Skipping +# cleanup skipSingle local=true +# init skipSingle local=false +ok 13 - skipSingle(global=true:local=false) # SKIP Skipping +# cleanup skipSingle local=false +# init skipSingle local=true # global: true local: true -# cleanup skipSingle local 2 -ok 12 - skipSingle(2:local 2) +# cleanup skipSingle local=true +ok 14 - skipSingle(global=true:local=true) # cleanupTestCase cleanupTestCase (null) -ok 13 - cleanupTestCase() -1..13 -# tests 13 -# pass 9 +ok 15 - cleanupTestCase() +1..15 +# tests 15 +# pass 8 # fail 0 diff --git a/tests/auto/testlib/selftests/expected_globaldata.teamcity b/tests/auto/testlib/selftests/expected_globaldata.teamcity index 5d623a3285..f76f6090ba 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.teamcity +++ b/tests/auto/testlib/selftests/expected_globaldata.teamcity @@ -2,30 +2,31 @@ ##teamcity[testStarted name='initTestCase()' flowId='tst_globaldata'] ##teamcity[testStdOut name='initTestCase()' out='QDEBUG: initTestCase initTestCase (null)' flowId='tst_globaldata'] ##teamcity[testFinished name='initTestCase()' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 1)' out='QDEBUG: init testGlobal local 1|nQDEBUG: global: false|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local 1' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 2)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 2)' out='QDEBUG: init testGlobal local 2|nQDEBUG: global: false|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 2)' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 1)' out='QDEBUG: init testGlobal local 1|nQDEBUG: global: true|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local 1' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 1)' flowId='tst_globaldata'] -##teamcity[testStarted name='testGlobal(local 2)' flowId='tst_globaldata'] -##teamcity[testStdOut name='testGlobal(local 2)' out='QDEBUG: init testGlobal local 2|nQDEBUG: global: true|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='testGlobal(local 2)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=false)' out='QDEBUG: init testGlobal local=false|nQDEBUG: global: false|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local=false' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=true)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=true)' out='QDEBUG: init testGlobal local=true|nQDEBUG: global: false|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local=true' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=true)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=false)' out='QDEBUG: init testGlobal local=false|nQDEBUG: global: true|nQDEBUG: local: false|nQDEBUG: cleanup testGlobal local=false' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=false)' flowId='tst_globaldata'] +##teamcity[testStarted name='testGlobal(local=true)' flowId='tst_globaldata'] +##teamcity[testStdOut name='testGlobal(local=true)' out='QDEBUG: init testGlobal local=true|nQDEBUG: global: true|nQDEBUG: local: true|nQDEBUG: cleanup testGlobal local=true' flowId='tst_globaldata'] +##teamcity[testFinished name='testGlobal(local=true)' flowId='tst_globaldata'] ##teamcity[testIgnored name='skip()' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testIgnored name='skipLocal(local 1)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testIgnored name='skipLocal(local 2)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testStarted name='skipSingle(local 1)' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local 1)' out='QDEBUG: init skipLocal local 1|nQDEBUG: cleanup skipLocal local 1|nQDEBUG: init skipLocal local 2|nQDEBUG: cleanup skipLocal local 2|nQDEBUG: init skipSingle local 1|nQDEBUG: global: false local: false|nQDEBUG: cleanup skipSingle local 1' flowId='tst_globaldata'] -##teamcity[testFinished name='skipSingle(local 1)' flowId='tst_globaldata'] -##teamcity[testStarted name='skipSingle(local 2)' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local 2)' out='QDEBUG: init skipSingle local 2|nQDEBUG: global: false local: true|nQDEBUG: cleanup skipSingle local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='skipSingle(local 2)' flowId='tst_globaldata'] -##teamcity[testIgnored name='skipSingle(local 1)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] -##teamcity[testStdOut name='skipSingle(local 2)' out='QDEBUG: init skipSingle local 1|nQDEBUG: cleanup skipSingle local 1|nQDEBUG: init skipSingle local 2|nQDEBUG: global: true local: true|nQDEBUG: cleanup skipSingle local 2' flowId='tst_globaldata'] -##teamcity[testFinished name='skipSingle(local 2)' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=false)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=true)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=false)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipLocal(local=true)' message='skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testStarted name='skipSingle(local=false)' flowId='tst_globaldata'] +##teamcity[testStdOut name='skipSingle(local=false)' out='QDEBUG: init skipLocal local=false|nQDEBUG: cleanup skipLocal local=false|nQDEBUG: init skipLocal local=true|nQDEBUG: cleanup skipLocal local=true|nQDEBUG: init skipLocal local=false|nQDEBUG: cleanup skipLocal local=false|nQDEBUG: init skipLocal local=true|nQDEBUG: cleanup skipLocal local=true|nQDEBUG: init skipSingle local=false|nQDEBUG: global: false local: false|nQDEBUG: cleanup skipSingle local=false' flowId='tst_globaldata'] +##teamcity[testFinished name='skipSingle(local=false)' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipSingle(local=true)' message='Skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testIgnored name='skipSingle(local=false)' message='Skipping |[Loc: qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)|]' flowId='tst_globaldata'] +##teamcity[testStarted name='skipSingle(local=true)' flowId='tst_globaldata'] +##teamcity[testStdOut name='skipSingle(local=true)' out='QDEBUG: init skipSingle local=true|nQDEBUG: cleanup skipSingle local=true|nQDEBUG: init skipSingle local=false|nQDEBUG: cleanup skipSingle local=false|nQDEBUG: init skipSingle local=true|nQDEBUG: global: true local: true|nQDEBUG: cleanup skipSingle local=true' flowId='tst_globaldata'] +##teamcity[testFinished name='skipSingle(local=true)' flowId='tst_globaldata'] ##teamcity[testStarted name='cleanupTestCase()' flowId='tst_globaldata'] ##teamcity[testStdOut name='cleanupTestCase()' out='QDEBUG: cleanupTestCase cleanupTestCase (null)' flowId='tst_globaldata'] ##teamcity[testFinished name='cleanupTestCase()' flowId='tst_globaldata'] diff --git a/tests/auto/testlib/selftests/expected_globaldata.txt b/tests/auto/testlib/selftests/expected_globaldata.txt index b12f4a2a69..016b5e8299 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.txt +++ b/tests/auto/testlib/selftests/expected_globaldata.txt @@ -2,53 +2,61 @@ Config: Using QtTest library QDEBUG : tst_globaldata::initTestCase() initTestCase initTestCase (null) PASS : tst_globaldata::initTestCase() -QDEBUG : tst_globaldata::testGlobal(1:local 1) init testGlobal local 1 -QDEBUG : tst_globaldata::testGlobal(1:local 1) global: false -QDEBUG : tst_globaldata::testGlobal(1:local 1) local: false -QDEBUG : tst_globaldata::testGlobal(1:local 1) cleanup testGlobal local 1 -PASS : tst_globaldata::testGlobal(1:local 1) -QDEBUG : tst_globaldata::testGlobal(1:local 2) init testGlobal local 2 -QDEBUG : tst_globaldata::testGlobal(1:local 2) global: false -QDEBUG : tst_globaldata::testGlobal(1:local 2) local: true -QDEBUG : tst_globaldata::testGlobal(1:local 2) cleanup testGlobal local 2 -PASS : tst_globaldata::testGlobal(1:local 2) -QDEBUG : tst_globaldata::testGlobal(2:local 1) init testGlobal local 1 -QDEBUG : tst_globaldata::testGlobal(2:local 1) global: true -QDEBUG : tst_globaldata::testGlobal(2:local 1) local: false -QDEBUG : tst_globaldata::testGlobal(2:local 1) cleanup testGlobal local 1 -PASS : tst_globaldata::testGlobal(2:local 1) -QDEBUG : tst_globaldata::testGlobal(2:local 2) init testGlobal local 2 -QDEBUG : tst_globaldata::testGlobal(2:local 2) global: true -QDEBUG : tst_globaldata::testGlobal(2:local 2) local: true -QDEBUG : tst_globaldata::testGlobal(2:local 2) cleanup testGlobal local 2 -PASS : tst_globaldata::testGlobal(2:local 2) -SKIP : tst_globaldata::skip(1) skipping +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) init testGlobal local=false +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) global: false +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) local: false +QDEBUG : tst_globaldata::testGlobal(global=false:local=false) cleanup testGlobal local=false +PASS : tst_globaldata::testGlobal(global=false:local=false) +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) init testGlobal local=true +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) global: false +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) local: true +QDEBUG : tst_globaldata::testGlobal(global=false:local=true) cleanup testGlobal local=true +PASS : tst_globaldata::testGlobal(global=false:local=true) +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) init testGlobal local=false +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) global: true +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) local: false +QDEBUG : tst_globaldata::testGlobal(global=true:local=false) cleanup testGlobal local=false +PASS : tst_globaldata::testGlobal(global=true:local=false) +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) init testGlobal local=true +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) global: true +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) local: true +QDEBUG : tst_globaldata::testGlobal(global=true:local=true) cleanup testGlobal local=true +PASS : tst_globaldata::testGlobal(global=true:local=true) +SKIP : tst_globaldata::skip(global=false) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipLocal(1:local 1) init skipLocal local 1 -SKIP : tst_globaldata::skipLocal(1:local 1) skipping +QDEBUG : tst_globaldata::skipLocal(global=false:local=false) init skipLocal local=false +SKIP : tst_globaldata::skipLocal(global=false:local=false) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipLocal(1:local 1) cleanup skipLocal local 1 -QDEBUG : tst_globaldata::skipLocal(1:local 2) init skipLocal local 2 -SKIP : tst_globaldata::skipLocal(1:local 2) skipping +QDEBUG : tst_globaldata::skipLocal(global=false:local=false) cleanup skipLocal local=false +QDEBUG : tst_globaldata::skipLocal(global=false:local=true) init skipLocal local=true +SKIP : tst_globaldata::skipLocal(global=false:local=true) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipLocal(1:local 2) cleanup skipLocal local 2 -QDEBUG : tst_globaldata::skipSingle(1:local 1) init skipSingle local 1 -QDEBUG : tst_globaldata::skipSingle(1:local 1) global: false local: false -QDEBUG : tst_globaldata::skipSingle(1:local 1) cleanup skipSingle local 1 -PASS : tst_globaldata::skipSingle(1:local 1) -QDEBUG : tst_globaldata::skipSingle(1:local 2) init skipSingle local 2 -QDEBUG : tst_globaldata::skipSingle(1:local 2) global: false local: true -QDEBUG : tst_globaldata::skipSingle(1:local 2) cleanup skipSingle local 2 -PASS : tst_globaldata::skipSingle(1:local 2) -QDEBUG : tst_globaldata::skipSingle(2:local 1) init skipSingle local 1 -SKIP : tst_globaldata::skipSingle(2:local 1) skipping +QDEBUG : tst_globaldata::skipLocal(global=false:local=true) cleanup skipLocal local=true +QDEBUG : tst_globaldata::skipLocal(global=true:local=false) init skipLocal local=false +SKIP : tst_globaldata::skipLocal(global=true:local=false) skipping Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] -QDEBUG : tst_globaldata::skipSingle(2:local 1) cleanup skipSingle local 1 -QDEBUG : tst_globaldata::skipSingle(2:local 2) init skipSingle local 2 -QDEBUG : tst_globaldata::skipSingle(2:local 2) global: true local: true -QDEBUG : tst_globaldata::skipSingle(2:local 2) cleanup skipSingle local 2 -PASS : tst_globaldata::skipSingle(2:local 2) +QDEBUG : tst_globaldata::skipLocal(global=true:local=false) cleanup skipLocal local=false +QDEBUG : tst_globaldata::skipLocal(global=true:local=true) init skipLocal local=true +SKIP : tst_globaldata::skipLocal(global=true:local=true) skipping + Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] +QDEBUG : tst_globaldata::skipLocal(global=true:local=true) cleanup skipLocal local=true +QDEBUG : tst_globaldata::skipSingle(global=false:local=false) init skipSingle local=false +QDEBUG : tst_globaldata::skipSingle(global=false:local=false) global: false local: false +QDEBUG : tst_globaldata::skipSingle(global=false:local=false) cleanup skipSingle local=false +PASS : tst_globaldata::skipSingle(global=false:local=false) +QDEBUG : tst_globaldata::skipSingle(global=false:local=true) init skipSingle local=true +SKIP : tst_globaldata::skipSingle(global=false:local=true) Skipping + Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] +QDEBUG : tst_globaldata::skipSingle(global=false:local=true) cleanup skipSingle local=true +QDEBUG : tst_globaldata::skipSingle(global=true:local=false) init skipSingle local=false +SKIP : tst_globaldata::skipSingle(global=true:local=false) Skipping + Loc: [qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(0)] +QDEBUG : tst_globaldata::skipSingle(global=true:local=false) cleanup skipSingle local=false +QDEBUG : tst_globaldata::skipSingle(global=true:local=true) init skipSingle local=true +QDEBUG : tst_globaldata::skipSingle(global=true:local=true) global: true local: true +QDEBUG : tst_globaldata::skipSingle(global=true:local=true) cleanup skipSingle local=true +PASS : tst_globaldata::skipSingle(global=true:local=true) QDEBUG : tst_globaldata::cleanupTestCase() cleanupTestCase cleanupTestCase (null) PASS : tst_globaldata::cleanupTestCase() -Totals: 9 passed, 0 failed, 4 skipped, 0 blacklisted, 0ms +Totals: 8 passed, 0 failed, 7 skipped, 0 blacklisted, 0ms ********* Finished testing of tst_globaldata ********* diff --git a/tests/auto/testlib/selftests/expected_globaldata.xml b/tests/auto/testlib/selftests/expected_globaldata.xml index 0f705ef352..9aa48c8f16 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xml +++ b/tests/auto/testlib/selftests/expected_globaldata.xml @@ -14,174 +14,195 @@ </TestFunction> <TestFunction name="testGlobal"> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[init testGlobal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[init testGlobal local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[global: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[local: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=false]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[init testGlobal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[init testGlobal local=true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> <Description><![CDATA[global: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> <Description><![CDATA[local: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=true]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[init testGlobal local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[init testGlobal local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> + <DataTag><![CDATA[global=true:local=false]]></DataTag> <Description><![CDATA[global: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> + <DataTag><![CDATA[global=true:local=false]]></DataTag> <Description><![CDATA[local: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=false]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> + <DataTag><![CDATA[global=true:local=false]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[init testGlobal local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[init testGlobal local=true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> <Description><![CDATA[global: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> <Description><![CDATA[local: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[cleanup testGlobal local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[cleanup testGlobal local=true]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="skip"> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[1]]></DataTag> + <DataTag><![CDATA[global=false]]></DataTag> <Description><![CDATA[skipping]]></Description> </Message> <Duration msecs="0"/> </TestFunction> <TestFunction name="skipLocal"> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[init skipLocal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[init skipLocal local=false]]></Description> </Message> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[cleanup skipLocal local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[init skipLocal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[init skipLocal local=true]]></Description> </Message> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> + <DataTag><![CDATA[global=false:local=true]]></DataTag> <Description><![CDATA[skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[cleanup skipLocal local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=true]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[init skipLocal local=false]]></Description> +</Message> +<Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[skipping]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=false]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[init skipLocal local=true]]></Description> +</Message> +<Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[skipping]]></Description> +</Message> +<Message type="qdebug" file="" line="0"> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[cleanup skipLocal local=true]]></Description> </Message> <Duration msecs="0"/> </TestFunction> <TestFunction name="skipSingle"> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[init skipSingle local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[init skipSingle local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> <Description><![CDATA[global: false local: false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 1]]></Description> + <DataTag><![CDATA[global=false:local=false]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=false]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 1]]></DataTag> + <DataTag><![CDATA[global=false:local=false]]></DataTag> </Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[init skipSingle local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[init skipSingle local=true]]></Description> </Message> -<Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[global: false local: true]]></Description> +<Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[Skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 2]]></Description> + <DataTag><![CDATA[global=false:local=true]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=true]]></Description> </Message> -<Incident type="pass" file="" line="0"> - <DataTag><![CDATA[1:local 2]]></DataTag> -</Incident> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[init skipSingle local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[init skipSingle local=false]]></Description> </Message> <Message type="skip" file="qtbase/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[skipping]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[Skipping]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 1]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 1]]></Description> + <DataTag><![CDATA[global=true:local=false]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=false]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[init skipSingle local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[init skipSingle local=true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> <Description><![CDATA[global: true local: true]]></Description> </Message> <Message type="qdebug" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> - <Description><![CDATA[cleanup skipSingle local 2]]></Description> + <DataTag><![CDATA[global=true:local=true]]></DataTag> + <Description><![CDATA[cleanup skipSingle local=true]]></Description> </Message> <Incident type="pass" file="" line="0"> - <DataTag><![CDATA[2:local 2]]></DataTag> + <DataTag><![CDATA[global=true:local=true]]></DataTag> </Incident> <Duration msecs="0"/> </TestFunction> diff --git a/tests/auto/testlib/selftests/expected_globaldata.xunitxml b/tests/auto/testlib/selftests/expected_globaldata.xunitxml index bdd7e3f00a..de184c2fdd 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xunitxml +++ b/tests/auto/testlib/selftests/expected_globaldata.xunitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite errors="37" failures="0" tests="6" name="tst_globaldata"> +<testsuite errors="43" failures="0" tests="6" name="tst_globaldata"> <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> @@ -9,88 +9,100 @@ <!-- message="initTestCase initTestCase (null)" type="qdebug" --> </testcase> <testcase result="pass" name="testGlobal"> - <!-- tag="1:local 1" message="init testGlobal local 1" type="qdebug" --> - <!-- tag="1:local 1" message="global: false" type="qdebug" --> - <!-- tag="1:local 1" message="local: false" type="qdebug" --> - <!-- tag="1:local 1" message="cleanup testGlobal local 1" type="qdebug" --> - <!-- tag="1:local 2" message="init testGlobal local 2" type="qdebug" --> - <!-- tag="1:local 2" message="global: false" type="qdebug" --> - <!-- tag="1:local 2" message="local: true" type="qdebug" --> - <!-- tag="1:local 2" message="cleanup testGlobal local 2" type="qdebug" --> - <!-- tag="2:local 1" message="init testGlobal local 1" type="qdebug" --> - <!-- tag="2:local 1" message="global: true" type="qdebug" --> - <!-- tag="2:local 1" message="local: false" type="qdebug" --> - <!-- tag="2:local 1" message="cleanup testGlobal local 1" type="qdebug" --> - <!-- tag="2:local 2" message="init testGlobal local 2" type="qdebug" --> - <!-- tag="2:local 2" message="global: true" type="qdebug" --> - <!-- tag="2:local 2" message="local: true" type="qdebug" --> - <!-- tag="2:local 2" message="cleanup testGlobal local 2" type="qdebug" --> + <!-- tag="global=false:local=false" message="init testGlobal local=false" type="qdebug" --> + <!-- tag="global=false:local=false" message="global: false" type="qdebug" --> + <!-- tag="global=false:local=false" message="local: false" type="qdebug" --> + <!-- tag="global=false:local=false" message="cleanup testGlobal local=false" type="qdebug" --> + <!-- tag="global=false:local=true" message="init testGlobal local=true" type="qdebug" --> + <!-- tag="global=false:local=true" message="global: false" type="qdebug" --> + <!-- tag="global=false:local=true" message="local: true" type="qdebug" --> + <!-- tag="global=false:local=true" message="cleanup testGlobal local=true" type="qdebug" --> + <!-- tag="global=true:local=false" message="init testGlobal local=false" type="qdebug" --> + <!-- tag="global=true:local=false" message="global: true" type="qdebug" --> + <!-- tag="global=true:local=false" message="local: false" type="qdebug" --> + <!-- tag="global=true:local=false" message="cleanup testGlobal local=false" type="qdebug" --> + <!-- tag="global=true:local=true" message="init testGlobal local=true" type="qdebug" --> + <!-- tag="global=true:local=true" message="global: true" type="qdebug" --> + <!-- tag="global=true:local=true" message="local: true" type="qdebug" --> + <!-- tag="global=true:local=true" message="cleanup testGlobal local=true" type="qdebug" --> </testcase> <testcase name="skip"> - <!-- tag="1" message="skipping" type="skip" --> + <!-- tag="global=false" message="skipping" type="skip" --> </testcase> <testcase name="skipLocal"> - <!-- tag="1:local 1" message="init skipLocal local 1" type="qdebug" --> - <!-- tag="1:local 1" message="skipping" type="skip" --> - <!-- tag="1:local 1" message="cleanup skipLocal local 1" type="qdebug" --> - <!-- tag="1:local 2" message="init skipLocal local 2" type="qdebug" --> - <!-- tag="1:local 2" message="skipping" type="skip" --> - <!-- tag="1:local 2" message="cleanup skipLocal local 2" type="qdebug" --> + <!-- tag="global=false:local=false" message="init skipLocal local=false" type="qdebug" --> + <!-- tag="global=false:local=false" message="skipping" type="skip" --> + <!-- tag="global=false:local=false" message="cleanup skipLocal local=false" type="qdebug" --> + <!-- tag="global=false:local=true" message="init skipLocal local=true" type="qdebug" --> + <!-- tag="global=false:local=true" message="skipping" type="skip" --> + <!-- tag="global=false:local=true" message="cleanup skipLocal local=true" type="qdebug" --> + <!-- tag="global=true:local=false" message="init skipLocal local=false" type="qdebug" --> + <!-- tag="global=true:local=false" message="skipping" type="skip" --> + <!-- tag="global=true:local=false" message="cleanup skipLocal local=false" type="qdebug" --> + <!-- tag="global=true:local=true" message="init skipLocal local=true" type="qdebug" --> + <!-- tag="global=true:local=true" message="skipping" type="skip" --> + <!-- tag="global=true:local=true" message="cleanup skipLocal local=true" type="qdebug" --> </testcase> <testcase result="pass" name="skipSingle"> - <!-- tag="1:local 1" message="init skipSingle local 1" type="qdebug" --> - <!-- tag="1:local 1" message="global: false local: false" type="qdebug" --> - <!-- tag="1:local 1" message="cleanup skipSingle local 1" type="qdebug" --> - <!-- tag="1:local 2" message="init skipSingle local 2" type="qdebug" --> - <!-- tag="1:local 2" message="global: false local: true" type="qdebug" --> - <!-- tag="1:local 2" message="cleanup skipSingle local 2" type="qdebug" --> - <!-- tag="2:local 1" message="init skipSingle local 1" type="qdebug" --> - <!-- tag="2:local 1" message="skipping" type="skip" --> - <!-- tag="2:local 1" message="cleanup skipSingle local 1" type="qdebug" --> - <!-- tag="2:local 2" message="init skipSingle local 2" type="qdebug" --> - <!-- tag="2:local 2" message="global: true local: true" type="qdebug" --> - <!-- tag="2:local 2" message="cleanup skipSingle local 2" type="qdebug" --> + <!-- tag="global=false:local=false" message="init skipSingle local=false" type="qdebug" --> + <!-- tag="global=false:local=false" message="global: false local: false" type="qdebug" --> + <!-- tag="global=false:local=false" message="cleanup skipSingle local=false" type="qdebug" --> + <!-- tag="global=false:local=true" message="init skipSingle local=true" type="qdebug" --> + <!-- tag="global=false:local=true" message="Skipping" type="skip" --> + <!-- tag="global=false:local=true" message="cleanup skipSingle local=true" type="qdebug" --> + <!-- tag="global=true:local=false" message="init skipSingle local=false" type="qdebug" --> + <!-- tag="global=true:local=false" message="Skipping" type="skip" --> + <!-- tag="global=true:local=false" message="cleanup skipSingle local=false" type="qdebug" --> + <!-- tag="global=true:local=true" message="init skipSingle local=true" type="qdebug" --> + <!-- tag="global=true:local=true" message="global: true local: true" type="qdebug" --> + <!-- tag="global=true:local=true" message="cleanup skipSingle local=true" type="qdebug" --> </testcase> <testcase result="pass" name="cleanupTestCase"> <!-- message="cleanupTestCase cleanupTestCase (null)" type="qdebug" --> </testcase> <system-err> <![CDATA[initTestCase initTestCase (null)]]> -<![CDATA[init testGlobal local 1]]> +<![CDATA[init testGlobal local=false]]> <![CDATA[global: false]]> <![CDATA[local: false]]> -<![CDATA[cleanup testGlobal local 1]]> -<![CDATA[init testGlobal local 2]]> +<![CDATA[cleanup testGlobal local=false]]> +<![CDATA[init testGlobal local=true]]> <![CDATA[global: false]]> <![CDATA[local: true]]> -<![CDATA[cleanup testGlobal local 2]]> -<![CDATA[init testGlobal local 1]]> +<![CDATA[cleanup testGlobal local=true]]> +<![CDATA[init testGlobal local=false]]> <![CDATA[global: true]]> <![CDATA[local: false]]> -<![CDATA[cleanup testGlobal local 1]]> -<![CDATA[init testGlobal local 2]]> +<![CDATA[cleanup testGlobal local=false]]> +<![CDATA[init testGlobal local=true]]> <![CDATA[global: true]]> <![CDATA[local: true]]> -<![CDATA[cleanup testGlobal local 2]]> +<![CDATA[cleanup testGlobal local=true]]> <![CDATA[skipping]]> -<![CDATA[init skipLocal local 1]]> +<![CDATA[init skipLocal local=false]]> <![CDATA[skipping]]> -<![CDATA[cleanup skipLocal local 1]]> -<![CDATA[init skipLocal local 2]]> +<![CDATA[cleanup skipLocal local=false]]> +<![CDATA[init skipLocal local=true]]> <![CDATA[skipping]]> -<![CDATA[cleanup skipLocal local 2]]> -<![CDATA[init skipSingle local 1]]> -<![CDATA[global: false local: false]]> -<![CDATA[cleanup skipSingle local 1]]> -<![CDATA[init skipSingle local 2]]> -<![CDATA[global: false local: true]]> -<![CDATA[cleanup skipSingle local 2]]> -<![CDATA[init skipSingle local 1]]> +<![CDATA[cleanup skipLocal local=true]]> +<![CDATA[init skipLocal local=false]]> +<![CDATA[skipping]]> +<![CDATA[cleanup skipLocal local=false]]> +<![CDATA[init skipLocal local=true]]> <![CDATA[skipping]]> -<![CDATA[cleanup skipSingle local 1]]> -<![CDATA[init skipSingle local 2]]> +<![CDATA[cleanup skipLocal local=true]]> +<![CDATA[init skipSingle local=false]]> +<![CDATA[global: false local: false]]> +<![CDATA[cleanup skipSingle local=false]]> +<![CDATA[init skipSingle local=true]]> +<![CDATA[Skipping]]> +<![CDATA[cleanup skipSingle local=true]]> +<![CDATA[init skipSingle local=false]]> +<![CDATA[Skipping]]> +<![CDATA[cleanup skipSingle local=false]]> +<![CDATA[init skipSingle local=true]]> <![CDATA[global: true local: true]]> -<![CDATA[cleanup skipSingle local 2]]> +<![CDATA[cleanup skipSingle local=true]]> <![CDATA[cleanupTestCase cleanupTestCase (null)]]> </system-err> </testsuite> diff --git a/tests/auto/testlib/selftests/expected_signaldumper.lightxml b/tests/auto/testlib/selftests/expected_signaldumper.lightxml new file mode 100644 index 0000000000..f68834e1a2 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.lightxml @@ -0,0 +1,578 @@ +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: QThread(_POINTER_) started ()]]></Description> +</Message> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="noConnections"> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="oneSlot"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="oneSlotOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="twoSlots"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="twoSlotsOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="signalForwarding"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="signalForwardingOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignal()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignal()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="slotEmittingSignal"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="slotEmittingSignalOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) emitSecondSignal()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="variousTypes"> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qListSignal (QList<int>())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector<int>())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector<int>&)@_POINTER_)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector<int>())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector<int>*)_POINTER_)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())]]></Description> +</Message> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: QThread(_POINTER_) finished ()]]></Description> +</Message> +<Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_signaldumper.tap b/tests/auto/testlib/selftests/expected_signaldumper.tap new file mode 100644 index 0000000000..04d7d94745 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.tap @@ -0,0 +1,151 @@ +TAP version 13 +# tst_Signaldumper +# Signal: QThread(_POINTER_) started () +ok 1 - initTestCase() +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +ok 2 - noConnections() +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 3 - oneSlot(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 4 - oneSlot(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 5 - oneSlotOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 6 - oneSlotOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 7 - twoSlots(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 8 - twoSlots(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +# Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 9 - twoSlotsOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 10 - twoSlotsOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 11 - signalForwarding(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 12 - signalForwarding(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) nestedSignal() +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char) +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Slot: SignalSlotClass(_POINTER_) nestedSignal() +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 13 - signalForwardingOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +# Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 14 - signalForwardingOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 15 - slotEmittingSignal(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 16 - slotEmittingSignal(queued) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Slot: SignalSlotClass(_POINTER_) emitSecondSignal() +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +ok 17 - slotEmittingSignalOldSyntax(direct) +# Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +# Signal: QEventDispatcherPlatform(_POINTER_) awake () +# Signal: SignalSlotClass(_POINTER_) nestedSignal () +ok 18 - slotEmittingSignalOldSyntax(queued) +# Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string)) +# Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_) +# Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string)) +# Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray)) +# Signal: SignalSlotClass(_POINTER_) qListSignal (QList<int>()) +# Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector<int>()) +# Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector<int>&)@_POINTER_) +# Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector<int>()) +# Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector<int>*)_POINTER_) +# Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal () +# Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +# Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +ok 19 - variousTypes() +ok 20 - cleanupTestCase() +# Signal: QThread(_POINTER_) finished () +1..20 +# tests 20 +# pass 20 +# fail 0 diff --git a/tests/auto/testlib/selftests/expected_signaldumper.teamcity b/tests/auto/testlib/selftests/expected_signaldumper.teamcity new file mode 100644 index 0000000000..3b8cf8c54f --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.teamcity @@ -0,0 +1,61 @@ +##teamcity[testSuiteStarted name='tst_Signaldumper' flowId='tst_Signaldumper'] +##teamcity[testStarted name='initTestCase()' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='initTestCase()' out='INFO: Signal: QThread(_POINTER_) started ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='initTestCase()' flowId='tst_Signaldumper'] +##teamcity[testStarted name='noConnections()' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='noConnections()' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))' flowId='tst_Signaldumper'] +##teamcity[testFinished name='noConnections()' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlot(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlot(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlot(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlot(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlot(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlot(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlotOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlotOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlotOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='oneSlotOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='oneSlotOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='oneSlotOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlots(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlots(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlots(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlots(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlots(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlots(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlotsOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlotsOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlotsOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='twoSlotsOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='twoSlotsOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='twoSlotsOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwarding(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwarding(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwarding(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwarding(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwarding(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwarding(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwardingOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwardingOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) nestedSignal()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char)|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Slot: SignalSlotClass(_POINTER_) nestedSignal()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwardingOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='signalForwardingOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='signalForwardingOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))|nINFO: Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='signalForwardingOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignal(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignal(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignal(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignal(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignal(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignal(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignalOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignalOldSyntax(direct)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Slot: SignalSlotClass(_POINTER_) emitSecondSignal()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignalOldSyntax(direct)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='slotEmittingSignalOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='slotEmittingSignalOldSyntax(queued)' out='INFO: Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()|nINFO: Signal: QEventDispatcherPlatform(_POINTER_) awake ()|nINFO: Signal: SignalSlotClass(_POINTER_) nestedSignal ()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='slotEmittingSignalOldSyntax(queued)' flowId='tst_Signaldumper'] +##teamcity[testStarted name='variousTypes()' flowId='tst_Signaldumper'] +##teamcity[testStdOut name='variousTypes()' out='INFO: Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string))|nINFO: Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_)|nINFO: Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string))|nINFO: Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray))|nINFO: Signal: SignalSlotClass(_POINTER_) qListSignal (QList<int>())|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector<int>())|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector<int>&)@_POINTER_)|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector<int>())|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector<int>*)_POINTER_)|nINFO: Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal ()|nINFO: Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())|nINFO: Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())' flowId='tst_Signaldumper'] +##teamcity[testFinished name='variousTypes()' flowId='tst_Signaldumper'] +##teamcity[testStarted name='cleanupTestCase()' flowId='tst_Signaldumper'] +##teamcity[testFinished name='cleanupTestCase()' flowId='tst_Signaldumper'] +##teamcity[testSuiteFinished name='tst_Signaldumper' flowId='tst_Signaldumper'] diff --git a/tests/auto/testlib/selftests/expected_signaldumper.txt b/tests/auto/testlib/selftests/expected_signaldumper.txt new file mode 100644 index 0000000000..f89c31afe5 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.txt @@ -0,0 +1,149 @@ +********* Start testing of tst_Signaldumper ********* +Config: Using QtTest library +INFO : tst_Signaldumper::initTestCase() Signal: QThread(_POINTER_) started () +PASS : tst_Signaldumper::initTestCase() +INFO : tst_Signaldumper::noConnections() Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::noConnections() Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +PASS : tst_Signaldumper::noConnections() +INFO : tst_Signaldumper::oneSlot(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlot(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlot(direct) +INFO : tst_Signaldumper::oneSlot(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlot(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlot(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlot(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlot(queued) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::oneSlotOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlotOldSyntax(direct) +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::oneSlotOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::oneSlotOldSyntax(queued) +INFO : tst_Signaldumper::twoSlots(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlots(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlots(direct) +INFO : tst_Signaldumper::twoSlots(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlots(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlots(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlots(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlots(queued) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) slotWithoutParameters() +INFO : tst_Signaldumper::twoSlotsOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlotsOldSyntax(direct) +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::twoSlotsOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::twoSlotsOldSyntax(queued) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwarding(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::signalForwarding(direct) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwarding(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwarding(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::signalForwarding(queued) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) nestedSignal() +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) nestedSignal() +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwardingOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::signalForwardingOldSyntax(direct) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m)) +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::signalForwardingOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::signalForwardingOldSyntax(queued) +INFO : tst_Signaldumper::slotEmittingSignal(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignal(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::slotEmittingSignal(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::slotEmittingSignal(direct) +INFO : tst_Signaldumper::slotEmittingSignal(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignal(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::slotEmittingSignal(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::slotEmittingSignal(queued) +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Slot: SignalSlotClass(_POINTER_) emitSecondSignal() +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Signal: SignalSlotClass(_POINTER_) nestedSignal () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) Signal: QEventDispatcherPlatform(_POINTER_) awake () +PASS : tst_Signaldumper::slotEmittingSignalOldSyntax(direct) +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) signalWithoutParameters () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) Signal: QEventDispatcherPlatform(_POINTER_) awake () +INFO : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) Signal: SignalSlotClass(_POINTER_) nestedSignal () +PASS : tst_Signaldumper::slotEmittingSignalOldSyntax(queued) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string)) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string)) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray)) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qListSignal (QList<int>()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector<int>()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector<int>&)@_POINTER_) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector<int>()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector<int>*)_POINTER_) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal () +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +INFO : tst_Signaldumper::variousTypes() Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant()) +PASS : tst_Signaldumper::variousTypes() +PASS : tst_Signaldumper::cleanupTestCase() +INFO : tst_Signaldumper::UnknownTestFunc() Signal: QThread(_POINTER_) finished () +Totals: 20 passed, 0 failed, 0 skipped, 0 blacklisted, 0ms +********* Finished testing of tst_Signaldumper ********* diff --git a/tests/auto/testlib/selftests/expected_signaldumper.xml b/tests/auto/testlib/selftests/expected_signaldumper.xml new file mode 100644 index 0000000000..82959c62df --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.xml @@ -0,0 +1,581 @@ +<?xml version="1.0" encoding="UTF-8"?> +<TestCase name="tst_Signaldumper"> +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: QThread(_POINTER_) started ()]]></Description> +</Message> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="noConnections"> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="oneSlot"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="oneSlotOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="twoSlots"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="twoSlotsOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="signalForwarding"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="signalForwardingOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignal()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignal()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="slotEmittingSignal"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="slotEmittingSignalOldSyntax"> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Slot: SignalSlotClass(_POINTER_) emitSecondSignal()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[direct]]></DataTag> +</Incident> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]></Description> +</Message> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[queued]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="variousTypes"> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray))]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qListSignal (QList<int>())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector<int>())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector<int>&)@_POINTER_)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector<int>())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector<int>*)_POINTER_)]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal ()]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())]]></Description> +</Message> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())]]></Description> +</Message> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<Message type="info" file="" line="0"> + <Description><![CDATA[Signal: QThread(_POINTER_) finished ()]]></Description> +</Message> +<Duration msecs="0"/> +</TestCase> diff --git a/tests/auto/testlib/selftests/expected_signaldumper.xunitxml b/tests/auto/testlib/selftests/expected_signaldumper.xunitxml new file mode 100644 index 0000000000..930dc97262 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_signaldumper.xunitxml @@ -0,0 +1,284 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<testsuite errors="125" failures="0" tests="12" name="tst_Signaldumper"> + <properties> + <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> + <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> + </properties> + <testcase result="pass" name="initTestCase"> + <!-- message="Signal: QThread(_POINTER_) started ()" type="info" --> + </testcase> + <testcase result="pass" name="noConnections"> + <!-- message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + </testcase> + <testcase result="pass" name="oneSlot"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + </testcase> + <testcase result="pass" name="oneSlotOldSyntax"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + </testcase> + <testcase result="pass" name="twoSlots"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + </testcase> + <testcase result="pass" name="twoSlotsOldSyntax"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + </testcase> + <testcase result="pass" name="signalForwarding"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + </testcase> + <testcase result="pass" name="signalForwardingOldSyntax"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) nestedSignal()" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char)" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) nestedSignal()" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + </testcase> + <testcase result="pass" name="slotEmittingSignal"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + </testcase> + <testcase result="pass" name="slotEmittingSignalOldSyntax"> + <!-- tag="direct" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="direct" message=" Slot: SignalSlotClass(_POINTER_) emitSecondSignal()" type="info" --> + <!-- tag="direct" message=" Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + <!-- tag="direct" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()" type="info" --> + <!-- tag="queued" message="Signal: QEventDispatcherPlatform(_POINTER_) awake ()" type="info" --> + <!-- tag="queued" message="Signal: SignalSlotClass(_POINTER_) nestedSignal ()" type="info" --> + </testcase> + <testcase result="pass" name="variousTypes"> + <!-- message="Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string))" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_)" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string))" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray))" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qListSignal (QList<int>())" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector<int>())" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector<int>&)@_POINTER_)" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector<int>())" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector<int>*)_POINTER_)" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal ()" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())" type="info" --> + <!-- message="Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())" type="info" --> + </testcase> + <testcase result="pass" name="cleanupTestCase"> + <!-- message="Signal: QThread(_POINTER_) finished ()" type="info" --> + </testcase> + <system-err> +<![CDATA[Signal: QThread(_POINTER_) started ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithParameters(int,char)]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) slotWithoutParameters()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignal()]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignalWithParameters(int,char)]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) nestedSignal()]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithParameters (int(242), char(m))]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[ Slot: SignalSlotClass(_POINTER_) emitSecondSignal()]]> +<![CDATA[ Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) signalWithoutParameters ()]]> +<![CDATA[Signal: QEventDispatcherPlatform(_POINTER_) awake ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) nestedSignal ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qStringSignal (QString(Test string))]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@_POINTER_)]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qStringConstRefSignal (QString(Test string))]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qByteArraySignal (QByteArray(Test bytearray))]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qListSignal (QList<int>())]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorSignal (QVector<int>())]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorRefSignal ((QVector<int>&)@_POINTER_)]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorConstRefSignal (QVector<int>())]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorConstPointerSignal ((const QVector<int>*)_POINTER_)]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qVectorPointerConstSignal ()]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())]]> +<![CDATA[Signal: SignalSlotClass(_POINTER_) qVariantSignal (QVariant())]]> +<![CDATA[Signal: QThread(_POINTER_) finished ()]]> + </system-err> +</testsuite> diff --git a/tests/auto/testlib/selftests/float/tst_float.cpp b/tests/auto/testlib/selftests/float/tst_float.cpp index 49d00ac0e0..cefd8a57c4 100644 --- a/tests/auto/testlib/selftests/float/tst_float.cpp +++ b/tests/auto/testlib/selftests/float/tst_float.cpp @@ -46,6 +46,55 @@ private slots: void compareFloatTests_data() const; }; +template<typename F> +static void nonFinite_data(F zero, F one) +{ + using Bounds = std::numeric_limits<F>; + + // QCOMPARE special-cases non-finite values + if (Bounds::has_quiet_NaN) { + const F nan = Bounds::quiet_NaN(); + QTest::newRow("should PASS: NaN == NaN") << nan << nan; + QTest::newRow("should FAIL: NaN != 0") << nan << zero; + QTest::newRow("should FAIL: 0 != NaN") << zero << nan; + QTest::newRow("should FAIL: NaN != 1") << nan << one; + QTest::newRow("should FAIL: 1 != NaN") << one << nan; + } + + if (Bounds::has_infinity) { + const F uge = Bounds::infinity(); + QTest::newRow("should PASS: inf == inf") << uge << uge; + QTest::newRow("should PASS: -inf == -inf") << -uge << -uge; + QTest::newRow("should FAIL: inf != -inf") << uge << -uge; + QTest::newRow("should FAIL: -inf != inf") << -uge << uge; + if (Bounds::has_quiet_NaN) { + const F nan = Bounds::quiet_NaN(); + QTest::newRow("should FAIL: inf != nan") << uge << nan; + QTest::newRow("should FAIL: nan != inf") << nan << uge; + QTest::newRow("should FAIL: -inf != nan") << -uge << nan; + QTest::newRow("should FAIL: nan != -inf") << nan << -uge; + } + QTest::newRow("should FAIL: inf != 0") << uge << zero; + QTest::newRow("should FAIL: 0 != inf") << zero << uge; + QTest::newRow("should FAIL: -inf != 0") << -uge << zero; + QTest::newRow("should FAIL: 0 != -inf") << zero << -uge; + QTest::newRow("should FAIL: inf != 1") << uge << one; + QTest::newRow("should FAIL: 1 != inf") << one << uge; + QTest::newRow("should FAIL: -inf != 1") << -uge << one; + QTest::newRow("should FAIL: 1 != -inf") << one << -uge; + + const F big = Bounds::max(); + QTest::newRow("should FAIL: inf != max") << uge << big; + QTest::newRow("should FAIL: inf != -max") << uge << -big; + QTest::newRow("should FAIL: max != inf") << big << uge; + QTest::newRow("should FAIL: -max != inf") << -big << uge; + QTest::newRow("should FAIL: -inf != max") << -uge << big; + QTest::newRow("should FAIL: -inf != -max") << -uge << -big; + QTest::newRow("should FAIL: max != -inf") << big << -uge; + QTest::newRow("should FAIL: -max != -inf") << -big << -uge; + } +} + void tst_float::doubleComparisons() const { QFETCH(double, operandLeft); @@ -58,65 +107,26 @@ void tst_float::doubleComparisons_data() const { QTest::addColumn<double>("operandLeft"); QTest::addColumn<double>("operandRight"); + double zero(0.), one(1.); - QTest::newRow("should PASS 1") << 0. << 0.; - QTest::newRow("should FAIL 1") << 1.00000 << 3.00000; - QTest::newRow("should FAIL 2") << 1.00000e-7 << 3.00000e-7; + QTest::newRow("should FAIL 1") << one << 3.; + QTest::newRow("should PASS 1") << zero << zero; + QTest::newRow("should FAIL 2") << 1.e-7 << 3.e-7; // QCOMPARE for doubles uses qFuzzyCompare(), which succeeds if the numbers // differ by no more than 1e-12 times the smaller value. Thus // QCOMPARE(1e12-2, 1e12-1) should fail, while QCOMPARE(1e12+1, 1e12+2) // should pass. - QTest::newRow("should PASS 2") << 1e12 + 1. << 1e12 + 2.; - QTest::newRow("should FAIL 3") << 1e12 - 1. << 1e12 - 2.; + QTest::newRow("should PASS 2") << 1e12 + one << 1e12 + 2.; + QTest::newRow("should FAIL 3") << 1e12 - one << 1e12 - 2.; // ... but rounding makes that a bit unrelaible when scaled close to the bounds. QTest::newRow("should PASS 3") << 1e-310 + 1e-322 << 1e-310 + 2e-322; QTest::newRow("should FAIL 4") << 1e-310 - 1e-322 << 1e-310 - 3e-322; QTest::newRow("should PASS 4") << 1e307 + 1e295 << 1e307 + 2e295; QTest::newRow("should FAIL 5") << 1e307 - 1e295 << 1e307 - 3e295; - // QCOMPARE special-cases non-finite values - if (std::numeric_limits<double>::has_quiet_NaN) { - const double nan = std::numeric_limits<double>::quiet_NaN(); - QTest::newRow("should PASS: NaN == NaN") << nan << nan; - QTest::newRow("should FAIL: NaN != 0") << nan << 0.; - QTest::newRow("should FAIL: 0 != NaN") << 0. << nan; - QTest::newRow("should FAIL: NaN != 1") << nan << 1.; - QTest::newRow("should FAIL: 1 != NaN") << 1. << nan; - } - if (std::numeric_limits<double>::has_infinity) { - const double uge = std::numeric_limits<double>::infinity(); - QTest::newRow("should PASS: inf == inf") << uge << uge; - QTest::newRow("should PASS: -inf == -inf") << -uge << -uge; - QTest::newRow("should FAIL: inf != -inf") << uge << -uge; - QTest::newRow("should FAIL: -inf != inf") << -uge << uge; - if (std::numeric_limits<double>::has_quiet_NaN) { - const double nan = std::numeric_limits<double>::quiet_NaN(); - QTest::newRow("should FAIL: inf != nan") << uge << nan; - QTest::newRow("should FAIL: nan != inf") << nan << uge; - QTest::newRow("should FAIL: -inf != nan") << -uge << nan; - QTest::newRow("should FAIL: nan != -inf") << nan << -uge; - } - QTest::newRow("should FAIL: inf != 0") << uge << 0.; - QTest::newRow("should FAIL: 0 != inf") << 0. << uge; - QTest::newRow("should FAIL: -inf != 0") << -uge << 0.; - QTest::newRow("should FAIL: 0 != -inf") << 0. << -uge; - QTest::newRow("should FAIL: inf != 1") << uge << 1.; - QTest::newRow("should FAIL: 1 != inf") << 1. << uge; - QTest::newRow("should FAIL: -inf != 1") << -uge << 1.; - QTest::newRow("should FAIL: 1 != -inf") << 1. << -uge; - - const double big = std::numeric_limits<double>::max(); - QTest::newRow("should FAIL: inf != max") << uge << big; - QTest::newRow("should FAIL: inf != -max") << uge << -big; - QTest::newRow("should FAIL: max != inf") << big << uge; - QTest::newRow("should FAIL: -max != inf") << -big << uge; - QTest::newRow("should FAIL: -inf != max") << -uge << big; - QTest::newRow("should FAIL: -inf != -max") << -uge << -big; - QTest::newRow("should FAIL: max != -inf") << big << -uge; - QTest::newRow("should FAIL: -max != -inf") << -big << -uge; - } + nonFinite_data(zero, one); } void tst_float::floatComparisons() const @@ -131,65 +141,26 @@ void tst_float::floatComparisons_data() const { QTest::addColumn<float>("operandLeft"); QTest::addColumn<float>("operandRight"); + float zero(0.f), one(1.f); - QTest::newRow("should FAIL 1") << 1.00000f << 3.00000f; - QTest::newRow("should PASS 1") << 0.f << 0.f; - QTest::newRow("should FAIL 2") << 1.00000e-7f << 3.00000e-7f; + QTest::newRow("should FAIL 1") << one << 3.f; + QTest::newRow("should PASS 1") << zero << zero; + QTest::newRow("should FAIL 2") << 1.e-7f << 3.e-7f; // QCOMPARE for floats uses qFuzzyCompare(), which succeeds if the numbers // differ by no more than 1e-5 times the smaller value. Thus // QCOMPARE(1e5-2, 1e5-1) should fail, while QCOMPARE(1e5+1, 1e5+2) // should pass. - QTest::newRow("should PASS 2") << 1e5f + 1.f << 1e5f + 2.f; - QTest::newRow("should FAIL 3") << 1e5f - 1.f << 1e5f - 2.f; + QTest::newRow("should PASS 2") << 1e5f + one << 1e5f + 2.f; + QTest::newRow("should FAIL 3") << 1e5f - one << 1e5f - 2.f; // ... but rounding makes that a bit unrelaible when scaled close to the bounds. QTest::newRow("should PASS 3") << 1e-39f + 1e-44f << 1e-39f + 2e-44f; QTest::newRow("should FAIL 4") << 1e-39f - 1e-44f << 1e-39f - 3e-44f; QTest::newRow("should PASS 4") << 1e38f + 1e33f << 1e38f + 2e33f; QTest::newRow("should FAIL 5") << 1e38f - 1e33f << 1e38f - 3e33f; - // QCOMPARE special-cases non-finite values - if (std::numeric_limits<float>::has_quiet_NaN) { - const float nan = std::numeric_limits<float>::quiet_NaN(); - QTest::newRow("should PASS: NaN == NaN") << nan << nan; - QTest::newRow("should FAIL: NaN != 0") << nan << 0.f; - QTest::newRow("should FAIL: 0 != NaN") << 0.f << nan; - QTest::newRow("should FAIL: NaN != 1") << nan << 1.f; - QTest::newRow("should FAIL: 1 != NaN") << 1.f << nan; - } - if (std::numeric_limits<float>::has_infinity) { - const float uge = std::numeric_limits<float>::infinity(); - QTest::newRow("should PASS: inf == inf") << uge << uge; - QTest::newRow("should PASS: -inf == -inf") << -uge << -uge; - QTest::newRow("should FAIL: inf != -inf") << uge << -uge; - QTest::newRow("should FAIL: -inf != inf") << -uge << uge; - if (std::numeric_limits<float>::has_quiet_NaN) { - const float nan = std::numeric_limits<float>::quiet_NaN(); - QTest::newRow("should FAIL: inf != nan") << uge << nan; - QTest::newRow("should FAIL: nan != inf") << nan << uge; - QTest::newRow("should FAIL: -inf != nan") << -uge << nan; - QTest::newRow("should FAIL: nan != -inf") << nan << -uge; - } - QTest::newRow("should FAIL: inf != 0") << uge << 0.f; - QTest::newRow("should FAIL: 0 != inf") << 0.f << uge; - QTest::newRow("should FAIL: -inf != 0") << -uge << 0.f; - QTest::newRow("should FAIL: 0 != -inf") << 0.f << -uge; - QTest::newRow("should FAIL: inf != 1") << uge << 1.f; - QTest::newRow("should FAIL: 1 != inf") << 1.f << uge; - QTest::newRow("should FAIL: -inf != 1") << -uge << 1.f; - QTest::newRow("should FAIL: 1 != -inf") << 1.f << -uge; - - const float big = std::numeric_limits<float>::max(); - QTest::newRow("should FAIL: inf != max") << uge << big; - QTest::newRow("should FAIL: inf != -max") << uge << -big; - QTest::newRow("should FAIL: max != inf") << big << uge; - QTest::newRow("should FAIL: -max != inf") << -big << uge; - QTest::newRow("should FAIL: -inf != max") << -uge << big; - QTest::newRow("should FAIL: -inf != -max") << -uge << -big; - QTest::newRow("should FAIL: max != -inf") << big << -uge; - QTest::newRow("should FAIL: -max != -inf") << -big << -uge; - } + nonFinite_data(zero, one); } void tst_float::float16Comparisons() const @@ -204,28 +175,22 @@ void tst_float::float16Comparisons_data() const { QTest::addColumn<qfloat16>("operandLeft"); QTest::addColumn<qfloat16>("operandRight"); + qfloat16 zero(0), one(1); - QTest::newRow("should SUCCEED 1") - << qfloat16(0) - << qfloat16(0); - - QTest::newRow("should FAIL 1") - << qfloat16(1.000) - << qfloat16(3.000); - - QTest::newRow("should FAIL 2") - << qfloat16(1.000e-4f) - << qfloat16(3.000e-4f); + QTest::newRow("should FAIL 1") << one << qfloat16(3); + QTest::newRow("should PASS 1") << zero << zero; + QTest::newRow("should FAIL 2") << qfloat16(1e-4f) << qfloat16(3e-4f); // QCOMPARE for qfloat16s uses qFuzzyCompare() - - QTest::newRow("should FAIL 3") - << qfloat16(98) - << qfloat16(99); - - QTest::newRow("should SUCCEED 2") - << qfloat16(1001) - << qfloat16(1002); + QTest::newRow("should PASS 2") << qfloat16(1001) << qfloat16(1002); + QTest::newRow("should FAIL 3") << qfloat16(98) << qfloat16(99); + // ... which gets a bit unreliable near to the type's bounds + QTest::newRow("should PASS 3") << qfloat16(6e-5f) + qfloat16(6e-7f) << qfloat16(6e-5f) + qfloat16(11e-7f); + QTest::newRow("should FAIL 4") << qfloat16(6e-5f) - qfloat16(7e-7f) << qfloat16(6e-5f) - qfloat16(13e-7f); + QTest::newRow("should PASS 4") << qfloat16(6e4) + qfloat16(700) << qfloat16(6e4) + qfloat16(1200); + QTest::newRow("should FAIL 5") << qfloat16(6e4) - qfloat16(600) << qfloat16(6e4) - qfloat16(1200); + + nonFinite_data(zero, one); } void tst_float::compareFloatTests() const diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index 9ec87c8fc6..48ecbf0289 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -92,6 +92,17 @@ class Cleaner (object): (r'(Loc: \[[^[\]()]+)\(\d+\)', r'\1(0)'), # txt (r'(\[Loc: [^[\]()]+)\(\d+\)', r'\1(0)'), # teamcity (r'(<(?:Incident|Message)\b.*\bfile=.*\bline=)"\d+"', r'\1"0"'), # lightxml, xml + # Pointers printed by signal dumper: + (r'\(\b[a-f0-9]{8,}\b\)', r'(_POINTER_)'), + # Example/for reference: + # ((QString&)@55f5fbb8dd40) + # ((const QVector<int>*)7ffd671d4558) + (r'\((\((?:const )?\w+(?:<[^>]+>)?[*&]*\)@?)\b[a-f\d]{8,}\b\)', r'(\1_POINTER_)'), + # For xml output there is no '<', '>' or '&', so we need an alternate version for that: + # ((QVector<int>&)@5608b455e640) + (r'\((\((?:const )?\w+(?:<(?:[^&]|&(?!gt;))*>)?(?:\*|&)?\)@?)[a-z\d]+\b\)', r'(\1_POINTER_)'), + # QEventDispatcher{Glib,Win32,etc.} + (r'\bQEventDispatcher\w+\b', r'QEventDispatcherPlatform'), ), precook = re.compile): """Private implementation details of __init__().""" @@ -296,6 +307,7 @@ def generateTestData(testname, clean, "benchlibcounting": "-eventcounter", "printdatatags": "-datatags", "printdatatagswithglobaltags": "-datatags", + "signaldumper": "-vs", "silent": "-silent", "verbose1": "-v1", "verbose2": "-v2", diff --git a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp index 6c0ae1f43c..3c5c2c8f37 100644 --- a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp +++ b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp @@ -66,9 +66,10 @@ void tst_globaldata::initTestCase() void tst_globaldata::initTestCase_data() { - QTest::addColumn<bool>("booli"); - QTest::newRow("1") << false; - QTest::newRow("2") << true; + // QFETCH_GLOBAL shall iterate these, for every test: + QTest::addColumn<bool>("global"); + QTest::newRow("global=false") << false; + QTest::newRow("global=true") << true; } void tst_globaldata::cleanupTestCase() @@ -94,41 +95,42 @@ void tst_globaldata::cleanup() void tst_globaldata::testGlobal_data() { - QTest::addColumn<bool>("booll"); - QTest::newRow("local 1") << false; - QTest::newRow("local 2") << true; + QTest::addColumn<bool>("local"); + QTest::newRow("local=false") << false; + QTest::newRow("local=true") << true; } void tst_globaldata::testGlobal() { - QFETCH_GLOBAL(bool, booli); - qDebug() << "global:" << booli; - QFETCH(bool, booll); - qDebug() << "local:" << booll; + QFETCH_GLOBAL(bool, global); + qDebug() << "global:" << global; + QFETCH(bool, local); + qDebug() << "local:" << local; } void tst_globaldata::skip_data() { - QTest::addColumn<bool>("booll"); - QTest::newRow("local 1") << false; - QTest::newRow("local 2") << true; - + testGlobal_data(); QSKIP("skipping"); } void tst_globaldata::skip() { - qDebug() << "this line should never be reached"; + // A skip in _data() causes the whole test to be skipped, for all global rows. + QVERIFY(!"This line should never be reached."); } void tst_globaldata::skipSingle() { - QFETCH_GLOBAL(bool, booli); - QFETCH(bool, booll); - - if (booli && !booll) - QSKIP("skipping"); - qDebug() << "global:" << booli << "local:" << booll; + QFETCH_GLOBAL(bool, global); + QFETCH(bool, local); + + // A skip in the last run of one global row used to suppress the test in the + // next global row (where a skip in an earlier run of the first row did not). + if (global ^ local) + QSKIP("Skipping"); + qDebug() << "global:" << global << "local:" << local; + QCOMPARE(global, local); } void tst_globaldata::skipLocal() diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index b4568dd3e1..2cad0b7e17 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -1,5 +1,4 @@ SUBPROGRAMS = \ - #alive \ assert \ badxml \ benchlibcallgrind \ @@ -37,6 +36,7 @@ SUBPROGRAMS = \ printdatatagswithglobaltags \ qexecstringlist \ silent \ + signaldumper \ singleskip \ skip \ skipcleanup \ diff --git a/tests/auto/testlib/selftests/signaldumper/signaldumper.pro b/tests/auto/testlib/selftests/signaldumper/signaldumper.pro new file mode 100644 index 0000000000..8780b18419 --- /dev/null +++ b/tests/auto/testlib/selftests/signaldumper/signaldumper.pro @@ -0,0 +1,9 @@ +SOURCES += tst_signaldumper.cpp +QT = core testlib-private + +macos:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = signaldumper + +include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp b/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp new file mode 100644 index 0000000000..f6cd0d510e --- /dev/null +++ b/tests/auto/testlib/selftests/signaldumper/tst_signaldumper.cpp @@ -0,0 +1,417 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QCoreApplication> +#include <QtTest/QtTest> +#include <private/qtestlog_p.h> + +class tst_Signaldumper : public QObject +{ + Q_OBJECT + + void addConnectionTypeData(); + +private slots: + void noConnections(); + void oneSlot_data(); + void oneSlot(); + void oneSlotOldSyntax_data(); + void oneSlotOldSyntax(); + void twoSlots_data(); + void twoSlots(); + void twoSlotsOldSyntax_data(); + void twoSlotsOldSyntax(); + void signalForwarding_data(); + void signalForwarding(); + void signalForwardingOldSyntax_data(); + void signalForwardingOldSyntax(); + void slotEmittingSignal_data(); + void slotEmittingSignal(); + void slotEmittingSignalOldSyntax_data(); + void slotEmittingSignalOldSyntax(); + + void variousTypes(); +}; + +void tst_Signaldumper::addConnectionTypeData() +{ + QTest::addColumn<Qt::ConnectionType>("connectionType"); + QTest::newRow("direct") << Qt::ConnectionType::DirectConnection; + QTest::newRow("queued") << Qt::ConnectionType::QueuedConnection; +} + +/* + Simple class to keep the slots and signals separate from the test +*/ +class SignalSlotClass : public QObject +{ + Q_OBJECT + +public: + SignalSlotClass(); + +public slots: + void slotWithoutParameters() {} + void slotWithParameters(int i, char c) { Q_UNUSED(i); Q_UNUSED(c); } + void emitSecondSignal() { emit nestedSignal(); } + +signals: + void signalWithoutParameters(); + void signalWithParameters(int i, char c); + + void nestedSignal(); + void nestedSignalWithParameters(int i, char c); + + // For the "variousTypes" test + void qStringSignal(QString string); + void qStringRefSignal(QString &string); + void qStringConstRefSignal(const QString &string); + void qByteArraySignal(QByteArray byteArray); + void qListSignal(QList<int> list); + void qVectorSignal(QVector<int> vector); + void qVectorRefSignal(QVector<int> &vector); + void qVectorConstRefSignal(const QVector<int> &vector); + void qVectorConstPointerSignal(const QVector<int> *vector); + void qVectorPointerConstSignal(QVector<int> *const vector); + void qVariantSignal(QVariant variant); +}; + +SignalSlotClass::SignalSlotClass() +{ + // For printing signal argument in "variousTypes" test + qRegisterMetaType<QVector<int>>(); + qRegisterMetaType<QList<int>>(); +} + +void tst_Signaldumper::noConnections() +{ + SignalSlotClass signalSlotOwner; + + emit signalSlotOwner.signalWithoutParameters(); + emit signalSlotOwner.signalWithParameters(242, 'm'); +} + +void tst_Signaldumper::oneSlot_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::oneSlot() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to no parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::oneSlotOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::oneSlotOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithParameters(int, char)), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameters to no parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::twoSlots_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::twoSlots() +{ + QFETCH(Qt::ConnectionType, connectionType); + + // Now, instead of creating two slots or two objects, we will just do the same connection twice. + // The same slot will then be invoked twice. + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + auto connection2 = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithParameters, connectionType); + connection2 = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to no parameters + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + connection2 = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::slotWithoutParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); +} + +void tst_Signaldumper::twoSlotsOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::twoSlotsOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + // Now, instead of creating two slots or two objects, we will just do the same connection twice. + // The same slot will then be invoked twice. + + SignalSlotClass signalSlotOwner; + // parameterless to parameterless + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + auto connection2 = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithParameters(int, char)), connectionType); + connection2 = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithParameters(int, char)), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); + + // parameters to no parameters + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + connection2 = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SLOT(slotWithoutParameters()), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + disconnect(connection2); +} + +void tst_Signaldumper::signalForwarding_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::signalForwarding() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + // parameterless signal to parameterless signal + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::nestedSignal, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameter(full) signal + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::nestedSignalWithParameters, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameterless signal + connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithParameters, + &signalSlotOwner, &SignalSlotClass::nestedSignal, connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::signalForwardingOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::signalForwardingOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + // parameterless signal to parameterless signal + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SIGNAL(nestedSignal()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameter(full) signal + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SIGNAL(nestedSignalWithParameters(int, char)), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); + + // parameter(full) signal to parameterless signal + connection = connect(&signalSlotOwner, SIGNAL(signalWithParameters(int, char)), + &signalSlotOwner, SIGNAL(nestedSignal()), connectionType); + emit signalSlotOwner.signalWithParameters(242, 'm'); + + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::slotEmittingSignal_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::slotEmittingSignal() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + auto connection = connect(&signalSlotOwner, &SignalSlotClass::signalWithoutParameters, + &signalSlotOwner, &SignalSlotClass::emitSecondSignal, connectionType); + emit signalSlotOwner.signalWithoutParameters(); + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::slotEmittingSignalOldSyntax_data() +{ + addConnectionTypeData(); +} + +void tst_Signaldumper::slotEmittingSignalOldSyntax() +{ + QFETCH(Qt::ConnectionType, connectionType); + + SignalSlotClass signalSlotOwner; + + auto connection = connect(&signalSlotOwner, SIGNAL(signalWithoutParameters()), + &signalSlotOwner, SLOT(emitSecondSignal()), connectionType); + emit signalSlotOwner.signalWithoutParameters(); + QCoreApplication::processEvents(); + disconnect(connection); +} + +void tst_Signaldumper::variousTypes() +{ + SignalSlotClass signalSlotOwner; + QString string = QString::fromLatin1("Test string"); + emit signalSlotOwner.qStringSignal(string); + emit signalSlotOwner.qStringRefSignal(string); + emit signalSlotOwner.qStringConstRefSignal(string); + emit signalSlotOwner.qByteArraySignal(QByteArray("Test bytearray")); + + QList<int> list{1, 2, 3, 242}; + emit signalSlotOwner.qListSignal(list); + + QVector<int> vector{1, 2, 3, 242}; + emit signalSlotOwner.qVectorSignal(vector); + emit signalSlotOwner.qVectorRefSignal(vector); + emit signalSlotOwner.qVectorConstRefSignal(vector); + emit signalSlotOwner.qVectorConstPointerSignal(&vector); + emit signalSlotOwner.qVectorPointerConstSignal(&vector); + + QVariant variant = 24; + emit signalSlotOwner.qVariantSignal(variant); + variant = QVariant(string); + emit signalSlotOwner.qVariantSignal(variant); +} + +QTEST_MAIN(tst_Signaldumper) +#include "tst_signaldumper.moc" diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp index 97fbbfd30a..cf3c35dec4 100644 --- a/tests/auto/testlib/selftests/silent/tst_silent.cpp +++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp @@ -72,6 +72,17 @@ void tst_Silent::xpass() QVERIFY2(true, "This test should XPASS"); } +#ifndef Q_OS_WIN +#include <signal.h> +#include <setjmp.h> + +static jmp_buf state; +static void abort_handler(int signal) +{ + longjmp(state, 1); +} +#endif + void tst_Silent::messages() { qWarning("This is a warning that should not appear in silent test output"); @@ -80,7 +91,15 @@ void tst_Silent::messages() qCritical("This is a critical message that should not appear in silent test output"); qInfo("This is an info message that should not appear in silent test output"); QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); - qFatal("This is a fatal error message that should still appear in silent test output"); + +#ifndef Q_OS_WIN + // We're testing qFatal, but we don't want to actually std::abort() ! + auto prior = signal(SIGABRT, abort_handler); + if (setjmp(state)) + signal(SIGABRT, prior); + else +#endif + qFatal("This is a fatal error message that should still appear in silent test output"); } QTEST_MAIN(tst_Silent) diff --git a/tests/auto/testlib/selftests/sleep/tst_sleep.cpp b/tests/auto/testlib/selftests/sleep/tst_sleep.cpp index b7b141afd0..95cb68521d 100644 --- a/tests/auto/testlib/selftests/sleep/tst_sleep.cpp +++ b/tests/auto/testlib/selftests/sleep/tst_sleep.cpp @@ -28,6 +28,7 @@ #include <QtCore/QCoreApplication> +#include <QtCore/QElapsedTimer> #include <QtTest/QtTest> class tst_Sleep: public QObject @@ -41,7 +42,7 @@ private slots: void tst_Sleep::sleep() { - QTime t; + QElapsedTimer t; t.start(); QTest::qSleep(100); diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 3ef15b9261..1326b96177 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -439,7 +439,6 @@ void tst_Selftests::runSubTest_data() QTest::addColumn<bool>("crashes"); QStringList tests = QStringList() -// << "alive" // timer dependent #if !defined(Q_OS_WIN) // On windows, assert does nothing in release mode and blocks execution // with a popup window in debug mode. @@ -488,6 +487,7 @@ void tst_Selftests::runSubTest_data() << "printdatatags" << "printdatatagswithglobaltags" << "qexecstringlist" + << "signaldumper" << "silent" << "singleskip" << "skip" @@ -553,6 +553,9 @@ void tst_Selftests::runSubTest_data() else if (subtest == "printdatatagswithglobaltags") { arguments << "-datatags"; } + else if (subtest == "signaldumper") { + arguments << "-vs"; + } else if (subtest == "silent") { arguments << "-silent"; } @@ -953,6 +956,29 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir, if (actualLine.startsWith(QLatin1String("Totals:")) && expectedLine.startsWith(QLatin1String("Totals:"))) return true; + const QLatin1String pointerPlaceholder("_POINTER_"); + if (expectedLine.contains(pointerPlaceholder) + && (expectedLine.contains(QLatin1String("Signal: ")) + || expectedLine.contains(QLatin1String("Slot: ")))) { + QString actual = actualLine; + // We don't care about the pointer of the object to whom the signal belongs, so we + // replace it with _POINTER_, e.g.: + // Signal: SignalSlotClass(7ffd72245410) signalWithoutParameters () + // Signal: QThread(7ffd72245410) started () + // After this instance pointer we may have further pointers and + // references (with an @ prefix) as parameters of the signal or + // slot being invoked. + // Signal: SignalSlotClass(_POINTER_) qStringRefSignal ((QString&)@55f5fbb8dd40) + actual.replace(QRegularExpression("\\b[a-f0-9]{8,}\\b"), pointerPlaceholder); + // Also change QEventDispatcher{Glib,Win32,etc.} to QEventDispatcherPlatform + actual.replace(QRegularExpression("\\b(QEventDispatcher)\\w+\\b"), QLatin1String("\\1Platform")); + if (actual != expectedLine) { + *errorMessage = msgMismatch(actual, expectedLine); + return false; + } + return true; + } + *errorMessage = msgMismatch(actualLine, expectedLine); return false; } diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri deleted file mode 100644 index 26e7f6ab8a..0000000000 --- a/tests/auto/testserver.pri +++ /dev/null @@ -1,216 +0,0 @@ -# Integrating docker-based test servers into Qt Test framework -# -# This file adds support for docker-based test servers built by testcase -# projects that need them. To enable this feature, any automated test can -# include testserver.pri in its project file. This instructs qmake to insert -# additional targets into the generated Makefile. The 'check' target then brings -# up test servers before running the testcase, and shuts them down afterwards. -# -# TESTSERVER_COMPOSE_FILE -# - Contains the path of docker-compose file -# This configuration file defines the services used for autotests. It tells the -# docker engine how to build up the docker images and containers. In qtbase, a -# shared docker-compose file is located in the tests folder. -# Example: TESTSERVER_COMPOSE_FILE = \ -# $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml -# -# The user must run the provisioning scripts in advance before attempting to -# build the test servers. The docker_testserver.sh script is used to build up -# the docker images into the docker-cache. It handles the immutable parts of the -# server installation that rarely need adjustment, such as downloading packages. -# Example: qt5/coin/provisioning/.../testserver/docker_testserver.sh -# -# QT_TEST_SERVER_LIST -# - A list of test servers to bring up for this testcase -# These test servers should be defined in $$TESTSERVER_COMPOSE_FILE. Each -# testcase can define the test servers it depends on. -# Example: QT_TEST_SERVER_LIST = apache2 squid vsftpd ftp-proxy danted -# -# Pre-processor defines needed for the application: -# QT_TEST_SERVER -# - A preprocessor macro used for testcase to change testing parameters at -# compile time -# This macro is predefined for docker-based test servers and is passed as a -# compiler option (-DQT_TEST_SERVER). The testcase can then check whether -# docker-based servers are in use and change the testing parameters, such as -# host name or port number, at compile time. An example can be found in -# network-settings.h. -# -# Example: -# #if defined(QT_TEST_SERVER) -# Change the testing parameters at compile time -# #endif -# -# QT_TEST_SERVER_DOMAIN -# - A preprocessor macro that holds the server domain name -# Provided for the helper functions in network-settings.h. Use function -# serverDomainName() in your application instead. -# -# Additional make targets: -# 1. check_network - A renamed target from the check target of testcase feature. -# 2. testserver_clean - Clean up server containers/images and tidy away related -# files. - -# The docker test server should only be integrated in the leaf Makefile. -# If debug_and_release option is in use, skip the meta-Makefile except for -# Makefile.Debug and Makefile.Release. -debug_and_release:!build_pass: return() - -DOCKER_ENABLED = 1 - -equals(QMAKE_HOST.os, Darwin) { - DOCKER_ENABLED = 0 - message("Not using docker network test server on macOS, see QTQAINFRA-2717 and QTQAINFRA-2750") -} - -TESTSERVER_VERSION = "" - -equals(DOCKER_ENABLED, 1) { - TESTSERVER_VERSION = $$system(docker-compose --version) -} - -isEmpty(TESTSERVER_VERSION) { - # Make check with server "qt-test-server.qt-test-net" as a fallback -} else { - # Make check with docker test servers - equals(QMAKE_HOST.os, Linux) { - # For the platform supporting docker bridge network, each container is - # assigned a unique hostname and connected to the same network domain - # to communicate with the others. - DEFINES += QT_TEST_SERVER_NAME - DNSDOMAIN = test-net.qt.local - } else { - # For the others, the containers are deployed into a virtual machine - # using the host network. All the containers share the same hostname of - # the virtual machine, and they are connected to the same network domain. - # NOTE: In Windows, Apple Bonjour only works within a single local domain. - DNSDOMAIN = local - } - - equals(QMAKE_HOST.os, Darwin) { - # There is no docker bridge on macOS. It is impossible to ping a container. - # Docker docs recommends using port mapping to connect to a container; - # but it causes a port conflict if the user is running a service that - # binds the same port on the host. An alternative solution is to deploy - # the docker environment into VirtualBox using docker-machine. - TESTSERVER_COMPOSE_FILE = \ - $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-macOS.yml - - # The connection configuration for the target machine - MACHINE_CONFIG = $(shell docker-machine config qt-test-server) - - # The environment variables passed to the docker-compose file - TEST_ENV = 'MACHINE_IP=$(shell docker-machine ip qt-test-server)' - TEST_ENV += 'TEST_DOMAIN=$$DNSDOMAIN' - TEST_CMD = env - } else:equals(QMAKE_HOST.os, Windows) { - # There is no docker bridge on Windows. It is impossible to ping a container. - # Use docker-machine to deploy the docker environment into VirtualBox. - TESTSERVER_COMPOSE_FILE = \ - $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-windows.yml - - # The connection configuration for the target machine - MACHINE_CONFIG = (docker-machine config qt-test-server) - - # The environment variables passed to the docker-compose file - TEST_ENV = '\$\$env:MACHINE_IP = docker-machine ip qt-test-server;' - TEST_ENV += '\$\$env:TEST_DOMAIN = $$shell_quote(\"$$DNSDOMAIN\");' - - # Docker-compose CLI environment variables: - # Enable path conversion from Windows-style to Unix-style in volume definitions. - TEST_ENV += '\$\$env:COMPOSE_CONVERT_WINDOWS_PATHS = $$shell_quote(\"true\");' - - TEST_CMD = 'PowerShell -noprofile' - CONFIG += PowerShell - } else { - TESTSERVER_COMPOSE_FILE = $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml - - # The environment variables passed to the docker-compose file - TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN' - TEST_CMD = env - } - - # The domain name is relevant to https keycert (qnetworkreply/crts/qt-test-net-cacert.pem). - DEFINES += QT_TEST_SERVER QT_TEST_SERVER_DOMAIN=$$shell_quote(\"$${DNSDOMAIN}\") - - # Ensure that the docker-compose file is provided. It is a configuration - # file which is mandatory for all docker-compose commands. You can get more - # detail from the description of TESTSERVER_COMPOSE_FILE above. There is - # also an example showing how to configure it manually. - FILE_PRETEST_MSG = "Project variable 'TESTSERVER_COMPOSE_FILE' is not set" - PowerShell { - testserver_pretest.commands = echo $$TESTSERVER_VERSION && - testserver_pretest.commands += \ - $$TEST_CMD if ([String]::IsNullOrEmpty($$shell_quote(\"$$TESTSERVER_COMPOSE_FILE\"))) \ - {Write-Error $$shell_quote(\"$$FILE_PRETEST_MSG\")} && - } else { - testserver_pretest.commands = $(info "testserver:" $$TESTSERVER_VERSION) - testserver_pretest.commands += $(if $$TESTSERVER_COMPOSE_FILE,,$(error $$FILE_PRETEST_MSG)) - } - - # Make sure docker-machine is both created and running. The docker_machine - # script is used to deploy the docker environment into VirtualBox. - # Example: qt5/coin/provisioning/common/shared/testserver/docker_machine.sh - !isEmpty(MACHINE_CONFIG) { - MACHINE_LIST_CMD = docker-machine ls -q --filter "Name=^qt-test-server\$\$" - MACHINE_LIST_MSG = "Docker machine qt-test-server not found" - PowerShell { - testserver_pretest.commands += $$TEST_CMD if (!($$MACHINE_LIST_CMD)) \ - {Write-Error $$shell_quote(\"$$MACHINE_LIST_MSG\")} && - } else { - testserver_pretest.commands += \ - $(if $(shell $$MACHINE_LIST_CMD),,$(error $$MACHINE_LIST_MSG)) - } - - MACHINE_STATE_CMD = \ - docker-machine ls -q --filter "State=Running" --filter "Name=^qt-test-server\$\$" - MACHINE_START_CMD = docker-machine start qt-test-server - MACHINE_RECERT = docker-machine regenerate-certs -f qt-test-server - PowerShell { - testserver_pretest.commands += \ - $$TEST_CMD if (!($$MACHINE_STATE_CMD)) {$$MACHINE_START_CMD; $$MACHINE_RECERT} && - } else { - testserver_pretest.commands += \ - $(if $(shell $$MACHINE_STATE_CMD),,\ - $(shell $$MACHINE_START_CMD > /dev/null && $$MACHINE_RECERT > /dev/null)) - } - } - - # Before starting the test servers, it requires the user to run the setup - # script (coin/provisioning/.../testserver/docker_testserver.sh) in advance. - IMAGE_PRETEST_CMD = docker $$MACHINE_CONFIG images -aq "qt-test-server-*" - IMAGE_PRETEST_MSG = "Docker image qt-test-server-* not found" - PowerShell { - testserver_pretest.commands += $$TEST_CMD if (!($$IMAGE_PRETEST_CMD)) \ - {Write-Error $$shell_quote(\"$$IMAGE_PRETEST_MSG\")} - } else { - testserver_pretest.commands += \ - $(if $(shell $$IMAGE_PRETEST_CMD),,$(error $$IMAGE_PRETEST_MSG)) - } - - # Rename the check target of testcase feature - check.target = check_network - testserver_test.target = check - - # Pretesting test servers environment - testserver_test.depends = testserver_pretest - - # Bring up test servers and make sure the services are ready. - !isEmpty(TEST_CMD): testserver_test.commands = $$TEST_CMD $$TEST_ENV - testserver_test.commands += docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE up \ - --detach --force-recreate --timeout 1 $${QT_TEST_SERVER_LIST} && - - # Check test cases with docker-based test servers. - testserver_test.commands += $(MAKE) -f $(MAKEFILE) check_network && - - # Stop and remove test servers after testing. - !isEmpty(TEST_CMD): testserver_test.commands += $$TEST_CMD $$TEST_ENV - testserver_test.commands += docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE down \ - --timeout 1 - - # Destroy test servers and tidy away related files. - testserver_clean.commands = docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE down \ - --rmi all - - QMAKE_EXTRA_TARGETS += testserver_pretest testserver_test testserver_clean -} diff --git a/tests/auto/tools/moc/cxx-attributes.h b/tests/auto/tools/moc/cxx-attributes.h new file mode 100644 index 0000000000..eff6a3ec41 --- /dev/null +++ b/tests/auto/tools/moc/cxx-attributes.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CXXATTRIBUTE_H +#define CXXATTRIBUTE_H + +#include <QtCore/QObject> + +class CppAttribute : public QObject +{ + Q_OBJECT +signals: + [[deprecated]] void deprecatedSignal(); + +public slots: + [[deprecated]] void deprecatedSlot() {} + [[deprecated]] [[tst_moc::maybe_unused]] int deprecatedSlot2() { return 42; } + [[deprecated("reason")]] void deprecatedReason() {} + [[deprecated("reason[")]] void deprecatedReasonWithLBRACK() {} + [[deprecated("reason[[")]] void deprecatedReasonWith2LBRACK() {} + [[deprecated("reason]")]] void deprecatedReasonWithRBRACK() {} + [[deprecated("reason]]")]] void deprecatedReasonWith2RBRACK() {} + void slotWithArguments([[tst_moc::maybe_unused]] int) {} +#if !defined(_MSC_VER) || _MSC_VER >= 1912 + // On MSVC it causes: + // moc_cxx-attributes.cpp(133): fatal error C1001: An internal error has occurred in the compiler. + Q_INVOKABLE [[tst_moc::noreturn]] void noreturnSlot() { throw "unused"; } + [[tst_moc::noreturn]] Q_SCRIPTABLE void noreturnSlot2() { throw "unused"; } + [[deprecated]] int returnInt() { return 0; } + Q_SLOT [[tst_moc::noreturn]] [[deprecated]] void noreturnDeprecatedSlot() { throw "unused"; } + Q_INVOKABLE void noreturnSlot3() [[tst_moc::noreturn]] { throw "unused"; } +#endif +}; + +#ifdef Q_MOC_RUN +# define TEST_COMPILER_DEPRECATION [[deprecated]] +# define TEST_COMPILER_DEPRECATION_X(x) [[deprecated(x)]] +#else +# define TEST_COMPILER_DEPRECATION Q_DECL_ENUMERATOR_DEPRECATED +# define TEST_COMPILER_DEPRECATION_X(x) Q_DECL_ENUMERATOR_DEPRECATED_X(x) +#endif + +namespace TestQNamespaceDeprecated { + Q_NAMESPACE + enum class TestEnum1 { + Key1 = 11, + Key2 TEST_COMPILER_DEPRECATION, + Key3 TEST_COMPILER_DEPRECATION_X("reason"), + Key4 TEST_COMPILER_DEPRECATION_X("reason["), + Key5 TEST_COMPILER_DEPRECATION_X("reason[["), + Key6 TEST_COMPILER_DEPRECATION_X("reason]"), + Key7 TEST_COMPILER_DEPRECATION_X("reason]]"), + }; + Q_ENUM_NS(TestEnum1) + + // try to dizzy moc by adding a struct in between + struct TestGadget { + Q_GADGET + public: + enum class TestGEnum1 { + Key1 = 13, + Key2 TEST_COMPILER_DEPRECATION, + Key3 TEST_COMPILER_DEPRECATION_X("reason") + }; + Q_ENUM(TestGEnum1) + }; + + enum class TestFlag1 { + None = 0, + Flag1 = 1, + Flag2 TEST_COMPILER_DEPRECATION = 2, + Flag3 TEST_COMPILER_DEPRECATION_X("reason") = 3, + Any = Flag1 | Flag2 | Flag3 + }; + Q_FLAG_NS(TestFlag1) +} + +#endif // CXXATTRIBUTE_H diff --git a/tests/auto/tools/moc/cxx11-enums.h b/tests/auto/tools/moc/cxx11-enums.h index cc14c0acda..d5bd228f12 100644 --- a/tests/auto/tools/moc/cxx11-enums.h +++ b/tests/auto/tools/moc/cxx11-enums.h @@ -30,7 +30,6 @@ #define CXX11_ENUMS_H #include <QtCore/QObject> -#if defined(Q_COMPILER_CLASS_ENUM) || defined(Q_MOC_RUN) class CXX11Enums { Q_GADGET @@ -73,21 +72,4 @@ public: Q_FLAGS(ClassFlags) }; -#else -//workaround to get the moc compiled code to compile -class CXX11Enums -{ - Q_GADGET -public: - struct EnumClass { enum { A0, A1, A2, A3 }; }; - struct TypedEnumClass { enum { C0, C1, C2, C3 }; }; - enum NormalEnum { D2 = 2, D3, D0 =0 , D1 }; - enum TypedEnum { B0, B1 , B2, B3 }; -}; - -class CXX11Enums2 : public CXX11Enums -{ - Q_GADGET -}; -#endif #endif // CXX11_ENUMS_H diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index 3cbc9ebb5e..ad8c093add 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -29,7 +29,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n non-gadget-parent-class.h grand-parent-gadget-class.h \ related-metaobjects-in-gadget.h \ related-metaobjects-name-conflict.h \ - namespace.h cxx17-namespaces.h + namespace.h cxx17-namespaces.h \ + cxx-attributes.h if(*-g++*|*-icc*|*-clang*|*-llvm):!win32-*: HEADERS += os9-newlines.h win-newlines.h diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h index 7b0fa29d7c..bd22b0b9af 100644 --- a/tests/auto/tools/moc/parse-defines.h +++ b/tests/auto/tools/moc/parse-defines.h @@ -51,7 +51,6 @@ #define PD_CLASSINFO Q_CLASSINFO -#if defined(Q_COMPILER_VARIADIC_MACROS) || defined (Q_MOC_RUN) #define PD_VARARG(x, ...) x(__VA_ARGS__) #if defined(Q_CC_GNU) || defined(Q_MOC_RUN) @@ -61,7 +60,6 @@ #define PD_VARARGEXT(x, ...) x(__VA_ARGS__) #endif -#endif #define PD_ADD_SUFFIX(x) PD_DEFINE1(x,_SUFFIX) #define PD_DEFINE_ITSELF PD_ADD_SUFFIX(PD_DEFINE_ITSELF) @@ -100,7 +98,6 @@ public slots: PD_TEST_IDENTIFIER_ARG(void, combined6()) {} -#if defined(Q_COMPILER_VARIADIC_MACROS) || defined (Q_MOC_RUN) PD_VARARG(void vararg1) {} PD_VARARG(void vararg2, int) {} PD_VARARG(void vararg3, int, int) {} @@ -108,14 +105,6 @@ public slots: PD_VARARGEXT(void vararg4) {} PD_VARARGEXT(void vararg5, int) {} PD_VARARGEXT(void vararg6, int, int) {} -#else - void vararg1() {} - void vararg2(int) {} - void vararg3(int,int) {} - void vararg4() {} - void vararg5(int) {} - void vararg6(int,int) {} -#endif #define OUTERFUNCTION(x) x #define INNERFUNCTION(x) OUTERFUNCTION(x) diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 50321c322b..ec4a44e672 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -71,6 +71,7 @@ #include "grand-parent-gadget-class.h" #include "namespace.h" #include "cxx17-namespaces.h" +#include "cxx-attributes.h" #ifdef Q_MOC_RUN // check that moc can parse these constructs, they are being used in Windows winsock2.h header @@ -704,6 +705,7 @@ private slots: void optionsFileError(); void testQNamespace(); void cxx17Namespaces(); + void cxxAttributes(); signals: void sigWithUnsignedArg(unsigned foo); @@ -1424,6 +1426,16 @@ void tst_Moc::environmentIncludePaths() // plugin_metadata.h contains a plugin which we register here. Since we're not building this // application as a plugin, we need top copy some of the initializer code found in qplugin.h: extern "C" QObject *qt_plugin_instance(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +extern "C" QPluginMetaData qt_plugin_query_metadata(); +class StaticPluginInstance{ +public: + StaticPluginInstance() { + QStaticPlugin plugin(qt_plugin_instance, qt_plugin_query_metadata); + qRegisterStaticPluginFunction(plugin); + } +}; +#else extern "C" const char *qt_plugin_query_metadata(); class StaticPluginInstance{ public: @@ -1432,6 +1444,7 @@ public: qRegisterStaticPluginFunction(plugin); } }; +#endif static StaticPluginInstance staticInstance; void tst_Moc::specifyMetaTagsFromCmdline() { @@ -3848,6 +3861,14 @@ static void checkEnum(const QMetaEnum &enumerator, const QByteArray &name, const } } +class EnumFromNamespaceClass : public QObject +{ + Q_OBJECT + Q_PROPERTY(FooNamespace::Enum1 prop READ prop CONSTANT) +public: + FooNamespace::Enum1 prop() { return FooNamespace::Enum1::Key2; } +}; + void tst_Moc::testQNamespace() { QCOMPARE(TestQNamespace::staticMetaObject.enumeratorCount(), 4); @@ -3875,6 +3896,11 @@ void tst_Moc::testQNamespace() QCOMPARE(FooNamespace::staticMetaObject.enumeratorCount(), 1); QCOMPARE(FooNamespace::FooNestedNamespace::staticMetaObject.enumeratorCount(), 2); QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); + + EnumFromNamespaceClass obj; + const QVariant prop = obj.property("prop"); + QCOMPARE(prop.type(), QMetaType::Int); + QCOMPARE(prop.toInt(), int(FooNamespace::Enum1::Key2)); } void tst_Moc::cxx17Namespaces() @@ -3896,6 +3922,41 @@ void tst_Moc::cxx17Namespaces() QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().value(0), 3); } +void tst_Moc::cxxAttributes() +{ + auto so = CppAttribute::staticMetaObject; + QCOMPARE(so.className(), "CppAttribute"); + QCOMPARE(so.enumeratorCount(), 0); + QVERIFY(so.indexOfSignal("deprecatedSignal") != 1); + for (auto a: {"deprecatedSlot", "deprecatedSlot2", "deprecatedReason", "deprecatedReasonWithLBRACK", + "deprecatedReasonWith2LBRACK", "deprecatedReasonWithRBRACK", "deprecatedReasonWith2RBRACK", + "slotWithArguments" +#if !defined(_MSC_VER) || _MSC_VER >= 1912 + , "noreturnSlot", "noreturnSlot2", "returnInt", "noreturnDeprecatedSlot", + "noreturnSlot3" +#endif + }) { + QVERIFY(so.indexOfSlot(a) != 1); + } + + QCOMPARE(TestQNamespaceDeprecated::staticMetaObject.enumeratorCount(), 2); + checkEnum(TestQNamespaceDeprecated::staticMetaObject.enumerator(0), "TestEnum1", + {{"Key1", 11}, {"Key2", 12}, {"Key3", 13}, {"Key4", 14}, {"Key5", 15}, {"Key6", 16}, + {"Key7", 17}}); + checkEnum(TestQNamespaceDeprecated::staticMetaObject.enumerator(1), "TestFlag1", + {{"None", 0}, {"Flag1", 1}, {"Flag2", 2}, {"Flag3", 3}, {"Any", 1 | 2 | 3}}); + + QCOMPARE(TestQNamespaceDeprecated::TestGadget::staticMetaObject.enumeratorCount(), 1); + checkEnum(TestQNamespaceDeprecated::TestGadget::staticMetaObject.enumerator(0), "TestGEnum1", + {{"Key1", 13}, {"Key2", 14}, {"Key3", 15}}); + + QMetaEnum meta = QMetaEnum::fromType<TestQNamespaceDeprecated::TestEnum1>(); + QVERIFY(meta.isValid()); + QCOMPARE(meta.name(), "TestEnum1"); + QCOMPARE(meta.enclosingMetaObject(), &TestQNamespaceDeprecated::staticMetaObject); + QCOMPARE(meta.keyCount(), 7); +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS diff --git a/tests/auto/tools/qmakelib/qmakelib.pro b/tests/auto/tools/qmakelib/qmakelib.pro index 29f17f6a14..5e9e9fe637 100644 --- a/tests/auto/tools/qmakelib/qmakelib.pro +++ b/tests/auto/tools/qmakelib/qmakelib.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qmakelib QT = core testlib -win32: LIBS += -ladvapi32 +win32: QMAKE_USE += advapi32 INCLUDEPATH += ../../../../qmake/library VPATH += ../../../../qmake/library diff --git a/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected new file mode 100644 index 0000000000..9dcd131af5 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1_python.expected @@ -0,0 +1,68 @@ +# Resource object code (Python 3) +# Created by: object code +# Created by: The Resource Compiler for Qt version 5.14.0 +# WARNING! All changes made in this file will be lost! + +from PySide2 import QtCore + +qt_resource_data = b"\ +\x00\x00\x00\x02\ +0\ +1\ +\x00\x00\x00#\ +0\ +123456789 012345\ +6789 0123456789 \ +12\ +\x00\x00\x00\x01\ +@\ +\ +\x00\x00\x00\x00\ +\ +" + +qt_resource_name = b"\ +\x00\x04\ +\x00\x06\xa8\xa1\ +\x00d\ +\x00a\x00t\x00a\ +\x00\x0a\ +\x04\x08\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x002\x00.\x00t\x00x\x00t\ +\x00\x0b\ +\x00\xb5Ot\ +\x00d\ +\x00a\x00t\x00a\x00-\x003\x005\x00.\x00t\x00x\x00t\ +\x00\x0a\ +\x04\x11\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x001\x00.\x00t\x00x\x00t\ +\x00\x0a\ +\x04\x0e\x0a\xb4\ +\x00d\ +\x00a\x00t\x00a\x00-\x000\x00.\x00t\x00x\x00t\ +" + +qt_resource_struct = b"\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00(\x00\x00\x00\x00\x00\x01\x00\x00\x00\x06\ +IGNORE: (time stamp) +\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +IGNORE: (time stamp) +\x00\x00\x00^\x00\x00\x00\x00\x00\x01\x00\x00\x002\ +IGNORE: (time stamp) +\x00\x00\x00D\x00\x00\x00\x00\x00\x01\x00\x00\x00-\ +IGNORE: (time stamp) +" + +def qInitResources(): + QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index c810c6e364..24fd79cf19 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -46,6 +46,33 @@ typedef QMap<QString, QString> QStringMap; Q_DECLARE_METATYPE(QStringMap) +static QByteArray msgProcessStartFailed(const QProcess &p) +{ + const QString result = QLatin1String("Could not start \"") + + QDir::toNativeSeparators(p.program()) + QLatin1String("\": ") + + p.errorString(); + return result.toLocal8Bit(); +} + +static QByteArray msgProcessTimeout(const QProcess &p) +{ + return '"' + QDir::toNativeSeparators(p.program()).toLocal8Bit() + + "\" timed out."; +} + +static QByteArray msgProcessCrashed(QProcess &p) +{ + return '"' + QDir::toNativeSeparators(p.program()).toLocal8Bit() + + "\" crashed.\n" + p.readAllStandardError(); +} + +static QByteArray msgProcessFailed(QProcess &p) +{ + return '"' + QDir::toNativeSeparators(p.program()).toLocal8Bit() + + "\" returned " + QByteArray::number(p.exitCode()) + ":\n" + + p.readAllStandardError(); +} + class tst_rcc : public QObject { Q_OBJECT @@ -62,10 +89,13 @@ private slots: void readback_data(); void readback(); + void python(); + void cleanupTestCase(); private: QString m_rcc; + QString m_dataPath; }; void tst_rcc::initTestCase() @@ -74,20 +104,19 @@ void tst_rcc::initTestCase() // we must force a certain hash order when testing or tst_rcc will fail, see QTBUG-25078 QVERIFY(qputenv("QT_RCC_TEST", "1")); m_rcc = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/rcc"); -} -QString findExpectedFile(const QString &base) -{ - QString expectedrccfile = base; + m_dataPath = QFINDTESTDATA("data"); + QVERIFY(!m_dataPath.isEmpty()); +} - // Must be updated with each minor release. - if (QFileInfo(expectedrccfile + QLatin1String(".450")).exists()) - expectedrccfile += QLatin1String(".450"); - return expectedrccfile; +static inline bool isPythonComment(const QString &line) +{ + return line.startsWith(QLatin1Char('#')); } -static QString doCompare(const QStringList &actual, const QStringList &expected) +static QString doCompare(const QStringList &actual, const QStringList &expected, + const QString &timeStampPath) { if (actual.size() != expected.size()) { return QString("Length count different: actual: %1, expected: %2") @@ -95,13 +124,21 @@ static QString doCompare(const QStringList &actual, const QStringList &expected) } QByteArray ba; + const bool isPython = isPythonComment(expected.constFirst()); for (int i = 0, n = expected.size(); i != n; ++i) { QString expectedLine = expected.at(i); if (expectedLine.startsWith("IGNORE:")) continue; + if (isPython && isPythonComment(expectedLine) && isPythonComment(actual.at(i))) + continue; if (expectedLine.startsWith("TIMESTAMP:")) { const QString relativePath = expectedLine.mid(strlen("TIMESTAMP:")); - const quint64 timeStamp = QFileInfo(relativePath).lastModified().toMSecsSinceEpoch(); + const QFileInfo fi(timeStampPath + QLatin1Char('/') + relativePath); + if (!fi.isFile()) { + ba.append("File " + fi.absoluteFilePath().toUtf8() + " does not exist!"); + break; + } + const quint64 timeStamp = quint64(fi.lastModified().toMSecsSinceEpoch()); expectedLine.clear(); for (int shift = 56; shift >= 0; shift -= 8) { expectedLine.append(QLatin1String("0x")); @@ -110,7 +147,7 @@ static QString doCompare(const QStringList &actual, const QStringList &expected) } } if (expectedLine != actual.at(i)) { - qDebug() << "LINES" << i << "DIFFER"; + qDebug() << "LINES" << (i + 1) << "DIFFER"; ba.append( "\n<<<<<< actual\n" + actual.at(i) + "\n======\n" + expectedLine + "\n>>>>>> expected\n" @@ -126,49 +163,53 @@ void tst_rcc::rcc_data() QTest::addColumn<QString>("qrcfile"); QTest::addColumn<QString>("expected"); - QString dataPath = QFINDTESTDATA("data/images/"); - if (dataPath.isEmpty()) - QFAIL("data path not found"); - QTest::newRow("images") << dataPath << "images.qrc" << "images.expected"; + const QString imagesPath = m_dataPath + QLatin1String("/images"); + QTest::newRow("images") << imagesPath << "images.qrc" << "images.expected"; - QString sizesPath = QFINDTESTDATA("data/sizes/"); - if (sizesPath.isEmpty()) - QFAIL("data path not found"); + const QString sizesPath = m_dataPath + QLatin1String("/sizes"); QTest::newRow("size-0") << sizesPath << "size-0.qrc" << "size-0.expected"; QTest::newRow("size-1") << sizesPath << "size-1.qrc" << "size-1.expected"; QTest::newRow("size-2-0-35-1") << sizesPath << "size-2-0-35-1.qrc" << "size-2-0-35-1.expected"; } +static QStringList readLinesFromFile(const QString &fileName, + QString::SplitBehavior splitBehavior) +{ + QFile file(fileName); + + bool ok = file.open(QIODevice::ReadOnly | QIODevice::Text); + if (!ok) { + QWARN(qPrintable(QString::fromLatin1("Could not open testdata file %1: %2") + .arg(fileName, file.errorString()))); + } + + return QString::fromUtf8(file.readAll()).split(QLatin1Char('\n'), splitBehavior); +} + void tst_rcc::rcc() { QFETCH(QString, directory); QFETCH(QString, qrcfile); QFETCH(QString, expected); - if (!QDir::setCurrent(directory)) { - QString message = QString::fromLatin1("Unable to cd from '%1' to '%2'").arg(QDir::currentPath(), directory); - QFAIL(qPrintable(message)); - } - // If the file expectedoutput.txt exists, compare the // console output with the content of that file - const QString expected2 = findExpectedFile(expected); - QFile expectedFile(expected2); - if (!expectedFile.exists()) { - qDebug() << "NO EXPECTATIONS? " << expected2; - return; - } // Launch; force no compression, otherwise the output would be different // depending on the compression algorithm we're using QProcess process; + process.setWorkingDirectory(directory); process.start(m_rcc, { "-no-compress", qrcfile }); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); if (!process.waitForFinished()) { - const QString path = QString::fromLocal8Bit(qgetenv("PATH")); - QString message = QString::fromLatin1("'%1' could not be found when run from '%2'. Path: '%3' "). - arg(m_rcc, QDir::currentPath(), path); - QFAIL(qPrintable(message)); + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + const QChar cr = QLatin1Char('\r'); const QString err = QString::fromLocal8Bit(process.readAllStandardError()).remove(cr); const QString out = QString::fromLatin1(process.readAllStandardOutput()).remove(cr); @@ -181,63 +222,20 @@ void tst_rcc::rcc() const QChar nl = QLatin1Char('\n'); const QStringList actualLines = out.split(nl); - QVERIFY(expectedFile.open(QIODevice::ReadOnly|QIODevice::Text)); - const QStringList expectedLines = QString::fromLatin1(expectedFile.readAll()).split(nl); + const QStringList expectedLines = + readLinesFromFile(directory + QLatin1Char('/') + expected, QString::KeepEmptyParts); + QVERIFY(!expectedLines.isEmpty()); - const QString diff = doCompare(actualLines, expectedLines); + const QString diff = doCompare(actualLines, expectedLines, directory); if (diff.size()) QFAIL(qPrintable(diff)); } - - -static void createRccBinaryData(const QString &rcc, const QString &baseDir, - const QString &qrcFileName, const QString &rccFileName) -{ - QString currentDir = QDir::currentPath(); - QDir::setCurrent(baseDir); - - // same as above: force no compression - QProcess rccProcess; - rccProcess.start(rcc, { "-binary", "-no-compress", "-o", rccFileName, qrcFileName }); - bool ok = rccProcess.waitForFinished(); - if (!ok) { - QString errorString = QString::fromLatin1("Could not start rcc (is it in PATH?): %1").arg(rccProcess.errorString()); - QFAIL(qPrintable(errorString)); - } - - QByteArray output = rccProcess.readAllStandardOutput(); - if (!output.isEmpty()) { - QString errorMessage = QString::fromLatin1("rcc stdout: %1").arg(QString::fromLocal8Bit(output)); - QWARN(qPrintable(errorMessage)); - } - - output = rccProcess.readAllStandardError(); - if (!output.isEmpty()) { - QString errorMessage = QString::fromLatin1("rcc stderr: %1").arg(QString::fromLocal8Bit(output)); - QWARN(qPrintable(errorMessage)); - } - - QDir::setCurrent(currentDir); -} - -static QStringList readLinesFromFile(const QString &fileName) -{ - QFile file(fileName); - - bool ok = file.open(QIODevice::ReadOnly | QIODevice::Text); - if (!ok) - QWARN(qPrintable(QString::fromLatin1("Could not open testdata file %1: %2").arg(fileName, file.errorString()))); - - QStringList lines = QString::fromUtf8(file.readAll()).split(QLatin1Char('\n'), QString::SkipEmptyParts); - return lines; -} - static QStringMap readExpectedFiles(const QString &fileName) { QStringMap expectedFiles; - QStringList lines = readLinesFromFile(fileName); + QStringList lines = readLinesFromFile(fileName, QString::SkipEmptyParts); foreach (const QString &line, lines) { QString resourceFileName = line.section(QLatin1Char(' '), 0, 0, QString::SectionSkipEmpty); QString actualFileName = line.section(QLatin1Char(' '), 1, 1, QString::SectionSkipEmpty); @@ -268,9 +266,7 @@ void tst_rcc::binary_data() QTest::addColumn<QString>("baseDirectory"); QTest::addColumn<QStringMap>("expectedFiles"); - QString dataPath = QFINDTESTDATA("data/binary/"); - if (dataPath.isEmpty()) - QFAIL("data path not found"); + QString dataPath = m_dataPath + QLatin1String("/binary/"); QDirIterator iter(dataPath, QStringList() << QLatin1String("*.qrc")); while (iter.hasNext()) @@ -279,12 +275,33 @@ void tst_rcc::binary_data() QFileInfo qrcFileInfo = iter.fileInfo(); QString absoluteBaseName = QFileInfo(qrcFileInfo.absolutePath(), qrcFileInfo.baseName()).absoluteFilePath(); QString rccFileName = absoluteBaseName + QLatin1String(".rcc"); - createRccBinaryData(m_rcc, dataPath, qrcFileInfo.absoluteFilePath(), rccFileName); + + // same as above: force no compression + QProcess rccProcess; + rccProcess.setWorkingDirectory(dataPath); + rccProcess.start(m_rcc, { "-binary", "-no-compress", "-o", rccFileName, qrcFileInfo.absoluteFilePath() }); + QVERIFY2(rccProcess.waitForStarted(), msgProcessStartFailed(rccProcess).constData()); + if (!rccProcess.waitForFinished()) { + rccProcess.kill(); + QFAIL(msgProcessTimeout(rccProcess).constData()); + } + QVERIFY2(rccProcess.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(rccProcess).constData()); + QVERIFY2(rccProcess.exitCode() == 0, + msgProcessFailed(rccProcess).constData()); + + QByteArray output = rccProcess.readAllStandardOutput(); + if (!output.isEmpty()) + qWarning("rcc stdout: %s", output.constData()); + + output = rccProcess.readAllStandardError(); + if (!output.isEmpty()) + qWarning("rcc stderr: %s", output.constData()); QString localeFileName = absoluteBaseName + QLatin1String(".locale"); QFile localeFile(localeFileName); if (localeFile.exists()) { - QStringList locales = readLinesFromFile(localeFileName); + QStringList locales = readLinesFromFile(localeFileName, QString::SkipEmptyParts); foreach (const QString &locale, locales) { QString expectedFileName = QString::fromLatin1("%1.%2.%3").arg(absoluteBaseName, locale, QLatin1String("expected")); QStringMap expectedFiles = readExpectedFiles(expectedFileName); @@ -386,16 +403,12 @@ void tst_rcc::readback() QFETCH(QString, resourceName); QFETCH(QString, fileSystemName); - QString dataPath = QFINDTESTDATA("data/"); - if (dataPath.isEmpty()) - QFAIL("data path not found"); - QFile resourceFile(resourceName); QVERIFY(resourceFile.open(QIODevice::ReadOnly)); QByteArray resourceData = resourceFile.readAll(); resourceFile.close(); - QFile fileSystemFile(dataPath + fileSystemName); + QFile fileSystemFile(m_dataPath + QLatin1Char('/') + fileSystemName); QVERIFY(fileSystemFile.open(QIODevice::ReadOnly)); QByteArray fileSystemData = fileSystemFile.readAll(); fileSystemFile.close(); @@ -403,12 +416,39 @@ void tst_rcc::readback() QCOMPARE(resourceData, fileSystemData); } +void tst_rcc::python() +{ + const QString path = m_dataPath + QLatin1String("/sizes"); + const QString testFileRoot = path + QLatin1String("/size-2-0-35-1"); + const QString qrcFile = testFileRoot + QLatin1String(".qrc"); + const QString expectedFile = testFileRoot + QLatin1String("_python.expected"); + const QString actualFile = testFileRoot + QLatin1String(".rcc"); + + QProcess process; + process.setWorkingDirectory(path); + process.start(m_rcc, { "-g", "python", "-o", actualFile, qrcFile}); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); + if (!process.waitForFinished()) { + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); + } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + + const auto actualLines = readLinesFromFile(actualFile, QString::KeepEmptyParts); + QVERIFY(!actualLines.isEmpty()); + const auto expectedLines = readLinesFromFile(expectedFile, QString::KeepEmptyParts); + QVERIFY(!expectedLines.isEmpty()); + const QString diff = doCompare(actualLines, expectedLines, path); + if (!diff.isEmpty()) + QFAIL(qPrintable(diff)); +} + void tst_rcc::cleanupTestCase() { - QString dataPath = QFINDTESTDATA("data/binary/"); - if (dataPath.isEmpty()) - return; - QDir dataDir(dataPath); + QDir dataDir(m_dataPath + QLatin1String("/binary")); QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc")); foreach (const QFileInfo &entry, entries) QFile::remove(entry.absoluteFilePath()); diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index f9553028fe..5b2f1f008b 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -36,17 +36,27 @@ #include <QtCore/QTemporaryDir> #include <QtCore/QRegularExpression> #include <QtCore/QStandardPaths> +#include <QtCore/QVector> #include <cstdio> static const char keepEnvVar[] = "UIC_KEEP_GENERATED_FILES"; static const char diffToStderrEnvVar[] = "UIC_STDERR_DIFF"; +struct TestEntry +{ + QByteArray name; + QString baselineBaseName; + QString generatedFileName; +}; + class tst_uic : public QObject { Q_OBJECT public: + using TestEntries = QVector<TestEntry>; + tst_uic(); private Q_SLOTS: @@ -63,13 +73,20 @@ private Q_SLOTS: void compare(); void compare_data() const; + void python(); + void python_data() const; + void runCompare(); private: + void populateTestEntries(); + const QString m_command; QString m_baseline; QTemporaryDir m_generated; + TestEntries m_testEntries; QRegularExpression m_versionRegexp; + QString m_python; }; tst_uic::tst_uic() @@ -85,6 +102,32 @@ static QByteArray msgProcessStartFailed(const QString &command, const QString &w return result.toLocal8Bit(); } +// Locate Python and check whether PySide2 is installed +static QString locatePython(QTemporaryDir &generatedDir) +{ + QString python = QStandardPaths::findExecutable(QLatin1String("python")); + if (python.isEmpty()) { + qWarning("Cannot locate python, skipping tests"); + return QString(); + } + QFile importTestFile(generatedDir.filePath(QLatin1String("import_test.py"))); + if (!importTestFile.open(QIODevice::WriteOnly| QIODevice::Text)) + return QString(); + importTestFile.write("import PySide2.QtCore\n"); + importTestFile.close(); + QProcess process; + process.start(python, {importTestFile.fileName()}); + if (!process.waitForStarted() || !process.waitForFinished()) + return QString(); + if (process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) { + const QString stdErr = QString::fromLocal8Bit(process.readAllStandardError()).simplified(); + qWarning("PySide2 is not installed (%s)", qPrintable(stdErr)); + return QString(); + } + importTestFile.remove(); + return python; +} + void tst_uic::initTestCase() { QVERIFY2(m_generated.isValid(), qPrintable(m_generated.errorString())); @@ -105,7 +148,28 @@ void tst_uic::initTestCase() arg(QDir::currentPath()); if (!outLines.empty()) msg += outLines.front(); + populateTestEntries(); + QVERIFY(!m_testEntries.isEmpty()); qDebug("%s", qPrintable(msg)); + + m_python = locatePython(m_generated); +} + +void tst_uic::populateTestEntries() +{ + const QString generatedPrefix = m_generated.path() + QLatin1Char('/'); + QDir baseline(m_baseline); + const QString baseLinePrefix = baseline.path() + QLatin1Char('/'); + const QFileInfoList baselineFiles = + baseline.entryInfoList(QStringList(QString::fromLatin1("*.ui")), QDir::Files); + m_testEntries.reserve(baselineFiles.size()); + for (const QFileInfo &baselineFile : baselineFiles) { + const QString baseName = baselineFile.baseName(); + const QString baselineBaseName = baseLinePrefix + baseName; + const QString generatedFile = generatedPrefix + baselineFile.fileName() + + QLatin1String(".h"); + m_testEntries.append(TestEntry{baseName.toLocal8Bit(), baselineBaseName, generatedFile}); + } } static const char helpFormat[] = R"( @@ -171,22 +235,12 @@ void tst_uic::run_data() const QTest::addColumn<QString>("generatedFile"); QTest::addColumn<QStringList>("options"); - QDir generated(m_generated.path()); - QDir baseline(m_baseline); - const QFileInfoList baselineFiles = baseline.entryInfoList(QStringList("*.ui"), QDir::Files); - foreach (const QFileInfo &baselineFile, baselineFiles) { - const QString generatedFile = generated.absolutePath() - + QLatin1Char('/') + baselineFile.fileName() - + QLatin1String(".h"); - + for (const TestEntry &te : m_testEntries) { QStringList options; - if (baselineFile.fileName() == QLatin1String("qttrid.ui")) + if (te.name == QByteArrayLiteral("qttrid")) options << QStringList(QLatin1String("-idbased")); - - QTest::newRow(qPrintable(baselineFile.baseName())) - << baselineFile.absoluteFilePath() - << generatedFile - << options; + QTest::newRow(te.name.constData()) << (te.baselineBaseName + QLatin1String(".ui")) + << te.generatedFileName << options; } } @@ -264,15 +318,9 @@ void tst_uic::compare_data() const QTest::addColumn<QString>("originalFile"); QTest::addColumn<QString>("generatedFile"); - QDir generated(m_generated.path()); - QDir baseline(m_baseline); - const QFileInfoList baselineFiles = baseline.entryInfoList(QStringList("*.h"), QDir::Files); - foreach (const QFileInfo &baselineFile, baselineFiles) { - const QString generatedFile = generated.absolutePath() - + QLatin1Char('/') + baselineFile.fileName(); - QTest::newRow(qPrintable(baselineFile.baseName())) - << baselineFile.absoluteFilePath() - << generatedFile; + for (const TestEntry &te : m_testEntries) { + QTest::newRow(te.name.constData()) << (te.baselineBaseName + QLatin1String(".ui.h")) + << te.generatedFileName; } } @@ -280,7 +328,7 @@ void tst_uic::runTranslation() { QProcess process; - QDir baseline(m_baseline); + const QDir baseline(m_baseline); QDir generated(m_generated.path()); generated.mkdir(QLatin1String("translation")); @@ -327,5 +375,75 @@ void tst_uic::runCompare() QCOMPARE(generatedFileContents, originalFileContents); } +// Let uic generate Python code and verify that it is syntactically +// correct by compiling it into .pyc. This test is executed only +// when python with an installed Qt for Python is detected (see locatePython()). + +static inline QByteArray msgCompilePythonFailed(const QByteArray &error) +{ + // If there is a line with blanks and caret indicating an error in the line + // above, insert the cursor into the offending line and remove the caret. + QByteArrayList lines = error.trimmed().split('\n'); + for (int i = lines.size() - 1; i > 0; --i) { + const auto &line = lines.at(i); + const int caret = line.indexOf('^'); + if (caret == 0 || (caret > 0 && line.at(caret - 1) == ' ')) { + lines.removeAt(i); + lines[i - 1].insert(caret, '|'); + break; + } + } + return lines.join('\n'); +} + +void tst_uic::python_data() const +{ + QTest::addColumn<QString>("originalFile"); + QTest::addColumn<QString>("generatedFile"); + + const int size = m_python.isEmpty() + ? qMin(1, m_testEntries.size()) : m_testEntries.size(); + for (int i = 0; i < size; ++i) { + const TestEntry &te = m_testEntries.at(i); + // qprintsettingsoutput: variable named 'from' clashes with Python + if (!te.baselineBaseName.endsWith(QLatin1String("/qprintsettingsoutput"))) { + QString generatedFile = te.generatedFileName; + generatedFile.chop(1); // foo.h -> foo.py + generatedFile.append(QLatin1String("py")); + QTest::newRow(te.name.constData()) + << (te.baselineBaseName + QLatin1String(".ui")) + << generatedFile; + } + } +} + +void tst_uic::python() +{ + QFETCH(QString, originalFile); + QFETCH(QString, generatedFile); + if (m_python.isEmpty()) + QSKIP("Python was not found"); + + QStringList uicArguments{QLatin1String("-g"), QLatin1String("python"), + originalFile, QLatin1String("-o"), generatedFile}; + QProcess process; + process.setWorkingDirectory(m_generated.path()); + process.start(m_command, uicArguments); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(m_command, process.errorString())); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); + QVERIFY(QFileInfo::exists(generatedFile)); + + // Test Python code generation by compiling the file + QStringList compileArguments{QLatin1String("-m"), QLatin1String("py_compile"), generatedFile}; + process.start(m_python, compileArguments); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(m_command, process.errorString())); + QVERIFY(process.waitForFinished()); + const bool compiled = process.exitStatus() == QProcess::NormalExit + && process.exitCode() == 0; + QVERIFY2(compiled, msgCompilePythonFailed(process.readAllStandardError()).constData()); +} + QTEST_MAIN(tst_uic) #include "tst_uic.moc" diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 748c8aaa84..f7482bae45 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1421,6 +1421,16 @@ void tst_QFiledialog::clearLineEdit() QTRY_VERIFY(fd.directory().absolutePath() != workDirPath); QVERIFY(lineEdit->text().isEmpty()); + + // QTBUG-71415: When pressing back, the selection (activated + // directory) should be restored. + QToolButton *backButton = fd.findChild<QToolButton*>("backButton"); + QVERIFY(backButton); + QTreeView *treeView = fd.findChildren<QTreeView*>("treeView").value(0); + QVERIFY(treeView); + backButton->click(); + QTRY_COMPARE(treeView->selectionModel()->selectedIndexes().value(0).data().toString(), + dirName); } void tst_QFiledialog::enableChooseButton() diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp index 2ada4fedb6..6f527e7b6b 100644 --- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp +++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp @@ -252,7 +252,7 @@ class QTestTranslator : public QTranslator { const QString m_str; public: - explicit QTestTranslator(QString str) : m_str(qMove(str)) {} + explicit QTestTranslator(QString str) : m_str(std::move(str)) {} QString translate(const char *, const char *sourceText, const char *, int) const override { return m_str + sourceText + m_str; } @@ -265,7 +265,7 @@ class QTranslatorGuard { Translator t; public: template <typename Arg> - explicit QTranslatorGuard(Arg a) : t(qMove(a)) + explicit QTranslatorGuard(Arg a) : t(std::move(a)) { qApp->installTranslator(&t); } ~QTranslatorGuard() { qApp->removeTranslator(&t); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro index ae6de48195..16818a98f9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro @@ -5,4 +5,4 @@ QT += core-private gui-private SOURCES += tst_qgraphicsitem.cpp DEFINES += QT_NO_CAST_TO_ASCII -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index bca664c05b..0cfdecbcab 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -8386,7 +8386,7 @@ void tst_QGraphicsItem::focusProxy() QString err; QTextStream stream(&err); stream << "QGraphicsItem::setFocusProxy: " - << (void*)item << " is already in the focus proxy chain" << flush; + << (void*)item << " is already in the focus proxy chain" << Qt::flush; QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); item2->setFocusProxy(item); // fails QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp index dfb2752ee0..ed79904ed8 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp @@ -54,9 +54,9 @@ void tst_QGraphicsItemAnimation::construction() QCOMPARE(animation.posAt(0), QPointF()); QCOMPARE(animation.posAt(0.5), QPointF()); QCOMPARE(animation.posAt(1), QPointF()); - QCOMPARE(animation.matrixAt(0), QMatrix()); - QCOMPARE(animation.matrixAt(0.5), QMatrix()); - QCOMPARE(animation.matrixAt(1), QMatrix()); + QCOMPARE(animation.transformAt(0), QTransform()); + QCOMPARE(animation.transformAt(0.5), QTransform()); + QCOMPARE(animation.transformAt(1), QTransform()); QCOMPARE(animation.rotationAt(0), qreal(0.0)); QCOMPARE(animation.rotationAt(0.5), qreal(0.0)); QCOMPARE(animation.rotationAt(1), qreal(0.0)); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro index 351cecd92e..2f648a2212 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro @@ -4,7 +4,7 @@ QT += widgets widgets-private testlib QT += core-private gui-private SOURCES += tst_qgraphicsscene.cpp RESOURCES += images.qrc -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_NO_CAST_TO_ASCII diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index a9c1404891..6e42758122 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4857,7 +4857,7 @@ void tst_QGraphicsView::QTBUG_16063_microFocusRect() scene.setFocusItem(item); view.setFocus(); - QRectF mfv = view.inputMethodQuery(Qt::ImMicroFocus).toRectF(); + QRectF mfv = view.inputMethodQuery(Qt::ImCursorRectangle).toRectF(); QCOMPARE(mfv, IMItem::mf.translated(-view.mapToScene(view.sceneRect().toRect()).boundingRect().topLeft())); } diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 1b3e1e1f34..f247889d55 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -85,8 +85,8 @@ class XResetModel : public QStandardItemModel blockSignals(true); bool r = QStandardItemModel::removeRows(row, count, parent); blockSignals(false); - emit beginResetModel(); - emit endResetModel(); + beginResetModel(); + endResetModel(); return r; } virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) @@ -94,8 +94,8 @@ class XResetModel : public QStandardItemModel blockSignals(true); bool r = QStandardItemModel::insertRows(row, count, parent); blockSignals(false); - emit beginResetModel(); - emit endResetModel(); + beginResetModel(); + endResetModel(); return r; } }; diff --git a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro index 10cd1dcc54..916694fd0f 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro +++ b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro @@ -3,4 +3,4 @@ TARGET = tst_qitemdelegate QT += widgets widgets-private testlib SOURCES += tst_qitemdelegate.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/itemviews/qlistview/qlistview.pro b/tests/auto/widgets/itemviews/qlistview/qlistview.pro index 75f45ab432..c3e19adc81 100644 --- a/tests/auto/widgets/itemviews/qlistview/qlistview.pro +++ b/tests/auto/widgets/itemviews/qlistview/qlistview.pro @@ -2,4 +2,4 @@ CONFIG += testcase TARGET = tst_qlistview QT += widgets gui-private widgets-private core-private testlib testlib-private SOURCES += tst_qlistview.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 91088aeeca..fe2ede4183 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -1525,11 +1525,11 @@ void tst_QListWidget::itemData() item.setData(Qt::DisplayRole, QString("0")); QCOMPARE(widget.currentRoles, QVector<int>({Qt::DisplayRole, Qt::EditRole})); item.setData(Qt::CheckStateRole, Qt::PartiallyChecked); - QCOMPARE(widget.currentRoles, {Qt::CheckStateRole}); + QCOMPARE(widget.currentRoles, QVector<int>{Qt::CheckStateRole}); for (int i = 0; i < 4; ++i) { item.setData(Qt::UserRole + i, QString::number(i + 1)); - QCOMPARE(widget.currentRoles, {Qt::UserRole + i}); + QCOMPARE(widget.currentRoles, QVector<int>{Qt::UserRole + i}); } QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0)); QCOMPARE(flags.count(), 6); diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index b1ddc6e7a2..bf87408056 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -32,6 +32,9 @@ #include <private/qtablewidget_p.h> #include <QtTest/QtTest> #include "private/qapplication_p.h" +#if QT_CONFIG(textmarkdownwriter) +#include "private/qtextmarkdownwriter_p.h" +#endif #include <algorithm> @@ -196,6 +199,10 @@ private slots: void viewOptions(); void taskQTBUG_7232_AllowUserToControlSingleStep(); + +#if QT_CONFIG(textmarkdownwriter) + void markdownWriter(); +#endif }; // Testing get/set functions @@ -4560,5 +4567,33 @@ void tst_QTableView::taskQTBUG_50171_selectRowAfterSwapColumns() } } +// This has nothing to do with QTableView, but it's convenient to reuse the QtTestTableModel +#if QT_CONFIG(textmarkdownwriter) + +// #define DEBUG_WRITE_OUTPUT + +void tst_QTableView::markdownWriter() +{ + QtTestTableModel model(2, 3); + QString md; + { + QTextStream stream(&md); + QTextMarkdownWriter writer(stream, QTextDocument::MarkdownDialectGitHub); + writer.writeTable(&model); + } + +#ifdef DEBUG_WRITE_OUTPUT + { + QFile out("/tmp/table.md"); + out.open(QFile::WriteOnly); + out.write(md.toUtf8()); + out.close(); + } +#endif + + QCOMPARE(md, QString::fromLatin1("|1 |2 |3 |\n|-------|-------|-------|\n|[0,0,0]|[0,1,0]|[0,2,0]|\n|[1,0,0]|[1,1,0]|[1,2,0]|\n")); +} +#endif + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index c2de5c2761..6184962d93 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -1383,11 +1383,11 @@ void tst_QTableWidget::itemData() item->setData(Qt::DisplayRole, QString("0")); QCOMPARE(widget.currentRoles, QVector<int>({Qt::DisplayRole, Qt::EditRole})); item->setData(Qt::CheckStateRole, Qt::PartiallyChecked); - QCOMPARE(widget.currentRoles, {Qt::CheckStateRole}); + QCOMPARE(widget.currentRoles, QVector<int>{Qt::CheckStateRole}); for (int i = 0; i < 4; ++i) { item->setData(Qt::UserRole + i, QString::number(i + 1)); - QCOMPARE(widget.currentRoles, {Qt::UserRole + i}); + QCOMPARE(widget.currentRoles, QVector<int>{Qt::UserRole + i}); } QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0)); QCOMPARE(flags.count(), 6); diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 33d4f3bf91..0d97974b90 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -1999,10 +1999,10 @@ void tst_QTreeWidget::itemData() item.setData(0, Qt::DisplayRole, QString("0")); QCOMPARE(widget.currentRoles, QVector<int>({Qt::DisplayRole, Qt::EditRole})); item.setData(0, Qt::CheckStateRole, Qt::PartiallyChecked); - QCOMPARE(widget.currentRoles, {Qt::CheckStateRole}); + QCOMPARE(widget.currentRoles, QVector<int>{Qt::CheckStateRole}); for (int i = 0; i < 4; ++i) { item.setData(0, Qt::UserRole + i, QString::number(i + 1)); - QCOMPARE(widget.currentRoles, {Qt::UserRole + i}); + QCOMPARE(widget.currentRoles, QVector<int>{Qt::UserRole + i}); } QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0)); QCOMPARE(flags.count(), 6); diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index 73fd934502..af85a2bd13 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -22,5 +22,3 @@ SUBDIRS=\ darwin:SUBDIRS -= \ # Uses native recognizers qgesturerecognizer \ - -SUBDIRS -= qsound diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp index 52ca10d31f..64e5b969e7 100644 --- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp @@ -41,6 +41,7 @@ private slots: void enabledPropagation(); void visiblePropagation(); void exclusive(); + void exclusiveOptional(); void separators(); void testActionInTwoQActionGroup(); void unCheckCurrentAction(); @@ -151,6 +152,52 @@ void tst_QActionGroup::exclusive() QVERIFY( !actThree->isChecked() ); } +void tst_QActionGroup::exclusiveOptional() +{ + QActionGroup group(0); + group.setExclusive(true); + QVERIFY( group.isExclusive() ); + + QAction* actOne = new QAction( &group ); + actOne->setCheckable( true ); + QAction* actTwo = new QAction( &group ); + actTwo->setCheckable( true ); + QAction* actThree = new QAction( &group ); + actThree->setCheckable( true ); + + QVERIFY( !actOne->isChecked() ); + QVERIFY( !actTwo->isChecked() ); + QVERIFY( !actThree->isChecked() ); + + actOne->trigger(); + QVERIFY( actOne->isChecked() ); + QVERIFY( !actTwo->isChecked() ); + QVERIFY( !actThree->isChecked() ); + + actOne->trigger(); + QVERIFY( actOne->isChecked() ); + QVERIFY( !actTwo->isChecked() ); + QVERIFY( !actThree->isChecked() ); + + group.setExclusionPolicy( QActionGroup::ExclusionPolicy::ExclusiveOptional ); + QVERIFY( group.isExclusive() ); + + actOne->trigger(); + QVERIFY( !actOne->isChecked() ); + QVERIFY( !actTwo->isChecked() ); + QVERIFY( !actThree->isChecked() ); + + actTwo->trigger(); + QVERIFY( !actOne->isChecked() ); + QVERIFY( actTwo->isChecked() ); + QVERIFY( !actThree->isChecked() ); + + actTwo->trigger(); + QVERIFY( !actOne->isChecked() ); + QVERIFY( !actTwo->isChecked() ); + QVERIFY( !actThree->isChecked() ); +} + void tst_QActionGroup::separators() { QMainWindow mw; @@ -166,24 +213,22 @@ void tst_QActionGroup::separators() separator->setSeparator(true); actGroup.addAction(separator); - QListIterator<QAction*> it(actGroup.actions()); - while (it.hasNext()) - menu.addAction(it.next()); + menu.addActions(actGroup.actions()); QCOMPARE((int)menu.actions().size(), 2); - it = QListIterator<QAction*>(actGroup.actions()); - while (it.hasNext()) - menu.removeAction(it.next()); + const auto removeActions = [&menu](const QList<QAction *> &actions) { + for (QAction *action : actions) + menu.removeAction(action); + }; + removeActions(actGroup.actions()); QCOMPARE((int)menu.actions().size(), 0); action = new QAction(&actGroup); action->setText("test two"); - it = QListIterator<QAction*>(actGroup.actions()); - while (it.hasNext()) - menu.addAction(it.next()); + menu.addActions(actGroup.actions()); QCOMPARE((int)menu.actions().size(), 3); } diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 3b387c9235..4f94e83c1c 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -890,7 +890,9 @@ void tst_QApplication::libraryPaths() QStringList actual = QApplication::libraryPaths(); actual.sort(); - QStringList expected = QSet<QString>::fromList((QStringList() << testDir << appDirPath)).toList(); + QStringList expected; + expected << testDir << appDirPath; + expected = QSet<QString>(expected.constBegin(), expected.constEnd()).values(); expected.sort(); QVERIFY2(isPathListIncluded(actual, expected), @@ -907,7 +909,9 @@ void tst_QApplication::libraryPaths() QStringList actual = QApplication::libraryPaths(); actual.sort(); - QStringList expected = QSet<QString>::fromList((QStringList() << installPathPlugins << appDirPath)).toList(); + QStringList expected; + expected << installPathPlugins << appDirPath; + expected = QSet<QString>(expected.constBegin(), expected.constEnd()).values(); expected.sort(); #ifdef Q_OS_WINRT diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index b2650d1f32..8dd9d7c428 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -47,6 +47,7 @@ private slots: void sizeConstraints(); void setGeometry(); void setStyleShouldChangeSpacing(); + void widgetSurplus(); void testLayoutEngine_data(); void testLayoutEngine(); @@ -236,6 +237,69 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing() QTRY_COMPARE(spacing(), 10); } +class MarginEatingStyle : public QProxyStyle +{ +public: + MarginEatingStyle() : QProxyStyle(QStyleFactory::create("windows")) + { + } + + virtual QRect subElementRect(SubElement sr, const QStyleOption *opt, + const QWidget *widget) const + { + QRect rect = opt->rect; + switch (sr) { + case SE_GroupBoxLayoutItem: + // this is a simplifed version of what the macOS style does + rect.setTop(rect.top() + 20); + rect.setLeft(rect.left() + 20); + rect.setRight(rect.right() - 20); + rect.setBottom(rect.bottom() - 20); + break; + default: + return QProxyStyle::subElementRect(sr, opt, widget); + } + + return rect; + } +}; + +void tst_QBoxLayout::widgetSurplus() +{ + // Test case for QTBUG-67608 - a style requests space in the margin + + QDialog window; + QScopedPointer<MarginEatingStyle> marginEater(new MarginEatingStyle); + QVBoxLayout *vbox = new QVBoxLayout(&window); + vbox->setMargin(0); + vbox->setSpacing(0); + + QLabel *hiddenLabel = new QLabel(tr("Invisible label")); + hiddenLabel->setVisible(false); + + QGroupBox *groupBox = new QGroupBox(tr("Groupbox Title")); + groupBox->setStyle(marginEater.data()); + groupBox->setObjectName("Test group box"); + QPushButton *button1 = new QPushButton(tr("Button 1")); + QPushButton *button2 = new QPushButton(tr("Button 2")); + QVBoxLayout *groupLayout = new QVBoxLayout; + groupLayout->addWidget(button1); + groupLayout->addWidget(button2); + groupBox->setLayout(groupLayout); + + QLabel *label = new QLabel(tr("Visible label")); + + vbox->addWidget(hiddenLabel); + vbox->addWidget(groupBox); + vbox->addWidget(label); + window.setLayout(vbox); + + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QCOMPARE(groupBox->y(), 0); + QCOMPARE(groupBox->x(), 0); +} + void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected() { QLabel *label = new QLabel("Qt uses standard C++, but makes extensive use of the C pre-processor to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on all major platforms, and has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling."); @@ -507,6 +571,10 @@ void tst_QBoxLayout::replaceWidget() QCOMPARE(boxLayout->indexOf(replaceFrom), 1); QCOMPARE(boxLayout->indexOf(replaceTo), -1); + QCOMPARE(boxLayout->count(), 3); + boxLayout->replaceWidget(replaceFrom, replaceFrom); + QCOMPARE(boxLayout->count(), 3); + delete boxLayout->replaceWidget(replaceFrom, replaceTo); QCOMPARE(boxLayout->indexOf(replaceFrom), -1); diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index cff3dad35e..ab32643061 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -52,7 +52,7 @@ using namespace QTestPrivate; Q_CONSTEXPR QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3); struct QFormLayoutTakeRowResultHolder { - QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) Q_DECL_NOTHROW + QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) noexcept : labelItem(result.labelItem), fieldItem(result.fieldItem) { @@ -66,20 +66,20 @@ struct QFormLayoutTakeRowResultHolder { if (fieldItem) disposer.setItem(0, QFormLayout::FieldRole, fieldItem); } - QFormLayoutTakeRowResultHolder(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW + QFormLayoutTakeRowResultHolder(QFormLayoutTakeRowResultHolder &&other) noexcept : labelItem(other.labelItem), fieldItem(other.fieldItem) { other.labelItem = nullptr; other.fieldItem = nullptr; } - QFormLayoutTakeRowResultHolder &operator=(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW + QFormLayoutTakeRowResultHolder &operator=(QFormLayoutTakeRowResultHolder &&other) noexcept { swap(other); return *this; } - void swap(QFormLayoutTakeRowResultHolder &other) Q_DECL_NOTHROW + void swap(QFormLayoutTakeRowResultHolder &other) noexcept { qSwap(labelItem, other.labelItem); qSwap(fieldItem, other.fieldItem); diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro index c1908af2a2..d3fbd6d0d9 100644 --- a/tests/auto/widgets/kernel/qwidget/qwidget.pro +++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro @@ -16,4 +16,4 @@ mac { OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm } -win32:!winrt: LIBS += -luser32 -lgdi32 +win32:!winrt: QMAKE_USE += user32 gdi32 diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index da542ba67f..fb40674d98 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -2480,8 +2480,8 @@ void tst_QWidget::showMinimizedKeepsFocus() { if (m_platform == QStringLiteral("xcb")) QSKIP("QTBUG-26424"); - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); if (m_platform == QStringLiteral("offscreen")) QSKIP("Platform offscreen does not support showMinimized()"); @@ -2692,8 +2692,8 @@ void tst_QWidget::icon() void tst_QWidget::hideWhenFocusWidgetIsChild() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); QScopedPointer<QWidget> testWidget(new QWidget); testWidget->setWindowTitle(__FUNCTION__); @@ -5494,8 +5494,8 @@ void tst_QWidget::multipleToplevelFocusCheck() QSKIP("QTBUG-52974"); #endif - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); else if (m_platform == QStringLiteral("winrt")) QSKIP("Winrt: Sometimes crashes in QTextLayout. - QTBUG-68297"); TopLevelFocusCheck w1; @@ -6209,7 +6209,11 @@ public: return false; } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *) override +#else bool nativeEvent(const QByteArray &eventType, void *message, long *) override +#endif { if (isMapNotify(eventType, message)) gotExpectedMapNotify = true; @@ -6217,7 +6221,11 @@ public: } // QAbstractNativeEventFilter interface +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override +#else bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override +#endif { if (isMapNotify(eventType, message)) gotExpectedGlobalEvent = true; @@ -9621,8 +9629,8 @@ void tst_QWidget::setGraphicsEffect() void tst_QWidget::activateWindow() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); // Test case for QTBUG-26711 @@ -9690,8 +9698,8 @@ void tst_QWidget::openModal_taskQTBUG_5804() void tst_QWidget::focusProxyAndInputMethods() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported."); QScopedPointer<QWidget> toplevel(new QWidget(nullptr, Qt::X11BypassWindowManagerHint)); toplevel->setWindowTitle(QLatin1String(QTest::currentTestFunction())); toplevel->resize(200, 200); diff --git a/tests/auto/widgets/kernel/qwidget_window/BLACKLIST b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST index 934f2e8025..381cf76c46 100644 --- a/tests/auto/widgets/kernel/qwidget_window/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST @@ -2,7 +2,6 @@ # QTBUG-66345 opensuse-42.3 ubuntu-16.04 -ubuntu-18.04 [setWindowState] ubuntu-18.04 rhel diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp index 007825d39c..a17a9f6c33 100644 --- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp +++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp @@ -124,13 +124,19 @@ void tst_QAbstractScrollArea::scrollBarWidgets() QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList()); QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), w2List); + auto sort = [](const QWidgetList l) { + QWidgetList list = l; + std::sort(list.begin(), list.end()); + return list; + }; + // two widgets at Bottom. area.addScrollBarWidget(w3, Qt::AlignBottom); - QCOMPARE(area.scrollBarWidgets(all).toSet(), allList.toSet()); + QCOMPARE(sort(area.scrollBarWidgets(all)), sort(allList)); QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List); QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList()); QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList()); - QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom).toSet(), (w2List + w3List).toSet()); + QCOMPARE(sort(area.scrollBarWidgets(Qt::AlignBottom)), sort(w2List + w3List)); //delete delete w1; diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index 1a0d7a9289..d8fbb8e041 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -33,7 +33,7 @@ #include <QSlider> #include <QStyle> #include <QStyleOption> -#include <QTime> +#include <QElapsedTimer> #include <QDebug> #include <QtTest/private/qtesthelpers_p.h> @@ -91,7 +91,7 @@ private slots: void connectedSliders(); private: - void waitUntilTimeElapsed(const QTime& t, int ms); + void waitUntilTimeElapsed(const QElapsedTimer &t, int ms); QWidget *topLevel; Slider *slider; @@ -2053,11 +2053,11 @@ void tst_QAbstractSlider::setValue() QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp); } -void tst_QAbstractSlider::waitUntilTimeElapsed(const QTime& t, int ms) +void tst_QAbstractSlider::waitUntilTimeElapsed(const QElapsedTimer &t, int ms) { const int eps = 80; while (t.elapsed() < ms + eps) - QTest::qWait(qMax(ms - t.elapsed() + eps, 25)); + QTest::qWait(qMax(int(ms - t.elapsed() + eps), 25)); } void tst_QAbstractSlider::setRepeatAction() @@ -2073,7 +2073,7 @@ void tst_QAbstractSlider::setRepeatAction() QCOMPARE(spy.count(), 0); QCOMPARE(slider->value(), 55); - QTime t; + QElapsedTimer t; t.start(); QTest::qWait(300); QCOMPARE(spy.count(), 0); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index b5ef454b14..c6f6900def 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -307,19 +307,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -331,17 +331,17 @@ static QLatin1String sectionToName(const QDateTimeEdit::Section section) { switch (section) { case QDateTimeEdit::SecondSection: - return QLatin1Literal("Second"); + return QLatin1String("Second"); case QDateTimeEdit::MinuteSection: - return QLatin1Literal("Minute"); + return QLatin1String("Minute"); case QDateTimeEdit::HourSection: - return QLatin1Literal("Hours"); + return QLatin1String("Hours"); case QDateTimeEdit::DaySection: - return QLatin1Literal("Day"); + return QLatin1String("Day"); case QDateTimeEdit::MonthSection: - return QLatin1Literal("Month"); + return QLatin1String("Month"); case QDateTimeEdit::YearSection: - return QLatin1Literal("Year"); + return QLatin1String("Year"); default: qFatal("Unexpected section"); return QLatin1String(); @@ -3217,16 +3217,16 @@ void tst_QDateTimeEdit::wheelEvent_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index f8ce6a2c0a..625116654d 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -670,7 +670,11 @@ void tst_QDockWidget::dockLocationChanged() spy.clear(); dw.setFloating(true); - QTest::qWait(100); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), + Qt::NoDockWidgetArea); + spy.clear(); + dw.setFloating(false); QTRY_COMPARE(spy.count(), 1); QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 954ee6471d..a20b5568da 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -221,19 +221,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -1448,16 +1448,16 @@ void tst_QDoubleSpinBox::wheelEvents_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp index 1813e5ad5f..5392d36ae0 100644 --- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp @@ -108,7 +108,7 @@ void tst_QFontComboBox::currentFont() QFont oldCurrentFont = box.currentFont(); box.setCurrentFont(currentFont); - QRegExp foundry(" \\[.*\\]"); + QRegularExpression foundry(" \\[.*\\]"); if (!box.currentFont().family().contains(foundry)) { QCOMPARE(box.currentFont(), currentFont); } diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 95799905de..f1bc3e8dd4 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3615,6 +3615,14 @@ void tst_QLineEdit::task174640_editingFinished() le2->setFocus(); QTRY_VERIFY(le2->hasFocus()); + // editingFinished will not be emitted anew because no editing happened + QCOMPARE(editingFinishedSpy.count(), 0); + + le1->setFocus(); + QTRY_VERIFY(le1->hasFocus()); + QTest::keyPress(le1, Qt::Key_Plus); + le2->setFocus(); + QTRY_VERIFY(le2->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 1); editingFinishedSpy.clear(); @@ -3632,6 +3640,8 @@ void tst_QLineEdit::task174640_editingFinished() delete testMenu1; QCOMPARE(editingFinishedSpy.count(), 0); QTRY_VERIFY(le1->hasFocus()); + // Ensure le1 has been edited + QTest::keyPress(le1, Qt::Key_Plus); QMenu *testMenu2 = new QMenu(le2); testMenu2->addAction("foo2"); @@ -3986,7 +3996,7 @@ void tst_QLineEdit::QTBUG7174_inputMaskCursorBlink() edit.setFocus(); edit.setText(QLatin1String("AAAA")); edit.show(); - QRect cursorRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect(); + QRect cursorRect = edit.inputMethodQuery(Qt::ImCursorRectangle).toRect(); QVERIFY(QTest::qWaitForWindowExposed(&edit)); edit.updateRegion = QRegion(); QTest::qWait(QApplication::cursorFlashTime()); diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 67b79e3faf..046899ce05 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -333,6 +333,7 @@ void tst_QMdiArea::subWindowActivated() for ( i = 0; i < count; ++i ) { QWidget *widget = new QWidget(workspace, 0); widget->setAttribute(Qt::WA_DeleteOnClose); + widget->setFocus(); workspace->addSubWindow(widget)->show(); widget->show(); qApp->processEvents(); diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index cb829c81a6..d6ba85d61f 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -113,10 +113,7 @@ private slots: void check_escKey(); #endif -#ifndef Q_OS_WINCE void allowActiveAndDisabled(); -#endif - void taskQTBUG56860_focus(); void check_endKey(); void check_homeKey(); diff --git a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp index d1923e4bb0..9f08bd337b 100644 --- a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp +++ b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp @@ -87,7 +87,7 @@ public: protected: QVariant inputMethodQuery(Qt::InputMethodQuery query) const { - if (query == Qt::ImMicroFocus) + if (query == Qt::ImCursorRectangle) return QRect(width() / 2, height() / 2, 5, 5); return QWidget::inputMethodQuery(query); } @@ -110,7 +110,7 @@ void tst_QScrollArea::ensureMicroFocusVisible_Task_167838() parent->resize(300, 300); scrollArea.setWidget(parent); scrollArea.ensureWidgetVisible(child, 10, 10); - QRect microFocus = child->inputMethodQuery(Qt::ImMicroFocus).toRect(); + QRect microFocus = child->inputMethodQuery(Qt::ImCursorRectangle).toRect(); QPoint p = child->mapTo(scrollArea.viewport(), microFocus.topLeft()); microFocus.translate(p - microFocus.topLeft()); QVERIFY(scrollArea.viewport()->rect().contains(microFocus)); diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 52d7dad7cf..3dd29b0214 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -206,7 +206,7 @@ private slots: void stepModifierPressAndHold_data(); void stepModifierPressAndHold(); public slots: - void valueChangedHelper(const QString &); + void textChangedHelper(const QString &); void valueChangedHelper(int); private: QStringList actualTexts; @@ -222,19 +222,19 @@ static QLatin1String modifierToName(Qt::KeyboardModifier modifier) { switch (modifier) { case Qt::NoModifier: - return QLatin1Literal("No"); + return QLatin1String("No"); break; case Qt::ControlModifier: - return QLatin1Literal("Ctrl"); + return QLatin1String("Ctrl"); break; case Qt::ShiftModifier: - return QLatin1Literal("Shift"); + return QLatin1String("Shift"); break; case Qt::AltModifier: - return QLatin1Literal("Alt"); + return QLatin1String("Alt"); break; case Qt::MetaModifier: - return QLatin1Literal("Meta"); + return QLatin1String("Meta"); break; default: qFatal("Unexpected keyboard modifier"); @@ -490,7 +490,7 @@ void tst_QSpinBox::setPrefixSuffix() } } -void tst_QSpinBox::valueChangedHelper(const QString &text) +void tst_QSpinBox::textChangedHelper(const QString &text) { actualTexts << text; } @@ -568,7 +568,7 @@ void tst_QSpinBox::setTracking() QSpinBox spin(0); spin.setKeyboardTracking(tracking); spin.show(); - connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(QString))); + connect(&spin, &QSpinBox::textChanged, this, &tst_QSpinBox::textChangedHelper); keys.simulate(&spin); QCOMPARE(actualTexts, texts); @@ -1402,16 +1402,16 @@ void tst_QSpinBox::wheelEvents_data() QLatin1String sourceName; switch (source) { case Qt::MouseEventNotSynthesized: - sourceName = QLatin1Literal("NotSynthesized"); + sourceName = QLatin1String("NotSynthesized"); break; case Qt::MouseEventSynthesizedBySystem: - sourceName = QLatin1Literal("SynthesizedBySystem"); + sourceName = QLatin1String("SynthesizedBySystem"); break; case Qt::MouseEventSynthesizedByQt: - sourceName = QLatin1Literal("SynthesizedByQt"); + sourceName = QLatin1String("SynthesizedByQt"); break; case Qt::MouseEventSynthesizedByApplication: - sourceName = QLatin1Literal("SynthesizedByApplication"); + sourceName = QLatin1String("SynthesizedByApplication"); break; default: qFatal("Unexpected wheel event source"); diff --git a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro index 6523209c32..b61cc8fa13 100644 --- a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro +++ b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro @@ -8,4 +8,4 @@ INCLUDEPATH += ../ HEADERS += SOURCES += tst_qtabwidget.cpp -win32:!winrt: LIBS += -luser32 +win32:!winrt: QMAKE_USE += user32 diff --git a/tests/auto/widgets/widgets/qtextbrowser/heading.html b/tests/auto/widgets/widgets/qtextbrowser/heading.html new file mode 100644 index 0000000000..8b23807f65 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/heading.html @@ -0,0 +1,2 @@ +<h3>this is a heading</h3> +<p>this is a paragraph</p> diff --git a/tests/auto/widgets/widgets/qtextbrowser/markdown.md b/tests/auto/widgets/widgets/qtextbrowser/markdown.md new file mode 100644 index 0000000000..be56aef234 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/markdown.md @@ -0,0 +1,2 @@ +### this is a heading +this is a paragraph diff --git a/tests/auto/widgets/widgets/qtextbrowser/markdown.really b/tests/auto/widgets/widgets/qtextbrowser/markdown.really new file mode 100644 index 0000000000..be56aef234 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/markdown.really @@ -0,0 +1,2 @@ +### this is a heading +this is a paragraph diff --git a/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro b/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro index 9680ffd871..dfdcf26497 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro +++ b/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro @@ -4,6 +4,6 @@ SOURCES += tst_qtextbrowser.cpp QT += widgets testlib -TESTDATA += *.html subdir/* +TESTDATA += *.html *.md markdown.really subdir/* builtin_testdata: DEFINES += BUILTIN_TESTDATA diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index 8a1b228c71..083e297941 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -38,7 +38,7 @@ class TestBrowser : public QTextBrowser { public: - inline TestBrowser() : htmlLoadAttempts(0) { + inline TestBrowser() { show(); QApplication::setActiveWindow(this); activateWindow(); @@ -47,11 +47,12 @@ public: QVERIFY(hasFocus()); } - virtual QVariant loadResource(int type, const QUrl &name); + QVariant loadResource(int type, const QUrl &name) override; - int htmlLoadAttempts; + int htmlLoadAttempts = 0; QUrl lastResource; QUrl sourceInsideLoadResource; + QUrl baseInsideLoadResource; }; QVariant TestBrowser::loadResource(int type, const QUrl &name) @@ -60,6 +61,7 @@ QVariant TestBrowser::loadResource(int type, const QUrl &name) htmlLoadAttempts++; lastResource = name; sourceInsideLoadResource = source(); + baseInsideLoadResource = document()->baseUrl(); return QTextBrowser::loadResource(type, name); } @@ -90,6 +92,8 @@ private slots: void focusIndicator(); void focusHistory(); void urlEncoding(); + void sourceType_data(); + void sourceType(); private: TestBrowser *browser; @@ -108,7 +112,7 @@ void tst_QTextBrowser::init() void tst_QTextBrowser::cleanup() { delete browser; - browser = 0; + browser = nullptr; } void tst_QTextBrowser::noReloadOnAnchorJump() @@ -428,11 +432,18 @@ void tst_QTextBrowser::sourceInsideLoadResource() #ifdef Q_OS_WINRT QSKIP("Paths cannot be compared if applications are sandboxed."); #endif - QUrl url = QUrl::fromLocalFile("pagewithimage.html"); + QUrl url = QUrl::fromLocalFile("pagewithimage.html"); // "file://pagewithimage.html" browser->setSource(url); QCOMPARE(browser->lastResource, QUrl::fromLocalFile(QDir::current().filePath("foobar.png"))); + // baseUrl was not set because the source URL was a relative one + QCOMPARE(browser->baseInsideLoadResource, QUrl()); QEXPECT_FAIL("", "This is currently not supported", Continue); QCOMPARE(browser->sourceInsideLoadResource.toString(), url.toString()); + url = QUrl::fromLocalFile(QDir::current().filePath("pagewithimage.html")); // "file:///home/user/path/to/pagewithimage.html" + browser->setSource(url); + QCOMPARE(browser->lastResource, QUrl::fromLocalFile(QDir::current().filePath("foobar.png"))); + // baseUrl has the full path, and that's where relative-path resources come from + QCOMPARE(browser->baseInsideLoadResource, QUrl::fromLocalFile(QDir::currentPath() + QLatin1Char('/'))); } void tst_QTextBrowser::textInteractionFlags_vs_readOnly() @@ -669,5 +680,46 @@ void tst_QTextBrowser::urlEncoding() delete browser; } +void tst_QTextBrowser::sourceType_data() +{ + QTest::addColumn<QString>("sourceFile"); + QTest::addColumn<QTextDocument::ResourceType>("sourceType"); + QTest::addColumn<int>("expectedMaxHeadingLevel"); + QTest::addColumn<QTextDocument::ResourceType>("expectedSourceType"); + +#if QT_CONFIG(textmarkdownreader) + const int maxMdHeadingLevel = 3; + const QTextDocument::ResourceType mdExpectedType = QTextDocument::MarkdownResource; +#else + // If Qt doesn't support markdown, and we read a MD document anyway, it won't have any H3's. + const int maxMdHeadingLevel = 0; + const QTextDocument::ResourceType mdExpectedType = QTextDocument::HtmlResource; +#endif + QTest::newRow("markdown detected") << "markdown.md" << QTextDocument::UnknownResource << maxMdHeadingLevel << mdExpectedType; + QTest::newRow("markdown specified") << "markdown.really" << QTextDocument::MarkdownResource << maxMdHeadingLevel << mdExpectedType; + QTest::newRow("markdown not identified") << "markdown.really" << QTextDocument::UnknownResource << 0 << QTextDocument::HtmlResource; + QTest::newRow("html detected") << "heading.html" << QTextDocument::UnknownResource << 3 << QTextDocument::HtmlResource; + QTest::newRow("html specified") << "heading.html" << QTextDocument::HtmlResource << 3 << QTextDocument::HtmlResource; +} + +void tst_QTextBrowser::sourceType() +{ + QFETCH(QString, sourceFile); + QFETCH(QTextDocument::ResourceType, sourceType); + QFETCH(int, expectedMaxHeadingLevel); + QFETCH(QTextDocument::ResourceType, expectedSourceType); + if (sourceType == QTextDocument::UnknownResource) + // verify that the property setter works, with its default parameter for sourceType + browser->setProperty("source", QUrl::fromLocalFile(QFINDTESTDATA(sourceFile))); + else + browser->setSource(QUrl::fromLocalFile(QFINDTESTDATA(sourceFile)), sourceType); + QCOMPARE(browser->sourceType(), expectedSourceType); + QTextFrame::iterator iterator = browser->document()->rootFrame()->begin(); + int maxHeadingLevel = -1; + while (!iterator.atEnd()) + maxHeadingLevel = qMax(iterator++.currentBlock().blockFormat().intProperty(QTextFormat::HeadingLevel), maxHeadingLevel); + QCOMPARE(maxHeadingLevel, expectedMaxHeadingLevel); +} + QTEST_MAIN(tst_QTextBrowser) #include "tst_qtextbrowser.moc" diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 3669935823..81682dc027 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -160,6 +160,7 @@ private slots: void selectionChanged(); #ifndef QT_NO_CLIPBOARD void copyPasteBackgroundImage(); + void copyPasteForegroundImage(); #endif void setText(); void cursorRect(); @@ -1904,6 +1905,36 @@ void tst_QTextEdit::copyPasteBackgroundImage() ba.texture().cacheKey() == bb.texture().cacheKey()); QFile::remove(QLatin1String("foo.png")); } + +void tst_QTextEdit::copyPasteForegroundImage() +{ + ed->clear(); + + QPixmap pix(20, 20); + pix.fill(Qt::blue); + + QTextCharFormat fmt; + { + QBrush textureBrush; + { + textureBrush.setTexture(pix); + } + textureBrush.setStyle(Qt::TexturePattern); + fmt.setForeground(textureBrush); + } + ed->textCursor().insertText("Foobar", fmt); + + ed->moveCursor(QTextCursor::Start); + ed->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor); + + ed->copy(); + ed->clear(); + ed->paste(); + + QBrush brush = ed->textCursor().charFormat().foreground(); + QCOMPARE(brush.style(), Qt::TexturePattern); + QCOMPARE(brush.texture().cacheKey(), pix.cacheKey()); +} #endif void tst_QTextEdit::setText() diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp index 752e39c23f..d40c8c2fd6 100644 --- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp +++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp @@ -34,6 +34,7 @@ #include <QTcpServer> #include <QTcpSocket> #include <QTimer> +#include <QElapsedTimer> #include <QtDebug> #include <QtTest/QtTest> #include <QXmlDefaultHandler> @@ -259,7 +260,7 @@ public: // Delibrately wait a maximum of 10 seconds for the sake // of the test, so it doesn't unduly hang const int waitTime = qMax(10000, msecs); - QTime t; + QElapsedTimer t; t.start(); while (t.elapsed() < waitTime) { QCoreApplication::processEvents(); diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp b/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp index 15f10232bd..b5d9fea315 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp @@ -72,7 +72,7 @@ int main(int argc, const char *argv[]) QFile in_file(file_name); if (!in_file.open(QIODevice::ReadOnly)) { - qerr << "Could not open " << file_name << ": " << strerror(errno) << endl; + qerr << "Could not open " << file_name << ": " << strerror(errno) << Qt::endl; return 1; } @@ -87,7 +87,7 @@ int main(int argc, const char *argv[]) } else { _out_file.setFileName(out_file_name); if (!_out_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - qerr << "Could not open " << out_file_name << ": " << strerror(errno) << endl; + qerr << "Could not open " << out_file_name << ": " << strerror(errno) << Qt::endl; return 1; } _out_stream.setDevice(&_out_file); diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp index 17351883c3..556603a681 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp @@ -28,7 +28,7 @@ #include <qxml.h> -#include <qregexp.h> +#include <qregularexpression.h> #include "parser.h" @@ -139,11 +139,11 @@ bool ContentHandler::startElement(const QString &namespaceURI, QString ContentHandler::escapeStr(const QString &s) { QString result = s; - result.replace(QRegExp("\""), "\\\""); - result.replace(QRegExp("\\"), "\\\\"); - result.replace(QRegExp("\n"), "\\n"); - result.replace(QRegExp("\r"), "\\r"); - result.replace(QRegExp("\t"), "\\t"); + result.replace(QRegularExpression("\""), "\\\""); + result.replace(QRegularExpression("\\"), "\\\\"); + result.replace(QRegularExpression("\n"), "\\n"); + result.replace(QRegularExpression("\r"), "\\r"); + result.replace(QRegularExpression("\t"), "\\t"); return result; } diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak deleted file mode 100644 index 2d80c8f3fb..0000000000 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.bak +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE doc [
-<!ENTITY e "𐀀􏿽">
-<!ELEMENT doc (#PCDATA)>
-]>
-<doc>&e;</doc>
|