diff options
Diffstat (limited to 'tests/auto')
185 files changed, 3833 insertions, 1431 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 23221122d9..81d144dd03 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -14,16 +14,10 @@ SUBDIRS += \ other \ widgets \ printsupport \ + cmake cross_compile: SUBDIRS -= tools !contains(QT_CONFIG, opengl): SUBDIRS -= opengl !unix|embedded|!contains(QT_CONFIG, dbus): SUBDIRS -= dbus contains(QT_CONFIG, no-widgets): SUBDIRS -= widgets - -# disable 'make check' on Mac OS X for the following subdirs for the time being -mac { - network.CONFIG += no_check_target -} - -!contains(QT_CONFIG, concurrent): SUBDIRS -= concurrent - +!contains(QT_CONFIG, concurrent): SUBDIRS -= concurrent diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt new file mode 100644 index 0000000000..b9b0e8c605 --- /dev/null +++ b/tests/auto/cmake/CMakeLists.txt @@ -0,0 +1,100 @@ + +# This is an automatic test for the CMake configuration files. +# To run it, +# 1) mkdir build # Create a build directory +# 2) cd build +# 3) cmake .. # Run cmake on this directory. +# 4) ctest # Run ctest +# +# The expected output is something like: +# +# Start 1: pass1 +# 1/7 Test #1: pass1 ............................ Passed 4.25 sec +# Start 2: pass2 +# 2/7 Test #2: pass2 ............................ Passed 2.00 sec +# Start 3: pass3 +# 3/7 Test #3: pass3 ............................ Passed 2.85 sec +# Start 4: fail4 +# 4/7 Test #4: fail4 ............................ Passed 1.88 sec +# Start 5: fail5 +# 5/7 Test #5: fail5 ............................ Passed 1.36 sec +# Start 6: pass_needsquoting_6 +# 6/7 Test #6: pass_needsquoting_6 .............. Passed 2.88 sec +# Start 7: pass7 +# 7/7 Test #7: pass7 ............................ Passed 0.93 sec +# +# Note that if Qt is not installed, or if it is installed to a +# non-standard prefix, the environment variable CMAKE_PREFIX_PATH +# needs to be set to the installation prefix or build prefix of Qt +# before running these tests. + +cmake_minimum_required(VERSION 2.8) + +project(qmake_cmake_files) + +enable_testing() + +macro(expect_pass _dir) + string(REPLACE "(" "_" testname "${_dir}") + string(REPLACE ")" "_" testname "${testname}") + add_test(${testname} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" + "${CMAKE_CURRENT_BINARY_DIR}/${_dir}" + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-options -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ) +endmacro() + +macro(expect_fail _dir) + string(REPLACE "(" "_" testname "${_dir}") + string(REPLACE ")" "_" testname "${testname}") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}") + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt" + " + cmake_minimum_required(VERSION 2.8) + project(${_dir}_build) + + try_compile(Result \${CMAKE_CURRENT_BINARY_DIR}/${_dir} + \${CMAKE_CURRENT_SOURCE_DIR}/${_dir} + ${_dir} + OUTPUT_VARIABLE Out + ) + message(\"\${Out}\") + if (Result) + message(SEND_ERROR \"Succeeded build which should fail\") + endif() + " + ) + add_test(${testname} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}" + "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/build" + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-options -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ) +endmacro() + +if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.7) + # Requires CMAKE_AUTOMOC function in CMake 2.8.7 + expect_pass(pass1) +else() + message("CMake version older than 2.8.7 (Found ${CMAKE_VERSION}). Not running test \"pass1\"") +endif() +expect_pass(pass2) +# Modules do not currently find their own dependencies. +# expect_pass(pass3) +expect_fail(fail4) +expect_fail(fail5) +expect_pass("pass(needsquoting)6") +expect_pass(pass7) +expect_pass(pass8) + +# If QtDBus has been installed then run the tests for its macros. +find_package(Qt5DBus QUIET) +if (Qt5DBus_FOUND AND NOT APPLE) + expect_pass(pass9) +endif() diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro new file mode 100644 index 0000000000..0fe999b957 --- /dev/null +++ b/tests/auto/cmake/cmake.pro @@ -0,0 +1,54 @@ + +CMAKE_VERSION = $$system(cmake --version) + +# Cause make to do nothing. +TEMPLATE = subdirs + +check.commands = +isEmpty(CMAKE_VERSION) { + message("cmake executable not found. Not running CMake unit tests") +} else { + CTEST_VERSION = $$system(ctest --version) + isEmpty(CTEST_VERSION) { + message("ctest executable not found. Not running CMake unit tests") + } else { + CMAKE_VERSION = $$last(CMAKE_VERSION) + CMAKE_VERSION_MAJOR = $$section(CMAKE_VERSION, ., 0, 0) + CMAKE_VERSION_MINOR = $$section(CMAKE_VERSION, ., 1, 1) + CMAKE_VERSION_PATCH = $$section(CMAKE_VERSION, ., 2, 2) + + VERSION_OK = + greaterThan(CMAKE_VERSION_MAJOR, 2) { + VERSION_OK = 1 + } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 8) { + VERSION_OK = 1 + } else:greaterThan(CMAKE_VERSION_MAJOR, 1):greaterThan(CMAKE_VERSION_MINOR, 7):greaterThan(CMAKE_VERSION_PATCH, 2) { + VERSION_OK = 1 + } + + isEmpty(VERSION_OK) { + message("cmake $$CMAKE_VERSION is too old for this test.") + } else { + SET = set + equals(QMAKE_DIR_SEP, "/"):SET = export + + CMAKE_BUILD_TYPE = Debug + CONFIG(release, debug|release):CMAKE_BUILD_TYPE = Release + + BUILD_DIR = $$replace($$list($$OUT_PWD/build), /, $$QMAKE_DIR_SEP) + + check.commands = \ + cd . && $$SET CMAKE_PREFIX_PATH=$$[QT_INSTALL_PREFIX] && \ + $(MKDIR) $$BUILD_DIR && cd $$BUILD_DIR && \ + cmake $$_PRO_FILE_PWD_ -DCMAKE_BUILD_TYPE=$${CMAKE_BUILD_TYPE} && \ + $(TESTRUNNER) ctest --output-on-failure + + } + } +} + +insignificant_test:!isEmpty(check.commands) { + check.commands = -$${check.commands} +} + +QMAKE_EXTRA_TARGETS *= check diff --git a/tests/auto/cmake/fail4/CMakeLists.txt b/tests/auto/cmake/fail4/CMakeLists.txt new file mode 100644 index 0000000000..fdf90e17a7 --- /dev/null +++ b/tests/auto/cmake/fail4/CMakeLists.txt @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass4) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +qt5_wrap_cpp(moc_files myobject.h) + +# Test options. The -binary option generates a binary to dlopen instead of +# a source file to compile. The compiler will consider it garbage when used +# in the add_executable call. +qt5_add_resources(rcc_files "pass4.qrc" OPTIONS -binary) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(myobject myobject.cpp ${moc_files} ${rcc_files}) +target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/auto/cmake/fail4/myobject.cpp b/tests/auto/cmake/fail4/myobject.cpp new file mode 100644 index 0000000000..292a76e569 --- /dev/null +++ b/tests/auto/cmake/fail4/myobject.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + return 0; +} diff --git a/tests/auto/cmake/fail4/myobject.h b/tests/auto/cmake/fail4/myobject.h new file mode 100644 index 0000000000..cd8765d03f --- /dev/null +++ b/tests/auto/cmake/fail4/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <QObject> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif diff --git a/tests/auto/cmake/fail4/pass4.qrc b/tests/auto/cmake/fail4/pass4.qrc new file mode 100644 index 0000000000..00a17f541f --- /dev/null +++ b/tests/auto/cmake/fail4/pass4.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>resource_file.txt</file> +</qresource> +</RCC> + diff --git a/tests/auto/cmake/fail4/resource_file.txt b/tests/auto/cmake/fail4/resource_file.txt new file mode 100644 index 0000000000..2c604a4f18 --- /dev/null +++ b/tests/auto/cmake/fail4/resource_file.txt @@ -0,0 +1 @@ +Ken sent me. diff --git a/tests/auto/cmake/fail5/CMakeLists.txt b/tests/auto/cmake/fail5/CMakeLists.txt new file mode 100644 index 0000000000..962314c818 --- /dev/null +++ b/tests/auto/cmake/fail5/CMakeLists.txt @@ -0,0 +1,19 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass5) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +# Test options. The -i option removes the include "myobject.h" from the moc file +# causing a compile failure. -> Options work +qt5_wrap_cpp(moc_files myobject.h OPTIONS -i) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(myobject myobject.cpp ${moc_files}) +target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/auto/cmake/fail5/myobject.cpp b/tests/auto/cmake/fail5/myobject.cpp new file mode 100644 index 0000000000..292a76e569 --- /dev/null +++ b/tests/auto/cmake/fail5/myobject.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + return 0; +} diff --git a/tests/auto/cmake/fail5/myobject.h b/tests/auto/cmake/fail5/myobject.h new file mode 100644 index 0000000000..cd8765d03f --- /dev/null +++ b/tests/auto/cmake/fail5/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <QObject> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif diff --git a/tests/auto/cmake/pass(needsquoting)6/CMakeLists.txt b/tests/auto/cmake/pass(needsquoting)6/CMakeLists.txt new file mode 100644 index 0000000000..7b9561c588 --- /dev/null +++ b/tests/auto/cmake/pass(needsquoting)6/CMakeLists.txt @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 2.8) + +project("pass(needsquoting)6") + +find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5Widgets REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +qt5_wrap_cpp(moc_files mywidget.h) +qt5_wrap_ui(ui_files mywidget.ui) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files}) +target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_LIBRARIES}) diff --git a/tests/auto/cmake/pass(needsquoting)6/mywidget.cpp b/tests/auto/cmake/pass(needsquoting)6/mywidget.cpp new file mode 100644 index 0000000000..7f8923810d --- /dev/null +++ b/tests/auto/cmake/pass(needsquoting)6/mywidget.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mywidget.h" +#include "ui_mywidget.h" + +MyWidget::MyWidget(QWidget *parent) + : QWidget(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + MyWidget myWidget; + return 0; +} diff --git a/tests/auto/cmake/pass(needsquoting)6/mywidget.h b/tests/auto/cmake/pass(needsquoting)6/mywidget.h new file mode 100644 index 0000000000..11968e6454 --- /dev/null +++ b/tests/auto/cmake/pass(needsquoting)6/mywidget.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYWIDGET_H +#define MYWIDGET_H + +#include <QWidget> + +namespace Ui +{ +class MyWidget; +} + +class MyWidget : public QWidget +{ + Q_OBJECT +public: + MyWidget(QWidget *parent = 0); + +signals: + void someSignal(); + +private: + Ui::MyWidget *ui; +}; + +#endif diff --git a/tests/auto/cmake/pass(needsquoting)6/mywidget.ui b/tests/auto/cmake/pass(needsquoting)6/mywidget.ui new file mode 100644 index 0000000000..ac42ac4dc2 --- /dev/null +++ b/tests/auto/cmake/pass(needsquoting)6/mywidget.ui @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + <item> + <widget class="QTextEdit" name="textEdit"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/cmake/pass1/CMakeLists.txt b/tests/auto/cmake/pass1/CMakeLists.txt new file mode 100644 index 0000000000..970ca33078 --- /dev/null +++ b/tests/auto/cmake/pass1/CMakeLists.txt @@ -0,0 +1,51 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass1) + +set(CMAKE_AUTOMOC ON) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +macro(qt5_use_package _target _package) + if (NOT Qt5${_package}_FOUND) + find_package(Qt5${_package} ${ARG1}) + endif() + if (Qt5${_package}_FOUND) + # TODO: Handle public/private keywords? + target_link_libraries(${_target} ${Qt5${_package}_LIBRARIES}) + # ### Requires CMake 2.8.8: + # set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_package}_INCLUDE_DIRS}) + include_directories(${Qt5${_package}_INCLUDE_DIRS}) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_package}_COMPILE_DEFINITIONS}) + + # We can't just append to the COMPILE_FLAGS property. That creats a ';' separated list + # which breaks the compile commmand line. + # Ensure non-duplication here manually instead. + get_property(_taget_type TARGET ${_target} PROPERTY TYPE) + if ("${_taget_type}" STREQUAL "EXECUTABLE") + get_target_property(_flags ${_target} COMPILE_FLAGS) + if (_flags) + list(APPEND _flags ${Qt5${_package}_EXECUTABLE_COMPILE_FLAGS}) + list(REMOVE_DUPLICATES _flags) + else() + set(_flags ${Qt5${_package}_EXECUTABLE_COMPILE_FLAGS}) + endif() + if (_flags) + set_target_properties(${_target} PROPERTIES COMPILE_FLAGS ${_flags}) + endif() + endif() + else() + message(FATAL_ERROR "NOT FOUND: Qt5${_package}") + endif() +endmacro() + +add_executable(two two.cpp) +add_executable(three three.cpp) + +qt5_use_package(two Core) +qt5_use_package(two Test) +qt5_use_package(three Widgets) +qt5_use_package(three Gui) +qt5_use_package(three Core) +qt5_use_package(three Test) diff --git a/tests/auto/cmake/pass1/three.cpp b/tests/auto/cmake/pass1/three.cpp new file mode 100644 index 0000000000..63bcbff480 --- /dev/null +++ b/tests/auto/cmake/pass1/three.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest> +#include <QWidget> + +class Three : public QObject +{ + Q_OBJECT +public: + Three(QObject *parent = 0) + { + QWidget *w = new QWidget; + w->show(); + } +}; + +QTEST_MAIN(Three) + +#include "three.moc" diff --git a/tests/auto/cmake/pass1/two.cpp b/tests/auto/cmake/pass1/two.cpp new file mode 100644 index 0000000000..24fcd5dba4 --- /dev/null +++ b/tests/auto/cmake/pass1/two.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest> + +class Two : public QObject +{ + Q_OBJECT +public: + Two(QObject *parent = 0) + { + + } +}; + +QTEST_MAIN(Two) + +#include "two.moc" diff --git a/tests/auto/cmake/pass2/CMakeLists.txt b/tests/auto/cmake/pass2/CMakeLists.txt new file mode 100644 index 0000000000..c859f13fff --- /dev/null +++ b/tests/auto/cmake/pass2/CMakeLists.txt @@ -0,0 +1,19 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass2) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +qt5_wrap_cpp(moc_files myobject.h) + +qt5_add_resources(rcc_files "pass2.qrc") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(myobject myobject.cpp ${moc_files} ${rcc_files}) +target_link_libraries(myobject ${Qt5Core_LIBRARIES}) diff --git a/tests/auto/cmake/pass2/myobject.cpp b/tests/auto/cmake/pass2/myobject.cpp new file mode 100644 index 0000000000..a237b00c50 --- /dev/null +++ b/tests/auto/cmake/pass2/myobject.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + // Compile error if the resource file was not created. + Q_INIT_RESOURCE(pass2); + return 0; +} diff --git a/tests/auto/cmake/pass2/myobject.h b/tests/auto/cmake/pass2/myobject.h new file mode 100644 index 0000000000..cd8765d03f --- /dev/null +++ b/tests/auto/cmake/pass2/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <QObject> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif diff --git a/tests/auto/cmake/pass2/pass2.qrc b/tests/auto/cmake/pass2/pass2.qrc new file mode 100644 index 0000000000..00a17f541f --- /dev/null +++ b/tests/auto/cmake/pass2/pass2.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>resource_file.txt</file> +</qresource> +</RCC> + diff --git a/tests/auto/cmake/pass2/resource_file.txt b/tests/auto/cmake/pass2/resource_file.txt new file mode 100644 index 0000000000..2c604a4f18 --- /dev/null +++ b/tests/auto/cmake/pass2/resource_file.txt @@ -0,0 +1 @@ +Ken sent me. diff --git a/tests/auto/cmake/pass3/CMakeLists.txt b/tests/auto/cmake/pass3/CMakeLists.txt new file mode 100644 index 0000000000..7fa6731f9b --- /dev/null +++ b/tests/auto/cmake/pass3/CMakeLists.txt @@ -0,0 +1,21 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass3) + +# The module finds its dependencies +find_package(Qt5Widgets REQUIRED) + +include_directories(${Qt5Widgets_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +qt5_wrap_cpp(moc_files mywidget.h) +qt5_wrap_ui(ui_files mywidget.ui) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files}) +target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES}) diff --git a/tests/auto/cmake/pass3/mywidget.cpp b/tests/auto/cmake/pass3/mywidget.cpp new file mode 100644 index 0000000000..7f8923810d --- /dev/null +++ b/tests/auto/cmake/pass3/mywidget.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mywidget.h" +#include "ui_mywidget.h" + +MyWidget::MyWidget(QWidget *parent) + : QWidget(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + MyWidget myWidget; + return 0; +} diff --git a/tests/auto/cmake/pass3/mywidget.h b/tests/auto/cmake/pass3/mywidget.h new file mode 100644 index 0000000000..11968e6454 --- /dev/null +++ b/tests/auto/cmake/pass3/mywidget.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYWIDGET_H +#define MYWIDGET_H + +#include <QWidget> + +namespace Ui +{ +class MyWidget; +} + +class MyWidget : public QWidget +{ + Q_OBJECT +public: + MyWidget(QWidget *parent = 0); + +signals: + void someSignal(); + +private: + Ui::MyWidget *ui; +}; + +#endif diff --git a/tests/auto/cmake/pass3/mywidget.ui b/tests/auto/cmake/pass3/mywidget.ui new file mode 100644 index 0000000000..ac42ac4dc2 --- /dev/null +++ b/tests/auto/cmake/pass3/mywidget.ui @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + <item> + <widget class="QTextEdit" name="textEdit"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/cmake/pass7/CMakeLists.txt b/tests/auto/cmake/pass7/CMakeLists.txt new file mode 100644 index 0000000000..ecf6b3649e --- /dev/null +++ b/tests/auto/cmake/pass7/CMakeLists.txt @@ -0,0 +1,13 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass7) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) +add_definitions(${Qt5Core_DEFINITIONS}) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(myobject main.cpp) diff --git a/tests/auto/cmake/pass7/main.cpp b/tests/auto/cmake/pass7/main.cpp new file mode 100644 index 0000000000..0a6b09d877 --- /dev/null +++ b/tests/auto/cmake/pass7/main.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatformdefs.h" + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/tests/auto/cmake/pass8/CMakeLists.txt b/tests/auto/cmake/pass8/CMakeLists.txt new file mode 100644 index 0000000000..735b1bd26e --- /dev/null +++ b/tests/auto/cmake/pass8/CMakeLists.txt @@ -0,0 +1,20 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass8) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +qt5_wrap_cpp(moc_files myobject.h) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +# On non-windows, the WIN32 is harmless, and Qt5Core_QTMAIN_LIBRARIES is empty. +# We test that it is harmless on those, and test that it builds on Windows. +# It wouldn't build if WIN32 is used and Qt5Core_QTMAIN_LIBRARIES is empty. +add_executable(myobject WIN32 myobject.cpp ${moc_files} ) +target_link_libraries(myobject ${Qt5Core_LIBRARIES} ${Qt5Core_QTMAIN_LIBRARIES}) diff --git a/tests/auto/cmake/pass8/myobject.cpp b/tests/auto/cmake/pass8/myobject.cpp new file mode 100644 index 0000000000..b6287b2540 --- /dev/null +++ b/tests/auto/cmake/pass8/myobject.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + return 0; +} diff --git a/tests/auto/cmake/pass8/myobject.h b/tests/auto/cmake/pass8/myobject.h new file mode 100644 index 0000000000..71a65ee801 --- /dev/null +++ b/tests/auto/cmake/pass8/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include <QObject> + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif diff --git a/tests/auto/cmake/pass9/CMakeLists.txt b/tests/auto/cmake/pass9/CMakeLists.txt new file mode 100644 index 0000000000..bf8ff6b3da --- /dev/null +++ b/tests/auto/cmake/pass9/CMakeLists.txt @@ -0,0 +1,36 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass9) + +find_package(Qt5Core REQUIRED) +find_package(Qt5DBus REQUIRED) + +include_directories( + ${Qt5Core_INCLUDE_DIRS} + ${Qt5DBus_INCLUDE_DIRS} +) + +add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS}) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(my_srcs mydbusobject.cpp) + +qt5_wrap_cpp(moc_files mydbusobject.h) + +qt5_generate_dbus_interface( + mydbusobject.h + ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml +) + +qt5_add_dbus_adaptor(my_srcs + ${CMAKE_BINARY_DIR}/org.qtProject.Tests.MyDBusObject.xml + mydbusobject.h + MyDBusObject +) + +add_executable(myobject ${my_srcs} ${moc_files}) +target_link_libraries(myobject ${Qt5DBus_LIBRARIES} ${Qt5Core_LIBRARIES}) diff --git a/tests/auto/cmake/pass9/mydbusobject.cpp b/tests/auto/cmake/pass9/mydbusobject.cpp new file mode 100644 index 0000000000..ee211bbe9b --- /dev/null +++ b/tests/auto/cmake/pass9/mydbusobject.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mydbusobject.h" +#include "mydbusobjectadaptor.h" + +MyDBusObject::MyDBusObject(QObject *parent) + : QObject(parent) +{ + new MyDBusObjectAdaptor(this); + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyDBusObject myDBusObject; + return 0; +} diff --git a/tests/auto/cmake/pass9/mydbusobject.h b/tests/auto/cmake/pass9/mydbusobject.h new file mode 100644 index 0000000000..dd9a023ffe --- /dev/null +++ b/tests/auto/cmake/pass9/mydbusobject.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYDBUSOBJECT_H +#define MYDBUSOBJECT_H + +#include <QObject> + +class MyDBusObject : public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.qtProject.Tests.MyDBusObject") +public: + MyDBusObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif diff --git a/tests/auto/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro b/tests/auto/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro index eb0c054f6f..e82d101de0 100644 --- a/tests/auto/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro +++ b/tests/auto/concurrent/qtconcurrentfilter/qtconcurrentfilter.pro @@ -3,5 +3,3 @@ TARGET = tst_qtconcurrentfilter QT = core testlib concurrent SOURCES = tst_qtconcurrentfilter.cpp DEFINES += QT_STRICT_ITERATORS - -CONFIG += insignificant_test # See QTBUG-20688 diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp index c8d4c211a9..57f05cbeae 100644 --- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp +++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp @@ -1472,6 +1472,8 @@ void tst_QtConcurrentFilter::noDetach() QVERIFY(ll.isDetached() == false); QtConcurrent::filter(l, waitFilterfn).waitForFinished(); + if (!l.isDetached()) + QEXPECT_FAIL("", "QTBUG-20688: Known unstable failure", Abort); QVERIFY(l.isDetached() == true); QVERIFY(ll.isDetached() == true); } diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index 3abd851c89..db7f067680 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -145,9 +145,9 @@ void tst_QAnimationGroup::emptyGroup() QCOMPARE(groupStateChangedSpy.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -160,9 +160,9 @@ void tst_QAnimationGroup::emptyGroup() group.start(); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(2).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(2).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(3).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(3).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 2fdf1de9c8..b7464c8467 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -270,18 +270,18 @@ void tst_QParallelAnimationGroup::stateChanged() group.start(); //all the animations should be started QCOMPARE(spy1.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); QCOMPARE(spy2.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); QCOMPARE(spy3.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); QCOMPARE(spy4.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim1 should be finished QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); QCOMPARE(spy2.count(), 1); //no change QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -290,7 +290,7 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 2); //no change QCOMPARE(spy2.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -299,9 +299,9 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(spy1.count(), 2); //no change QCOMPARE(spy2.count(), 2); //no change QCOMPARE(spy3.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); QCOMPARE(spy4.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); //cleanup spy1.clear(); @@ -318,22 +318,22 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(spy1.count(), 0); QCOMPARE(spy2.count(), 0); QCOMPARE(spy3.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); QCOMPARE(spy4.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim2 should be started QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 0); //no change QCOMPARE(spy2.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change group.setCurrentTime(500); //anim1 is finally also started QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); QCOMPARE(spy2.count(), 1); //no change QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -341,13 +341,13 @@ void tst_QParallelAnimationGroup::stateChanged() group.setCurrentTime(0); //everything should be stopped QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(spy1.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); QCOMPARE(spy2.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); QCOMPARE(spy3.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); QCOMPARE(spy4.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); } void tst_QParallelAnimationGroup::clearGroup() @@ -455,9 +455,9 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(groupStateChangedSpy.count(), 1); QCOMPARE(childStateChangedSpy.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()), QAnimationGroup::Running); // starting directly a running child will not have any effect @@ -620,11 +620,11 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() anim2.start(); anim2.pause(); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(1).first()), QAnimationGroup::Paused); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -634,15 +634,15 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() group.start(); QCOMPARE(stateChangedSpy1.count(), 3); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()), QAnimationGroup::Running); QCOMPARE(stateChangedSpy2.count(), 4); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), QAnimationGroup::Running); QCOMPARE(group.state(), QAnimationGroup::Running); @@ -694,19 +694,19 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() group.start(); QCOMPARE(stateChangedSpy1.count(), 2); QCOMPARE(finishedSpy1.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(stateChangedSpy2.count(), 1); QCOMPARE(finishedSpy2.count(), 0); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); QCOMPARE(stateChangedSpy3.count(), 1); QCOMPARE(finishedSpy3.count(), 0); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()), QAnimationGroup::Running); @@ -770,9 +770,9 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations() group.start(); QCOMPARE(stateChangedSpy.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); @@ -1000,10 +1000,10 @@ void tst_QParallelAnimationGroup::pauseResume() new TestAnimation2(500, &group); group.start(); QCOMPARE(spy.count(), 1); //the animation should have been started - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running); group.setCurrentTime(250); //end of first animation QCOMPARE(spy.count(), 2); //the animation should have been stopped - QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped); group.pause(); QCOMPARE(spy.count(), 2); //this shouldn't have changed group.resume(); diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 05d1569988..11b95d82d8 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -702,7 +702,7 @@ Q_DECLARE_METATYPE(QAbstractAnimation::State) QVariant numberInterpolator(const Number &f, const Number &t, qreal progress) { - return qVariantFromValue<Number>(Number(f.n + (t.n - f.n)*progress)); + return QVariant::fromValue<Number>(Number(f.n + (t.n - f.n)*progress)); } QVariant xaxisQPointInterpolator(const QPointF &f, const QPointF &t, qreal progress) @@ -714,21 +714,21 @@ void tst_QPropertyAnimation::interpolated() { QObject o; o.setProperty("point", QPointF()); //this will avoid warnings - o.setProperty("number", qVariantFromValue<Number>(Number(42))); - QCOMPARE(qVariantValue<Number>(o.property("number")), Number(42)); + o.setProperty("number", QVariant::fromValue<Number>(Number(42))); + QCOMPARE(qvariant_cast<Number>(o.property("number")), Number(42)); { qRegisterAnimationInterpolator<Number>(numberInterpolator); QPropertyAnimation anim(&o, "number"); - anim.setStartValue(qVariantFromValue<Number>(Number(0))); - anim.setEndValue(qVariantFromValue<Number>(Number(100))); + anim.setStartValue(QVariant::fromValue<Number>(Number(0))); + anim.setEndValue(QVariant::fromValue<Number>(Number(100))); anim.setDuration(1000); anim.start(); anim.pause(); anim.setCurrentTime(100); - Number t(qVariantValue<Number>(o.property("number"))); + Number t(qvariant_cast<Number>(o.property("number"))); QCOMPARE(t, Number(10)); anim.setCurrentTime(500); - QCOMPARE(qVariantValue<Number>(o.property("number")), Number(50)); + QCOMPARE(qvariant_cast<Number>(o.property("number")), Number(50)); } { qRegisterAnimationInterpolator<QPointF>(xaxisQPointInterpolator); @@ -861,16 +861,16 @@ void tst_QPropertyAnimation::zeroDurationStart() //let's check the first state change const QVariantList firstChange = spy.first(); //old state - QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Stopped); //new state - QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Running); //let's check the first state change const QVariantList secondChange = spy.last(); //old state - QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Running); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Running); //new state - QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Stopped); + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Stopped); } #define Pause 1 diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 63a4de5ac9..0ceeb6ce86 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -590,7 +590,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates } QList<QVariant> args = spy.at(i); QAbstractAnimation::State st = expectedStates.at(i); - QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.first()); + QAbstractAnimation::State actual = qvariant_cast<QAbstractAnimation::State>(args.first()); if (equals && actual != st) { equals = false; break; @@ -608,7 +608,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates } if (i < spy.count()) { QList<QVariant> args = spy.at(i); - QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.value(1)); + QAbstractAnimation::State actual = qvariant_cast<QAbstractAnimation::State>(args.value(1)); if (!a.isEmpty()) a += QLatin1String(", "); if (int(actual) >= 0 && int(actual) <= 2) { @@ -677,20 +677,20 @@ void tst_QSequentialAnimationGroup::pauseAndResume() << QAbstractAnimation::Running << QAbstractAnimation::Stopped))); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(1).first()), QAnimationGroup::Paused); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(3).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(4).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()), QAnimationGroup::Paused); group.resume(); @@ -711,7 +711,7 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QVERIFY(a3_s_o1->currentLoopTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running - QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()), QAnimationGroup::Running); group.pause(); @@ -732,13 +732,13 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QVERIFY(a3_s_o1->currentLoopTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused - QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()), QAnimationGroup::Paused); group.stop(); QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped - QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()), QAnimationGroup::Stopped); } @@ -782,25 +782,25 @@ void tst_QSequentialAnimationGroup::restart() for (int i = 0; i < 3; i++) { QCOMPARE(animsStateChanged[i]->count(), 4); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(2).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(3).first()), QAnimationGroup::Stopped); } QCOMPARE(seqStateChangedSpy.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(seqCurrentAnimChangedSpy.count(), 6); for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++) - QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qVariantValue<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0))); + QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qvariant_cast<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0))); group.start(); @@ -1124,9 +1124,9 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(groupStateChangedSpy.count(), 1); QCOMPARE(childStateChangedSpy.count(), 1); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()), QAnimationGroup::Running); // starting directly a running child will not have any effect @@ -1317,9 +1317,9 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QCOMPARE(anim2->state(), QAnimationGroup::Running); QCOMPARE(stateChangedSpy2.count(), 4); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), QAnimationGroup::Running); group.stop(); @@ -1357,9 +1357,9 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() group.start(); QCOMPARE(stateChangedSpy.count(), 2); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), + QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(anim1->state(), QAnimationGroup::Stopped); diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index 4144e82a29..719e29e412 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -528,8 +528,10 @@ void tst_QTextCodec::utf8Codec_data() QTest::newRow("str0") << QByteArray("abcdefgh") << QString("abcdefgh") << -1; QTest::newRow("str0-len") << QByteArray("abcdefgh") << QString("abc") << 3; - QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304\334\370\346\345\330\306\305") << -1; - QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304") << 10; + QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") + << QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305") << -1; + QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") + << QString::fromLatin1("\366\344\374\326\304") << 10; str += QChar(0x05e9); str += QChar(0x05d3); @@ -1565,7 +1567,7 @@ void tst_QTextCodec::utf8bom_data() QTest::newRow("nobom") << QByteArray("\302\240", 2) - << QString("\240"); + << QString::fromLatin1("\240"); { static const ushort data[] = { 0x201d }; diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index fb21800976..0b8b761a83 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -8,9 +8,13 @@ TARGET = ../tst_qprocess win32:TESTDATA += ../testBatFiles/* include(../qprocess.pri) + +win32:CONFIG += insignificant_test # QTBUG-25342 - sometimes hangs + load(testcase) # for target.path and installTestHelperApp() for(file, SUBPROGRAMS): installTestHelperApp("../$${file}/$${file}",$${file},$${file}) installTestHelperApp("../testProcessSpacesArgs/nospace",testProcessSpacesArgs,nospace) installTestHelperApp("../testProcessSpacesArgs/one space",testProcessSpacesArgs,"one space") installTestHelperApp("../testProcessSpacesArgs/two space s",testProcessSpacesArgs,"two space s") installTestHelperApp("../test Space In Name/testSpaceInName","test Space In Name",testSpaceInName) + diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index c3c4607119..3ca9521d8b 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -264,9 +264,9 @@ void tst_QProcess::simpleStart() process = 0; QCOMPARE(spy.count(), 3); - QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(0).at(0)), QProcess::Starting); - QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(1).at(0)), QProcess::Running); - QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(0).at(0)), QProcess::Starting); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(1).at(0)), QProcess::Running); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning); } //----------------------------------------------------------------------------- void tst_QProcess::execute() @@ -331,9 +331,9 @@ void tst_QProcess::crashTest() process = 0; QCOMPARE(stateSpy.count(), 3); - QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(0).at(0)), QProcess::Starting); - QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(1).at(0)), QProcess::Running); - QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(0).at(0)), QProcess::Starting); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(1).at(0)), QProcess::Running); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning); } //----------------------------------------------------------------------------- @@ -1571,8 +1571,8 @@ void tst_QProcess::failToStart() int it = j * attempts + i + 1; QCOMPARE(stateSpy.count(), it * 2); - QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting); - QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting); + QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning); } } } diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index dbb844d204..65ab63510c 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -1023,7 +1023,7 @@ void tst_QSettings::testVariantTypes() #define testVal(key, val, tp, rtype) \ { \ QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \ - settings1.setValue(key, qVariantFromValue(val)); \ + settings1.setValue(key, QVariant::fromValue(val)); \ } \ QConfFile::clearCache(); \ { \ @@ -1055,7 +1055,7 @@ void tst_QSettings::testVariantTypes() QList<QVariant> l3; QDate date = QDate::currentDate(); QTime time = QTime::currentTime(); - l3 << QString("ene") << 10 << qVariantFromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4)) + l3 << QString("ene") << 10 << QVariant::fromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4)) << QVariant(QSize(4, 56)) << QVariant(QPoint(4, 2)) << true << false << date << time; testVal("key3", l3, QVariantList, List); @@ -1989,6 +1989,9 @@ void tst_QSettings::setIniCodec() QConfFile::clearCache(); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-25446", Abort); +#endif QCOMPARE(actualContents4, expeContents4); QCOMPARE(actualContents5, expeContents5); diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 37a1556cf9..6e330faa85 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -419,28 +419,28 @@ void tst_QTextStream::generateLineData(bool for_QString) // one line QTest::newRow("utf16-BE/nothing") << QByteArray("\xfe\xff" - "\x00\xe5\x00\x67\x00\x65", 8) << (QStringList() << "\345ge"); + "\x00\xe5\x00\x67\x00\x65", 8) << (QStringList() << QLatin1String("\345ge")); QTest::newRow("utf16-LE/nothing") << QByteArray("\xff\xfe" - "\xe5\x00\x67\x00\x65\x00", 8) << (QStringList() << "\345ge"); + "\xe5\x00\x67\x00\x65\x00", 8) << (QStringList() << QLatin1String("\345ge")); QTest::newRow("utf16-BE/lf") << QByteArray("\xfe\xff" - "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << (QStringList() << "\345ge"); + "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << (QStringList() << QLatin1String("\345ge")); QTest::newRow("utf16-LE/lf") << QByteArray("\xff\xfe" - "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << (QStringList() << "\345ge"); + "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << (QStringList() << QLatin1String("\345ge")); // two lines QTest::newRow("utf16-BE/twolines") << QByteArray("\xfe\xff" "\x00\xe5\x00\x67\x00\x65\x00\x0a" "\x00\xe5\x00\x67\x00\x65\x00\x0a", 18) - << (QStringList() << "\345ge" << "\345ge"); + << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge")); QTest::newRow("utf16-LE/twolines") << QByteArray("\xff\xfe" "\xe5\x00\x67\x00\x65\x00\x0a\x00" "\xe5\x00\x67\x00\x65\x00\x0a\x00", 18) - << (QStringList() << "\345ge" << "\345ge"); + << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge")); // three lines QTest::newRow("utf16-BE/threelines") @@ -448,32 +448,32 @@ void tst_QTextStream::generateLineData(bool for_QString) "\x00\xe5\x00\x67\x00\x65\x00\x0a" "\x00\xe5\x00\x67\x00\x65\x00\x0a" "\x00\xe5\x00\x67\x00\x65\x00\x0a", 26) - << (QStringList() << "\345ge" << "\345ge" << "\345ge"); + << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge") << QLatin1String("\345ge")); QTest::newRow("utf16-LE/threelines") << QByteArray("\xff\xfe" "\xe5\x00\x67\x00\x65\x00\x0a\x00" "\xe5\x00\x67\x00\x65\x00\x0a\x00" "\xe5\x00\x67\x00\x65\x00\x0a\x00", 26) - << (QStringList() << "\345ge" << "\345ge" << "\345ge"); + << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge") << QLatin1String("\345ge")); // utf-32 QTest::newRow("utf32-BE/twolines") << QByteArray("\x00\x00\xfe\xff" "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a" "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a", 36) - << (QStringList() << "\345ge" << "\345ge"); + << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge")); QTest::newRow("utf32-LE/twolines") << QByteArray("\xff\xfe\x00\x00" "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00" "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00", 36) - << (QStringList() << "\345ge" << "\345ge"); + << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge")); } // partials QTest::newRow("cr") << QByteArray("\r") << (QStringList() << ""); QTest::newRow("oneline/cr") << QByteArray("ole\r") << (QStringList() << "ole"); if (!for_QString) - QTest::newRow("utf16-BE/cr") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0d", 10) << (QStringList() << "\345ge"); + QTest::newRow("utf16-BE/cr") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0d", 10) << (QStringList() << QLatin1String("\345ge")); } // ------------------------------------------------------------------------------ @@ -702,34 +702,34 @@ void tst_QTextStream::generateAllData(bool for_QString) // one line QTest::newRow("utf16-BE/nothing") << QByteArray("\xfe\xff" - "\x00\xe5\x00\x67\x00\x65", 8) << QString("\345ge"); + "\x00\xe5\x00\x67\x00\x65", 8) << QString::fromLatin1("\345ge"); QTest::newRow("utf16-LE/nothing") << QByteArray("\xff\xfe" - "\xe5\x00\x67\x00\x65\x00", 8) << QString("\345ge"); + "\xe5\x00\x67\x00\x65\x00", 8) << QString::fromLatin1("\345ge"); QTest::newRow("utf16-BE/lf") << QByteArray("\xfe\xff" - "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << QString("\345ge\n"); + "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << QString::fromLatin1("\345ge\n"); QTest::newRow("utf16-LE/lf") << QByteArray("\xff\xfe" - "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << QString("\345ge\n"); + "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << QString::fromLatin1("\345ge\n"); QTest::newRow("utf16-BE/crlf") << QByteArray("\xfe\xff" - "\x00\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a", 12) << QString("\345ge\r\n"); + "\x00\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a", 12) << QString::fromLatin1("\345ge\r\n"); QTest::newRow("utf16-LE/crlf") << QByteArray("\xff\xfe" - "\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a\x00", 12) << QString("\345ge\r\n"); + "\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a\x00", 12) << QString::fromLatin1("\345ge\r\n"); // two lines QTest::newRow("utf16-BE/twolines") << QByteArray("\xfe\xff" "\x00\xe5\x00\x67\x00\x65\x00\x0a" "\x00\xe5\x00\x67\x00\x65\x00\x0a", 18) - << QString("\345ge\n\345ge\n"); + << QString::fromLatin1("\345ge\n\345ge\n"); QTest::newRow("utf16-LE/twolines") << QByteArray("\xff\xfe" "\xe5\x00\x67\x00\x65\x00\x0a\x00" "\xe5\x00\x67\x00\x65\x00\x0a\x00", 18) - << QString("\345ge\n\345ge\n"); + << QString::fromLatin1("\345ge\n\345ge\n"); // three lines QTest::newRow("utf16-BE/threelines") @@ -737,13 +737,13 @@ void tst_QTextStream::generateAllData(bool for_QString) "\x00\xe5\x00\x67\x00\x65\x00\x0a" "\x00\xe5\x00\x67\x00\x65\x00\x0a" "\x00\xe5\x00\x67\x00\x65\x00\x0a", 26) - << QString("\345ge\n\345ge\n\345ge\n"); + << QString::fromLatin1("\345ge\n\345ge\n\345ge\n"); QTest::newRow("utf16-LE/threelines") << QByteArray("\xff\xfe" "\xe5\x00\x67\x00\x65\x00\x0a\x00" "\xe5\x00\x67\x00\x65\x00\x0a\x00" "\xe5\x00\x67\x00\x65\x00\x0a\x00", 26) - << QString("\345ge\n\345ge\n\345ge\n"); + << QString::fromLatin1("\345ge\n\345ge\n\345ge\n"); } } @@ -2042,9 +2042,9 @@ void tst_QTextStream::generateStringData(bool for_QString) if (!for_QString) { QTest::newRow("utf16-BE (empty)") << QByteArray("\xff\xfe", 2) << QByteArray() << QString(); - QTest::newRow("utf16-BE (corrupt)") << QByteArray("\xff", 1) << QByteArray("\xff") << QString("\xff"); + QTest::newRow("utf16-BE (corrupt)") << QByteArray("\xff", 1) << QByteArray("\xff") << QString::fromLatin1("\xff"); QTest::newRow("utf16-LE (empty)") << QByteArray("\xfe\xff", 2) << QByteArray() << QString(); - QTest::newRow("utf16-LE (corrupt)") << QByteArray("\xfe", 1) << QByteArray("\xfe") << QString("\xfe"); + QTest::newRow("utf16-LE (corrupt)") << QByteArray("\xfe", 1) << QByteArray("\xfe") << QString::fromLatin1("\xfe"); } } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index f9fbb8cba8..608bdfb78b 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1017,12 +1017,22 @@ void tst_QUrl::toLocalFile_data() QTest::newRow("data0") << QString::fromLatin1("file:/a.txt") << QString::fromLatin1("/a.txt"); QTest::newRow("data4") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); +#ifdef Q_OS_WIN QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("c:/a.txt"); +#else + QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("/c:/a.txt"); +#endif QTest::newRow("data6") << QString::fromLatin1("file://somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/"); QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost"); QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt"); + QTest::newRow("data11") << QString::fromLatin1("file:///Mambo <%235>.mp3") << QString::fromLatin1("/Mambo <#5>.mp3"); + QTest::newRow("data12") << QString::fromLatin1("file:///a%25.txt") << QString::fromLatin1("/a%.txt"); + QTest::newRow("data13") << QString::fromLatin1("file:///a%25%25.txt") << QString::fromLatin1("/a%%.txt"); + QTest::newRow("data14") << QString::fromLatin1("file:///a%25a%25.txt") << QString::fromLatin1("/a%a%.txt"); + QTest::newRow("data15") << QString::fromLatin1("file:///a%1f.txt") << QString::fromLatin1("/a\x1f.txt"); + QTest::newRow("data16") << QString::fromLatin1("file:///%2580.txt") << QString::fromLatin1("/%80.txt"); // and some that result in empty (i.e., not local) QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString(); @@ -1059,6 +1069,14 @@ void tst_QUrl::fromLocalFile_data() << QString::fromLatin1(""); QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("/"); + QTest::newRow("data7") << QString::fromLatin1("/Mambo <#5>.mp3") << QString::fromLatin1("file:///Mambo <%235>.mp3") + << QString::fromLatin1("/Mambo <#5>.mp3"); + QTest::newRow("data8") << QString::fromLatin1("/a%.txt") << QString::fromLatin1("file:///a%25.txt") + << QString::fromLatin1("/a%25.txt"); + QTest::newRow("data9") << QString::fromLatin1("/a%25.txt") << QString::fromLatin1("file:///a%2525.txt") + << QString::fromLatin1("/a%2525.txt"); + QTest::newRow("data10") << QString::fromLatin1("/%80.txt") << QString::fromLatin1("file:///%2580.txt") + << QString::fromLatin1("/%2580.txt"); } void tst_QUrl::fromLocalFile() @@ -1069,7 +1087,7 @@ void tst_QUrl::fromLocalFile() QUrl url = QUrl::fromLocalFile(theFile); - QCOMPARE(url.toString(), theUrl); + QCOMPARE(url.toString(QUrl::MostDecoded), theUrl); QCOMPARE(url.path(), thePath); } @@ -1616,7 +1634,7 @@ void tst_QUrl::isRelative_data() QTest::newRow("man: URL, is relative") << "man:mmap" << false; QTest::newRow("javascript: URL, is relative") << "javascript:doSomething()" << false; QTest::newRow("file: URL, is relative") << "file:/blah" << false; - QTest::newRow("/path, is relative") << "/path" << false; + QTest::newRow("/path, is relative") << "/path" << true; QTest::newRow("something, is relative") << "something" << true; // end kde } diff --git a/tests/auto/corelib/itemmodels/itemmodels.pro b/tests/auto/corelib/itemmodels/itemmodels.pro index 851035e949..418c5e1678 100644 --- a/tests/auto/corelib/itemmodels/itemmodels.pro +++ b/tests/auto/corelib/itemmodels/itemmodels.pro @@ -7,5 +7,3 @@ SUBDIRS = qabstractitemmodel \ qitemselectionmodel \ qsortfilterproxymodel \ qstringlistmodel - -mac: qabstractitemmodel.CONFIG = no_check_target # QTBUG-22748 diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index d27d685f37..6a15133b27 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -535,27 +535,27 @@ void tst_QItemModel::data() // General Purpose roles QVariant variant = currentModel->data(currentModel->index(0,0), Qt::ToolTipRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert<QString>(variant)); + QVERIFY(variant.canConvert<QString>()); } variant = currentModel->data(currentModel->index(0,0), Qt::StatusTipRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert<QString>(variant)); + QVERIFY(variant.canConvert<QString>()); } variant = currentModel->data(currentModel->index(0,0), Qt::WhatsThisRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert<QString>(variant)); + QVERIFY(variant.canConvert<QString>()); } variant = currentModel->data(currentModel->index(0,0), Qt::SizeHintRole); if (variant.isValid()) { - QVERIFY(qVariantCanConvert<QSize>(variant)); + QVERIFY(variant.canConvert<QSize>()); } // Appearance roles QVariant fontVariant = currentModel->data(currentModel->index(0,0), Qt::FontRole); if (fontVariant.isValid()) { - QVERIFY(qVariantCanConvert<QFont>(fontVariant)); + QVERIFY(fontVariant.canConvert<QFont>()); } QVariant textAlignmentVariant = currentModel->data(currentModel->index(0,0), Qt::TextAlignmentRole); @@ -569,12 +569,12 @@ void tst_QItemModel::data() QVariant colorVariant = currentModel->data(currentModel->index(0,0), Qt::BackgroundColorRole); if (colorVariant.isValid()) { - QVERIFY(qVariantCanConvert<QColor>(colorVariant)); + QVERIFY(colorVariant.canConvert<QColor>()); } colorVariant = currentModel->data(currentModel->index(0,0), Qt::TextColorRole); if (colorVariant.isValid()) { - QVERIFY(qVariantCanConvert<QColor>(colorVariant)); + QVERIFY(colorVariant.canConvert<QColor>()); } QVariant checkStateVariant = currentModel->data(currentModel->index(0,0), Qt::CheckStateRole); diff --git a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp index 55997a3ca0..2858bf64eb 100644 --- a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp +++ b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp @@ -54,6 +54,10 @@ private slots: void method(); void invalidMethod(); + + void comparisonOperators(); + + void fromSignal(); }; struct CustomType { }; @@ -672,5 +676,65 @@ void tst_QMetaMethod::invalidMethod() QVERIFY(!method3.isValid()); } +void tst_QMetaMethod::comparisonOperators() +{ + static const QMetaObject *mo = &MethodTestObject::staticMetaObject; + for (int x = 0; x < 2; ++x) { + int count = x ? mo->constructorCount() : mo->methodCount(); + for (int i = 0; i < count; ++i) { + QMetaMethod method = x ? mo->constructor(i) : mo->method(i); + const QMetaObject *methodMo = method.enclosingMetaObject(); + for (int j = 0; j < count; ++j) { + QMetaMethod other = x ? mo->constructor(j) : mo->method(j); + bool expectedEqual = ((methodMo == other.enclosingMetaObject()) + && (i == j)); + QCOMPARE(method == other, expectedEqual); + QCOMPARE(method != other, !expectedEqual); + QCOMPARE(other == method, expectedEqual); + QCOMPARE(other != method, !expectedEqual); + } + + QVERIFY(method != QMetaMethod()); + QVERIFY(QMetaMethod() != method); + QVERIFY(!(method == QMetaMethod())); + QVERIFY(!(QMetaMethod() == method)); + } + } + + // Constructors and normal methods with identical index should not + // compare equal + for (int i = 0; i < qMin(mo->methodCount(), mo->constructorCount()); ++i) { + QMetaMethod method = mo->method(i); + QMetaMethod constructor = mo->constructor(i); + QVERIFY(method != constructor); + QVERIFY(!(method == constructor)); + } +} + +void tst_QMetaMethod::fromSignal() +{ +#define FROMSIGNAL_HELPER(ObjectType, Name, Arguments) { \ + void (ObjectType::*signal)Arguments = &ObjectType::Name; \ + const QMetaObject *signalMeta = &ObjectType::staticMetaObject; \ + QCOMPARE(QMetaMethod::fromSignal(signal), \ + signalMeta->method(signalMeta->indexOfSignal(QMetaObject::normalizedSignature(#Name #Arguments)))); \ + } + + FROMSIGNAL_HELPER(MethodTestObject, voidSignal, ()) + FROMSIGNAL_HELPER(MethodTestObject, voidSignalQString, (const QString&)) + FROMSIGNAL_HELPER(QObject, destroyed, (QObject*)) + FROMSIGNAL_HELPER(QObject, objectNameChanged, (const QString &)) + + // Inherited from QObject + FROMSIGNAL_HELPER(MethodTestObject, destroyed, (QObject*)) + FROMSIGNAL_HELPER(MethodTestObject, objectNameChanged, (const QString &)) + + // Methods that are not signals; fromSignal should return invalid method + FROMSIGNAL_HELPER(MethodTestObject, voidSlot, ()) + FROMSIGNAL_HELPER(QObject, deleteLater, ()) + +#undef FROMSIGNAL_HELPER +} + QTEST_MAIN(tst_QMetaMethod) #include "tst_qmetamethod.moc" diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index 4b0a64ab54..cfb23989dc 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -1097,6 +1097,11 @@ void tst_QMetaObjectBuilder::relocatableData() QMetaObject *meta = builder.toMetaObject(); QVERIFY(sameMetaObject(meta, &meta2)); + + QVERIFY(!meta2.d.extradata); + QVERIFY(!meta2.d.relatedMetaObjects); + QVERIFY(!meta2.d.static_metacall); + free(meta); } @@ -1316,25 +1321,8 @@ bool tst_QMetaObjectBuilder::sameMetaObject return false; } - const QMetaObject **objects1 = 0; - const QMetaObject **objects2 = 0; - if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] >= 2) { - QMetaObjectExtraData *extra1 = (QMetaObjectExtraData *)(meta1->d.extradata); - QMetaObjectExtraData *extra2 = (QMetaObjectExtraData *)(meta2->d.extradata); - if (extra1 && !extra2) - return false; - if (extra2 && !extra1) - return false; - if (extra1 && extra2) { - if (extra1->static_metacall != extra2->static_metacall) - return false; - objects1 = extra1->objects; - objects2 = extra1->objects; - } - } else if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] == 1) { - objects1 = (const QMetaObject **)(meta1->d.extradata); - objects2 = (const QMetaObject **)(meta2->d.extradata); - } + const QMetaObject **objects1 = meta1->d.relatedMetaObjects; + const QMetaObject **objects2 = meta2->d.relatedMetaObjects; if (objects1 && !objects2) return false; if (objects2 && !objects1) @@ -1402,7 +1390,7 @@ private: }; QMetaObject TestObject::staticMetaObject = { - { 0, 0, 0, 0 } + { 0, 0, 0, 0, 0, 0 } }; TestObject::TestObject(QObject *parent) diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 4eb26928ac..e9de52b821 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -260,7 +260,7 @@ Q_DECLARE_METATYPE(TestSpace::Foo) void tst_QMetaType::namespaces() { TestSpace::Foo nf = { 11.12 }; - QVariant v = qVariantFromValue(nf); + QVariant v = QVariant::fromValue(nf); QCOMPARE(qvariant_cast<TestSpace::Foo>(v).d, 11.12); } diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f429af7ce2..e5da03c890 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -77,6 +77,12 @@ private slots: void connectDisconnectNotify_data(); void connectDisconnectNotify(); void connectNotifyPtr(); + void connectDisconnectNotifyMethod_data(); + void connectDisconnectNotifyMethod(); + void connectDisconnectNotifyMethodPMF(); + void disconnectNotifyMethod_receiverDestroyed(); + void connectNotifyMethod_connectSlotsByName(); + void connectDisconnectNotifyMethod_shadowing(); void emitInDefinedOrder(); void customTypes(); void streamCustomTypes(); @@ -166,6 +172,7 @@ signals: void signal4(); QT_MOC_COMPAT void signal5(); void signal6(void); + void signal7(int, const QString &); public slots: void aPublicSlot() { aPublicSlotCalled++; } @@ -827,6 +834,7 @@ void tst_QObject::connectDisconnectNotify_data() QTest::newRow("combo4") << SIGNAL( signal4( void ) )<< SLOT( slot4( void ) ); QTest::newRow("combo5") << SIGNAL( signal6( void ) ) << SLOT( slot4() ); QTest::newRow("combo6") << SIGNAL( signal6() ) << SLOT( slot4() ); + QTest::newRow("combo7") << SIGNAL( signal7( int , const QString & ) ) << SLOT( slot4() ); } void tst_QObject::connectDisconnectNotify() @@ -887,6 +895,316 @@ void tst_QObject::connectNotifyPtr() delete r; } +class NotifyMethodObject : public SenderObject, public ReceiverObject +{ +public: + NotifyMethodObject() : SenderObject(), ReceiverObject() + {} + + QList<QMetaMethod> connectedSignals; + QList<QMetaMethod> disconnectedSignals; + void clearNotifications() + { + connectedSignals.clear(); + disconnectedSignals.clear(); + } +protected: + void connectNotify(const QMetaMethod &signal) + { connectedSignals.append(signal); } + void disconnectNotify(const QMetaMethod &signal) + { disconnectedSignals.append(signal); } +}; + +void tst_QObject::connectDisconnectNotifyMethod_data() +{ + tst_QObject::connectDisconnectNotify_data(); +} + +void tst_QObject::connectDisconnectNotifyMethod() +{ + NotifyMethodObject *s = new NotifyMethodObject; + NotifyMethodObject *r = new NotifyMethodObject; + + QFETCH(QString, a_signal); + QFETCH(QString, a_slot); + + // Obtaining meta methods + int signalIndx = ((SenderObject*)s)->metaObject()->indexOfSignal( + QMetaObject::normalizedSignature(a_signal.toLatin1().constData()+1).constData()); + int methodIndx = ((ReceiverObject*)r)->metaObject()->indexOfMethod( + QMetaObject::normalizedSignature(a_slot.toLatin1().constData()+1).constData()); + QMetaMethod signal = ((SenderObject*)s)->metaObject()->method(signalIndx); + QMetaMethod method = ((ReceiverObject*)r)->metaObject()->method(methodIndx); + QVERIFY(signal.isValid()); + QVERIFY(method.isValid()); + + // Test connectNotify + QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); + QCOMPARE(s->connectedSignals.size(), 1); + QCOMPARE(s->connectedSignals.at(0), signal); + QVERIFY(s->disconnectedSignals.isEmpty()); + + // Test disconnectNotify + QVERIFY(QObject::disconnect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); + QCOMPARE(s->disconnectedSignals.size(), 1); + QCOMPARE(s->disconnectedSignals.at(0), signal); + QCOMPARE(s->connectedSignals.size(), 1); + + // Reconnect + s->clearNotifications(); + QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); + QCOMPARE(s->connectedSignals.size(), 1); + QCOMPARE(s->connectedSignals.at(0), signal); + QVERIFY(s->disconnectedSignals.isEmpty()); + + // Test disconnectNotify for a complete disconnect + QVERIFY(((SenderObject*)s)->disconnect((ReceiverObject*)r)); + QCOMPARE(s->disconnectedSignals.size(), 1); + QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod()); + QCOMPARE(s->connectedSignals.size(), 1); + + // Test connectNotify when connecting by QMetaMethod + s->clearNotifications(); + QVERIFY(QObject::connect((SenderObject*)s, signal, (ReceiverObject*)r, method)); + QCOMPARE(s->connectedSignals.size(), 1); + QCOMPARE(s->connectedSignals.at(0), signal); + QVERIFY(s->disconnectedSignals.isEmpty()); + + // Test disconnectNotify when disconnecting by QMetaMethod + QVERIFY(QObject::disconnect((SenderObject*)s, signal, (ReceiverObject*)r, method)); + QCOMPARE(s->disconnectedSignals.size(), 1); + QCOMPARE(s->disconnectedSignals.at(0), signal); + QCOMPARE(s->connectedSignals.size(), 1); + + // Reconnect + s->clearNotifications(); + QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); + + // Test disconnectNotify for a complete disconnect by QMetaMethod + QVERIFY(QObject::disconnect((SenderObject*)s, QMetaMethod(), 0, QMetaMethod())); + QCOMPARE(s->disconnectedSignals.size(), 1); + QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod()); + QCOMPARE(s->connectedSignals.size(), 1); + + // Test connectNotify when connecting by index + s->clearNotifications(); + QVERIFY(QMetaObject::connect((SenderObject*)s, signalIndx, (ReceiverObject*)r, methodIndx)); + QCOMPARE(s->connectedSignals.size(), 1); + QCOMPARE(s->connectedSignals.at(0), signal); + QVERIFY(s->disconnectedSignals.isEmpty()); + + // Test disconnectNotify when disconnecting by index + QVERIFY(QMetaObject::disconnect((SenderObject*)s, signalIndx, (ReceiverObject*)r, methodIndx)); + QCOMPARE(s->disconnectedSignals.size(), 1); + QCOMPARE(s->disconnectedSignals.at(0), signal); + QCOMPARE(s->connectedSignals.size(), 1); + + delete s; + delete r; +} + +static void connectDisconnectNotifyTestSlot() {} + +void tst_QObject::connectDisconnectNotifyMethodPMF() +{ + NotifyMethodObject *s = new NotifyMethodObject; + NotifyMethodObject *r = new NotifyMethodObject; + + QMetaMethod signal = QMetaMethod::fromSignal(&SenderObject::signal1); + + // Test connectNotify + QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1)); + QCOMPARE(s->connectedSignals.size(), 1); + QCOMPARE(s->connectedSignals.at(0), signal); + QVERIFY(s->disconnectedSignals.isEmpty()); + + // Test disconnectNotify + QVERIFY(QObject::disconnect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1)); + QCOMPARE(s->disconnectedSignals.size(), 1); + QCOMPARE(s->disconnectedSignals.at(0), signal); + QCOMPARE(s->connectedSignals.size(), 1); + + // Reconnect + s->clearNotifications(); + QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1)); + QCOMPARE(s->connectedSignals.size(), 1); + QCOMPARE(s->connectedSignals.at(0), signal); + QVERIFY(s->disconnectedSignals.isEmpty()); + + // Test disconnectNotify with wildcard slot + QVERIFY(QObject::disconnect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, 0)); + QCOMPARE(s->disconnectedSignals.size(), 1); + QCOMPARE(s->disconnectedSignals.at(0), signal); + QCOMPARE(s->connectedSignals.size(), 1); + + // Reconnect + s->clearNotifications(); + QMetaObject::Connection conn = connect((SenderObject*)s, &SenderObject::signal1, + (ReceiverObject*)r, &ReceiverObject::slot1); + + // Test disconnectNotify when disconnecting by QMetaObject::Connection + QVERIFY(QObject::disconnect(conn)); + // disconnectNotify() is not called, but it probably should be. + QVERIFY(s->disconnectedSignals.isEmpty()); + + // Test connectNotify when connecting by function pointer + s->clearNotifications(); + QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, connectDisconnectNotifyTestSlot)); + QCOMPARE(s->connectedSignals.size(), 1); + QCOMPARE(s->connectedSignals.at(0), signal); + QVERIFY(s->disconnectedSignals.isEmpty()); + + delete s; + delete r; +} + +void tst_QObject::disconnectNotifyMethod_receiverDestroyed() +{ + NotifyMethodObject *s = new NotifyMethodObject; + NotifyMethodObject *r = new NotifyMethodObject; + + QVERIFY(QObject::connect((SenderObject*)s, SIGNAL(signal1()), (ReceiverObject*)r, SLOT(slot1()))); + + delete r; + // disconnectNotify() is not called, but it probably should be. + QVERIFY(s->disconnectedSignals.isEmpty()); + + delete s; +} + +class ConnectByNameNotifySenderObject : public QObject +{ + Q_OBJECT +public: + QList<QMetaMethod> connectedSignals; + QList<QMetaMethod> disconnectedSignals; + void clearNotifications() + { + connectedSignals.clear(); + disconnectedSignals.clear(); + } +protected: + void connectNotify(const QMetaMethod &signal) + { connectedSignals.append(signal); } + void disconnectNotify(const QMetaMethod &signal) + { disconnectedSignals.append(signal); } +Q_SIGNALS: + void signal1(); +}; + +class ConnectByNameNotifyReceiverObject : public QObject +{ + Q_OBJECT + void createNotifyChild(const char *name) + { + QObject *o = new ConnectByNameNotifySenderObject; + o->setParent(this); + o->setObjectName(QString::fromLatin1(name)); + } +public: + ConnectByNameNotifyReceiverObject() + { + createNotifyChild("foo"); + createNotifyChild("bar"); + createNotifyChild("baz"); + }; + +public Q_SLOTS: + void on_foo_signal1() {} + void on_bar_signal1() {} + void on_baz_signal1() {} +}; + +void tst_QObject::connectNotifyMethod_connectSlotsByName() +{ + ConnectByNameNotifyReceiverObject testObject; + QList<ConnectByNameNotifySenderObject *> senders = + qFindChildren<ConnectByNameNotifySenderObject *>(&testObject); + for (int i = 0; i < senders.size(); ++i) { + ConnectByNameNotifySenderObject *o = senders.at(i); + QVERIFY(o->connectedSignals.isEmpty()); + QVERIFY(o->disconnectedSignals.isEmpty()); + } + + QMetaObject::connectSlotsByName(&testObject); + + for (int i = 0; i < senders.size(); ++i) { + ConnectByNameNotifySenderObject *o = senders.at(i); + QCOMPARE(o->connectedSignals.size(), 1); + QCOMPARE(o->connectedSignals.at(0), QMetaMethod::fromSignal(&ConnectByNameNotifySenderObject::signal1)); + QVERIFY(o->disconnectedSignals.isEmpty()); + } +} + +class ConnectDisconnectNotifyShadowObject + : public ConnectByNameNotifySenderObject +{ + Q_OBJECT +public Q_SLOTS: + void slot1() {} +Q_SIGNALS: + void signal1(); +}; + +void tst_QObject::connectDisconnectNotifyMethod_shadowing() +{ + ConnectDisconnectNotifyShadowObject s; + // Obtain QMetaMethods + QMetaMethod shadowedSignal1 = QMetaMethod::fromSignal(&ConnectByNameNotifySenderObject::signal1); + QMetaMethod redefinedSignal1 = QMetaMethod::fromSignal(&ConnectDisconnectNotifyShadowObject::signal1); + QVERIFY(shadowedSignal1 != redefinedSignal1); + int slot1Index = s.metaObject()->indexOfSlot("slot1()"); + QVERIFY(slot1Index != -1); + QMetaMethod slot1 = s.metaObject()->method(slot1Index); + + // Test connectNotify +#ifndef QT_NO_DEBUG + const char *warning = "QMetaObject::indexOfSignal: signal signal1() from " + "ConnectByNameNotifySenderObject redefined in " + "ConnectDisconnectNotifyShadowObject"; + QTest::ignoreMessage(QtWarningMsg, warning); +#endif + QVERIFY(QObject::connect(&s, SIGNAL(signal1()), &s, SLOT(slot1()))); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), redefinedSignal1); + QVERIFY(s.disconnectedSignals.isEmpty()); + + // Test disconnectNotify +#ifndef QT_NO_DEBUG + QTest::ignoreMessage(QtWarningMsg, warning); +#endif + QVERIFY(QObject::disconnect(&s, SIGNAL(signal1()), &s, SLOT(slot1()))); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), redefinedSignal1); + QCOMPARE(s.connectedSignals.size(), 1); + + // Test connectNotify when connecting by shadowed QMetaMethod + s.clearNotifications(); + QVERIFY(QObject::connect(&s, shadowedSignal1, &s, slot1)); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), shadowedSignal1); + QVERIFY(s.disconnectedSignals.isEmpty()); + + // Test disconnectNotify when disconnecting by shadowed QMetaMethod + QVERIFY(QObject::disconnect(&s, shadowedSignal1, &s, slot1)); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), shadowedSignal1); + QCOMPARE(s.connectedSignals.size(), 1); + + // Test connectNotify when connecting by redefined QMetaMethod + s.clearNotifications(); + QVERIFY(QObject::connect(&s, redefinedSignal1, &s, slot1)); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), redefinedSignal1); + QVERIFY(s.disconnectedSignals.isEmpty()); + + // Test disconnectNotify when disconnecting by redefined QMetaMethod + QVERIFY(QObject::disconnect(&s, redefinedSignal1, &s, slot1)); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), redefinedSignal1); + QCOMPARE(s.connectedSignals.size(), 1); +} + class SequenceObject : public ReceiverObject { Q_OBJECT @@ -1733,12 +2051,12 @@ void tst_QObject::property() CustomType *customPointer = 0; QVariant customVariant = object.property("custom"); - customPointer = qVariantValue<CustomType *>(customVariant); + customPointer = qvariant_cast<CustomType *>(customVariant); QCOMPARE(customPointer, object.custom()); CustomType custom; customPointer = &custom; - qVariantSetValue(customVariant, customPointer); + customVariant.setValue(customPointer); property = mo->property(mo->indexOfProperty("custom")); QVERIFY(property.isWritable()); @@ -1750,7 +2068,7 @@ void tst_QObject::property() QCOMPARE(object.custom(), customPointer); customVariant = object.property("custom"); - customPointer = qVariantValue<CustomType *>(customVariant); + customPointer = qvariant_cast<CustomType *>(customVariant); QCOMPARE(object.custom(), customPointer); // this enum property has a meta type, but it's not yet registered, so we know this fails @@ -1783,22 +2101,22 @@ void tst_QObject::property() var = object.property("priority"); QVERIFY(!var.isNull()); - QVERIFY(qVariantCanConvert<PropertyObject::Priority>(var)); - QCOMPARE(qVariantValue<PropertyObject::Priority>(var), PropertyObject::High); + QVERIFY(var.canConvert<PropertyObject::Priority>()); + QCOMPARE(qvariant_cast<PropertyObject::Priority>(var), PropertyObject::High); object.setPriority(PropertyObject::Low); - QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low); + QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low); QVERIFY(object.setProperty("priority", PropertyObject::VeryHigh)); - QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::VeryHigh); + QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::VeryHigh); QVERIFY(object.setProperty("priority", "High")); - QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::High); + QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::High); QVERIFY(!object.setProperty("priority", QVariant())); var = object.property("priority"); - QCOMPARE(qVariantValue<PropertyObject::Priority>(var), PropertyObject::High); + QCOMPARE(qvariant_cast<PropertyObject::Priority>(var), PropertyObject::High); object.setPriority(PropertyObject::Low); - QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low); + QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low); object.setProperty("priority", var); - QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::High); + QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::High); qRegisterMetaType<CustomString>("CustomString"); QVERIFY(mo->indexOfProperty("customString") != -1); @@ -2684,10 +3002,10 @@ void tst_QObject::floatProperty() QVERIFY(prop.isValid()); QVERIFY(prop.type() == uint(QMetaType::type("float"))); QVERIFY(!prop.write(&obj, QVariant("Hello"))); - QVERIFY(prop.write(&obj, qVariantFromValue(128.0f))); + QVERIFY(prop.write(&obj, QVariant::fromValue(128.0f))); QVariant v = prop.read(&obj); QVERIFY(int(v.userType()) == QMetaType::Float); - QVERIFY(qVariantValue<float>(v) == 128.0f); + QVERIFY(qvariant_cast<float>(v) == 128.0f); } void tst_QObject::qrealProperty() @@ -2700,15 +3018,15 @@ void tst_QObject::qrealProperty() QVERIFY(prop.type() == uint(QMetaType::type("qreal"))); QVERIFY(!prop.write(&obj, QVariant("Hello"))); - QVERIFY(prop.write(&obj, qVariantFromValue(128.0f))); + QVERIFY(prop.write(&obj, QVariant::fromValue(128.0f))); QVariant v = prop.read(&obj); QCOMPARE(v.userType(), qMetaTypeId<qreal>()); - QVERIFY(qVariantValue<qreal>(v) == 128.0); + QVERIFY(qvariant_cast<qreal>(v) == 128.0); - QVERIFY(prop.write(&obj, qVariantFromValue(double(127)))); + QVERIFY(prop.write(&obj, QVariant::fromValue(double(127)))); v = prop.read(&obj); QCOMPARE(v.userType(), qMetaTypeId<qreal>()); - QVERIFY(qVariantValue<qreal>(v) == 127.0); + QVERIFY(qvariant_cast<qreal>(v) == 127.0); } class DynamicPropertyObject : public PropertyObject @@ -3456,6 +3774,7 @@ public: void tst_QObject::isSignalConnected() { ManySignals o; + const QMetaObject *meta = o.metaObject(); o.rec = 0; #ifdef QT_BUILD_INTERNAL QObjectPrivate *priv = QObjectPrivate::get(&o); @@ -3466,6 +3785,13 @@ void tst_QObject::isSignalConnected() QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()"))); QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()"))); #endif + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig00()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig05()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig15()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig29()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig60()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig69()")))); QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69())); QObject::connect(&o, SIGNAL(sig34()), &o, SIGNAL(sig03())); @@ -3484,6 +3810,18 @@ void tst_QObject::isSignalConnected() QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig18()"))); #endif + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed(QObject*)")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig05()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig15()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig29()")))); + + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig00()")))); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig03()")))); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig34()")))); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig69()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig18()")))); + QObject::connect(&o, SIGNAL(sig18()), &o, SIGNAL(sig29())); QObject::connect(&o, SIGNAL(sig29()), &o, SIGNAL(sig62())); @@ -3497,6 +3835,11 @@ void tst_QObject::isSignalConnected() QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig27()"))); #endif + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig18()")))); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig62()")))); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig28()")))); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig69()")))); + QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig27()")))); QCOMPARE(o.rec, 0); emit o.sig01(); @@ -3527,6 +3870,12 @@ void tst_QObject::isSignalConnected() QCOMPARE(o.rec, 2); emit o.sig36(); QCOMPARE(o.rec, 2); + + QObject::connect(&o, &QObject::destroyed, qt_noop); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed()")))); + QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed(QObject*)")))); + + QVERIFY(!o.isSignalConnected(QMetaMethod())); } void tst_QObject::qMetaObjectConnect() diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index e4ecfb6f2d..0e42572b03 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -39,6 +39,12 @@ ** ****************************************************************************/ +#ifdef QT_GUI_LIB +# include <QtGui/QGuiApplication> +#else +# include <QtCore/QCoreApplication> +#endif + #include <QtTest/QtTest> #include <qtimer.h> diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 7d821f038b..569e448d88 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -102,6 +102,8 @@ private slots: void constructor(); void copy_constructor(); + void constructor_invalid_data(); + void constructor_invalid(); void isNull(); void swap(); @@ -346,6 +348,67 @@ void tst_QVariant::constructor() QVERIFY(!var8.isNull()); } +void tst_QVariant::constructor_invalid_data() +{ + QTest::addColumn<uint>("typeId"); + + QTest::newRow("-1") << uint(-1); + QTest::newRow("-122234567") << uint(-122234567); + QTest::newRow("0xfffffffff") << uint(0xfffffffff); + QTest::newRow("LastCoreType + 1") << uint(QMetaType::LastCoreType + 1); + QVERIFY(!QMetaType::isRegistered(QMetaType::LastCoreType + 1)); + QTest::newRow("LastGuiType + 1") << uint(QMetaType::LastGuiType + 1); + QVERIFY(!QMetaType::isRegistered(QMetaType::LastGuiType + 1)); + QTest::newRow("LastWidgetsType + 1") << uint(QMetaType::LastWidgetsType + 1); + QVERIFY(!QMetaType::isRegistered(QMetaType::LastWidgetsType + 1)); +} + +struct MessageHandlerInvalidType +{ + MessageHandlerInvalidType() + : oldMsgHandler(qInstallMsgHandler(handler)) + { + ok = false; + } + + ~MessageHandlerInvalidType() + { + qInstallMsgHandler(oldMsgHandler); + } + + QtMsgHandler oldMsgHandler; + + static void handler(QtMsgType type, const char *txt) + { + QString msg = QString::fromLatin1(txt); + // uint(-1) can be platform dependent so we check only beginning of the message. + ok = msg.startsWith("Trying to construct an instance of an invalid type, type id:"); + QVERIFY2(ok, (QString::fromLatin1("Message is not started correctly: '") + msg + '\'').toLatin1().constData()); + } + static bool ok; +}; +bool MessageHandlerInvalidType::ok; + +void tst_QVariant::constructor_invalid() +{ + + QFETCH(uint, typeId); + { + MessageHandlerInvalidType msg; + QVariant variant(static_cast<QVariant::Type>(typeId)); + QVERIFY(!variant.isValid()); + QVERIFY(variant.userType() == QMetaType::UnknownType); + QVERIFY(msg.ok); + } + { + MessageHandlerInvalidType msg; + QVariant variant(typeId, /* copy */ 0); + QVERIFY(!variant.isValid()); + QVERIFY(variant.userType() == QMetaType::UnknownType); + QVERIFY(msg.ok); + } +} + void tst_QVariant::copy_constructor() { QVariant var7(QVariant::Int); @@ -447,20 +510,20 @@ void tst_QVariant::canConvert_data() QVariant var(QBitArray(0)); QTest::newRow("BitArray") << var << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QBitmap()); + var = QVariant::fromValue(QBitmap()); QTest::newRow("Bitmap") << var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QBrush()); + var = QVariant::fromValue(QBrush()); QTest::newRow("Brush") << var << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; var = QVariant(QByteArray()); QTest::newRow("ByteArray") << var << N << N << Y << N << Y << Y << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; - var = qVariantFromValue(QColor()); + var = QVariant::fromValue(QColor()); QTest::newRow("Color") << var << N << N << N << Y << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; #ifndef QT_NO_CURSOR - var = qVariantFromValue(QCursor()); + var = QVariant::fromValue(QCursor()); QTest::newRow("Cursor") << var << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; #endif @@ -476,13 +539,13 @@ void tst_QVariant::canConvert_data() var = QVariant(0.1f); QTest::newRow("Float") << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; - var = qVariantFromValue(QFont()); + var = QVariant::fromValue(QFont()); QTest::newRow("Font") << var << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; - var = qVariantFromValue(QIcon()); + var = QVariant::fromValue(QIcon()); QTest::newRow("Icon") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QImage()); + var = QVariant::fromValue(QImage()); QTest::newRow("Image") << var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; var = QVariant((int)1); @@ -491,7 +554,7 @@ void tst_QVariant::canConvert_data() var = QVariant(); QTest::newRow("Invalid") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QKeySequence()); + var = QVariant::fromValue(QKeySequence()); QTest::newRow("KeySequence") << var << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; var = QVariant(QList<QVariant>()); @@ -503,16 +566,16 @@ void tst_QVariant::canConvert_data() var = QVariant(QMap<QString,QVariant>()); QTest::newRow("Map") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPalette()); + var = QVariant::fromValue(QPalette()); QTest::newRow("Palette") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPen()); + var = QVariant::fromValue(QPen()); QTest::newRow("Pen") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPixmap()); + var = QVariant::fromValue(QPixmap()); QTest::newRow("Pixmap") << var << N << Y << N << Y << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QPolygon()); + var = QVariant::fromValue(QPolygon()); QTest::newRow("PointArray") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; var = QVariant(QPoint()); @@ -521,13 +584,13 @@ void tst_QVariant::canConvert_data() var = QVariant(QRect()); QTest::newRow("Rect") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N; - var = qVariantFromValue(QRegion()); + var = QVariant::fromValue(QRegion()); QTest::newRow("Region") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N; var = QVariant(QSize()); QTest::newRow("Size") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N; - var = qVariantFromValue(QSizePolicy()); + var = QVariant::fromValue(QSizePolicy()); QTest::newRow("SizePolicy") << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N; var = QVariant(QString()); @@ -648,7 +711,7 @@ void tst_QVariant::toInt_data() QTest::newRow( "signedint-string" ) << QVariant( QString("-123") ) << -123 << true; QTest::newRow( "signedlonglong0" ) << QVariant( (qlonglong)-34 ) << -34 << true; QTest::newRow( "QChar" ) << QVariant(QChar('a')) << int('a') << true; - QTest::newRow( "keysequence" ) << qVariantFromValue( QKeySequence( Qt::Key_A ) ) << 65 << true; + QTest::newRow( "keysequence" ) << QVariant::fromValue( QKeySequence( Qt::Key_A ) ) << 65 << true; QByteArray bytearray(4, ' '); bytearray[0] = 'T'; bytearray[1] = 'e'; @@ -955,7 +1018,7 @@ void tst_QVariant::toColor() QFETCH( QColor, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Color ) ); - QColor d = qVariantValue<QColor>(value); + QColor d = qvariant_cast<QColor>(value); QCOMPARE( d, result ); } @@ -979,7 +1042,7 @@ void tst_QVariant::toPixmap() QFETCH( QPixmap, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Pixmap ) ); - QPixmap d = qVariantValue<QPixmap>(value); + QPixmap d = qvariant_cast<QPixmap>(value); QCOMPARE( d, result ); } @@ -999,7 +1062,7 @@ void tst_QVariant::toImage() QFETCH( QImage, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Image ) ); - QImage d = qVariantValue<QImage>(value); + QImage d = qvariant_cast<QImage>(value); QCOMPARE( d, result ); } @@ -1021,7 +1084,7 @@ void tst_QVariant::toBrush() QFETCH( QBrush, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Brush ) ); - QBrush d = qVariantValue<QBrush>(value); + QBrush d = qvariant_cast<QBrush>(value); QCOMPARE( d, result ); } @@ -1040,7 +1103,7 @@ void tst_QVariant::toFont() QFETCH( QFont, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::Font ) ); - QFont d = qVariantValue<QFont>(value); + QFont d = qvariant_cast<QFont>(value); QCOMPARE( d, result ); } @@ -1064,7 +1127,7 @@ void tst_QVariant::toKeySequence() QFETCH( QKeySequence, result ); QVERIFY( value.isValid() ); QVERIFY( value.canConvert( QVariant::KeySequence ) ); - QKeySequence d = qVariantValue<QKeySequence>(value); + QKeySequence d = qvariant_cast<QKeySequence>(value); QCOMPARE( d, result ); } @@ -1226,7 +1289,7 @@ void tst_QVariant::toString_data() QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" ); QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" ); QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" ); - QTest::newRow( "qkeysequence" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) + QTest::newRow( "qkeysequence" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) #ifndef Q_OS_MAC << QString( "Ctrl+A" ); #else @@ -1234,8 +1297,8 @@ void tst_QVariant::toString_data() #endif QFont font( "times", 12 ); - QTest::newRow( "qfont" ) << qVariantFromValue( font ) << QString("times,12,-1,5,50,0,0,0,0,0"); - QTest::newRow( "qcolor" ) << qVariantFromValue( QColor( 10, 10, 10 ) ) << QString( "#0a0a0a" ); + QTest::newRow( "qfont" ) << QVariant::fromValue( font ) << QString("times,12,-1,5,50,0,0,0,0,0"); + QTest::newRow( "qcolor" ) << QVariant::fromValue( QColor( 10, 10, 10 ) ) << QString( "#0a0a0a" ); QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) << QString( "123456789012" ); } @@ -1342,10 +1405,10 @@ void tst_QVariant::toRegularExpression() void tst_QVariant::matrix() { QVariant variant; - QMatrix matrix = qVariantValue<QMatrix>(variant); + QMatrix matrix = qvariant_cast<QMatrix>(variant); QVERIFY(matrix.isIdentity()); - qVariantSetValue(variant, QMatrix().rotate(90)); - QCOMPARE(QMatrix().rotate(90), qVariantValue<QMatrix>(variant)); + variant.setValue(QMatrix().rotate(90)); + QCOMPARE(QMatrix().rotate(90), qvariant_cast<QMatrix>(variant)); void *mmatrix = QMetaType::create(QVariant::Matrix, 0); QVERIFY(mmatrix); @@ -1355,12 +1418,12 @@ void tst_QVariant::matrix() void tst_QVariant::matrix4x4() { QVariant variant; - QMatrix4x4 matrix = qVariantValue<QMatrix4x4>(variant); + QMatrix4x4 matrix = qvariant_cast<QMatrix4x4>(variant); QVERIFY(matrix.isIdentity()); QMatrix4x4 m; m.scale(2.0f); - qVariantSetValue(variant, m); - QCOMPARE(m, qVariantValue<QMatrix4x4>(variant)); + variant.setValue(m); + QCOMPARE(m, qvariant_cast<QMatrix4x4>(variant)); void *mmatrix = QMetaType::create(QVariant::Matrix4x4, 0); QVERIFY(mmatrix); @@ -1370,10 +1433,10 @@ void tst_QVariant::matrix4x4() void tst_QVariant::transform() { QVariant variant; - QTransform matrix = qVariantValue<QTransform>(variant); + QTransform matrix = qvariant_cast<QTransform>(variant); QVERIFY(matrix.isIdentity()); - qVariantSetValue(variant, QTransform().rotate(90)); - QCOMPARE(QTransform().rotate(90), qVariantValue<QTransform>(variant)); + variant.setValue(QTransform().rotate(90)); + QCOMPARE(QTransform().rotate(90), qvariant_cast<QTransform>(variant)); void *mmatrix = QMetaType::create(QVariant::Transform, 0); QVERIFY(mmatrix); @@ -1384,10 +1447,10 @@ void tst_QVariant::transform() void tst_QVariant::vector2D() { QVariant variant; - QVector2D vector = qVariantValue<QVector2D>(variant); + QVector2D vector = qvariant_cast<QVector2D>(variant); QVERIFY(vector.isNull()); - qVariantSetValue(variant, QVector2D(0.1, 0.2)); - QCOMPARE(QVector2D(0.1, 0.2), qVariantValue<QVector2D>(variant)); + variant.setValue(QVector2D(0.1, 0.2)); + QCOMPARE(QVector2D(0.1, 0.2), qvariant_cast<QVector2D>(variant)); void *pvector = QMetaType::create(QVariant::Vector2D, 0); QVERIFY(pvector); @@ -1397,10 +1460,10 @@ void tst_QVariant::vector2D() void tst_QVariant::vector3D() { QVariant variant; - QVector3D vector = qVariantValue<QVector3D>(variant); + QVector3D vector = qvariant_cast<QVector3D>(variant); QVERIFY(vector.isNull()); - qVariantSetValue(variant, QVector3D(0.1, 0.2, 0.3)); - QCOMPARE(QVector3D(0.1, 0.2, 0.3), qVariantValue<QVector3D>(variant)); + variant.setValue(QVector3D(0.1, 0.2, 0.3)); + QCOMPARE(QVector3D(0.1, 0.2, 0.3), qvariant_cast<QVector3D>(variant)); void *pvector = QMetaType::create(QVariant::Vector3D, 0); QVERIFY(pvector); @@ -1410,10 +1473,10 @@ void tst_QVariant::vector3D() void tst_QVariant::vector4D() { QVariant variant; - QVector4D vector = qVariantValue<QVector4D>(variant); + QVector4D vector = qvariant_cast<QVector4D>(variant); QVERIFY(vector.isNull()); - qVariantSetValue(variant, QVector4D(0.1, 0.2, 0.3, 0.4)); - QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qVariantValue<QVector4D>(variant)); + variant.setValue(QVector4D(0.1, 0.2, 0.3, 0.4)); + QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qvariant_cast<QVector4D>(variant)); void *pvector = QMetaType::create(QVariant::Vector4D, 0); QVERIFY(pvector); @@ -1423,10 +1486,10 @@ void tst_QVariant::vector4D() void tst_QVariant::quaternion() { QVariant variant; - QQuaternion quaternion = qVariantValue<QQuaternion>(variant); + QQuaternion quaternion = qvariant_cast<QQuaternion>(variant); QVERIFY(quaternion.isIdentity()); - qVariantSetValue(variant, QQuaternion(0.1, 0.2, 0.3, 0.4)); - QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qVariantValue<QQuaternion>(variant)); + variant.setValue(QQuaternion(0.1, 0.2, 0.3, 0.4)); + QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qvariant_cast<QQuaternion>(variant)); void *pquaternion = QMetaType::create(QVariant::Quaternion, 0); QVERIFY(pquaternion); @@ -1483,14 +1546,14 @@ void tst_QVariant::writeToReadFromDataStream_data() bytearray[3] = 't'; bytearray[4] = '\0'; QTest::newRow( "bytearray_valid" ) << QVariant( bytearray ) << false; - QTest::newRow( "bitmap_invalid" ) << qVariantFromValue( QBitmap() ) << true; + QTest::newRow( "bitmap_invalid" ) << QVariant::fromValue( QBitmap() ) << true; QBitmap bitmap( 10, 10 ); bitmap.fill( Qt::red ); - QTest::newRow( "bitmap_valid" ) << qVariantFromValue( bitmap ) << false; - QTest::newRow( "brush_valid" ) << qVariantFromValue( QBrush( Qt::red ) ) << false; - QTest::newRow( "color_valid" ) << qVariantFromValue( QColor( Qt::red ) ) << false; + QTest::newRow( "bitmap_valid" ) << QVariant::fromValue( bitmap ) << false; + QTest::newRow( "brush_valid" ) << QVariant::fromValue( QBrush( Qt::red ) ) << false; + QTest::newRow( "color_valid" ) << QVariant::fromValue( QColor( Qt::red ) ) << false; #ifndef QT_NO_CURSOR - QTest::newRow( "cursor_valid" ) << qVariantFromValue( QCursor( Qt::PointingHandCursor ) ) << false; + QTest::newRow( "cursor_valid" ) << QVariant::fromValue( QCursor( Qt::PointingHandCursor ) ) << false; #endif QTest::newRow( "date_invalid" ) << QVariant( QDate() ) << true; QTest::newRow( "date_valid" ) << QVariant( QDate( 2002, 07, 06 ) ) << false; @@ -1498,14 +1561,14 @@ void tst_QVariant::writeToReadFromDataStream_data() QTest::newRow( "datetime_valid" ) << QVariant( QDateTime( QDate( 2002, 07, 06 ), QTime( 14, 0, 0 ) ) ) << false; QTest::newRow( "double_valid" ) << QVariant( 123.456 ) << false; QTest::newRow( "float_valid" ) << QVariant( 123.456f ) << false; - QTest::newRow( "font_valid" ) << qVariantFromValue( QFont( "times", 12 ) ) << false; - QTest::newRow( "pixmap_invalid" ) << qVariantFromValue( QPixmap() ) << true; + QTest::newRow( "font_valid" ) << QVariant::fromValue( QFont( "times", 12 ) ) << false; + QTest::newRow( "pixmap_invalid" ) << QVariant::fromValue( QPixmap() ) << true; QPixmap pixmap( 10, 10 ); pixmap.fill( Qt::red ); - QTest::newRow( "pixmap_valid" ) << qVariantFromValue( pixmap ) << false; + QTest::newRow( "pixmap_valid" ) << QVariant::fromValue( pixmap ) << false; // QTest::newRow( "iconset_valid" ) << QVariant( QIcon( pixmap ) ) << false; - QTest::newRow( "image_invalid" ) << qVariantFromValue( QImage() ) << true; - QTest::newRow( "keysequence_valid" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false; + QTest::newRow( "image_invalid" ) << QVariant::fromValue( QImage() ) << true; + QTest::newRow( "keysequence_valid" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false; QTest::newRow( "int_valid" ) << QVariant( -123 ) << false; typedef QMap<QString, QVariant> variantsMap; variantsMap vMap; @@ -1514,15 +1577,15 @@ void tst_QVariant::writeToReadFromDataStream_data() vMap.insert( "double", QVariant( 3.45 ) ); vMap.insert( "float", QVariant( 3.45f ) ); QTest::newRow( "map_valid" ) << QVariant( vMap ) << false; - QTest::newRow( "palette_valid" ) << qVariantFromValue(QPalette(QColor("turquoise"))) << false; - QTest::newRow( "pen_valid" ) << qVariantFromValue( QPen( Qt::red ) ) << false; - QTest::newRow( "pointarray_invalid" ) << qVariantFromValue( QPolygon() ) << true; - QTest::newRow( "pointarray_valid" ) << qVariantFromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false; - QTest::newRow( "region_invalid" ) << qVariantFromValue( QRegion() ) << true; - QTest::newRow( "region_valid" ) << qVariantFromValue( QRegion( 10, 10, 20, 20 ) ) << false; - QTest::newRow( "sizepolicy_valid" ) << qVariantFromValue( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ) << false; - QTest::newRow( "point_invalid" ) << qVariantFromValue( QPoint() ) << true; - QTest::newRow( "point_valid" ) << qVariantFromValue( QPoint( 10, 10 ) ) << false; + QTest::newRow( "palette_valid" ) << QVariant::fromValue(QPalette(QColor("turquoise"))) << false; + QTest::newRow( "pen_valid" ) << QVariant::fromValue( QPen( Qt::red ) ) << false; + QTest::newRow( "pointarray_invalid" ) << QVariant::fromValue( QPolygon() ) << true; + QTest::newRow( "pointarray_valid" ) << QVariant::fromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false; + QTest::newRow( "region_invalid" ) << QVariant::fromValue( QRegion() ) << true; + QTest::newRow( "region_valid" ) << QVariant::fromValue( QRegion( 10, 10, 20, 20 ) ) << false; + QTest::newRow( "sizepolicy_valid" ) << QVariant::fromValue( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ) << false; + QTest::newRow( "point_invalid" ) << QVariant::fromValue( QPoint() ) << true; + QTest::newRow( "point_valid" ) << QVariant::fromValue( QPoint( 10, 10 ) ) << false; QTest::newRow( "rect_invalid" ) << QVariant( QRect() ) << true; QTest::newRow( "rect_valid" ) << QVariant( QRect( 10, 10, 20, 20 ) ) << false; QTest::newRow( "size_invalid" ) << QVariant( QSize( 0, 0 ) ) << true; @@ -2067,7 +2130,7 @@ void tst_QVariant::userType() { QVariant userVar; - qVariantSetValue(userVar, data); + userVar.setValue(data); QCOMPARE(userVar.type(), QVariant::UserType); QCOMPARE(userVar.userType(), qMetaTypeId<MyType>()); @@ -2078,7 +2141,7 @@ void tst_QVariant::userType() QVariant userVar2(userVar); QVERIFY(userVar == userVar2); - qVariantSetValue(userVar2, data2); + userVar2.setValue(data2); QVERIFY(userVar != userVar2); const MyType *varData = static_cast<const MyType *>(userVar.constData()); @@ -2087,7 +2150,7 @@ void tst_QVariant::userType() QCOMPARE(varData->text, data.text); QVariant userVar3; - qVariantSetValue(userVar3, data2); + userVar3.setValue(data2); userVar3 = userVar2; QVERIFY(userVar2 == userVar3); @@ -2096,7 +2159,7 @@ void tst_QVariant::userType() QCOMPARE(instanceCount, 2); { QVariant userVar; - qVariantSetValue(userVar, &data); + userVar.setValue(&data); QCOMPARE(userVar.type(), QVariant::UserType); QCOMPARE(userVar.userType(), qMetaTypeId<MyType*>()); @@ -2107,7 +2170,7 @@ void tst_QVariant::userType() QVariant userVar2(userVar); QVERIFY(userVar == userVar2); - qVariantSetValue(userVar2, &data2); + userVar2.setValue(&data2); QVERIFY(userVar != userVar2); MyType * const*varData = reinterpret_cast<MyType *const *>(userVar.constData()); @@ -2115,7 +2178,7 @@ void tst_QVariant::userType() QCOMPARE(*varData, &data); QVariant userVar3; - qVariantSetValue(userVar3, &data2); + userVar3.setValue(&data2); /* This check is correct now. userVar2 contains a pointer to data2 and so * does userVar3. */ @@ -2127,7 +2190,7 @@ void tst_QVariant::userType() QCOMPARE(instanceCount, 2); QVariant myCarrier; - qVariantSetValue(myCarrier, data); + myCarrier.setValue(data); QCOMPARE(instanceCount, 3); { QVariant second = myCarrier; @@ -2138,7 +2201,7 @@ void tst_QVariant::userType() QCOMPARE(instanceCount, 3); MyType data3(0, "null"); - data3 = qVariantValue<MyType>(myCarrier); + data3 = qvariant_cast<MyType>(myCarrier); QCOMPARE(data3.number, 1); QCOMPARE(data3.text, (const char *)"eins"); #ifndef Q_CC_SUN @@ -2151,7 +2214,7 @@ void tst_QVariant::userType() const MyType data(3, "drei"); QVariant myCarrier; - qVariantSetValue(myCarrier, data); + myCarrier.setValue(data); QCOMPARE(myCarrier.typeName(), "MyType"); const MyType data2 = qvariant_cast<MyType>(myCarrier); @@ -2163,7 +2226,7 @@ void tst_QVariant::userType() short s = 42; QVariant myCarrier; - qVariantSetValue(myCarrier, s); + myCarrier.setValue(s); QCOMPARE((int)qvariant_cast<short>(myCarrier), 42); } @@ -2171,7 +2234,7 @@ void tst_QVariant::userType() qlonglong ll = Q_INT64_C(42); QVariant myCarrier; - qVariantSetValue(myCarrier, ll); + myCarrier.setValue(ll); QCOMPARE(qvariant_cast<int>(myCarrier), 42); } @@ -2192,14 +2255,14 @@ void tst_QVariant::podUserType() pod.a = 10; pod.b = 20; - QVariant pod_as_variant = qVariantFromValue(pod); + QVariant pod_as_variant = QVariant::fromValue(pod); MyTypePOD pod2 = qvariant_cast<MyTypePOD>(pod_as_variant); QCOMPARE(pod.a, pod2.a); QCOMPARE(pod.b, pod2.b); - qVariantSetValue(pod_as_variant, pod); - pod2 = qVariantValue<MyTypePOD>(pod_as_variant); + pod_as_variant.setValue(pod); + pod2 = qvariant_cast<MyTypePOD>(pod_as_variant); QCOMPARE(pod.a, pod2.a); QCOMPARE(pod.b, pod2.b); @@ -2266,7 +2329,7 @@ void tst_QVariant::data() v = f; QVERIFY(v.data()); - QCOMPARE(*static_cast<float *>(v.data()), qVariantValue<float>(v)); + QCOMPARE(*static_cast<float *>(v.data()), qvariant_cast<float>(v)); v = ll; QVERIFY(v.data()); @@ -2345,12 +2408,12 @@ void tst_QVariant::variant_to() QStringList sl; sl << QLatin1String("blah"); - qVariantSetValue(v3, sl); + v3.setValue(sl); Foo foo; foo.i = 42; - qVariantSetValue(v4, foo); + v4.setValue(foo); QCOMPARE(qvariant_cast<double>(v1), 4.2); QCOMPARE(qvariant_cast<float>(v1), 4.2f); @@ -2365,7 +2428,7 @@ void tst_QVariant::variant_to() QCOMPARE(qvariant_cast<int>(v1), 4); - QVariant n = qVariantFromValue<short>(42); + QVariant n = QVariant::fromValue<short>(42); QCOMPARE(qvariant_cast<int>(n), 42); QCOMPARE(qvariant_cast<uint>(n), 42u); QCOMPARE(qvariant_cast<double>(n), 42.0); @@ -2373,7 +2436,7 @@ void tst_QVariant::variant_to() QCOMPARE(qvariant_cast<short>(n), short(42)); QCOMPARE(qvariant_cast<ushort>(n), ushort(42)); - n = qVariantFromValue(43l); + n = QVariant::fromValue(43l); QCOMPARE(qvariant_cast<int>(n), 43); QCOMPARE(qvariant_cast<uint>(n), 43u); QCOMPARE(qvariant_cast<double>(n), 43.0); @@ -2385,7 +2448,7 @@ void tst_QVariant::variant_to() QCOMPARE(qvariant_cast<ulong>(n), 44ul); QCOMPARE(qvariant_cast<float>(n), 44.0f); - QCOMPARE(qVariantFromValue(0.25f).toDouble(), 0.25); + QCOMPARE(QVariant::fromValue(0.25f).toDouble(), 0.25); } struct Blah { int i; }; @@ -2437,10 +2500,10 @@ void tst_QVariant::url() QVariant v3(str); //built with a QString QCOMPARE(v2.toUrl(), url); - QVERIFY(qVariantCanConvert<QUrl>(v3)); + QVERIFY(v3.canConvert<QUrl>()); QCOMPARE(v2.toUrl(), v3.toUrl()); - QVERIFY(qVariantCanConvert<QString>(v2)); + QVERIFY(v2.canConvert<QString>()); QCOMPARE(v2.toString(), str); QCOMPARE(v3.toString(), str); } @@ -2615,7 +2678,7 @@ void tst_QVariant::convertToQUint8() const * It's of type QVariant::Int. */ const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert<qint8>(v0)); + QVERIFY(v0.canConvert<qint8>()); QCOMPARE(int(qvariant_cast<qint8>(v0)), 32); QCOMPARE(int(v0.toInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2633,7 +2696,7 @@ void tst_QVariant::convertToQUint8() const const quint8 anInt = 32; const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert<quint8>(v0)); + QVERIFY(v0.canConvert<quint8>()); QCOMPARE(int(qvariant_cast<quint8>(v0)), 32); QCOMPARE(int(v0.toUInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2644,7 +2707,7 @@ void tst_QVariant::convertToQUint8() const const qint16 anInt = 32; const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert<qint16>(v0)); + QVERIFY(v0.canConvert<qint16>()); QCOMPARE(int(qvariant_cast<qint16>(v0)), 32); QCOMPARE(int(v0.toInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2655,7 +2718,7 @@ void tst_QVariant::convertToQUint8() const const quint16 anInt = 32; const QVariant v0 = anInt; - QVERIFY(qVariantCanConvert<quint16>(v0)); + QVERIFY(v0.canConvert<quint16>()); QCOMPARE(int(qvariant_cast<quint16>(v0)), 32); QCOMPARE(int(v0.toUInt()), 32); QCOMPARE(v0.toString(), QString("32")); @@ -2670,8 +2733,8 @@ void tst_QVariant::comparePointers() const MyClass myClass; - QVariant v = qVariantFromValue<void *>(&myClass); - QVariant v2 = qVariantFromValue<void *>(&myClass); + QVariant v = QVariant::fromValue<void *>(&myClass); + QVariant v2 = QVariant::fromValue<void *>(&myClass); QCOMPARE(v, v2); } @@ -2686,15 +2749,15 @@ void tst_QVariant::voidStar() const void *p2 = p1; QVariant v1, v2; - v1 = qVariantFromValue(p1); + v1 = QVariant::fromValue(p1); v2 = v1; QVERIFY(v1 == v2); - v2 = qVariantFromValue(p2); + v2 = QVariant::fromValue(p2); QVERIFY(v1 == v2); p2 = 0; - v2 = qVariantFromValue(p2); + v2 = QVariant::fromValue(p2); QVERIFY(v1 != v2); } @@ -2703,14 +2766,14 @@ void tst_QVariant::dataStar() const qRegisterMetaType<Data*>(); Data *p1 = new Data; - QVariant v1 = qVariantFromValue(p1); + QVariant v1 = QVariant::fromValue(p1); QCOMPARE(v1.userType(), qMetaTypeId<Data*>()); QCOMPARE(qvariant_cast<Data*>(v1), p1); QVariant v2 = v1; QVERIFY(v1 == v2); - v2 = qVariantFromValue(p1); + v2 = QVariant::fromValue(p1); QVERIFY(v1 == v2); delete p1; } @@ -2748,10 +2811,10 @@ void tst_QVariant::canConvertQStringList_data() const template<typename T> void convertMetaType() { - QVERIFY(qVariantFromValue<T>(10).isValid()); - QVERIFY(qVariantFromValue<T>(10).canConvert(QVariant::Int)); - QCOMPARE(qVariantFromValue<T>(10).toInt(), 10); - QCOMPARE(qVariantFromValue<T>(10), qVariantFromValue<T>(10)); + QVERIFY(QVariant::fromValue<T>(10).isValid()); + QVERIFY(QVariant::fromValue<T>(10).canConvert(QVariant::Int)); + QCOMPARE(QVariant::fromValue<T>(10).toInt(), 10); + QCOMPARE(QVariant::fromValue<T>(10), QVariant::fromValue<T>(10)); } #define CONVERT_META_TYPE(Type) \ @@ -2818,6 +2881,8 @@ Q_DECLARE_METATYPE( MyClass ) void tst_QVariant::loadUnknownUserType() { qRegisterMetaType<MyClass>("MyClass"); + QTest::ignoreMessage(QtWarningMsg, "QVariant::load: unable to load type " + + QByteArray::number(qMetaTypeId<MyClass>()) +"."); char data[] = {0, 0, QMetaType::User >> 8 , char(QMetaType::User), 0, 0, 0, 0, 8, 'M', 'y', 'C', 'l', 'a', 's', 's', 0}; QByteArray ba(data, sizeof(data)); @@ -2829,13 +2894,14 @@ void tst_QVariant::loadUnknownUserType() void tst_QVariant::loadBrokenUserType() { - char data[] = {0, 0, 0, 127, 0, 112 }; + QTest::ignoreMessage(QtWarningMsg, "Trying to construct an instance of an invalid type, type id: 127"); + char data[] = {0, 0, 0, 127, 0 }; QByteArray ba(data, sizeof(data)); QDataStream ds(&ba, QIODevice::ReadOnly); QVariant var; var.load(ds); - QCOMPARE(ds.status(), QDataStream::ReadPastEnd); + QCOMPARE(ds.status(), QDataStream::Ok); } void tst_QVariant::invalidDate() const @@ -2872,11 +2938,11 @@ void tst_QVariant::compareCustomTypes() const WontCompare f1; f1.x = 0; - const QVariant variant1(qVariantFromValue(f1)); + const QVariant variant1(QVariant::fromValue(f1)); WontCompare f2; f2.x = 0; - const QVariant variant2(qVariantFromValue(f2)); + const QVariant variant2(QVariant::fromValue(f2)); /* We compare pointers. */ QVERIFY(variant1 != variant2); @@ -2898,10 +2964,10 @@ void tst_QVariant::copyingUserTypes() const QVariant var; QVariant var3; const QHostAddress ha("127.0.0.1"); - qVariantSetValue(var, ha); + var.setValue(ha); var3 = var; - QCOMPARE(qVariantValue<QHostAddress>(var3), ha); + QCOMPARE(qvariant_cast<QHostAddress>(var3), ha); } void tst_QVariant::convertBoolToByteArray() const @@ -2912,7 +2978,7 @@ void tst_QVariant::convertBoolToByteArray() const const QVariant variant(input); - QCOMPARE(qVariantCanConvert<bool>(variant), canConvert); + QCOMPARE(variant.canConvert<bool>(), canConvert); if(canConvert) { /* Just call this function so we run the code path. */ @@ -2980,7 +3046,7 @@ void tst_QVariant::convertByteArrayToBool() const const QVariant variant(input); QCOMPARE(variant.type(), QVariant::Bool); QCOMPARE(variant.toBool(), input); - QVERIFY(qVariantCanConvert<bool>(variant)); + QVERIFY(variant.canConvert<bool>()); QCOMPARE(variant.toByteArray(), output); } @@ -3055,7 +3121,7 @@ void tst_QVariant::setValue() QVERIFY( !v1.isDetached() ); QVERIFY( !v2.isDetached() ); - qVariantSetValue(v2, 3); //set an integer value + v2.setValue(3); //set an integer value QVERIFY( v1.isDetached() ); QVERIFY( v2.isDetached() ); @@ -3134,7 +3200,7 @@ template<class T> void playWithVariant(const T &orig, bool isNull, const QString } QCOMPARE(qvariant_cast<T>(v2), qvariant_cast<T>(v)); QCOMPARE(v2.toString(), toString); - v3 = qVariantFromValue(orig); + v3 = QVariant::fromValue(orig); QVERIFY(v3.isValid()); QCOMPARE(v3.isNull(), isNull); @@ -3344,7 +3410,7 @@ void tst_QVariant::moreCustomTypes() PLAY_WITH_VARIANT( qint32(17), false, "17", 17, true); PLAY_WITH_VARIANT(quint64(18), false, "18", 18, true); PLAY_WITH_VARIANT( qint64(19), false, "19", 19, true); - PLAY_WITH_VARIANT( qint8(-12), false, "\xf4", -12, true); + PLAY_WITH_VARIANT( qint8(-12), false, QLatin1String("\xf4"), -12, true); // qint8 is char, so it gets converted via QChar PLAY_WITH_VARIANT( qint16(-13), false, "-13", -13, true); PLAY_WITH_VARIANT( qint32(-14), false, "-14", -14, true); PLAY_WITH_VARIANT( qint64(-15), false, "-15", -15, true); diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro index d03af231aa..1ec4db8756 100644 --- a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro +++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro @@ -18,4 +18,3 @@ win32 { } mac: CONFIG -= app_bundle -mac: CONFIG += insignificant_test # QTBUG-22765 diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro index 810efe856c..a8dad32720 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro +++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro @@ -13,5 +13,3 @@ win32 { } TESTDATA += ../elftest - -mac: CONFIG += insignificant_test # QTBUG-22765 diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 267aa71085..e84eb95447 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -170,10 +170,10 @@ static const struct StaticByteArrays { const char string[8]; } shiftedNotNullTerminated; -} statics = {{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) }, "data"} - ,{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) }, "dataBAD"} - ,{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) + sizeof(char) }, 0, "data"} - ,{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) + sizeof(char) }, 0, "dataBAD"} +} statics = {{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(4), "data"} + ,{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(4), "dataBAD"} + ,{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(4, sizeof(QByteArrayData) + sizeof(char)), 0, "data"} + ,{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(4, sizeof(QByteArrayData) + sizeof(char)), 0, "dataBAD"} }; static const QByteArrayDataPtr staticStandard = { const_cast<QByteArrayData *>(&statics.standard.data) }; diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index 14c43d0088..1a568073cf 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -276,8 +276,65 @@ void tst_QChar::isLetterOrNumber() void tst_QChar::isPrint() { + // noncharacters, reserved (General_Gategory =Cn) + QVERIFY(!QChar(0x2064).isPrint()); + QVERIFY(!QChar(0x2069).isPrint()); + QVERIFY(!QChar(0xfdd0).isPrint()); + QVERIFY(!QChar(0xfdef).isPrint()); + QVERIFY(!QChar(0xfff0).isPrint()); + QVERIFY(!QChar(0xfff8).isPrint()); + QVERIFY(!QChar(0xfffe).isPrint()); + QVERIFY(!QChar(0xffff).isPrint()); +/* + QVERIFY(!QChar::isPrint(0xe0000u)); + QVERIFY(!QChar::isPrint(0xe0002u)); + QVERIFY(!QChar::isPrint(0xe001fu)); + QVERIFY(!QChar::isPrint(0xe0080u)); + QVERIFY(!QChar::isPrint(0xe00ffu)); +*/ + + // Other_Default_Ignorable_Code_Point, Variation_Selector + QVERIFY(QChar(0x034f).isPrint()); + QVERIFY(QChar(0x115f).isPrint()); + QVERIFY(QChar(0x180b).isPrint()); + QVERIFY(QChar(0x180d).isPrint()); + QVERIFY(QChar(0x3164).isPrint()); + QVERIFY(QChar(0xfe00).isPrint()); + QVERIFY(QChar(0xfe0f).isPrint()); + QVERIFY(QChar(0xffa0).isPrint()); +/* + QVERIFY(QChar::isPrint(0xe0100u)); + QVERIFY(QChar::isPrint(0xe01efu)); +*/ + + // Cf, Cs, Cc, White_Space, Annotation Characters + QVERIFY(!QChar(0x0008).isPrint()); + QVERIFY(!QChar(0x000a).isPrint()); + QVERIFY(QChar(0x0020).isPrint()); + QVERIFY(QChar(0x00a0).isPrint()); + QVERIFY(!QChar(0x00ad).isPrint()); + QVERIFY(!QChar(0x0085).isPrint()); + QVERIFY(!QChar(0xd800).isPrint()); + QVERIFY(!QChar(0xdc00).isPrint()); + QVERIFY(!QChar(0xfeff).isPrint()); +/* + QVERIFY(!QChar::isPrint(0x1d173u)); +*/ + + QVERIFY(QChar('0').isPrint()); QVERIFY(QChar('A').isPrint()); - QVERIFY(!QChar(0x1aff).isPrint()); // General_Gategory =Cn + QVERIFY(QChar('a').isPrint()); + + QVERIFY(!QChar(0x0370).isPrint()); // assigned in 5.1 + QVERIFY(!QChar(0x0524).isPrint()); // assigned in 5.2 + QVERIFY(!QChar(0x0526).isPrint()); // assigned in 6.0 + QVERIFY(!QChar(0x08a0).isPrint()); // assigned in 6.1 + QVERIFY(!QChar(0x1aff).isPrint()); // not assigned + QVERIFY(!QChar(0x1e9e).isPrint()); // assigned in 5.1 +/* + QVERIFY(!QChar::isPrint(0x1b000u)); // assigned in 6.0 + QVERIFY(!QChar::isPrint(0x110d0u)); // assigned in 5.1 +*/ } void tst_QChar::isUpper() @@ -551,6 +608,14 @@ void tst_QChar::mirroredChar() void tst_QChar::decomposition() { + // Hangul syllables + for (uint ucs = 0xac00; ucs <= 0xd7af; ++ucs) { + QChar::Decomposition expected = QChar::unicodeVersion(ucs) > QChar::Unicode_Unassigned ? QChar::Canonical : QChar::NoDecomposition; + QString desc = QString::fromLatin1("ucs = 0x%1, tag = %2, expected = %3") + .arg(QString::number(ucs, 16)).arg(QChar::decompositionTag(ucs)).arg(expected); + QVERIFY2(QChar::decompositionTag(ucs) == expected, desc.toLatin1()); + } + QVERIFY(QChar((ushort)0xa0).decompositionTag() == QChar::NoBreak); QVERIFY(QChar((ushort)0xa8).decompositionTag() == QChar::Compat); QVERIFY(QChar((ushort)0x41).decompositionTag() == QChar::NoDecomposition); @@ -748,6 +813,25 @@ void tst_QChar::normalization_manual() QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed); QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed); } + { // hangul + QString composed; + composed += QChar(0xc154); + composed += QChar(0x11f0); + QString decomposed; + decomposed += QChar(0x1109); + decomposed += QChar(0x1167); + decomposed += QChar(0x11f0); + + QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed); + QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed); + QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed); + QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed); + + QVERIFY(decomposed.normalized(QString::NormalizationForm_D) == decomposed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_C) == composed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_KD) == decomposed); + QVERIFY(decomposed.normalized(QString::NormalizationForm_KC) == composed); + } } void tst_QChar::normalizationCorrections() diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 40e3cd08b6..487007e4cf 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -526,7 +526,7 @@ void tst_QEasingCurve::properties() obj.setEasing(inOutBack); - QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing")); + QEasingCurve easing = qvariant_cast<QEasingCurve>(obj.property("easing")); QCOMPARE(easing.type(), QEasingCurve::InOutBack); QCOMPARE(easing.overshoot(), overshoot); QCOMPARE(easing.amplitude(), amplitude); @@ -538,9 +538,9 @@ void tst_QEasingCurve::properties() period = linear.period(); obj.setProperty("easing", - qVariantFromValue(QEasingCurve(QEasingCurve::Linear))); + QVariant::fromValue(QEasingCurve(QEasingCurve::Linear))); - easing = qVariantValue<QEasingCurve>(obj.property("easing")); + easing = qvariant_cast<QEasingCurve>(obj.property("easing")); QCOMPARE(easing.type(), QEasingCurve::Linear); QCOMPARE(easing.overshoot(), overshoot); QCOMPARE(easing.amplitude(), amplitude); diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index 28e127e307..25023fad4d 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -16,5 +16,4 @@ win32 { load(testcase) # for target.path and installTestHelperApp() installTestHelperApp("../syslocaleapp/syslocaleapp",syslocaleapp,syslocaleapp) -mac: CONFIG += insignificant_test # QTBUG-22769 win32:CONFIG+= insignificant_test # QTBUG-25284 diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 1905c9c049..4ac1221643 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -39,6 +39,16 @@ ** ****************************************************************************/ +#ifdef QT_NO_CAST_FROM_ASCII +# undef QT_NO_CAST_FROM_ASCII +#endif +#ifdef QT_NO_CAST_TO_ASCII +# undef QT_NO_CAST_TO_ASCII +#endif +#ifdef QT_ASCII_CAST_WARNINGS +# undef QT_ASCII_CAST_WARNINGS +#endif + #include <QtTest/QtTest> #include <qregexp.h> #include <qregularexpression.h> @@ -623,7 +633,7 @@ void tst_QString::utf8_data() QTest::newRow( "str0" ) << QByteArray("abcdefgh") << QString("abcdefgh"); QTest::newRow( "str1" ) << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") - << QString("\366\344\374\326\304\334\370\346\345\330\306\305") ; + << QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305") ; str += QChar( 0x05e9 ); str += QChar( 0x05d3 ); str += QChar( 0x05d2 ); @@ -885,41 +895,11 @@ void tst_QString::constructorQByteArray() void tst_QString::STL() { -#ifndef QT_NO_CAST_TO_ASCII - QString qt( "QString" ); - std::string stdstr( "QString" ); - QString stlqt; - - // constructor - stlqt = QString( stdstr ); - QCOMPARE( stlqt, qt ); - - // assignment - stlqt = stdstr; - QCOMPARE( stlqt, qt ); - - std::string stdstr2 = stlqt; - QCOMPARE( stdstr2, stdstr ); - - // prepend - stlqt = QString(); - stlqt.prepend( stdstr ); - QCOMPARE( stlqt, qt ); - - // append - stlqt = QString(); - stlqt.append( stdstr ); - QCOMPARE( stlqt, qt ); - - // pathologics (null-strings not supported by many STLs, so test only empty strings) - stdstr = std::string(); - stlqt = stdstr; - QVERIFY( stlqt.isEmpty() ); - std::string stdstr3 = stlqt; - QVERIFY( !stdstr3.length() ); -#endif + QString stlqt = QString::fromStdString(stdstr); + QCOMPARE(stlqt, QString::fromLatin1(stdstr.c_str())); + QCOMPARE(stlqt.toStdString(), stdstr); const wchar_t arr[] = {'h', 'e', 'l', 'l', 'o', 0}; std::wstring stlStr = arr; @@ -3297,7 +3277,7 @@ void tst_QString::check_QTextIOStream() a=""; QTextStream ts(&a); ts << "pi \261= " << 3.125; - QCOMPARE(a,(QString)"pi \261= 3.125"); + QCOMPARE(a, QString::fromLatin1("pi \261= 3.125")); } { a="123 456"; @@ -3426,8 +3406,10 @@ void tst_QString::fromUtf8_data() QTest::newRow("str0") << QByteArray("abcdefgh") << QString("abcdefgh") << -1; QTest::newRow("str0-len") << QByteArray("abcdefgh") << QString("abc") << 3; - QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304\334\370\346\345\330\306\305") << -1; - QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304") << 10; + QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") + << QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305") << -1; + QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") + << QString::fromLatin1("\366\344\374\326\304") << 10; str += QChar(0x05e9); str += QChar(0x05d3); @@ -3474,9 +3456,9 @@ void tst_QString::fromUtf8_data() QTest::newRow("null5") << QByteArray() << QString() << 5; QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << QString() << -1; QTest::newRow("empty0") << QByteArray() << QString() << 0; - QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromAscii("\0abcd", 5) << 5; - QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab") << -1; - QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab\0cd", 5) << 5; + QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromLatin1("\0abcd", 5) << 5; + QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab") << -1; + QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab\0cd", 5) << 5; str = "Old Italic: "; str += QChar(0xd800); @@ -4390,13 +4372,13 @@ void tst_QString::localeAwareCompare_data() below. */ #ifdef Q_OS_WIN // assume c locale to be english - QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << 1; - QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1; + QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << 1; + QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1; #else - QTest::newRow("c1") << QString("C") << QString("\xe5") << QString("\xe4") << 1; - QTest::newRow("c2") << QString("C") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("c3") << QString("C") << QString("\xe5") << QString("\xf6") << -1; + QTest::newRow("c1") << QString("C") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << 1; + QTest::newRow("c2") << QString("C") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("c3") << QString("C") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1; #endif /* @@ -4422,20 +4404,20 @@ void tst_QString::localeAwareCompare_data() all come after z. */ #ifdef Q_OS_MAC - QTest::newRow("swedish1") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xe4") << -1; - QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xf6") << -1; - QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString("z") << QString("\xe5") << -1; + QTest::newRow("swedish1") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1; + QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1; #elif defined(Q_OS_WIN) - QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << -1; - QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1; - QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("z") << QString("\xe5") << -1; + QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1; + QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1; #else - QTest::newRow("swedish1") << QString("sv_SE") << QString("\xe5") << QString("\xe4") << -1; - QTest::newRow("swedish2") << QString("sv_SE") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("swedish3") << QString("sv_SE") << QString("\xe5") << QString("\xf6") << -1; - QTest::newRow("swedish4") << QString("sv_SE") << QString("z") << QString("\xe5") << -1; + QTest::newRow("swedish1") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1; + QTest::newRow("swedish2") << QString("sv_SE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("swedish3") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("swedish4") << QString("sv_SE") << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1; #endif #if 0 @@ -4443,9 +4425,9 @@ void tst_QString::localeAwareCompare_data() In Norwegian, ae (E6) comes before o with stroke (D8), which comes before a with ring above (E5). */ - QTest::newRow("norwegian1") << QString("no_NO") << QString("\xe6") << QString("\xd8") << -1; - QTest::newRow("norwegian2") << QString("no_NO") << QString("\xd8") << QString("\xe5") << -1; - QTest::newRow("norwegian3") << QString("no_NO") << QString("\xe6") << QString("\xe5") << -1; + QTest::newRow("norwegian1") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xd8") << -1; + QTest::newRow("norwegian2") << QString("no_NO") << QString::fromLatin1("\xd8") << QString::fromLatin1("\xe5") << -1; + QTest::newRow("norwegian3") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xe5") << -1; #endif /* @@ -4453,17 +4435,17 @@ void tst_QString::localeAwareCompare_data() which comes before o diaresis (F6). */ #ifdef Q_OS_MAC - QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xe4") << 1; - QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xf6") << 1; + QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1; + QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1; #elif defined(Q_OS_WIN) - QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xe4") << 1; - QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xf6") << 1; + QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1; + QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1; #else - QTest::newRow("german1") << QString("de_DE") << QString("z") << QString("\xe4") << 1; - QTest::newRow("german2") << QString("de_DE") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("german3") << QString("de_DE") << QString("z") << QString("\xf6") << 1; + QTest::newRow("german1") << QString("de_DE") << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1; + QTest::newRow("german2") << QString("de_DE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1; + QTest::newRow("german3") << QString("de_DE") << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1; #endif } diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 556b9ac16a..d0f82a38b7 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -57,6 +57,11 @@ #define UNICODE_LITERAL_EXTRA u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l" "EXTRA" #endif +#ifndef P +# error You need to define P +# define P + +#endif + //fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS #ifndef QT_USE_FAST_CONCATENATION #define Q % @@ -68,7 +73,6 @@ void runScenario() { // this code is latin1. TODO: replace it with the utf8 block below, once // strings default to utf8. - QLatin1Literal l1literal(LITERAL); QLatin1String l1string(LITERAL); QString string(l1string); QStringRef stringref(&string, 2, 10); @@ -78,14 +82,10 @@ void runScenario() QString r3 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); QString r; - r = l1literal Q l1literal; - QCOMPARE(r, r2); r = string P string; QCOMPARE(r, r2); r = stringref Q stringref; QCOMPARE(r, QString(stringref.toString() + stringref.toString())); - r = string Q l1literal; - QCOMPARE(r, r2); r = string P l1string; QCOMPARE(r, r2); r = string Q QStringLiteral(LITERAL); diff --git a/tests/auto/corelib/tools/qtimeline/qtimeline.pro b/tests/auto/corelib/tools/qtimeline/qtimeline.pro index cac8074038..3a6c120b5a 100644 --- a/tests/auto/corelib/tools/qtimeline/qtimeline.pro +++ b/tests/auto/corelib/tools/qtimeline/qtimeline.pro @@ -2,4 +2,3 @@ CONFIG += testcase parallel_test TARGET = tst_qtimeline QT = core testlib SOURCES = tst_qtimeline.cpp -win32:CONFIG+=insignificant_test # unstable, QTBUG-24796 diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index f05497d7a2..b15de5c1df 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -184,9 +184,10 @@ void tst_QTimeLine::duration() timeLine.start(); QTest::qWait(999); QCOMPARE(timeLine.state(), QTimeLine::Running); - QVERIFY(timeLine.currentTime() > 0.9); - QTest::qWait(50); + QVERIFY(timeLine.currentTime() > 900); + QTest::qWait(100); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); + QCOMPARE(timeLine.currentTime(), 1000); // The duration shouldn't change QCOMPARE(timeLine.duration(), 1000); } @@ -368,6 +369,8 @@ void tst_QTimeLine::interpolation() QCOMPARE(timeLine.state(), QTimeLine::Running); // Smooth accellerates slowly so in the beginning so it is farther behind + if (firstValue >= timeLine.currentFrame()) + QEXPECT_FAIL("", "QTBUG-24796: QTimeLine exhibits inconsistent timing behaviour", Abort); QVERIFY(firstValue < timeLine.currentFrame()); QTest::qWait(200); QVERIFY(endValue > timeLine.currentFrame()); @@ -456,24 +459,33 @@ void tst_QTimeLine::toggleDirection() void tst_QTimeLine::frameChanged() { QTimeLine timeLine; + timeLine.setCurveShape(QTimeLine::LinearCurve); timeLine.setFrameRange(0,9); - timeLine.setUpdateInterval(1000); + timeLine.setUpdateInterval(800); QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); QVERIFY(spy.isValid()); + + // Test what happens when duration expires before all frames are emitted. timeLine.start(); - QTest::qWait(timeLine.duration()*2); + QTest::qWait(timeLine.duration()/2); + QCOMPARE(timeLine.state(), QTimeLine::Running); + QCOMPARE(spy.count(), 0); + QTest::qWait(timeLine.duration()); + if (timeLine.state() != QTimeLine::NotRunning) + QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - // Probably 10 - QVERIFY(spy.count() <= 10 && spy.count() > 0); + if (spy.count() != 1) + QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); + QCOMPARE(spy.count(), 1); + // Test what happens when the frames are all emitted well before duration expires. timeLine.setUpdateInterval(5); spy.clear(); timeLine.setCurrentTime(0); timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - // Probably 1 - QVERIFY(spy.count() <= 10 && spy.count() > 0); + QCOMPARE(spy.count(), 10); } void tst_QTimeLine::stopped() diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index 8a60bb1876..4442094541 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -1252,7 +1252,7 @@ void tst_QXmlStream::writeWithCodec() const QVERIFY(codec); writer.setCodec(codec); - const char *latin2 = "hé hé"; + const char *latin2 = "h\xe9 h\xe9"; const QString string = codec->toUnicode(latin2); diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index 30571fadd6..7e31f6091c 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -1064,11 +1064,11 @@ void tst_QDBusAbstractAdaptor::writeProperties() valueSpy.clear(); properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop1"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QVERIFY(valueSpy.isEmpty()); // call mustn't have succeeded properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop2"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QCOMPARE(valueSpy, name); QCOMPARE(QString(slotSpy), QString("void %1::setProp2(const QString &)").arg(name)); } @@ -1570,11 +1570,11 @@ void tst_QDBusAbstractAdaptor::writePropertiesPeer() clearValueSpyPeer(); properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop1"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QVERIFY(valueSpyPeer().isEmpty()); // call mustn't have succeeded properties.call(QDBus::BlockWithGui, "Set", "local." + name, QString("prop2"), - qVariantFromValue(QDBusVariant(name))); + QVariant::fromValue(QDBusVariant(name))); QCOMPARE(valueSpyPeer(), name); QCOMPARE(QString(slotSpyPeer()), QString("void %1::setProp2(const QString &)").arg(name)); } @@ -1774,9 +1774,9 @@ void tst_QDBusAbstractAdaptor::typeMatching_data() QTest::addColumn<QVariant>("value"); QTest::newRow("bool") << "Bool" << "b" << QVariant(true); - QTest::newRow("byte") << "UChar" << "y" << qVariantFromValue(uchar(42)); - QTest::newRow("short") << "Short" << "n" << qVariantFromValue(short(-43)); - QTest::newRow("ushort") << "UShort" << "q" << qVariantFromValue(ushort(44)); + QTest::newRow("byte") << "UChar" << "y" << QVariant::fromValue(uchar(42)); + QTest::newRow("short") << "Short" << "n" << QVariant::fromValue(short(-43)); + QTest::newRow("ushort") << "UShort" << "q" << QVariant::fromValue(ushort(44)); QTest::newRow("int") << "Int" << "i" << QVariant(42); QTest::newRow("uint") << "UInt" << "u" << QVariant(42U); QTest::newRow("qlonglong") << "LongLong" << "x" << QVariant(Q_INT64_C(42)); @@ -1784,12 +1784,12 @@ void tst_QDBusAbstractAdaptor::typeMatching_data() QTest::newRow("double") << "Double" << "d" << QVariant(2.5); QTest::newRow("string") << "String" << "s" << QVariant("Hello, World!"); - QTest::newRow("variant") << "Variant" << "v" << qVariantFromValue(QDBusVariant("Hello again!")); + QTest::newRow("variant") << "Variant" << "v" << QVariant::fromValue(QDBusVariant("Hello again!")); QTest::newRow("list") << "List" << "av" << QVariant(QVariantList() << 42 << QString("foo") << QByteArray("bar") - << qVariantFromValue(QDBusVariant(QString("baz")))); + << QVariant::fromValue(QDBusVariant(QString("baz")))); QTest::newRow("stringlist") << "StringList" << "as" << QVariant(QStringList() << "Hello" << "world"); QTest::newRow("bytearray") << "ByteArray" << "ay" << QVariant(QByteArray("foo")); @@ -1798,24 +1798,24 @@ void tst_QDBusAbstractAdaptor::typeMatching_data() map["The answer to life, the Universe and everything"] = 42u; // uint map["In the beginning..."] = QString("There was nothing"); // string map["but Unix came and said"] = QByteArray("\"Hello, World\""); // bytearray - map["two"] = qVariantFromValue(short(2)); // short + map["two"] = QVariant::fromValue(short(2)); // short QTest::newRow("map") << "Map" << "a{sv}" << QVariant(map); StringStringMap ssmap; ssmap["a"] = "A"; ssmap["A"] = "a"; - QTest::newRow("ssmap") << "SSMap" << "a{ss}" << qVariantFromValue(ssmap); + QTest::newRow("ssmap") << "SSMap" << "a{ss}" << QVariant::fromValue(ssmap); LLDateTimeMap lldtmap; lldtmap[-1] = QDateTime(); QDateTime now = QDateTime::currentDateTime(); lldtmap[now.toTime_t()] = now; // array of struct of int64 and struct of 3 ints and struct of 4 ints and int - QTest::newRow("lldtmap") << "LLDateTimeMap" << "a{x((iii)(iiii)i)}" << qVariantFromValue(lldtmap); + QTest::newRow("lldtmap") << "LLDateTimeMap" << "a{x((iii)(iiii)i)}" << QVariant::fromValue(lldtmap); MyStruct s; s.i = 42; s.s = "A value"; - QTest::newRow("struct") << "Struct" << "(is)" << qVariantFromValue(s); + QTest::newRow("struct") << "Struct" << "(is)" << QVariant::fromValue(s); } void tst_QDBusAbstractAdaptor::typeMatching() diff --git a/tests/auto/dbus/qdbusabstractinterface/pinger.h b/tests/auto/dbus/qdbusabstractinterface/pinger.h index 7fc6e640fe..0b6e8343bb 100644 --- a/tests/auto/dbus/qdbusabstractinterface/pinger.h +++ b/tests/auto/dbus/qdbusabstractinterface/pinger.h @@ -81,19 +81,19 @@ public: inline RegisteredType complexProp() const { return qvariant_cast< RegisteredType >(property("complexProp")); } inline void setComplexProp(RegisteredType value) - { setProperty("complexProp", qVariantFromValue(value)); } + { setProperty("complexProp", QVariant::fromValue(value)); } Q_PROPERTY(QString stringProp READ stringProp WRITE setStringProp) inline QString stringProp() const { return qvariant_cast< QString >(property("stringProp")); } inline void setStringProp(const QString &value) - { setProperty("stringProp", qVariantFromValue(value)); } + { setProperty("stringProp", QVariant::fromValue(value)); } Q_PROPERTY(QDBusVariant variantProp READ variantProp WRITE setVariantProp) inline QDBusVariant variantProp() const { return qvariant_cast< QDBusVariant >(property("variantProp")); } inline void setVariantProp(const QDBusVariant &value) - { setProperty("variantProp", qVariantFromValue(value)); } + { setProperty("variantProp", QVariant::fromValue(value)); } public Q_SLOTS: // METHODS inline QDBusPendingReply<RegisteredType> complexMethod() @@ -120,7 +120,7 @@ public Q_SLOTS: // METHODS inline QDBusPendingReply<int> sleepMethod(int in0) { QList<QVariant> argumentList; - argumentList << qVariantFromValue(in0); + argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QLatin1String("sleepMethod"), argumentList); } diff --git a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 59ec2955e4..fcc2a32920 100644 --- a/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/dbus/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -495,7 +495,7 @@ void tst_QDBusAbstractInterface::callWithTimeout() QDBusMessage msg = QDBusMessage::createMethodCall(server_serviceName, server_objectPath, server_interfaceName, "sleepMethod"); - msg << 100; + msg << 100; // sleep 100 ms { // Call with no timeout -> works @@ -505,7 +505,7 @@ void tst_QDBusAbstractInterface::callWithTimeout() } { - // Call with 1 sec timeout -> fails + // Call with 1 msec timeout -> fails QDBusMessage reply = con.call(msg, QDBus::Block, 1); QCOMPARE(reply.type(), QDBusMessage::ErrorMessage); } @@ -520,11 +520,17 @@ void tst_QDBusAbstractInterface::callWithTimeout() QCOMPARE(reply.arguments().at(0).toInt(), 42); } { - // Call with 1 sec timeout -> fails + // Call with 1 msec timeout -> fails iface.setTimeout(1); QDBusMessage reply = iface.call("sleepMethod", 100); QCOMPARE(reply.type(), QDBusMessage::ErrorMessage); } + { + // Call with 300 msec timeout -> works + iface.setTimeout(300); + QDBusMessage reply = iface.call("sleepMethod", 100); + QCOMPARE(reply.arguments().at(0).toInt(), 42); + } // Now using generated code com::trolltech::QtDBus::Pinger p(server_serviceName, server_objectPath, QDBusConnection::sessionBus()); @@ -535,7 +541,7 @@ void tst_QDBusAbstractInterface::callWithTimeout() QCOMPARE(int(reply), 42); } { - // Call with 1 sec timeout -> fails + // Call with 1 msec timeout -> fails p.setTimeout(1); QDBusReply<int> reply = p.sleepMethod(100); QVERIFY(!reply.isValid()); @@ -582,7 +588,7 @@ void tst_QDBusAbstractInterface::variantPropWrite() QVERIFY2(p, "Not connected to D-Bus"); QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); - QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("variantProp", QVariant::fromValue(expectedValue))); QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); } @@ -603,7 +609,7 @@ void tst_QDBusAbstractInterface::complexPropWrite() QVERIFY2(p, "Not connected to D-Bus"); RegisteredType expectedValue = RegisteredType("This is a value"); - QVERIFY(p->setProperty("complexProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("complexProp", QVariant::fromValue(expectedValue))); QCOMPARE(targetObj.m_complexProp, expectedValue); } @@ -652,7 +658,7 @@ void tst_QDBusAbstractInterface::variantPropWritePeer() resetServer(); QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); - QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("variantProp", QVariant::fromValue(expectedValue))); QEXPECT_FAIL("", "QTBUG-24262 peer tests are broken", Abort); QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); } @@ -676,7 +682,7 @@ void tst_QDBusAbstractInterface::complexPropWritePeer() resetServer(); RegisteredType expectedValue = RegisteredType("This is a value"); - QVERIFY(p->setProperty("complexProp", qVariantFromValue(expectedValue))); + QVERIFY(p->setProperty("complexProp", QVariant::fromValue(expectedValue))); QEXPECT_FAIL("", "QTBUG-24262 peer tests are broken", Abort); QCOMPARE(targetObj.m_complexProp, expectedValue); } diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index af2355aa5d..f6520ce946 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -161,7 +161,7 @@ int prop1Peer() void setComplexPropPeer(QList<int> val) { QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "setComplexProp"); - req << qVariantFromValue(val); + req << QVariant::fromValue(val); QDBusMessage reply = QDBusConnection::sessionBus().call(req); } @@ -474,7 +474,7 @@ void tst_QDBusInterface::callMethod() MyObject::callCount = 0; // call a SLOT method - QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo"))); + QDBusMessage reply = iface.call("ping", QVariant::fromValue(QDBusVariant("foo"))); QCOMPARE(MyObject::callCount, 1); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -493,7 +493,7 @@ void tst_QDBusInterface::callMethod() QCOMPARE(dv.variant().toString(), QString("foo")); // call an INVOKABLE method - reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar"))); + reply = iface.call("ping_invokable", QVariant::fromValue(QDBusVariant("bar"))); QCOMPARE(MyObject::callCount, 2); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -708,7 +708,7 @@ void tst_QDBusInterface::callMethodPeer() resetPeer(); // call a SLOT method - QDBusMessage reply = iface.call("ping", qVariantFromValue(QDBusVariant("foo"))); + QDBusMessage reply = iface.call("ping", QVariant::fromValue(QDBusVariant("foo"))); QCOMPARE(callCountPeer(), 1); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -728,7 +728,7 @@ void tst_QDBusInterface::callMethodPeer() QCOMPARE(dv.variant().toString(), QString("foo")); // call an INVOKABLE method - reply = iface.call("ping_invokable", qVariantFromValue(QDBusVariant("bar"))); + reply = iface.call("ping_invokable", QVariant::fromValue(QDBusVariant("bar"))); QCOMPARE(callCountPeer(), 2); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); @@ -1066,7 +1066,7 @@ void tst_QDBusInterface::complexPropertyWrite() obj.m_complexProp.clear(); MyObject::callCount = 0; - QVERIFY(iface.setProperty("complexProp", qVariantFromValue(arg))); + QVERIFY(iface.setProperty("complexProp", QVariant::fromValue(arg))); QCOMPARE(MyObject::callCount, 1); QCOMPARE(obj.m_complexProp, arg); } @@ -1129,7 +1129,7 @@ void tst_QDBusInterface::complexPropertyWritePeer() resetPeer(); QList<int> arg = QList<int>() << -47 << 42; - QVERIFY(iface.setProperty("complexProp", qVariantFromValue(arg))); + QVERIFY(iface.setProperty("complexProp", QVariant::fromValue(arg))); QCOMPARE(callCountPeer(), 1); QCOMPARE(complexPropPeer(), arg); } diff --git a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp index 871ae6948d..340455c2bd 100644 --- a/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp +++ b/tests/auto/dbus/qdbuslocalcalls/tst_qdbuslocalcalls.cpp @@ -185,7 +185,7 @@ void tst_QDBusLocalCalls::makeCallsVariant() QFETCH(QVariant, value); QDBusMessage callMsg = QDBusMessage::createMethodCall(conn.baseService(), "/", QString(), "echo"); - callMsg << qVariantFromValue(QDBusVariant(value)); + callMsg << QVariant::fromValue(QDBusVariant(value)); QDBusMessage replyMsg = doCall(callMsg); QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); @@ -222,7 +222,7 @@ void tst_QDBusLocalCalls::makeCallsComplex() value << 1 << -42 << 47; QDBusMessage callMsg = QDBusMessage::createMethodCall(conn.baseService(), "/", QString(), "echo"); - callMsg << qVariantFromValue(value); + callMsg << QVariant::fromValue(value); QDBusMessage replyMsg = doCall(callMsg); QCOMPARE(int(replyMsg.type()), int(QDBusMessage::ReplyMessage)); diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 8412fb85be..8a7e809b15 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -182,9 +182,9 @@ void basicNumericTypes_data() { QTest::newRow("bool") << QVariant(false) << "b" << "false"; QTest::newRow("bool2") << QVariant(true) << "b" << "true"; - QTest::newRow("byte") << qVariantFromValue(uchar(1)) << "y" << "1"; - QTest::newRow("int16") << qVariantFromValue(short(2)) << "n" << "2"; - QTest::newRow("uint16") << qVariantFromValue(ushort(3)) << "q" << "3"; + QTest::newRow("byte") << QVariant::fromValue(uchar(1)) << "y" << "1"; + QTest::newRow("int16") << QVariant::fromValue(short(2)) << "n" << "2"; + QTest::newRow("uint16") << QVariant::fromValue(ushort(3)) << "q" << "3"; QTest::newRow("int") << QVariant(1) << "i" << "1"; QTest::newRow("uint") << QVariant(2U) << "u" << "2"; QTest::newRow("int64") << QVariant(Q_INT64_C(3)) << "x" << "3"; @@ -195,8 +195,8 @@ void basicNumericTypes_data() void basicStringTypes_data() { QTest::newRow("string") << QVariant("ping") << "s" << "\"ping\""; - QTest::newRow("objectpath") << qVariantFromValue(QDBusObjectPath("/org/kde")) << "o" << "[ObjectPath: /org/kde]"; - QTest::newRow("signature") << qVariantFromValue(QDBusSignature("g")) << "g" << "[Signature: g]"; + QTest::newRow("objectpath") << QVariant::fromValue(QDBusObjectPath("/org/kde")) << "o" << "[ObjectPath: /org/kde]"; + QTest::newRow("signature") << QVariant::fromValue(QDBusSignature("g")) << "g" << "[Signature: g]"; QTest::newRow("emptystring") << QVariant("") << "s" << "\"\""; QTest::newRow("nullstring") << QVariant(QString()) << "s" << "\"\""; } @@ -210,17 +210,17 @@ void tst_QDBusMarshall::sendBasic_data() basicStringTypes_data(); if (fileDescriptorPassing) - QTest::newRow("file-descriptor") << qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())) << "h" << "[Unix FD: valid]"; + QTest::newRow("file-descriptor") << QVariant::fromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())) << "h" << "[Unix FD: valid]"; } void tst_QDBusMarshall::sendVariant_data() { sendBasic_data(); - QTest::newRow("variant") << qVariantFromValue(QDBusVariant(1)) << "v" << "[Variant(int): 1]"; + QTest::newRow("variant") << QVariant::fromValue(QDBusVariant(1)) << "v" << "[Variant(int): 1]"; QDBusVariant nested(1); - QTest::newRow("variant-variant") << qVariantFromValue(QDBusVariant(qVariantFromValue(nested))) << "v" + QTest::newRow("variant-variant") << QVariant::fromValue(QDBusVariant(QVariant::fromValue(nested))) << "v" << "[Variant(QDBusVariant): [Variant(int): 1]]"; } @@ -252,70 +252,70 @@ void tst_QDBusMarshall::sendArrays_data() QTest::newRow("bytearray") << QVariant(bytearray) << "ay" << "{102, 111, 111}"; QList<bool> bools; - QTest::newRow("emptyboollist") << qVariantFromValue(bools) << "ab" << "[Argument: ab {}]"; + QTest::newRow("emptyboollist") << QVariant::fromValue(bools) << "ab" << "[Argument: ab {}]"; bools << false << true << false; - QTest::newRow("boollist") << qVariantFromValue(bools) << "ab" << "[Argument: ab {false, true, false}]"; + QTest::newRow("boollist") << QVariant::fromValue(bools) << "ab" << "[Argument: ab {false, true, false}]"; QList<short> shorts; - QTest::newRow("emptyshortlist") << qVariantFromValue(shorts) << "an" << "[Argument: an {}]"; + QTest::newRow("emptyshortlist") << QVariant::fromValue(shorts) << "an" << "[Argument: an {}]"; shorts << 42 << -43 << 44 << 45 << -32768 << 32767; - QTest::newRow("shortlist") << qVariantFromValue(shorts) << "an" + QTest::newRow("shortlist") << QVariant::fromValue(shorts) << "an" << "[Argument: an {42, -43, 44, 45, -32768, 32767}]"; QList<ushort> ushorts; - QTest::newRow("emptyushortlist") << qVariantFromValue(ushorts) << "aq" << "[Argument: aq {}]"; + QTest::newRow("emptyushortlist") << QVariant::fromValue(ushorts) << "aq" << "[Argument: aq {}]"; ushorts << 12u << 13u << 14u << 15 << 65535; - QTest::newRow("ushortlist") << qVariantFromValue(ushorts) << "aq" << "[Argument: aq {12, 13, 14, 15, 65535}]"; + QTest::newRow("ushortlist") << QVariant::fromValue(ushorts) << "aq" << "[Argument: aq {12, 13, 14, 15, 65535}]"; QList<int> ints; - QTest::newRow("emptyintlist") << qVariantFromValue(ints) << "ai" << "[Argument: ai {}]"; + QTest::newRow("emptyintlist") << QVariant::fromValue(ints) << "ai" << "[Argument: ai {}]"; ints << 42 << -43 << 44 << 45 << 2147483647 << -2147483647-1; - QTest::newRow("intlist") << qVariantFromValue(ints) << "ai" << "[Argument: ai {42, -43, 44, 45, 2147483647, -2147483648}]"; + QTest::newRow("intlist") << QVariant::fromValue(ints) << "ai" << "[Argument: ai {42, -43, 44, 45, 2147483647, -2147483648}]"; QList<uint> uints; - QTest::newRow("emptyuintlist") << qVariantFromValue(uints) << "au" << "[Argument: au {}]"; + QTest::newRow("emptyuintlist") << QVariant::fromValue(uints) << "au" << "[Argument: au {}]"; uints << uint(12) << uint(13) << uint(14) << 4294967295U; - QTest::newRow("uintlist") << qVariantFromValue(uints) << "au" << "[Argument: au {12, 13, 14, 4294967295}]"; + QTest::newRow("uintlist") << QVariant::fromValue(uints) << "au" << "[Argument: au {12, 13, 14, 4294967295}]"; QList<qlonglong> llints; - QTest::newRow("emptyllintlist") << qVariantFromValue(llints) << "ax" << "[Argument: ax {}]"; + QTest::newRow("emptyllintlist") << QVariant::fromValue(llints) << "ax" << "[Argument: ax {}]"; llints << Q_INT64_C(99) << Q_INT64_C(-100) << Q_INT64_C(-9223372036854775807)-1 << Q_INT64_C(9223372036854775807); - QTest::newRow("llintlist") << qVariantFromValue(llints) << "ax" + QTest::newRow("llintlist") << QVariant::fromValue(llints) << "ax" << "[Argument: ax {99, -100, -9223372036854775808, 9223372036854775807}]"; QList<qulonglong> ullints; - QTest::newRow("emptyullintlist") << qVariantFromValue(ullints) << "at" << "[Argument: at {}]"; + QTest::newRow("emptyullintlist") << QVariant::fromValue(ullints) << "at" << "[Argument: at {}]"; ullints << Q_UINT64_C(66) << Q_UINT64_C(67) << Q_UINT64_C(18446744073709551615); - QTest::newRow("ullintlist") << qVariantFromValue(ullints) << "at" << "[Argument: at {66, 67, 18446744073709551615}]"; + QTest::newRow("ullintlist") << QVariant::fromValue(ullints) << "at" << "[Argument: at {66, 67, 18446744073709551615}]"; QList<double> doubles; - QTest::newRow("emptydoublelist") << qVariantFromValue(doubles) << "ad" << "[Argument: ad {}]"; + QTest::newRow("emptydoublelist") << QVariant::fromValue(doubles) << "ad" << "[Argument: ad {}]"; doubles << 1.2 << 2.2 << 4.4 << -std::numeric_limits<double>::infinity() << std::numeric_limits<double>::infinity() << std::numeric_limits<double>::quiet_NaN(); - QTest::newRow("doublelist") << qVariantFromValue(doubles) << "ad" << "[Argument: ad {1.2, 2.2, 4.4, -inf, inf, nan}]"; + QTest::newRow("doublelist") << QVariant::fromValue(doubles) << "ad" << "[Argument: ad {1.2, 2.2, 4.4, -inf, inf, nan}]"; QList<QDBusObjectPath> objectPaths; - QTest::newRow("emptyobjectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {}]"; + QTest::newRow("emptyobjectpathlist") << QVariant::fromValue(objectPaths) << "ao" << "[Argument: ao {}]"; objectPaths << QDBusObjectPath("/") << QDBusObjectPath("/foo"); - QTest::newRow("objectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {[ObjectPath: /], [ObjectPath: /foo]}]"; + QTest::newRow("objectpathlist") << QVariant::fromValue(objectPaths) << "ao" << "[Argument: ao {[ObjectPath: /], [ObjectPath: /foo]}]"; if (fileDescriptorPassing) { QList<QDBusUnixFileDescriptor> fileDescriptors; - QTest::newRow("emptyfiledescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {}]"; + QTest::newRow("emptyfiledescriptorlist") << QVariant::fromValue(fileDescriptors) << "ah" << "[Argument: ah {}]"; fileDescriptors << QDBusUnixFileDescriptor(fileDescriptorForTest()) << QDBusUnixFileDescriptor(1); - QTest::newRow("filedescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {[Unix FD: valid], [Unix FD: valid]}]"; + QTest::newRow("filedescriptorlist") << QVariant::fromValue(fileDescriptors) << "ah" << "[Argument: ah {[Unix FD: valid], [Unix FD: valid]}]"; } QVariantList variants; QTest::newRow("emptyvariantlist") << QVariant(variants) << "av" << "[Argument: av {}]"; variants << QString("Hello") << QByteArray("World") << 42 << -43.0 << 44U << Q_INT64_C(-45) - << Q_UINT64_C(46) << true << qVariantFromValue(short(-47)) - << qVariantFromValue(QDBusSignature("av")) - << qVariantFromValue(QDBusVariant(qVariantFromValue(QDBusObjectPath("/")))); + << Q_UINT64_C(46) << true << QVariant::fromValue(short(-47)) + << QVariant::fromValue(QDBusSignature("av")) + << QVariant::fromValue(QDBusVariant(QVariant::fromValue(QDBusObjectPath("/")))); QTest::newRow("variantlist") << QVariant(variants) << "av" << "[Argument: av {[Variant(QString): \"Hello\"], [Variant(QByteArray): {87, 111, 114, 108, 100}], [Variant(int): 42], [Variant(double): -43], [Variant(uint): 44], [Variant(qlonglong): -45], [Variant(qulonglong): 46], [Variant(bool): true], [Variant(short): -47], [Variant: [Signature: av]], [Variant: [Variant: [ObjectPath: /]]]}]"; } @@ -328,132 +328,132 @@ void tst_QDBusMarshall::sendArrayOfArrays_data() // arrays: QList<QStringList> strings; - QTest::newRow("empty-list-of-stringlist") << qVariantFromValue(strings) << "aas" + QTest::newRow("empty-list-of-stringlist") << QVariant::fromValue(strings) << "aas" << "[Argument: aas {}]"; strings << QStringList(); - QTest::newRow("list-of-emptystringlist") << qVariantFromValue(strings) << "aas" + QTest::newRow("list-of-emptystringlist") << QVariant::fromValue(strings) << "aas" << "[Argument: aas {{}}]"; strings << (QStringList() << "hello" << "world") << (QStringList() << "hi" << "there") << (QStringList() << QString()); - QTest::newRow("stringlist") << qVariantFromValue(strings) << "aas" + QTest::newRow("stringlist") << QVariant::fromValue(strings) << "aas" << "[Argument: aas {{}, {\"hello\", \"world\"}, {\"hi\", \"there\"}, {\"\"}}]"; QList<QByteArray> bytearray; - QTest::newRow("empty-list-of-bytearray") << qVariantFromValue(bytearray) << "aay" + QTest::newRow("empty-list-of-bytearray") << QVariant::fromValue(bytearray) << "aay" << "[Argument: aay {}]"; bytearray << QByteArray(); - QTest::newRow("list-of-emptybytearray") << qVariantFromValue(bytearray) << "aay" + QTest::newRow("list-of-emptybytearray") << QVariant::fromValue(bytearray) << "aay" << "[Argument: aay {{}}]"; bytearray << "foo" << "bar" << "baz" << "" << QByteArray(); - QTest::newRow("bytearray") << qVariantFromValue(bytearray) << "aay" + QTest::newRow("bytearray") << QVariant::fromValue(bytearray) << "aay" << "[Argument: aay {{}, {102, 111, 111}, {98, 97, 114}, {98, 97, 122}, {}, {}}]"; QList<QList<bool> > bools; - QTest::newRow("empty-list-of-boollist") << qVariantFromValue(bools) << "aab" + QTest::newRow("empty-list-of-boollist") << QVariant::fromValue(bools) << "aab" << "[Argument: aab {}]"; bools << QList<bool>(); - QTest::newRow("list-of-emptyboollist") << qVariantFromValue(bools) << "aab" + QTest::newRow("list-of-emptyboollist") << QVariant::fromValue(bools) << "aab" << "[Argument: aab {[Argument: ab {}]}]"; bools << (QList<bool>() << false << true) << (QList<bool>() << false) << (QList<bool>()); - QTest::newRow("boollist") << qVariantFromValue(bools) << "aab" + QTest::newRow("boollist") << QVariant::fromValue(bools) << "aab" << "[Argument: aab {[Argument: ab {}], [Argument: ab {false, true}], [Argument: ab {false}], [Argument: ab {}]}]"; QList<QList<short> > shorts; - QTest::newRow("empty-list-of-shortlist") << qVariantFromValue(shorts) << "aan" + QTest::newRow("empty-list-of-shortlist") << QVariant::fromValue(shorts) << "aan" << "[Argument: aan {}]"; shorts << QList<short>(); - QTest::newRow("list-of-emptyshortlist") << qVariantFromValue(shorts) << "aan" + QTest::newRow("list-of-emptyshortlist") << QVariant::fromValue(shorts) << "aan" << "[Argument: aan {[Argument: an {}]}]"; shorts << (QList<short>() << 42 << -43 << 44 << 45) << (QList<short>() << -32768 << 32767) << (QList<short>()); - QTest::newRow("shortlist") << qVariantFromValue(shorts) << "aan" + QTest::newRow("shortlist") << QVariant::fromValue(shorts) << "aan" << "[Argument: aan {[Argument: an {}], [Argument: an {42, -43, 44, 45}], [Argument: an {-32768, 32767}], [Argument: an {}]}]"; QList<QList<ushort> > ushorts; - QTest::newRow("empty-list-of-ushortlist") << qVariantFromValue(ushorts) << "aaq" + QTest::newRow("empty-list-of-ushortlist") << QVariant::fromValue(ushorts) << "aaq" << "[Argument: aaq {}]"; ushorts << QList<ushort>(); - QTest::newRow("list-of-emptyushortlist") << qVariantFromValue(ushorts) << "aaq" + QTest::newRow("list-of-emptyushortlist") << QVariant::fromValue(ushorts) << "aaq" << "[Argument: aaq {[Argument: aq {}]}]"; ushorts << (QList<ushort>() << 12u << 13u << 14u << 15) << (QList<ushort>() << 65535) << (QList<ushort>()); - QTest::newRow("ushortlist") << qVariantFromValue(ushorts) << "aaq" + QTest::newRow("ushortlist") << QVariant::fromValue(ushorts) << "aaq" << "[Argument: aaq {[Argument: aq {}], [Argument: aq {12, 13, 14, 15}], [Argument: aq {65535}], [Argument: aq {}]}]"; QList<QList<int> > ints; - QTest::newRow("empty-list-of-intlist") << qVariantFromValue(ints) << "aai" + QTest::newRow("empty-list-of-intlist") << QVariant::fromValue(ints) << "aai" << "[Argument: aai {}]"; ints << QList<int>(); - QTest::newRow("list-of-emptyintlist") << qVariantFromValue(ints) << "aai" + QTest::newRow("list-of-emptyintlist") << QVariant::fromValue(ints) << "aai" << "[Argument: aai {[Argument: ai {}]}]"; ints << (QList<int>() << 42 << -43 << 44 << 45) << (QList<int>() << 2147483647 << -2147483647-1) << (QList<int>()); - QTest::newRow("intlist") << qVariantFromValue(ints) << "aai" + QTest::newRow("intlist") << QVariant::fromValue(ints) << "aai" << "[Argument: aai {[Argument: ai {}], [Argument: ai {42, -43, 44, 45}], [Argument: ai {2147483647, -2147483648}], [Argument: ai {}]}]"; QList<QList<uint> > uints; - QTest::newRow("empty-list-of-uintlist") << qVariantFromValue(uints) << "aau" + QTest::newRow("empty-list-of-uintlist") << QVariant::fromValue(uints) << "aau" << "[Argument: aau {}]"; uints << QList<uint>(); - QTest::newRow("list-of-emptyuintlist") << qVariantFromValue(uints) << "aau" + QTest::newRow("list-of-emptyuintlist") << QVariant::fromValue(uints) << "aau" << "[Argument: aau {[Argument: au {}]}]"; uints << (QList<uint>() << uint(12) << uint(13) << uint(14)) << (QList<uint>() << 4294967295U) << (QList<uint>()); - QTest::newRow("uintlist") << qVariantFromValue(uints) << "aau" + QTest::newRow("uintlist") << QVariant::fromValue(uints) << "aau" << "[Argument: aau {[Argument: au {}], [Argument: au {12, 13, 14}], [Argument: au {4294967295}], [Argument: au {}]}]"; QList<QList<qlonglong> > llints; - QTest::newRow("empty-list-of-llintlist") << qVariantFromValue(llints) << "aax" + QTest::newRow("empty-list-of-llintlist") << QVariant::fromValue(llints) << "aax" << "[Argument: aax {}]"; llints << QList<qlonglong>(); - QTest::newRow("list-of-emptyllintlist") << qVariantFromValue(llints) << "aax" + QTest::newRow("list-of-emptyllintlist") << QVariant::fromValue(llints) << "aax" << "[Argument: aax {[Argument: ax {}]}]"; llints << (QList<qlonglong>() << Q_INT64_C(99) << Q_INT64_C(-100)) << (QList<qlonglong>() << Q_INT64_C(-9223372036854775807)-1 << Q_INT64_C(9223372036854775807)) << (QList<qlonglong>()); - QTest::newRow("llintlist") << qVariantFromValue(llints) << "aax" + QTest::newRow("llintlist") << QVariant::fromValue(llints) << "aax" << "[Argument: aax {[Argument: ax {}], [Argument: ax {99, -100}], [Argument: ax {-9223372036854775808, 9223372036854775807}], [Argument: ax {}]}]"; QList<QList<qulonglong> > ullints; - QTest::newRow("empty-list-of-ullintlist") << qVariantFromValue(ullints) << "aat" + QTest::newRow("empty-list-of-ullintlist") << QVariant::fromValue(ullints) << "aat" << "[Argument: aat {}]"; ullints << QList<qulonglong>(); - QTest::newRow("list-of-emptyullintlist") << qVariantFromValue(ullints) << "aat" + QTest::newRow("list-of-emptyullintlist") << QVariant::fromValue(ullints) << "aat" << "[Argument: aat {[Argument: at {}]}]"; ullints << (QList<qulonglong>() << Q_UINT64_C(66) << Q_UINT64_C(67)) << (QList<qulonglong>() << Q_UINT64_C(18446744073709551615)) << (QList<qulonglong>()); - QTest::newRow("ullintlist") << qVariantFromValue(ullints) << "aat" + QTest::newRow("ullintlist") << QVariant::fromValue(ullints) << "aat" << "[Argument: aat {[Argument: at {}], [Argument: at {66, 67}], [Argument: at {18446744073709551615}], [Argument: at {}]}]"; QList<QList<double> > doubles; - QTest::newRow("empty-list-ofdoublelist") << qVariantFromValue(doubles) << "aad" + QTest::newRow("empty-list-ofdoublelist") << QVariant::fromValue(doubles) << "aad" << "[Argument: aad {}]"; doubles << QList<double>(); - QTest::newRow("list-of-emptydoublelist") << qVariantFromValue(doubles) << "aad" + QTest::newRow("list-of-emptydoublelist") << QVariant::fromValue(doubles) << "aad" << "[Argument: aad {[Argument: ad {}]}]"; doubles << (QList<double>() << 1.2 << 2.2 << 4.4) << (QList<double>() << -std::numeric_limits<double>::infinity() << std::numeric_limits<double>::infinity() << std::numeric_limits<double>::quiet_NaN()) << (QList<double>()); - QTest::newRow("doublelist") << qVariantFromValue(doubles) << "aad" + QTest::newRow("doublelist") << QVariant::fromValue(doubles) << "aad" << "[Argument: aad {[Argument: ad {}], [Argument: ad {1.2, 2.2, 4.4}], [Argument: ad {-inf, inf, nan}], [Argument: ad {}]}]"; QList<QVariantList> variants; - QTest::newRow("emptyvariantlist") << qVariantFromValue(variants) << "aav" + QTest::newRow("emptyvariantlist") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {}]"; variants << QVariantList(); - QTest::newRow("emptyvariantlist") << qVariantFromValue(variants) << "aav" + QTest::newRow("emptyvariantlist") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {[Argument: av {}]}]"; variants << (QVariantList() << QString("Hello") << QByteArray("World")) << (QVariantList() << 42 << -43.0 << 44U << Q_INT64_C(-45)) - << (QVariantList() << Q_UINT64_C(46) << true << qVariantFromValue(short(-47))); - QTest::newRow("variantlist") << qVariantFromValue(variants) << "aav" + << (QVariantList() << Q_UINT64_C(46) << true << QVariant::fromValue(short(-47))); + QTest::newRow("variantlist") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {[Argument: av {}], [Argument: av {[Variant(QString): \"Hello\"], [Variant(QByteArray): {87, 111, 114, 108, 100}]}], [Argument: av {[Variant(int): 42], [Variant(double): -43], [Variant(uint): 44], [Variant(qlonglong): -45]}], [Argument: av {[Variant(qulonglong): 46], [Variant(bool): true], [Variant(short): -47]}]}]"; } @@ -464,65 +464,65 @@ void tst_QDBusMarshall::sendMaps_data() QTest::addColumn<QString>("stringResult"); QMap<int, QString> ismap; - QTest::newRow("empty-is-map") << qVariantFromValue(ismap) << "a{is}" + QTest::newRow("empty-is-map") << QVariant::fromValue(ismap) << "a{is}" << "[Argument: a{is} {}]"; ismap[1] = "a"; ismap[2000] = "b"; ismap[-47] = "c"; - QTest::newRow("is-map") << qVariantFromValue(ismap) << "a{is}" + QTest::newRow("is-map") << QVariant::fromValue(ismap) << "a{is}" << "[Argument: a{is} {-47 = \"c\", 1 = \"a\", 2000 = \"b\"}]"; QMap<QString, QString> ssmap; - QTest::newRow("empty-ss-map") << qVariantFromValue(ssmap) << "a{ss}" + QTest::newRow("empty-ss-map") << QVariant::fromValue(ssmap) << "a{ss}" << "[Argument: a{ss} {}]"; ssmap["a"] = "a"; ssmap["c"] = "b"; ssmap["b"] = "c"; - QTest::newRow("ss-map") << qVariantFromValue(ssmap) << "a{ss}" + QTest::newRow("ss-map") << QVariant::fromValue(ssmap) << "a{ss}" << "[Argument: a{ss} {\"a\" = \"a\", \"b\" = \"c\", \"c\" = \"b\"}]"; QVariantMap svmap; - QTest::newRow("empty-sv-map") << qVariantFromValue(svmap) << "a{sv}" + QTest::newRow("empty-sv-map") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {}]"; svmap["a"] = 1; svmap["c"] = "b"; svmap["b"] = QByteArray("c"); svmap["d"] = 42U; - svmap["e"] = qVariantFromValue(short(-47)); - svmap["f"] = qVariantFromValue(QDBusVariant(0)); - QTest::newRow("sv-map1") << qVariantFromValue(svmap) << "a{sv}" + svmap["e"] = QVariant::fromValue(short(-47)); + svmap["f"] = QVariant::fromValue(QDBusVariant(0)); + QTest::newRow("sv-map1") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]]}]"; QMap<QDBusObjectPath, QString> osmap; - QTest::newRow("empty-os-map") << qVariantFromValue(osmap) << "a{os}" + QTest::newRow("empty-os-map") << QVariant::fromValue(osmap) << "a{os}" << "[Argument: a{os} {}]"; osmap[QDBusObjectPath("/")] = "root"; osmap[QDBusObjectPath("/foo")] = "foo"; osmap[QDBusObjectPath("/bar/baz")] = "bar and baz"; - QTest::newRow("os-map") << qVariantFromValue(osmap) << "a{os}" + QTest::newRow("os-map") << QVariant::fromValue(osmap) << "a{os}" << "[Argument: a{os} {[ObjectPath: /] = \"root\", [ObjectPath: /bar/baz] = \"bar and baz\", [ObjectPath: /foo] = \"foo\"}]"; QMap<QDBusSignature, QString> gsmap; - QTest::newRow("empty-gs-map") << qVariantFromValue(gsmap) << "a{gs}" + QTest::newRow("empty-gs-map") << QVariant::fromValue(gsmap) << "a{gs}" << "[Argument: a{gs} {}]"; gsmap[QDBusSignature("i")] = "int32"; gsmap[QDBusSignature("s")] = "string"; gsmap[QDBusSignature("a{gs}")] = "array of dict_entry of (signature, string)"; - QTest::newRow("gs-map") << qVariantFromValue(gsmap) << "a{gs}" + QTest::newRow("gs-map") << QVariant::fromValue(gsmap) << "a{gs}" << "[Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]"; if (fileDescriptorPassing) { - svmap["zzfiledescriptor"] = qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())); - QTest::newRow("sv-map1-fd") << qVariantFromValue(svmap) << "a{sv}" + svmap["zzfiledescriptor"] = QVariant::fromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())); + QTest::newRow("sv-map1-fd") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]], \"zzfiledescriptor\" = [Variant(QDBusUnixFileDescriptor): [Unix FD: valid]]}]"; } svmap.clear(); - svmap["ismap"] = qVariantFromValue(ismap); - svmap["ssmap"] = qVariantFromValue(ssmap); - svmap["osmap"] = qVariantFromValue(osmap); - svmap["gsmap"] = qVariantFromValue(gsmap); - QTest::newRow("sv-map2") << qVariantFromValue(svmap) << "a{sv}" + svmap["ismap"] = QVariant::fromValue(ismap); + svmap["ssmap"] = QVariant::fromValue(ssmap); + svmap["osmap"] = QVariant::fromValue(osmap); + svmap["gsmap"] = QVariant::fromValue(gsmap); + QTest::newRow("sv-map2") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"gsmap\" = [Variant: [Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]], \"ismap\" = [Variant: [Argument: a{is} {-47 = \"c\", 1 = \"a\", 2000 = \"b\"}]], \"osmap\" = [Variant: [Argument: a{os} {[ObjectPath: /] = \"root\", [ObjectPath: /bar/baz] = \"bar and baz\", [ObjectPath: /foo] = \"foo\"}]], \"ssmap\" = [Variant: [Argument: a{ss} {\"a\" = \"a\", \"b\" = \"c\", \"c\" = \"b\"}]]}]"; } @@ -554,33 +554,33 @@ void tst_QDBusMarshall::sendStructs_data() << "[Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 12, 25, 0, 0], 0]"; MyStruct ms = { 1, "Hello, World" }; - QTest::newRow("int-string") << qVariantFromValue(ms) << "(is)" << "[Argument: (is) 1, \"Hello, World\"]"; + QTest::newRow("int-string") << QVariant::fromValue(ms) << "(is)" << "[Argument: (is) 1, \"Hello, World\"]"; MyVariantMapStruct mvms = { "Hello, World", QVariantMap() }; - QTest::newRow("string-variantmap") << qVariantFromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {}]]"; + QTest::newRow("string-variantmap") << QVariant::fromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {}]]"; // use only basic types, otherwise comparison will fail mvms.map["int"] = 42; mvms.map["uint"] = 42u; - mvms.map["short"] = qVariantFromValue<short>(-47); + mvms.map["short"] = QVariant::fromValue<short>(-47); mvms.map["bytearray"] = QByteArray("Hello, world"); - QTest::newRow("string-variantmap2") << qVariantFromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]"; + QTest::newRow("string-variantmap2") << QVariant::fromValue(mvms) << "(sa{sv})" << "[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]"; QList<MyVariantMapStruct> list; - QTest::newRow("empty-list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {}]"; + QTest::newRow("empty-list-of-string-variantmap") << QVariant::fromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {}]"; list << mvms; - QTest::newRow("list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]}]"; + QTest::newRow("list-of-string-variantmap") << QVariant::fromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]}]"; if (fileDescriptorPassing) { MyFileDescriptorStruct fds; fds.fd = QDBusUnixFileDescriptor(fileDescriptorForTest()); - QTest::newRow("fdstruct") << qVariantFromValue(fds) << "(h)" << "[Argument: (h) [Unix FD: valid]]"; + QTest::newRow("fdstruct") << QVariant::fromValue(fds) << "(h)" << "[Argument: (h) [Unix FD: valid]]"; QList<MyFileDescriptorStruct> fdlist; - QTest::newRow("empty-list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {}]"; + QTest::newRow("empty-list-of-fdstruct") << QVariant::fromValue(fdlist) << "a(h)" << "[Argument: a(h) {}]"; fdlist << fds; - QTest::newRow("list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {[Argument: (h) [Unix FD: valid]]}]"; + QTest::newRow("list-of-fdstruct") << QVariant::fromValue(fdlist) << "a(h)" << "[Argument: a(h) {[Argument: (h) [Unix FD: valid]]}]"; } } @@ -591,23 +591,23 @@ void tst_QDBusMarshall::sendComplex_data() QTest::addColumn<QString>("stringResult"); QList<QDateTime> dtlist; - QTest::newRow("empty-datetimelist") << qVariantFromValue(dtlist) << "a((iii)(iiii)i)" + QTest::newRow("empty-datetimelist") << QVariant::fromValue(dtlist) << "a((iii)(iiii)i)" << "[Argument: a((iii)(iiii)i) {}]"; dtlist << QDateTime(); - QTest::newRow("list-of-emptydatetime") << qVariantFromValue(dtlist) << "a((iii)(iiii)i)" + QTest::newRow("list-of-emptydatetime") << QVariant::fromValue(dtlist) << "a((iii)(iiii)i)" << "[Argument: a((iii)(iiii)i) {[Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0]}]"; dtlist << QDateTime(QDate(1977, 9, 13), QTime(0, 0, 0)) << QDateTime(QDate(2006, 6, 18), QTime(13, 14, 0)); - QTest::newRow("datetimelist") << qVariantFromValue(dtlist) << "a((iii)(iiii)i)" + QTest::newRow("datetimelist") << QVariant::fromValue(dtlist) << "a((iii)(iiii)i)" << "[Argument: a((iii)(iiii)i) {[Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 1977, 9, 13], [Argument: (iiii) 0, 0, 0, 0], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 13, 14, 0, 0], 0]}]"; QMap<qlonglong, QDateTime> lldtmap; - QTest::newRow("empty-lldtmap") << qVariantFromValue(lldtmap) << "a{x((iii)(iiii)i)}" + QTest::newRow("empty-lldtmap") << QVariant::fromValue(lldtmap) << "a{x((iii)(iiii)i)}" << "[Argument: a{x((iii)(iiii)i)} {}]"; lldtmap[0] = QDateTime(); lldtmap[1] = QDateTime(QDate(1970, 1, 1), QTime(0, 0, 1), Qt::UTC); lldtmap[1150629776] = QDateTime(QDate(2006, 6, 18), QTime(11, 22, 56), Qt::UTC); - QTest::newRow("lldtmap") << qVariantFromValue(lldtmap) << "a{x((iii)(iiii)i)}" + QTest::newRow("lldtmap") << QVariant::fromValue(lldtmap) << "a{x((iii)(iiii)i)}" << "[Argument: a{x((iii)(iiii)i)} {0 = [Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], 1 = [Argument: ((iii)(iiii)i) [Argument: (iii) 1970, 1, 1], [Argument: (iiii) 0, 0, 1, 0], 1], 1150629776 = [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 11, 22, 56, 0], 1]}]"; @@ -631,18 +631,18 @@ void tst_QDBusMarshall::sendComplex_data() svmap["c"] = "b"; svmap["b"] = QByteArray("c"); svmap["d"] = 42U; - svmap["e"] = qVariantFromValue(short(-47)); - svmap["f"] = qVariantFromValue(QDBusVariant(0)); + svmap["e"] = QVariant::fromValue(short(-47)); + svmap["f"] = QVariant::fromValue(QDBusVariant(0)); svmap["date"] = QDate(1977, 1, 1); svmap["time"] = QTime(8, 58, 0); svmap["datetime"] = QDateTime(QDate(13, 9, 2008), QTime(8, 59, 31)); svmap["pointf"] = QPointF(0.5, -0.5); - svmap["ismap"] = qVariantFromValue(ismap); - svmap["ssmap"] = qVariantFromValue(ssmap); - svmap["gsmap"] = qVariantFromValue(gsmap); - svmap["dtlist"] = qVariantFromValue(dtlist); - svmap["lldtmap"] = qVariantFromValue(lldtmap); - QTest::newRow("sv-map") << qVariantFromValue(svmap) << "a{sv}" + svmap["ismap"] = QVariant::fromValue(ismap); + svmap["ssmap"] = QVariant::fromValue(ssmap); + svmap["gsmap"] = QVariant::fromValue(gsmap); + svmap["dtlist"] = QVariant::fromValue(dtlist); + svmap["lldtmap"] = QVariant::fromValue(lldtmap); + QTest::newRow("sv-map") << QVariant::fromValue(svmap) << "a{sv}" << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"date\" = [Variant: [Argument: (iii) 1977, 1, 1]], \"datetime\" = [Variant: [Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) 8, 59, 31, 0], 0]], \"dtlist\" = [Variant: [Argument: a((iii)(iiii)i) {[Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 1977, 9, 13], [Argument: (iiii) 0, 0, 0, 0], 0], [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 13, 14, 0, 0], 0]}]], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]], \"gsmap\" = [Variant: [Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]], \"ismap\" = [Variant: [Argument: a{is} {-47 = \"c\", 1 = \"a\", 2000 = \"b\"}]], \"lldtmap\" = [Variant: [Argument: a{x((iii)(iiii)i)} {0 = [Argument: ((iii)(iiii)i) [Argument: (iii) 0, 0, 0], [Argument: (iiii) -1, -1, -1, -1], 0], 1 = [Argument: ((iii)(iiii)i) [Argument: (iii) 1970, 1, 1], [Argument: (iiii) 0, 0, 1, 0], 1], 1150629776 = [Argument: ((iii)(iiii)i) [Argument: (iii) 2006, 6, 18], [Argument: (iiii) 11, 22, 56, 0], 1]}]], \"pointf\" = [Variant: [Argument: (dd) 0.5, -0.5]], \"ssmap\" = [Variant: [Argument: a{ss} {\"a\" = \"a\", \"b\" = \"c\", \"c\" = \"b\"}]], \"time\" = [Variant: [Argument: (iiii) 8, 58, 0, 0]]}]"; } @@ -657,83 +657,83 @@ void tst_QDBusMarshall::sendArgument_data() arg = QDBusArgument(); arg << true; - QTest::newRow("bool") << qVariantFromValue(arg) << "b" << int(QDBusArgument::BasicType);; + QTest::newRow("bool") << QVariant::fromValue(arg) << "b" << int(QDBusArgument::BasicType);; arg = QDBusArgument(); arg << false; - QTest::newRow("bool2") << qVariantFromValue(arg) << "b" << int(QDBusArgument::BasicType); + QTest::newRow("bool2") << QVariant::fromValue(arg) << "b" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << uchar(1); - QTest::newRow("byte") << qVariantFromValue(arg) << "y" << int(QDBusArgument::BasicType); + QTest::newRow("byte") << QVariant::fromValue(arg) << "y" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << short(2); - QTest::newRow("int16") << qVariantFromValue(arg) << "n" << int(QDBusArgument::BasicType); + QTest::newRow("int16") << QVariant::fromValue(arg) << "n" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << ushort(3); - QTest::newRow("uint16") << qVariantFromValue(arg) << "q" << int(QDBusArgument::BasicType); + QTest::newRow("uint16") << QVariant::fromValue(arg) << "q" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << 1; - QTest::newRow("int32") << qVariantFromValue(arg) << "i" << int(QDBusArgument::BasicType); + QTest::newRow("int32") << QVariant::fromValue(arg) << "i" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << 2U; - QTest::newRow("uint32") << qVariantFromValue(arg) << "u" << int(QDBusArgument::BasicType); + QTest::newRow("uint32") << QVariant::fromValue(arg) << "u" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << Q_INT64_C(3); - QTest::newRow("int64") << qVariantFromValue(arg) << "x" << int(QDBusArgument::BasicType); + QTest::newRow("int64") << QVariant::fromValue(arg) << "x" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << Q_UINT64_C(4); - QTest::newRow("uint64") << qVariantFromValue(arg) << "t" << int(QDBusArgument::BasicType); + QTest::newRow("uint64") << QVariant::fromValue(arg) << "t" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << 42.5; - QTest::newRow("double") << qVariantFromValue(arg) << "d" << int(QDBusArgument::BasicType); + QTest::newRow("double") << QVariant::fromValue(arg) << "d" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QLatin1String("ping"); - QTest::newRow("string") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType); + QTest::newRow("string") << QVariant::fromValue(arg) << "s" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QDBusObjectPath("/org/kde"); - QTest::newRow("objectpath") << qVariantFromValue(arg) << "o" << int(QDBusArgument::BasicType); + QTest::newRow("objectpath") << QVariant::fromValue(arg) << "o" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QDBusSignature("g"); - QTest::newRow("signature") << qVariantFromValue(arg) << "g" << int(QDBusArgument::BasicType); + QTest::newRow("signature") << QVariant::fromValue(arg) << "g" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QLatin1String(""); - QTest::newRow("emptystring") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType); + QTest::newRow("emptystring") << QVariant::fromValue(arg) << "s" << int(QDBusArgument::BasicType); arg = QDBusArgument(); arg << QString(); - QTest::newRow("nullstring") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType); + QTest::newRow("nullstring") << QVariant::fromValue(arg) << "s" << int(QDBusArgument::BasicType); if (fileDescriptorPassing) { arg = QDBusArgument(); arg << QDBusUnixFileDescriptor(fileDescriptorForTest()); - QTest::newRow("filedescriptor") << qVariantFromValue(arg) << "h" << int(QDBusArgument::BasicType); + QTest::newRow("filedescriptor") << QVariant::fromValue(arg) << "h" << int(QDBusArgument::BasicType); } arg = QDBusArgument(); arg << QDBusVariant(1); - QTest::newRow("variant") << qVariantFromValue(arg) << "v" << int(QDBusArgument::VariantType); + QTest::newRow("variant") << QVariant::fromValue(arg) << "v" << int(QDBusArgument::VariantType); arg = QDBusArgument(); - arg << QDBusVariant(qVariantFromValue(QDBusVariant(1))); - QTest::newRow("variant-variant") << qVariantFromValue(arg) << "v" << int(QDBusArgument::VariantType); + arg << QDBusVariant(QVariant::fromValue(QDBusVariant(1))); + QTest::newRow("variant-variant") << QVariant::fromValue(arg) << "v" << int(QDBusArgument::VariantType); arg = QDBusArgument(); arg.beginArray(QVariant::Int); arg << 1 << 2 << 3 << -4; arg.endArray(); - QTest::newRow("array-of-int") << qVariantFromValue(arg) << "ai" << int(QDBusArgument::ArrayType); + QTest::newRow("array-of-int") << QVariant::fromValue(arg) << "ai" << int(QDBusArgument::ArrayType); arg = QDBusArgument(); arg.beginMap(QVariant::Int, QVariant::UInt); @@ -744,13 +744,13 @@ void tst_QDBusMarshall::sendArgument_data() arg << 3 << 4U; arg.endMapEntry(); arg.endMap(); - QTest::newRow("map") << qVariantFromValue(arg) << "a{iu}" << int(QDBusArgument::MapType); + QTest::newRow("map") << QVariant::fromValue(arg) << "a{iu}" << int(QDBusArgument::MapType); arg = QDBusArgument(); arg.beginStructure(); arg << 1 << 2U << short(-3) << ushort(4) << 5.0 << false; arg.endStructure(); - QTest::newRow("structure") << qVariantFromValue(arg) << "(iunqdb)" << int(QDBusArgument::StructureType); + QTest::newRow("structure") << QVariant::fromValue(arg) << "(iunqdb)" << int(QDBusArgument::StructureType); } void tst_QDBusMarshall::sendBasic() @@ -790,7 +790,7 @@ void tst_QDBusMarshall::sendVariant() QDBusMessage msg = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "ping"); - msg << qVariantFromValue(QDBusVariant(value)); + msg << QVariant::fromValue(QDBusVariant(value)); QDBusMessage reply = con.call(msg); // qDebug() << reply; @@ -851,7 +851,7 @@ void tst_QDBusMarshall::sendArgument() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); reply = con.call(msg); QCOMPARE(reply.signature(), QString("(%1)").arg(sig)); @@ -883,7 +883,7 @@ void tst_QDBusMarshall::sendSignalErrors() QVERIFY(con.isConnected()); QDBusMessage msg = QDBusMessage::createSignal("/foo", "local.interfaceName", "signalName"); - msg << qVariantFromValue(QDBusObjectPath()); + msg << QVariant::fromValue(QDBusObjectPath()); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); QVERIFY(!con.send(msg)); @@ -893,20 +893,20 @@ void tst_QDBusMarshall::sendSignalErrors() QTest::ignoreMessage(QtWarningMsg, "QDBusObjectPath: invalid path \"abc\""); path.setPath("abc"); - msg << qVariantFromValue(path); + msg << QVariant::fromValue(path); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); QVERIFY(!con.send(msg)); QDBusSignature sig; - msg.setArguments(QVariantList() << qVariantFromValue(sig)); + msg.setArguments(QVariantList() << QVariant::fromValue(sig)); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); QVERIFY(!con.send(msg)); QTest::ignoreMessage(QtWarningMsg, "QDBusSignature: invalid signature \"a\""); sig.setSignature("a"); msg.setArguments(QVariantList()); - msg << qVariantFromValue(sig); + msg << QVariant::fromValue(sig); QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); QVERIFY(!con.send(msg)); } @@ -956,7 +956,7 @@ void tst_QDBusMarshall::sendCallErrors_data() << "Marshalling failed: Variant containing QVariant::Invalid passed in arguments" << "QDBusMarshaller: cannot add an invalid QVariant"; QTest::newRow("invalid-variant1") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusVariant())) + << (QVariantList() << QVariant::fromValue(QDBusVariant())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Variant containing QVariant::Invalid passed in arguments" << "QDBusMarshaller: cannot add a null QDBusVariant"; @@ -970,20 +970,20 @@ void tst_QDBusMarshall::sendCallErrors_data() // this type is known to the meta type system, but not registered with D-Bus qRegisterMetaType<UnregisteredType>(); QTest::newRow("extra-unregistered") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(UnregisteredType())) + << (QVariantList() << QVariant::fromValue(UnregisteredType())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Unregistered type UnregisteredType passed in arguments" << QString("QDBusMarshaller: type `UnregisteredType' (%1) is not registered with D-BUS. Use qDBusRegisterMetaType to register it") .arg(qMetaTypeId<UnregisteredType>()); QTest::newRow("invalid-object-path-arg") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusObjectPath())) + << (QVariantList() << QVariant::fromValue(QDBusObjectPath())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid object path passed in arguments" << ""; QTest::newRow("invalid-signature-arg") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusSignature())) + << (QVariantList() << QVariant::fromValue(QDBusSignature())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid signature passed in arguments" << ""; @@ -991,7 +991,7 @@ void tst_QDBusMarshall::sendCallErrors_data() // invalid file descriptor if (fileDescriptorPassing) { QTest::newRow("invalid-file-descriptor") << serviceName << objectPath << interfaceName << "ping" - << (QVariantList() << qVariantFromValue(QDBusUnixFileDescriptor(-1))) + << (QVariantList() << QVariant::fromValue(QDBusUnixFileDescriptor(-1))) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid file descriptor passed in arguments" << ""; @@ -1200,7 +1200,7 @@ QVariant demarshallPrimitiveAs(const QDBusArgument& dbusArg) { T val; dbusArg >> val; - return qVariantFromValue(val); + return QVariant::fromValue(val); } QVariant demarshallPrimitiveAs(int typeIndex, const QDBusArgument& dbusArg) @@ -1247,7 +1247,7 @@ void tst_QDBusMarshall::demarshallPrimitives() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast<QDBusArgument>(reply.arguments().at(0)); @@ -1279,15 +1279,15 @@ void tst_QDBusMarshall::demarshallStrings_data() typedef QPair<QVariant, char> ValSigPair; const QList<ValSigPair> nullStringTypes = QList<ValSigPair>() - << ValSigPair(qVariantFromValue(QString()), 's') - << ValSigPair(qVariantFromValue(QDBusObjectPath()), 'o') - << ValSigPair(qVariantFromValue(QDBusSignature()), 'g'); + << ValSigPair(QVariant::fromValue(QString()), 's') + << ValSigPair(QVariant::fromValue(QDBusObjectPath()), 'o') + << ValSigPair(QVariant::fromValue(QDBusSignature()), 'g'); foreach (ValSigPair valSigPair, nullStringTypes) { QTest::newRow("bool(false)") << QVariant(false) << valSigPair.second << valSigPair.first; QTest::newRow("bool(true)") << QVariant(true) << valSigPair.second << valSigPair.first; - QTest::newRow("byte") << qVariantFromValue(uchar(1)) << valSigPair.second << valSigPair.first; - QTest::newRow("int16") << qVariantFromValue(short(2)) << valSigPair.second << valSigPair.first; - QTest::newRow("uint16") << qVariantFromValue(ushort(3)) << valSigPair.second << valSigPair.first; + QTest::newRow("byte") << QVariant::fromValue(uchar(1)) << valSigPair.second << valSigPair.first; + QTest::newRow("int16") << QVariant::fromValue(short(2)) << valSigPair.second << valSigPair.first; + QTest::newRow("uint16") << QVariant::fromValue(ushort(3)) << valSigPair.second << valSigPair.first; QTest::newRow("int") << QVariant(1) << valSigPair.second << valSigPair.first; QTest::newRow("uint") << QVariant(2U) << valSigPair.second << valSigPair.first; QTest::newRow("int64") << QVariant(Q_INT64_C(3)) << valSigPair.second << valSigPair.first; @@ -1299,32 +1299,32 @@ void tst_QDBusMarshall::demarshallStrings_data() // to check released functionality is maintained even after checks have // been added to string demarshalling QTest::newRow("empty string->invalid objectpath") << QVariant("") - << 'o' << qVariantFromValue(QDBusObjectPath()); + << 'o' << QVariant::fromValue(QDBusObjectPath()); QTest::newRow("null string->invalid objectpath") << QVariant(QString()) - << 'o' << qVariantFromValue(QDBusObjectPath()); + << 'o' << QVariant::fromValue(QDBusObjectPath()); QTest::newRow("string->invalid objectpath") << QVariant("invalid objectpath") - << 'o' << qVariantFromValue(QDBusObjectPath()); + << 'o' << QVariant::fromValue(QDBusObjectPath()); QTest::newRow("string->valid objectpath") << QVariant("/org/kde") - << 'o' << qVariantFromValue(QDBusObjectPath("/org/kde")); + << 'o' << QVariant::fromValue(QDBusObjectPath("/org/kde")); QTest::newRow("empty string->invalid signature") << QVariant("") - << 'g' << qVariantFromValue(QDBusSignature()); + << 'g' << QVariant::fromValue(QDBusSignature()); QTest::newRow("null string->invalid signature") << QVariant(QString()) - << 'g' << qVariantFromValue(QDBusSignature()); + << 'g' << QVariant::fromValue(QDBusSignature()); QTest::newRow("string->invalid signature") << QVariant("_invalid signature") - << 'g' << qVariantFromValue(QDBusSignature()); + << 'g' << QVariant::fromValue(QDBusSignature()); QTest::newRow("string->valid signature") << QVariant("s") - << 'g' << qVariantFromValue(QDBusSignature("s")); + << 'g' << QVariant::fromValue(QDBusSignature("s")); - QTest::newRow("objectpath->string") << qVariantFromValue(QDBusObjectPath("/org/kde")) - << 's' << qVariantFromValue(QString("/org/kde")); - QTest::newRow("objectpath->invalid signature") << qVariantFromValue(QDBusObjectPath("/org/kde")) - << 'g' << qVariantFromValue(QDBusSignature()); + QTest::newRow("objectpath->string") << QVariant::fromValue(QDBusObjectPath("/org/kde")) + << 's' << QVariant::fromValue(QString("/org/kde")); + QTest::newRow("objectpath->invalid signature") << QVariant::fromValue(QDBusObjectPath("/org/kde")) + << 'g' << QVariant::fromValue(QDBusSignature()); - QTest::newRow("signature->string") << qVariantFromValue(QDBusSignature("s")) - << 's' << qVariantFromValue(QString("s")); - QTest::newRow("signature->invalid objectpath") << qVariantFromValue(QDBusSignature("s")) - << 'o' << qVariantFromValue(QDBusObjectPath()); + QTest::newRow("signature->string") << QVariant::fromValue(QDBusSignature("s")) + << 's' << QVariant::fromValue(QString("s")); + QTest::newRow("signature->invalid objectpath") << QVariant::fromValue(QDBusSignature("s")) + << 'o' << QVariant::fromValue(QDBusObjectPath()); } QVariant demarshallAsString(const QDBusArgument& dbusArg, char targetSig) @@ -1338,12 +1338,12 @@ QVariant demarshallAsString(const QDBusArgument& dbusArg, char targetSig) case 'o': { QDBusObjectPath op; dbusArg >> op; - return qVariantFromValue(op); + return QVariant::fromValue(op); } case 'g' : { QDBusSignature sig; dbusArg >> sig; - return qVariantFromValue(sig); + return QVariant::fromValue(sig); } default: { return QVariant(); @@ -1367,7 +1367,7 @@ void tst_QDBusMarshall::demarshallStrings() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast<QDBusArgument>(reply.arguments().at(0)); @@ -1391,15 +1391,15 @@ void tst_QDBusMarshall::demarshallInvalidStringList_data() // Arrays of non-string type should not demarshall to a string list QList<bool> bools; - QTest::newRow("emptyboollist") << qVariantFromValue(bools); + QTest::newRow("emptyboollist") << QVariant::fromValue(bools); bools << false << true << false; - QTest::newRow("boollist") << qVariantFromValue(bools); + QTest::newRow("boollist") << QVariant::fromValue(bools); // Structures should not demarshall to a QByteArray QTest::newRow("struct of strings") - << qVariantFromValue(QVariantList() << QString("foo") << QString("bar")); + << QVariant::fromValue(QVariantList() << QString("foo") << QString("bar")); QTest::newRow("struct of mixed types") - << qVariantFromValue(QVariantList() << QString("foo") << int(42) << double(3.14)); + << QVariant::fromValue(QVariantList() << QString("foo") << int(42) << double(3.14)); } void tst_QDBusMarshall::demarshallInvalidStringList() @@ -1416,7 +1416,7 @@ void tst_QDBusMarshall::demarshallInvalidStringList() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast<QDBusArgument>(reply.arguments().at(0)); @@ -1440,16 +1440,16 @@ void tst_QDBusMarshall::demarshallInvalidByteArray_data() // Arrays of other types than byte should not demarshall to a QByteArray QList<bool> bools; - QTest::newRow("empty array of bool") << qVariantFromValue(bools); + QTest::newRow("empty array of bool") << QVariant::fromValue(bools); bools << true << false << true; - QTest::newRow("non-empty array of bool") << qVariantFromValue(bools); + QTest::newRow("non-empty array of bool") << QVariant::fromValue(bools); // Structures should not demarshall to a QByteArray QTest::newRow("struct of bytes") - << qVariantFromValue(QVariantList() << uchar(1) << uchar(2)); + << QVariant::fromValue(QVariantList() << uchar(1) << uchar(2)); QTest::newRow("struct of mixed types") - << qVariantFromValue(QVariantList() << int(42) << QString("foo") << double(3.14)); + << QVariant::fromValue(QVariantList() << int(42) << QString("foo") << double(3.14)); } void tst_QDBusMarshall::demarshallInvalidByteArray() @@ -1466,7 +1466,7 @@ void tst_QDBusMarshall::demarshallInvalidByteArray() sendArg.beginStructure(); sendArg.appendVariant(value); sendArg.endStructure(); - msg.setArguments(QVariantList() << qVariantFromValue(sendArg)); + msg.setArguments(QVariantList() << QVariant::fromValue(sendArg)); QDBusMessage reply = con.call(msg); const QDBusArgument receiveArg = qvariant_cast<QDBusArgument>(reply.arguments().at(0)); diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index c5c2b13b3e..65571f13c2 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -88,9 +88,7 @@ private slots: void dotsPerMeterZero(); void convertToFormatPreserveDotsPrMeter(); -#ifndef QT_NO_IMAGE_TEXT void convertToFormatPreserveText(); -#endif void rotate_data(); void rotate(); @@ -1143,7 +1141,6 @@ void tst_QImage::convertToFormatPreserveDotsPrMeter() QCOMPARE(img.dotsPerMeterY(), dpmy); } -#ifndef QT_NO_IMAGE_TEXT void tst_QImage::convertToFormatPreserveText() { QImage img(100, 100, QImage::Format_ARGB32_Premultiplied); @@ -1168,7 +1165,6 @@ void tst_QImage::convertToFormatPreserveText() QCOMPARE(imgResult2.text(), result); QCOMPARE(imgResult2.textKeys(), listResult); } -#endif // QT_NO_IMAGE_TEXT void tst_QImage::setColorCount() { diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 876d69ea1c..12c90445cb 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1487,7 +1487,8 @@ void tst_QImageReader::supportsOption_data() << (QIntList() << QImageIOHandler::Gamma << QImageIOHandler::Description << QImageIOHandler::Quality - << QImageIOHandler::Size); + << QImageIOHandler::Size + << QImageIOHandler::ScaledSize); } void tst_QImageReader::supportsOption() diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index 827fa3606c..f28f84dc60 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -394,7 +394,8 @@ void tst_QImageWriter::supportsOption_data() << (QIntList() << QImageIOHandler::Gamma << QImageIOHandler::Description << QImageIOHandler::Quality - << QImageIOHandler::Size); + << QImageIOHandler::Size + << QImageIOHandler::ScaledSize); } void tst_QImageWriter::supportsOption() diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 0bd988b68c..8f191bd42d 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -7,6 +7,7 @@ SUBDIRS=\ qfileopenevent \ qguieventdispatcher \ qguimetatype \ + qguitimer \ qguivariant \ qinputmethod \ qkeysequence \ diff --git a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro index cc0a2c69f7..211be4c1c0 100644 --- a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro +++ b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro @@ -4,6 +4,3 @@ TARGET = tst_qbackingstore QT += core-private gui-private testlib SOURCES += tst_qbackingstore.cpp - -mac: CONFIG += insignificant_test # QTBUG-23059 -win32: CONFIG += insignificant_test # QTBUG-24885 diff --git a/tests/auto/gui/kernel/qclipboard/test/test.pro b/tests/auto/gui/kernel/qclipboard/test/test.pro index 4be6769592..d7a67ae3b6 100644 --- a/tests/auto/gui/kernel/qclipboard/test/test.pro +++ b/tests/auto/gui/kernel/qclipboard/test/test.pro @@ -15,8 +15,6 @@ wince* { DEPLOYMENT += rsc reg_resource } -mac: CONFIG += insignificant_test # QTBUG-23057 - load(testcase) # for target.path and installTestHelperApp() installTestHelperApp("../copier/copier",copier,copier) installTestHelperApp("../paster/paster",paster,paster) diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 7f41f0651e..466764f81e 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -158,7 +158,7 @@ void tst_QClipboard::testSignals() QCOMPARE(selectionChangedSpy.count(), 0); QCOMPARE(changedSpy.count(), 1); QCOMPARE(changedSpy.at(0).count(), 1); - QCOMPARE(qVariantValue<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Clipboard); + QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Clipboard); changedSpy.clear(); @@ -168,7 +168,7 @@ void tst_QClipboard::testSignals() QCOMPARE(selectionChangedSpy.count(), 1); QCOMPARE(changedSpy.count(), 1); QCOMPARE(changedSpy.at(0).count(), 1); - QCOMPARE(qVariantValue<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Selection); + QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Selection); } else { QCOMPARE(selectionChangedSpy.count(), 0); } @@ -183,7 +183,7 @@ void tst_QClipboard::testSignals() QCOMPARE(searchChangedSpy.count(), 1); QCOMPARE(changedSpy.count(), 1); QCOMPARE(changedSpy.at(0).count(), 1); - QCOMPARE(qVariantValue<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::FindBuffer); + QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::FindBuffer); } else { QCOMPARE(searchChangedSpy.count(), 0); } diff --git a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro index 777e2c6b1a..fffa097d73 100644 --- a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro +++ b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro @@ -2,5 +2,3 @@ CONFIG += testcase TARGET = tst_qguiapplication QT += core gui testlib SOURCES = tst_qguiapplication.cpp - -win32:CONFIG += insignificant_test # QTBUG-24186 diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index c0242d95c5..29b65d1fd4 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -116,6 +116,9 @@ void tst_QGuiApplication::focusObject() QTest::qWaitForWindowShown(&window2); QTRY_COMPARE(app.focusWindow(), &window2); QCOMPARE(app.focusObject(), &obj3); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24186", Abort); +#endif QCOMPARE(spy.count(), 1); // focus change on unfocused window does not show @@ -238,6 +241,9 @@ void tst_QGuiApplication::changeFocusWindow() window2.requestActivateWindow(); QTRY_COMPARE(app.focusWindow(), &window2); QCOMPARE(window1.windowDuringFocusAboutToChange, &window1); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24186", Abort); +#endif QCOMPARE(window1.windowDuringFocusOut, &window2); } diff --git a/tests/auto/gui/kernel/qguitimer/qguitimer.pro b/tests/auto/gui/kernel/qguitimer/qguitimer.pro new file mode 100644 index 0000000000..8a71e48007 --- /dev/null +++ b/tests/auto/gui/kernel/qguitimer/qguitimer.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qguitimer +QT = core gui testlib +SOURCES += ../../../corelib/kernel/qtimer/tst_qtimer.cpp diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index c4db74b6ec..588584545c 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -197,26 +197,26 @@ void tst_QKeySequence::operatorQString_data() QTest::addColumn<int>("keycode"); QTest::addColumn<QString>("keystring"); - QTest::newRow( "No modifier" ) << 0 << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString( "\x0c5" ); + QTest::newRow( "No modifier" ) << 0 << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "\x0c5" ); #ifndef Q_OS_MAC QTest::newRow( "Ctrl+Left" ) << int(Qt::CTRL) << int(Qt::Key_Left) << QString( "Ctrl+Left" ); QTest::newRow( "Ctrl+," ) << int(Qt::CTRL) << int(Qt::Key_Comma) << QString( "Ctrl+," ); QTest::newRow( "Alt+Left" ) << int(Qt::ALT) << int(Qt::Key_Left) << QString( "Alt+Left" ); QTest::newRow( "Alt+Shift+Left" ) << int(Qt::ALT | Qt::SHIFT) << int(Qt::Key_Left) << QString( "Alt+Shift+Left" ); - QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString( "Ctrl+\x0c5" ); - QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString( "Alt+\x0c5" ); - QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString( "Shift+\x0c5" ); - QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString( "Meta+\x0c5" ); + QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Ctrl+\x0c5" ); + QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Alt+\x0c5" ); + QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Shift+\x0c5" ); + QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Meta+\x0c5" ); #else QTest::newRow( "Ctrl+Left" ) << int(Qt::CTRL) << int(Qt::Key_Left) << MacCtrl + macSymbolForQtKey(Qt::Key_Left); QTest::newRow( "Ctrl+," ) << int(Qt::CTRL) << int(Qt::Key_Comma) << MacCtrl + ","; QTest::newRow( "Alt+Left" ) << int(Qt::ALT) << int(Qt::Key_Left) << MacAlt + macSymbolForQtKey(Qt::Key_Left); QTest::newRow( "Alt+Shift+Left" ) << int(Qt::ALT | Qt::SHIFT) << int(Qt::Key_Left) << MacAlt + MacShift + macSymbolForQtKey(Qt::Key_Left); - QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacCtrl + "\x0c5"; - QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacAlt + "\x0c5"; - QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacShift + "\x0c5"; - QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacMeta + "\x0c5"; + QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacCtrl + QLatin1String("\x0c5"); + QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacAlt + QLatin1String("\x0c5"); + QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacShift + QLatin1String("\x0c5"); + QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacMeta + QLatin1String("\x0c5"); #endif } @@ -448,10 +448,10 @@ void tst_QKeySequence::toString_data() QTest::newRow("Ctrl+Left") << QString("Ctrl+Left") << QString("Ctrl+Left") << QString("Ctrl+Left"); QTest::newRow("Alt+Left") << QString("Alt+Left") << QString("Alt+Left") << QString("Alt+Left"); QTest::newRow("Alt+Shift+Left") << QString("Alt+Shift+Left") << QString("Alt+Shift+Left") << QString("Alt+Shift+Left"); - QTest::newRow("Ctrl") << QString("Ctrl+\x0c5") << QString("Ctrl+\x0c5") << QString("Ctrl+\x0c5"); - QTest::newRow("Alt") << QString("Alt+\x0c5") << QString("Alt+\x0c5") << QString("Alt+\x0c5"); - QTest::newRow("Shift") << QString("Shift+\x0c5") << QString("Shift+\x0c5") << QString("Shift+\x0c5"); - QTest::newRow("Meta") << QString("Meta+\x0c5") << QString("Meta+\x0c5") << QString("Meta+\x0c5"); + QTest::newRow("Ctrl") << QString::fromLatin1("Ctrl+\x0c5") << QString::fromLatin1("Ctrl+\x0c5") << QString::fromLatin1("Ctrl+\x0c5"); + QTest::newRow("Alt") << QString::fromLatin1("Alt+\x0c5") << QString::fromLatin1("Alt+\x0c5") << QString::fromLatin1("Alt+\x0c5"); + QTest::newRow("Shift") << QString::fromLatin1("Shift+\x0c5") << QString::fromLatin1("Shift+\x0c5") << QString::fromLatin1("Shift+\x0c5"); + QTest::newRow("Meta") << QString::fromLatin1("Meta+\x0c5") << QString::fromLatin1("Meta+\x0c5") << QString::fromLatin1("Meta+\x0c5"); QTest::newRow("Ctrl+Plus") << QString("Ctrl++") << QString("Ctrl++") << QString("Ctrl++"); QTest::newRow("Ctrl+,") << QString("Ctrl+,") << QString("Ctrl+,") << QString("Ctrl+,"); QTest::newRow("Ctrl+,,Ctrl+,") << QString("Ctrl+,,Ctrl+,") << QString("Ctrl+,, Ctrl+,") << QString("Ctrl+,, Ctrl+,"); @@ -467,10 +467,10 @@ void tst_QKeySequence::toString_data() << MacAlt + MacShift + macSymbolForQtKey(Qt::Key_Left); */ QTest::newRow("Ctrl+Right,Left") << MacCtrl + "Right, Left" << QString("Ctrl+Right, Left") << MacCtrl + macSymbolForQtKey(Qt::Key_Right) + QString(", ") + macSymbolForQtKey(Qt::Key_Left); - QTest::newRow("Ctrl") << MacCtrl + "\x0c5" << QString("Ctrl+\x0c5") << MacCtrl + "\x0c5"; - QTest::newRow("Alt") << MacAlt + "\x0c5" << QString("Alt+\x0c5") << MacAlt + "\x0c5"; - QTest::newRow("Shift") << MacShift + "\x0c5" << QString("Shift+\x0c5") << MacShift + "\x0c5"; - QTest::newRow("Meta") << MacMeta + "\x0c5" << QString("Meta+\x0c5") << MacMeta + "\x0c5"; + QTest::newRow("Ctrl") << MacCtrl + QLatin1String("\x0c5") << QString::fromLatin1("Ctrl+\x0c5") << MacCtrl + QLatin1String("\x0c5"); + QTest::newRow("Alt") << MacAlt + QLatin1String("\x0c5") << QString::fromLatin1("Alt+\x0c5") << MacAlt + QLatin1String("\x0c5"); + QTest::newRow("Shift") << MacShift + QLatin1String("\x0c5") << QString::fromLatin1("Shift+\x0c5") << MacShift + QLatin1String("\x0c5"); + QTest::newRow("Meta") << MacMeta + QLatin1String("\x0c5") << QString::fromLatin1("Meta+\x0c5") << MacMeta + QLatin1String("\x0c5"); QTest::newRow("Ctrl+Plus") << MacCtrl + "+" << QString("Ctrl++") << MacCtrl + "+"; QTest::newRow("Ctrl+,") << MacCtrl + "," << QString("Ctrl+,") << MacCtrl + ","; QTest::newRow("Ctrl+,,Ctrl+,") << MacCtrl + ",, " + MacCtrl + "," << QString("Ctrl+,, Ctrl+,") << MacCtrl + ",, " + MacCtrl + ","; diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index fb8132afab..363f7dd92e 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -6,5 +6,4 @@ QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp mac: CONFIG += insignificant_test # QTBUG-23059 -win32: CONFIG += insignificant_test # QTBUG-24904 diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 3dc2886b80..ae5bf55b72 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -70,6 +70,7 @@ private slots: void activateAndClose(); void mouseEventSequence(); void windowModality(); + void inputReentrancy(); void initTestCase() { @@ -141,11 +142,14 @@ private: void tst_QWindow::eventOrderOnShow() { - QRect geometry(80, 80, 40, 40); + // Some platforms enforce minimum widths for windows, which can cause extra resize + // events, so set the width to suitably large value to avoid those. + QRect geometry(80, 80, 300, 40); Window window; window.setGeometry(geometry); window.show(); + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Show), 1); QTRY_COMPARE(window.received(QEvent::Resize), 1); @@ -157,12 +161,15 @@ void tst_QWindow::eventOrderOnShow() void tst_QWindow::positioning() { - QRect geometry(80, 80, 40, 40); + // Some platforms enforce minimum widths for windows, which can cause extra resize + // events, so set the width to suitably large value to avoid those. + QRect geometry(80, 80, 300, 40); Window window; window.setGeometry(geometry); QCOMPARE(window.geometry(), geometry); window.show(); + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_VERIFY(window.received(QEvent::Expose) > 0); @@ -176,12 +183,11 @@ void tst_QWindow::positioning() QPoint originalFramePos = window.framePos(); window.setWindowState(Qt::WindowFullScreen); -#ifdef Q_OS_WIN - QEXPECT_FAIL("", "QTBUG-24904 - Too many resize events on setting window state", Continue); -#endif + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 2); window.setWindowState(Qt::WindowNoState); + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 3); QTRY_COMPARE(originalPos, window.pos()); @@ -218,12 +224,14 @@ void tst_QWindow::isExposed() window.setGeometry(geometry); QCOMPARE(window.geometry(), geometry); window.show(); + QCoreApplication::processEvents(); QTRY_VERIFY(window.received(QEvent::Expose) > 0); QTRY_VERIFY(window.isExposed()); window.hide(); + QCoreApplication::processEvents(); #ifdef Q_OS_MAC QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-23059", Abort); #endif @@ -235,8 +243,11 @@ void tst_QWindow::isExposed() void tst_QWindow::isActive() { Window window; - window.setGeometry(80, 80, 40, 40); + // Some platforms enforce minimum widths for windows, which can cause extra resize + // events, so set the width to suitably large value to avoid those. + window.setGeometry(80, 80, 300, 40); window.show(); + QCoreApplication::processEvents(); QTRY_VERIFY(window.isExposed()); QTRY_COMPARE(window.received(QEvent::Resize), 1); @@ -256,6 +267,7 @@ void tst_QWindow::isActive() QVERIFY(child.isActive()); // parent shouldn't receive new resize events from child being shown + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_COMPARE(window.received(QEvent::FocusIn), 1); QTRY_COMPARE(window.received(QEvent::FocusOut), 1); @@ -266,12 +278,13 @@ void tst_QWindow::isActive() Window dialog; dialog.setTransientParent(&window); - dialog.setGeometry(110, 110, 30, 30); + dialog.setGeometry(110, 110, 300, 30); dialog.show(); dialog.requestActivateWindow(); QTRY_VERIFY(dialog.isExposed()); + QCoreApplication::processEvents(); QTRY_COMPARE(dialog.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &dialog); QVERIFY(dialog.isActive()); @@ -285,6 +298,7 @@ void tst_QWindow::isActive() window.requestActivateWindow(); QTRY_VERIFY(QGuiApplication::focusWindow() == &window); + QCoreApplication::processEvents(); QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1); QTRY_COMPARE(window.received(QEvent::FocusIn), 2); @@ -314,6 +328,8 @@ public: mouseSequenceSignature += 'p'; mousePressButton = event->button(); mousePressScreenPos = event->screenPos(); + if (spinLoopWhenPressed) + QCoreApplication::processEvents(); } } void mouseReleaseEvent(QMouseEvent *event) { @@ -329,6 +345,7 @@ public: if (ignoreMouse) { event->ignore(); } else { + ++mouseMovedCount; mouseMoveButton = event->button(); mouseMoveScreenPos = event->screenPos(); } @@ -352,6 +369,8 @@ public: switch (points.at(i).state()) { case Qt::TouchPointPressed: ++touchPressedCount; + if (spinLoopWhenPressed) + QCoreApplication::processEvents(); break; case Qt::TouchPointReleased: ++touchReleasedCount; @@ -365,7 +384,7 @@ public: } } void resetCounters() { - mousePressedCount = mouseReleasedCount = mouseDoubleClickedCount = 0; + mousePressedCount = mouseReleasedCount = mouseMovedCount = mouseDoubleClickedCount = 0; mouseSequenceSignature = QString(); touchPressedCount = touchReleasedCount = touchMovedCount = 0; } @@ -374,18 +393,21 @@ public: keyPressCode = keyReleaseCode = 0; mousePressButton = mouseReleaseButton = mouseMoveButton = 0; ignoreMouse = ignoreTouch = false; + spinLoopWhenPressed = false; resetCounters(); } int keyPressCode, keyReleaseCode; int mousePressButton, mouseReleaseButton, mouseMoveButton; - int mousePressedCount, mouseReleasedCount, mouseDoubleClickedCount; + int mousePressedCount, mouseReleasedCount, mouseMovedCount, mouseDoubleClickedCount; QString mouseSequenceSignature; QPointF mousePressScreenPos, mouseMoveScreenPos; int touchPressedCount, touchReleasedCount, touchMovedCount; QEvent::Type touchEventType; bool ignoreMouse, ignoreTouch; + + bool spinLoopWhenPressed; }; void tst_QWindow::testInputEvents() @@ -839,5 +861,49 @@ void tst_QWindow::windowModality() QCOMPARE(spy.count(), 3); } +void tst_QWindow::inputReentrancy() +{ + InputTestWindow window; + window.spinLoopWhenPressed = true; + + window.setGeometry(80, 80, 40, 40); + window.show(); + QTest::qWaitForWindowShown(&window); + + // Queue three events. + QPointF local(12, 34); + QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton); + local += QPointF(2, 2); + QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::NoButton); + // Process them. However, the event handler for the press will also call + // processEvents() so the move and release will be delivered before returning + // from mousePressEvent(). The point is that no events should get lost. + QCoreApplication::processEvents(); + QCOMPARE(window.mousePressButton, int(Qt::LeftButton)); + QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton)); + QCOMPARE(window.mousePressedCount, 1); + QCOMPARE(window.mouseMovedCount, 1); + QCOMPARE(window.mouseReleasedCount, 1); + + // Now the same for touch. + QList<QWindowSystemInterface::TouchPoint> points; + QWindowSystemInterface::TouchPoint tp1; + tp1.id = 1; + tp1.state = Qt::TouchPointPressed; + tp1.area = QRectF(10, 10, 4, 4); + points << tp1; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + points[0].state = Qt::TouchPointMoved; + points[0].area = QRectF(20, 20, 8, 8); + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + points[0].state = Qt::TouchPointReleased; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QCOMPARE(window.touchPressedCount, 1); + QCOMPARE(window.touchMovedCount, 1); + QCOMPARE(window.touchReleasedCount, 1); +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 698470ac60..c89d10a543 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -3358,13 +3358,13 @@ void tst_QMatrixNxN::properties() QMatrix4x4 m1(uniqueValues4); obj.setMatrix(m1); - QMatrix4x4 m2 = qVariantValue<QMatrix4x4>(obj.property("matrix")); + QMatrix4x4 m2 = qvariant_cast<QMatrix4x4>(obj.property("matrix")); QVERIFY(isSame(m2, uniqueValues4)); QMatrix4x4 m3(transposedValues4); - obj.setProperty("matrix", qVariantFromValue(m3)); + obj.setProperty("matrix", QVariant::fromValue(m3)); - m2 = qVariantValue<QMatrix4x4>(obj.property("matrix")); + m2 = qvariant_cast<QMatrix4x4>(obj.property("matrix")); QVERIFY(isSame(m2, transposedValues4)); } diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp index 1690afcac4..a4e1f940fc 100644 --- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp @@ -855,16 +855,16 @@ void tst_QQuaternion::properties() obj.setQuaternion(QQuaternion(6.0f, 7.0f, 8.0f, 9.0f)); - QQuaternion q = qVariantValue<QQuaternion>(obj.property("quaternion")); + QQuaternion q = qvariant_cast<QQuaternion>(obj.property("quaternion")); QCOMPARE(q.scalar(), (qreal)6.0f); QCOMPARE(q.x(), (qreal)7.0f); QCOMPARE(q.y(), (qreal)8.0f); QCOMPARE(q.z(), (qreal)9.0f); obj.setProperty("quaternion", - qVariantFromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f))); + QVariant::fromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f))); - q = qVariantValue<QQuaternion>(obj.property("quaternion")); + q = qvariant_cast<QQuaternion>(obj.property("quaternion")); QCOMPARE(q.scalar(), (qreal)-6.0f); QCOMPARE(q.x(), (qreal)-7.0f); QCOMPARE(q.y(), (qreal)-8.0f); diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp index 067773074e..72a4ecef97 100644 --- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp @@ -2077,38 +2077,38 @@ void tst_QVectorND::properties() obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); obj.setVector4D(QVector4D(6.0f, 7.0f, 8.0f, 9.0f)); - QVector2D v2 = qVariantValue<QVector2D>(obj.property("vector2D")); + QVector2D v2 = qvariant_cast<QVector2D>(obj.property("vector2D")); QCOMPARE(v2.x(), (qreal)1.0f); QCOMPARE(v2.y(), (qreal)2.0f); - QVector3D v3 = qVariantValue<QVector3D>(obj.property("vector3D")); + QVector3D v3 = qvariant_cast<QVector3D>(obj.property("vector3D")); QCOMPARE(v3.x(), (qreal)3.0f); QCOMPARE(v3.y(), (qreal)4.0f); QCOMPARE(v3.z(), (qreal)5.0f); - QVector4D v4 = qVariantValue<QVector4D>(obj.property("vector4D")); + QVector4D v4 = qvariant_cast<QVector4D>(obj.property("vector4D")); QCOMPARE(v4.x(), (qreal)6.0f); QCOMPARE(v4.y(), (qreal)7.0f); QCOMPARE(v4.z(), (qreal)8.0f); QCOMPARE(v4.w(), (qreal)9.0f); obj.setProperty("vector2D", - qVariantFromValue(QVector2D(-1.0f, -2.0f))); + QVariant::fromValue(QVector2D(-1.0f, -2.0f))); obj.setProperty("vector3D", - qVariantFromValue(QVector3D(-3.0f, -4.0f, -5.0f))); + QVariant::fromValue(QVector3D(-3.0f, -4.0f, -5.0f))); obj.setProperty("vector4D", - qVariantFromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f))); + QVariant::fromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f))); - v2 = qVariantValue<QVector2D>(obj.property("vector2D")); + v2 = qvariant_cast<QVector2D>(obj.property("vector2D")); QCOMPARE(v2.x(), (qreal)-1.0f); QCOMPARE(v2.y(), (qreal)-2.0f); - v3 = qVariantValue<QVector3D>(obj.property("vector3D")); + v3 = qvariant_cast<QVector3D>(obj.property("vector3D")); QCOMPARE(v3.x(), (qreal)-3.0f); QCOMPARE(v3.y(), (qreal)-4.0f); QCOMPARE(v3.z(), (qreal)-5.0f); - v4 = qVariantValue<QVector4D>(obj.property("vector4D")); + v4 = qvariant_cast<QVector4D>(obj.property("vector4D")); QCOMPARE(v4.x(), (qreal)-6.0f); QCOMPARE(v4.y(), (qreal)-7.0f); QCOMPARE(v4.z(), (qreal)-8.0f); diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro index d0af96df37..ee1b1e39bc 100644 --- a/tests/auto/gui/qopengl/qopengl.pro +++ b/tests/auto/gui/qopengl/qopengl.pro @@ -8,5 +8,4 @@ QT += gui gui-private core-private testlib SOURCES += tst_qopengl.cpp -mac: CONFIG += insignificant_test # QTBUG-23061 win32:CONFIG += insignificant_test # QTBUG-24192 diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro index c853aaa100..8be6fe22d1 100644 --- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro @@ -9,5 +9,3 @@ wince* { additionalFiles.path = . DEPLOYMENT += additionalFiles } - -mac: CONFIG += insignificant_test # QTBUG-23062 diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index 7a1cc53c57..9510b9719a 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -265,7 +265,10 @@ void tst_QFontDatabase::addAppFont() QVERIFY(QFontDatabase::removeApplicationFont(id)); QCOMPARE(fontDbChangedSpy.count(), 2); - QVERIFY(db.families() == oldFamilies); +#ifdef Q_OS_MAC + QEXPECT_FAIL("font file", "QTBUG-23062", Continue); +#endif + QCOMPARE(db.families(), oldFamilies); } QTEST_MAIN(tst_QFontDatabase) diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 4dbdf9a4f1..8144696e8e 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -233,7 +233,7 @@ void tst_QFontMetrics::bypassShaping() template<class FontMetrics> void elidedMultiLength_helper() { - QString text1 = "Long Text 1\x9cShorter\x9csmall"; + QString text1 = QLatin1String("Long Text 1\x9cShorter\x9csmall"); QString text1_long = "Long Text 1"; QString text1_short = "Shorter"; QString text1_small = "small"; diff --git a/tests/auto/gui/text/qrawfont/qrawfont.pro b/tests/auto/gui/text/qrawfont/qrawfont.pro index 8cac4abc57..149ad6442e 100644 --- a/tests/auto/gui/text/qrawfont/qrawfont.pro +++ b/tests/auto/gui/text/qrawfont/qrawfont.pro @@ -9,5 +9,3 @@ SOURCES += \ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src TESTDATA += testfont_bold_italic.ttf testfont.ttf - -win32:CONFIG += insignificant_test # QTBUG-24197 diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index 99e53f3261..a3fe7b5368 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -295,6 +295,15 @@ void tst_QRawFont::advances() bool supportsSubPixelPositions = font_d->fontEngine->supportsSubPixelPositions(); QVector<QPointF> advances = font.advancesForGlyphIndexes(glyphIndices); for (int i=0; i<glyphIndices.size(); ++i) { +#ifdef Q_OS_WIN + // In Windows, freetype engine returns advance of 9 when full hinting is used (default) for + // some of the glyphs. + if (font_d->fontEngine->type() == QFontEngine::Freetype + && (hintingPreference == QFont::PreferFullHinting || hintingPreference == QFont::PreferDefaultHinting) + && (i == 0 || i == 5)) { + QEXPECT_FAIL("", "Advance for some glyphs is not the expected with Windows Freetype engine (9 instead of 8)", Continue); + } +#endif QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0)); if (supportsSubPixelPositions) QVERIFY(advances.at(i).x() > 8.0); @@ -879,7 +888,7 @@ void tst_QRawFont::multipleRawFontsFromData() testFontBoldItalic.loadFromData(file.readAll(), 11, QFont::PreferDefaultHinting); QVERIFY(testFont.familyName() != (testFontBoldItalic.familyName()) - || testFont.styleName() != (testFontBoldItalic.styleName())); + || testFont.style() != (testFontBoldItalic.style())); } #endif // QT_NO_RAWFONT diff --git a/tests/auto/gui/text/qstatictext/qstatictext.pro b/tests/auto/gui/text/qstatictext/qstatictext.pro index 67f2e047a4..9abc3245ed 100644 --- a/tests/auto/gui/text/qstatictext/qstatictext.pro +++ b/tests/auto/gui/text/qstatictext/qstatictext.pro @@ -3,5 +3,3 @@ TARGET = tst_qstatictext QT += testlib QT += core core-private gui gui-private SOURCES += tst_qstatictext.cpp - -mac: CONFIG += insignificant_test # QTBUG-23063 diff --git a/tests/auto/gui/text/qtextlayout/qtextlayout.pro b/tests/auto/gui/text/qtextlayout/qtextlayout.pro index f35239bc6a..7addbe88dc 100644 --- a/tests/auto/gui/text/qtextlayout/qtextlayout.pro +++ b/tests/auto/gui/text/qtextlayout/qtextlayout.pro @@ -5,3 +5,5 @@ HEADERS += SOURCES += tst_qtextlayout.cpp DEFINES += QT_COMPILES_IN_HARFBUZZ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src + +mac:CONFIG+=insignificant_test # QTBUG-23050 diff --git a/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro b/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro index 516fa67f11..6dcb1b44a0 100644 --- a/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro +++ b/tests/auto/gui/text/qtextscriptengine/qtextscriptengine.pro @@ -6,5 +6,3 @@ QT += core-private gui-private testlib HEADERS += SOURCES += tst_qtextscriptengine.cpp INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src - -mac: CONFIG += insignificant_test # QTBUG-23064 diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index d566f0a20d..5a53f09e77 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1173,11 +1173,12 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675() QFont font("Monaco"); QTextLayout layout(s, font); - QTextEngine *e = layout.d; + QTextEngine *e = layout.engine(); e->itemize(); e->shape(0); QVERIFY(e->layoutData->items[0].num_glyphs == 4); + QEXPECT_FAIL("", "QTBUG-23064", Abort); QVERIFY(e->layoutData->glyphLayout.advances_y[2] > 0); #elif defined(Q_WS_X11) QFontDatabase db; @@ -1317,6 +1318,9 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 10; i++) QCOMPARE(logClusters[i+7], ushort(0)); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23064", Abort); +#endif QCOMPARE(logClusters[17], ushort(1)); // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro index c24fe7553d..5055ab61a3 100644 --- a/tests/auto/gui/text/text.pro +++ b/tests/auto/gui/text/text.pro @@ -31,7 +31,3 @@ win32:SUBDIRS -= qtextpiecetable qstatictext \ qtextlayout \ qtextpiecetable \ - -mac { - qtextlayout.CONFIG = no_check_target # QTBUG-23050 -} diff --git a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp index bcd9cbdff7..4df1084eac 100644 --- a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp @@ -238,7 +238,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("path-with-quotes2") << "a=b; path = \"/with\\\"Quotes\"" << cookie; cookie.setPath(QString::fromUtf8("/R\303\251sum\303\251")); - QTest::newRow("path-with-utf8") << "a=b;path=/R\303\251sum\303\251" << cookie; + QTest::newRow("path-with-utf8") << QString::fromUtf8("a=b;path=/R\303\251sum\303\251") << cookie; QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie; cookie.setPath(QString()); @@ -256,9 +256,9 @@ void tst_QNetworkCookie::parseSingleCookie_data() cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); QTest::newRow("idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie; - QTest::newRow("idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie; + QTest::newRow("idn-domain2") << QString::fromUtf8("a=b;domain=.d\303\270gn\303\245pent.troll.no") << cookie; QTest::newRow("idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; - QTest::newRow("idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; + QTest::newRow("idn-domain4") << QString::fromUtf8("a=b;domain=.D\303\230GN\303\205PENT.troll.NO") << cookie; cookie.setDomain(".qt.nokia.com"); cookie.setPath("/"); @@ -595,7 +595,7 @@ void tst_QNetworkCookie::parseSingleCookie() QFETCH(QString, cookieString); QFETCH(QNetworkCookie, expectedCookie); - QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toLatin1()); + QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toUtf8()); //QEXPECT_FAIL("network2", "QDateTime parsing problem: the date is beyond year 8000", Abort); QCOMPARE(result.count(), 1); @@ -723,7 +723,7 @@ void tst_QNetworkCookie::parseMultipleCookies() QFETCH(QString, cookieString); QFETCH(QList<QNetworkCookie>, expectedCookies); - QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toLatin1()); + QList<QNetworkCookie> result = QNetworkCookie::parseCookies(cookieString.toUtf8()); QEXPECT_FAIL("network1", "Apparently multiple cookies set in one request (and an invalid date)", Abort); QCOMPARE(result, expectedCookies); diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 2d784fcbbc..824f5fc507 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -405,6 +405,10 @@ private Q_SLOTS: void backgroundRequest_data(); void backgroundRequest(); + void backgroundRequestInterruption_data(); + void backgroundRequestInterruption(); + void backgroundRequestConnectInBackground_data(); + void backgroundRequestConnectInBackground(); // NOTE: This test must be last! void parentingRepliesToTheApp(); @@ -1402,6 +1406,11 @@ void tst_QNetworkReply::cleanup() // clear cookies cookieJar->setAllCookies(QList<QNetworkCookie>()); + + // disconnect manager signals + manager.disconnect(SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>))); + manager.disconnect(SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); + manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); } void tst_QNetworkReply::stateChecking() @@ -3812,9 +3821,13 @@ void tst_QNetworkReply::ioPutToFileFromSocket() QFETCH(QByteArray, data); SocketPair socketpair; - socketpair.create(); - QVERIFY(socketpair.endPoints[0] && socketpair.endPoints[1]); + QTRY_VERIFY(socketpair.create()); //QTRY_VERIFY as a workaround for QTBUG-24451 +#ifdef Q_OS_WIN + //128k and 2M tests regularly fail. Assumed same characteristics as ioPostToHttpFromSocket + if (data.size() > 1000) + QSKIP("unstable on windows - QTBUG-25386"); +#endif socketpair.endPoints[0]->write(data); QNetworkReplyPtr reply(manager.put(QNetworkRequest(url), socketpair.endPoints[1])); socketpair.endPoints[0]->close(); @@ -4100,9 +4113,13 @@ void tst_QNetworkReply::ioPostToHttpFromSocket() QFETCH(QByteArray, data); QFETCH(QUrl, url); QFETCH(QNetworkProxy, proxy); +#ifdef Q_OS_WIN + //QTBUG-25386 hits one of the 128k tests 50% of the time, one of the 4k tests rarely (but at least 1%) + if (data.size() > 1000) + QSKIP("unstable on windows - QTBUG-25386"); +#endif SocketPair socketpair; - socketpair.create(); - QVERIFY(socketpair.endPoints[0] && socketpair.endPoints[1]); + QTRY_VERIFY(socketpair.create()); //QTRY_VERIFY as a workaround for QTBUG-24451 socketpair.endPoints[0]->write(data); @@ -4173,8 +4190,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous() QFETCH(QByteArray, data); SocketPair socketpair; - QVERIFY(socketpair.create()); - QVERIFY(socketpair.endPoints[0] && socketpair.endPoints[1]); + QTRY_VERIFY(socketpair.create()); //QTRY_VERIFY as a workaround for QTBUG-24451 socketpair.endPoints[0]->write(data); socketpair.endPoints[0]->waitForBytesWritten(5000); // ### for 4.8: make the socket pair unbuffered, to not read everything in one go in QNetworkReplyImplPrivate::setup() @@ -4292,8 +4308,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag() QByteArray data = QByteArray("daaaaaaataaaaaaa"); // create a sequential QIODevice by feeding the data into a local TCP server SocketPair socketpair; - socketpair.create(); - QVERIFY(socketpair.endPoints[0] && socketpair.endPoints[1]); + QTRY_VERIFY(socketpair.create()); //QTRY_VERIFY as a workaround for QTBUG-24451 socketpair.endPoints[0]->write(data); QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi"; @@ -6811,25 +6826,45 @@ void tst_QNetworkReply::ftpAuthentication() void tst_QNetworkReply::backgroundRequest_data() { + QTest::addColumn<QUrl>("url"); QTest::addColumn<bool>("background"); QTest::addColumn<int>("policy"); QTest::addColumn<QNetworkReply::NetworkError>("error"); - QTest::newRow("fg, normal") << false << 0 << QNetworkReply::NoError; - QTest::newRow("bg, normal") << true << 0 << QNetworkReply::NoError; - QTest::newRow("fg, nobg") << false << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::NoError; - QTest::newRow("bg, nobg") << true << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::BackgroundRequestNotAllowedError; + QUrl httpurl("http://" + QtNetworkSettings::serverName()); + QUrl httpsurl("https://" + QtNetworkSettings::serverName()); + QUrl ftpurl("ftp://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + + QTest::newRow("http, fg, normal") << httpurl << false << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError; + QTest::newRow("http, bg, normal") << httpurl << true << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError; + QTest::newRow("http, fg, nobg") << httpurl << false << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::NoError; + QTest::newRow("http, bg, nobg") << httpurl << true << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::BackgroundRequestNotAllowedError; + +#ifndef QT_NO_SSL + QTest::newRow("https, fg, normal") << httpsurl << false << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError; + QTest::newRow("https, bg, normal") << httpsurl << true << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError; + QTest::newRow("https, fg, nobg") << httpsurl << false << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::NoError; + QTest::newRow("https, bg, nobg") << httpsurl << true << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::BackgroundRequestNotAllowedError; +#endif + + QTest::newRow("ftp, fg, normal") << ftpurl << false << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError; + QTest::newRow("ftp, bg, normal") << ftpurl << true << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError; + QTest::newRow("ftp, fg, nobg") << ftpurl << false << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::NoError; + QTest::newRow("ftp, bg, nobg") << ftpurl << true << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::BackgroundRequestNotAllowedError; } +//test purpose: background requests can't be started when not allowed void tst_QNetworkReply::backgroundRequest() { #ifdef QT_BUILD_INTERNAL +#ifndef QT_NO_BEARERMANAGEMENT + QFETCH(QUrl, url); QFETCH(bool, background); QFETCH(int, policy); QFETCH(QNetworkReply::NetworkError, error); - QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName())); + QNetworkRequest request(url); if (background) request.setAttribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(true)); @@ -6837,6 +6872,11 @@ void tst_QNetworkReply::backgroundRequest() //this preconstructs the session so we can change policies in advance manager.setConfiguration(networkConfiguration); +#ifndef QT_NO_SSL + connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), + SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); +#endif + const QWeakPointer<const QNetworkSession> session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); QVERIFY(session); QNetworkSession::UsagePolicies original = session.data()->usagePolicies(); @@ -6851,6 +6891,138 @@ void tst_QNetworkReply::backgroundRequest() QVERIFY(reply->isFinished()); QCOMPARE(reply->error(), error); #endif +#endif +} + +void tst_QNetworkReply::backgroundRequestInterruption_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<bool>("background"); + QTest::addColumn<QNetworkReply::NetworkError>("error"); + + QUrl httpurl("http://" + QtNetworkSettings::serverName() + "/qtest/mediumfile"); + QUrl httpsurl("https://" + QtNetworkSettings::serverName() + "/qtest/mediumfile"); + QUrl ftpurl("ftp://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + + QTest::newRow("http, fg, nobg") << httpurl << false << QNetworkReply::NoError; + QTest::newRow("http, bg, nobg") << httpurl << true << QNetworkReply::BackgroundRequestNotAllowedError; + +#ifndef QT_NO_SSL + QTest::newRow("https, fg, nobg") << httpsurl << false << QNetworkReply::NoError; + QTest::newRow("https, bg, nobg") << httpsurl << true << QNetworkReply::BackgroundRequestNotAllowedError; +#endif + + QTest::newRow("ftp, fg, nobg") << ftpurl << false << QNetworkReply::NoError; + QTest::newRow("ftp, bg, nobg") << ftpurl << true << QNetworkReply::BackgroundRequestNotAllowedError; + +} + +//test purpose: background requests in progress are aborted when policy changes to disallow them +void tst_QNetworkReply::backgroundRequestInterruption() +{ +#ifdef QT_BUILD_INTERNAL +#ifndef QT_NO_BEARERMANAGEMENT + QFETCH(QUrl, url); + QFETCH(bool, background); + QFETCH(QNetworkReply::NetworkError, error); + + QNetworkRequest request(url); + + if (background) + request.setAttribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(true)); + + //this preconstructs the session so we can change policies in advance + manager.setConfiguration(networkConfiguration); + +#ifndef QT_NO_SSL + connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), + SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); +#endif + + const QWeakPointer<const QNetworkSession> session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); + QVERIFY(session); + QNetworkSession::UsagePolicies original = session.data()->usagePolicies(); + QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), QNetworkSession::NoPolicy); + + request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 8192); + QNetworkReplyPtr reply(manager.get(request)); + reply->setReadBufferSize(1024); + + QSignalSpy spy(reply.data(), SIGNAL(readyRead())); + QTRY_VERIFY(spy.count() > 0); + + QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), QNetworkSession::NoBackgroundTrafficPolicy); + + QVERIFY(waitForFinish(reply) != Timeout); + if (session) + QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), original); + + QVERIFY(reply->isFinished()); + QCOMPARE(reply->error(), error); +#endif +#endif +} + +void tst_QNetworkReply::backgroundRequestConnectInBackground_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<bool>("background"); + + QUrl httpurl("http://" + QtNetworkSettings::serverName()); + QUrl ftpurl("ftp://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + + QTest::newRow("http, fg") << httpurl << false; + QTest::newRow("http, bg") << httpurl << true; + + QTest::newRow("ftp, fg") << ftpurl << false; + QTest::newRow("ftp, bg") << ftpurl << true; +} + +//test purpose: check that backgroundness is propagated to the network session +void tst_QNetworkReply::backgroundRequestConnectInBackground() +{ +#ifdef QT_BUILD_INTERNAL +#ifndef QT_NO_BEARERMANAGEMENT + QFETCH(QUrl, url); + QFETCH(bool, background); + + QNetworkRequest request(url); + + if (background) + request.setAttribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(true)); + + QWeakPointer<const QNetworkSession> session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); + //force QNAM to reopen the session. + if (session && session.data()->isOpen()) { + const_cast<QNetworkSession *>(session.data())->close(); + QCoreApplication::processEvents(); //let signals propagate inside QNAM + } + + //this preconstructs the session so we can change policies in advance + manager.setConfiguration(networkConfiguration); + + session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); + QVERIFY(session); + QNetworkSession::UsagePolicies original = session.data()->usagePolicies(); + QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), QNetworkSession::NoPolicy); + + QNetworkReplyPtr reply(manager.get(request)); + + QVERIFY(waitForFinish(reply) != Timeout); + session = QNetworkAccessManagerPrivate::getNetworkSession(&manager); + if (session) { + QVariant cib = session.data()->sessionProperty(QStringLiteral("ConnectInBackground")); + if (!cib.isValid()) + QSKIP("inconclusive - ConnectInBackground session property not supported by the bearer plugin"); + QCOMPARE(cib.toBool(), background); + QNetworkSessionPrivate::setUsagePolicies(*const_cast<QNetworkSession *>(session.data()), original); + } else { + QSKIP("inconclusive - network session has been destroyed"); + } + + QVERIFY(reply->isFinished()); +#endif +#endif } // NOTE: This test must be last testcase in tst_qnetworkreply! diff --git a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp index 928dc48125..25764aacce 100644 --- a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp +++ b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp @@ -282,21 +282,21 @@ void tst_QNetworkRequest::setHeader_data() cookie.setName("a"); cookie.setValue("b"); QTest::newRow("Cookie-1") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie) << true << "Cookie" << "a=b"; QTest::newRow("SetCookie-1") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie) << true << "Set-Cookie" << "a=b"; cookie.setPath("/"); QTest::newRow("Cookie-2") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie) << true << "Cookie" << "a=b"; QTest::newRow("SetCookie-2") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie) << true << "Set-Cookie" << "a=b; path=/"; @@ -304,11 +304,11 @@ void tst_QNetworkRequest::setHeader_data() cookie2.setName("c"); cookie2.setValue("d"); QTest::newRow("Cookie-3") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie << cookie2) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2) << true << "Cookie" << "a=b; c=d"; QTest::newRow("SetCookie-3") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie << cookie2) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2) << true << "Set-Cookie" << "a=b; path=/, c=d"; } @@ -388,17 +388,17 @@ void tst_QNetworkRequest::rawHeaderParsing_data() cookie.setName("a"); cookie.setValue("b"); QTest::newRow("Cookie-1") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie) << true << "Cookie" << "a=b"; QTest::newRow("SetCookie-1") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie) << true << "Set-Cookie" << "a=b"; cookie.setPath("/"); QTest::newRow("SetCookie-2") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie) << true << "Set-Cookie" << "a=b; path=/"; @@ -407,12 +407,12 @@ void tst_QNetworkRequest::rawHeaderParsing_data() cookie2.setName("c"); cookie2.setValue("d"); QTest::newRow("Cookie-3") << QNetworkRequest::CookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie << cookie2) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2) << true << "Cookie" << "a=b; c=d"; cookie.setPath("/"); QTest::newRow("SetCookie-3") << QNetworkRequest::SetCookieHeader - << qVariantFromValue(QList<QNetworkCookie>() << cookie << cookie2) + << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2) << true << "Set-Cookie" << "a=b; path=/, c=d"; } diff --git a/tests/auto/network/kernel/kernel.pro b/tests/auto/network/kernel/kernel.pro index 32ba8b41b7..14080a0548 100644 --- a/tests/auto/network/kernel/kernel.pro +++ b/tests/auto/network/kernel/kernel.pro @@ -3,7 +3,7 @@ SUBDIRS=\ qdnslookup \ qdnslookup_appless \ qhostinfo \ -# qnetworkproxyfactory \ # Uses a hardcoded proxy configuration + qnetworkproxyfactory \ qauthenticator \ qnetworkproxy \ qnetworkinterface \ diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index c1400b82af..b4ef1b803b 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -97,8 +97,10 @@ void tst_QDnsLookup::lookup_data() QTest::newRow("mx-empty") << int(QDnsLookup::MX) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); QTest::newRow("mx-notfound") << int(QDnsLookup::MX) << "invalid." << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); QTest::newRow("mx-ascii") << int(QDnsLookup::MX) << "troll.no" << int(QDnsLookup::NoError) << "" << "" << "10 smtp.trolltech.com" << "" << "" << "" << QByteArray(); +#if 0 // FIXME: we need an IDN MX record in the troll.no domain QTest::newRow("mx-idn") << int(QDnsLookup::MX) << QString::fromUtf8("rÃ¥kat.se") << int(QDnsLookup::NoError) << "" << "" << "10 mail.cdr.se" << "" << "" << "" << QByteArray(); +#endif QTest::newRow("ns-empty") << int(QDnsLookup::NS) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); QTest::newRow("ns-notfound") << int(QDnsLookup::NS) << "invalid." << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); @@ -111,8 +113,10 @@ void tst_QDnsLookup::lookup_data() QTest::newRow("srv-empty") << int(QDnsLookup::SRV) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); QTest::newRow("srv-notfound") << int(QDnsLookup::SRV) << "invalid." << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); +#if 0 // FIXME: we need SRV records in the troll.no domain QTest::newRow("srv-idn") << int(QDnsLookup::SRV) << QString::fromUtf8("_xmpp-client._tcp.rÃ¥kat.se") << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "5 0 5224 jabber.cdr.se" << QByteArray(); +#endif QTest::newRow("txt-empty") << int(QDnsLookup::TXT) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); QTest::newRow("txt-notfound") << int(QDnsLookup::TXT) << "invalid." << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); diff --git a/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro b/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro index ba401579a6..694dec2ed7 100644 --- a/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro +++ b/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro @@ -3,5 +3,3 @@ TARGET = tst_qnetworkinterface SOURCES += tst_qnetworkinterface.cpp QT = core network testlib - -win32:CONFIG+=insignificant_test # QTBUG-24451 - localAddress() diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index 9b7d21eff8..d8f5a0428f 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -133,6 +133,10 @@ void tst_QNetworkProxyFactory::systemProxyForQuery_data() QTest::newRow("imap") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString() << QString("qt-project.org") << 0 << (int)QNetworkProxy::TunnelingCapability; QTest::newRow("autobind-server") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString() << QString() << 0 << (int)QNetworkProxy::ListeningCapability; QTest::newRow("web-server") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString() << QString() << 80 << (int)QNetworkProxy::ListeningCapability; + //windows: these should be bypassed if "bypass proxy server for local addresses" is ticked + foreach (QHostAddress address, QNetworkInterface::allAddresses()) { + QTest::newRow(qPrintable(address.toString())) << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString() << address.toString() << 0 << 0; + } //UDP QTest::newRow("udp") << (int)QNetworkProxyQuery::UdpSocket << QUrl() << QString() << QString() << 0 << (int)QNetworkProxy::UdpTunnelingCapability; diff --git a/tests/auto/network/network.pro b/tests/auto/network/network.pro index 2048d14dc8..64262a8632 100644 --- a/tests/auto/network/network.pro +++ b/tests/auto/network/network.pro @@ -6,7 +6,5 @@ SUBDIRS=\ ssl \ socket \ -win32 { - socket.CONFIG += no_check_target # QTBUG-24451 - all socket tests require waitForX - bearer.CONFIG += no_check_target # QTBUG-24503 - these tests fail if machine has a WLAN adaptor -} +win32: socket.CONFIG += no_check_target # QTBUG-24451 - all socket tests require waitForX +win32|mac:bearer.CONFIG += no_check_target # QTBUG-24503 - these tests fail if machine has a WLAN adaptor diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 2715bfc5dc..eeda46dfdc 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -383,7 +383,7 @@ void tst_QLocalSocket::listenAndConnect() QVERIFY(socket->error() != QLocalSocket::UnknownSocketError); QCOMPARE(socket->state(), QLocalSocket::UnconnectedState); //QVERIFY(socket->socketDescriptor() == -1); - QCOMPARE(qVariantValue<QLocalSocket::LocalSocketError>(spyError.first()[0]), + QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]), QLocalSocket::ServerNotFoundError); } @@ -403,19 +403,19 @@ void tst_QLocalSocket::listenAndConnect() QVERIFY(spyError.count() >= 0); if (canListen) { if (spyError.count() > 0) - QCOMPARE(qVariantValue<QLocalSocket::LocalSocketError>(spyError.first()[0]), + QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]), QLocalSocket::SocketTimeoutError); } else { - QCOMPARE(qVariantValue<QLocalSocket::LocalSocketError>(spyError.first()[0]), + QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]), QLocalSocket::ServerNotFoundError); } // Check first and last state - QCOMPARE(qVariantValue<QLocalSocket::LocalSocketState>(spyStateChanged.first()[0]), + QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketState>(spyStateChanged.first()[0]), QLocalSocket::ConnectingState); if (canListen) - QCOMPARE(qVariantValue<QLocalSocket::LocalSocketState>(spyStateChanged.last()[0]), + QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketState>(spyStateChanged.last()[0]), QLocalSocket::ConnectedState); QCOMPARE(spyStateChanged.count(), 2); QCOMPARE(spyReadyRead.count(), 0); @@ -1153,7 +1153,7 @@ void tst_QLocalSocket::verifyListenWithDescriptor_data() QTest::addColumn<bool>("abstract"); QTest::addColumn<bool>("bound"); - QTest::newRow("normal") << QDir::tempPath() + QLatin1Literal("/testsocket") << false << true; + QTest::newRow("normal") << QDir::tempPath() + QLatin1String("/testsocket") << false << true; #ifdef Q_OS_LINUX QTest::newRow("absrtact") << QString::fromLatin1("abstractsocketname") << true << true; QTest::newRow("abstractwithslash") << QString::fromLatin1("abstractsocketwitha/inthename") << true << true; diff --git a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro index 9e37aec5ce..c9793952ce 100644 --- a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro @@ -10,6 +10,6 @@ MOC_DIR=tmp QT = core-private network-private testlib -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG += insignificant_test # QTBUG-23380 +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC # QTBUG-23380 requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index 0c0690babe..3cc1f32622 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -130,7 +130,7 @@ private slots: { QTcpSocket *client = nextPendingConnection(); connect(client, SIGNAL(readyRead()), SLOT(handleClientCommand())); - client->setProperty("pendingResponses", qVariantFromValue(responses)); + client->setProperty("pendingResponses", QVariant::fromValue(responses)); } void handleClientCommand() @@ -145,7 +145,7 @@ private slots: client->disconnectFromHost(); else client->write(pendingResponses.dequeue()); - client->setProperty("pendingResponses", qVariantFromValue(pendingResponses)); + client->setProperty("pendingResponses", QVariant::fromValue(pendingResponses)); } }; @@ -551,7 +551,16 @@ void tst_QSocks5SocketEngine::udpTest() QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState); // Bind #1 +#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) + { + bool bindSuccessful = udpSocket.bind(QHostAddress("0.0.0.0"), 0); + if (!bindSuccessful) + QEXPECT_FAIL("", "QTBUG-23380: Fails on some Ubuntu 11.10 x64 configurations", Abort); + QVERIFY(bindSuccessful); + } +#else QVERIFY(udpSocket.bind(QHostAddress("0.0.0.0"), 0)); +#endif QVERIFY(udpSocket.state() == QAbstractSocket::BoundState); QVERIFY(udpSocket.localPort() != 0); diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 3c7c3a3da0..13c5d961d7 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -2212,9 +2212,9 @@ void tst_QTcpSocket::connectionRefused() QCOMPARE(socket->error(), QAbstractSocket::ConnectionRefusedError); QCOMPARE(stateSpy.count(), 3); - QCOMPARE(qVariantValue<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState); - QCOMPARE(qVariantValue<QAbstractSocket::SocketState>(stateSpy.at(1).at(0)), QAbstractSocket::ConnectingState); - QCOMPARE(qVariantValue<QAbstractSocket::SocketState>(stateSpy.at(2).at(0)), QAbstractSocket::UnconnectedState); + QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(0).at(0)), QAbstractSocket::HostLookupState); + QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(1).at(0)), QAbstractSocket::ConnectingState); + QCOMPARE(qvariant_cast<QAbstractSocket::SocketState>(stateSpy.at(2).at(0)), QAbstractSocket::UnconnectedState); QCOMPARE(errorSpy.count(), 1); delete socket; diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index 6ff5dca813..48e076b2ab 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -22,4 +22,4 @@ wince* { TARGET = tst_qudpsocket -CONFIG+=insignificant_test +CONFIG+=insignificant_test # QTBUG-25367, QTBUG-25368 diff --git a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro index bb04e0b9c4..c24fe22518 100644 --- a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro +++ b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro @@ -31,9 +31,6 @@ wince* { DEFINES += SRCDIR=\\\"$$PWD/\\\" } -# QTBUG-23575 -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC # QTBUG-24234 requires(contains(QT_CONFIG,private_tests)) - -win32:CONFIG += insignificant_test # QTBUG-24234 diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 23e87b7f3b..34bc361e4b 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -189,6 +189,8 @@ private slots: void encryptWithoutConnecting(); void resume_data(); void resume(); + void qtbug18498_peek(); + void qtbug18498_peek2(); void setEmptyDefaultConfiguration(); // this test should be last static void exitLoop() @@ -1764,8 +1766,8 @@ void tst_QSslSocket::verifyMode() loop.exec(); QVERIFY(clientSocket.isEncrypted()); -#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) - QEXPECT_FAIL("", "QTBUG-23575 - Fails on this platform", Abort); +#if (defined(UBUNTU_ONEIRIC) && defined(__x86_64__)) || defined(Q_OS_WIN) || defined(Q_OS_MAC) + QEXPECT_FAIL("", "QTBUG-24234", Abort); #endif QVERIFY(server.socket->sslErrors().isEmpty()); } @@ -1791,8 +1793,8 @@ void tst_QSslSocket::peerVerifyError() QVERIFY(!socket->waitForEncrypted(10000)); QVERIFY(!peerVerifyErrorSpy.isEmpty()); QVERIFY(!sslErrorsSpy.isEmpty()); - QCOMPARE(qVariantValue<QSslError>(peerVerifyErrorSpy.last().at(0)).error(), QSslError::HostNameMismatch); - QCOMPARE(qVariantValue<QList<QSslError> >(sslErrorsSpy.at(0).at(0)).size(), peerVerifyErrorSpy.size()); + QCOMPARE(qvariant_cast<QSslError>(peerVerifyErrorSpy.last().at(0)).error(), QSslError::HostNameMismatch); + QCOMPARE(qvariant_cast<QList<QSslError> >(sslErrorsSpy.at(0).at(0)).size(), peerVerifyErrorSpy.size()); } void tst_QSslSocket::disconnectFromHostWhenConnecting() @@ -2198,6 +2200,261 @@ void tst_QSslSocket::resume() } } +class WebSocket : public QSslSocket +{ + Q_OBJECT +public: + explicit WebSocket(qintptr socketDescriptor, + const QString &keyFile = SRCDIR "certs/fluke.key", + const QString &certFile = SRCDIR "certs/fluke.cert"); + +protected slots: + void onReadyReadFirstBytes(void); + +private: + void _startServerEncryption(void); + + QString m_keyFile; + QString m_certFile; + +private: + Q_DISABLE_COPY(WebSocket) +}; + +WebSocket::WebSocket (qintptr socketDescriptor, const QString &keyFile, const QString &certFile) + : m_keyFile(keyFile), + m_certFile(certFile) +{ + QVERIFY(setSocketDescriptor(socketDescriptor, QAbstractSocket::ConnectedState, QIODevice::ReadWrite | QIODevice::Unbuffered)); + connect (this, SIGNAL(readyRead()), this, SLOT(onReadyReadFirstBytes())); +} + +void WebSocket::_startServerEncryption (void) +{ + QFile file(m_keyFile); + QVERIFY(file.open(QIODevice::ReadOnly)); + QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); + QVERIFY(!key.isNull()); + setPrivateKey(key); + + QList<QSslCertificate> localCert = QSslCertificate::fromPath(m_certFile); + QVERIFY(!localCert.isEmpty()); + QVERIFY(localCert.first().handle()); + setLocalCertificate(localCert.first()); + + QVERIFY(!peerAddress().isNull()); + QVERIFY(peerPort() != 0); + QVERIFY(!localAddress().isNull()); + QVERIFY(localPort() != 0); + + setProtocol(QSsl::AnyProtocol); + setPeerVerifyMode(QSslSocket::VerifyNone); + ignoreSslErrors(); + startServerEncryption(); +} + +void WebSocket::onReadyReadFirstBytes (void) +{ + peek(1); + disconnect(this,SIGNAL(readyRead()), this, SLOT(onReadyReadFirstBytes())); + _startServerEncryption(); +} + +class SslServer4 : public QTcpServer +{ + Q_OBJECT +public: + SslServer4() : socket(0) {} + WebSocket *socket; + +protected: + void incomingConnection(qintptr socketDescriptor) + { + socket = new WebSocket(socketDescriptor); + } +}; + +void tst_QSslSocket::qtbug18498_peek() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SslServer4 server; + QSslSocket *client = new QSslSocket(this); + + QVERIFY(server.listen(QHostAddress::LocalHost)); + client->connectToHost("127.0.0.1", server.serverPort()); + QVERIFY(client->waitForConnected(5000)); + QVERIFY(server.waitForNewConnection(1000)); + client->setObjectName("client"); + client->ignoreSslErrors(); + + connect(client, SIGNAL(encrypted()), this, SLOT(exitLoop())); + connect(client, SIGNAL(disconnected()), this, SLOT(exitLoop())); + + client->startClientEncryption(); + WebSocket *serversocket = server.socket; + QVERIFY(serversocket); + serversocket->setObjectName("server"); + + enterLoop(1); + QVERIFY(!timeout()); + QVERIFY(serversocket->isEncrypted()); + QVERIFY(client->isEncrypted()); + + QByteArray data("abc123"); + client->write(data.data()); + + connect(serversocket, SIGNAL(readyRead()), this, SLOT(exitLoop())); + enterLoop(1); + QVERIFY(!timeout()); + + QByteArray peek1_data; + peek1_data.reserve(data.size()); + QByteArray peek2_data; + QByteArray read_data; + + int lngth = serversocket->peek(peek1_data.data(), 10); + peek1_data.resize(lngth); + + peek2_data = serversocket->peek(10); + read_data = serversocket->readAll(); + + QCOMPARE(peek1_data, data); + QCOMPARE(peek2_data, data); + QCOMPARE(read_data, data); +} + +class SslServer5 : public QTcpServer +{ + Q_OBJECT +public: + SslServer5() : socket(0) {} + QSslSocket *socket; + +protected: + void incomingConnection(qintptr socketDescriptor) + { + socket = new QSslSocket; + socket->setSocketDescriptor(socketDescriptor); + } +}; + +void tst_QSslSocket::qtbug18498_peek2() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SslServer5 listener; + QVERIFY(listener.listen(QHostAddress::Any)); + QScopedPointer<QSslSocket> client(new QSslSocket); + client->connectToHost(QHostAddress::LocalHost, listener.serverPort()); + QVERIFY(client->waitForConnected(5000)); + QVERIFY(listener.waitForNewConnection(1000)); + + QScopedPointer<QSslSocket> server(listener.socket); + + QVERIFY(server->write("HELLO\r\n", 7)); + QElapsedTimer stopwatch; + stopwatch.start(); + while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000) + QTest::qWait(100); + char c; + QVERIFY(client->peek(&c,1) == 1); + QCOMPARE(c, 'H'); + QVERIFY(client->read(&c,1) == 1); + QCOMPARE(c, 'H'); + QByteArray b = client->peek(2); + QCOMPARE(b, QByteArray("EL")); + char a[3]; + QVERIFY(client->peek(a, 2) == 2); + QCOMPARE(a[0], 'E'); + QCOMPARE(a[1], 'L'); + QCOMPARE(client->readAll(), QByteArray("ELLO\r\n")); + + //check data split between QIODevice and plain socket buffers. + QByteArray bigblock; + bigblock.fill('#', QIODEVICE_BUFFERSIZE + 1024); + QVERIFY(client->write(QByteArray("head"))); + QVERIFY(client->write(bigblock)); + while (server->bytesAvailable() < bigblock.length() + 4 && stopwatch.elapsed() < 5000) + QTest::qWait(100); + QCOMPARE(server->read(4), QByteArray("head")); + QCOMPARE(server->peek(bigblock.length()), bigblock); + b.reserve(bigblock.length()); + b.resize(server->peek(b.data(), bigblock.length())); + QCOMPARE(b, bigblock); + + //check oversized peek + QCOMPARE(server->peek(bigblock.length() * 3), bigblock); + b.reserve(bigblock.length() * 3); + b.resize(server->peek(b.data(), bigblock.length() * 3)); + QCOMPARE(b, bigblock); + + QCOMPARE(server->readAll(), bigblock); + + QVERIFY(client->write("STARTTLS\r\n")); + stopwatch.start(); + // ### Qt5 use QTRY_VERIFY + while (server->bytesAvailable() < 10 && stopwatch.elapsed() < 5000) + QTest::qWait(100); + QVERIFY(server->peek(&c,1) == 1); + QCOMPARE(c, 'S'); + b = server->peek(3); + QCOMPARE(b, QByteArray("STA")); + QCOMPARE(server->read(5), QByteArray("START")); + QVERIFY(server->peek(a, 3) == 3); + QCOMPARE(a[0], 'T'); + QCOMPARE(a[1], 'L'); + QCOMPARE(a[2], 'S'); + QCOMPARE(server->readAll(), QByteArray("TLS\r\n")); + + QFile file(SRCDIR "certs/fluke.key"); + QVERIFY(file.open(QIODevice::ReadOnly)); + QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); + QVERIFY(!key.isNull()); + server->setPrivateKey(key); + + QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); + QVERIFY(!localCert.isEmpty()); + QVERIFY(localCert.first().handle()); + server->setLocalCertificate(localCert.first()); + + server->setProtocol(QSsl::AnyProtocol); + server->setPeerVerifyMode(QSslSocket::VerifyNone); + + server->ignoreSslErrors(); + client->ignoreSslErrors(); + + server->startServerEncryption(); + client->startClientEncryption(); + + QVERIFY(server->write("hello\r\n", 7)); + stopwatch.start(); + while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000) + QTest::qWait(100); + QVERIFY(server->mode() == QSslSocket::SslServerMode && client->mode() == QSslSocket::SslClientMode); + QVERIFY(client->peek(&c,1) == 1); + QCOMPARE(c, 'h'); + QVERIFY(client->read(&c,1) == 1); + QCOMPARE(c, 'h'); + b = client->peek(2); + QCOMPARE(b, QByteArray("el")); + QCOMPARE(client->readAll(), QByteArray("ello\r\n")); + + QVERIFY(client->write("goodbye\r\n")); + stopwatch.start(); + while (server->bytesAvailable() < 9 && stopwatch.elapsed() < 5000) + QTest::qWait(100); + QVERIFY(server->peek(&c,1) == 1); + QCOMPARE(c, 'g'); + QCOMPARE(server->readAll(), QByteArray("goodbye\r\n")); + client->disconnectFromHost(); + QVERIFY(client->waitForDisconnected(5000)); +} + void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, as it has some side effects { // used to produce a crash in QSslConfigurationPrivate::deepCopyDefaultConfiguration, QTBUG-13265 diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro index 5aeb0e48ac..33b55b4638 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro @@ -22,5 +22,3 @@ wince* { } requires(contains(QT_CONFIG,private_tests)) - -win32:CONFIG+=insignificant_test # QTBUG-24451 - all diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro index 3955ea106c..8a500a3d99 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro @@ -22,5 +22,3 @@ wince* { } requires(contains(QT_CONFIG,private_tests)) - -win32:CONFIG+=insignificant_test # QTBUG-24451 - all diff --git a/tests/auto/opengl/qgl/qgl.pro b/tests/auto/opengl/qgl/qgl.pro index db82d9a256..40da265417 100644 --- a/tests/auto/opengl/qgl/qgl.pro +++ b/tests/auto/opengl/qgl/qgl.pro @@ -10,4 +10,5 @@ QT += widgets widgets-private opengl-private gui-private core-private testlib SOURCES += tst_qgl.cpp RESOURCES = qgl.qrc -CONFIG+=insignificant_test +win32:CONFIG+=insignificant_test # QTBUG-25293 +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = lucid ]"): CONFIG+=insignificant_test # QTBUG-25293 diff --git a/tests/auto/opengl/qglthreads/qglthreads.pro b/tests/auto/opengl/qglthreads/qglthreads.pro index 1534472ef6..9b8d9a5301 100644 --- a/tests/auto/opengl/qglthreads/qglthreads.pro +++ b/tests/auto/opengl/qglthreads/qglthreads.pro @@ -10,4 +10,4 @@ x11 { LIBS += $$QMAKE_LIBS_X11 } -CONFIG+=insignificant_test # QTBUG-22560 +win32|linux-*:CONFIG+=insignificant_test # QTBUG-22560 diff --git a/tests/auto/other/headersclean/headersclean.pri b/tests/auto/other/headersclean/headersclean.pri index c95380e3b9..e81c000768 100644 --- a/tests/auto/other/headersclean/headersclean.pri +++ b/tests/auto/other/headersclean/headersclean.pri @@ -10,7 +10,7 @@ # The flags here come from http://wiki.qt-project.org/Coding_Conventions#Conventions_for_public_header_files # -Wold-style-cast cannot be used, /usr/include/bits/byteswap.h defines the macro bswap_16 using C style casts :( # -Wfloat-equal cannot be used, qrect.h and qvector2d.h do exact comparisons in isNull and operator==. Would need #pragmas. -*-g++*: QMAKE_CXXFLAGS += -Woverloaded-virtual -Wshadow -Wundef +*-g++*: QMAKE_CXXFLAGS += -Wshadow -Wundef # Other nice flags *-g++*: QMAKE_CXXFLAGS += -Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wpointer-arith -Wformat-security diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro index ced8aceb99..534452ed14 100644 --- a/tests/auto/other/lancelot/lancelot.pro +++ b/tests/auto/other/lancelot/lancelot.pro @@ -11,5 +11,3 @@ RESOURCES += images.qrc include($$PWD/../../../baselineserver/shared/qbaselinetest.pri) TESTDATA += scripts/* - -CONFIG += insignificant_test # QTBUG-21402 diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 969db62acb..4e45c75e4d 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -694,7 +694,7 @@ void PaintCommands::runCommand(const QString &scriptLine) QString firstWord = scriptLine.section(QRegExp("\\s"), 0, 0); QList<int> indices = s_commandHash.values(firstWord); foreach(int idx, indices) { - const PaintCommandInfos &command = s_commandInfoTable.at(idx); + PaintCommandInfos command = s_commandInfoTable.at(idx); if (command.regExp.indexIn(scriptLine) >= 0) { (this->*(command.paintMethod))(command.regExp); return; diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp index 4bb0bae243..897f238aa5 100644 --- a/tests/auto/other/lancelot/tst_lancelot.cpp +++ b/tests/auto/other/lancelot/tst_lancelot.cpp @@ -186,6 +186,9 @@ void tst_Lancelot::testOpenGL_data() void tst_Lancelot::testOpenGL() { +#ifdef Q_OS_MAC + QSKIP("QTBUG-22792: This test function crashes on Mac OS X"); +#endif bool ok = false; QGLWidget glWidget; if (glWidget.isValid() && glWidget.format().directRendering() diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp index 876b6a1365..98f66000f6 100644 --- a/tests/auto/other/modeltest/modeltest.cpp +++ b/tests/auto/other/modeltest/modeltest.cpp @@ -414,27 +414,27 @@ void ModelTest::data() // General Purpose roles that should return a QString QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert<QString> ( variant ) ); + QVERIFY( variant.canConvert<QString>() ); } variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert<QString> ( variant ) ); + QVERIFY( variant.canConvert<QString>() ); } variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert<QString> ( variant ) ); + QVERIFY( variant.canConvert<QString>() ); } // General Purpose roles that should return a QSize variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole ); if ( variant.isValid() ) { - QVERIFY( qVariantCanConvert<QSize> ( variant ) ); + QVERIFY( variant.canConvert<QSize>() ); } // General Purpose roles that should return a QFont QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole ); if ( fontVariant.isValid() ) { - QVERIFY( qVariantCanConvert<QFont> ( fontVariant ) ); + QVERIFY( fontVariant.canConvert<QFont>() ); } // Check that the alignment is one we know about @@ -447,12 +447,12 @@ void ModelTest::data() // General Purpose roles that should return a QColor QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole ); if ( colorVariant.isValid() ) { - QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) ); + QVERIFY( colorVariant.canConvert<QColor>() ); } colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole ); if ( colorVariant.isValid() ) { - QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) ); + QVERIFY( colorVariant.canConvert<QColor>() ); } // Check that the "check state" is one we know about. diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 2a6dc1d662..8c86a95c59 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -5,7 +5,7 @@ SUBDIRS=\ collections \ compiler \ exceptionsafety \ - exceptionsafety_objects \ + # exceptionsafety_objects \ # QObjectPrivate is not safe gestures \ headersclean \ lancelot \ @@ -42,5 +42,3 @@ wince*|!contains(QT_CONFIG, accessibility):SUBDIRS -= qaccessibility qdirectpainter !linux*-g++*:SUBDIRS -= exceptionsafety_objects - -mac: lancelot.CONFIG = no_check_target # QTBUG-22792 diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 388e6ab29d..0c224ad0a8 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -12,8 +12,6 @@ wince*: { DEPLOYMENT += accessneeded } -mac: CONFIG += insignificant_test # QTBUG-22812 - win32 { !*g++: include(../../../../src/3rdparty/iaccessible2/iaccessible2.pri) LIBS += -loleacc -loleaut32 -lole32 diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 977013ab8c..ba1e73a99b 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1747,6 +1747,9 @@ void tst_QAccessibility::mdiSubWindowTest() const QRect widgetGeometry = testWindow->contentsRect(); const QPoint globalWidgetPos = QPoint(globalPos.x() + widgetGeometry.x(), globalPos.y() + widgetGeometry.y()); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-22812", Abort); +#endif QCOMPARE(childRect(interface), QRect(globalWidgetPos, widgetGeometry.size())); // childAt diff --git a/tests/auto/other/qfocusevent/qfocusevent.pro b/tests/auto/other/qfocusevent/qfocusevent.pro index ee2cf22a6a..5f799291c6 100644 --- a/tests/auto/other/qfocusevent/qfocusevent.pro +++ b/tests/auto/other/qfocusevent/qfocusevent.pro @@ -2,4 +2,3 @@ CONFIG += testcase TARGET = tst_qfocusevent QT += widgets testlib SOURCES += tst_qfocusevent.cpp -mac: CONFIG += insignificant_test # QTBUG-22815 diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index 946003fc72..05a609c8a6 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -378,6 +378,9 @@ void tst_QFocusEvent::checkReason_ActiveWindow() #if defined(Q_OS_IRIX) QEXPECT_FAIL("", "IRIX requires explicit activateWindow(), so this test does not make any sense.", Abort); #endif +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-22815", Abort); +#endif QTRY_VERIFY(childFocusWidgetOne->focusInEventRecieved); QVERIFY(childFocusWidgetOne->focusInEventGotFocus); diff --git a/tests/auto/printsupport/kernel/qprinter/qprinter.pro b/tests/auto/printsupport/kernel/qprinter/qprinter.pro index ebf8edea32..d3abd1677a 100644 --- a/tests/auto/printsupport/kernel/qprinter/qprinter.pro +++ b/tests/auto/printsupport/kernel/qprinter/qprinter.pro @@ -3,4 +3,4 @@ TARGET = tst_qprinter QT += printsupport widgets testlib SOURCES += tst_qprinter.cpp -mac*:CONFIG+=insignificant_test +mac*:CONFIG+=insignificant_test # QTBUG-25292 diff --git a/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro index b0e69dca2e..f397f48bb8 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro +++ b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro @@ -5,5 +5,3 @@ SOURCES += tst_qprinterinfo.cpp QT += printsupport network testlib DEFINES += QT_USE_USING_NAMESPACE - -mac: CONFIG += insignificant_test # QTBUG-23060 diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 626c5049f0..fb2db21743 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2078,7 +2078,7 @@ void tst_QSqlDatabase::eventNotificationPSQL() QCOMPARE(spy.count(), 1); QList<QVariant> arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), procedureName); - QCOMPARE(qVariantValue<QSqlDriver::NotificationSource>(arguments.at(1)), QSqlDriver::SelfSource); + QCOMPARE(qvariant_cast<QSqlDriver::NotificationSource>(arguments.at(1)), QSqlDriver::SelfSource); QCOMPARE(qvariant_cast<QVariant>(arguments.at(2)).toString(), payload); QVERIFY_SQL(driver, unsubscribeFromNotification(procedureName)); } diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 559afc4ef4..4a0eab0f83 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -211,6 +211,8 @@ private slots: void QTBUG_5765(); void QTBUG_14132_data() { generic_data("QOCI"); } void QTBUG_14132(); + void QTBUG_18435_data() { generic_data("QODBC"); } + void QTBUG_18435(); void QTBUG_21884_data() { generic_data("QSQLITE"); } void QTBUG_21884(); void QTBUG_16967_data() { generic_data("QSQLITE"); } @@ -2801,9 +2803,9 @@ void tst_QSqlQuery::task_250026() data258.fill( 'A', 258 ); data1026.fill( 'A', 1026 ); QVERIFY_SQL( q, prepare( "insert into " + tableName + "(longfield) VALUES (:longfield)" ) ); - q.bindValue( "longfield", data258 ); + q.bindValue( ":longfield", data258 ); QVERIFY_SQL( q, exec() ); - q.bindValue( "longfield", data1026 ); + q.bindValue( ":longfield", data1026 ); QVERIFY_SQL( q, exec() ); QVERIFY_SQL( q, exec( "select * from " + tableName ) ); QVERIFY_SQL( q, next() ); @@ -2999,7 +3001,7 @@ void tst_QSqlQuery::QTBUG_551() q.bindValue(":outp", outLst, QSql::Out); QVERIFY_SQL(q, execBatch(QSqlQuery::ValuesAsColumns) ); - res_outLst = qVariantValue<QVariantList>(q.boundValues()[":outp"]); + res_outLst = qvariant_cast<QVariantList>(q.boundValues()[":outp"]); QCOMPARE(res_outLst[0].toString(), QLatin1String("1. Value is 0")); QCOMPARE(res_outLst[1].toString(), QLatin1String("2. Value is 1")); QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2")); @@ -3024,6 +3026,36 @@ void tst_QSqlQuery::QTBUG_14132() QCOMPARE(q.boundValue(0).toString(), QLatin1String("OUTSTRING")); } +void tst_QSqlQuery::QTBUG_18435() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + if (!db.driverName().startsWith("QODBC") || !tst_Databases::isSqlServer(db)) + return; + + QSqlQuery q(db); + QString procName(qTableName("qtbug_18435_proc", __FILE__)); + + q.exec("DROP PROCEDURE " + procName); + const QString stmt = + "CREATE PROCEDURE " + procName + " @key nvarchar(50) OUTPUT AS\n" + "BEGIN\n" + " SET NOCOUNT ON\n" + " SET @key = 'TEST'\n" + "END\n"; + + QVERIFY_SQL(q, exec(stmt)); + QVERIFY_SQL(q, prepare("{CALL "+ procName +"(?)}")); + const QString testStr = "0123"; + q.bindValue(0, testStr, QSql::Out); + QVERIFY_SQL(q, exec()); + QCOMPARE(q.boundValue(0).toString(), QLatin1String("TEST")); + + QVERIFY_SQL(q, exec("DROP PROCEDURE " + procName)); +} + void tst_QSqlQuery::QTBUG_5251() { QFETCH( QString, dbName ); @@ -3494,7 +3526,10 @@ void tst_QSqlQuery::aggregateFunctionTypes() // First test without any entries QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); QVERIFY(q.next()); - QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + if (db.driverName().startsWith("QSQLITE")) + QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + else + QCOMPARE(q.record().field(0).type(), QVariant::Int); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (1)")); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (2)")); @@ -3506,8 +3541,13 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY_SQL(q, exec("SELECT AVG(id) FROM " + tableName)); QVERIFY(q.next()); - QCOMPARE(q.value(0).toDouble(), 1.5); - QCOMPARE(q.record().field(0).type(), QVariant::Double); + if (db.driverName().startsWith("QSQLITE")) { + QCOMPARE(q.value(0).toDouble(), 1.5); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + } else { + QCOMPARE(q.value(0).toInt(), 1); + QCOMPARE(q.record().field(0).type(), QVariant::Int); + } QVERIFY_SQL(q, exec("SELECT COUNT(id) FROM " + tableName)); QVERIFY(q.next()); @@ -3529,12 +3569,15 @@ void tst_QSqlQuery::aggregateFunctionTypes() tst_Databases::safeDropTable( db, tableName ); QSqlQuery q(db); - QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id DOUBLE)")); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id REAL)")); // First test without any entries QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); QVERIFY(q.next()); - QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + if (db.driverName().startsWith("QSQLITE")) + QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + else + QCOMPARE(q.record().field(0).type(), QVariant::Double); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (1.5)")); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (2.5)")); @@ -3583,7 +3626,10 @@ void tst_QSqlQuery::aggregateFunctionTypes() QVERIFY_SQL(q, exec("SELECT MAX(txt) FROM " + tableName)); QVERIFY(q.next()); - QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + if (db.driverName().startsWith("QSQLITE")) + QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + else + QCOMPARE(q.record().field(0).type(), QVariant::String); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, txt) VALUES (1, 'lower')")); QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, txt) VALUES (2, 'upper')")); diff --git a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp index 33793c013d..1c1319630e 100644 --- a/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/sql/models/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -478,22 +478,23 @@ void tst_QSqlQueryModel::fetchMore() CHECK_DATABASE(db); QSqlQueryModel model; - QSignalSpy spy(&model, SIGNAL(rowsInserted(QModelIndex, int, int))); + QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset())); + QSignalSpy modelResetSpy(&model, SIGNAL(modelReset())); model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__), db)); int rowCount = model.rowCount(); - QCOMPARE(spy.value(0).value(1).toInt(), 0); - QCOMPARE(spy.value(0).value(2).toInt(), rowCount - 1); + QCOMPARE(modelAboutToBeResetSpy.count(), 1); + QCOMPARE(modelResetSpy.count(), 1); // If the driver doesn't return the query size fetchMore() causes the // model to grow and new signals are emitted + QSignalSpy rowsInsertedSpy(&model, SIGNAL(rowsInserted(QModelIndex, int, int))); if (!db.driver()->hasFeature(QSqlDriver::QuerySize)) { - spy.clear(); model.fetchMore(); int newRowCount = model.rowCount(); - QCOMPARE(spy.value(0).value(1).toInt(), rowCount); - QCOMPARE(spy.value(0).value(2).toInt(), newRowCount - 1); + QCOMPARE(rowsInsertedSpy.value(0).value(1).toInt(), rowCount); + QCOMPARE(rowsInsertedSpy.value(0).value(2).toInt(), newRowCount - 1); } } @@ -519,7 +520,8 @@ void tst_QSqlQueryModel::withSortFilterProxyModel() QTableView view; view.setModel(&proxy); - QSignalSpy modelRowsRemovedSpy(&model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); + QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset())); + QSignalSpy modelResetSpy(&model, SIGNAL(modelReset())); QSignalSpy modelRowsInsertedSpy(&model, SIGNAL(rowsInserted(const QModelIndex &, int, int))); model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db)); view.scrollToBottom(); @@ -528,19 +530,14 @@ void tst_QSqlQueryModel::withSortFilterProxyModel() QCOMPARE(proxy.rowCount(), 511); - // The second call to setQuery() clears the model by removing it's rows. - // Only 256 rows because that is what was cached. - QCOMPARE(modelRowsRemovedSpy.count(), 1); - QCOMPARE(modelRowsRemovedSpy.value(0).value(1).toInt(), 0); - QCOMPARE(modelRowsRemovedSpy.value(0).value(2).toInt(), 255); - - // The call to scrollToBottom() forces the model to fetch all rows, - // which will be done in two steps. - QCOMPARE(modelRowsInsertedSpy.count(), 2); - QCOMPARE(modelRowsInsertedSpy.value(0).value(1).toInt(), 0); - QCOMPARE(modelRowsInsertedSpy.value(0).value(2).toInt(), 255); - QCOMPARE(modelRowsInsertedSpy.value(1).value(1).toInt(), 256); - QCOMPARE(modelRowsInsertedSpy.value(1).value(2).toInt(), 510); + // setQuery() resets the model accompanied by begin and end signals + QCOMPARE(modelAboutToBeResetSpy.count(), 1); + QCOMPARE(modelResetSpy.count(), 1); + + // The call to scrollToBottom() forces the model to fetch additional rows. + QCOMPARE(modelRowsInsertedSpy.count(), 1); + QCOMPARE(modelRowsInsertedSpy.value(0).value(1).toInt(), 256); + QCOMPARE(modelRowsInsertedSpy.value(0).value(2).toInt(), 510); } // For task 155402: When the model is already empty when setQuery() is called @@ -553,22 +550,19 @@ void tst_QSqlQueryModel::setQuerySignalEmission() CHECK_DATABASE(db); QSqlQueryModel model; - QSignalSpy modelRowsAboutToBeRemovedSpy(&model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int))); - QSignalSpy modelRowsRemovedSpy(&model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); + QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset())); + QSignalSpy modelResetSpy(&model, SIGNAL(modelReset())); - // First select, the model was empty and no rows had to be removed! + // First select, the model was empty and no rows had to be removed, but model resets anyway. model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db)); - QCOMPARE(modelRowsAboutToBeRemovedSpy.count(), 0); - QCOMPARE(modelRowsRemovedSpy.count(), 0); + QCOMPARE(modelAboutToBeResetSpy.count(), 1); + QCOMPARE(modelResetSpy.count(), 1); // Second select, the model wasn't empty and two rows had to be removed! + // setQuery() resets the model accompanied by begin and end signals model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db)); - QCOMPARE(modelRowsAboutToBeRemovedSpy.count(), 1); - QCOMPARE(modelRowsAboutToBeRemovedSpy.value(0).value(1).toInt(), 0); - QCOMPARE(modelRowsAboutToBeRemovedSpy.value(0).value(2).toInt(), 1); - QCOMPARE(modelRowsRemovedSpy.count(), 1); - QCOMPARE(modelRowsRemovedSpy.value(0).value(1).toInt(), 0); - QCOMPARE(modelRowsRemovedSpy.value(0).value(2).toInt(), 1); + QCOMPARE(modelAboutToBeResetSpy.count(), 2); + QCOMPARE(modelResetSpy.count(), 2); } // For task 170783: When the query's result set is empty no rows should be inserted, diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index 2cea8b3546..89085df6c9 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -1338,39 +1338,13 @@ void tst_QSqlTableModel::setFilter() QCOMPARE(model.rowCount(), 1); QCOMPARE(model.data(model.index(0, 0)).toInt(), 1); - QSignalSpy rowsRemovedSpy(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy rowsAboutToBeRemovedSpy(&model, - SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy rowsInsertedSpy(&model, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy rowsAboutToBeInsertedSpy(&model, - SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset())); + QSignalSpy modelResetSpy(&model, SIGNAL(modelReset())); model.setFilter("id = 2"); // check the signals - QCOMPARE(rowsAboutToBeRemovedSpy.count(), 1); - QCOMPARE(rowsRemovedSpy.count(), 1); - QCOMPARE(rowsAboutToBeInsertedSpy.count(), 1); - QCOMPARE(rowsInsertedSpy.count(), 1); - QList<QVariant> args = rowsAboutToBeRemovedSpy.takeFirst(); - QCOMPARE(args.count(), 3); - QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), QModelIndex()); - QCOMPARE(args.at(1).toInt(), 0); - QCOMPARE(args.at(2).toInt(), 0); - args = rowsRemovedSpy.takeFirst(); - QCOMPARE(args.count(), 3); - QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), QModelIndex()); - QCOMPARE(args.at(1).toInt(), 0); - QCOMPARE(args.at(2).toInt(), 0); - args = rowsInsertedSpy.takeFirst(); - QCOMPARE(args.count(), 3); - QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), QModelIndex()); - QCOMPARE(args.at(1).toInt(), 0); - QCOMPARE(args.at(2).toInt(), 0); - args = rowsAboutToBeInsertedSpy.takeFirst(); - QCOMPARE(args.count(), 3); - QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), QModelIndex()); - QCOMPARE(args.at(1).toInt(), 0); - QCOMPARE(args.at(2).toInt(), 0); + QCOMPARE(modelAboutToBeResetSpy.count(), 1); + QCOMPARE(modelResetSpy.count(), 1); QCOMPARE(model.rowCount(), 1); QCOMPARE(model.data(model.index(0, 0)).toInt(), 2); @@ -1500,7 +1474,8 @@ void tst_QSqlTableModel::insertRecordsInLoop() record.setValue(1, "Testman"); record.setValue(2, 1); - QSignalSpy spyRowsRemoved(&model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); + QSignalSpy modelAboutToBeResetSpy(&model, SIGNAL(modelAboutToBeReset())); + QSignalSpy modelResetSpy(&model, SIGNAL(modelReset())); QSignalSpy spyRowsInserted(&model, SIGNAL(rowsInserted(const QModelIndex &, int, int))); for (int i = 0; i < 10; i++) { QVERIFY(model.insertRecord(model.rowCount(), record)); @@ -1509,18 +1484,9 @@ void tst_QSqlTableModel::insertRecordsInLoop() } model.submitAll(); // submitAll() calls select() which clears and repopulates the table - int firstRowIndex = 0, lastRowIndex = 12; - QCOMPARE(spyRowsRemoved.count(), 11); - // QSqlTableModel emits 10 signals for its 10 inserted rows - QCOMPARE(spyRowsRemoved.at(0).at(1).toInt(), lastRowIndex); - QCOMPARE(spyRowsRemoved.at(9).at(1).toInt(), firstRowIndex + 3); - // QSqlQueryModel emits 1 signal for its 3 rows - QCOMPARE(spyRowsRemoved.at(10).at(1).toInt(), firstRowIndex); - QCOMPARE(spyRowsRemoved.at(10).at(2).toInt(), firstRowIndex + 2); - - QCOMPARE(spyRowsInserted.at(10).at(1).toInt(), firstRowIndex); - QCOMPARE(spyRowsInserted.at(10).at(2).toInt(), lastRowIndex); - QCOMPARE(spyRowsInserted.count(), 11); + // model emits reset signals + QCOMPARE(modelAboutToBeResetSpy.count(), 1); + QCOMPARE(modelResetSpy.count(), 1); QCOMPARE(model.rowCount(), 13); QCOMPARE(model.columnCount(), 3); diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 78e18f9229..1bf016d6f5 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -847,10 +847,7 @@ void tst_Moc::testExtraDataForEnum() const QMetaObject *mobjUser = &EnumUserClass::staticMetaObject; QCOMPARE(mobjUser->enumeratorCount(), 0); - const QMetaObjectExtraData *extra = reinterpret_cast<const QMetaObjectExtraData *>(mobjUser->d.extradata); - QVERIFY(extra); - - const QMetaObject **objects = extra->objects; + const QMetaObject **objects = mobjUser->d.relatedMetaObjects; QVERIFY(objects); QVERIFY(objects[0] == mobjSource); QVERIFY(objects[1] == 0); @@ -863,13 +860,13 @@ void tst_Moc::namespaceTypeProperty() QByteArray ba = QByteArray("points"); QVariant v = tst.property(ba); QVERIFY(v.isValid()); - myNS::Points p = qVariantValue<myNS::Points>(v); + myNS::Points p = qvariant_cast<myNS::Points>(v); QCOMPARE(p.p1, 0xBEEF); QCOMPARE(p.p2, 0xBABE); p.p1 = 0xCAFE; p.p2 = 0x1EE7; - QVERIFY(tst.setProperty(ba, qVariantFromValue(p))); - myNS::Points pp = qVariantValue<myNS::Points>(tst.property(ba)); + QVERIFY(tst.setProperty(ba, QVariant::fromValue(p))); + myNS::Points pp = qvariant_cast<myNS::Points>(tst.property(ba)); QCOMPARE(p.p1, pp.p1); QCOMPARE(p.p2, pp.p2); } @@ -1184,16 +1181,16 @@ void tst_Moc::qprivateproperties() PrivatePropertyTest test; test.setProperty("foo", 1); - QCOMPARE(test.property("foo"), qVariantFromValue(1)); + QCOMPARE(test.property("foo"), QVariant::fromValue(1)); test.setProperty("bar", 2); - QCOMPARE(test.property("bar"), qVariantFromValue(2)); + QCOMPARE(test.property("bar"), QVariant::fromValue(2)); test.setProperty("plop", 3); - QCOMPARE(test.property("plop"), qVariantFromValue(3)); + QCOMPARE(test.property("plop"), QVariant::fromValue(3)); test.setProperty("baz", 4); - QCOMPARE(test.property("baz"), qVariantFromValue(4)); + QCOMPARE(test.property("baz"), QVariant::fromValue(4)); } diff --git a/tests/auto/widgets/dialogs/dialogs.pro b/tests/auto/widgets/dialogs/dialogs.pro index e74323a305..53e2338158 100644 --- a/tests/auto/widgets/dialogs/dialogs.pro +++ b/tests/auto/widgets/dialogs/dialogs.pro @@ -16,3 +16,5 @@ SUBDIRS=\ !contains(QT_CONFIG, private_tests): SUBDIRS -= \ qsidebar \ + +mac:qinputdialog.CONFIG += no_check_target # QTBUG-25496 diff --git a/tests/auto/widgets/dialogs/qdialog/qdialog.pro b/tests/auto/widgets/dialogs/qdialog/qdialog.pro index 779c10ed66..2c4d10dd0b 100644 --- a/tests/auto/widgets/dialogs/qdialog/qdialog.pro +++ b/tests/auto/widgets/dialogs/qdialog/qdialog.pro @@ -2,4 +2,3 @@ CONFIG += testcase TARGET = tst_qdialog QT += widgets testlib SOURCES += tst_qdialog.cpp -mac:CONFIG += insignificant_test # QTBUG-24977 diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 14c2be5bd8..a62c1a8f9a 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -504,7 +504,7 @@ void tst_QFiledialog::completer() // press 'keys' for the input for (int i = 0; i < input.count(); ++i) - QTest::keyPress(lineEdit, input[i].toAscii()); + QTest::keyPress(lineEdit, input[i].toLatin1()); QStringList expectedFiles; if (expected == -1) { @@ -1061,11 +1061,11 @@ void tst_QFiledialog::historyBack() QCOMPARE(backButton->isEnabled(), true); QCOMPARE(forwardButton->isEnabled(), true); QCOMPARE(spy.count(), 3); - QString currentPath = qVariantValue<QString>(spy.last().first()); + QString currentPath = qvariant_cast<QString>(spy.last().first()); QCOMPARE(model->index(currentPath), model->index(temp)); backButton->click(); - currentPath = qVariantValue<QString>(spy.last().first()); + currentPath = qvariant_cast<QString>(spy.last().first()); QCOMPARE(currentPath, home); QCOMPARE(backButton->isEnabled(), false); QCOMPARE(forwardButton->isEnabled(), true); @@ -1101,39 +1101,39 @@ void tst_QFiledialog::historyForward() backButton->click(); QCOMPARE(forwardButton->isEnabled(), true); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); forwardButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(desktop)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(desktop)); QCOMPARE(backButton->isEnabled(), true); QCOMPARE(forwardButton->isEnabled(), false); QCOMPARE(spy.count(), 4); backButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); QCOMPARE(backButton->isEnabled(), true); backButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(home)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(home)); QCOMPARE(backButton->isEnabled(), false); QCOMPARE(forwardButton->isEnabled(), true); QCOMPARE(spy.count(), 6); forwardButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); backButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(home)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(home)); QCOMPARE(spy.count(), 8); forwardButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); forwardButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(desktop)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(desktop)); backButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(temp)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(temp)); backButton->click(); - QCOMPARE(model->index(qVariantValue<QString>(spy.last().first())), model->index(home)); + QCOMPARE(model->index(qvariant_cast<QString>(spy.last().first())), model->index(home)); fd.setDirectory(desktop); QCOMPARE(forwardButton->isEnabled(), false); } diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 4a6f714a7c..d90c6f8851 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -568,7 +568,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot() // - No another dir with same start QString testDir; foreach (const QString &entry, entryList) { - if (entry.size() > 5 && QString(entry.toAscii()).compare(entry) == 0) { + if (entry.size() > 5 && QString(entry.toLatin1()).compare(entry) == 0) { bool invalid = false; for (int i = 0; i < 5; i++) { if (!entry.at(i).isLetter()) { @@ -605,7 +605,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) //I love testlib :D for (int i = 0; i < 5; i++) - QTest::keyClick(edit, testDir.at(i).toLower().toAscii() - 'a' + Qt::Key_A); + QTest::keyClick(edit, testDir.at(i).toLower().toLatin1() - 'a' + Qt::Key_A); #else QTest::keyClick(edit, Qt::Key_E); QTest::keyClick(edit, Qt::Key_T); diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index 6b2caf17d7..533014b1c9 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -160,12 +160,9 @@ class FriendlyFontDialog : public QFontDialog void tst_QFontDialog::task256466_wrongStyle() { -#ifdef Q_OS_MAC - QSKIP("Test crashes on Mac OS X, see QTBUG-24321"); -#endif - QFontDatabase fdb; FriendlyFontDialog dialog; + dialog.setOption(QFontDialog::DontUseNativeDialog); QListView *familyList = reinterpret_cast<QListView*>(dialog.d_func()->familyList); QListView *styleList = reinterpret_cast<QListView*>(dialog.d_func()->styleList); QListView *sizeList = reinterpret_cast<QListView*>(dialog.d_func()->sizeList); diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp index a38c2d070d..f6c10bc2e9 100644 --- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp @@ -110,7 +110,7 @@ void testTypingValue( sbox->selectAll(); for (int i = 0; i < value.size(); ++i) { const QChar valChar = value[i]; - _keyClick(static_cast<QWidget *>(sbox), valChar.toAscii()); // ### always guaranteed to work? + _keyClick(static_cast<QWidget *>(sbox), valChar.toLatin1()); // ### always guaranteed to work? if (sbox->hasAcceptableInput()) QVERIFY(okButton->isEnabled()); else @@ -123,7 +123,7 @@ void testTypingValue(QLineEdit *ledit, QPushButton *okButton, const QString &val ledit->selectAll(); for (int i = 0; i < value.size(); ++i) { const QChar valChar = value[i]; - _keyClick(ledit, valChar.toAscii()); // ### always guaranteed to work? + _keyClick(ledit, valChar.toLatin1()); // ### always guaranteed to work? QVERIFY(ledit->hasAcceptableInput()); QVERIFY(okButton->isEnabled()); } diff --git a/tests/auto/widgets/effects/qgraphicseffect/qgraphicseffect.pro b/tests/auto/widgets/effects/qgraphicseffect/qgraphicseffect.pro index d21ff564dd..177d1a7c42 100644 --- a/tests/auto/widgets/effects/qgraphicseffect/qgraphicseffect.pro +++ b/tests/auto/widgets/effects/qgraphicseffect/qgraphicseffect.pro @@ -5,4 +5,3 @@ QT += widgets widgets-private testlib QT += core-private gui-private SOURCES += tst_qgraphicseffect.cpp -CONFIG += parallel_test diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 97feb642dc..7687fd4b67 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -167,7 +167,7 @@ public: { setContentsMargins( 0,0,0,0 ); if (name.isEmpty()) - setData(0, QString::fromAscii("w%1").arg(quintptr(this))); + setData(0, QString::fromLatin1("w%1").arg(quintptr(this))); else setData(0, name); } @@ -1711,7 +1711,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() // Create dummy widgets QList<QGraphicsWidget *> widgets; for (int i = 0; i < widgetCount; ++i) { - TestWidget *w = new TestWidget(0, QString::fromAscii("W%1").arg(i)); + TestWidget *w = new TestWidget(0, QString::fromLatin1("W%1").arg(i)); widgets << w; } diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 51ce7f909c..5da996bd59 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -458,7 +458,7 @@ void tst_QGraphicsGridLayout::addItem_data() int column = b; int rowSpan = c; int columnSpan = d; - QString name = QString::fromAscii("(%1,%2,%3,%4").arg(a).arg(b).arg(c).arg(d); + QString name = QString::fromLatin1("(%1,%2,%3,%4").arg(a).arg(b).arg(c).arg(d); Qt::Alignment alignment = Qt::AlignLeft; QTest::newRow(name.toLatin1()) << row << column << rowSpan << columnSpan << alignment; }}}} @@ -1114,7 +1114,7 @@ void tst_QGraphicsGridLayout::itemAt() if (i >= 0 && i < layout->count()) { QVERIFY(layout->itemAt(i)); } else { - QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::itemAt: invalid index %1").arg(i).toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QGraphicsGridLayout::itemAt: invalid index %1").arg(i).toLatin1().constData()); QCOMPARE(layout->itemAt(i), static_cast<QGraphicsLayoutItem*>(0)); } } @@ -1146,7 +1146,7 @@ void tst_QGraphicsGridLayout::removeAt() layout->removeAt(0); QCOMPARE(item0->parentLayoutItem(), static_cast<QGraphicsLayoutItem *>(0)); QCOMPARE(layout->count(), 0); - QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::removeAt: invalid index 0").toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QGraphicsGridLayout::removeAt: invalid index 0").toLatin1().constData()); layout->removeAt(0); QCOMPARE(layout->count(), 0); delete widget; @@ -1169,11 +1169,11 @@ void tst_QGraphicsGridLayout::removeItem() QCOMPARE(l->count(), 4); // Avoid crashing. Note that the warning message might change in the future. - QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData()); l->removeItem(0); QCOMPARE(l->count(), 4); - QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData()); l->removeItem(new QGraphicsWidget); QCOMPARE(l->count(), 4); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 639a1f61a9..a6f846045f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -2219,7 +2219,7 @@ void tst_QGraphicsItem::setMatrix() QApplication::instance()->processEvents(); QCOMPARE(spy.count(), 3); - QList<QRectF> rlist = qVariantValue<QList<QRectF> >(spy.last().at(0)); + QList<QRectF> rlist = qvariant_cast<QList<QRectF> >(spy.last().at(0)); QCOMPARE(rlist.size(), 3); QCOMPARE(rlist.at(0), rotatedRect); // From item.setMatrix() (clearing rotated rect) @@ -4450,13 +4450,13 @@ protected: break; case QGraphicsItem::ItemMatrixChange: { QVariant variant; - qVariantSetValue<QMatrix>(variant, matrix()); + variant.setValue<QMatrix>(matrix()); oldValues << variant; } break; case QGraphicsItem::ItemTransformChange: { QVariant variant; - qVariantSetValue<QTransform>(variant, transform()); + variant.setValue<QTransform>(transform()); oldValues << variant; } break; @@ -4478,7 +4478,7 @@ protected: case QGraphicsItem::ItemSelectedHasChanged: break; case QGraphicsItem::ItemParentChange: - oldValues << qVariantFromValue<void *>(parentItem()); + oldValues << QVariant::fromValue<void *>(parentItem()); break; case QGraphicsItem::ItemParentHasChanged: break; @@ -4489,11 +4489,11 @@ protected: oldValues << children().size(); break; case QGraphicsItem::ItemSceneChange: - oldValues << qVariantFromValue<QGraphicsScene *>(scene()); + oldValues << QVariant::fromValue<QGraphicsScene *>(scene()); if (itemSceneChangeTargetScene - && qVariantValue<QGraphicsScene *>(value) - && itemSceneChangeTargetScene != qVariantValue<QGraphicsScene *>(value)) { - return qVariantFromValue<QGraphicsScene *>(itemSceneChangeTargetScene); + && qvariant_cast<QGraphicsScene *>(value) + && itemSceneChangeTargetScene != qvariant_cast<QGraphicsScene *>(value)) { + return QVariant::fromValue<QGraphicsScene *>(itemSceneChangeTargetScene); } return value; case QGraphicsItem::ItemSceneHasChanged: @@ -4573,17 +4573,17 @@ void tst_QGraphicsItem::itemChange() } { // ItemMatrixChange / ItemTransformHasChanged - qVariantSetValue<QMatrix>(tester.itemChangeReturnValue, QMatrix().rotate(90)); + tester.itemChangeReturnValue.setValue<QMatrix>(QMatrix().rotate(90)); tester.setMatrix(QMatrix().translate(50, 0), true); ++changeCount; // notification sent too QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(int(tester.changes.at(tester.changes.size() - 2)), int(QGraphicsItem::ItemMatrixChange)); QCOMPARE(int(tester.changes.last()), int(QGraphicsItem::ItemTransformHasChanged)); - QCOMPARE(qVariantValue<QMatrix>(tester.values.at(tester.values.size() - 2)), + QCOMPARE(qvariant_cast<QMatrix>(tester.values.at(tester.values.size() - 2)), QMatrix().translate(50, 0)); QCOMPARE(tester.values.last(), QVariant(QTransform(QMatrix().rotate(90)))); QVariant variant; - qVariantSetValue<QMatrix>(variant, QMatrix()); + variant.setValue<QMatrix>(QMatrix()); QCOMPARE(tester.oldValues.last(), variant); QCOMPARE(tester.matrix(), QMatrix().rotate(90)); } @@ -4593,19 +4593,19 @@ void tst_QGraphicsItem::itemChange() ++changeCount; // notification sent too // ItemTransformChange / ItemTransformHasChanged - qVariantSetValue<QTransform>(tester.itemChangeReturnValue, QTransform().rotate(90)); + tester.itemChangeReturnValue.setValue<QTransform>(QTransform().rotate(90)); tester.translate(50, 0); ++changeCount; // notification sent too ++changeCount; QCOMPARE(tester.changes.size(), changeCount); QCOMPARE(tester.changes.at(tester.changes.size() - 2), QGraphicsItem::ItemTransformChange); QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemTransformHasChanged); - QCOMPARE(qVariantValue<QTransform>(tester.values.at(tester.values.size() - 2)), + QCOMPARE(qvariant_cast<QTransform>(tester.values.at(tester.values.size() - 2)), QTransform().translate(50, 0)); - QCOMPARE(qVariantValue<QTransform>(tester.values.at(tester.values.size() - 1)), + QCOMPARE(qvariant_cast<QTransform>(tester.values.at(tester.values.size() - 1)), QTransform().rotate(90)); QVariant variant; - qVariantSetValue<QTransform>(variant, QTransform()); + variant.setValue<QTransform>(QTransform()); QCOMPARE(tester.oldValues.last(), variant); QCOMPARE(tester.transform(), QTransform().rotate(90)); } @@ -4690,9 +4690,9 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.changes.size(), changeCount); QCOMPARE(tester.changes.at(tester.changes.size() - 2), QGraphicsItem::ItemFlagsChange); QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemFlagsHaveChanged); - QVariant expectedFlags = qVariantFromValue<quint32>(QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges)); + QVariant expectedFlags = QVariant::fromValue<quint32>(QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges)); QCOMPARE(tester.values.at(tester.values.size() - 2), expectedFlags); - QCOMPARE(tester.values.at(tester.values.size() - 1), qVariantFromValue<quint32>((quint32)QGraphicsItem::ItemIsSelectable)); + QCOMPARE(tester.values.at(tester.values.size() - 1), QVariant::fromValue<quint32>((quint32)QGraphicsItem::ItemIsSelectable)); } { // ItemSelectedChange @@ -4739,12 +4739,12 @@ void tst_QGraphicsItem::itemChange() } { // ItemParentChange - qVariantSetValue<QGraphicsItem *>(tester.itemChangeReturnValue, 0); + tester.itemChangeReturnValue.setValue<QGraphicsItem *>(0); tester.setParentItem(&testerHelper); QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(tester.changes.last(), QGraphicsItem::ItemParentChange); - QCOMPARE(qVariantValue<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper); - QCOMPARE(qVariantValue<QGraphicsItem *>(tester.oldValues.last()), (QGraphicsItem *)0); + QCOMPARE(qvariant_cast<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper); + QCOMPARE(qvariant_cast<QGraphicsItem *>(tester.oldValues.last()), (QGraphicsItem *)0); QCOMPARE(tester.parentItem(), (QGraphicsItem *)0); } { @@ -4771,14 +4771,14 @@ void tst_QGraphicsItem::itemChange() testerHelper.setParentItem(&tester); QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(tester.changes.last(), QGraphicsItem::ItemChildAddedChange); - QCOMPARE(qVariantValue<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper); + QCOMPARE(qvariant_cast<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper); } { // ItemChildRemovedChange 1 testerHelper.setParentItem(0); QCOMPARE(tester.changes.size(), ++changeCount); QCOMPARE(tester.changes.last(), QGraphicsItem::ItemChildRemovedChange); - QCOMPARE(qVariantValue<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper); + QCOMPARE(qvariant_cast<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper); // ItemChildRemovedChange 1 ItemChangeTester *test = new ItemChangeTester; @@ -4819,10 +4819,10 @@ void tst_QGraphicsItem::itemChange() ItemChangeTester *child = new ItemChangeTester; child->setParentItem(&parent); QCOMPARE(parent.changes.last(), QGraphicsItem::ItemChildAddedChange); - QCOMPARE(qVariantValue<QGraphicsItem *>(parent.values.last()), (QGraphicsItem *)child); + QCOMPARE(qvariant_cast<QGraphicsItem *>(parent.values.last()), (QGraphicsItem *)child); delete child; QCOMPARE(parent.changes.last(), QGraphicsItem::ItemChildRemovedChange); - QCOMPARE(qVariantValue<QGraphicsItem *>(parent.values.last()), (QGraphicsItem *)child); + QCOMPARE(qvariant_cast<QGraphicsItem *>(parent.values.last()), (QGraphicsItem *)child); } { // !!! Note: If this test crashes because of double-deletion, there's @@ -4841,8 +4841,8 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemSceneHasChanged); // Item's old value was 0 // Item's current value is scene - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)0); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.last()), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.last()), (QGraphicsScene *)&scene); scene2.addItem(&tester); ++changeCount; // ItemSceneChange (0) was: (scene) ++changeCount; // ItemSceneHasChanged (0) @@ -4858,16 +4858,16 @@ void tst_QGraphicsItem::itemChange() // Item's last old value was scene // Item's last current value is 0 - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.oldValues.at(tester.oldValues.size() - 2)), (QGraphicsScene *)&scene); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.oldValues.at(tester.oldValues.size() - 1)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 4)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene2); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.at(tester.oldValues.size() - 2)), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.at(tester.oldValues.size() - 1)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 4)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene2); // Item's last old value was 0 // Item's last current value is scene2 - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)0); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.last()), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.last()), (QGraphicsScene *)&scene2); scene2.removeItem(&tester); ++changeCount; // ItemSceneChange (0) was: (scene2) @@ -4879,9 +4879,9 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemSceneHasChanged); // Item's last old value was scene2 // Item's last current value is 0 - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)&scene2); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)0); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)0); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)0); tester.itemSceneChangeTargetScene = &scene; scene2.addItem(&tester); @@ -4890,9 +4890,9 @@ void tst_QGraphicsItem::itemChange() ++changeCount; // ItemSceneHasChanged (scene) QCOMPARE(tester.values.size(), changeCount); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)&scene2); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene); - QCOMPARE(qVariantValue<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)&scene2); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene); + QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene); QCOMPARE(tester.scene(), &scene); tester.itemSceneChangeTargetScene = 0; diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/qgraphicsproxywidget.pro b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/qgraphicsproxywidget.pro index f2bd7bde70..7fd6db1dd6 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/qgraphicsproxywidget.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/qgraphicsproxywidget.pro @@ -6,7 +6,4 @@ QT += core-private gui-private SOURCES += tst_qgraphicsproxywidget.cpp -# ### fixme: QTBUG-20756 crashes on xcb -contains(QT_CONFIG,xcb):CONFIG+=insignificant_test - -win32:CONFIG += insignificant_test # QTBUG-24294 +contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-25294 diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index fef21c19f7..2b143c5d98 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -1498,6 +1498,9 @@ void tst_QGraphicsProxyWidget::scrollUpdate() // QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2) // QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2), // intersected with the above update. +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24294", Abort); +#endif QCOMPARE(view.paintEventRegion.rects(), QVector<QRect>() << QRect(0, 0, 200, 12) << QRect(0, 12, 102, 10)); QCOMPARE(widget->npaints, 2); @@ -2472,6 +2475,9 @@ void tst_QGraphicsProxyWidget::popup_basic() QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24294", Abort); +#endif QTRY_COMPARE(box->pos(), QPoint()); QCOMPARE(proxy->childItems().count(), 1); @@ -3376,11 +3382,13 @@ void tst_QGraphicsProxyWidget::updateAndDelete() // Update and hide. proxy->update(); proxy->hide(); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23700", Abort); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24294", Abort); #endif - QTRY_COMPARE(view.npaints, 1); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23700", Continue); +#endif QCOMPARE(view.paintEventRegion, expectedRegion); proxy->show(); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro index c0a9075d10..8a084472b8 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro @@ -17,5 +17,3 @@ wince* { DEPLOYMENT += rootFiles renderFiles DEFINES += SRCDIR=\\\".\\\" } - -win32:CONFIG += insignificant_test # QTBUG-24295 diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index df529c6095..3686619fea 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -2830,7 +2830,7 @@ void tst_QGraphicsScene::update() // Check that the update region is correct QCOMPARE(spy.count(), 1); QRectF region; - foreach (QRectF rectF, qVariantValue<QList<QRectF> >(spy.at(0).at(0))) + foreach (QRectF rectF, qvariant_cast<QList<QRectF> >(spy.at(0).at(0))) region |= rectF; QCOMPARE(region, QRectF(-100, -100, 200, 200)); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro index 59ad89ed1f..20cff5500a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro @@ -6,7 +6,3 @@ QT += core-private gui-private SOURCES += tst_qgraphicsview.cpp tst_qgraphicsview_2.cpp DEFINES += QT_NO_CAST_TO_ASCII - -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG+=insignificant_test # QTBUG-16063 - -win32|mac:CONFIG += insignificant_test # QTBUG-24296 diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 1838977749..156d815765 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -3423,6 +3423,9 @@ void tst_QGraphicsView::moveItemWhileScrolling() int a = adjustForAntialiasing ? 2 : 1; expectedRegion += QRect(40, 50, 10, 10).adjusted(-a, -a, a, a); expectedRegion += QRect(40, 60, 10, 10).adjusted(-a, -a, a, a); +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24296", Abort); +#endif COMPARE_REGIONS(view.lastPaintedRegion, expectedRegion); } @@ -4386,10 +4389,8 @@ void tst_QGraphicsView::task259503_scrollingArtifacts() if (itSTimeToTest) { -// qDebug() << event->region(); -// qDebug() << updateRegion; -#ifndef Q_OS_MAC - QEXPECT_FAIL("", "The event region doesn't include the original item position region. See QTBUG-4416", Continue); +#ifndef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-24296", Continue); #endif QCOMPARE(event->region(), updateRegion); } diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/qgraphicswidget.pro b/tests/auto/widgets/graphicsview/qgraphicswidget/qgraphicswidget.pro index 2fc45b48de..6acb63089e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/qgraphicswidget.pro +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/qgraphicswidget.pro @@ -6,4 +6,4 @@ QT += core-private gui-private SOURCES += tst_qgraphicswidget.cpp -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG += insignificant_test # QTBUG-23616 +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = lucid ]"):DEFINES+=UBUNTU_LUCID # QTBUG-20778 diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 3c98f8936c..7a5aabe714 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1515,7 +1515,7 @@ void tst_QGraphicsWidget::setTabOrderAndReparent() for (i = 1; i < 4; ++i) { QGraphicsWidget *wid = new QGraphicsWidget; wid->setFocusPolicy(Qt::StrongFocus); - wid->setData(0, QString::fromAscii("w%1").arg(i)); + wid->setData(0, QString::fromLatin1("w%1").arg(i)); scene.addItem(wid); if (i == 1) w1 = wid; @@ -1555,7 +1555,7 @@ void tst_QGraphicsWidget::setTabOrderAndReparent() for (i = 1; i < 5; ++i) { QGraphicsWidget *wid = new QGraphicsWidget; wid->setFocusPolicy(Qt::StrongFocus); - wid->setData(0, QString::fromAscii("w%1").arg(i)); + wid->setData(0, QString::fromLatin1("w%1").arg(i)); scene.addItem(wid); if (i == 1) w1 = wid; @@ -3191,7 +3191,7 @@ void tst_QGraphicsWidget::initialShow2() view.show(); QTest::qWaitForWindowShown(&view); -#ifndef Q_OS_MAC +#if defined(Q_OS_WIN) || defined(UBUNTU_LUCID) QEXPECT_FAIL("", "QTBUG-20778", Abort); #endif QTRY_COMPARE(widget->repaints, expectedRepaintCount); @@ -3211,11 +3211,11 @@ void tst_QGraphicsWidget::itemChangeEvents() break; } case QEvent::ParentAboutToChange: { - valueDuringEvents.insert(QEvent::ParentAboutToChange, qVariantFromValue(parentItem())); + valueDuringEvents.insert(QEvent::ParentAboutToChange, QVariant::fromValue(parentItem())); break; } case QEvent::ParentChange: { - valueDuringEvents.insert(QEvent::ParentChange, qVariantFromValue(parentItem())); + valueDuringEvents.insert(QEvent::ParentChange, QVariant::fromValue(parentItem())); break; } case QEvent::CursorChange: { @@ -3252,10 +3252,10 @@ void tst_QGraphicsWidget::itemChangeEvents() TestGraphicsWidget *item = new TestGraphicsWidget; item->setParentItem(parent); // ParentAboutToChange should be triggered before the parent has changed - QTRY_COMPARE(qVariantValue<QGraphicsItem *>(item->valueDuringEvents.value(QEvent::ParentAboutToChange)), + QTRY_COMPARE(qvariant_cast<QGraphicsItem *>(item->valueDuringEvents.value(QEvent::ParentAboutToChange)), static_cast<QGraphicsItem *>(0)); // ParentChange should be triggered after the parent has changed - QTRY_COMPARE(qVariantValue<QGraphicsItem *>(item->valueDuringEvents.value(QEvent::ParentChange)), + QTRY_COMPARE(qvariant_cast<QGraphicsItem *>(item->valueDuringEvents.value(QEvent::ParentChange)), static_cast<QGraphicsItem *>(parent)); // ShowEvent should be triggered before the item is shown diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 1518403a64..3846433e29 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -1545,7 +1545,7 @@ public: return QVariant(); } if (role == Qt::DisplayRole) { - return QString::fromAscii("%1,%2").arg(index.row()).arg(index.column()); + return QString::fromLatin1("%1,%2").arg(index.row()).arg(index.column()); } return QVariant(); } diff --git a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro index d1a7686637..d90f6fd154 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro +++ b/tests/auto/widgets/itemviews/qitemdelegate/qitemdelegate.pro @@ -4,5 +4,3 @@ QT += widgets testlib SOURCES += tst_qitemdelegate.cpp win32:!wince*: LIBS += -lUser32 - -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG+=insignificant_test # QTBUG-23637 diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 9bb08edcce..be649db9d8 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -1277,7 +1277,7 @@ void tst_QListView::scrollBarRanges() QStringListModel model(&lv); QStringList list; for (int i = 0; i < rowCount; ++i) - list << QString::fromAscii("Item %1").arg(i); + list << QString::fromLatin1("Item %1").arg(i); model.setStringList(list); lv.setModel(&model); @@ -1375,7 +1375,7 @@ void tst_QListView::scrollBarAsNeeded() QStringList list; int i; for (i = 0; i < rowCounts[r]; ++i) - list << QString::fromAscii("Item %1").arg(i); + list << QString::fromLatin1("Item %1").arg(i); model.setStringList(list); QApplication::processEvents(); @@ -1383,7 +1383,7 @@ void tst_QListView::scrollBarAsNeeded() QStringList replacement; for (i = 0; i < itemCount; ++i) { - replacement << QString::fromAscii("Item %1").arg(i); + replacement << QString::fromLatin1("Item %1").arg(i); } model.setStringList(replacement); @@ -2059,7 +2059,7 @@ void tst_QListView::taskQTBUG_12308_wrongFlowLayout() QListWidgetItem *item = new QListWidgetItem(); item->setText(QString("Item %L1").arg(i)); lw.addItem(item); - if (!item->text().contains(QString::fromAscii("1"))) + if (!item->text().contains(QString::fromLatin1("1"))) item->setHidden(true); } lw.show(); diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 35e13e2f0a..afc24cd493 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -1667,6 +1667,8 @@ void tst_QListWidget::QTBUG14363_completerWithAnyKeyPressedEditTriggers() listWidget.show(); listWidget.setCurrentItem(item); QTest::qWaitForWindowShown(&listWidget); + listWidget.setFocus(); + QCOMPARE(qApp->focusWidget(), &listWidget); QTest::keyClick(listWidget.viewport(), Qt::Key_C); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index e1f175ad1b..6c082fe35f 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -210,6 +210,8 @@ private slots: void indexRowSizeHint(); void addRowsWhileSectionsAreHidden(); void filterProxyModelCrash(); + void renderToPixmap_data(); + void renderToPixmap(); void styleOptionViewItem(); void keyboardNavigationWithDisabled(); @@ -2125,12 +2127,12 @@ void tst_QTreeView::resizeColumnToContents() for (int r = 0; r < model.rowCount(); ++r) { for (int c = 0; c < model.columnCount(); ++c) { QModelIndex idx = model.index(r, c); - model.setData(idx, QString::fromAscii("%1,%2").arg(r).arg(c) ); + model.setData(idx, QString::fromLatin1("%1,%2").arg(r).arg(c) ); model.insertColumns(0, 2, idx); model.insertRows(0, 6, idx); for (int i = 0; i < 6; ++i) { for (int j = 0; j < 2 ; ++j) { - model.setData(model.index(i, j, idx), QString::fromAscii("child%1%2").arg(i).arg(j)); + model.setData(model.index(i, j, idx), QString::fromLatin1("child%1%2").arg(i).arg(j)); } } } @@ -2890,6 +2892,37 @@ void tst_QTreeView::filterProxyModelCrash() view.repaint(); //used to crash } +void tst_QTreeView::renderToPixmap_data() +{ + QTest::addColumn<int>("row"); + QTest::newRow("row-0") << 0; + QTest::newRow("row-1") << 1; +} + +void tst_QTreeView::renderToPixmap() +{ + QFETCH(int, row); + PublicView view; + QStandardItemModel model; + + model.appendRow(new QStandardItem("Spanning")); + model.appendRow(QList<QStandardItem*>() << new QStandardItem("Not") << new QStandardItem("Spanning")); + + view.setModel(&model); + view.setFirstColumnSpanned(0, QModelIndex(), true); + +#ifdef QT_BUILD_INTERNAL + { + // We select the index at row=0 because it spans the + // column (regression test for an assert) + // We select the index at row=1 for coverage. + QItemSelection sel(model.index(row,0), model.index(row,1)); + QRect rect; + view.aiv_priv()->renderToPixmap(sel.indexes(), &rect); + } +#endif +} + void tst_QTreeView::styleOptionViewItem() { class MyDelegate : public QStyledItemDelegate @@ -2990,6 +3023,22 @@ void tst_QTreeView::styleOptionViewItem() view.setFirstColumnSpanned(2, QModelIndex(), true); view.setAlternatingRowColors(true); +#ifdef QT_BUILD_INTERNAL + { + // Test the rendering to pixmap before painting the widget. + // The rendering to pixmap should not depend on having been + // painted already yet. + delegate.count = 0; + QItemSelection sel(model.index(0,0), model.index(0,modelColumns-1)); + QRect rect; + view.aiv_priv()->renderToPixmap(sel.indexes(), &rect); + if (delegate.count != visibleColumns) { + qDebug() << rect << view.rect() << view.isVisible(); + } + QTRY_COMPARE(delegate.count, visibleColumns); + } +#endif + delegate.count = 0; delegate.allCollapsed = true; view.showMaximized(); @@ -3011,7 +3060,10 @@ void tst_QTreeView::styleOptionViewItem() QItemSelection sel(model.index(0,0), model.index(0,modelColumns-1)); QRect rect; view.aiv_priv()->renderToPixmap(sel.indexes(), &rect); - QTRY_VERIFY(delegate.count == visibleColumns); + if (delegate.count != visibleColumns) { + qDebug() << rect << view.rect() << view.isVisible(); + } + QTRY_COMPARE(delegate.count, visibleColumns); #endif //test dynamic models diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index cf909b7e87..e1c245d9d1 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -17,5 +17,3 @@ SUBDIRS=\ qshortcut \ SUBDIRS -= qsound - -mac: qwidget.CONFIG += no_check_target # crashes, see QTBUG-23695 diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 91ecbf23a2..288e41c6ef 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -605,8 +605,6 @@ public slots: void tst_QApplication::quitOnLastWindowClosed() { -#ifndef Q_OS_MAC - // Test hangs on Mac OS X, see QTBUG-24319 { int argc = 0; QApplication app(argc, 0, QApplication::GuiServer); @@ -621,7 +619,6 @@ void tst_QApplication::quitOnLastWindowClosed() // lastWindowClosed() signal should only be sent after the last dialog is closed QCOMPARE(appSpy.count(), 2); } -#endif { int argc = 0; QApplication app(argc, 0, QApplication::GuiServer); @@ -1469,8 +1466,8 @@ void tst_QApplication::focusChanged() QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse) QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).count(), 2); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &le1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == 0); @@ -1479,8 +1476,8 @@ void tst_QApplication::focusChanged() pb1.setFocus(); QCOMPARE(spy.count(), 1); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &pb1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le1); @@ -1488,8 +1485,8 @@ void tst_QApplication::focusChanged() lb1.setFocus(); QCOMPARE(spy.count(), 1); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &lb1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb1); @@ -1497,8 +1494,8 @@ void tst_QApplication::focusChanged() lb1.clearFocus(); QCOMPARE(spy.count(), 1); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == 0); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &lb1); @@ -1516,8 +1513,8 @@ void tst_QApplication::focusChanged() parent2.show(); QApplication::setActiveWindow(&parent2); // needs this on twm (focus follows mouse) QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows - old = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(0)); - now = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(1)); + old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0)); + now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == 0); @@ -1550,8 +1547,8 @@ void tst_QApplication::focusChanged() QVERIFY(now == QApplication::focusWidget()); } else { QVERIFY(spy.count() > 0); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &pb2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); @@ -1564,8 +1561,8 @@ void tst_QApplication::focusChanged() } else { tab.simulate(now); QVERIFY(spy.count() > 0); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb2); @@ -1578,8 +1575,8 @@ void tst_QApplication::focusChanged() } else { backtab.simulate(now); QVERIFY(spy.count() > 0); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &pb2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); @@ -1594,8 +1591,8 @@ void tst_QApplication::focusChanged() } else { backtab.simulate(now); QVERIFY(spy.count() > 0); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb2); @@ -1608,8 +1605,8 @@ void tst_QApplication::focusChanged() QVERIFY(now == QApplication::focusWidget()); } else { QVERIFY(spy.count() > 0); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &pb2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); @@ -1617,8 +1614,8 @@ void tst_QApplication::focusChanged() click.simulate(old); QVERIFY(spy.count() > 0); - old = qVariantValue<QWidget*>(spy.at(0).at(0)); - now = qVariantValue<QWidget*>(spy.at(0).at(1)); + old = qvariant_cast<QWidget*>(spy.at(0).at(0)); + now = qvariant_cast<QWidget*>(spy.at(0).at(1)); QVERIFY(now == &le2); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &pb2); @@ -1632,10 +1629,10 @@ void tst_QApplication::focusChanged() //on windows, the change of focus is made in 2 steps //(the focusChanged SIGNAL is emitted twice) if (spy.count()==1) - old = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(0)); + old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0)); else - old = qVariantValue<QWidget*>(spy.at(spy.count()-2).at(0)); - now = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(1)); + old = qvariant_cast<QWidget*>(spy.at(spy.count()-2).at(0)); + now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1)); QVERIFY(now == &le1); QVERIFY(now == QApplication::focusWidget()); QVERIFY(old == &le2); diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index c43ea065f3..6b424ab4b4 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -540,7 +540,7 @@ public: } private: void init(int numPixels = -1){ - setText(QString::fromAscii("(%1,%2)").arg(sh.width()).arg(sh.height())); + setText(QString::fromLatin1("(%1,%2)").arg(sh.width()).arg(sh.height())); setFrameStyle(QFrame::Box | QFrame::Plain); setNumberOfPixels(numPixels); } @@ -797,12 +797,12 @@ void tst_QGridLayout::minMaxSize_data() << SizeInfo(QPoint(10, 10), QSize( 90, 90), QSize(100,100)) << SizeInfo(QPoint(10 + 100 + 1, 10), QSize( 90, 90)) ); - QTest::newRow("2x1 grid, extend to minimumSize, motif") << QString::fromAscii("motif") << 2 << 1 + QTest::newRow("2x1 grid, extend to minimumSize, motif") << QString::fromLatin1("motif") << 2 << 1 << int(QSizePolicy::Preferred) << QSize() << (SizeInfoList() << SizeInfo(QPoint(11, 11), QSize( 90, 90), QSize(100,100)) << SizeInfo(QPoint(11 + 100 + 6, 11), QSize( 90, 90)) ); - QTest::newRow("2x1 grid, extend to minimumSize, windows") << QString::fromAscii("windows") << 2 << 1 + QTest::newRow("2x1 grid, extend to minimumSize, windows") << QString::fromLatin1("windows") << 2 << 1 << int(QSizePolicy::Preferred) << QSize() << (SizeInfoList() << SizeInfo(QPoint(11, 11), QSize( 90, 90), QSize(100,100)) << SizeInfo(QPoint(11 + 100 + 6, 11), QSize( 90, 90)) @@ -1430,7 +1430,7 @@ void tst_QGridLayout::layoutSpacingImplementation_data() w->setLayout(layout); int pw = up->sizeHint().width(); int ph = up->sizeHint().height(); - QByteArray testName = QString::fromAscii("arrowpad with %1 empty rows, %2 empty columns").arg(yoff).arg(xoff).toLatin1(); + QByteArray testName = QString::fromLatin1("arrowpad with %1 empty rows, %2 empty columns").arg(yoff).arg(xoff).toLatin1(); QTest::newRow(testName.data()) << w << (PointList() << QPoint(0 + pw + 5, 3) diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 61efb6e3f3..971f60bb3e 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -580,8 +580,8 @@ void tst_QShortcut::text_data() Qt::UNICODE_ACCEL + Qt::Key_K */ /* see comments above on the #ifdef'ery */ - QTest::newRow("T06 - slot1") << SetupAccel << TriggerSlot1 << QString("\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; - QTest::newRow("T07 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift+\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("T06 - slot1") << SetupAccel << TriggerSlot1 << QString::fromLatin1("\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; + QTest::newRow("T07 - slot2") << SetupAccel << TriggerSlot2 << QString::fromLatin1("Shift+\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T08 - slot2") << SetupAccel << TriggerSlot1 << QString("K") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; QTest::newRow("T:Qt::Key_aring") << TestAccel << NoWidget << QString("") << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString("") << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered; @@ -1204,25 +1204,25 @@ void tst_QShortcut::sendKeyEvents(QWidget *w, int k1, QChar c1, int k2, QChar c2 k4 &= ~Qt::MODIFIER_MASK; - if (k1 || c1.toAscii()) { + if (k1 || c1.toLatin1()) { QString c(c1.unicode() == QChar::Null ? QString() : QString(c1)); QTest::sendKeyEvent(QTest::Press, w, static_cast<Qt::Key>(k1), c, b1); QTest::sendKeyEvent(QTest::Release, w, static_cast<Qt::Key>(k1), c, b1); } - if (k2 || c2.toAscii()) { + if (k2 || c2.toLatin1()) { QString c(c2.unicode() == QChar::Null ? QString() : QString(c2)); QTest::sendKeyEvent(QTest::Press, w, static_cast<Qt::Key>(k2), c, b2); QTest::sendKeyEvent(QTest::Release, w, static_cast<Qt::Key>(k2), c, b2); } - if (k3 || c3.toAscii()) { + if (k3 || c3.toLatin1()) { QString c(c3.unicode() == QChar::Null ? QString() : QString(c3)); QTest::sendKeyEvent(QTest::Press, w, static_cast<Qt::Key>(k3), c, b3); QTest::sendKeyEvent(QTest::Release, w, static_cast<Qt::Key>(k3), c, b3); } - if (k4 || c4.toAscii()) { + if (k4 || c4.toLatin1()) { QString c(c4.unicode() == QChar::Null ? QString() : QString(c4)); QTest::sendKeyEvent(QTest::Press, w, static_cast<Qt::Key>(k4), c, b4); QTest::sendKeyEvent(QTest::Release, w, static_cast<Qt::Key>(k4), c, b4); diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro index 23fd2459bf..678796d2e5 100644 --- a/tests/auto/widgets/kernel/qwidget/qwidget.pro +++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro @@ -21,4 +21,4 @@ x11 { !wince*:win32: LIBS += -luser32 -lgdi32 -CONFIG+=insignificant_test +CONFIG+=insignificant_test # QTBUG-25300, QTBUG-23695 diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 0c769d55da..6e88c6e74e 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -66,6 +66,7 @@ #include <QtGui/qpaintengine.h> #include <QtGui/qbackingstore.h> #include <QtGui/qguiapplication.h> +#include <QtGui/qscreen.h> #include <qmenubar.h> #include <qtableview.h> #include <qtreewidget.h> @@ -73,17 +74,13 @@ #include <QtWidgets/QGraphicsView> #include <QtWidgets/QGraphicsProxyWidget> -#ifdef Q_WS_QWS -# include <qscreen_qws.h> -#endif - #if defined(Q_OS_MAC) #include "tst_qwidget_mac_helpers.h" // Abstract the ObjC stuff out so not everyone must run an ObjC++ compile. #endif #include <QtTest/QtTest> -#if defined(Q_OS_WIN) +#ifdef Q_OS_WIN # include <QtCore/qt_windows.h> # include <QtGui/private/qguiapplication_p.h> # include <QtGui/QPlatformNativeInterface> @@ -98,27 +95,32 @@ static HWND winHandleOf(const QWidget *w) qWarning() << "Cannot obtain native handle for " << w; return 0; } -#endif -#if defined(Q_WS_WIN) -# include <qt_windows.h> -# if !defined(Q_OS_WINCE) -#define Q_CHECK_PAINTEVENTS \ +# ifdef Q_OS_WINCE +# define Q_CHECK_PAINTEVENTS +# ifdef Q_OS_WINCE_WM +# include <qguifunctions_wince.h> +// taken from qguifunctions_wce.cpp +# define SPI_GETPLATFORMTYPE 257 +static bool qt_wince_is_platform(const QString &platformString) { + wchar_t tszPlatform[64]; + if (SystemParametersInfo(SPI_GETPLATFORMTYPE, + sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) + if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform)) + return true; + return false; +} +static inline bool qt_wince_is_smartphone() { return qt_wince_is_platform(QString::fromLatin1("Smartphone")); } +# endif // Q_OS_WINCE_WM +# else // Q_OS_WINCE +# define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ QSKIP("desktop is not visible, this test would fail"); -# else -# define Q_CHECK_PAINTEVENTS -# endif -#elif defined(Q_WS_X11) -# include <private/qt_x11_p.h> -# include <qx11info_x11.h> -#elif defined(Q_WS_QWS) -# include <qwindowsystem_qws.h> -#endif +# endif // !Q_OS_WINCE +#else // Q_OS_WIN +# define Q_CHECK_PAINTEVENTS +#endif // else Q_OS_WIN -#if !defined(Q_WS_WIN) -#define Q_CHECK_PAINTEVENTS -#endif #if defined(Q_OS_WINCE_WM) #include <qguifunctions_wince.h> @@ -148,11 +150,6 @@ bool macHasAccessToWindowsServer() } #endif - -#if defined(Bool) -#undef Bool -#endif - class tst_QWidget : public QObject { Q_OBJECT @@ -187,24 +184,18 @@ private slots: void focusChainOnHide(); void focusChainOnReparent(); void setTabOrder(); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN void activation(); #endif void reparent(); -#ifndef Q_WS_X11 void windowState(); -#endif void showMaximized(); void showFullScreen(); void showMinimized(); void showMinimizedKeepsFocus(); -#ifndef Q_WS_QWS void icon(); -#endif void hideWhenFocusWidgetIsChild(); -#ifndef Q_OS_IRIX void normalGeometry(); -#endif void setGeometry(); #ifndef Q_OS_WINCE void windowOpacity(); @@ -215,11 +206,9 @@ private slots: void stackUnder(); #endif void testContentsPropagation(); -#ifndef Q_OS_IRIX void saveRestoreGeometry(); void restoreVersion1Geometry_data(); void restoreVersion1Geometry(); -#endif void widgetAt(); #ifdef Q_OS_MAC @@ -257,17 +246,13 @@ private slots: void scroll(); #endif -#ifndef Q_WS_X11 // tests QWidget::setGeometry() void setWindowGeometry_data(); void setWindowGeometry(); -#endif -#if !defined(Q_WS_X11) && !defined(Q_OS_IRIX) // tests QWidget::move() and resize() void windowMoveResize_data(); void windowMoveResize(); -#endif void moveChild_data(); void moveChild(); @@ -277,12 +262,9 @@ private slots: void subtractOpaqueSiblings(); #endif -#ifdef Q_WS_WIN - void getDC(); -#ifndef Q_OS_WINCE +#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) void setGeometry_win(); #endif -#endif void setLocale(); void deleteStyle(); @@ -291,11 +273,10 @@ private slots: void setCursor(); void setToolTip(); void testWindowIconChangeEventPropagation(); -#ifdef Q_WS_X11 + void minAndMaxSizeWithX11BypassWindowManagerHint(); - void showHideShow(); + void showHideShowX11(); void clean_qt_x11_enforce_cursor(); -#endif void childEvents(); void render(); @@ -317,39 +298,30 @@ private slots: void setContentsMargins(); -#ifndef Q_OS_IRIX void moveWindowInShowEvent_data(); void moveWindowInShowEvent(); -#endif void repaintWhenChildDeleted(); void hideOpaqueChildWhileHidden(); -#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) +#if !defined(Q_OS_WINCE) void updateWhileMinimized(); #endif -#if defined(Q_WS_WIN) || defined(Q_WS_X11) void alienWidgets(); -#endif void adjustSize(); void adjustSize_data(); void updateGeometry(); void updateGeometry_data(); void sendUpdateRequestImmediately(); -#ifndef Q_OS_IRIX void doubleRepaint(); -#endif void resizeInPaintEvent(); void opaqueChildren(); void setMaskInResizeEvent(); void moveInResizeEvent(); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) - // We don't support immediate repaint right after show on - // other platforms. Must be compatible with Qt 4.3. void immediateRepaintAfterShow(); void immediateRepaintAfterInvalidateBuffer(); -#endif + void effectiveWinId(); void effectiveWinId2(); void customDpi(); @@ -358,15 +330,13 @@ private slots: void quitOnCloseAttribute(); void moveRect(); -#if defined (Q_WS_WIN) +#if defined (Q_OS_WIN) void gdiPainting(); void paintOnScreenPossible(); #endif void reparentStaticWidget(); void QTBUG6883_reparentStaticWidget2(); -#ifdef Q_WS_QWS - void updateOutsideSurfaceClip(); -#endif + void translucentWidget(); void setClearAndResizeMask(); @@ -415,21 +385,13 @@ private slots: private: bool ensureScreenSize(int width, int height); QWidget *testWidget; + + const QString m_platform; }; bool tst_QWidget::ensureScreenSize(int width, int height) { QSize available; -#ifdef Q_WS_QWS - available = QDesktopWidget().availableGeometry().size(); - if (available.width() < width || available.height() < height) { - QScreen *screen = QScreen::instance(); - if (!screen) - return false; - screen->setMode(width, height, screen->depth()); - } -#endif // Q_WS_QWS - available = QDesktopWidget().availableGeometry().size(); return (available.width() >= width && available.height() >= height); } @@ -455,9 +417,6 @@ void tst_QWidget::getSetCheck() obj1.setMinimumWidth(INT_MIN); QCOMPARE(obj1.minimumWidth(), 0); // A widgets width can never be less than 0 obj1.setMinimumWidth(INT_MAX); -#ifndef Q_WS_QWS //QWS doesn't allow toplevels to be bigger than the screen - QCOMPARE(obj1.minimumWidth(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#endif child1.setMinimumWidth(0); QCOMPARE(child1.minimumWidth(), 0); @@ -473,9 +432,6 @@ void tst_QWidget::getSetCheck() obj1.setMinimumHeight(INT_MIN); QCOMPARE(obj1.minimumHeight(), 0); // A widgets height can never be less than 0 obj1.setMinimumHeight(INT_MAX); -#ifndef Q_WS_QWS //QWS doesn't allow toplevels to be bigger than the screen - QCOMPARE(obj1.minimumHeight(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#endif child1.setMinimumHeight(0); QCOMPARE(child1.minimumHeight(), 0); @@ -577,15 +533,14 @@ void tst_QWidget::getSetCheck() QCOMPARE(true, obj1.autoFillBackground()); delete var1; -#if defined (Q_WS_WIN) && !defined(Q_OS_WINCE) +#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) obj1.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint); - HWND handle = obj1.winId(); - long flags = GetWindowLong(handle, GWL_STYLE); - QVERIFY(flags & WS_POPUP); + const HWND handle = winHandleOf(&obj1); + QVERIFY(GetWindowLong(handle, GWL_STYLE) & WS_POPUP); #endif } -tst_QWidget::tst_QWidget() +tst_QWidget::tst_QWidget() : m_platform(qApp->platformName().toLower()) { QFont font; font.setBold(true); @@ -1685,11 +1640,7 @@ void tst_QWidget::setTabOrder() container.show(); container.activateWindow(); qApp->setActiveWindow(&container); -#ifdef Q_WS_X11 - QTest::qWaitForWindowShown(&container); - QTest::qWait(50); -#endif - + QTest::qWaitForWindowShown(container.windowHandle()); QTest::qWait(100); QTRY_VERIFY(lastEdit->hasFocus()); @@ -1703,7 +1654,7 @@ void tst_QWidget::setTabOrder() QVERIFY(firstEdit->hasFocus()); } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN void tst_QWidget::activation() { Q_CHECK_PAINTEVENTS @@ -1740,7 +1691,7 @@ void tst_QWidget::activation() QVERIFY(qApp->activeWindow() == &widget1); widget2.showNormal(); QTest::qWait(waitTime); -#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE) +#ifndef Q_OS_WINCE if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) QEXPECT_FAIL("", "MS introduced new behavior after XP", Continue); #endif @@ -1750,12 +1701,12 @@ void tst_QWidget::activation() QTest::qWait(waitTime); QVERIFY(qApp->activeWindow() == &widget1); } -#endif +#endif // Q_OS_WIN -// Many window managers do not support window state properly, which causes this test to fail. -#ifndef Q_WS_X11 void tst_QWidget::windowState() { + if (m_platform == QStringLiteral("xcb")) + QSKIP("X11: Many window managers do not support window state properly, which causes this test to fail."); #ifdef Q_OS_WINCE_WM QPoint pos(500, 500); QSize size(200, 200); @@ -1873,7 +1824,6 @@ void tst_QWidget::windowState() QTRY_COMPARE(widget1.pos(), pos); QTRY_COMPARE(widget1.size(), size); } -#endif void tst_QWidget::showMaximized() { @@ -2217,13 +2167,7 @@ void tst_QWidget::showMinimizedKeepsFocus() window.showMinimized(); QTest::qWait(30); QTRY_VERIFY(window.isMinimized()); -#ifdef Q_WS_QWS - QEXPECT_FAIL("", "QWS does not implement showMinimized()", Continue); -#endif QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0)); -#ifdef Q_WS_QWS - QEXPECT_FAIL("", "QWS does not implement showMinimized()", Continue); -#endif QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(0)); window.showNormal(); @@ -2281,17 +2225,16 @@ void tst_QWidget::reparent() child.setGeometry(childPos.x(), childPos.y(), child.width(), child.height()); child.show(); -#ifdef Q_WS_X11 - // On X11, the window manager will apply NorthWestGravity rules to 'child', which - // means the top-left corner of the window frame will be placed at 'childPos', - // causing this test to fail -#else + if (m_platform == QStringLiteral("xcb")) + QEXPECT_FAIL("", "On X11, the window manager will apply NorthWestGravity rules to 'child', which" + " means the top-left corner of the window frame will be placed at 'childPos'" + " causing this test to fail.", Continue); + QCOMPARE(child.geometry().topLeft(), childPos); -#endif QTRY_COMPARE(childTLW.pos(), tlwPos); // This following part of the test only makes sense on Windows. -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN QWidget childTLWChild(&childTLW); childTLWChild.setObjectName("childTLWChild"); @@ -2314,17 +2257,17 @@ void tst_QWidget::reparent() QWidget grandChildTLWChild(&grandChildTLW); grandChildTLWChild.setObjectName("grandChildTLWChild"); - QVERIFY(IsWindow(childTLW.winId())); - QVERIFY(IsWindow(childTLWChild.winId())); - QVERIFY(IsWindow(grandChildTLW.winId())); - QVERIFY(IsWindow(grandChildTLWChild.winId())); + QVERIFY(IsWindow(winHandleOf(&childTLW))); + QVERIFY(IsWindow(winHandleOf(&childTLWChild))); + QVERIFY(IsWindow(winHandleOf(&grandChildTLW))); + QVERIFY(IsWindow(winHandleOf(&grandChildTLWChild))); parent.show(); - QVERIFY(IsWindow(childTLW.winId())); - QVERIFY(IsWindow(childTLWChild.winId())); - QVERIFY(IsWindow(grandChildTLW.winId())); - QVERIFY(IsWindow(grandChildTLWChild.winId())); + QVERIFY(IsWindow(winHandleOf(&childTLW))); + QVERIFY(IsWindow(winHandleOf(&childTLWChild))); + QVERIFY(IsWindow(winHandleOf(&grandChildTLW))); + QVERIFY(IsWindow(winHandleOf(&grandChildTLWChild))); child.setParent(&parent); child.move(10,10); @@ -2333,16 +2276,15 @@ void tst_QWidget::reparent() // this appears to stabelize results qApp->processEvents(); - QVERIFY(IsWindow(childTLW.winId())); - QVERIFY(IsWindow(childTLWChild.winId())); + QVERIFY(IsWindow(winHandleOf(&childTLW))); + QVERIFY(IsWindow(winHandleOf(&childTLWChild))); - QVERIFY(IsWindow(grandChildTLW.winId())); - QVERIFY(IsWindow(grandChildTLWChild.winId())); + QVERIFY(IsWindow(winHandleOf(&grandChildTLW))); + QVERIFY(IsWindow(winHandleOf(&grandChildTLWChild))); #endif } // Qt/Embedded does it differently. -#ifndef Q_WS_QWS void tst_QWidget::icon() { QPixmap p(20,20); @@ -2357,7 +2299,6 @@ void tst_QWidget::icon() testWidget->showNormal(); QVERIFY(!testWidget->windowIcon().isNull()); } -#endif void tst_QWidget::hideWhenFocusWidgetIsChild() { @@ -2378,10 +2319,9 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() edit->setFocus(); qApp->processEvents(); QString actualFocusWidget, expectedFocusWidget; -#ifdef Q_WS_X11 - if (!qApp->focusWidget()) - QSKIP("Your window manager is too broken for this test"); -#endif + if (!qApp->focusWidget() && m_platform == QStringLiteral("xcb")) + QSKIP("X11: Your window manager is too broken for this test"); + QVERIFY(qApp->focusWidget()); actualFocusWidget.sprintf("%p %s %s", qApp->focusWidget(), qApp->focusWidget()->objectName().toLatin1().constData(), qApp->focusWidget()->metaObject()->className()); expectedFocusWidget.sprintf("%p %s %s", edit, edit->objectName().toLatin1().constData(), edit->metaObject()->className()); @@ -2397,8 +2337,6 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() delete parentWidget; } -// 4DWM issues on IRIX makes this test fail. -#ifndef Q_OS_IRIX void tst_QWidget::normalGeometry() { QWidget parent; @@ -2500,7 +2438,6 @@ void tst_QWidget::normalGeometry() QTest::qWait(10); QTRY_COMPARE(parent.normalGeometry(), geom); } -#endif void tst_QWidget::setGeometry() { @@ -2835,17 +2772,13 @@ void tst_QWidget::stackUnder() parent->show(); QTest::qWaitForWindowShown(parent); QTest::qWait(10); -#ifdef Q_WS_QWS - QApplication::sendPostedEvents(); //glib workaround -#endif - QList<QObject *> list1; list1 << child1 << child2 << child3 << child4; QVERIFY(parent->children() == list1); foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child4 ? 1 : 0; -#if defined(Q_WS_WIN) || defined(Q_OS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) if (expectedPaintEvents == 1 && child->numPaintEvents == 2) QEXPECT_FAIL(0, "Mac and Windows issues double repaints for Z-Order change", Continue); #endif @@ -2944,13 +2877,9 @@ protected: void tst_QWidget::testContentsPropagation() { ContentsPropagationWidget widget; -#ifdef Q_WS_QWS - widget.resize(500,500); -#else widget.setFixedSize(500, 500); -#endif widget.setContentsPropagation(false); - QPixmap widgetSnapshot = QPixmap::grabWidget(&widget); + QPixmap widgetSnapshot = widget.grab(QRect(QPoint(0, 0), QSize(-1, -1))); QPixmap correct(500, 500); drawPolygon(&correct, 500, 500); @@ -2960,7 +2889,7 @@ void tst_QWidget::testContentsPropagation() QVERIFY(widgetSnapshot.toImage() != correct.toImage()); widget.setContentsPropagation(true); - widgetSnapshot = QPixmap::grabWidget(&widget); + widgetSnapshot = widgetSnapshot = widget.grab(QRect(QPoint(0, 0), QSize(-1, -1))); //widgetSnapshot.save("snap2.png", "PNG"); QCOMPARE(widgetSnapshot, correct); @@ -2970,8 +2899,7 @@ void tst_QWidget::testContentsPropagation() Test that saving and restoring window geometry with saveGeometry() and restoreGeometry() works. */ -// 4DWM issues on IRIX makes this test fail. -#ifndef Q_OS_IRIX + void tst_QWidget::saveRestoreGeometry() { const QPoint position(100, 100); @@ -3100,10 +3028,7 @@ void tst_QWidget::saveRestoreGeometry() QTRY_COMPARE(widget.geometry(), geom); } } -#endif -// 4DWM issues on IRIX makes this test fail. -#ifndef Q_OS_IRIX void tst_QWidget::restoreVersion1Geometry_data() { QTest::addColumn<QString>("fileName"); @@ -3178,9 +3103,7 @@ void tst_QWidget::restoreVersion1Geometry() widgetToSave.move(expectedPosition); widgetToSave.resize(expectedSize); widgetToSave.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QTest::qWaitForWindowShown(widget.windowHandle()); QTest::qWait(500); // stabilize widgetToSave.setWindowState(Qt::WindowStates(expectedWindowState)); QTest::qWait(500); // stabilize @@ -3195,7 +3118,6 @@ void tst_QWidget::restoreVersion1Geometry() } #endif } -#endif void tst_QWidget::widgetAt() { @@ -3278,57 +3200,6 @@ void tst_QWidget::widgetAt() delete w1; } -#if defined(Q_WS_X11) -bool getProperty(Display *display, Window target, Atom type, Atom property, - unsigned char** data, unsigned long* count) -{ - Atom atom_return; - int size; - unsigned long nitems, bytes_left; - - int ret = XGetWindowProperty(display, target, property, - 0l, 1l, false, - type, &atom_return, &size, - &nitems, &bytes_left, data); - if (ret != Success || nitems < 1) - return false; - - if (bytes_left != 0) { - XFree(*data); - unsigned long remain = ((size / 8) * nitems) + bytes_left; - ret = XGetWindowProperty(display, target, - property, 0l, remain, false, - type, &atom_return, &size, - &nitems, &bytes_left, data); - if (ret != Success) - return false; - } - - *count = nitems; - return true; -} - -QString textPropertyToString(Display *display, XTextProperty& text_prop) -{ - QString ret; - if (text_prop.value && text_prop.nitems > 0) { - if (text_prop.encoding == XA_STRING) { - ret = reinterpret_cast<char *>(text_prop.value); - } else { - text_prop.nitems = strlen(reinterpret_cast<char *>(text_prop.value)); - char **list; - int num; - if (XmbTextPropertyToTextList(display, &text_prop, &list, &num) == Success - && num > 0 && *list) { - ret = QString::fromLocal8Bit(*list); - XFreeStringList(list); - } - } - } - return ret; -} -#endif - void tst_QWidget::task110173() { QWidget w; @@ -3491,7 +3362,7 @@ public: */ bool verifyWidgetMask(QWidget *widget, QRect mask) { - const QImage image = QPixmap::grabWindow(widget->winId()).toImage(); + const QImage image = widget->grab(QRect(QPoint(0, 0), widget->size())).toImage(); const QImage masked = image.copy(mask); QImage red(masked); @@ -3644,7 +3515,7 @@ void tst_QWidget::optimizedResizeMove() void tst_QWidget::optimizedResize_topLevel() { -#if defined(Q_OS_MAC) || defined(Q_WS_QWS) +#if defined(Q_OS_MAC) QSKIP("We do not yet have static contents support for *top-levels* on this platform"); #endif @@ -3659,7 +3530,7 @@ void tst_QWidget::optimizedResize_topLevel() topLevel.partial = false; topLevel.paintedRegion = QRegion(); -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN topLevel.resize(topLevel.size() + QSize(10, 10)); #else // Static contents does not work when programmatically resizing @@ -3669,7 +3540,7 @@ void tst_QWidget::optimizedResize_topLevel() // WM_RESIZE in QApplication). This is a corner case, though. // See task 243708 const QRect frame = topLevel.frameGeometry(); - MoveWindow(topLevel.winId(), frame.x(), frame.y(), + MoveWindow(winHandleOf(&topLevel), frame.x(), frame.y(), frame.width() + 10, frame.height() + 10, true); #endif @@ -3709,28 +3580,10 @@ void tst_QWidget::childDeletesItsSibling() } -#ifdef Q_WS_QWS -# define SET_SAFE_SIZE(w) \ - do { \ - QSize safeSize(qt_screen->width() - 250, qt_screen->height() - 250); \ - if (!safeSize.isValid()) \ - QSKIP("Screen size too small"); \ - if (defaultSize.width() > safeSize.width() || defaultSize.height() > safeSize.height()) { \ - defaultSize = safeSize; \ - w.resize(defaultSize); \ - w.setAttribute(Qt::WA_Resized, false); \ - } \ - } while (false) -#else -# define SET_SAFE_SIZE(w) -#endif - - void tst_QWidget::setMinimumSize() { QWidget w; QSize defaultSize = w.size(); - SET_SAFE_SIZE(w); w.setMinimumSize(defaultSize + QSize(100, 100)); QCOMPARE(w.size(), defaultSize + QSize(100, 100)); @@ -3760,7 +3613,6 @@ void tst_QWidget::setMaximumSize() { QWidget w; QSize defaultSize = w.size(); - SET_SAFE_SIZE(w); w.setMinimumSize(defaultSize + QSize(100, 100)); QCOMPARE(w.size(), defaultSize + QSize(100, 100)); @@ -3780,7 +3632,6 @@ void tst_QWidget::setFixedSize() { QWidget w; QSize defaultSize = w.size(); - SET_SAFE_SIZE(w); w.setFixedSize(defaultSize + QSize(100, 100)); QCOMPARE(w.size(), defaultSize + QSize(100, 100)); @@ -4432,7 +4283,7 @@ Q_DECLARE_METATYPE(QList<QRect>) // Since X11 WindowManager operations are all async, and we have no way to know if the window // manager has finished playing with the window geometry, this test can't be reliable on X11. -#ifndef Q_WS_X11 + void tst_QWidget::setWindowGeometry_data() { QTest::addColumn<QList<QRect> >("rects"); @@ -4481,7 +4332,7 @@ void tst_QWidget::setWindowGeometry_data() .arg(rect.y()) .arg(rect.width()) .arg(rect.height()) - .arg(windowFlag, 0, 16).toAscii()) + .arg(windowFlag, 0, 16).toLatin1()) << l << windowFlag; } @@ -4490,6 +4341,9 @@ void tst_QWidget::setWindowGeometry_data() void tst_QWidget::setWindowGeometry() { + if (m_platform == QStringLiteral("xcb")) + QSKIP("X11: Skip this test due to Window manager positioning issues."); + QFETCH(QList<QRect>, rects); QFETCH(int, windowFlags); QRect rect = rects.takeFirst(); @@ -4610,9 +4464,8 @@ void tst_QWidget::setWindowGeometry() QTRY_COMPARE(widget.geometry(), rect); } } -#endif -#if defined (Q_WS_WIN) && !defined(Q_OS_WINCE) +#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) void tst_QWidget::setGeometry_win() { QWidget widget; @@ -4625,16 +4478,15 @@ void tst_QWidget::setGeometry_win() widget.setWindowState(widget.windowState() | Qt::WindowMaximized); widget.show(); RECT rt; - ::GetWindowRect(widget.internalWinId(), &rt); + ::GetWindowRect(winHandleOf(&widget), &rt); QVERIFY(rt.left <= 0); QVERIFY(rt.top <= 0); } -#endif +#endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) // Since X11 WindowManager operation are all async, and we have no way to know if the window // manager has finished playing with the window geometry, this test can't be reliable on X11. -// 4DWM issues on IRIX also makes this test fail. -#if !defined(Q_WS_X11) && !defined(Q_OS_IRIX) + void tst_QWidget::windowMoveResize_data() { setWindowGeometry_data(); @@ -4642,6 +4494,9 @@ void tst_QWidget::windowMoveResize_data() void tst_QWidget::windowMoveResize() { + if (m_platform == QStringLiteral("xcb")) + QSKIP("X11: Skip this test due to Window manager positioning issues."); + QFETCH(QList<QRect>, rects); QFETCH(int, windowFlags); @@ -4684,9 +4539,9 @@ void tst_QWidget::windowMoveResize() QTRY_COMPARE(widget.size(), rect.size()); // move() while shown - foreach (QRect r, rects) { -#ifdef Q_WS_X11 - if ((widget.width() == 0 || widget.height() == 0) && r.width() != 0 && r.height() != 0) { + foreach (const QRect &r, rects) { + if (m_platform == QStringLiteral("xcb") + && ((widget.width() == 0 || widget.height() == 0) && r.width() != 0 && r.height() != 0)) { QEXPECT_FAIL("130,100 0x200, flags 0", "First resize after show of zero-sized gets wrong win_gravity.", Continue); @@ -4697,7 +4552,7 @@ void tst_QWidget::windowMoveResize() "First resize after show of zero-sized gets wrong win_gravity.", Continue); } -#endif + widget.move(r.topLeft()); widget.resize(r.size()); QApplication::processEvents(); @@ -4819,7 +4674,6 @@ void tst_QWidget::windowMoveResize() QTRY_COMPARE(widget.size(), rect.size()); } } -#endif class ColorWidget : public QWidget { @@ -4847,10 +4701,12 @@ public: #define VERIFY_COLOR(region, color) { \ const QRegion r = QRegion(region); \ + QScreen *screen = qApp->primaryScreen(); \ + const WId desktopWinId = QDesktopWidget().winId(); \ for (int i = 0; i < r.rects().size(); ++i) { \ const QRect rect = r.rects().at(i); \ for (int t = 0; t < 5; t++) { \ - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ + const QPixmap pixmap = screen->grabWindow(desktopWinId, \ rect.left(), rect.top(), \ rect.width(), rect.height()); \ QCOMPARE(pixmap.size(), rect.size()); \ @@ -5008,19 +4864,6 @@ void tst_QWidget::deleteStyle() qApp->processEvents(); } -#ifdef Q_WS_WIN -void tst_QWidget::getDC() -{ - QWidget widget; - widget.setGeometry(0, 0, 2, 4); - - HDC dc = widget.getDC(); - QVERIFY(dc != 0); - - widget.releaseDC(dc); -} -#endif - class TopLevelFocusCheck: public QWidget { Q_OBJECT @@ -5077,9 +4920,6 @@ void tst_QWidget::multipleToplevelFocusCheck() QApplication::processEvents(); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2)); QTest::mouseClick(&w2, Qt::LeftButton); -#ifdef Q_WS_QWS - QEXPECT_FAIL("", "embedded toplevels take focus anyway", Continue); -#endif QTRY_COMPARE(QApplication::focusWidget(), (QWidget *)0); QTest::mouseDClick(&w2, Qt::LeftButton); @@ -5555,9 +5395,10 @@ void tst_QWidget::testWindowIconChangeEventPropagation() qApp->setWindowIcon(QIcon()); } -#ifdef Q_WS_X11 void tst_QWidget::minAndMaxSizeWithX11BypassWindowManagerHint() { + if (m_platform != QStringLiteral("xcb")) + QSKIP("This test is for X11 only."); // Same size as in QWidget::create_sys(). const QSize desktopSize = QApplication::desktop()->size(); const QSize originalSize(desktopSize.width() / 2, desktopSize.height() * 4 / 10); @@ -5570,7 +5411,7 @@ void tst_QWidget::minAndMaxSizeWithX11BypassWindowManagerHint() QCOMPARE(widget.size(), newMaximumSize); widget.show(); - qt_x11_wait_for_window_manager(&widget); + QTest::qWaitForWindowShown(widget.windowHandle()); QCOMPARE(widget.size(), newMaximumSize); } @@ -5582,7 +5423,7 @@ void tst_QWidget::minAndMaxSizeWithX11BypassWindowManagerHint() QCOMPARE(widget.size(), newMinimumSize); widget.show(); - qt_x11_wait_for_window_manager(&widget); + QTest::qWaitForWindowShown(widget.windowHandle()); QCOMPARE(widget.size(), newMinimumSize); } } @@ -5613,10 +5454,16 @@ public: } } - bool x11Event(XEvent *event) + bool nativeEvent(const QByteArray &eventType, void *message, long *) { - if (state == 1 && event->type == MapNotify) - gotExpectedMapNotify = true; + enum { XCB_MAP_NOTIFY = 19 }; + + if (state == 1 && eventType == QByteArrayLiteral("xcb_generic_event_t")) { + // XCB events have a uint8 response_type member at the beginning. + const unsigned char responseType = *(const unsigned char *)(message); + if ((responseType & ~0x80) == XCB_MAP_NOTIFY) + gotExpectedMapNotify = true; + } return false; } @@ -5624,8 +5471,11 @@ signals: void done(); }; -void tst_QWidget::showHideShow() +void tst_QWidget::showHideShowX11() { + if (m_platform != QStringLiteral("xcb")) + QSKIP("This test is for X11 only."); + ShowHideShowWidget w; w.show(); w.hide(); @@ -5639,6 +5489,9 @@ void tst_QWidget::showHideShow() void tst_QWidget::clean_qt_x11_enforce_cursor() { + if (m_platform != QStringLiteral("xcb")) + QSKIP("This test is for X11 only."); + { QWidget window; QWidget *w = new QWidget(&window); @@ -5665,7 +5518,6 @@ void tst_QWidget::clean_qt_x11_enforce_cursor() // If the test didn't crash, then it passed. } -#endif class EventRecorder : public QObject { @@ -5986,9 +5838,9 @@ void tst_QWidget::render() qApp->sendPostedEvents(); QTest::qWait(250); - QImage sourceImage = QPixmap::grabWidget(&source).toImage(); + const QImage sourceImage = source.grab(QRect(QPoint(0, 0), QSize(-1, -1))).toImage(); qApp->processEvents(); - QImage targetImage = QPixmap::grabWidget(&target).toImage(); + QImage targetImage = target.grab(QRect(QPoint(0, 0), QSize(-1, -1))).toImage(); qApp->processEvents(); QCOMPARE(sourceImage, targetImage); @@ -5999,7 +5851,7 @@ void tst_QWidget::render() qApp->processEvents(); qApp->sendPostedEvents(); - targetImage = QPixmap::grabWidget(&target).toImage(); + targetImage = target.grab(QRect(QPoint(0, 0), QSize(-1, -1))).toImage(); QVERIFY(sourceImage != targetImage); QCOMPARE(targetImage.pixel(target.width() / 2, 29), QColor(Qt::red).rgb()); @@ -6018,7 +5870,9 @@ void tst_QWidget::render() child.show(); qApp->processEvents(); - QCOMPARE(QPixmap::grabWidget(&child), QPixmap::grabWidget(&window)); + const QPixmap childPixmap = child.grab(QRect(QPoint(0, 0), QSize(-1, -1))); + const QPixmap windowPixmap = window.grab(QRect(QPoint(0, 0), QSize(-1, -1))); + QCOMPARE(childPixmap, windowPixmap); } { // Check that the target offset is correct. @@ -6056,7 +5910,7 @@ void tst_QWidget::render() // in testing the geometry so just workaround the palette issue for now. static void workaroundPaletteIssue(QWidget *widget) { -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN return; #endif if (!widget) @@ -6381,7 +6235,8 @@ void tst_QWidget::render_task188133() // Make sure QWidget::render does not trigger QWidget::repaint/update // and asserts for Qt::WA_WState_Created. - QPixmap pixmap = QPixmap::grabWidget(&mainWindow); + const QPixmap pixmap = mainWindow.grab(QRect(QPoint(0, 0), QSize(-1, -1))); + Q_UNUSED(pixmap) } void tst_QWidget::render_task211796() @@ -6444,10 +6299,10 @@ void tst_QWidget::render_windowOpacity() child.setAutoFillBackground(true); QPixmap expected(child.size()); -#ifdef Q_WS_X11 - if (expected.depth() < 24) + + if (m_platform == QStringLiteral("xcb") && expected.depth() < 24) QSKIP("This test won't give correct results with dithered pixmaps"); -#endif + expected.fill(Qt::green); QPainter painter(&expected); painter.setOpacity(opacity); @@ -6908,8 +6763,6 @@ void tst_QWidget::setContentsMargins() QCOMPARE(newSize, label3.sizeHint()); } -// 4DWM issues on IRIX makes this test fail. -#ifndef Q_OS_IRIX void tst_QWidget::moveWindowInShowEvent_data() { QTest::addColumn<QPoint>("initial"); @@ -6947,18 +6800,15 @@ void tst_QWidget::moveWindowInShowEvent() // show it widget.show(); - #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); - #endif + QTest::qWaitForWindowShown(widget.windowHandle()); QTest::qWait(100); // it should have moved QCOMPARE(widget.pos(), position); } -#endif void tst_QWidget::repaintWhenChildDeleted() { -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) { QTest::qWait(1000); } @@ -7031,7 +6881,7 @@ void tst_QWidget::hideOpaqueChildWhileHidden() } // This test doesn't make sense without support for showMinimized(). -#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) +#if !defined(Q_OS_WINCE) void tst_QWidget::updateWhileMinimized() { UpdateWidget widget; @@ -7064,7 +6914,6 @@ void tst_QWidget::updateWhileMinimized() } #endif -#if defined(Q_WS_WIN) || defined(Q_WS_X11) class PaintOnScreenWidget: public QWidget { public: @@ -7072,7 +6921,7 @@ public: :QWidget(parent, f) { } -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) // This is the only way to enable PaintOnScreen on Windows. QPaintEngine * paintEngine () const {return 0;} #endif @@ -7080,6 +6929,9 @@ public: void tst_QWidget::alienWidgets() { + if (m_platform != QStringLiteral("xcb") && m_platform != QStringLiteral("windows")) + QSKIP("This test is only for X11/Windows."); + qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QWidget parent; QWidget child(&parent); @@ -7087,9 +6939,7 @@ void tst_QWidget::alienWidgets() QWidget greatGrandChild(&grandChild); parent.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&parent); -#endif + QTest::qWaitForWindowShown(parent.windowHandle()); // Verify that the WA_WState_Created attribute is set // and the top-level is the only native window. @@ -7160,36 +7010,20 @@ void tst_QWidget::alienWidgets() widget.show(); QVERIFY(widget.testAttribute(Qt::WA_WState_Created)); QVERIFY(!widget.internalWinId()); -#ifdef Q_WS_X11 - widget.handle(); -#else - widget.getDC(); -#endif - QVERIFY(widget.internalWinId()); - } -#ifdef Q_WS_X11 -#ifndef QT_NO_XRENDER - { // Enforce a native window when calling QWidget::x11PictureHandle(). - QWidget widget(&parent); - widget.show(); - QVERIFY(widget.testAttribute(Qt::WA_WState_Created)); - QVERIFY(!widget.internalWinId()); - widget.x11PictureHandle(); + widget.winId(); QVERIFY(widget.internalWinId()); } -#endif - { // Make sure we don't create native windows when setting Qt::WA_X11NetWmWindowType attributes - // on alien widgets (see task 194231). + if (m_platform == QStringLiteral("xcb")) { + // Make sure we don't create native windows when setting Qt::WA_X11NetWmWindowType attributes + // on alien widgets (see task 194231). QWidget dummy; QVERIFY(dummy.winId()); QWidget widget(&dummy); widget.setAttribute(Qt::WA_X11NetWmWindowTypeToolBar); QVERIFY(!widget.internalWinId()); } -#endif - { // Make sure we create native ancestors when setting Qt::WA_PaintOnScreen before show(). QWidget topLevel; @@ -7296,7 +7130,6 @@ void tst_QWidget::alienWidgets() QVERIFY(toolBar->testAttribute(Qt::WA_NativeWindow)); } } -#endif // Q_WS_WIN / Q_WS_X11 class ASWidget : public QWidget { @@ -7526,14 +7359,10 @@ void tst_QWidget::sendUpdateRequestImmediately() { UpdateWidget updateWidget; updateWidget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&updateWidget); -#endif + + QTest::qWaitForWindowShown(updateWidget.windowHandle()); qApp->processEvents(); -#ifdef Q_WS_QWS - QApplication::sendPostedEvents(); //glib workaround -#endif updateWidget.reset(); QCOMPARE(updateWidget.numUpdateRequestEvents, 0); @@ -7541,8 +7370,6 @@ void tst_QWidget::sendUpdateRequestImmediately() QCOMPARE(updateWidget.numUpdateRequestEvents, 1); } -// 4DWM issues on IRIX makes this test fail. -#ifndef Q_OS_IRIX void tst_QWidget::doubleRepaint() { #if defined(Q_OS_MAC) @@ -7574,7 +7401,6 @@ void tst_QWidget::doubleRepaint() QTest::qWait(10); QCOMPARE(widget.numPaintEvents, 0); } -#endif void tst_QWidget::resizeInPaintEvent() { @@ -7616,9 +7442,7 @@ void tst_QWidget::opaqueChildren() greatGrandChild.setAutoFillBackground(true); // Opaque child widget. widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QTest::qWaitForWindowShown(widget.windowHandle()); QTest::qWait(100); // Child, grandChild and greatGrandChild are outside the ancestor clip. @@ -7747,10 +7571,11 @@ void tst_QWidget::moveInResizeEvent() QTRY_COMPARE(testWidget.geometry(), expectedGeometry); } - -#if defined(Q_WS_WIN) || defined(Q_WS_X11) void tst_QWidget::immediateRepaintAfterShow() { + if (m_platform != QStringLiteral("xcb") && m_platform != QStringLiteral("windows")) + QSKIP("We don't support immediate repaint right after show on other platforms."); + UpdateWidget widget; widget.show(); qApp->processEvents(); @@ -7764,11 +7589,12 @@ void tst_QWidget::immediateRepaintAfterShow() void tst_QWidget::immediateRepaintAfterInvalidateBuffer() { + if (m_platform != QStringLiteral("xcb") && m_platform != QStringLiteral("windows")) + QSKIP("We don't support immediate repaint right after show on other platforms."); + QWidget *widget = new UpdateWidget; widget->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(widget); -#endif + QTest::qWaitForWindowShown(widget->windowHandle()); QTest::qWait(200); static_cast<UpdateWidget *>(widget)->numPaintEvents = 0; @@ -7786,7 +7612,6 @@ void tst_QWidget::immediateRepaintAfterInvalidateBuffer() delete widget; } -#endif void tst_QWidget::effectiveWinId() { @@ -7941,31 +7766,43 @@ void tst_QWidget::moveRect() child.move(10, 10); // Don't crash. } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN class GDIWidget : public QDialog { + Q_OBJECT public: GDIWidget() { setAttribute(Qt::WA_PaintOnScreen); } QPaintEngine *paintEngine() const { return 0; } void paintEvent(QPaintEvent *) { - HDC hdc = getDC(); + QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface(); + const HDC hdc = (HDC)ni->nativeResourceForWindow(QByteArrayLiteral("getDC"), windowHandle()); + if (!hdc) { + qWarning("%s: Unable to obtain native DC.", Q_FUNC_INFO); + QTimer::singleShot(0, this, SLOT(reject())); + return; + } SelectObject(hdc, CreateSolidBrush(RGB(255, 0, 0))); Rectangle(hdc, 0, 0, 10, 10); - releaseDC(hdc); - - QImage im = QPixmap::grabWindow(winId(), 0, 0, width(), height()).toImage(); - color = im.pixel(1, 1); + ni->nativeResourceForWindow(QByteArrayLiteral("releaseDC"), windowHandle()); - accept(); + QTimer::singleShot(0, this, SLOT(slotTimer())); } QSize sizeHint() const { return QSize(400, 300); } +private slots: + void slotTimer() { + const QImage im = grab(QRect(QPoint(0, 0), size())).toImage(); + color = im.pixel(1, 1); + accept(); + } + +public: QColor color; }; @@ -7988,7 +7825,7 @@ void tst_QWidget::paintOnScreenPossible() w2.setAttribute(Qt::WA_PaintOnScreen); QVERIFY(w2.testAttribute(Qt::WA_PaintOnScreen)); } -#endif +#endif // Q_OS_WIN void tst_QWidget::reparentStaticWidget() { @@ -8089,34 +7926,6 @@ void tst_QWidget::QTBUG6883_reparentStaticWidget2() //do not crash } -#ifdef Q_WS_QWS -void tst_QWidget::updateOutsideSurfaceClip() -{ - UpdateWidget widget; - widget.setWindowFlags(Qt::FramelessWindowHint); - widget.resize(100, 100); - widget.raise(); - widget.show(); - QTest::qWait(200); - widget.reset(); - - // Move widget partially outside buffer and change the surface clip. - widget.move(-50, 0); - QTest::qWait(100); - - // Update region is outside the surface clip and should not trigger a repaint. - widget.update(0, 0, 20, 20); - QTest::qWait(100); - QCOMPARE(widget.numPaintEvents, 0); - - // Now, move the widget back so that the update region is inside the clip - // and make sure we get a repaint of the dirty area. - widget.move(0, 0); - QTest::qWait(100); - QCOMPARE(widget.numPaintEvents, 1); - QCOMPARE(widget.paintedRegion, QRegion(0, 0, 20, 20)); -} -#endif class ColorRedWidget : public QWidget { public: @@ -8138,22 +7947,21 @@ void tst_QWidget::translucentWidget() ColorRedWidget label; label.setFixedSize(16,16); label.setAttribute(Qt::WA_TranslucentBackground); - label.move(qApp->desktop()->availableGeometry().topLeft()); + const QPoint labelPos = qApp->desktop()->availableGeometry().topLeft(); + label.move(labelPos); label.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&label); -#endif + QTest::qWaitForWindowShown(label.windowHandle()); QTest::qWait(200); QPixmap widgetSnapshot; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN QWidget *desktopWidget = QApplication::desktop()->screen(0); if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) - widgetSnapshot = QPixmap::grabWindow(desktopWidget->winId(), 0,0, label.width(), label.height()); + widgetSnapshot = qApp->primaryScreen()->grabWindow(desktopWidget->winId(), labelPos.x(), labelPos.y(), label.width(), label.height()); else #endif - widgetSnapshot = QPixmap::grabWindow(label.winId()); + widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size())); QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32); QImage expected = pm.toImage().convertToFormat(QImage::Format_RGB32); QCOMPARE(actual.size(),expected.size()); @@ -8205,10 +8013,10 @@ void tst_QWidget::setClearAndResizeMask() const QRegion topLevelMask(0, 0, 100, 100, QRegion::Ellipse); topLevel.setMask(topLevelMask); QCOMPARE(topLevel.mask(), topLevelMask); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) // We don't control what's happening on other platforms. - // and ensure that the top-level doesn't get any update. - QCOMPARE(topLevel.numPaintEvents, 0); -#endif + // Ensure that the top-level doesn't get any update. + // We don't control what's happening on platforms other than X11, Windows + if (m_platform == QStringLiteral("xcb") || m_platform == QStringLiteral("windows")) + QCOMPARE(topLevel.numPaintEvents, 0); topLevel.reset(); @@ -8218,11 +8026,12 @@ void tst_QWidget::setClearAndResizeMask() QTest::qWait(10); QRegion outsideOldMask(topLevel.rect()); outsideOldMask -= topLevelMask; -#if defined(Q_WS_WIN) || defined(Q_WS_X11) // We don't control what's happening on other platforms. - // and ensure that the top-level gets an update for the area outside the old mask. - QTRY_VERIFY(topLevel.numPaintEvents > 0); - QTRY_COMPARE(topLevel.paintedRegion, outsideOldMask); -#endif + // Ensure that the top-level gets an update for the area outside the old mask. + // We don't control what's happening on platforms other than X11, Windows + if (m_platform == QStringLiteral("xcb") || m_platform == QStringLiteral("windows")) { + QTRY_VERIFY(topLevel.numPaintEvents > 0); + QTRY_COMPARE(topLevel.paintedRegion, outsideOldMask); + } UpdateWidget child(&topLevel); child.setAutoFillBackground(true); // NB! Opaque child. @@ -8526,9 +8335,8 @@ void tst_QWidget::syntheticEnterLeave() window.show(); window.raise(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif + + QTest::qWaitForWindowShown(window.windowHandle()); QTest::qWait(300); #define RESET_EVENT_COUNTS \ @@ -8629,9 +8437,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() SELChild child(&parent); child.resize(200, 200); parent.show(); - #ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&parent); - #endif + QTest::qWaitForWindowShown(parent.windowHandle()); QTest::qWait(150); QCursor::setPos(child.mapToGlobal(QPoint(100, 100))); @@ -8733,9 +8539,7 @@ void tst_QWidget::updateOnDestroyedSignal() child->setPalette(Qt::red); widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QTest::qWaitForWindowShown(widget.windowHandle()); QTest::qWait(200); // Please do not crash. @@ -8788,9 +8592,7 @@ void tst_QWidget::destroyBackingStore() w.update(); QApplication::processEvents(); -#ifdef Q_WS_QWS - QApplication::processEvents(); -#endif + QCOMPARE(w.numPaintEvents, 1); // Check one more time, because the second time around does more caching. @@ -8798,7 +8600,7 @@ void tst_QWidget::destroyBackingStore() QApplication::processEvents(); QCOMPARE(w.numPaintEvents, 2); } -#endif +#endif // QT_BUILD_INTERNAL // Helper function QWidgetBackingStore* backingStore(QWidget &widget) @@ -8844,8 +8646,9 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() QPixmap correct(main.size()); correct.fill(Qt::green); + const QPixmap mainPixmap = main.grab(QRect(QPoint(0, 0), QSize(-1, -1))); - QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage().convertToFormat(QImage::Format_RGB32), + QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32), correct.toImage().convertToFormat(QImage::Format_RGB32)); QApplication::restoreOverrideCursor(); } @@ -9059,7 +8862,7 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() void tst_QWidget::movedAndResizedAttributes() { -#if defined (Q_OS_MAC) || defined(Q_WS_QWS) +#if defined (Q_OS_MAC) QEXPECT_FAIL("", "FixMe, QTBUG-8941 and QTBUG-8977", Abort); QVERIFY(false); #else diff --git a/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro b/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro index 1408f87682..4cd85ab7f2 100644 --- a/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro +++ b/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro @@ -2,6 +2,3 @@ CONFIG += testcase TARGET = tst_qmacstyle QT += widgets testlib SOURCES += tst_qmacstyle.cpp - - -mac*:CONFIG+=insignificant_test diff --git a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp index f732dfa18d..62e1c7c8ef 100644 --- a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp +++ b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp @@ -135,6 +135,7 @@ void tst_QMacStyle::sizeHints() QCOMPARE(sh(&progress1).width(), SIZE(16, 10, 10)); // Builder QRadioButton radio1("Radio", &w); + QEXPECT_FAIL("", "QTBUG-25296", Abort); QCOMPARE(sh(&radio1).height(), SIZE(15, 12, 10)); // Builder QCheckBox checkBox1("Switch", &w); @@ -401,6 +402,8 @@ void tst_QMacStyle::smallMiniNormalExclusivity() opt.initFrom(&dummyWidget); QSize size = dummyWidget.style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(0, 0), &dummyWidget); + if (size.height() != expected[i]) + QEXPECT_FAIL("", "QTBUG-25296", Abort); QCOMPARE(size.height(), expected[i]); } } diff --git a/tests/auto/widgets/util/qcompleter/qcompleter.pro b/tests/auto/widgets/util/qcompleter/qcompleter.pro index 6a817a89ac..19d8d500b8 100644 --- a/tests/auto/widgets/util/qcompleter/qcompleter.pro +++ b/tests/auto/widgets/util/qcompleter/qcompleter.pro @@ -4,5 +4,3 @@ TARGET = tst_qcompleter QT += widgets testlib SOURCES += tst_qcompleter.cpp - -CONFIG += insignificant_test # QTBUG-21424 diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index a257eb1798..61b0e04624 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -266,7 +266,7 @@ retry: for (int i = 0; i < step.length(); i++) { int row = completer->currentRow(); - switch (step[i].toUpper().toAscii()) { + switch (step[i].toUpper().toLatin1()) { case 'P': --row; break; case 'N': ++row; break; case 'L': row = completer->completionCount() - 1; break; diff --git a/tests/auto/widgets/widgets/qcombobox/qcombobox.pro b/tests/auto/widgets/widgets/qcombobox/qcombobox.pro index e0545630c5..88b9d08557 100644 --- a/tests/auto/widgets/widgets/qcombobox/qcombobox.pro +++ b/tests/auto/widgets/widgets/qcombobox/qcombobox.pro @@ -2,5 +2,3 @@ CONFIG += testcase TARGET = tst_qcombobox QT += widgets widgets-private gui-private core-private testlib SOURCES += tst_qcombobox.cpp - -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG += insignificant_test # QTBUG-23639, (related QTBUG-1071) diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 4730d7d556..90b5a88805 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1271,7 +1271,7 @@ void tst_QComboBox::insertOnCurrentIndex() testWidget->addItem("first item"); testWidget->setCurrentIndex(0); testWidget->insertItem(0, "second item"); - QCOMPARE(testWidget->lineEdit()->text(), QString::fromAscii("first item")); + QCOMPARE(testWidget->lineEdit()->text(), QString::fromLatin1("first item")); } void tst_QComboBox::textpixmapdata_data() @@ -1669,33 +1669,33 @@ void tst_QComboBox::flaggedItems_data() KeyList keyMovementList; keyMovementList << Qt::Key_Down << Qt::Key_Down << Qt::Key_Down << Qt::Key_Down; - QTest::newRow(testCase.toAscii() + "normal") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; + QTest::newRow(testCase.toLatin1() + "normal") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; deselectFlagList.clear(); disableFlagList.clear(); deselectFlagList << 1 << 3; - QTest::newRow(testCase.toAscii() + "non-selectable") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; + QTest::newRow(testCase.toLatin1() + "non-selectable") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; deselectFlagList.clear(); disableFlagList.clear(); disableFlagList << 2; - QTest::newRow(testCase.toAscii() + "disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 5; + QTest::newRow(testCase.toLatin1() + "disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 5; deselectFlagList.clear(); disableFlagList.clear(); deselectFlagList << 1 << 3; disableFlagList << 2 << 3; - QTest::newRow(testCase.toAscii() + "mixed") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 6; + QTest::newRow(testCase.toLatin1() + "mixed") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 6; deselectFlagList.clear(); disableFlagList.clear(); disableFlagList << 0 << 1 << 2 << 3 << 4 << 5 << 6; - QTest::newRow(testCase.toAscii() + "nearly-empty") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7; + QTest::newRow(testCase.toLatin1() + "nearly-empty") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7; deselectFlagList.clear(); disableFlagList.clear(); disableFlagList << 0 << 1 << 2 << 3 << 5 << 6 << 7; keyMovementList.clear(); - QTest::newRow(testCase.toAscii() + "only one enabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; + QTest::newRow(testCase.toLatin1() + "only one enabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; if (!editable) { deselectFlagList.clear(); @@ -1703,38 +1703,38 @@ void tst_QComboBox::flaggedItems_data() keyMovementList.clear(); disableFlagList << 0 << 2 << 3; keyMovementList << Qt::Key_Down << Qt::Key_Home; - QTest::newRow(testCase.toAscii() + "home-disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 1; + QTest::newRow(testCase.toLatin1() + "home-disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 1; keyMovementList.clear(); keyMovementList << Qt::Key_End; - QTest::newRow(testCase.toAscii() + "end-key") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7; + QTest::newRow(testCase.toLatin1() + "end-key") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7; disableFlagList.clear(); disableFlagList << 1 ; keyMovementList << Qt::Key_T; - QTest::newRow(testCase.toAscii() + "keyboard-search") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; + QTest::newRow(testCase.toLatin1() + "keyboard-search") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; itemList << "nine" << "ten"; keyMovementList << Qt::Key_T; - QTest::newRow(testCase.toAscii() + "search same start letter") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 9; + QTest::newRow(testCase.toLatin1() + "search same start letter") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 9; keyMovementList.clear(); keyMovementList << Qt::Key_T << Qt::Key_H; - QTest::newRow(testCase.toAscii() + "keyboard search item") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; + QTest::newRow(testCase.toLatin1() + "keyboard search item") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; disableFlagList.clear(); disableFlagList << 1 << 3 << 5 << 7 << 9; keyMovementList.clear(); keyMovementList << Qt::Key_End << Qt::Key_Up << Qt::Key_Up << Qt::Key_PageDown << Qt::Key_PageUp << Qt::Key_PageUp << Qt::Key_Down; - QTest::newRow(testCase.toAscii() + "all key combinations") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; + QTest::newRow(testCase.toLatin1() + "all key combinations") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4; } else { deselectFlagList.clear(); disableFlagList.clear(); disableFlagList << 1; keyMovementList.clear(); keyMovementList << Qt::Key_T << Qt::Key_Enter; - QTest::newRow(testCase.toAscii() + "disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; - QTest::newRow(testCase.toAscii() + "broken autocompletion") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; + QTest::newRow(testCase.toLatin1() + "disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; + QTest::newRow(testCase.toLatin1() + "broken autocompletion") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2; } } } diff --git a/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro b/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro index 41c90b499a..2362be3b73 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro +++ b/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro @@ -4,4 +4,3 @@ QT += widgets testlib SOURCES += tst_qdatetimeedit.cpp wincewm50smart-msvc2005: DEFINES += WINCE_NO_MODIFIER_KEYS -mac:CONFIG += insignificant_test # numerous failures, see QTBUG-23674 diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index e66909e9eb..a6f344c4bc 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -786,6 +786,9 @@ void tst_QDateTimeEdit::selectAndScrollWithKeys() QTest::keyClick(testWidget, Qt::Key_Home); #endif QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(testWidget->lineEdit()->selectedText(), QString("1")); QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier); QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11")); @@ -889,6 +892,9 @@ void tst_QDateTimeEdit::backspaceKey() #endif QCOMPARE(testWidget->text(), QString("11/05/2004")); QTest::keyClick(testWidget, Qt::Key_Backspace); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(testWidget->text(), QString("11/05/200")); QTest::keyClick(testWidget, Qt::Key_Backspace); QCOMPARE(testWidget->text(), QString("11/05/20")); @@ -1025,6 +1031,9 @@ void tst_QDateTimeEdit::enterKey() QTest::keyClick(testWidget, Qt::Key_Home); #endif QTest::keyClick(testWidget, Qt::Key_Enter); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QVERIFY(!testWidget->lineEdit()->hasSelectedText()); #ifdef Q_OS_MAC QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier); @@ -2040,7 +2049,7 @@ void tst_QDateTimeEdit::dateSignalChecking() if (timesEmitted > 0) { QList<QVariant> list = dateSpy.takeFirst(); QDate d; - d = qVariantValue<QDate>(list.at(0)); + d = qvariant_cast<QDate>(list.at(0)); QCOMPARE(d, newDate); } QCOMPARE(dateTimeSpy.count(), timesEmitted); @@ -2076,7 +2085,7 @@ void tst_QDateTimeEdit::timeSignalChecking() if (timesEmitted > 0) { QList<QVariant> list = timeSpy.takeFirst(); QTime t; - t = qVariantValue<QTime>(list.at(0)); + t = qvariant_cast<QTime>(list.at(0)); QCOMPARE(t, newTime); } QCOMPARE(dateTimeSpy.count(), timesEmitted); @@ -2126,21 +2135,21 @@ void tst_QDateTimeEdit::dateTimeSignalChecking() QCOMPARE(timesDateEmitted, 1); QList<QVariant> list = dateSpy.takeFirst(); QDate d; - d = qVariantValue<QDate>(list.at(0)); + d = qvariant_cast<QDate>(list.at(0)); QCOMPARE(d, newDateTime.date()); } QCOMPARE(timeSpy.count(), timesTimeEmitted); if (timesTimeEmitted > 0) { QList<QVariant> list = timeSpy.takeFirst(); QTime t; - t = qVariantValue<QTime>(list.at(0)); + t = qvariant_cast<QTime>(list.at(0)); QCOMPARE(t, newDateTime.time()); } QCOMPARE(dateTimeSpy.count(), timesDateTimeEmitted); if (timesDateTimeEmitted > 0) { QList<QVariant> list = dateTimeSpy.takeFirst(); QDateTime dt; - dt = qVariantValue<QDateTime>(list.at(0)); + dt = qvariant_cast<QDateTime>(list.at(0)); QCOMPARE(dt, newDateTime); } } @@ -2551,6 +2560,9 @@ void tst_QDateTimeEdit::newCase() #else QTest::keyClick(testWidget, Qt::Key_Home); #endif +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(testWidget->lineEdit()->selectedText(), QString()); QTest::keyClick(testWidget, Qt::Key_Right); QTest::keyClick(testWidget, Qt::Key_Right); @@ -2627,6 +2639,9 @@ void tst_QDateTimeEdit::cursorPos() QTest::keyClick(testWidget, Qt::Key_Return); QTest::keyClick(testWidget, Qt::Key_3); QTest::keyClick(testWidget, Qt::Key_1); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(testWidget->lineEdit()->cursorPosition(), 3); } @@ -2660,6 +2675,9 @@ void tst_QDateTimeEdit::newCase5() QTest::keyClick(testWidget, Qt::Key_1); QTest::keyClick(testWidget, Qt::Key_2); QTest::keyClick(testWidget, Qt::Key_4); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(testWidget->lineEdit()->displayText(), QString("2005-10-07 17:44:13 124 ms")); QTest::keyClick(testWidget, Qt::Key_Backspace); @@ -2770,6 +2788,9 @@ void tst_QDateTimeEdit::setSelectedSection() #else QTest::keyClick(testWidget, Qt::Key_Home); #endif +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QVERIFY(!testWidget->lineEdit()->hasSelectedText()); testWidget->setSelectedSection(QDateTimeEdit::MinuteSection); QCOMPARE(testWidget->lineEdit()->selectedText(), QString("00")); @@ -2887,6 +2908,9 @@ void tst_QDateTimeEdit::reverseTest() #else QTest::keyClick(testWidget, Qt::Key_End); #endif +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(testWidget->currentSection(), QDateTimeEdit::DaySection); QTest::keyClick(testWidget, Qt::Key_Up); QCOMPARE(testWidget->date(), QDate(2001, 3, 31)); @@ -3039,6 +3063,9 @@ void tst_QDateTimeEdit::ddMMMMyyyy() QTest::keyClick(testWidget, Qt::Key_End); #endif QTest::keyClick(testWidget, Qt::Key_Backspace); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(testWidget->lineEdit()->text(), "01." + QDate::longMonthName(1) + ".200"); } @@ -3328,6 +3355,9 @@ void tst_QDateTimeEdit::potentialYYValueBug() QTest::keyClick(&edit, Qt::Key_End); #endif QTest::keyClick(&edit, Qt::Key_Backspace); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(edit.text(), QString("14/09/5")); } @@ -3343,6 +3373,9 @@ void tst_QDateTimeEdit::textSectionAtEnd() QTest::keyClick(&edit, Qt::Key_End); #endif QTest::keyClick(&edit, Qt::Key_Backspace); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23674", Abort); +#endif QCOMPARE(edit.text(), QString("Januar")); } diff --git a/tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro b/tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro index 183210b597..cc66eaae26 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro +++ b/tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro @@ -2,5 +2,3 @@ CONFIG += testcase TARGET = tst_qdoublespinbox QT += widgets testlib SOURCES += tst_qdoublespinbox.cpp - -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG += insignificant_test # QTBUG-23641 diff --git a/tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro b/tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro index 54aa3c4ff1..d2156a1718 100644 --- a/tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro +++ b/tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro @@ -12,4 +12,4 @@ mac { LIBS += -framework Security } -CONFIG+=insignificant_test +!mac:!win32:CONFIG+=insignificant_test # QTBUG-25298 diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index eeb2eea9a1..7aa9bb2ddf 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -530,6 +530,9 @@ void tst_QMdiArea::subWindowActivated2() #ifdef Q_OS_WINCE QSKIP("Not fixed yet. See Task 197453"); #endif +#ifdef Q_OS_MAC + QSKIP("QTBUG-25298: This test is unstable on Mac."); +#endif QTRY_COMPARE(spy.count(), 1); QVERIFY(!mdiArea.activeSubWindow()); QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow); @@ -1029,7 +1032,7 @@ void tst_QMdiArea::activeSubWindow() qApp->setActiveWindow(&mainWindow); QCOMPARE(mdiArea->activeSubWindow(), subWindow); -#if !defined(Q_OS_MAC) && !defined(Q_WS_WIN) +#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) qApp->setActiveWindow(0); QVERIFY(!mdiArea->activeSubWindow()); #endif @@ -1114,7 +1117,7 @@ void tst_QMdiArea::currentSubWindow() QVERIFY(mdiArea.activeSubWindow()); QVERIFY(mdiArea.currentSubWindow()); -#if !defined(Q_OS_MAC) && !defined(Q_WS_WIN) +#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) qApp->setActiveWindow(0); QVERIFY(!mdiArea.activeSubWindow()); QVERIFY(mdiArea.currentSubWindow()); @@ -1756,6 +1759,9 @@ void tst_QMdiArea::tileSubWindows() #ifdef Q_OS_WINCE QSKIP("Not fixed yet! See task 197453"); #endif +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25298", Abort); +#endif QTRY_COMPARE(workspace.viewport()->rect().size(), expectedViewportSize); // Not enough space for all sub-windows to be visible -> provide scroll bars. @@ -1825,6 +1831,9 @@ void tst_QMdiArea::cascadeAndTileSubWindows() titleBarHeight -= 4; const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar")); const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25298", Abort); +#endif QCOMPARE(windows.at(2)->geometry().top() - windows.at(1)->geometry().top(), dy); for (int i = 0; i < windows.count(); ++i) { @@ -2286,6 +2295,9 @@ void tst_QMdiArea::setActivationOrder() QVERIFY(verifyArrangement(&mdiArea, Tiled, expectedTileIndices)); mdiArea.cascadeSubWindows(); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25298", Abort); +#endif QVERIFY(verifyArrangement(&mdiArea, Cascaded, expectedCascadeIndices)); QTest::qWait(100); @@ -2333,6 +2345,9 @@ void tst_QMdiArea::tabBetweenSubWindows() QCOMPARE(spy.count(), 0); // Walk through the entire list of sub windows. +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25298", Abort); +#endif QVERIFY(tabBetweenSubWindowsIn(&mdiArea)); QCOMPARE(mdiArea.activeSubWindow(), subWindows.back()); QCOMPARE(spy.count(), 0); diff --git a/tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro b/tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro index be929d1429..4299f7711e 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro +++ b/tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro @@ -4,6 +4,3 @@ QT += widgets testlib INCLUDEPATH += . SOURCES += tst_qmdisubwindow.cpp DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII - - -mac*:CONFIG+=insignificant_test diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index bc5100f118..79afd14481 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -610,6 +610,9 @@ void tst_QMdiSubWindow::showShaded() else #endif mouseReceiver = window; +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25297", Abort); +#endif QVERIFY(mouseReceiver); sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton); sendMousePress(mouseReceiver, mousePosition); @@ -724,6 +727,9 @@ void tst_QMdiSubWindow::setOpaqueResizeAndMove() mouseReceiver = qFindChild<QSizeGrip *>(window); else mouseReceiver = window; +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25297", Abort); +#endif QVERIFY(mouseReceiver); // ----------------------------- resize ----------------------------- @@ -1432,6 +1438,9 @@ void tst_QMdiSubWindow::defaultSizeGrip() // QSizeGrip on windows with decoration. QMdiSubWindow *windowWithDecoration = mdiArea.addSubWindow(new QWidget); windowWithDecoration->show(); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25297", Abort); +#endif QVERIFY(qFindChild<QSizeGrip *>(windowWithDecoration)); // ...but not on windows without decoration (Qt::FramelessWindowHint). @@ -1699,6 +1708,9 @@ void tst_QMdiSubWindow::fixedMinMaxSize() // to minimize the window. subWindow->showMinimized(); QVERIFY(subWindow->isMinimized()); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-25297", Abort); +#endif QCOMPARE(subWindow->size(), minimizedSize); QCOMPARE(subWindow->minimumSize(), minimizedSize); diff --git a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro index c74c9e84c1..3fb6ae61a8 100644 --- a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro +++ b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro @@ -2,5 +2,3 @@ CONFIG += testcase TARGET = tst_qmenubar QT += widgets testlib SOURCES += tst_qmenubar.cpp - -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG += insignificant_test # QTBUG-4965, QTBUG-11823 diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 6a1f418739..6f7d7517e8 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -980,7 +980,7 @@ void tst_QMenuBar::check_altPress() { if ( !qApp->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation) ) { QSKIP( QString( "this is not supposed to work in the %1 style. Skipping." ). - arg( qApp->style()->objectName() ).toAscii()); + arg( qApp->style()->objectName() ).toLatin1()); } initSimpleMenubar(); diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index 4019faf428..1052bb2103 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -345,7 +345,7 @@ void tst_QPlainTextEdit::selectAllSetsNotSelection() ed->insertPlainText("Hello World"); ed->selectAll(); - QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromAscii("foobar")); + QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromLatin1("foobar")); } #endif diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 1c06197d11..7696ab2dea 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -561,37 +561,37 @@ void tst_QPushButton::sizeHint_data() { QTest::addColumn<QString>("stylename"); #if !defined(QT_NO_STYLE_MOTIF) - QTest::newRow("motif") << QString::fromAscii("motif"); + QTest::newRow("motif") << QString::fromLatin1("motif"); #endif #if !defined(QT_NO_STYLE_CDE) - QTest::newRow("cde") << QString::fromAscii("cde"); + QTest::newRow("cde") << QString::fromLatin1("cde"); #endif #if !defined(QT_NO_STYLE_WINDOWS) - QTest::newRow("windows") << QString::fromAscii("windows"); + QTest::newRow("windows") << QString::fromLatin1("windows"); #endif #if !defined(QT_NO_STYLE_CLEANLOOKS) - QTest::newRow("cleanlooks") << QString::fromAscii("cleanlooks"); + QTest::newRow("cleanlooks") << QString::fromLatin1("cleanlooks"); #endif #if !defined(QT_NO_STYLE_GTK) - QTest::newRow("gtk") << QString::fromAscii("gtk"); + QTest::newRow("gtk") << QString::fromLatin1("gtk"); #endif #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) - QTest::newRow("mac") << QString::fromAscii("mac"); + QTest::newRow("mac") << QString::fromLatin1("mac"); #endif #if !defined(QT_NO_STYLE_PLASTIQUE) - QTest::newRow("plastique") << QString::fromAscii("plastique"); + QTest::newRow("plastique") << QString::fromLatin1("plastique"); #endif #if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP) - QTest::newRow("windowsxp") << QString::fromAscii("windowsxp"); + QTest::newRow("windowsxp") << QString::fromLatin1("windowsxp"); #endif #if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA) - QTest::newRow("windowsvista") << QString::fromAscii("windowsvista"); + QTest::newRow("windowsvista") << QString::fromLatin1("windowsvista"); #endif #if defined(Q_OS_WINCE) && !defined(QT_NO_STYLE_WINDOWSCE) - QTest::newRow("windowsce") << QString::fromAscii("windowsce"); + QTest::newRow("windowsce") << QString::fromLatin1("windowsce"); #endif #if defined(Q_OS_WINCE_WM) && !defined(QT_NO_STYLE_WINDOWSCE) - QTest::newRow("windowsmobile") << QString::fromAscii("windowsmobile"); + QTest::newRow("windowsmobile") << QString::fromLatin1("windowsmobile"); #endif } diff --git a/tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro b/tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro index 98cf169730..1149b50feb 100644 --- a/tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro +++ b/tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro @@ -3,5 +3,3 @@ TARGET = tst_qsizegrip INCLUDEPATH += . QT += widgets testlib SOURCES += tst_qsizegrip.cpp - -mac: CONFIG += insignificant_test # failures on mac, QTBUG-23681 diff --git a/tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp b/tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp index 4c5df04188..a0a314bd9d 100644 --- a/tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp +++ b/tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp @@ -140,6 +140,7 @@ void tst_QSizeGrip::hideAndShowOnWindowStateChange() #ifndef Q_OS_MAC QVERIFY(!sizeGrip->isVisible()); #else + QEXPECT_FAIL("", "QTBUG-23681", Abort); QVERIFY(sizeGrip->isVisible()); #endif diff --git a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp index 081e817727..d23f69ac6c 100644 --- a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp +++ b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp @@ -199,7 +199,9 @@ void tst_QStatusBar::setSizeGripEnabled() QVERIFY(!sizeGrip); qApp->processEvents(); +#ifndef Q_OS_MAC // Work around Lion fullscreen issues on CI system - QTQAINFRA-506 mainWindow.showFullScreen(); +#endif #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&mainWindow); #endif @@ -220,7 +222,9 @@ void tst_QStatusBar::setSizeGripEnabled() QVERIFY(!sizeGrip->isVisible()); qApp->processEvents(); +#ifndef Q_OS_MAC mainWindow.showNormal(); +#endif qApp->processEvents(); QTRY_VERIFY(sizeGrip->isVisible()); } diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index a3f58c4c0d..88489f4328 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -604,7 +604,7 @@ void tst_QTextEdit::selectAllSetsNotSelection() ed->insertPlainText("Hello World"); ed->selectAll(); - QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromAscii("foobar")); + QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromLatin1("foobar")); } #endif void tst_QTextEdit::asciiTab() |