summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/cmake/CMakeLists.txt83
-rw-r--r--tests/manual/cmake/fail4/CMakeLists.txt2
-rw-r--r--tests/manual/cmake/fail5/CMakeLists.txt2
-rw-r--r--tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt2
-rw-r--r--tests/manual/cmake/pass1/CMakeLists.txt1
-rw-r--r--tests/manual/cmake/pass2/CMakeLists.txt2
-rw-r--r--tests/manual/cmake/pass3/CMakeLists.txt2
-rw-r--r--tests/manual/cmake/pass7/CMakeLists.txt11
-rw-r--r--tests/manual/cmake/pass7/main.cpp47
-rw-r--r--tests/manual/qnetworkconfigurationmanager/main.cpp84
-rw-r--r--tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro13
11 files changed, 234 insertions, 15 deletions
diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt
index 91ead649ec..7ec3cebf4b 100644
--- a/tests/manual/cmake/CMakeLists.txt
+++ b/tests/manual/cmake/CMakeLists.txt
@@ -1,35 +1,88 @@
+# 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)
-macro(_do_build _dir)
- try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${_dir}
- ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}
- ${_dir}
- OUTPUT_VARIABLE Out
- )
-endmacro()
+enable_testing()
macro(expect_pass _dir)
- _do_build(${_dir})
- if (NOT Result)
- message(SEND_ERROR "Build failed: ${Out}")
- endif()
+ 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}
+ )
endmacro()
macro(expect_fail _dir)
- _do_build(${_dir})
- if (Result)
- message(SEND_ERROR "Build should fail, but did not: ${Out}")
- endif()
+ 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}
+ )
+ 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}
+ )
endmacro()
if(${CMAKE_VERSION} VERSION_GREATER 2.8.7)
# Requires CMAKE_AUTOMOC function in CMake 2.8.7
expect_pass(pass1)
+else()
+ message("CMake version older than 2.8.7. Not running test \"pass1\"")
endif()
expect_pass(pass2)
expect_pass(pass3)
expect_fail(fail4)
expect_fail(fail5)
+expect_pass("pass(needsquoting)6")
+expect_pass(pass7)
diff --git a/tests/manual/cmake/fail4/CMakeLists.txt b/tests/manual/cmake/fail4/CMakeLists.txt
index dcd4b8bd65..2466e24d3a 100644
--- a/tests/manual/cmake/fail4/CMakeLists.txt
+++ b/tests/manual/cmake/fail4/CMakeLists.txt
@@ -7,6 +7,8 @@ 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
diff --git a/tests/manual/cmake/fail5/CMakeLists.txt b/tests/manual/cmake/fail5/CMakeLists.txt
index f82a62b626..9aedf4a008 100644
--- a/tests/manual/cmake/fail5/CMakeLists.txt
+++ b/tests/manual/cmake/fail5/CMakeLists.txt
@@ -7,6 +7,8 @@ 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)
diff --git a/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt b/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt
index cc1a1bc588..fb971f9ebd 100644
--- a/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt
+++ b/tests/manual/cmake/pass(needsquoting)6/CMakeLists.txt
@@ -9,6 +9,8 @@ find_package(Qt5Widgets REQUIRED)
include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
+add_definitions(${Qt5Core_DEFINITIONS})
+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
qt5_wrap_cpp(moc_files mywidget.h)
diff --git a/tests/manual/cmake/pass1/CMakeLists.txt b/tests/manual/cmake/pass1/CMakeLists.txt
index f11887e545..b1922c075b 100644
--- a/tests/manual/cmake/pass1/CMakeLists.txt
+++ b/tests/manual/cmake/pass1/CMakeLists.txt
@@ -18,6 +18,7 @@ macro(qt5_use_package _target _package)
# 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})
+ set_property(TARGET ${_target} APPEND PROPERTY COMPILE_FLAGS ${Qt5${_package}_COMPILE_FLAGS})
else()
message(FATAL_ERROR "NOT FOUND: Qt5${_package}")
endif()
diff --git a/tests/manual/cmake/pass2/CMakeLists.txt b/tests/manual/cmake/pass2/CMakeLists.txt
index ac1bb15846..a52744623e 100644
--- a/tests/manual/cmake/pass2/CMakeLists.txt
+++ b/tests/manual/cmake/pass2/CMakeLists.txt
@@ -7,6 +7,8 @@ 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")
diff --git a/tests/manual/cmake/pass3/CMakeLists.txt b/tests/manual/cmake/pass3/CMakeLists.txt
index 11402e2e18..b836161813 100644
--- a/tests/manual/cmake/pass3/CMakeLists.txt
+++ b/tests/manual/cmake/pass3/CMakeLists.txt
@@ -8,6 +8,8 @@ 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)
diff --git a/tests/manual/cmake/pass7/CMakeLists.txt b/tests/manual/cmake/pass7/CMakeLists.txt
new file mode 100644
index 0000000000..e7c9b46ead
--- /dev/null
+++ b/tests/manual/cmake/pass7/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(pass7)
+
+find_package(Qt5Core REQUIRED)
+
+include_directories(${Qt5Core_INCLUDE_DIRS})
+add_definitions(${Qt5Core_DEFINITIONS})
+
+add_executable(myobject main.cpp)
diff --git a/tests/manual/cmake/pass7/main.cpp b/tests/manual/cmake/pass7/main.cpp
new file mode 100644
index 0000000000..0a6b09d877
--- /dev/null
+++ b/tests/manual/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/manual/qnetworkconfigurationmanager/main.cpp b/tests/manual/qnetworkconfigurationmanager/main.cpp
new file mode 100644
index 0000000000..2ac33d4fe1
--- /dev/null
+++ b/tests/manual/qnetworkconfigurationmanager/main.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** 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 <QDebug>
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtNetwork/qnetworkconfigmanager.h>
+
+class tst_qnetworkconfigurationmanager : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void isOnline();
+};
+
+class SignalHandler : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void onOnlineStateChanged(bool isOnline)
+ {
+ qDebug() << "Online state changed to:" << isOnline;
+ }
+};
+
+void tst_qnetworkconfigurationmanager::isOnline()
+{
+ QNetworkConfigurationManager manager;
+ qDebug() << "Testing QNetworkConfigurationManager online status reporting functionality.";
+ qDebug() << "This should tell the current online state:" << manager.isOnline();
+ qDebug() << "Now please plug / unplug the network cable, and check the state update signal.";
+ qDebug() << "Note that there might be some delays before you see the change, depending on the backend.";
+
+ SignalHandler signalHandler;
+ connect(&manager, SIGNAL(onlineStateChanged(bool)), &signalHandler, SLOT(onOnlineStateChanged(bool)));
+
+ // event loop
+ QTestEventLoop::instance().enterLoop(30);
+ QVERIFY(QTestEventLoop::instance().timeout());
+}
+
+QTEST_MAIN(tst_qnetworkconfigurationmanager)
+
+#include "main.moc"
diff --git a/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro b/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro
new file mode 100644
index 0000000000..613fcd85e4
--- /dev/null
+++ b/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TEMPLATE = app
+TARGET = tst_qnetworkconfigurationmanager
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+QT += network testlib
+
+CONFIG += release
+
+# Input
+SOURCES += main.cpp