diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-12-29 16:37:38 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-12-29 16:37:38 +0100 |
commit | aaff94c2df665035addb90714bab4722003894da (patch) | |
tree | 3af76e8aa4dbf86a86b1e4d2ad2f6dda06374ee0 /tests/auto | |
parent | 2302d386c7a1aa1a96658f79c236d6b8a59db7ac (diff) | |
parent | 1196f691120d77ab3be55f21824aba645210fb8c (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
src/corelib/tools/qbytearray.cpp
src/gui/kernel/qplatformsystemtrayicon.cpp
src/gui/kernel/qplatformsystemtrayicon.h
src/plugins/platforms/xcb/xcb-plugin.pro
Change-Id: I00355d3908b678af8a61c38f9e814a63df808c79
Diffstat (limited to 'tests/auto')
61 files changed, 584 insertions, 1801 deletions
diff --git a/tests/auto/android/AndroidManifest.xml b/tests/auto/android/AndroidManifest.xml deleted file mode 100644 index bd1e0afc68..0000000000 --- a/tests/auto/android/AndroidManifest.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.qtproject.qt5.android.tests" - android:versionCode="1" - android:versionName="1.0"> - <uses-sdk android:minSdkVersion="4" /> - <application android:label="@string/app_name" android:name="org.qtproject.qt5.android.QtNative"> - <activity android:label="@string/app_name" android:name="org.qtproject.qt5.android.QtActivity"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - </application> - <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> - <uses-permission android:name="android.permission.INTERNET"/> - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> - <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/> - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> - <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"/> - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> - <uses-permission android:name="android.permission.BLUETOOTH"/> - <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> - <uses-permission android:name="android.permission.CAMERA"/> - <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/> - <uses-permission android:name="android.permission.INJECT_EVENTS"/> - <uses-permission android:name="android.permission.NFC"/> - <uses-permission android:name="android.permission.READ_PHONE_STATE"/> - <uses-permission android:name="android.permission.SET_ORIENTATION"/> - <uses-permission android:name="android.permission.STATUS_BAR"/> - <uses-permission android:name="android.permission.VIBRATE"/> - <uses-permission android:name="android.permission.WAKE_LOCK"/> - <uses-permission android:name="android.permission.WRITE_CALENDAR"/> - <uses-permission android:name="android.permission.WRITE_CONTACTS"/> -</manifest> diff --git a/tests/auto/android/res/layout/main.xml b/tests/auto/android/res/layout/main.xml deleted file mode 100644 index 7fe6bbac67..0000000000 --- a/tests/auto/android/res/layout/main.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - > -<TextView - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:id="@+id/textView" - /> -</LinearLayout> diff --git a/tests/auto/android/res/values/libs.xml b/tests/auto/android/res/values/libs.xml deleted file mode 100644 index 43f1d4aff4..0000000000 --- a/tests/auto/android/res/values/libs.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<resources> - <array name="qt_libs"> - <item>gnustl_shared</item> - <item>Qt5Core</item> - <item>Qt5Gui</item> - <item>Qt5Widgets</item> - <item>Qt5Test</item> - <item>Qt5OpenGL</item> - <item>Qt5Network</item> - <item>Qt5Script</item> - <item>Qt5Sql</item> - <item>Qt5Xml</item> - <item>Qt5ScriptTools</item> - <item>Qt5Svg</item> - <item>Qt5XmlPatterns</item> - <item>Qt5Declarative</item> - <item>Qt5WebKit</item> - </array> - <array name="bundled_libs"/> -</resources> diff --git a/tests/auto/android/res/values/strings.xml b/tests/auto/android/res/values/strings.xml deleted file mode 100644 index faf61040b5..0000000000 --- a/tests/auto/android/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="app_name">Quadruplor</string> -</resources> diff --git a/tests/auto/android/runtests.pl b/tests/auto/android/runtests.pl deleted file mode 100755 index 30bf78f0b7..0000000000 --- a/tests/auto/android/runtests.pl +++ /dev/null @@ -1,367 +0,0 @@ -#!/usr/bin/perl -w -############################################################################# -## -## Copyright (C) 2012-2013 BogDan Vatra <bogdan@kde.org> -## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -## Contact: http://www.qt-project.org/legal -## -## This file is part of the test suite of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:LGPL21$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and Digia. For licensing terms and -## conditions see http://qt.digia.com/licensing. For further information -## use the contact form at http://qt.digia.com/contact-us. -## -## GNU Lesser General Public License Usage -## Alternatively, this file may be used under the terms of the GNU Lesser -## General Public License version 2.1 or version 3 as published by the Free -## Software Foundation and appearing in the file LICENSE.LGPLv21 and -## LICENSE.LGPLv3 included in the packaging of this file. Please review the -## following information to ensure the GNU Lesser General Public License -## requirements will be met: https://www.gnu.org/licenses/lgpl.html and -## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -## -## In addition, as a special exception, Digia gives you certain additional -## rights. These rights are described in the Digia Qt LGPL Exception -## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -## -## $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; - -### default options -my @stack = cwd; -my $device_serial=""; # "-s device_serial"; -my $packageName="org.qtproject.qt5.android.tests"; -my $intentName="$packageName/org.qtproject.qt5.android.QtActivity"; -my $jobs = 4; -my $testsubset = ""; -my $man = 0; -my $help = 0; -my $make_clean = 0; -my $deploy_qt = 0; -my $time_out=400; -my $android_sdk_dir = "$ENV{'ANDROID_SDK_ROOT'}"; -my $android_ndk_dir = "$ENV{'ANDROID_NDK_ROOT'}"; -my $ant_tool = `which ant`; -chomp $ant_tool; -my $strip_tool=""; -my $readelf_tool=""; -GetOptions('h|help' => \$help - , man => \$man - , 's|serial=s' => \$device_serial - , 't|test=s' => \$testsubset - , 'c|clean' => \$make_clean - , 'd|deploy' => \$deploy_qt - , 'j|jobs=i' => \$jobs - , 'sdk=s' => \$android_sdk_dir - , 'ndk=s' => \$android_ndk_dir - , 'ant=s' => \$ant_tool - , 'strip=s' => \$strip_tool - , 'readelf=s' => \$readelf_tool - , 'testcase=s' => \$testcase - ) or pod2usage(2); -pod2usage(1) if $help; -pod2usage(-verbose => 2) if $man; - -my $adb_tool="$android_sdk_dir/platform-tools/adb"; -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 - -$device_serial = "-s $device_serial" if ($device_serial); -$testsubset="/$testsubset" if ($testsubset); - -$strip_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-strip" unless($strip_tool); -$readelf_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/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; -} - - -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"; - print $action?" start...\n":" die...\n"; - 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"; - return 1; - } - sleep($sleepPeriod); - print "timeount in ".$timeout*$sleepPeriod." seconds\n" - } - print "... failed\n"; - 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 $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); -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 reinstallQuadruplor -{ - pushd($quadruplor_dir); - system("$android_sdk_dir/tools/android update project -p . -t android-10")==0 or die "Can't update project ...\n"; - system("$ant_tool uninstall clean debug install")==0 or die "Can't install Quadruplor\n"; - system("$adb_tool $device_serial shell am start -n $intentName"); # create application folders - waitForProcess($packageName,1,10); - waitForProcess($packageName,0,20); - popd(); -} -sub killProcess -{ - reinstallQuadruplor; -# #### it seems I'm too idiot to use perl regexp -# my $process=shift; -# my $output = `$adb_tool $device_serial shell ps 2>&1`; # get current processes -# $output =~ s/\r//g; # replace all "\r" with "" -# chomp($output); -# print $output; -# if ($output =~ m/^.*_\d+\s+(\d+).*S $process/) # check the procress -# { -# print("Killing $process PID:$1\n"); -# system("$adb_tool $device_serial shell kill $1"); -# waitForProcess($process,0,20); -# } -# else -# { -# print("Can't kill the process $process\n"); -# } -} - - -sub startTest -{ - my $libs = shift; - my $mainLib = shift; - my $openGL = ((shift)?"true":"false"); - system("$adb_tool $device_serial shell am start -n $intentName --ez needsOpenGl $openGL --es extra_libs \"$libs\" --es lib_name \"$mainLib\""); # start intent - #wait to start - return 0 unless(waitForProcess($packageName,1,10)); - #wait to stop - unless(waitForProcess($packageName,0,$time_out,5)) - { - killProcess($packageName); - return 1; - } - my $output_file = shift; - system("$adb_tool $device_serial pull /data/data/$packageName/app_files/output.xml $output_dir/$output_file"); - return 1; -} - -sub needsOpenGl -{ - my $app=$readelf_tool.shift.' |grep -e "^.*(NEEDED).*Shared library: \[libQtOpenGL\.so\]$"'; - my $res=`$app`; - chomp $res; - return $res; -} - -########### delpoy qt libs ########### -if ($deploy_qt) -{ - - pushd($src_dir_qt); - mkdir("$temp_dir/lib"); - my @libs=`find lib -name *.so`; # libs must be handled diferently - foreach (@libs) - { - chomp; - print ("cp -L $_ $temp_dir/lib\n"); - system("cp -L $_ $temp_dir/lib"); - } - system("cp -L $android_ndk_dir/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/libgnustl_shared.so $temp_dir/lib"); - system("cp -a plugins $temp_dir"); - system("cp -a imports $temp_dir"); - system("cp -a qml $temp_dir"); - pushd($temp_dir); - system("find -name *.so | xargs $strip_tool --strip-unneeded"); - popd; - system("$adb_tool $device_serial shell rm -r /data/local/tmp/qt"); # remove old qt libs - system("$adb_tool $device_serial push $temp_dir /data/local/tmp/qt"); # copy newer qt libs - popd; -} - -########### build & install quadruplor ########### -reinstallQuadruplor; - -########### build qt tests and benchmarks ########### -pushd($tests_dir); -print "Building $tests_dir \n"; -system("make distclean") if ($make_clean); -system("$qmake_path CONFIG-=QTDIR_build -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 - system("make INSTALL_ROOT=$temp_dir install"); # install the application to temp dir - system("$adb_tool $device_serial shell rm -r /data/data/$packageName/app_files/*"); # remove old data - system("$adb_tool $device_serial push $temp_dir /data/data/$packageName/app_files"); # copy - my $application=basename(cwd); - 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=5*60/5; # 5 minutes time out for a normal test - if (-e "$temp_dir/libtst_bench_$application.so") - { - $time_out=5*60/5; # 10 minutes for a benchmark - $application = "bench_$application"; - } - - if (-e "$temp_dir/libtst_$application.so") - { - if (needsOpenGl("$temp_dir/libtst_$application.so")) - { - startTest("/data/local/tmp/qt/plugins/platforms/android/libqtforandroidGL.so", "/data/data/$packageName/app_files/libtst_$application.so", 1 - , "$output_name.xml") or warn "Can't run $application ...\n"; - } - else - { - startTest("/data/local/tmp/qt/plugins/platforms/android/libqtforandroid.so", "/data/data/$packageName/app_files/libtst_$application.so", 0 - , "$output_name.xml") or warn "Can't run $application stopping tests ...\n"; - } - } - else - { #ups this test application doesn't respect name convention - warn "$application test application doesn't respect name convention please fix it !\n"; - } - popd(); - remove_tree( $temp_dir, {keep_root => 1} ); -} -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<-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<-d --deploy> - -Deploy current qt libs. - -=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<-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/android/src/org/qtproject/qt5/android/QtActivity.java b/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java deleted file mode 100644 index ed190fdc1b..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra <bogdan@kde.org> - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; - -import org.qtproject.qt5.android.tests.R; - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.graphics.Rect; -import android.os.Bundle; -import android.text.method.MetaKeyKeyListener; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.KeyCharacterMap; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.Window; -import android.view.WindowManager; -import android.view.inputmethod.InputMethodManager; - -public class QtActivity extends Activity { - private int m_id =- 1; - private boolean softwareKeyboardIsVisible = false; - private long m_metaState; - private int m_lastChar = 0; - private boolean m_fullScreen = false; - private boolean m_started = false; - private QtSurface m_surface = null; - private boolean m_usesGL = false; - private void loadQtLibs(String[] libs, String environment, String params, String mainLib, String nativeLibDir) throws Exception - { - QtNative.loadQtLibraries(libs); - // start application - - final String envPaths = "NECESSITAS_API_LEVEL=2\tHOME=" + getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE).getAbsolutePath() + - "\tTMPDIR=" + getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE).getAbsolutePath() + - "\tCACHE_PATH=" + getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE).getAbsolutePath(); - if (environment != null && environment.length() > 0) - environment = envPaths + "\t" + environment; - else - environment = envPaths; - - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - QtNative.startApplication(params, environment, mainLib, nativeLibDir); - m_surface.applicationStarted(m_usesGL); - m_started = true; - } - - private boolean m_quitApp = true; - private Process m_debuggerProcess = null; // debugger process - - private void startApp(final boolean firstStart) - { - try { - String qtLibs[] = getResources().getStringArray(R.array.qt_libs); - ArrayList<String> libraryList = new ArrayList<String>(); - for (int i = 0; i < qtLibs.length; i++) - libraryList.add("/data/local/tmp/qt/lib/lib" + qtLibs[i] + ".so"); - - String mainLib = null; - String nativeLibDir = null; - if (getIntent().getExtras() != null) { - if (getIntent().getExtras().containsKey("extra_libs")) { - String extra_libs = getIntent().getExtras().getString("extra_libs"); - for (String lib : extra_libs.split(":")) - libraryList.add(lib); - } - if (getIntent().getExtras().containsKey("lib_name")) { - mainLib = getIntent().getExtras().getString("lib_name"); - libraryList.add(mainLib); - int slash = mainLib.lastIndexOf("/"); - if (slash >= 0) { - nativeLibDir = mainLib.substring(0, slash+1); - mainLib = mainLib.substring(slash+1+3, mainLib.length()-3); //remove lib and .so - } else { - nativeLibDir = ""; - } - } - - if (getIntent().getExtras().containsKey("needsOpenGl")) - m_usesGL = getIntent().getExtras().getBoolean("needsOpenGl"); - } else { - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - finish(); - System.exit(0); - } - String[] libs = new String[libraryList.size()]; - libs = libraryList.toArray(libs); - loadQtLibs(libs - ,"QT_QPA_EGLFS_HIDECURSOR=1\tQML2_IMPORT_PATH=/data/local/tmp/qt/qml\tQML_IMPORT_PATH=/data/local/tmp/qt/imports\tQT_PLUGIN_PATH=/data/local/tmp/qt/plugins" - , "-xml\t-silent\t-o\toutput.xml", mainLib, nativeLibDir); - } catch (Exception e) { - Log.e(QtNative.QtTAG, "Can't create main activity", e); - } - } - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - getDir("files", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE); - requestWindowFeature(Window.FEATURE_NO_TITLE); - m_quitApp = true; - QtNative.setMainActivity(this); - if (null == getLastNonConfigurationInstance()) { - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, metrics.heightPixels, - metrics.widthPixels, metrics.heightPixels, - metrics.xdpi, metrics.ydpi); - } - m_surface = new QtSurface(this, m_id); - setContentView(m_surface); - if (null == getLastNonConfigurationInstance()) - startApp(true); - } - - public QtSurface getQtSurface() - { - return m_surface; - } - - @Override - public Object onRetainNonConfigurationInstance() - { - super.onRetainNonConfigurationInstance(); - m_quitApp = false; - return true; - } - - @Override - protected void onDestroy() - { - QtNative.setMainActivity(null); - super.onDestroy(); - if (m_quitApp) { - Log.i(QtNative.QtTAG, "onDestroy"); - if (m_debuggerProcess != null) - m_debuggerProcess.destroy(); - System.exit(0);// FIXME remove it or find a better way - } - QtNative.setMainActivity(null); - } - - @Override - protected void onResume() - { - // fire all lostActions - synchronized (QtNative.m_mainActivityMutex) { - Iterator<Runnable> itr = QtNative.getLostActions().iterator(); - while (itr.hasNext()) - runOnUiThread(itr.next()); - if (m_started) { - QtNative.clearLostActions(); - QtNative.updateWindow(); - } - } - super.onResume(); - } - - public void redrawWindow(int left, int top, int right, int bottom) - { - m_surface.drawBitmap(new Rect(left, top, right, bottom)); - } - - public void setFullScreen(boolean enterFullScreen) - { - if (m_fullScreen == enterFullScreen) - return; - if (m_fullScreen = enterFullScreen) - getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - else - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - } - - @Override - protected void onSaveInstanceState(Bundle outState) - { - super.onSaveInstanceState(outState); - outState.putBoolean("FullScreen", m_fullScreen); - outState.putBoolean("Started", m_started); - } - - @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) - { - super.onRestoreInstanceState(savedInstanceState); - setFullScreen(savedInstanceState.getBoolean("FullScreen")); - m_started = savedInstanceState.getBoolean("Started"); - if (m_started) - m_surface.applicationStarted(true); - } - - public void showSoftwareKeyboard() - { - softwareKeyboardIsVisible = true; - InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); - } - - public void resetSoftwareKeyboard() - { - } - - public void hideSoftwareKeyboard() - { - if (softwareKeyboardIsVisible) { - InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); - imm.toggleSoftInput(0, 0); - } - softwareKeyboardIsVisible = false; - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) - { - if (m_started && event.getAction() == KeyEvent.ACTION_MULTIPLE && - event.getCharacters() != null && - event.getCharacters().length() == 1 && - event.getKeyCode() == 0) { - Log.i(QtNative.QtTAG, "dispatchKeyEvent at MULTIPLE with one character: " + event.getCharacters()); - QtNative.keyDown(0, event.getCharacters().charAt(0), event.getMetaState()); - QtNative.keyUp(0, event.getCharacters().charAt(0), event.getMetaState()); - } - - return super.dispatchKeyEvent(event); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) - { - if (!m_started) - return false; - m_metaState = MetaKeyKeyListener.handleKeyDown(m_metaState, keyCode, event); - int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(m_metaState)); - int lc = c; - m_metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(m_metaState); - - if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) { - c = c & KeyCharacterMap.COMBINING_ACCENT_MASK; - int composed = KeyEvent.getDeadChar(m_lastChar, c); - c = composed; - } - m_lastChar = lc; - if (keyCode != KeyEvent.KEYCODE_BACK) - QtNative.keyDown(keyCode, c, event.getMetaState()); - return true; - } - - @Override - public boolean onKeyUp(int keyCode, KeyEvent event) - { - if (!m_started) - return false; - m_metaState = MetaKeyKeyListener.handleKeyUp(m_metaState, keyCode, event); - QtNative.keyUp(keyCode, event.getUnicodeChar(), event.getMetaState()); - return true; - } - - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - } - -/* public boolean onCreateOptionsMenu(Menu menu) - { - QtNative.createOptionsMenu(menu); - try { - return onPrepareOptionsMenu(menu); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean onPrepareOptionsMenu(Menu menu) - { - QtNative.prepareOptionsMenu(menu); - try { - return (Boolean) onPrepareOptionsMenu(menu); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean onOptionsItemSelected(MenuItem item) - { - return QtNative.optionsItemSelected(item.getGroupId(), item.getItemId()); - }*/ -} diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtInputConnection.java b/tests/auto/android/src/org/qtproject/qt5/android/QtInputConnection.java deleted file mode 100644 index e69a03061b..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtInputConnection.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra <bogdan@kde.org> - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import android.content.Context; -import android.content.Intent; -import android.text.Editable; -import android.text.InputFilter; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.view.inputmethod.BaseInputConnection; -import android.view.inputmethod.CompletionInfo; -import android.view.inputmethod.ExtractedText; -import android.view.inputmethod.ExtractedTextRequest; -import android.view.inputmethod.InputMethodManager; - -class QtExtractedText -{ - public int partialEndOffset; - public int partialStartOffset; - public int selectionEnd; - public int selectionStart; - public int startOffset; - public String text; -} - -class QtNativeInputConnection -{ - static native boolean commitText(String text, int newCursorPosition); - static native boolean commitCompletion(String text, int position); - static native boolean deleteSurroundingText(int leftLength, int rightLength); - static native boolean finishComposingText(); - static native int getCursorCapsMode(int reqModes); - static native QtExtractedText getExtractedText(int hintMaxChars, int hintMaxLines, int flags); - static native String getSelectedText(int flags); - static native String getTextAfterCursor(int length, int flags); - static native String getTextBeforeCursor(int length, int flags); - static native boolean setComposingText(String text, int newCursorPosition); - static native boolean setSelection(int start, int end); - static native boolean selectAll(); - static native boolean cut(); - static native boolean copy(); - static native boolean copyURL(); - static native boolean paste(); -} - -public class QtInputConnection extends BaseInputConnection -{ - private static final int ID_SELECT_ALL = android.R.id.selectAll; - private static final int ID_START_SELECTING_TEXT = android.R.id.startSelectingText; - private static final int ID_STOP_SELECTING_TEXT = android.R.id.stopSelectingText; - private static final int ID_CUT = android.R.id.cut; - private static final int ID_COPY = android.R.id.copy; - private static final int ID_PASTE = android.R.id.paste; - private static final int ID_COPY_URL = android.R.id.copyUrl; - private static final int ID_SWITCH_INPUT_METHOD = android.R.id.switchInputMethod; - private static final int ID_ADD_TO_DICTIONARY = android.R.id.addToDictionary; - View m_view; - - public QtInputConnection(View targetView) - { - super(targetView, true); - m_view = targetView; - } - - @Override - public boolean beginBatchEdit() - { - return true; - } - - @Override - public boolean endBatchEdit() - { - return true; - } - - @Override - public boolean commitCompletion(CompletionInfo text) - { - return QtNativeInputConnection.commitCompletion(text.getText().toString(), text.getPosition()); - } - - @Override - public boolean commitText(CharSequence text, int newCursorPosition) - { - return QtNativeInputConnection.commitText(text.toString(), newCursorPosition); - } - - @Override - public boolean deleteSurroundingText(int leftLength, int rightLength) - { - return QtNativeInputConnection.deleteSurroundingText(leftLength, rightLength); - } - - @Override - public boolean finishComposingText() - { - return QtNativeInputConnection.finishComposingText(); - } - - @Override - public int getCursorCapsMode(int reqModes) - { - return QtNativeInputConnection.getCursorCapsMode(reqModes); - } - - @Override - public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) - { - QtExtractedText qExtractedText = QtNativeInputConnection.getExtractedText(request.hintMaxChars, request.hintMaxLines, flags); - ExtractedText extractedText = new ExtractedText(); - extractedText.partialEndOffset = qExtractedText.partialEndOffset; - extractedText.partialStartOffset = qExtractedText.partialStartOffset; - extractedText.selectionEnd = qExtractedText.selectionEnd; - extractedText.selectionStart = qExtractedText.selectionStart; - extractedText.startOffset = qExtractedText.startOffset; - extractedText.text = qExtractedText.text; - return extractedText; - } - - public CharSequence getSelectedText(int flags) - { - return QtNativeInputConnection.getSelectedText(flags); - } - - @Override - public CharSequence getTextAfterCursor(int length, int flags) - { - return QtNativeInputConnection.getTextAfterCursor(length, flags); - } - - @Override - public CharSequence getTextBeforeCursor(int length, int flags) - { - return QtNativeInputConnection.getTextBeforeCursor(length, flags); - } - - @Override - public boolean performContextMenuAction(int id) - { - switch (id) { - case ID_SELECT_ALL: - return QtNativeInputConnection.selectAll(); - case ID_COPY: - return QtNativeInputConnection.copy(); - case ID_COPY_URL: - return QtNativeInputConnection.copyURL(); - case ID_CUT: - return QtNativeInputConnection.cut(); - case ID_PASTE: - return QtNativeInputConnection.paste(); - - case ID_SWITCH_INPUT_METHOD: - InputMethodManager imm = (InputMethodManager)m_view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - if (imm != null) { - imm.showInputMethodPicker(); - } - return true; - - case ID_ADD_TO_DICTIONARY: -// TODO -// String word = m_editable.subSequence(0, m_editable.length()).toString(); -// if (word != null) { -// Intent i = new Intent("com.android.settings.USER_DICTIONARY_INSERT"); -// i.putExtra("word", word); -// i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); -// m_view.getContext().startActivity(i); -// } - return true; - } - return super.performContextMenuAction(id); - } - - @Override - public boolean setComposingText(CharSequence text, int newCursorPosition) { - return QtNativeInputConnection.setComposingText(text.toString(), newCursorPosition); - } - - @Override - public boolean setSelection(int start, int end) { - return QtNativeInputConnection.setSelection(start, end); - } -} diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java b/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java deleted file mode 100644 index a61543d31a..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra <bogdan@kde.org> - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import java.io.File; -import java.util.ArrayList; - -import android.app.Activity; -import android.app.Application; -import android.content.Intent; -import android.net.Uri; -import android.util.Log; -import android.view.ContextMenu; -import android.view.Menu; -import android.view.MotionEvent; - -public class QtNative extends Application -{ - private static QtActivity m_mainActivity = null; - private static QtSurface m_mainView = null; - public static Object m_mainActivityMutex = new Object(); // mutex used to synchronize runnable operations - - public static final String QtTAG = "Qt JAVA"; // string used for Log.x - private static ArrayList<Runnable> m_lostActions = new ArrayList<Runnable>(); // a list containing all actions which could not be performed (e.g. the main activity is destroyed, etc.) - private static boolean m_started = false; - private static int m_displayMetricsScreenWidthPixels = 0; - private static int m_displayMetricsScreenHeightPixels = 0; - private static int m_displayMetricsDesktopWidthPixels = 0; - private static int m_displayMetricsDesktopHeightPixels = 0; - private static double m_displayMetricsXDpi = .0; - private static double m_displayMetricsYDpi = .0; - private static int m_oldx, m_oldy; - private static final int m_moveThreshold = 0; - - public static ClassLoader classLoader() - { - return m_mainActivity.getClassLoader(); - } - - public static Activity activity() - { - return m_mainActivity; - } - - public static QtSurface mainView() - { - return m_mainView; - } - - public static void openURL(String url) - { - Uri uri = Uri.parse(url); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - activity().startActivity(intent); - } - - // this method loads full path libs - public static void loadQtLibraries(String[] libraries) - { - if (libraries == null) - return; - - for (int i = 0; i < libraries.length; i++) { - try { - File f = new File(libraries[i]); - if (f.exists()) - System.load(libraries[i]); - } catch (SecurityException e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } catch (Exception e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } - } - } - - // this method loads bundled libs by name. - public static void loadBundledLibraries(String[] libraries) - { - for (int i = 0; i < libraries.length; i++) { - try { - System.loadLibrary(libraries[i]); - } catch (UnsatisfiedLinkError e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } catch (SecurityException e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } catch (Exception e) { - Log.i(QtTAG, "Can't load '" + libraries[i] + "'", e); - } - } - } - - public static void setMainActivity(QtActivity qtMainActivity) - { - synchronized (m_mainActivityMutex) { - m_mainActivity = qtMainActivity; - } - } - public static void setMainView(QtSurface qtSurface) - { - synchronized (m_mainActivityMutex) { - m_mainView = qtSurface; - } - } - - static public ArrayList<Runnable> getLostActions() - { - return m_lostActions; - } - - static public void clearLostActions() - { - m_lostActions.clear(); - } - - private static boolean runAction(Runnable action) - { - synchronized (m_mainActivityMutex) { - if (m_mainActivity == null) - m_lostActions.add(action); - else - m_mainActivity.runOnUiThread(action); - return m_mainActivity != null; - } - } - - public static boolean startApplication(String params, String environment, String mainLibrary, String nativeLibraryDir) throws Exception - { - File f = new File(nativeLibraryDir+"lib"+mainLibrary+".so"); - if (!f.exists()) - throw new Exception("Can't find main library '" + mainLibrary + "'"); - - if (params == null) - params = "-platform\tandroid"; - - boolean res = false; - synchronized (m_mainActivityMutex) { - res = startQtAndroidPlugin(); - setDisplayMetrics(m_displayMetricsScreenWidthPixels, - m_displayMetricsScreenHeightPixels, - m_displayMetricsDesktopWidthPixels, - m_displayMetricsDesktopHeightPixels, - m_displayMetricsXDpi, - m_displayMetricsYDpi, - 1.0); - startQtApplication(f.getAbsolutePath()+"\t"+params, environment); - m_started = true; - } - return res; - } - - public static void setApplicationDisplayMetrics(int screenWidthPixels, - int screenHeightPixels, int desktopWidthPixels, - int desktopHeightPixels, double XDpi, double YDpi) - { - /* Fix buggy dpi report */ - if (XDpi < android.util.DisplayMetrics.DENSITY_LOW) - XDpi = android.util.DisplayMetrics.DENSITY_LOW; - if (YDpi < android.util.DisplayMetrics.DENSITY_LOW) - YDpi = android.util.DisplayMetrics.DENSITY_LOW; - - synchronized (m_mainActivityMutex) { - if (m_started) { - setDisplayMetrics(screenWidthPixels, screenHeightPixels, desktopWidthPixels, desktopHeightPixels, XDpi, YDpi, 1.0); - } else { - m_displayMetricsScreenWidthPixels = screenWidthPixels; - m_displayMetricsScreenHeightPixels = screenHeightPixels; - m_displayMetricsDesktopWidthPixels = desktopWidthPixels; - m_displayMetricsDesktopHeightPixels = desktopHeightPixels; - m_displayMetricsXDpi = XDpi; - m_displayMetricsYDpi = YDpi; - } - } - } - - public static void pauseApplication() - { - synchronized (m_mainActivityMutex) { - if (m_started) - pauseQtApp(); - } - } - - public static void resumeApplication() - { - synchronized (m_mainActivityMutex) { - if (m_started) { - resumeQtApp(); - updateWindow(); - } - } - } - // application methods - public static native void startQtApplication(String params, String env); - public static native void pauseQtApp(); - public static native void resumeQtApp(); - public static native boolean startQtAndroidPlugin(); - public static native void quitQtAndroidPlugin(); - public static native void terminateQt(); - // application methods - - private static void quitApp() - { - m_mainActivity.finish(); - } - - private static void redrawSurface(final int left, final int top, final int right, final int bottom ) - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.redrawWindow(left, top, right, bottom); - } - }); - } - - @Override - public void onTerminate() - { - if (m_started) - terminateQt(); - super.onTerminate(); - } - - - static public void sendTouchEvent(MotionEvent event, int id) - { - switch (event.getAction()) { - case MotionEvent.ACTION_UP: - mouseUp(id,(int) event.getX(), (int) event.getY()); - break; - - case MotionEvent.ACTION_DOWN: - mouseDown(id,(int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - break; - - case MotionEvent.ACTION_MOVE: - int dx = (int) (event.getX() - m_oldx); - int dy = (int) (event.getY() - m_oldy); - if (Math.abs(dx) > m_moveThreshold || Math.abs(dy) > m_moveThreshold) { - mouseMove(id,(int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - } - break; - } - } - - static public void sendTrackballEvent(MotionEvent event, int id) - { - switch (event.getAction()) { - case MotionEvent.ACTION_UP: - mouseUp(id, (int) event.getX(), (int) event.getY()); - break; - - case MotionEvent.ACTION_DOWN: - mouseDown(id, (int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - break; - - case MotionEvent.ACTION_MOVE: - int dx = (int) (event.getX() - m_oldx); - int dy = (int) (event.getY() - m_oldy); - if (Math.abs(dx) > 5 || Math.abs(dy) > 5) { - mouseMove(id, (int) event.getX(), (int) event.getY()); - m_oldx = (int) event.getX(); - m_oldy = (int) event.getY(); - } - break; - } - } - - private static void updateSelection(final int selStart, final int selEnd, final int candidatesStart, final int candidatesEnd) - { - } - - private static void showSoftwareKeyboard(final int x, final int y - , final int width, final int height - , final int inputHints ) - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.showSoftwareKeyboard(); - } - }); - } - - private static void resetSoftwareKeyboard() - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.resetSoftwareKeyboard(); - } - }); - } - - private static void hideSoftwareKeyboard() - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.hideSoftwareKeyboard(); - } - }); - } - - private static boolean isSoftwareKeyboardVisible() - { - return false; - } - - private static void setFullScreen(final boolean fullScreen) - { - runAction(new Runnable() { - @Override - public void run() { - m_mainActivity.setFullScreen(fullScreen); - updateWindow(); - } - }); - } - - private static void registerClipboardManager() - { - } - - private static void setClipboardText(String text) - { - } - - private static boolean hasClipboardText() - { - return false; - } - - private static String getClipboardText() - { - return "Qt"; - } - - private static void openContextMenu() - { - } - - private static void closeContextMenu() - { - } - - private static void resetOptionsMenu() - { - } - - // screen methods - public static native void setDisplayMetrics(int screenWidthPixels, - int screenHeightPixels, - int desktopWidthPixels, - int desktopHeightPixels, - double XDpi, - double YDpi, - double scaledDensity); - public static native void handleOrientationChanged(int newOrientation); - // screen methods - - private static void showOptionsMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.openOptionsMenu(); - } - }); - } - - private static void hideOptionsMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.closeOptionsMenu(); - } - }); - } - - private static void showContextMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.openContextMenu(m_mainView); - } - }); - } - - private static void hideContextMenu() - { - runAction(new Runnable() { - @Override - public void run() { - if (m_mainActivity != null) - m_mainActivity.closeContextMenu(); - } - }); - } - - // pointer methods - public static native void mouseDown(int winId, int x, int y); - public static native void mouseUp(int winId, int x, int y); - public static native void mouseMove(int winId, int x, int y); - public static native void touchBegin(int winId); - public static native void touchAdd(int winId, int pointerId, int action, boolean primary, int x, int y, float size, float pressure); - public static native void touchEnd(int winId, int action); - public static native void longPress(int winId, int x, int y); - // pointer methods - - // keyboard methods - public static native void keyDown(int key, int unicode, int modifier); - public static native void keyUp(int key, int unicode, int modifier); - // keyboard methods - - // surface methods - public static native void destroySurface(); - public static native void setSurface(Object surface); - public static native void lockSurface(); - public static native void unlockSurface(); - // surface methods - - // window methods - public static native void updateWindow(); - // window methods - - // menu methods - public static native boolean onPrepareOptionsMenu(Menu menu); - public static native boolean onOptionsItemSelected(int itemId, boolean checked); - public static native void onOptionsMenuClosed(Menu menu); - - public static native void onCreateContextMenu(ContextMenu menu); - public static native boolean onContextItemSelected(int itemId, boolean checked); - public static native void onContextMenuClosed(Menu menu); - // menu methods -} diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtSurface.java b/tests/auto/android/src/org/qtproject/qt5/android/QtSurface.java deleted file mode 100644 index 7e7db031ec..0000000000 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtSurface.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - Copyright (c) 2012, BogDan Vatra <bogdan@kde.org> - Contact: http://www.qt-project.org/legal - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package org.qtproject.qt5.android; - -import android.app.Activity; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.PixelFormat; -import android.graphics.Rect; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.SurfaceView; - -public class QtSurface extends SurfaceView implements SurfaceHolder.Callback -{ - private Bitmap m_bitmap=null; - private boolean m_started = false; - private boolean m_usesGL = false; - public QtSurface(Context context, int id) - { - super(context); - setFocusable(true); - getHolder().addCallback(this); - getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU); - setId(id); - } - - public void applicationStarted(boolean usesGL) - { - m_started = true; - m_usesGL = usesGL; - if (getWidth() < 1 || getHeight() < 1) - return; - if (m_usesGL) { - QtNative.setSurface(getHolder().getSurface()); - } else { - QtNative.lockSurface(); - QtNative.setSurface(null); - m_bitmap=Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); - QtNative.setSurface(m_bitmap); - QtNative.unlockSurface(); - } - } - - @Override - public void surfaceCreated(SurfaceHolder holder) - { - DisplayMetrics metrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, - metrics.heightPixels, getWidth(), getHeight(), metrics.xdpi, metrics.ydpi); - - if (m_usesGL) - holder.setFormat(PixelFormat.RGBA_8888); - else - holder.setFormat(PixelFormat.RGB_565); - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) - { - Log.i(QtNative.QtTAG,"surfaceChanged: "+width+","+height); - if (width < 1 || height < 1) - return; - - DisplayMetrics metrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, - metrics.heightPixels, width, height, metrics.xdpi, metrics.ydpi); - - if (!m_started) - return; - - if (m_usesGL) { - QtNative.setSurface(holder.getSurface()); - } else { - QtNative.lockSurface(); - QtNative.setSurface(null); - m_bitmap=Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); - QtNative.setSurface(m_bitmap); - QtNative.unlockSurface(); - QtNative.updateWindow(); - } - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) - { - Log.i(QtNative.QtTAG,"surfaceDestroyed "); - if (m_usesGL) { - QtNative.destroySurface(); - } else { - if (!m_started) - return; - - QtNative.lockSurface(); - QtNative.setSurface(null); - QtNative.unlockSurface(); - } - } - - public void drawBitmap(Rect rect) - { - if (!m_started) - return; - QtNative.lockSurface(); - if (null != m_bitmap) { - try { - Canvas cv=getHolder().lockCanvas(rect); - cv.drawBitmap(m_bitmap, rect, rect, null); - getHolder().unlockCanvasAndPost(cv); - } catch (Exception e) { - Log.e(QtNative.QtTAG, "Can't create main activity", e); - } - } - QtNative.unlockSurface(); - } - - @Override - public boolean onTouchEvent(MotionEvent event) - { - if (!m_started) - return false; - QtNative.sendTouchEvent(event, getId()); - return true; - } - - @Override - public boolean onTrackballEvent(MotionEvent event) - { - if (!m_started) - return false; - QtNative.sendTrackballEvent(event, getId()); - return true; - } -} diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index a9aecc9448..01952aac3c 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -24,9 +24,18 @@ ios: SUBDIRS = corelib gui wince*: SUBDIRS -= printsupport cross_compile: SUBDIRS -= tools !qtHaveModule(opengl): SUBDIRS -= opengl -!unix|embedded|!qtHaveModule(dbus): SUBDIRS -= dbus !qtHaveModule(gui): SUBDIRS -= gui cmake !qtHaveModule(widgets): SUBDIRS -= widgets !qtHaveModule(printsupport): SUBDIRS -= printsupport !qtHaveModule(concurrent): SUBDIRS -= concurrent !qtHaveModule(network): SUBDIRS -= network + +# Disable the QtDBus tests if we can't connect to the session bus +qtHaveModule(dbus) { + !system("dbus-send --type=signal / local.AutotestCheck.Hello"): { + warning("QtDBus is enabled but session bus is not available. Please check the installation.") + SUBDIRS -= dbus + } +} else { + SUBDIRS -= dbus +} diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index a966f557f5..1b7f28bbfa 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -39,8 +39,12 @@ #include <private/qabstractanimation_p.h> -#ifdef Q_OS_WIN -static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution"; +#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID) +# define BAD_TIMER_RESOLUTION +#endif + +#ifdef BAD_TIMER_RESOLUTION +static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution"; #endif class TestablePauseAnimation : public QPauseAnimation @@ -140,17 +144,17 @@ void tst_QPauseAnimation::noTimerUpdates() animation.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); const int expectedLoopCount = 1 + loopCount; -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != expectedLoopCount) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount); } @@ -169,41 +173,41 @@ void tst_QPauseAnimation::multiplePauseAnimations() animation2.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Running) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Running); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, 2); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 2); QTest::qWait(550); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 3); } @@ -232,9 +236,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations() QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); QVERIFY(pause.state() == QAbstractAnimation::Stopped); @@ -253,9 +257,9 @@ void tst_QPauseAnimation::pauseResume() animation.start(); QTRY_COMPARE(animation.state(), QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount < 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY2(animation.m_updateCurrentTimeCount >= 3, qPrintable( QString::fromLatin1("animation.m_updateCurrentTimeCount = %1").arg(animation.m_updateCurrentTimeCount))); @@ -408,39 +412,39 @@ void tst_QPauseAnimation::multipleSequentialGroups() // measure... QTest::qWait(group.totalDuration() + 500); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (group.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(group.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup1.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup3.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup3.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup4.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (pause5.m_updateCurrentTimeCount != 4) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(pause5.m_updateCurrentTimeCount, 4); } diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 749c7da789..140b349c64 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -40,6 +40,9 @@ class tst_qmessagehandler : public QObject { Q_OBJECT +public: + tst_qmessagehandler(); + public slots: void initTestCase(); @@ -92,6 +95,12 @@ void customMsgHandler(QtMsgType type, const char *msg) s_message = QString::fromLocal8Bit(msg); } +tst_qmessagehandler::tst_qmessagehandler() +{ + // ensure it's unset, otherwise we'll have trouble + qputenv("QT_MESSAGE_PATTERN", ""); +} + void tst_qmessagehandler::initTestCase() { m_appDir = QFINDTESTDATA("app"); @@ -756,6 +765,12 @@ void tst_qmessagehandler::qMessagePattern_data() << "A DEBUG qDebug " << "A qWarning "); + QTest::newRow("pid") << "%{pid}: %{message}" + << true << QList<QByteArray>(); // can't match anything, just test validity + QTest::newRow("threadid") << "ThreadId:%{threadid}: %{message}" + << true << (QList<QByteArray>() + << "ThreadId:0x"); + // This test won't work when midnight is too close... wait a bit while (QTime::currentTime() > QTime(23, 59, 30)) QTest::qWait(10000); @@ -811,6 +826,7 @@ void tst_qmessagehandler::qMessagePattern() process.start(appExe); QVERIFY2(process.waitForStarted(), qPrintable( QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString()))); + QByteArray pid = QByteArray::number(process.processId()); process.waitForFinished(); QByteArray output = process.readAllStandardError(); @@ -825,6 +841,8 @@ void tst_qmessagehandler::qMessagePattern() QVERIFY(output.contains(e)); } } + if (pattern.startsWith("%{pid}")) + QVERIFY2(output.startsWith('"' + pid), "PID: " + pid + "\noutput:\n" + output); #endif } diff --git a/tests/auto/corelib/io/qdir/android_testdata.qrc b/tests/auto/corelib/io/qdir/android_testdata.qrc new file mode 100644 index 0000000000..52cf4da330 --- /dev/null +++ b/tests/auto/corelib/io/qdir/android_testdata.qrc @@ -0,0 +1,44 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>tst_qdir.cpp</file> + <file>entrylist/file</file> + <file>entrylist/directory/dummy</file> + <file>searchdir/subdir1/picker.png</file> + <file>searchdir/subdir2/picker.png</file> + <file>testData/empty</file> + <file>testdir/dir/tmp/empty</file> + <file>testdir/dir/qdir.pro</file> + <file>testdir/dir/qrc_qdir.cpp</file> + <file>testdir/dir/tst_qdir.cpp</file> + <file>testdir/spaces/foo. bar</file> + <file>testdir/spaces/foo.bar</file> + <file>types/a</file> + <file>types/a.a</file> + <file>types/a.b</file> + <file>types/a.c</file> + <file>types/b</file> + <file>types/b.a</file> + <file>types/b.b</file> + <file>types/b.c</file> + <file>types/c</file> + <file>types/c.a</file> + <file>types/c.b</file> + <file>types/c.c</file> + <file>types/d/dummy</file> + <file>types/d.a/dummy</file> + <file>types/d.c/dummy</file> + <file>types/d.b/dummy</file> + <file>types/e/dummy</file> + <file>types/e.a/dummy</file> + <file>types/e.c/dummy</file> + <file>types/f/dummy</file> + <file>types/f.a/dummy</file> + <file>types/f.b/dummy</file> + <file>types/f.c/dummy</file> + <file>types/e.b/dummy</file> + <file>resources/entryList/file1.data</file> + <file>resources/entryList/file2.data</file> + <file>resources/entryList/file3.data</file> + <file>resources/entryList/file4.nothing</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index e2b25866df..d3e954bd32 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -6,3 +6,7 @@ RESOURCES += qdir.qrc TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 49e3264617..484130f163 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -214,8 +214,35 @@ private: Q_DECLARE_METATYPE(tst_QDir::UncHandling) tst_QDir::tst_QDir() +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + : m_dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) +#else : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath()) +#endif { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString resourceSourcePath = QStringLiteral(":/android_testdata/"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + + if (!fileInfo.isDir()) { + QString destination = m_dataPath + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length()); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QDir().mkpath(destinationFileInfo.path()); + if (!QFile::copy(fileInfo.filePath(), destination)) + qWarning("Failed to copy %s", qPrintable(fileInfo.filePath())); + } + } + + } + + if (!QDir::setCurrent(m_dataPath)) + qWarning("Couldn't set current path to %s", qPrintable(m_dataPath)); +#endif } void tst_QDir::init() @@ -2028,6 +2055,8 @@ void tst_QDir::equalityOperator_data() //need a path in the root directory that is unlikely to be a symbolic link. #if defined (Q_OS_WIN) QString pathinroot("c:/windows/.."); +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString pathinroot("/system/.."); #else QString pathinroot("/usr/.."); #endif diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index fa6a1978ca..cdece2f8c7 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -119,8 +119,34 @@ private slots: void tst_QDirIterator::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString testdata_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + QString resourceSourcePath = QStringLiteral(":/"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + + if (!fileInfo.isDir()) { + QString destination = testdata_dir + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length()); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QDir().mkpath(destinationFileInfo.path()); + if (!QFile::copy(fileInfo.filePath(), destination)) + qWarning("Failed to copy %s", qPrintable(fileInfo.filePath())); + } + } + + } + + testdata_dir += QStringLiteral("/entrylist"); +#else + // chdir into testdata directory, then find testdata by relative paths. QString testdata_dir = QFileInfo(QFINDTESTDATA("entrylist")).absolutePath(); +#endif + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); QFile::remove("entrylist/entrylist1.lnk"); diff --git a/tests/auto/corelib/io/qfileinfo/android_testdata.qrc b/tests/auto/corelib/io/qfileinfo/android_testdata.qrc new file mode 100644 index 0000000000..ce545cc21c --- /dev/null +++ b/tests/auto/corelib/io/qfileinfo/android_testdata.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>resources/file1</file> + <file>resources/file1.ext1</file> + <file>resources/file1.ext1.ext2</file> + <file>tst_qfileinfo.cpp</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index 64d289bc3c..3fd58b4958 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -8,3 +8,7 @@ TESTDATA += qfileinfo.qrc qfileinfo.pro tst_qfileinfo.cpp resources/file1 resour win32*:!wince*:!winrt:LIBS += -ladvapi32 -lnetapi32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk: { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 22d5da8e68..5b67fd2af5 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -272,9 +272,32 @@ private: void tst_QFileInfo::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString dataPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + QString resourceSourcePath = QStringLiteral(":/android_testdata"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + if (!fileInfo.isDir()) { + QString destination = dataPath + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length()); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QDir().mkpath(destinationFileInfo.path()); + if (!QFile::copy(fileInfo.filePath(), destination)) + qWarning("Failed to copy %s", qPrintable(fileInfo.filePath())); + } + } + } + m_sourceFile = dataPath + QStringLiteral("/tst_qfileinfo.cpp"); + m_resourcesDir = dataPath + QStringLiteral("/resources"); +#else m_sourceFile = QFINDTESTDATA("tst_qfileinfo.cpp"); - QVERIFY(!m_sourceFile.isEmpty()); m_resourcesDir = QFINDTESTDATA("resources"); +#endif + + QVERIFY(!m_sourceFile.isEmpty()); QVERIFY(!m_resourcesDir.isEmpty()); QVERIFY(m_dir.isValid()); QVERIFY(QDir::setCurrent(m_dir.path())); @@ -1137,7 +1160,11 @@ void tst_QFileInfo::fileTimes() QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue); #elif defined(Q_OS_QNX) QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue); +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + if (fileInfo.lastRead() <= beforeRead) + QEXPECT_FAIL("", "Android may use relatime or noatime on mounts", Continue); #endif + QVERIFY(fileInfo.lastRead() > beforeRead); QVERIFY(fileInfo.lastModified() > beforeWrite); QVERIFY(fileInfo.lastModified() < beforeRead); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 4f648a62d6..0a952e9452 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -87,6 +87,10 @@ tst_QFileSystemWatcher::tst_QFileSystemWatcher() m_tempDirPattern += QLatin1Char('/'); m_tempDirPattern += QStringLiteral("tst_qfilesystemwatcherXXXXXX"); #endif // QT_NO_FILESYSTEMWATCHER + +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); +#endif } #ifndef QT_NO_FILESYSTEMWATCHER diff --git a/tests/auto/corelib/io/qiodevice/android_testdata.qrc b/tests/auto/corelib/io/qiodevice/android_testdata.qrc new file mode 100644 index 0000000000..fa4b3d11da --- /dev/null +++ b/tests/auto/corelib/io/qiodevice/android_testdata.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>tst_qiodevice.cpp</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qiodevice/qiodevice.pro b/tests/auto/corelib/io/qiodevice/qiodevice.pro index 9103ff2152..9fd70fb177 100644 --- a/tests/auto/corelib/io/qiodevice/qiodevice.pro +++ b/tests/auto/corelib/io/qiodevice/qiodevice.pro @@ -6,3 +6,8 @@ SOURCES = tst_qiodevice.cpp TESTDATA += tst_qiodevice.cpp MOC_DIR=tmp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk: { + RESOURCES += \ + android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index dec440a6d5..d94893c767 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -62,6 +62,10 @@ private slots: void tst_QIODevice::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists() + || QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp"))); +#endif } // Testing get/set functions diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 1790676028..77bef94550 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -66,7 +66,9 @@ public: void tst_QLockFile::initTestCase() { -#ifdef QT_NO_PROCESS +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QSKIP("This test requires deploying and running external console applications"); +#elif defined(QT_NO_PROCESS) QSKIP("This test requires QProcess support"); #else // chdir to our testdata path and execute helper apps relative to that. diff --git a/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc b/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc new file mode 100644 index 0000000000..7563fb9630 --- /dev/null +++ b/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qtlogging.ini</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro index c6c4caace3..6be5fb1067 100644 --- a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro +++ b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro @@ -6,3 +6,8 @@ QT = core core-private testlib SOURCES += tst_qloggingregistry.cpp OTHER_FILES += qtlogging.ini + +android:!android-no-sdk: { + RESOURCES += \ + android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qresourceengine/android_testdata.qrc b/tests/auto/corelib/io/qresourceengine/android_testdata.qrc new file mode 100644 index 0000000000..ad3389ac20 --- /dev/null +++ b/tests/auto/corelib/io/qresourceengine/android_testdata.qrc @@ -0,0 +1,21 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>runtime_resource.rcc</file> + <file>parentdir.txt</file> + <file>testqrc/blahblah.txt</file> + <file>testqrc/currentdir.txt</file> + <file>testqrc/currentdir2.txt</file> + <file>testqrc/search_file.txt</file> + <file>testqrc/aliasdir/aliasdir.txt</file> + <file>testqrc/aliasdir/compressme.txt</file> + <file>testqrc/otherdir/otherdir.txt</file> + <file>testqrc/searchpath1/search_file.txt</file> + <file>testqrc/searchpath2/search_file.txt</file> + <file>testqrc/subdir/subdir.txt</file> + <file>testqrc/test/test/test2.txt</file> + <file>testqrc/test/test/test1.txt</file> + <file>testqrc/test/german.txt</file> + <file>testqrc/test/testdir.txt</file> + <file>testqrc/test/testdir2.txt</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index b7606eb3fc..92d0952b89 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -16,3 +16,7 @@ TESTDATA += \ testqrc/* GENERATED_TESTDATA = $${runtime_resource.target} DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 20a5fa2786..5f8b79d2fc 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -40,7 +40,13 @@ class tst_QResourceEngine: public QObject Q_OBJECT public: - tst_QResourceEngine() : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) {} + tst_QResourceEngine() +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + : m_runtimeResourceRcc(QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/runtime_resource.rcc")).absoluteFilePath()) +#else + : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) +#endif + {} private slots: void initTestCase(); @@ -62,6 +68,29 @@ private: void tst_QResourceEngine::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString sourcePath(QStringLiteral(":/android_testdata/")); + QString dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); + + QDirIterator it(sourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + if (!fileInfo.isDir()) { + QString destination(dataPath + QLatin1Char('/') + fileInfo.filePath().mid(sourcePath.length())); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QVERIFY(QDir().mkpath(destinationFileInfo.path())); + QVERIFY(QFile::copy(fileInfo.filePath(), destination)); + QVERIFY(QFileInfo(destination).exists()); + } + } + } + + QVERIFY(QDir::setCurrent(dataPath)); +#endif + QVERIFY(!m_runtimeResourceRcc.isEmpty()); QVERIFY(QResource::registerResource(m_runtimeResourceRcc)); QVERIFY(QResource::registerResource(m_runtimeResourceRcc, "/secondary_root/")); @@ -85,16 +114,25 @@ void tst_QResourceEngine::checkStructure_data() QFileInfo info; + QStringList rootContents; + rootContents << QLatin1String("aliasdir") + << QLatin1String("otherdir") + << QLatin1String("qt-project.org") + << QLatin1String("runtime_resource") + << QLatin1String("searchpath1") + << QLatin1String("searchpath2") + << QLatin1String("secondary_root") + << QLatin1String("test") + << QLatin1String("withoutslashes"); + +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + rootContents.insert(1, QLatin1String("android_testdata")); +#endif + QTest::newRow("root dir") << QString(":/") << QString() << (QStringList() << "search_file.txt") - << (QStringList() << QLatin1String("aliasdir") << QLatin1String("otherdir") - << QLatin1String("qt-project.org") - << QLatin1String("runtime_resource") - << QLatin1String("searchpath1") << QLatin1String("searchpath2") - << QLatin1String("secondary_root") - << QLatin1String("test") - << QLatin1String("withoutslashes")) + << rootContents << QLocale::c() << qlonglong(0); diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index a1732a0a79..21e020404b 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -472,7 +472,7 @@ void tst_qstandardpaths::testAllWritableLocations() QString loc = QStandardPaths::writableLocation(location); if (loc.size() > 1) // workaround for unlikely case of locations that return '/' QCOMPARE(loc.endsWith(QLatin1Char('/')), false); - QVERIFY(loc.contains(QLatin1Char('/'))); + QVERIFY(loc.isEmpty() || loc.contains(QLatin1Char('/'))); QVERIFY(!loc.contains(QLatin1Char('\\'))); } diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 3e11ba0717..a68a1185b8 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -237,7 +237,11 @@ void tst_QTemporaryDir::nonWritableCurrentDir() }; ChdirOnReturn cor(QDir::currentPath()); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent("/data"); +#else QDir::setCurrent("/home"); +#endif // QTemporaryDir("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... QTemporaryDir dir("tempXXXXXX"); diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index b3fa47e586..a08a0ae777 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -269,7 +269,12 @@ void tst_QTemporaryFile::nonWritableCurrentDir() }; ChdirOnReturn cor(QDir::currentPath()); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent("/data"); +#else QDir::setCurrent("/home"); +#endif + // QTemporaryFile("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... QTemporaryFile file("tempXXXXXX"); diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro index 25d740f5b9..237e20685a 100644 --- a/tests/auto/corelib/json/json.pro +++ b/tests/auto/corelib/json/json.pro @@ -1,10 +1,11 @@ -TARGET = tst_qtjson +TARGET = tst_json QT = core testlib CONFIG -= app_bundle CONFIG += testcase CONFIG += parallel_test -TESTDATA += test.json test.bjson test3.json test2.json +!android:TESTDATA += test.json test.bjson test3.json test2.json + else:RESOURCES += json.qrc SOURCES += tst_qtjson.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/json/json.qrc b/tests/auto/corelib/json/json.qrc new file mode 100644 index 0000000000..eb122a1779 --- /dev/null +++ b/tests/auto/corelib/json/json.qrc @@ -0,0 +1,9 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>bom.json</file> + <file>test2.json</file> + <file>test3.json</file> + <file>test.json</file> + <file>test.bjson</file> +</qresource> +</RCC> diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp index b4c16c6fa3..c680d93dab 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp @@ -44,14 +44,14 @@ QString valueSpy; Q_DECLARE_METATYPE(QDBusConnection::RegisterOptions) -class MyServer : public QDBusServer +class MyServer : public QDBusServer, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qmyserver") public: - MyServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0) - : QDBusServer(addr, parent), + MyServer(QObject* parent = 0) + : QDBusServer(parent), m_conn("none"), obj(NULL) { @@ -67,6 +67,8 @@ public: public slots: QString address() const { + if (!QDBusServer::isConnected()) + sendErrorReply(QDBusServer::lastError().name(), QDBusServer::lastError().message()); return QDBusServer::address(); } @@ -161,6 +163,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro index dc480fc88c..ddafd528ee 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro +++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.pro @@ -1,6 +1,7 @@ SOURCES = qmyserver.cpp HEADERS = ../myobject.h TARGET = qmyserver +DESTDIR = ./ QT = core dbus CONFIG -= app_bundle DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusabstractadaptor/test/test.pro b/tests/auto/dbus/qdbusabstractadaptor/test/test.pro index 0e4dc91128..3d8f885437 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/test/test.pro +++ b/tests/auto/dbus/qdbusabstractadaptor/test/test.pro @@ -2,6 +2,7 @@ CONFIG += testcase SOURCES += ../tst_qdbusabstractadaptor.cpp HEADERS += ../myobject.h TARGET = ../tst_qdbusabstractadaptor +DESTDIR = ./ QT = core core-private dbus testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 9fe6bc790e..971c939aad 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -491,12 +491,14 @@ void tst_QDBusAbstractAdaptor::initTestCase() commonInit(); // start peer server - #ifdef Q_OS_WIN - proc.start("qmyserver"); - #else - proc.start("./qmyserver/qmyserver"); - #endif - QVERIFY(proc.waitForStarted()); +#ifdef Q_OS_WIN +# define EXE ".exe" +#else +# define EXE "" +#endif + proc.start(QFINDTESTDATA("qmyserver/qmyserver" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); WaitForQMyServer w; QVERIFY(w.ok()); diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp index 6be61ec9e0..49462d388c 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.cpp @@ -38,13 +38,13 @@ static const char serviceName[] = "org.qtproject.autotests.qpinger"; static const char objectPath[] = "/org/qtproject/qpinger"; //static const char *interfaceName = serviceName; -class PingerServer : public QDBusServer +class PingerServer : public QDBusServer, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qpinger") public: - PingerServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0) - : QDBusServer(addr, parent), + PingerServer(QObject* parent = 0) + : QDBusServer(parent), m_conn("none") { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); @@ -54,6 +54,8 @@ public: public slots: QString address() const { + if (!QDBusServer::isConnected()) + sendErrorReply(QDBusServer::lastError().name(), QDBusServer::lastError().message()); return QDBusServer::address(); } @@ -116,6 +118,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro index 5001ec2cd2..957b47e413 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro @@ -1,6 +1,7 @@ SOURCES = qpinger.cpp ../interface.cpp HEADERS = ../interface.h TARGET = qpinger +DESTDIR = ./ CONFIG -= app_bundle CONFIG += console QT = core dbus diff --git a/tests/auto/dbus/qdbusabstractinterface/test/test.pro b/tests/auto/dbus/qdbusabstractinterface/test/test.pro index 223c94866c..afd101455e 100644 --- a/tests/auto/dbus/qdbusabstractinterface/test/test.pro +++ b/tests/auto/dbus/qdbusabstractinterface/test/test.pro @@ -3,6 +3,7 @@ SOURCES += ../tst_qdbusabstractinterface.cpp ../interface.cpp HEADERS += ../interface.h TARGET = ../tst_qdbusabstractinterface +DESTDIR = ./ QT = core testlib QT += dbus diff --git a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 904c1be88f..0cb29d121b 100644 --- a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -51,6 +51,7 @@ class tst_QDBusAbstractInterface: public QObject { Q_OBJECT Interface targetObj; + QString peerAddress; Pinger getPinger(QString service = "", const QString &path = "/") { @@ -81,6 +82,7 @@ public: private slots: void initTestCase(); + void cleanupTestCase(); void init(); void cleanup(); @@ -223,24 +225,20 @@ void tst_QDBusAbstractInterface::initTestCase() QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); con.registerObject("/", &targetObj, QDBusConnection::ExportScriptableContents); -} - -void tst_QDBusAbstractInterface::init() -{ - QDBusConnection con = QDBusConnection::sessionBus(); - QVERIFY(con.isConnected()); // verify service isn't registered by something else // (e.g. a left over qpinger from a previous test run) QVERIFY(!con.interface()->isServiceRegistered(serviceName)); // start peer server - #ifdef Q_OS_WIN - proc.start("qpinger"); - #else - proc.start("./qpinger/qpinger"); - #endif - QVERIFY(proc.waitForStarted()); +#ifdef Q_OS_WIN +# define EXE ".exe" +#else +# define EXE "" +#endif + proc.start(QFINDTESTDATA("qpinger/qpinger" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); // verify service is now registered QTRY_VERIFY(con.interface()->isServiceRegistered(serviceName)); @@ -249,10 +247,33 @@ void tst_QDBusAbstractInterface::init() QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "address"); QDBusMessage rpl = con.call(req); QVERIFY(rpl.type() == QDBusMessage::ReplyMessage); - QString address = rpl.arguments().at(0).toString(); + peerAddress = rpl.arguments().at(0).toString(); +} + +void tst_QDBusAbstractInterface::cleanupTestCase() +{ + // Kill peer, resetting the object exported by a separate process +#ifdef Q_OS_WIN + proc.kill(); // non-GUI processes don't respond to QProcess::terminate() +#else + proc.terminate(); +#endif + QVERIFY(proc.waitForFinished() || proc.state() == QProcess::NotRunning); + + // Wait until the service is certainly not registered + QDBusConnection con = QDBusConnection::sessionBus(); + if (con.isConnected()) { + QTRY_VERIFY(!con.interface()->isServiceRegistered(serviceName)); + } +} + +void tst_QDBusAbstractInterface::init() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); // connect to peer server - QDBusConnection peercon = QDBusConnection::connectToPeer(address, "peer"); + QDBusConnection peercon = QDBusConnection::connectToPeer(peerAddress, "peer"); QVERIFY(peercon.isConnected()); QDBusMessage req2 = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "isConnected"); @@ -265,20 +286,13 @@ void tst_QDBusAbstractInterface::cleanup() { QDBusConnection::disconnectFromPeer("peer"); - // Kill peer, resetting the object exported by a separate process - proc.terminate(); - QVERIFY(proc.waitForFinished() || proc.state() == QProcess::NotRunning); - // Reset the object exported by this process targetObj.m_stringProp = QString(); targetObj.m_variantProp = QDBusVariant(); targetObj.m_complexProp = RegisteredType(); - // Wait until the service is certainly not registered - QDBusConnection con = QDBusConnection::sessionBus(); - if (con.isConnected()) { - QTRY_VERIFY(!con.interface()->isServiceRegistered(serviceName)); - } + QDBusMessage resetCall = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "reset"); + QVERIFY(QDBusConnection::sessionBus().call(resetCall).type() == QDBusMessage::ReplyMessage); } void tst_QDBusAbstractInterface::makeVoidCall() diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index c8d1184226..7e6e742e28 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -296,7 +296,7 @@ void tst_QDBusConnection::connectToPeer() QVERIFY(con.lastError().isValid()); } - QDBusServer server("unix:tmpdir=/tmp", 0); + QDBusServer server; { QDBusConnection con = QDBusConnection::connectToPeer( @@ -381,9 +381,7 @@ class MyServer : public QDBusServer { Q_OBJECT public: - MyServer(QString path, QString addr, QObject* parent) : QDBusServer(addr, parent), - m_path(path), - m_connections() + MyServer(QString path) : m_path(path), m_connections() { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } @@ -446,7 +444,7 @@ void tst_QDBusConnection::registerObjectPeer() { QFETCH(QString, path); - MyServer server(path, "unix:tmpdir=/tmp", 0); + MyServer server(path); QDBusConnection::connectToPeer(server.address(), "beforeFoo"); @@ -594,8 +592,7 @@ class MyServer2 : public QDBusServer { Q_OBJECT public: - MyServer2(QString addr, QObject* parent) : QDBusServer(addr, parent), - m_conn("none") + MyServer2() : m_conn("none") { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); } @@ -620,7 +617,7 @@ private: void tst_QDBusConnection::registerObjectPeer2() { - MyServer2 server("unix:tmpdir=/tmp", 0); + MyServer2 server; QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo"); QCoreApplication::processEvents(); QVERIFY(con.isConnected()); @@ -775,7 +772,7 @@ void tst_QDBusConnection::registerQObjectChildren() void tst_QDBusConnection::registerQObjectChildrenPeer() { - MyServer2 server("unix:tmpdir=/tmp", 0); + MyServer2 server; QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo"); QCoreApplication::processEvents(); QVERIFY(con.isConnected()); diff --git a/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp b/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp index 2c5ca71990..3d7e477f47 100644 --- a/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp +++ b/tests/auto/dbus/qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp @@ -51,8 +51,8 @@ class tst_QDBusConnectionNoBus : public QObject public: tst_QDBusConnectionNoBus() { - ::setenv("DBUS_SESSION_BUS_ADDRESS", "unix:abstract=/tmp/does_not_exist", 1); - ::setenv("QT_SIMULATE_DBUS_LIBFAIL", "1", 1); + qputenv("DBUS_SESSION_BUS_ADDRESS", "unix:abstract=/tmp/does_not_exist"); + qputenv("QT_SIMULATE_DBUS_LIBFAIL", "1"); } private slots: diff --git a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp index df131f13f6..7a22fe90ad 100644 --- a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp +++ b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.cpp @@ -42,14 +42,14 @@ static const char objectPath[] = "/org/qtproject/qmyserver"; int MyObject::callCount = 0; QVariantList MyObject::callArgs; -class MyServer : public QDBusServer +class MyServer : public QDBusServer, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.qmyserver") public: - MyServer(QString addr = "unix:tmpdir=/tmp", QObject* parent = 0) - : QDBusServer(addr, parent), + MyServer(QObject* parent = 0) + : QDBusServer(parent), m_conn("none") { connect(this, SIGNAL(newConnection(QDBusConnection)), SLOT(handleConnection(QDBusConnection))); @@ -58,6 +58,8 @@ public: public slots: QString address() const { + if (!QDBusServer::isConnected()) + sendErrorReply(QDBusServer::lastError().name(), QDBusServer::lastError().message()); return QDBusServer::address(); } @@ -140,6 +142,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &server, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro index dc480fc88c..ddafd528ee 100644 --- a/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro +++ b/tests/auto/dbus/qdbusinterface/qmyserver/qmyserver.pro @@ -1,6 +1,7 @@ SOURCES = qmyserver.cpp HEADERS = ../myobject.h TARGET = qmyserver +DESTDIR = ./ QT = core dbus CONFIG -= app_bundle DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusinterface/test/test.pro b/tests/auto/dbus/qdbusinterface/test/test.pro index ba70273aab..70e631de9c 100644 --- a/tests/auto/dbus/qdbusinterface/test/test.pro +++ b/tests/auto/dbus/qdbusinterface/test/test.pro @@ -2,6 +2,7 @@ CONFIG += testcase SOURCES += ../tst_qdbusinterface.cpp HEADERS += ../myobject.h TARGET = ../tst_qdbusinterface +DESTDIR = ./ QT = core core-private dbus testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index e66b1134d4..04992c9f28 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -266,13 +266,14 @@ void tst_QDBusInterface::initTestCase() | QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllInvokables); - // start peer server - #ifdef Q_OS_WIN - proc.start("qmyserver"); - #else - proc.start("./qmyserver/qmyserver"); - #endif - QVERIFY(proc.waitForStarted()); +#ifdef Q_OS_WIN +# define EXE ".exe" +#else +# define EXE "" +#endif + proc.start(QFINDTESTDATA("qmyserver/qmyserver" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); WaitForQMyServer w; QVERIFY(w.ok()); diff --git a/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp b/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp index 5476dd7f8e..bb8aab3d21 100644 --- a/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp +++ b/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp @@ -66,6 +66,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &pong, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro b/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro index ffc538f2ab..a4c5efba85 100644 --- a/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro +++ b/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro @@ -1,5 +1,6 @@ SOURCES = qpong.cpp TARGET = qpong +DESTDIR = ./ QT = core dbus CONFIG -= app_bundle CONFIG += console diff --git a/tests/auto/dbus/qdbusmarshall/test/test.pro b/tests/auto/dbus/qdbusmarshall/test/test.pro index 5c67bfc624..658cc52fde 100644 --- a/tests/auto/dbus/qdbusmarshall/test/test.pro +++ b/tests/auto/dbus/qdbusmarshall/test/test.pro @@ -1,6 +1,7 @@ CONFIG += testcase SOURCES += ../tst_qdbusmarshall.cpp TARGET = ../tst_qdbusmarshall +DESTDIR = ./ QT = core-private dbus-private testlib diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 972205566a..4d12522a68 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -130,25 +130,15 @@ void tst_QDBusMarshall::initTestCase() commonInit(); QDBusConnection con = QDBusConnection::sessionBus(); fileDescriptorPassing = con.connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing; + #ifdef Q_OS_WIN - proc.start("qpong"); +# define EXE ".exe" #else - proc.start("./qpong/qpong"); +# define EXE "" #endif - if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)) { - QVERIFY(proc.waitForStarted()); - - QVERIFY(con.isConnected()); - con.connect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", - QStringList() << serviceName << QString(""), QString(), - &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(2); - QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)); - con.disconnect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", - QStringList() << serviceName << QString(""), QString(), - &QTestEventLoop::instance(), SLOT(exitLoop())); - } + proc.start(QFINDTESTDATA("qpong/qpong" EXE)); + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); } void tst_QDBusMarshall::cleanupTestCase() diff --git a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro index 83af3960a6..a58336e511 100644 --- a/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro +++ b/tests/auto/gui/image/qicoimageformat/qicoimageformat.pro @@ -14,3 +14,4 @@ wince*: { DEPLOYMENT += addPlugins } TESTDATA += icons/* +android:RESOURCES+=qicoimageformat.qrc diff --git a/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc b/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc new file mode 100644 index 0000000000..1e0ee8aa8c --- /dev/null +++ b/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc @@ -0,0 +1,18 @@ +<RCC> + <qresource prefix="/"> + <file>icons/invalid/35floppy.ico</file> + <file>icons/valid/35FLOPPY.ICO</file> + <file>icons/valid/abcardWindow.ico</file> + <file>icons/valid/AddPerfMon.ico</file> + <file>icons/valid/App.ico</file> + <file>icons/valid/Obj_N2_Internal_Mem.ico</file> + <file>icons/valid/Qt.ico</file> + <file>icons/valid/semitransparent.ico</file> + <file>icons/valid/Status_Play.ico</file> + <file>icons/valid/TIMER01.ICO</file> + <file>icons/valid/trolltechlogo_tiny.ico</file> + <file>icons/valid/WORLD.ico</file> + <file>icons/valid/WORLDH.ico</file> + <file>icons/valid/yellow.cur</file> + </qresource> +</RCC> diff --git a/tests/auto/gui/image/qicon/tst_qicon.qrc b/tests/auto/gui/image/qicon/tst_qicon.qrc index 469a0a21b4..dc11a87ddd 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.qrc +++ b/tests/auto/gui/image/qicon/tst_qicon.qrc @@ -1,5 +1,6 @@ <!DOCTYPE RCC><RCC version="1.0"> <qresource prefix="/"> +<file>tst_qicon.cpp</file> <file>image.png</file> <file>rect.png</file> <file>./icons/testtheme/16x16/actions/appointment-new.png</file> diff --git a/tests/auto/gui/image/qmovie/resources.qrc b/tests/auto/gui/image/qmovie/resources.qrc index ce459a0e7e..077f6ff004 100644 --- a/tests/auto/gui/image/qmovie/resources.qrc +++ b/tests/auto/gui/image/qmovie/resources.qrc @@ -1,5 +1,7 @@ <!DOCTYPE RCC><RCC version="1.0"> <qresource> + <file>animations/comicsecard.gif</file> <file>animations/corrupt.gif</file> + <file>animations/trolltech.gif</file> </qresource> </RCC> diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 12ca2bb68a..41a53ddd55 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -316,6 +316,8 @@ void tst_QWindow::positioning() QTRY_VERIFY(window.received(QEvent::Resize) > 0); #endif + QTest::qWait(2000); + QTRY_COMPARE(originalPos, window.position()); QTRY_COMPARE(originalFramePos, window.framePosition()); QTRY_COMPARE(originalMargins, window.frameMargins()); diff --git a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro index a7b9f6126e..cdab37bd07 100644 --- a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro +++ b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro @@ -4,6 +4,6 @@ TEMPLATE = subdirs !wince*: SUBDIRS = test stressTest wince*|vxworks* : SUBDIRS = test -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC +linux-*:system(". /etc/lsb-release && [ "$DISTRIB_CODENAME" = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index eda24abcd9..60ac54856c 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -127,6 +127,17 @@ private: #endif }; +static QHostAddress makeNonAny(const QHostAddress &address, QHostAddress::SpecialAddress preferForAny = QHostAddress::LocalHost) +{ + if (address == QHostAddress::Any) + return preferForAny; + if (address == QHostAddress::AnyIPv4) + return QHostAddress::LocalHost; + if (address == QHostAddress::AnyIPv6) + return QHostAddress::LocalHostIPv6; + return address; +} + tst_QUdpSocket::tst_QUdpSocket() { } @@ -236,10 +247,7 @@ void tst_QUdpSocket::unconnectedServerAndClientTest() const char *message[] = {"Yo mista", "Yo", "Wassap"}; - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(serverSocket.localAddress() == QHostAddress::AnyIPv4 || serverSocket.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = serverSocket.localAddress(); - + QHostAddress serverAddress = makeNonAny(serverSocket.localAddress()); for (int i = 0; i < 3; ++i) { QUdpSocket clientSocket; #ifdef FORCE_SESSION @@ -282,8 +290,11 @@ void tst_QUdpSocket::broadcasting() foreach (QNetworkInterface iface, QNetworkInterface::allInterfaces()) { if ((iface.flags() & QNetworkInterface::CanBroadcast) && iface.flags() & QNetworkInterface::IsUp) { - for (int i=0;i<iface.addressEntries().count();i++) - broadcastAddresses.append(iface.addressEntries().at(i).broadcast()); + for (int i=0;i<iface.addressEntries().count();i++) { + QHostAddress broadcast = iface.addressEntries().at(i).broadcast(); + if (broadcast.protocol() == QAbstractSocket::IPv4Protocol) + broadcastAddresses.append(broadcast); + } } } if (broadcastAddresses.isEmpty()) @@ -293,7 +304,8 @@ void tst_QUdpSocket::broadcasting() #ifdef FORCE_SESSION serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - QVERIFY2(serverSocket.bind(QHostAddress::Any, 5000), serverSocket.errorString().toLatin1().constData()); + QVERIFY2(serverSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0), serverSocket.errorString().toLatin1().constData()); + quint16 serverPort = serverSocket.localPort(); QCOMPARE(serverSocket.state(), QUdpSocket::BoundState); @@ -303,14 +315,14 @@ void tst_QUdpSocket::broadcasting() #ifdef FORCE_SESSION broadcastSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - broadcastSocket.bind(); + broadcastSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0); - for (int j = 0; j < 100; ++j) { + for (int j = 0; j < 10; ++j) { for (int k = 0; k < 4; k++) { broadcastSocket.writeDatagram(message[i], strlen(message[i]), - QHostAddress::Broadcast, 5000); + QHostAddress::Broadcast, serverPort); foreach (QHostAddress addr, broadcastAddresses) - broadcastSocket.writeDatagram(message[i], strlen(message[i]), addr, 5000); + broadcastSocket.writeDatagram(message[i], strlen(message[i]), addr, serverPort); } QTestEventLoop::instance().enterLoop(15); if (QTestEventLoop::instance().timeout()) { @@ -371,12 +383,8 @@ void tst_QUdpSocket::loop() QVERIFY2(peter.bind(), peter.errorString().toLatin1().constData()); QVERIFY2(paul.bind(), paul.errorString().toLatin1().constData()); - QHostAddress peterAddress = QHostAddress::LocalHost; - if (!(peter.localAddress() == QHostAddress::AnyIPv4 || peter.localAddress() == QHostAddress::AnyIPv6)) - peterAddress = peter.localAddress(); - QHostAddress pualAddress = QHostAddress::LocalHost; - if (!(paul.localAddress() == QHostAddress::AnyIPv4 || paul.localAddress() == QHostAddress::AnyIPv6)) - pualAddress = paul.localAddress(); + QHostAddress peterAddress = makeNonAny(peter.localAddress()); + QHostAddress pualAddress = makeNonAny(paul.localAddress()); QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), pualAddress, paul.localPort()), qint64(peterMessage.length())); @@ -419,13 +427,18 @@ void tst_QUdpSocket::ipv6Loop() paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - quint16 peterPort = 28124; - quint16 paulPort = 28123; + quint16 peterPort; + quint16 paulPort; - if (!peter.bind(QHostAddress::LocalHostIPv6, peterPort)) { - QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); - } else { - QVERIFY(paul.bind(QHostAddress::LocalHostIPv6, paulPort)); + if (!peter.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)) { + QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); + return; + } + + QVERIFY(paul.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)); + + peterPort = peter.localPort(); + paulPort = paul.localPort(); QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"), paulPort), qint64(peterMessage.length())); @@ -451,7 +464,6 @@ void tst_QUdpSocket::ipv6Loop() QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage); QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage); - } } void tst_QUdpSocket::dualStack() @@ -616,7 +628,7 @@ void tst_QUdpSocket::readLine() #endif QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData()); - socket2.connectToHost("127.0.0.1", socket1.localPort()); + socket2.connectToHost(makeNonAny(socket1.localAddress()), socket1.localPort()); QVERIFY(socket2.waitForConnected(5000)); } @@ -630,10 +642,7 @@ void tst_QUdpSocket::pendingDatagramSize() #endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(server.localAddress() == QHostAddress::AnyIPv4 || server.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = server.localAddress(); - + QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; #ifdef FORCE_SESSION client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -681,10 +690,7 @@ void tst_QUdpSocket::writeDatagram() #endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(server.localAddress() == QHostAddress::AnyIPv4 || server.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = server.localAddress(); - + QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; #ifdef FORCE_SESSION client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -731,10 +737,7 @@ void tst_QUdpSocket::performance() #endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); - QHostAddress serverAddress = QHostAddress::LocalHost; - if (!(server.localAddress() == QHostAddress::AnyIPv4 || server.localAddress() == QHostAddress::AnyIPv6)) - serverAddress = server.localAddress(); - + QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; #ifdef FORCE_SESSION client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -1160,8 +1163,8 @@ void tst_QUdpSocket::multicastJoinBeforeBind() void tst_QUdpSocket::multicastLeaveAfterClose_data() { QTest::addColumn<QHostAddress>("groupAddress"); - QTest::newRow("valid ipv4 group address") << QHostAddress("239.255.118.62"); - QTest::newRow("valid ipv6 group address") << QHostAddress("FF01::114"); + QTest::newRow("ipv4") << QHostAddress("239.255.118.62"); + QTest::newRow("ipv6") << QHostAddress("FF01::114"); } void tst_QUdpSocket::multicastLeaveAfterClose() @@ -1177,7 +1180,10 @@ void tst_QUdpSocket::multicastLeaveAfterClose() #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - QVERIFY2(udpSocket.bind(groupAddress, 0), + QHostAddress bindAddress = QHostAddress::AnyIPv4; + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) + bindAddress = QHostAddress::AnyIPv6; + QVERIFY2(udpSocket.bind(bindAddress, 0), qPrintable(udpSocket.errorString())); QVERIFY2(udpSocket.joinMulticastGroup(groupAddress), qPrintable(udpSocket.errorString())); @@ -1243,7 +1249,7 @@ void tst_QUdpSocket::multicast_data() QTest::newRow("same bind, group ipv4 address") << groupAddress << true << groupAddress << true; QTest::newRow("valid bind, group ipv6 address") << any6Address << true << group6Address << true; QTest::newRow("valid bind, invalid group ipv6 address") << any6Address << true << any6Address << false; - QTest::newRow("same bind, group ipv6 address") << group6Address << true << group6Address << true; + QTest::newRow("same bind, group ipv6 address") << group6Address << false << group6Address << false; QTest::newRow("dual bind, group ipv4 address") << dualAddress << true << groupAddress << false; QTest::newRow("dual bind, group ipv6 address") << dualAddress << true << group6Address << true; } @@ -1255,20 +1261,11 @@ void tst_QUdpSocket::multicast() QFETCH(bool, bindResult); QFETCH(QHostAddress, groupAddress); QFETCH(bool, joinResult); - if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol && !QtNetworkSettings::hasIPv6()) QSKIP("system doesn't support ipv6!"); if (setProxy) { // UDP multicast does not work with proxies - if ( -#ifndef Q_OS_WIN - //windows native socket engine binds 0.0.0.0 instead of the requested multicast address - (bindAddress.protocol() == QAbstractSocket::IPv4Protocol && (bindAddress.toIPv4Address() & 0xffff0000) == 0xefff0000) || -#endif - bindAddress.protocol() == QAbstractSocket::IPv6Protocol) { - // proxy cannot bind to IPv6 or multicast addresses - bindResult = false; - } - joinResult = false; + return; } QUdpSocket receiver; @@ -1282,6 +1279,12 @@ void tst_QUdpSocket::multicast() if (!bindResult) return; + if (bindAddress == QHostAddress::Any && groupAddress.protocol() == QAbstractSocket::IPv4Protocol) { + QCOMPARE(joinResult, false); + QTest::ignoreMessage(QtWarningMsg, + "QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address) and join an IPv4 multicast group;" + " bind to QHostAddress::AnyIPv4 instead if you want to do this"); + } QVERIFY2(receiver.joinMulticastGroup(groupAddress) == joinResult, qPrintable(receiver.errorString())); if (!joinResult) diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index bf4d1f2ebd..fec79326c8 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -2512,6 +2512,7 @@ void tst_QLineEdit::setValidator_QIntValidator_data() QTest::addColumn<QString>("expectedText"); QTest::addColumn<bool>("useKeys"); QTest::addColumn<bool>("is_valid"); + QTest::addColumn<uint>("echoMode"); for (int i=0; i<2; i++) { bool useKeys = false; @@ -2528,7 +2529,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("1") << QString("1") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] valid '3'").toLatin1()) << 3 @@ -2536,7 +2538,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("3") << QString("3") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] valid '7'").toLatin1()) << 3 @@ -2544,7 +2547,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("7") << QString("7") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,100] valid '9'").toLatin1()) << 0 @@ -2552,7 +2556,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("9") << QString("9") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,100] valid '12'").toLatin1()) << 0 @@ -2560,7 +2565,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("12") << QString("12") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [-100,100] valid '-12'").toLatin1()) << -100 @@ -2568,7 +2574,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("-12") << QString("-12") << bool(useKeys) - << bool(true); + << bool(true) + << uint(QLineEdit::Normal); // invalid data // characters not allowed in QIntValidator @@ -2578,7 +2585,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("a") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,9] inv 'A'").toLatin1()) << 0 @@ -2586,7 +2594,8 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("A") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); // minus sign only allowed with a range on the negative side QTest::newRow(QString(inputMode + "range [0,100] inv '-'").toLatin1()) << 0 @@ -2594,36 +2603,48 @@ void tst_QLineEdit::setValidator_QIntValidator_data() << QString("-") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [0,100] int '153'").toLatin1()) << 0 << 100 << QString("153") << QString(useKeys ? "15" : "") << bool(useKeys) - << bool(useKeys ? true : false); + << bool(useKeys ? true : false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [-100,100] int '-153'").toLatin1()) << -100 << 100 << QString("-153") << QString(useKeys ? "-15" : "") << bool(useKeys) - << bool(useKeys ? true : false); + << bool(useKeys ? true : false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] int '2'").toLatin1()) << 3 << 7 << QString("2") << QString("2") << bool(useKeys) - << bool(false); - + << bool(false) + << uint(QLineEdit::Normal); QTest::newRow(QString(inputMode + "range [3,7] int '8'").toLatin1()) << 3 << 7 << QString("8") << QString("") << bool(useKeys) - << bool(false); + << bool(false) + << uint(QLineEdit::Normal); + QTest::newRow(QString(inputMode + "range [0,99] inv 'a-a'").toLatin1()) + << 0 + << 99 + << QString("19a") + << QString(useKeys ? "19" : "") + << bool(useKeys) + << bool(useKeys ? true : false) + << uint(QLineEdit::Password); } } @@ -2635,9 +2656,11 @@ void tst_QLineEdit::setValidator_QIntValidator() QFETCH(QString, expectedText); QFETCH(bool, useKeys); QFETCH(bool, is_valid); + QFETCH(uint, echoMode); QIntValidator intValidator(mini, maxi, 0); QLineEdit *testWidget = ensureTestWidget(); + testWidget->setEchoMode((QLineEdit::EchoMode)echoMode); testWidget->setValidator(&intValidator); QVERIFY(testWidget->text().isEmpty()); //qDebug("1 input: '" + input + "' Exp: '" + expectedText + "'"); diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index cb0383c398..008d3b2435 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -58,6 +58,7 @@ private slots: #ifndef QT_NO_WHEELEVENT void QTBUG_27308(); #endif + void QTBUG_42871(); }; class SingleStepTestScrollBar : public QScrollBar { @@ -169,5 +170,44 @@ void tst_QScrollBar::QTBUG_27308() } #endif +class QTBUG_42871_Handler : public QObject { + Q_OBJECT +public: + int updatesCount; + QTBUG_42871_Handler() : QObject(), updatesCount(0) {} +public slots: + void valueUpdated(int) { ++updatesCount; QTest::qSleep(600); } +}; + +void tst_QScrollBar::QTBUG_42871() +{ + QTBUG_42871_Handler myHandler; + QScrollBar scrollBarWidget(Qt::Vertical); + bool connection = connect(&scrollBarWidget, SIGNAL(valueChanged(int)), &myHandler, SLOT(valueUpdated(int))); + QVERIFY(connection); + scrollBarWidget.resize(100, scrollBarWidget.height()); + centerOnScreen(&scrollBarWidget); + scrollBarWidget.show(); + QTest::qWaitForWindowExposed(&scrollBarWidget); + QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int))); + QVERIFY(spy.isValid()); + QCOMPARE(myHandler.updatesCount, 0); + QCOMPARE(spy.count(), 0); + + // Simulate a mouse click on the "scroll down button". + const QPoint pressPoint(scrollBarWidget.width() / 2, scrollBarWidget.height() - 10); + const QPoint globalPressPoint = scrollBarWidget.mapToGlobal(pressPoint); + QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint, + Qt::LeftButton, Qt::LeftButton, 0); + QApplication::sendEvent(&scrollBarWidget, &mousePressEvent); + QTest::qWait(1); + QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint, + Qt::LeftButton, Qt::LeftButton, 0); + QApplication::sendEvent(&scrollBarWidget, &mouseReleaseEvent); + // Check that the action was triggered once. + QCOMPARE(myHandler.updatesCount, 1); + QCOMPARE(spy.count(), 1); +} + QTEST_MAIN(tst_QScrollBar) #include "tst_qscrollbar.moc" |