From d8b49e6b51007d6f0a9faec82a66b95dc7ccf541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 4 Mar 2020 16:33:51 +0100 Subject: QtNetwork: Delete bearer management All remaining pieces are gone, configuration included. Relevant CMakeLists and configure.cmake were regenerated. Fixes: QTBUG-76502 Change-Id: I667b5da7e3802830d236d50b5e9190c2ee9c19e2 Reviewed-by: Lars Knoll --- tests/auto/network/CMakeLists.txt | 1 - .../tst_qabstractnetworkcache.cpp | 21 - tests/auto/network/access/qftp/tst_qftp.cpp | 57 +- tests/auto/network/bearer/CMakeLists.txt | 6 - tests/auto/network/bearer/bearer.pro | 7 - tests/auto/network/bearer/qbearertestcommon.h | 49 - .../bearer/qnetworkconfiguration/CMakeLists.txt | 13 - .../qnetworkconfiguration.pro | 6 - .../tst_qnetworkconfiguration.cpp | 203 --- .../qnetworkconfigurationmanager/CMakeLists.txt | 13 - .../qnetworkconfigurationmanager.pro | 6 - .../tst_qnetworkconfigurationmanager.cpp | 243 ---- .../CMakeLists.txt | 13 - .../qnetworkconfigurationmanagerqappless.pro | 6 - .../tst_qnetworkconfigurationmanagerqappless.cpp | 60 - .../network/bearer/qnetworksession/CMakeLists.txt | 7 - .../bearer/qnetworksession/lackey/CMakeLists.txt | 13 - .../bearer/qnetworksession/lackey/lackey.pro | 8 - .../network/bearer/qnetworksession/lackey/main.cpp | 147 --- .../bearer/qnetworksession/qnetworksession.pro | 4 - .../qnetworksession/test/.prev_CMakeLists.txt | 29 - .../bearer/qnetworksession/test/CMakeLists.txt | 30 - .../network/bearer/qnetworksession/test/test.pro | 18 - .../qnetworksession/test/tst_qnetworksession.cpp | 1299 -------------------- .../network/kernel/qhostinfo/tst_qhostinfo.cpp | 22 - .../qnetworkinterface/tst_qnetworkinterface.cpp | 33 - tests/auto/network/network.pro | 2 - .../network/socket/qtcpserver/tst_qtcpserver.cpp | 13 +- .../network/socket/qtcpsocket/tst_qtcpsocket.cpp | 1 + .../other/networkselftest/tst_networkselftest.cpp | 21 - tests/manual/.prev_CMakeLists.txt | 68 + tests/manual/CMakeLists.txt | 5 +- tests/manual/bearerex/CMakeLists.txt | 25 - tests/manual/bearerex/bearerex.cpp | 569 --------- tests/manual/bearerex/bearerex.h | 134 -- tests/manual/bearerex/bearerex.pro | 21 - tests/manual/bearerex/bearerex.ui | 95 -- tests/manual/bearerex/bearerex_maemo.ui | 100 -- tests/manual/bearerex/datatransferer.cpp | 166 --- tests/manual/bearerex/datatransferer.h | 100 -- tests/manual/bearerex/detailedinfodialog.ui | 54 - tests/manual/bearerex/main.cpp | 42 - tests/manual/bearerex/sessiondialog.ui | 187 --- tests/manual/bearerex/sessiondialog_maemo.ui | 151 --- tests/manual/bearerex/xqlistwidget.cpp | 54 - tests/manual/bearerex/xqlistwidget.h | 46 - tests/manual/manual.pro | 4 +- tests/manual/qnetworkaccessmanager/qget/qget.cpp | 3 - tests/manual/qnetworkconfiguration/CMakeLists.txt | 16 - tests/manual/qnetworkconfiguration/main.cpp | 126 -- .../qnetworkconfiguration.pro | 7 - .../qnetworkconfigurationmanager/CMakeLists.txt | 16 - tests/manual/qnetworkconfigurationmanager/main.cpp | 71 -- .../qnetworkconfigurationmanager.pro | 7 - tests/manual/socketengine/main.cpp | 3 - 55 files changed, 74 insertions(+), 4347 deletions(-) delete mode 100644 tests/auto/network/bearer/CMakeLists.txt delete mode 100644 tests/auto/network/bearer/bearer.pro delete mode 100644 tests/auto/network/bearer/qbearertestcommon.h delete mode 100644 tests/auto/network/bearer/qnetworkconfiguration/CMakeLists.txt delete mode 100644 tests/auto/network/bearer/qnetworkconfiguration/qnetworkconfiguration.pro delete mode 100644 tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp delete mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanager/CMakeLists.txt delete mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro delete mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp delete mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/CMakeLists.txt delete mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro delete mode 100644 tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp delete mode 100644 tests/auto/network/bearer/qnetworksession/CMakeLists.txt delete mode 100644 tests/auto/network/bearer/qnetworksession/lackey/CMakeLists.txt delete mode 100644 tests/auto/network/bearer/qnetworksession/lackey/lackey.pro delete mode 100644 tests/auto/network/bearer/qnetworksession/lackey/main.cpp delete mode 100644 tests/auto/network/bearer/qnetworksession/qnetworksession.pro delete mode 100644 tests/auto/network/bearer/qnetworksession/test/.prev_CMakeLists.txt delete mode 100644 tests/auto/network/bearer/qnetworksession/test/CMakeLists.txt delete mode 100644 tests/auto/network/bearer/qnetworksession/test/test.pro delete mode 100644 tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp create mode 100644 tests/manual/.prev_CMakeLists.txt delete mode 100644 tests/manual/bearerex/CMakeLists.txt delete mode 100644 tests/manual/bearerex/bearerex.cpp delete mode 100644 tests/manual/bearerex/bearerex.h delete mode 100644 tests/manual/bearerex/bearerex.pro delete mode 100644 tests/manual/bearerex/bearerex.ui delete mode 100644 tests/manual/bearerex/bearerex_maemo.ui delete mode 100644 tests/manual/bearerex/datatransferer.cpp delete mode 100644 tests/manual/bearerex/datatransferer.h delete mode 100644 tests/manual/bearerex/detailedinfodialog.ui delete mode 100644 tests/manual/bearerex/main.cpp delete mode 100644 tests/manual/bearerex/sessiondialog.ui delete mode 100644 tests/manual/bearerex/sessiondialog_maemo.ui delete mode 100644 tests/manual/bearerex/xqlistwidget.cpp delete mode 100644 tests/manual/bearerex/xqlistwidget.h delete mode 100644 tests/manual/qnetworkconfiguration/CMakeLists.txt delete mode 100644 tests/manual/qnetworkconfiguration/main.cpp delete mode 100644 tests/manual/qnetworkconfiguration/qnetworkconfiguration.pro delete mode 100644 tests/manual/qnetworkconfigurationmanager/CMakeLists.txt delete mode 100644 tests/manual/qnetworkconfigurationmanager/main.cpp delete mode 100644 tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro (limited to 'tests') diff --git a/tests/auto/network/CMakeLists.txt b/tests/auto/network/CMakeLists.txt index b7ba3de688..0e2415daac 100644 --- a/tests/auto/network/CMakeLists.txt +++ b/tests/auto/network/CMakeLists.txt @@ -15,7 +15,6 @@ endif() # special case end add_subdirectory(access) -add_subdirectory(bearer) add_subdirectory(kernel) add_subdirectory(ssl) add_subdirectory(socket) diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index 182e3e9547..b6be01d900 100644 --- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -31,12 +31,6 @@ #include #include "../../../network-settings.h" -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#include -#endif - #include #define TESTFILE QLatin1String("http://") + QtNetworkSettings::httpServerName() + QLatin1String("/qtest/cgi-bin/") @@ -77,11 +71,6 @@ private: void runTest(); void checkSynchronous(); -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager *netConfMan; - QNetworkConfiguration networkConfiguration; - QScopedPointer networkSession; -#endif }; class NetworkDiskCache : public QNetworkDiskCache @@ -133,16 +122,6 @@ void tst_QAbstractNetworkCache::initTestCase() if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); #endif - -#ifndef QT_NO_BEARERMANAGEMENT - netConfMan = new QNetworkConfigurationManager(this); - networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); - } -#endif } diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index 60acb70af4..886a589324 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -37,10 +37,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -66,7 +62,6 @@ public: private slots: void initTestCase_data(); void initTestCase(); - void cleanupTestCase(); void init(); void cleanup(); void connectToHost_data(); @@ -138,10 +133,6 @@ private: void renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete ); QFtp *ftp; -#ifndef QT_NO_BEARERMANAGEMENT - QSharedPointer networkSessionExplicit; - QSharedPointer networkSessionImplicit; -#endif QList ids; // helper to make sure that all expected signals are emitted int current_id; @@ -190,21 +181,13 @@ void tst_QFtp::initTestCase_data() { QTest::addColumn("setProxy"); QTest::addColumn("proxyType"); - QTest::addColumn("setSession"); - QTest::newRow("WithoutProxy") << false << 0 << false; + QTest::newRow("WithoutProxy") << false << 0; #if QT_CONFIG(socks5) - QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy) << false; + QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); #endif //### doesn't work well yet. //QTest::newRow("WithHttpProxy") << true << int(QNetworkProxy::HttpProxy); - -#ifndef QT_NO_BEARERMANAGEMENT - QTest::newRow("WithoutProxyWithSession") << false << 0 << true; -#if QT_CONFIG(socks5) - QTest::newRow("WithSocks5ProxyAndSession") << true << int(QNetworkProxy::Socks5Proxy) << true; -#endif -#endif } void tst_QFtp::initTestCase() @@ -217,30 +200,15 @@ void tst_QFtp::initTestCase() #else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); -#endif -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager manager; - networkSessionImplicit = QSharedPointer::create(manager.defaultConfiguration()); - networkSessionImplicit->open(); - QVERIFY(networkSessionImplicit->waitForOpened(60000)); //there may be user prompt on 1st connect #endif rfc3252File = QFINDTESTDATA("rfc3252.txt"); QVERIFY(!rfc3252File.isEmpty()); } -void tst_QFtp::cleanupTestCase() -{ -#ifndef QT_NO_BEARERMANAGEMENT - networkSessionExplicit.clear(); - networkSessionImplicit.clear(); -#endif -} - void tst_QFtp::init() { QFETCH_GLOBAL(bool, setProxy); QFETCH_GLOBAL(int, proxyType); - QFETCH_GLOBAL(bool, setSession); if (setProxy) { #ifndef QT_NO_NETWORKPROXY if (proxyType == QNetworkProxy::Socks5Proxy) { @@ -253,19 +221,6 @@ void tst_QFtp::init() QSKIP("No proxy support"); #endif // QT_NO_NETWORKPROXY } -#ifndef QT_NO_BEARERMANAGEMENT - if (setSession) { - networkSessionExplicit = networkSessionImplicit; - if (!networkSessionExplicit->isOpen()) { - networkSessionExplicit->open(); - QVERIFY(networkSessionExplicit->waitForOpened(30000)); - } - } else { - networkSessionExplicit.clear(); - } -#else - Q_UNUSED(setSession); -#endif delete ftp; ftp = 0; @@ -314,9 +269,6 @@ void tst_QFtp::cleanup() delete ftp; ftp = 0; -#ifndef QT_NO_BEARERMANAGEMENT - networkSessionExplicit.clear(); -#endif } void tst_QFtp::connectToHost_data() @@ -1947,11 +1899,6 @@ void tst_QFtp::dataTransferProgress( qint64 done, qint64 total ) QFtp *tst_QFtp::newFtp() { QFtp *nFtp = new QFtp( this ); -#ifndef QT_NO_BEARERMANAGEMENT - if (networkSessionExplicit) { - nFtp->setProperty("_q_networksession", QVariant::fromValue(networkSessionExplicit)); - } -#endif connect( nFtp, SIGNAL(commandStarted(int)), SLOT(commandStarted(int)) ); connect( nFtp, SIGNAL(commandFinished(int,bool)), diff --git a/tests/auto/network/bearer/CMakeLists.txt b/tests/auto/network/bearer/CMakeLists.txt deleted file mode 100644 index 4b593aab0a..0000000000 --- a/tests/auto/network/bearer/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Generated from bearer.pro. - -add_subdirectory(qnetworkconfiguration) -add_subdirectory(qnetworkconfigurationmanager) -add_subdirectory(qnetworkconfigurationmanagerqappless) -add_subdirectory(qnetworksession) diff --git a/tests/auto/network/bearer/bearer.pro b/tests/auto/network/bearer/bearer.pro deleted file mode 100644 index 6ce922eaf8..0000000000 --- a/tests/auto/network/bearer/bearer.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS=\ - qnetworkconfiguration \ - qnetworkconfigurationmanager \ - qnetworkconfigurationmanagerqappless \ - qnetworksession \ - diff --git a/tests/auto/network/bearer/qbearertestcommon.h b/tests/auto/network/bearer/qbearertestcommon.h deleted file mode 100644 index 923f093402..0000000000 --- a/tests/auto/network/bearer/qbearertestcommon.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBEARERTESTCOMMON_H -#define QBEARERTESTCOMMON_H - -#include - -enum { TestTimeOut = 90000 }; - -// Wait for __expr to happen, while still allowing events to be processed. -#define QTRY_NOOP(__expr) \ - do { \ - const int __step = 50; \ - const int __timeout = 15000; \ - if (!(__expr)) { \ - QTest::qWait(0); \ - } \ - for (int __i = 0; __i < __timeout && !(__expr); __i+=__step) { \ - QTest::qWait(__step); \ - } \ - } while(0) - -#endif diff --git a/tests/auto/network/bearer/qnetworkconfiguration/CMakeLists.txt b/tests/auto/network/bearer/qnetworkconfiguration/CMakeLists.txt deleted file mode 100644 index 1db8bb1e6b..0000000000 --- a/tests/auto/network/bearer/qnetworkconfiguration/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from qnetworkconfiguration.pro. - -##################################################################### -## tst_qnetworkconfiguration Test: -##################################################################### - -add_qt_test(tst_qnetworkconfiguration - SOURCES - ../qbearertestcommon.h - tst_qnetworkconfiguration.cpp - PUBLIC_LIBRARIES - Qt::Network -) diff --git a/tests/auto/network/bearer/qnetworkconfiguration/qnetworkconfiguration.pro b/tests/auto/network/bearer/qnetworkconfiguration/qnetworkconfiguration.pro deleted file mode 100644 index cde82a4fb2..0000000000 --- a/tests/auto/network/bearer/qnetworkconfiguration/qnetworkconfiguration.pro +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG += testcase -TARGET = tst_qnetworkconfiguration -SOURCES += tst_qnetworkconfiguration.cpp -HEADERS += ../qbearertestcommon.h - -QT = core network testlib diff --git a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp deleted file mode 100644 index 9c49e0c173..0000000000 --- a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "../qbearertestcommon.h" - -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#endif - -/* - Although this unit test doesn't use QNetworkAccessManager - this include is used to ensure that bearer continues to compile against - Qt 4.7+ which has a QNetworkConfiguration enabled QNetworkAccessManager -*/ -#include - -QT_USE_NAMESPACE - -class tst_QNetworkConfiguration : public QObject -{ - Q_OBJECT - -private slots: -#ifndef QT_NO_BEARERMANAGEMENT - void invalidPoint(); - void comparison(); - void children(); - void isRoamingAvailable(); - void connectTimeout(); -#endif -}; - -#ifndef QT_NO_BEARERMANAGEMENT -void tst_QNetworkConfiguration::invalidPoint() -{ - QNetworkConfiguration pt; - - QVERIFY(pt.name().isEmpty()); - QVERIFY(!pt.isValid()); - QCOMPARE(pt.type(), QNetworkConfiguration::Invalid); - QVERIFY(!(pt.state() & QNetworkConfiguration::Defined)); - QVERIFY(!(pt.state() & QNetworkConfiguration::Discovered)); - QVERIFY(!(pt.state() & QNetworkConfiguration::Active)); - QVERIFY(!pt.isRoamingAvailable()); - - QNetworkConfiguration pt2(pt); - QVERIFY(pt2.name().isEmpty()); - QVERIFY(!pt2.isValid()); - QCOMPARE(pt2.type(), QNetworkConfiguration::Invalid); - QVERIFY(!(pt2.state() & QNetworkConfiguration::Defined)); - QVERIFY(!(pt2.state() & QNetworkConfiguration::Discovered)); - QVERIFY(!(pt2.state() & QNetworkConfiguration::Active)); - QVERIFY(!pt2.isRoamingAvailable()); - -} - -void tst_QNetworkConfiguration::comparison() -{ - //test copy constructor and assignment operator - //compare invalid connection points - QNetworkConfiguration pt1; - QVERIFY(!pt1.isValid()); - QCOMPARE(pt1.type(), QNetworkConfiguration::Invalid); - - QNetworkConfiguration pt2(pt1); - QVERIFY(pt1==pt2); - QVERIFY(!(pt1!=pt2)); - QCOMPARE(pt1.name(), pt2.name()); - QCOMPARE(pt1.isValid(), pt2.isValid()); - QCOMPARE(pt1.type(), pt2.type()); - QCOMPARE(pt1.state(), pt2.state()); - QCOMPARE(pt1.purpose(), pt2.purpose()); - - - QNetworkConfiguration pt3; - pt3 = pt1; - QVERIFY(pt1==pt3); - QVERIFY(!(pt1!=pt3)); - QCOMPARE(pt1.name(), pt3.name()); - QCOMPARE(pt1.isValid(), pt3.isValid()); - QCOMPARE(pt1.type(), pt3.type()); - QCOMPARE(pt1.state(), pt3.state()); - QCOMPARE(pt1.purpose(), pt3.purpose()); - - //test case must run on machine that has valid connection points - QNetworkConfigurationManager manager; - QList preScanConfigs = manager.allConfigurations(); - - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete - - QList configs = manager.allConfigurations(QNetworkConfiguration::Discovered); - QVERIFY(configs.count()); - QNetworkConfiguration defaultConfig = manager.defaultConfiguration(); - QVERIFY(defaultConfig.isValid()); - QVERIFY(defaultConfig.type() != QNetworkConfiguration::Invalid); - QVERIFY(!defaultConfig.name().isEmpty()); - - pt3 = defaultConfig; - QVERIFY(defaultConfig==pt3); - QVERIFY(!(defaultConfig!=pt3)); - QCOMPARE(defaultConfig.name(), pt3.name()); - QCOMPARE(defaultConfig.isValid(), pt3.isValid()); - QCOMPARE(defaultConfig.type(), pt3.type()); - QCOMPARE(defaultConfig.state(), pt3.state()); - QCOMPARE(defaultConfig.purpose(), pt3.purpose()); -} - -void tst_QNetworkConfiguration::children() -{ - QNetworkConfigurationManager manager; - QList configs = manager.allConfigurations(); - - foreach(QNetworkConfiguration c, configs) - { - if ( c.type() == QNetworkConfiguration::ServiceNetwork ) { - qDebug() << "found service network" << c.name() << c.children().count(); - QVERIFY(c.isValid()); - QList members = c.children(); - foreach(QNetworkConfiguration child, members) { - QVERIFY(child.isValid()); - QVERIFY(configs.contains(child)); - qDebug() << "\t" << child.name(); - } - } - } -} - -void tst_QNetworkConfiguration::isRoamingAvailable() -{ - QNetworkConfigurationManager manager; - QList configs = manager.allConfigurations(); - - //force update to get maximum list - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete - - foreach(QNetworkConfiguration c, configs) - { - QVERIFY(QNetworkConfiguration::UserChoice != c.type()); - QVERIFY(QNetworkConfiguration::Invalid != c.type()); - if ( c.type() == QNetworkConfiguration::ServiceNetwork ) { - //cannot test flag as some SNAPs may not support roaming anyway - //QVERIFY(c.roamingavailable()) - if ( c.children().count() <= 1 ) - QVERIFY(!c.isRoamingAvailable()); - foreach(QNetworkConfiguration child, c.children()) { - QCOMPARE(QNetworkConfiguration::InternetAccessPoint, child.type()); - QCOMPARE(child.children().count(), 0); - } - } else { - QVERIFY(!c.isRoamingAvailable()); - } - } -} - -void tst_QNetworkConfiguration::connectTimeout() -{ - QNetworkConfigurationManager manager; - QList configs = manager.allConfigurations(); - - foreach (QNetworkConfiguration networkConfiguration, configs) { - QCOMPARE(networkConfiguration.connectTimeout(), 30000); - - bool result = networkConfiguration.setConnectTimeout(100); - QVERIFY(result); - - QCOMPARE(networkConfiguration.connectTimeout(), 100); - } -} -#endif - -QTEST_MAIN(tst_QNetworkConfiguration) -#include "tst_qnetworkconfiguration.moc" diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/CMakeLists.txt b/tests/auto/network/bearer/qnetworkconfigurationmanager/CMakeLists.txt deleted file mode 100644 index 355bd4898a..0000000000 --- a/tests/auto/network/bearer/qnetworkconfigurationmanager/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from qnetworkconfigurationmanager.pro. - -##################################################################### -## tst_qnetworkconfigurationmanager Test: -##################################################################### - -add_qt_test(tst_qnetworkconfigurationmanager - SOURCES - ../qbearertestcommon.h - tst_qnetworkconfigurationmanager.cpp - PUBLIC_LIBRARIES - Qt::Network -) diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro b/tests/auto/network/bearer/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro deleted file mode 100644 index 52cee1f64d..0000000000 --- a/tests/auto/network/bearer/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG += testcase -TARGET = tst_qnetworkconfigurationmanager -SOURCES += tst_qnetworkconfigurationmanager.cpp -HEADERS += ../qbearertestcommon.h - -QT = core network testlib diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp deleted file mode 100644 index b251a65420..0000000000 --- a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "../qbearertestcommon.h" - -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#endif - -QT_USE_NAMESPACE -class tst_QNetworkConfigurationManager : public QObject -{ - Q_OBJECT - -private slots: -#ifndef QT_NO_BEARERMANAGEMENT - void usedInThread(); // this test must be first, or it will falsely pass - void allConfigurations(); - void defaultConfiguration(); - void configurationFromIdentifier(); -#endif -}; - -#ifndef QT_NO_BEARERMANAGEMENT -void printConfigurationDetails(const QNetworkConfiguration& p) -{ - qDebug() << p.name() <<": isvalid->" <"<< p.type() << - " roaming->" << p.isRoamingAvailable() << "identifier->" << p.identifier() << - " purpose->" << p.purpose() << " state->" << p.state(); -} - -void tst_QNetworkConfigurationManager::allConfigurations() -{ - QNetworkConfigurationManager manager; - QList preScanConfigs = manager.allConfigurations(); - - foreach(QNetworkConfiguration c, preScanConfigs) - { - QVERIFY2(c.type()!=QNetworkConfiguration::UserChoice, "allConfiguration must not return UserChoice configs"); - } - - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete - - QList configs = manager.allConfigurations(); - - int all = configs.count(); - qDebug() << "All configurations:" << all; - QVERIFY(all); - foreach(QNetworkConfiguration p, configs) { - QVERIFY(p.isValid()); - printConfigurationDetails(p); - QVERIFY(p.type() != QNetworkConfiguration::Invalid); - QVERIFY(p.type() != QNetworkConfiguration::UserChoice); - } - - configs = manager.allConfigurations(QNetworkConfiguration::Undefined); - int undefined = configs.count(); - QVERIFY(undefined <= all); - qDebug() << "Undefined configurations:" << undefined; - foreach( const QNetworkConfiguration p, configs) { - printConfigurationDetails(p); - QVERIFY(p.state() & QNetworkConfiguration::Undefined); - QVERIFY(!(p.state() & QNetworkConfiguration::Defined)); - } - - //get defined configs only (same as all) - configs = manager.allConfigurations(QNetworkConfiguration::Defined); - int defined = configs.count(); - qDebug() << "Defined configurations:" << defined; - QVERIFY(defined <= all); - foreach( const QNetworkConfiguration p, configs) { - printConfigurationDetails(p); - QVERIFY(p.state() & QNetworkConfiguration::Defined); - QVERIFY(!(p.state() & QNetworkConfiguration::Undefined)); - } - - //get discovered configurations only - configs = manager.allConfigurations(QNetworkConfiguration::Discovered); - int discovered = configs.count(); - //QVERIFY(discovered); - qDebug() << "Discovered configurations:" << discovered; - foreach(const QNetworkConfiguration p, configs) { - printConfigurationDetails(p); - QVERIFY(p.isValid()); - QVERIFY(!(p.state() & QNetworkConfiguration::Undefined)); - QVERIFY(p.state() & QNetworkConfiguration::Defined); - QVERIFY(p.state() & QNetworkConfiguration::Discovered); - } - - //getactive configurations only - configs = manager.allConfigurations(QNetworkConfiguration::Active); - int active = configs.count(); - if (active) - QVERIFY(manager.isOnline()); - else - QVERIFY(!manager.isOnline()); - - //QVERIFY(active); - qDebug() << "Active configurations:" << active; - foreach(const QNetworkConfiguration p, configs) { - printConfigurationDetails(p); - QVERIFY(p.isValid()); - QVERIFY(!(p.state() & QNetworkConfiguration::Undefined)); - QVERIFY(p.state() & QNetworkConfiguration::Active); - QVERIFY(p.state() & QNetworkConfiguration::Discovered); - QVERIFY(p.state() & QNetworkConfiguration::Defined); - } - - QVERIFY(all >= discovered); - QVERIFY(discovered >= active); -} - - -void tst_QNetworkConfigurationManager::defaultConfiguration() -{ - QNetworkConfigurationManager manager; - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete - - QList configs = manager.allConfigurations(); - QNetworkConfiguration defaultConfig = manager.defaultConfiguration(); - - bool confirm = configs.contains(defaultConfig); - - if (defaultConfig.type() != QNetworkConfiguration::UserChoice) { - QVERIFY(confirm || !defaultConfig.isValid()); - QVERIFY(!(confirm && !defaultConfig.isValid())); - } else { - QVERIFY(!confirm); // user choice config is not part of allConfigurations() - QVERIFY(defaultConfig.isValid()); - QCOMPARE(defaultConfig.name(), QString("UserChoice")); - QCOMPARE(defaultConfig.children().count(), 0); - QVERIFY(!defaultConfig.isRoamingAvailable()); - QCOMPARE(defaultConfig.state(), QNetworkConfiguration::Discovered); - QNetworkConfiguration copy = manager.configurationFromIdentifier(defaultConfig.identifier()); - QCOMPARE(copy, defaultConfig); - } -} - -void tst_QNetworkConfigurationManager::configurationFromIdentifier() -{ - QNetworkConfigurationManager manager; - QSet allIdentifier; - - //force an update to get maximum number of configs - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete - - QList configs = manager.allConfigurations(); - - foreach(QNetworkConfiguration c, configs) { - QVERIFY(!allIdentifier.contains(c.identifier())); - allIdentifier.insert(c.identifier()); - - QNetworkConfiguration direct = manager.configurationFromIdentifier(c.identifier()); - QVERIFY(direct.isValid()); - QCOMPARE(direct, c); - } - - //assume that there is no item with identifier 'FooBar' - QVERIFY(!allIdentifier.contains("FooBar")); - QNetworkConfiguration invalid = manager.configurationFromIdentifier("FooBar"); - QVERIFY(!invalid.isValid()); -} - -class QNCMTestThread : public QThread -{ -protected: - virtual void run() - { - QNetworkConfigurationManager manager; - preScanConfigs = manager.allConfigurations(); - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete - configs = manager.allConfigurations(); - } -public: - QList configs; - QList preScanConfigs; -}; - -// regression test for QTBUG-18795 -void tst_QNetworkConfigurationManager::usedInThread() -{ -#if defined Q_OS_MAC && !defined (QT_NO_COREWLAN) - QSKIP("QTBUG-19070 Mac CoreWlan plugin is broken"); -#else - QNCMTestThread thread; - connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - thread.start(); - QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY_WITH_TIMEOUT could take ~90 seconds to time out in the thread - QVERIFY(!QTestEventLoop::instance().timeout()); - qDebug() << "prescan:" << thread.preScanConfigs.count(); - qDebug() << "postscan:" << thread.configs.count(); - - QNetworkConfigurationManager manager; - QList preScanConfigs = manager.allConfigurations(); - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); //initiate scans - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete - QList configs = manager.allConfigurations(); - QCOMPARE(thread.configs, configs); - //Don't compare pre scan configs, because these may be cached and therefore give different results - //which makes the test unstable. The post scan results should have all configurations every time - //QCOMPARE(thread.preScanConfigs, preScanConfigs); -#endif -} -#endif - -QTEST_MAIN(tst_QNetworkConfigurationManager) -#include "tst_qnetworkconfigurationmanager.moc" diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/CMakeLists.txt b/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/CMakeLists.txt deleted file mode 100644 index dcf18785bf..0000000000 --- a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from qnetworkconfigurationmanagerqappless.pro. - -##################################################################### -## tst_qnetworkconfigurationmanagerqappless Test: -##################################################################### - -add_qt_test(tst_qnetworkconfigurationmanagerqappless - SOURCES - ../qbearertestcommon.h - tst_qnetworkconfigurationmanagerqappless.cpp - PUBLIC_LIBRARIES - Qt::Network -) diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro b/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro deleted file mode 100644 index ad080910d7..0000000000 --- a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/qnetworkconfigurationmanagerqappless.pro +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG += testcase -TARGET = tst_qnetworkconfigurationmanagerqappless -SOURCES += tst_qnetworkconfigurationmanagerqappless.cpp -HEADERS += ../qbearertestcommon.h - -QT = core network testlib diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp deleted file mode 100644 index fdeaa9d3b2..0000000000 --- a/tests/auto/network/bearer/qnetworkconfigurationmanagerqappless/tst_qnetworkconfigurationmanagerqappless.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -QT_USE_NAMESPACE - -class tst_QNetworkConfigurationManager : public QObject -{ - Q_OBJECT - -private slots: - void staticsInitialization(); -}; - -void tst_QNetworkConfigurationManager::staticsInitialization() -{ - // This code should not crash. The test was introduced as - // a fix for QTBUG-36897 - for (int i = 0; i < 2; i++) - { - int argc = 1; - const char *testName = "tst_qnetworkconfigurationmanagerqappless"; - char **argv = const_cast(&testName); - QCoreApplication app(argc, argv); - QNetworkAccessManager qnam; - Q_UNUSED(app); - Q_UNUSED(qnam); - } - QVERIFY(true); -} - -QTEST_APPLESS_MAIN(tst_QNetworkConfigurationManager) -#include "tst_qnetworkconfigurationmanagerqappless.moc" diff --git a/tests/auto/network/bearer/qnetworksession/CMakeLists.txt b/tests/auto/network/bearer/qnetworksession/CMakeLists.txt deleted file mode 100644 index 99c3483e6c..0000000000 --- a/tests/auto/network/bearer/qnetworksession/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Generated from qnetworksession.pro. - -add_subdirectory(test) - -if(NOT WINRT) - add_subdirectory(lackey) -endif() diff --git a/tests/auto/network/bearer/qnetworksession/lackey/CMakeLists.txt b/tests/auto/network/bearer/qnetworksession/lackey/CMakeLists.txt deleted file mode 100644 index c2d0d59d57..0000000000 --- a/tests/auto/network/bearer/qnetworksession/lackey/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from lackey.pro. - -##################################################################### -## lackey Binary: -##################################################################### - -add_qt_executable(lackey - OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/" - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Network -) diff --git a/tests/auto/network/bearer/qnetworksession/lackey/lackey.pro b/tests/auto/network/bearer/qnetworksession/lackey/lackey.pro deleted file mode 100644 index dd83d905e6..0000000000 --- a/tests/auto/network/bearer/qnetworksession/lackey/lackey.pro +++ /dev/null @@ -1,8 +0,0 @@ -SOURCES += main.cpp -TARGET = lackey - -QT = core network - -DESTDIR = ./ - -CONFIG += cmdline diff --git a/tests/auto/network/bearer/qnetworksession/lackey/main.cpp b/tests/auto/network/bearer/qnetworksession/lackey/main.cpp deleted file mode 100644 index 5fad06c2cf..0000000000 --- a/tests/auto/network/bearer/qnetworksession/lackey/main.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#include -#endif - -#include -#include -#include - -QT_USE_NAMESPACE - - -#define NO_DISCOVERED_CONFIGURATIONS_ERROR 1 -#define SESSION_OPEN_ERROR 2 - - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - -#ifndef QT_NO_BEARERMANAGEMENT - // Update configurations so that everything is up to date for this process too. - // Event loop is used to wait for awhile. - QNetworkConfigurationManager manager; - manager.updateConfigurations(); - QEventLoop iIgnoreEventLoop; - QTimer::singleShot(3000, &iIgnoreEventLoop, SLOT(quit())); - iIgnoreEventLoop.exec(); - - QList discovered = - manager.allConfigurations(QNetworkConfiguration::Discovered); - - foreach(QNetworkConfiguration config, discovered) { - qDebug() << "Lackey: Name of the config enumerated: " << config.name(); - qDebug() << "Lackey: State of the config enumerated: " << config.state(); - } - - if (discovered.isEmpty()) { - qDebug("Lackey: no discovered configurations, returning empty error."); - return NO_DISCOVERED_CONFIGURATIONS_ERROR; - } - - // Cannot read/write to processes on WinCE. - // Easiest alternative is to use sockets for IPC. - QLocalSocket oopSocket; - - oopSocket.connectToServer("tst_qnetworksession"); - oopSocket.waitForConnected(-1); - - qDebug() << "Lackey started"; - - QNetworkSession *session = 0; - do { - if (session) { - delete session; - session = 0; - } - - qDebug() << "Discovered configurations:" << discovered.count(); - - if (discovered.isEmpty()) { - qDebug() << "No more discovered configurations"; - break; - } - - qDebug() << "Taking first configuration"; - - QNetworkConfiguration config = discovered.takeFirst(); - - if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { - qDebug() << config.name() << "is active, therefore skipping it (looking for configs in 'discovered' state)."; - continue; - } - - qDebug() << "Creating session for" << config.name() << config.identifier(); - - session = new QNetworkSession(config); - - QString output = QString("Starting session for %1\n").arg(config.identifier()); - oopSocket.write(output.toLatin1()); - oopSocket.waitForBytesWritten(); - session->open(); - session->waitForOpened(); - } while (!(session && session->isOpen())); - - qDebug() << "lackey: loop done"; - - if (!session) { - qDebug() << "Could not start session"; - - oopSocket.disconnectFromServer(); - oopSocket.waitForDisconnected(-1); - - return SESSION_OPEN_ERROR; - } - - QByteArray output = "Started session for " - + session->configuration().identifier().toLatin1() + '\n'; - oopSocket.write(output); - oopSocket.waitForBytesWritten(); - - oopSocket.waitForReadyRead(); - oopSocket.readLine(); - - session->stop(); - - delete session; - - oopSocket.disconnectFromServer(); - oopSocket.waitForDisconnected(-1); -#endif - - return 0; -} diff --git a/tests/auto/network/bearer/qnetworksession/qnetworksession.pro b/tests/auto/network/bearer/qnetworksession/qnetworksession.pro deleted file mode 100644 index cd480fb73b..0000000000 --- a/tests/auto/network/bearer/qnetworksession/qnetworksession.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs -!winrt:SUBDIRS = lackey -test.depends = $$SUBDIRS -SUBDIRS += test diff --git a/tests/auto/network/bearer/qnetworksession/test/.prev_CMakeLists.txt b/tests/auto/network/bearer/qnetworksession/test/.prev_CMakeLists.txt deleted file mode 100644 index e164bccbdf..0000000000 --- a/tests/auto/network/bearer/qnetworksession/test/.prev_CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Generated from test.pro. - -##################################################################### -## tst_qnetworksession Test: -##################################################################### - -add_qt_test(tst_qnetworksession - SOURCES - ../../qbearertestcommon.h - tst_qnetworksession.cpp - PUBLIC_LIBRARIES - Qt::Network - Qt::NetworkPrivate -) - -## Scopes: -##################################################################### - -#### Keys ignored in scope 3:.:.:test.pro:(CMAKE_BUILD_TYPE STREQUAL Debug): -# DESTDIR = "../debug" - -#### Keys ignored in scope 4:.:.:test.pro:else: -# DESTDIR = "../release" - -#### Keys ignored in scope 5:.:.:test.pro:else: -# DESTDIR = ".." - -#### Keys ignored in scope 6:.:.:test.pro:NOT ANDROID AND NOT WINRT: -# TEST_HELPER_INSTALLS = "../lackey/lackey" diff --git a/tests/auto/network/bearer/qnetworksession/test/CMakeLists.txt b/tests/auto/network/bearer/qnetworksession/test/CMakeLists.txt deleted file mode 100644 index c86966600d..0000000000 --- a/tests/auto/network/bearer/qnetworksession/test/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Generated from test.pro. - -##################################################################### -## tst_qnetworksession Test: -##################################################################### - -add_qt_test(tst_qnetworksession - OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" # special case - SOURCES - ../../qbearertestcommon.h - tst_qnetworksession.cpp - PUBLIC_LIBRARIES - Qt::Network - Qt::NetworkPrivate -) - -## Scopes: -##################################################################### - -#### Keys ignored in scope 3:.:.:test.pro:(CMAKE_BUILD_TYPE STREQUAL Debug): -# DESTDIR = "../debug" - -#### Keys ignored in scope 4:.:.:test.pro:else: -# DESTDIR = "../release" - -#### Keys ignored in scope 5:.:.:test.pro:else: -# DESTDIR = ".." - -#### Keys ignored in scope 6:.:.:test.pro:NOT ANDROID AND NOT WINRT: -# TEST_HELPER_INSTALLS = "../lackey/lackey" diff --git a/tests/auto/network/bearer/qnetworksession/test/test.pro b/tests/auto/network/bearer/qnetworksession/test/test.pro deleted file mode 100644 index bfc1ec7727..0000000000 --- a/tests/auto/network/bearer/qnetworksession/test/test.pro +++ /dev/null @@ -1,18 +0,0 @@ -CONFIG += testcase -SOURCES += tst_qnetworksession.cpp -HEADERS += ../../qbearertestcommon.h - -QT = core network testlib network-private - -TARGET = tst_qnetworksession -CONFIG(debug_and_release) { - CONFIG(debug, debug|release) { - DESTDIR = ../debug - } else { - DESTDIR = ../release - } -} else { - DESTDIR = .. -} - -!android:!winrt: TEST_HELPER_INSTALLS = ../lackey/lackey diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp deleted file mode 100644 index a13adc8ebf..0000000000 --- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp +++ /dev/null @@ -1,1299 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include "../../qbearertestcommon.h" - -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#include -#endif - -QT_USE_NAMESPACE - -// Can be used to configure tests that require manual attention (such as roaming) -//#define QNETWORKSESSION_MANUAL_TESTS 1 - -#ifndef QT_NO_BEARERMANAGEMENT -Q_DECLARE_METATYPE(QNetworkConfiguration::Type) -#endif - -class tst_QNetworkSession : public QObject -{ - Q_OBJECT - -#ifndef QT_NO_BEARERMANAGEMENT -public slots: - void initTestCase(); - void cleanupTestCase(); - -private slots: - void robustnessBombing(); - - void sessionClosing_data(); - void sessionClosing(); - - void outOfProcessSession(); - void invalidSession(); - - void repeatedOpenClose_data(); - void repeatedOpenClose(); - - void sessionProperties_data(); - void sessionProperties(); - - void userChoiceSession_data(); - void userChoiceSession(); - - void sessionOpenCloseStop_data(); - void sessionOpenCloseStop(); - - void sessionAutoClose_data(); - void sessionAutoClose(); - - void usagePolicies(); - -private: - QNetworkConfigurationManager manager; - int inProcessSessionManagementCount; - QString lackeyDir; -#endif -}; - -#ifndef QT_NO_BEARERMANAGEMENT -// Helper functions -bool openSession(QNetworkSession *session); -bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration = true); -void updateConfigurations(); -void printConfigurations(); -QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType); - -void tst_QNetworkSession::initTestCase() -{ - qRegisterMetaType("QNetworkConfiguration"); - qRegisterMetaType("QNetworkConfiguration::Type"); - - inProcessSessionManagementCount = -1; - - QSignalSpy spy(&manager, SIGNAL(updateCompleted())); - manager.updateConfigurations(); - QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); - - lackeyDir = QFINDTESTDATA("lackey"); - QVERIFY2(!lackeyDir.isEmpty(), qPrintable( - QString::fromLatin1("Couldn't find lackey dir starting from %1.").arg(QDir::currentPath()))); -} - -void tst_QNetworkSession::cleanupTestCase() -{ - if (!(manager.capabilities() & QNetworkConfigurationManager::SystemSessionSupport) && - (manager.capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces) && - inProcessSessionManagementCount == 0) { - qWarning("No usable configurations found to complete all possible tests in " - "inProcessSessionManagement()"); - } -} - -// Robustness test for calling interfaces in nonsense order / with nonsense parameters -void tst_QNetworkSession::robustnessBombing() -{ - QNetworkConfigurationManager mgr; - QNetworkSession testSession(mgr.defaultConfiguration()); - // Should not reset even session is not opened - testSession.migrate(); - testSession.accept(); - testSession.ignore(); - testSession.reject(); -} - -void tst_QNetworkSession::sessionClosing_data() { - QTest::addColumn("bearerType"); - QTest::addColumn("configurationType"); - - QTest::newRow("WLAN_IAP") << "WLAN" << QNetworkConfiguration::InternetAccessPoint; - QTest::newRow("Cellular_IAP") << "cellular" << QNetworkConfiguration::InternetAccessPoint; - QTest::newRow("SNAP") << "bearer_type_not_relevant_with_SNAPs" << QNetworkConfiguration::ServiceNetwork; -} - -// Testcase for closing the session at unexpected times -void tst_QNetworkSession::sessionClosing() -{ - QFETCH(QString, bearerType); - QFETCH(QNetworkConfiguration::Type, configurationType); - - // Update configurations so that WLANs are discovered too. - updateConfigurations(); - - // First check that opening once succeeds and determine if test is doable - QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType); - if (!config.isValid()) - QSKIP("No suitable configurations, skipping this round of repeated open-close test."); - qDebug() << "Using following configuration to bomb with close(): " << config.name(); - QNetworkSession session(config); - if (!openSession(&session) || !closeSession(&session)) - QSKIP("Unable to open/close session, skipping this round of close() bombing."); - - qDebug() << "Closing without issuing open()"; - session.close(); - - for (int i = 0; i < 25; i++) { - qDebug() << "Opening and then waiting: " << i * 100 << " ms before closing."; - session.open(); - QTest::qWait(i*100); - session.close(); - // Sooner or later session must end in Disconnected state, - // no matter what the phase was. - QTRY_VERIFY_WITH_TIMEOUT(session.state() == QNetworkSession::Disconnected, TestTimeOut); - QTest::qWait(200); // Give platform a breathe, otherwise we'll be catching other errors - } -} - -void tst_QNetworkSession::invalidSession() -{ - // 1. Verify that session created with invalid configuration remains in invalid state - QNetworkSession session(QNetworkConfiguration(), 0); - QVERIFY(!session.isOpen()); - QCOMPARE(session.state(), QNetworkSession::Invalid); - QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError); - - // 2. Verify that opening session with invalid configuration both 1) emits invalidconfigurationerror and 2) sets session's state as invalid. - QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError))); - session.open(); - session.waitForOpened(1000); // Should bail out right away - QCOMPARE(errorSpy.count(), 1); - QNetworkSession::SessionError error = - qvariant_cast (errorSpy.first().at(0)); - QCOMPARE(error, QNetworkSession::InvalidConfigurationError); - QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError); - QCOMPARE(session.state(), QNetworkSession::Invalid); - -#ifdef QNETWORKSESSION_MANUAL_TESTS - - QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); - if (invalidatedConfig.isValid()) { - // 3. Verify that invalidating a session after its successfully configured works - QNetworkSession invalidatedSession(invalidatedConfig); - qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - QVERIFY(!invalidatedConfig.isValid()); - QCOMPARE(invalidatedSession.state(), QNetworkSession::Invalid); - qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - } - - QNetworkConfiguration definedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); - if (definedConfig.isValid()) { - // 4. Verify that opening a session with defined configuration emits error and enters notavailable-state - // TODO these timer waits should be changed to waiting appropriate signals, now these wait excessively - qDebug() << "Shutdown WLAN IAP (waiting 60 seconds): " << definedConfig.name(); - QTest::qWait(60000); - // Shutting down WLAN should bring back to defined -state. - QVERIFY((definedConfig.state() & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined); - QNetworkSession definedSession(definedConfig); - QSignalSpy errorSpy(&definedSession, SIGNAL(error(QNetworkSession::SessionError))); - QNetworkSession::SessionError sessionError; - updateConfigurations(); - - definedSession.open(); - updateConfigurations(); - - QVERIFY(definedConfig.isValid()); // Session remains valid - QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage - QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration - sessionError = qvariant_cast (errorSpy.first().at(0)); - QCOMPARE(sessionError, QNetworkSession::InvalidConfigurationError); - qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name(); - QTest::qWait(60000); - updateConfigurations(); - QCOMPARE(definedConfig.state(), QNetworkConfiguration::Discovered); - } -#endif -} - -void tst_QNetworkSession::sessionProperties_data() -{ - QTest::addColumn("configuration"); - - QTest::newRow("invalid configuration") << QNetworkConfiguration(); - - foreach (const QNetworkConfiguration &config, manager.allConfigurations()) { - const QString name = config.name().isEmpty() ? QString("") : config.name(); - QTest::newRow(name.toLocal8Bit().constData()) << config; - } -} - -void tst_QNetworkSession::sessionProperties() -{ - QFETCH(QNetworkConfiguration, configuration); - QNetworkSession session(configuration); - QCOMPARE(session.configuration(), configuration); - QStringList validBearerNames = QStringList() << QLatin1String("Unknown") - << QLatin1String("Ethernet") - << QLatin1String("WLAN") - << QLatin1String("2G") - << QLatin1String("CDMA2000") - << QLatin1String("WCDMA") - << QLatin1String("HSPA") - << QLatin1String("Bluetooth") - << QLatin1String("WiMAX") - << QLatin1String("BearerEVDO") - << QLatin1String("BearerLTE") - << QLatin1String("Bearer3G") - << QLatin1String("Bearer4G"); - - if (!configuration.isValid()) { - QVERIFY(configuration.bearerTypeName().isEmpty()); - } else { - switch (configuration.type()) - { - case QNetworkConfiguration::ServiceNetwork: - case QNetworkConfiguration::UserChoice: - default: - QVERIFY(configuration.bearerTypeName().isEmpty()); - break; - case QNetworkConfiguration::InternetAccessPoint: - QVERIFY(validBearerNames.contains(configuration.bearerTypeName())); - break; - } - } - - // QNetworkSession::interface() should return an invalid interface unless - // session is in the connected state. -#ifndef QT_NO_NETWORKINTERFACE - QCOMPARE(session.state() == QNetworkSession::Connected, session.interface().isValid()); -#endif - - if (!configuration.isValid()) { - QVERIFY(configuration.state() == QNetworkConfiguration::Undefined && - session.state() == QNetworkSession::Invalid); - } else { - switch (configuration.state()) { - case QNetworkConfiguration::Undefined: - QCOMPARE(session.state(), QNetworkSession::NotAvailable); - break; - case QNetworkConfiguration::Defined: - QCOMPARE(session.state(), QNetworkSession::NotAvailable); - break; - case QNetworkConfiguration::Discovered: - QVERIFY(session.state() == QNetworkSession::Connecting || - session.state() == QNetworkSession::Disconnected); - break; - case QNetworkConfiguration::Active: - QVERIFY(session.state() == QNetworkSession::Connected || - session.state() == QNetworkSession::Closing || - session.state() == QNetworkSession::Roaming); - break; - default: - QFAIL("Invalid configuration state"); - }; - } -} - -void tst_QNetworkSession::repeatedOpenClose_data() { - QTest::addColumn("bearerType"); - QTest::addColumn("configurationType"); - QTest::addColumn("repeatTimes"); - - QTest::newRow("WLAN_IAP") << "WLAN" << QNetworkConfiguration::InternetAccessPoint << 3; - // QTest::newRow("Cellular_IAP") << "cellular" << QNetworkConfiguration::InternetAccessPoint << 3; - // QTest::newRow("SNAP") << "bearer_type_not_relevant_with_SNAPs" << QNetworkConfiguration::ServiceNetwork << 3; -} - -// Tests repeated-open close. -void tst_QNetworkSession::repeatedOpenClose() -{ - QFETCH(QString, bearerType); - QFETCH(QNetworkConfiguration::Type, configurationType); - QFETCH(int, repeatTimes); - - // First check that opening once succeeds and determine if repeatable testing is doable - QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType); - if (!config.isValid()) - QSKIP("No suitable configurations, skipping this round of repeated open-close test."); - qDebug() << "Using following configuratio to repeatedly open and close: " << config.name(); - QNetworkSession permanentSession(config); - if (!openSession(&permanentSession) || !closeSession(&permanentSession)) - QSKIP("Unable to open/close session, skipping this round of repeated open-close test."); - for (int i = 0; i < repeatTimes; i++) { - qDebug() << "Opening, loop number " << i; - QVERIFY(openSession(&permanentSession)); - qDebug() << "Closing, loop number, then waiting 5 seconds: " << i; - QVERIFY(closeSession(&permanentSession)); - QTest::qWait(5000); - } -} - -void tst_QNetworkSession::userChoiceSession_data() -{ - QTest::addColumn("configuration"); - - QNetworkConfiguration config = manager.defaultConfiguration(); - if (config.type() == QNetworkConfiguration::UserChoice) - QTest::newRow("UserChoice") << config; - else - QSKIP("Default configuration is not a UserChoice configuration."); -} - -void tst_QNetworkSession::userChoiceSession() -{ - QFETCH(QNetworkConfiguration, configuration); - - QCOMPARE(configuration.type(), QNetworkConfiguration::UserChoice); - - QNetworkSession session(configuration); - - // Check that configuration was really set - QCOMPARE(session.configuration(), configuration); - - QVERIFY(!session.isOpen()); - - // Check that session is not active - QVERIFY(session.sessionProperty("ActiveConfiguration").toString().isEmpty()); - - // The remaining tests require the session to be not NotAvailable. - if (session.state() == QNetworkSession::NotAvailable) - QSKIP("Network is not available."); - - QSignalSpy sessionOpenedSpy(&session, SIGNAL(opened())); - QSignalSpy sessionClosedSpy(&session, SIGNAL(closed())); - QSignalSpy stateChangedSpy(&session, SIGNAL(stateChanged(QNetworkSession::State))); - QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError))); - - // Test opening the session. - { - bool expectStateChange = session.state() != QNetworkSession::Connected; - - session.open(); - session.waitForOpened(); - - if (session.isOpen()) - QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); - if (!errorSpy.isEmpty()) { - QNetworkSession::SessionError error = - qvariant_cast(errorSpy.first().at(0)); - if (error == QNetworkSession::OperationNotSupportedError) { - // The session needed to bring up the interface, - // but the operation is not supported. - QSKIP("Configuration does not support open()."); - } else if (error == QNetworkSession::InvalidConfigurationError) { - // The session needed to bring up the interface, but it is not possible for the - // specified configuration. - if ((session.configuration().state() & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { - QFAIL("Failed to open session for Discovered configuration."); - } else { - QSKIP("Cannot test session for non-Discovered configuration."); - } - } else if (error == QNetworkSession::UnknownSessionError) { - QSKIP("Unknown session error."); - } else { - QFAIL("Error opening session."); - } - } else if (!sessionOpenedSpy.isEmpty()) { - QCOMPARE(sessionOpenedSpy.count(), 1); - QVERIFY(sessionClosedSpy.isEmpty()); - QVERIFY(errorSpy.isEmpty()); - - if (expectStateChange) - QTRY_VERIFY_WITH_TIMEOUT(!stateChangedSpy.isEmpty(), TestTimeOut); - - QCOMPARE(session.state(), QNetworkSession::Connected); -#ifndef QT_NO_NETWORKINTERFACE - QVERIFY(session.interface().isValid()); -#endif - const QString userChoiceIdentifier = - session.sessionProperty("UserChoiceConfiguration").toString(); - - QVERIFY(!userChoiceIdentifier.isEmpty()); - QVERIFY(userChoiceIdentifier != configuration.identifier()); - - QNetworkConfiguration userChoiceConfiguration = - manager.configurationFromIdentifier(userChoiceIdentifier); - - QVERIFY(userChoiceConfiguration.isValid()); - QVERIFY(userChoiceConfiguration.type() != QNetworkConfiguration::UserChoice); - - const QString testIdentifier("abc"); - //resetting UserChoiceConfiguration is ignored (read only property) - session.setSessionProperty("UserChoiceConfiguration", testIdentifier); - QVERIFY(session.sessionProperty("UserChoiceConfiguration").toString() != testIdentifier); - - const QString activeIdentifier = - session.sessionProperty("ActiveConfiguration").toString(); - - QVERIFY(!activeIdentifier.isEmpty()); - QVERIFY(activeIdentifier != configuration.identifier()); - - QNetworkConfiguration activeConfiguration = - manager.configurationFromIdentifier(activeIdentifier); - - QVERIFY(activeConfiguration.isValid()); - QCOMPARE(activeConfiguration.type(), QNetworkConfiguration::InternetAccessPoint); - - //resetting ActiveConfiguration is ignored (read only property) - session.setSessionProperty("ActiveConfiguration", testIdentifier); - QVERIFY(session.sessionProperty("ActiveConfiguration").toString() != testIdentifier); - - if (userChoiceConfiguration.type() == QNetworkConfiguration::InternetAccessPoint) { - QCOMPARE(userChoiceConfiguration, activeConfiguration); - } else { - QCOMPARE(userChoiceConfiguration.type(), QNetworkConfiguration::ServiceNetwork); - QVERIFY(userChoiceConfiguration.children().contains(activeConfiguration)); - } - } else { - QFAIL("Timeout waiting for session to open."); - } - } -} - -void tst_QNetworkSession::sessionOpenCloseStop_data() -{ - QTest::addColumn("configuration"); - QTest::addColumn("forceSessionStop"); - - foreach (const QNetworkConfiguration &config, manager.allConfigurations()) { - const QString name = config.name().isEmpty() ? QString("") : config.name(); - QTest::newRow((name + QLatin1String(" close")).toLocal8Bit().constData()) - << config << false; - QTest::newRow((name + QLatin1String(" stop")).toLocal8Bit().constData()) - << config << true; - } - - inProcessSessionManagementCount = 0; -} - -void tst_QNetworkSession::sessionOpenCloseStop() -{ - QFETCH(QNetworkConfiguration, configuration); - QFETCH(bool, forceSessionStop); -#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) - QSKIP("Deadlocks on Linux due to QTBUG-45655"); -#endif - - QNetworkSession session(configuration); - - // Test initial state of the session. - { - QCOMPARE(session.configuration(), configuration); - QVERIFY(!session.isOpen()); - // session may be invalid if configuration is removed between when - // sessionOpenCloseStop_data() is called and here. - QVERIFY((configuration.isValid() && (session.state() != QNetworkSession::Invalid)) || - (!configuration.isValid() && (session.state() == QNetworkSession::Invalid))); - QCOMPARE(session.error(), QNetworkSession::UnknownSessionError); - } - - // The remaining tests require the session to be not NotAvailable. - if (session.state() == QNetworkSession::NotAvailable) - QSKIP("Network is not available."); - - QSignalSpy sessionOpenedSpy(&session, SIGNAL(opened())); - QSignalSpy sessionClosedSpy(&session, SIGNAL(closed())); - QSignalSpy stateChangedSpy(&session, SIGNAL(stateChanged(QNetworkSession::State))); - QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError))); - - // Test opening the session. - { - QNetworkSession::State previousState = session.state(); - bool expectStateChange = previousState != QNetworkSession::Connected; - - session.open(); - session.waitForOpened(); - - // Wait until the configuration is uptodate as well, it may be signaled 'connected' - // bit later than the session - QTRY_VERIFY_WITH_TIMEOUT(configuration.state() == QNetworkConfiguration::Active, TestTimeOut); - - if (session.isOpen()) - QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); - if (!errorSpy.isEmpty()) { - QNetworkSession::SessionError error = - qvariant_cast(errorSpy.first().at(0)); - - QCOMPARE(session.state(), previousState); - - if (error == QNetworkSession::OperationNotSupportedError) { - // The session needed to bring up the interface, - // but the operation is not supported. - QSKIP("Configuration does not support open()."); - } else if (error == QNetworkSession::InvalidConfigurationError) { - // The session needed to bring up the interface, but it is not possible for the - // specified configuration. - if ((session.configuration().state() & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { - QFAIL("Failed to open session for Discovered configuration."); - } else { - QSKIP("Cannot test session for non-Discovered configuration."); - } - } else if (error == QNetworkSession::UnknownSessionError) { - QSKIP("Unknown Session error."); - } else { - QFAIL("Error opening session."); - } - } else if (!sessionOpenedSpy.isEmpty()) { - QCOMPARE(sessionOpenedSpy.count(), 1); - QVERIFY(sessionClosedSpy.isEmpty()); - QVERIFY(errorSpy.isEmpty()); - - if (expectStateChange) { - QTRY_VERIFY_WITH_TIMEOUT(stateChangedSpy.count() >= 2, TestTimeOut); - - QNetworkSession::State state = - qvariant_cast(stateChangedSpy.at(0).at(0)); - QCOMPARE(state, QNetworkSession::Connecting); - - state = qvariant_cast(stateChangedSpy.at(1).at(0)); - QCOMPARE(state, QNetworkSession::Connected); - } - - QCOMPARE(session.state(), QNetworkSession::Connected); -#ifndef QT_NO_NETWORKINTERFACE - QVERIFY(session.interface().isValid()); -#endif - } else { - QFAIL("Timeout waiting for session to open."); - } - } - - sessionOpenedSpy.clear(); - sessionClosedSpy.clear(); - stateChangedSpy.clear(); - errorSpy.clear(); - - QNetworkSession session2(configuration); - - QSignalSpy sessionOpenedSpy2(&session2, SIGNAL(opened())); - QSignalSpy sessionClosedSpy2(&session2, SIGNAL(closed())); - QSignalSpy stateChangedSpy2(&session2, SIGNAL(stateChanged(QNetworkSession::State))); - QSignalSpy errorSpy2(&session2, SIGNAL(error(QNetworkSession::SessionError))); - - // Test opening a second session. - { - QCOMPARE(session2.configuration(), configuration); - QVERIFY(!session2.isOpen()); - QCOMPARE(session2.state(), QNetworkSession::Connected); - QCOMPARE(session.error(), QNetworkSession::UnknownSessionError); - - session2.open(); - - QTRY_VERIFY_WITH_TIMEOUT(!sessionOpenedSpy2.isEmpty() || !errorSpy2.isEmpty(), TestTimeOut); - - if (errorSpy2.isEmpty()) { - QVERIFY(session2.isOpen()); - QCOMPARE(session2.state(), QNetworkSession::Connected); - } - QVERIFY(session.isOpen()); - QCOMPARE(session.state(), QNetworkSession::Connected); -#ifndef QT_NO_NETWORKINTERFACE - QVERIFY(session.interface().isValid()); - if (errorSpy2.isEmpty()) { - QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); - QCOMPARE(session.interface().index(), session2.interface().index()); - } -#endif - } - - sessionOpenedSpy2.clear(); - - if (forceSessionStop && session2.isOpen()) { - // Test forcing the second session to stop the interface. - QNetworkSession::State previousState = session.state(); - bool expectStateChange = previousState != QNetworkSession::Disconnected; - session2.stop(); - - // QNetworkSession::stop() must result either closed() signal - // or error() signal - QTRY_VERIFY_WITH_TIMEOUT(!sessionClosedSpy2.isEmpty() || !errorSpy2.isEmpty(), TestTimeOut); - QVERIFY(!session2.isOpen()); - - if (!errorSpy2.isEmpty()) { - // QNetworkSession::stop() resulted error() signal for session2 - // => also session should emit error() signal - QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), TestTimeOut); - - // check for SessionAbortedError - QNetworkSession::SessionError error = - qvariant_cast(errorSpy.first().at(0)); - QNetworkSession::SessionError error2 = - qvariant_cast(errorSpy2.first().at(0)); - - QCOMPARE(error, QNetworkSession::SessionAbortedError); - QCOMPARE(error2, QNetworkSession::SessionAbortedError); - - QCOMPARE(errorSpy.count(), 1); - QCOMPARE(errorSpy2.count(), 1); - - errorSpy.clear(); - errorSpy2.clear(); - } - - QVERIFY(errorSpy.isEmpty()); - QVERIFY(errorSpy2.isEmpty()); - - // Wait for Disconnected state - QTRY_NOOP(session2.state() == QNetworkSession::Disconnected); - - if (expectStateChange) - QTRY_VERIFY_WITH_TIMEOUT(stateChangedSpy2.count() >= 1 || !errorSpy2.isEmpty(), TestTimeOut); - - if (!errorSpy2.isEmpty()) { - QCOMPARE(session2.state(), previousState); - QCOMPARE(session.state(), previousState); - - QNetworkSession::SessionError error = - qvariant_cast(errorSpy2.first().at(0)); - if (error == QNetworkSession::OperationNotSupportedError) { - // The session needed to bring down the interface, - // but the operation is not supported. - QSKIP("Configuration does not support stop()."); - } else if (error == QNetworkSession::InvalidConfigurationError) { - // The session needed to bring down the interface, but it is not possible for the - // specified configuration. - if ((session.configuration().state() & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { - QFAIL("Failed to stop session for Discovered configuration."); - } else { - QSKIP("Cannot test session for non-Discovered configuration."); - } - } else { - QFAIL("Error stopping session."); - } - } else if (!sessionClosedSpy2.isEmpty()) { - if (expectStateChange) { - if (configuration.type() == QNetworkConfiguration::ServiceNetwork) { - bool roamedSuccessfully = false; - - QNetworkSession::State state; - if (stateChangedSpy2.count() == 4) { - state = qvariant_cast(stateChangedSpy2.at(0).at(0)); - QCOMPARE(state, QNetworkSession::Connecting); - - state = qvariant_cast(stateChangedSpy2.at(1).at(0)); - QCOMPARE(state, QNetworkSession::Connected); - - state = qvariant_cast(stateChangedSpy2.at(2).at(0)); - QCOMPARE(state, QNetworkSession::Closing); - - state = qvariant_cast(stateChangedSpy2.at(3).at(0)); - QCOMPARE(state, QNetworkSession::Disconnected); - } else if (stateChangedSpy2.count() == 2) { - state = qvariant_cast(stateChangedSpy2.at(0).at(0)); - QCOMPARE(state, QNetworkSession::Closing); - - state = qvariant_cast(stateChangedSpy2.at(1).at(0)); - QCOMPARE(state, QNetworkSession::Disconnected); - } else { - QFAIL("Unexpected amount of state changes when roaming."); - } - - QTRY_VERIFY_WITH_TIMEOUT(session.state() == QNetworkSession::Roaming || - session.state() == QNetworkSession::Connected || - session.state() == QNetworkSession::Disconnected, TestTimeOut); - - QTRY_VERIFY_WITH_TIMEOUT(stateChangedSpy.count() > 0, TestTimeOut); - state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 1).at(0)); - - for (int i = 0; i < stateChangedSpy.count(); i++) { - QNetworkSession::State state_temp = - qvariant_cast(stateChangedSpy.at(i).at(0)); - // Extra debug because a fragile point in testcase because statuses vary. - qDebug() << "------- Statechange spy at: " << i << " is " << state_temp; - } - - if (state == QNetworkSession::Roaming) { - QTRY_VERIFY_WITH_TIMEOUT(session.state() == QNetworkSession::Connected, TestTimeOut); - QTRY_VERIFY_WITH_TIMEOUT(session2.state() == QNetworkSession::Connected, TestTimeOut); - roamedSuccessfully = true; - } else if (state == QNetworkSession::Closing) { - QTRY_VERIFY_WITH_TIMEOUT(session2.state() == QNetworkSession::Disconnected, TestTimeOut); - QTRY_VERIFY_WITH_TIMEOUT(session.state() == QNetworkSession::Connected || - session.state() == QNetworkSession::Disconnected, TestTimeOut ); - roamedSuccessfully = false; - } else if (state == QNetworkSession::Disconnected) { - QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), TestTimeOut); - QTRY_VERIFY_WITH_TIMEOUT(session2.state() == QNetworkSession::Disconnected, TestTimeOut); - } else if (state == QNetworkSession::Connected) { - QTRY_VERIFY_WITH_TIMEOUT(errorSpy.isEmpty(),TestTimeOut); - - if (stateChangedSpy.count() > 1) { - state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); - QCOMPARE(state, QNetworkSession::Roaming); - } - roamedSuccessfully = true; - } - - if (roamedSuccessfully) { - // Verify that you can open session based on the disconnected configuration - QString configId = session.sessionProperty("ActiveConfiguration").toString(); - QNetworkConfiguration config = manager.configurationFromIdentifier(configId); - QNetworkSession session3(config); - QSignalSpy errorSpy3(&session3, SIGNAL(error(QNetworkSession::SessionError))); - QSignalSpy sessionOpenedSpy3(&session3, SIGNAL(opened())); - session3.open(); - session3.waitForOpened(); - QTest::qWait(1000); // Wait awhile to get all signals from platform - if (session.isOpen()) - QVERIFY(!sessionOpenedSpy3.isEmpty() || !errorSpy3.isEmpty()); - session.stop(); - QTRY_VERIFY_WITH_TIMEOUT(session.state() == QNetworkSession::Disconnected, TestTimeOut); - } - if (!roamedSuccessfully) - QVERIFY(!errorSpy.isEmpty()); - } else { - QTest::qWait(2000); // Wait awhile to get all signals from platform - - if (stateChangedSpy2.count() == 2) { - QNetworkSession::State state = - qvariant_cast(stateChangedSpy2.at(0).at(0)); - QCOMPARE(state, QNetworkSession::Closing); - state = qvariant_cast(stateChangedSpy2.at(1).at(0)); - QCOMPARE(state, QNetworkSession::Disconnected); - } else { - QVERIFY(stateChangedSpy2.count() >= 1); - - for (int i = 0; i < stateChangedSpy2.count(); i++) { - QNetworkSession::State state_temp = - qvariant_cast(stateChangedSpy2.at(i).at(0)); - // Extra debug because a fragile point in testcase. - qDebug() << "+++++ Statechange spy at: " << i << " is " << state_temp; - } - - QNetworkSession::State state = - qvariant_cast(stateChangedSpy2.at(stateChangedSpy2.count() - 1).at(0)); - QCOMPARE(state, QNetworkSession::Disconnected); - } - } - - QTRY_VERIFY_WITH_TIMEOUT(!sessionClosedSpy.isEmpty(), TestTimeOut); - QTRY_VERIFY_WITH_TIMEOUT(session.state() == QNetworkSession::Disconnected, TestTimeOut); - } - - QVERIFY(errorSpy2.isEmpty()); - - ++inProcessSessionManagementCount; - } else { - QFAIL("Timeout waiting for session to stop."); - } - - QVERIFY(!sessionClosedSpy.isEmpty()); - QVERIFY(!sessionClosedSpy2.isEmpty()); - - QVERIFY(!session.isOpen()); - QVERIFY(!session2.isOpen()); - } else if (session2.isOpen()) { - // Test closing the second session. - { - int stateChangedCountBeforeClose = stateChangedSpy2.count(); - session2.close(); - - QTRY_VERIFY_WITH_TIMEOUT(!sessionClosedSpy2.isEmpty(), TestTimeOut); - QCOMPARE(stateChangedSpy2.count(), stateChangedCountBeforeClose); - - QVERIFY(sessionClosedSpy.isEmpty()); - - QVERIFY(session.isOpen()); - QVERIFY(!session2.isOpen()); - QCOMPARE(session.state(), QNetworkSession::Connected); - QCOMPARE(session2.state(), QNetworkSession::Connected); -#ifndef QT_NO_NETWORKINTERFACE - QVERIFY(session.interface().isValid()); - QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); - QCOMPARE(session.interface().index(), session2.interface().index()); -#endif - } - - sessionClosedSpy2.clear(); - - // Test closing the first session. - { - bool expectStateChange = session.state() != QNetworkSession::Disconnected && - manager.capabilities() & QNetworkConfigurationManager::SystemSessionSupport; - - session.close(); - - QTRY_VERIFY_WITH_TIMEOUT(!sessionClosedSpy.isEmpty() || !errorSpy.isEmpty(), TestTimeOut); - - QVERIFY(!session.isOpen()); - - if (expectStateChange) - QTRY_VERIFY_WITH_TIMEOUT(!stateChangedSpy.isEmpty() || !errorSpy.isEmpty(), TestTimeOut); - - if (!errorSpy.isEmpty()) { - QNetworkSession::SessionError error = - qvariant_cast(errorSpy.first().at(0)); - if (error == QNetworkSession::OperationNotSupportedError) { - // The session needed to bring down the interface, - // but the operation is not supported. - QSKIP("Configuration does not support close()."); - } else if (error == QNetworkSession::InvalidConfigurationError) { - // The session needed to bring down the interface, but it is not possible for the - // specified configuration. - if ((session.configuration().state() & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { - QFAIL("Failed to close session for Discovered configuration."); - } else { - QSKIP("Cannot test session for non-Discovered configuration."); - } - } else { - QFAIL("Error closing session."); - } - } else if (!sessionClosedSpy.isEmpty()) { - QVERIFY(sessionOpenedSpy.isEmpty()); - QCOMPARE(sessionClosedSpy.count(), 1); - if (expectStateChange) - QVERIFY(!stateChangedSpy.isEmpty()); - QVERIFY(errorSpy.isEmpty()); - - if (expectStateChange) - QTRY_VERIFY_WITH_TIMEOUT(session.state() == QNetworkSession::Disconnected, TestTimeOut); - - ++inProcessSessionManagementCount; - } else { - QFAIL("Timeout waiting for session to close."); - } - } - } -} - -QDebug operator<<(QDebug debug, const QList &list) -{ - debug.nospace() << "( "; - foreach (const QNetworkConfiguration &config, list) - debug.nospace() << config.identifier() << ", "; - debug.nospace() << ")\n"; - return debug; -} - -// Note: outOfProcessSession requires that at least one configuration is -// at Discovered -state. -void tst_QNetworkSession::outOfProcessSession() -{ -#if !QT_CONFIG(process) - QSKIP("No qprocess support", SkipAll); -#else - updateConfigurations(); - QTest::qWait(2000); - - QNetworkConfigurationManager manager; - // Create a QNetworkConfigurationManager to detect configuration changes made in Lackey. This - // is actually the essence of this testcase - to check that platform mediates/reflects changes - // regardless of process boundaries. The interprocess communication is more like a way to get - // this test-case act correctly and timely. - QList before = manager.allConfigurations(QNetworkConfiguration::Active); - QSignalSpy spy(&manager, SIGNAL(configurationChanged(QNetworkConfiguration))); - - // Cannot read/write to processes on WinCE. - // Easiest alternative is to use sockets for IPC. - QLocalServer oopServer; - // First remove possible earlier listening address which would cause listen to fail - // (e.g. previously abruptly ended unit test might cause this) - QLocalServer::removeServer("tst_qnetworksession"); - oopServer.listen("tst_qnetworksession"); - - QProcess lackey; - QString lackeyExe = lackeyDir + "/lackey"; - lackey.start(lackeyExe); - QVERIFY2(lackey.waitForStarted(), qPrintable( - QString::fromLatin1("Could not start %1: %2").arg(lackeyExe, lackey.errorString()))); - - QVERIFY(oopServer.waitForNewConnection(-1)); - QLocalSocket *oopSocket = oopServer.nextPendingConnection(); - - do { - QByteArray output; - - if (oopSocket->waitForReadyRead()) - output = oopSocket->readLine().trimmed(); - - if (output.startsWith("Started session ")) { - QString identifier = QString::fromLocal8Bit(output.mid(20).constData()); - QNetworkConfiguration changed; - - do { - QTRY_VERIFY_WITH_TIMEOUT(!spy.isEmpty(), TestTimeOut); - changed = qvariant_cast(spy.takeFirst().at(0)); - } while (changed.identifier() != identifier); - - QVERIFY((changed.state() & QNetworkConfiguration::Active) == - QNetworkConfiguration::Active); - - QVERIFY(!before.contains(changed)); - - QList after = - manager.allConfigurations(QNetworkConfiguration::Active); - - QVERIFY(after.contains(changed)); - - spy.clear(); - - oopSocket->write("stop\n"); - oopSocket->waitForBytesWritten(); - - do { - QTRY_VERIFY_WITH_TIMEOUT(!spy.isEmpty(), TestTimeOut); - - changed = qvariant_cast(spy.takeFirst().at(0)); - } while (changed.identifier() != identifier); - - QVERIFY((changed.state() & QNetworkConfiguration::Active) != - QNetworkConfiguration::Active); - - QList afterStop = - manager.allConfigurations(QNetworkConfiguration::Active); - - QVERIFY(!afterStop.contains(changed)); - - oopSocket->disconnectFromServer(); - oopSocket->waitForDisconnected(-1); - - lackey.waitForFinished(); - } - // This is effected by QTBUG-4903, process will always report as running - //} while (lackey.state() == QProcess::Running); - - // Workaround: the socket in the lackey will disconnect on exit - } while (oopSocket->state() == QLocalSocket::ConnectedState); - - switch (lackey.exitCode()) { - case 0: - qDebug("Lackey returned exit success (0)"); - break; - case 1: - QSKIP("No discovered configurations found."); - case 2: - QSKIP("Lackey could not start session."); - default: - QSKIP("Lackey failed"); - } -#endif -} - -// A convenience / helper function for testcases. Return the first matching configuration. -// Ignores configurations in other than 'discovered' -state. Returns invalid (QNetworkConfiguration()) -// if none found. -QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType) { - - // Refresh configurations and derive configurations matching given parameters. - QNetworkConfigurationManager mgr; - QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted())); - - mgr.updateConfigurations(); - QTRY_NOOP(updateSpy.count() >= 1); - if (updateSpy.count() != 1) { - qDebug("tst_QNetworkSession::suitableConfiguration() failure: unable to update configurations"); - return QNetworkConfiguration(); - } - QList discoveredConfigs = mgr.allConfigurations(QNetworkConfiguration::Discovered); - foreach(QNetworkConfiguration config, discoveredConfigs) { - if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { - discoveredConfigs.removeOne(config); - } else if (config.type() != configType) { - // qDebug() << "Dumping config because type (IAP/SNAP) mismatches: " << config.name(); - discoveredConfigs.removeOne(config); - } else if ((config.type() == QNetworkConfiguration::InternetAccessPoint) && - bearerType == "cellular") { // 'cellular' bearertype is for convenience - if (config.bearerTypeName() != "2G" && - config.bearerTypeName() != "CDMA2000" && - config.bearerTypeName() != "WCDMA" && - config.bearerTypeName() != "HSPA" && - config.bearerTypeName() != "EVDO" && - config.bearerTypeName() != "LTE" && - config.bearerTypeName() != "3G" && - config.bearerTypeName() != "4G") { - // qDebug() << "Dumping config because bearer mismatches (cellular): " << config.name(); - discoveredConfigs.removeOne(config); - } - } else if ((config.type() == QNetworkConfiguration::InternetAccessPoint) && - bearerType != config.bearerTypeName()) { - // qDebug() << "Dumping config because bearer mismatches (WLAN): " << config.name(); - discoveredConfigs.removeOne(config); - } - } - if (discoveredConfigs.isEmpty()) { - qDebug("tst_QNetworkSession::suitableConfiguration() failure: no suitable configurations present."); - return QNetworkConfiguration(); - } else { - return discoveredConfigs.first(); - } -} - -// A convenience-function: updates configurations and waits that they are updated. -void updateConfigurations() -{ - QNetworkConfigurationManager mgr; - QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted())); - mgr.updateConfigurations(); - QTRY_NOOP(updateSpy.count() >= 1); -} - -// A convenience-function: updates and prints all available confiurations and their states -void printConfigurations() -{ - QNetworkConfigurationManager manager; - QList allConfigs = - manager.allConfigurations(); - qDebug("tst_QNetworkSession::printConfigurations QNetworkConfigurationManager gives following configurations: "); - foreach(QNetworkConfiguration config, allConfigs) { - qDebug() << "Name of the configuration: " << config.name(); - qDebug() << "State of the configuration: " << config.state(); - } -} - -// A convenience function for test-cases: opens the given configuration and return -// true if it was done gracefully. -bool openSession(QNetworkSession *session) { - bool result = true; - QNetworkConfigurationManager mgr; - QSignalSpy openedSpy(session, SIGNAL(opened())); - QSignalSpy stateChangeSpy(session, SIGNAL(stateChanged(QNetworkSession::State))); - QSignalSpy errorSpy(session, SIGNAL(error(QNetworkSession::SessionError))); - QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration))); - // Store some initial statuses, because expected signals differ if the config is already - // active by some other session - QNetworkConfiguration::StateFlags configInitState = session->configuration().state(); - QNetworkSession::State sessionInitState = session->state(); - qDebug() << "tst_QNetworkSession::openSession() name of the configuration to be opened: " << session->configuration().name(); - qDebug() << "tst_QNetworkSession::openSession() state of the configuration to be opened: " << session->configuration().state(); - qDebug() << "tst_QNetworkSession::openSession() state of the session to be opened: " << session->state(); - - if (session->isOpen() || - !session->sessionProperty("ActiveConfiguration").toString().isEmpty()) { - qDebug("tst_QNetworkSession::openSession() failure: session was already open / active."); - result = false; - } else { - session->open(); - session->waitForOpened(120000); // Bringing interfaces up and down may take time at platform - } - QTest::qWait(5000); // Wait a moment to ensure all signals are propagated - // Check that connection opening went by the book. Add checks here if more strictness needed. - if (!session->isOpen()) { - qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::open() failed."); - result = false; - } - if (openedSpy.count() != 1) { - qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::opened() - signal not received."); - result = false; - } - if (!errorSpy.isEmpty()) { - qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::error() - signal was detected."); - result = false; - } - if (sessionInitState != QNetworkSession::Connected && - stateChangeSpy.isEmpty()) { - qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::stateChanged() - signals not detected."); - result = false; - } - if (configInitState != QNetworkConfiguration::Active && - configChangeSpy.isEmpty()) { - qDebug("tst_QNetworkSession::openSession() failure: QNetworkConfigurationManager::configurationChanged() - signals not detected."); - result = false; - } - if (session->configuration().state() != QNetworkConfiguration::Active) { - qDebug("tst_QNetworkSession::openSession() failure: session's configuration is not in 'Active' -state."); - qDebug() << "tst_QNetworkSession::openSession() state is: " << session->configuration().state(); - result = false; - } - if (result == false) { - qDebug() << "tst_QNetworkSession::openSession() opening session failed."; - } else { - qDebug() << "tst_QNetworkSession::openSession() opening session succeeded."; - } - qDebug() << "tst_QNetworkSession::openSession() name of the configuration is: " << session->configuration().name(); - qDebug() << "tst_QNetworkSession::openSession() configuration state is: " << session->configuration().state(); - qDebug() << "tst_QNetworkSession::openSession() session state is: " << session->state(); - - return result; -} - -// Helper function for closing opened session. Performs checks that -// session is closed gradefully (e.g. signals). Function does not delete -// the session. The lastSessionOnConfiguration (true by default) is used to -// tell if there are more sessions open, basing on same configuration. This -// impacts the checks made. -bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { - if (!session) { - qDebug("tst_QNetworkSession::closeSession() failure: NULL session given"); - return false; - } - - qDebug() << "tst_QNetworkSession::closeSession() name of the configuration to be closed: " << session->configuration().name(); - qDebug() << "tst_QNetworkSession::closeSession() state of the configuration to be closed: " << session->configuration().state(); - qDebug() << "tst_QNetworkSession::closeSession() state of the session to be closed: " << session->state(); - - if (session->state() != QNetworkSession::Connected || - !session->isOpen()) { - qDebug("tst_QNetworkSession::closeSession() failure: session is not opened."); - return false; - } - QNetworkConfigurationManager mgr; - QSignalSpy sessionClosedSpy(session, SIGNAL(closed())); - QSignalSpy sessionStateChangedSpy(session, SIGNAL(stateChanged(QNetworkSession::State))); - QSignalSpy sessionErrorSpy(session, SIGNAL(error(QNetworkSession::SessionError))); - QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration))); - - bool result = true; - session->close(); - QTest::qWait(5000); // Wait a moment so that all signals are propagated - - if (!sessionErrorSpy.isEmpty()) { - qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::error() received."); - result = false; - } - if (sessionClosedSpy.count() != 1) { - qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::closed() signal not received."); - result = false; - } - if (lastSessionOnConfiguration && - sessionStateChangedSpy.isEmpty()) { - qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::stateChanged() signals not received."); - result = false; - } - if (lastSessionOnConfiguration && - session->state() != QNetworkSession::Disconnected) { - qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession is not in Disconnected -state"); - result = false; - } - QTRY_NOOP(!configChangeSpy.isEmpty()); - if (lastSessionOnConfiguration && - configChangeSpy.isEmpty()) { - qDebug("tst_QNetworkSession::closeSession() failure: QNetworkConfigurationManager::configurationChanged() - signal not detected."); - result = false; - } - if (lastSessionOnConfiguration && - session->configuration().state() == QNetworkConfiguration::Active) { - qDebug("tst_QNetworkSession::closeSession() failure: session's configuration is still in active state."); - result = false; - } - if (result == false) { - qDebug() << "tst_QNetworkSession::closeSession() closing session failed."; - } else { - qDebug() << "tst_QNetworkSession::closeSession() closing session succeeded."; - } - qDebug() << "tst_QNetworkSession::closeSession() name of the configuration is: " << session->configuration().name(); - qDebug() << "tst_QNetworkSession::closeSession() configuration state is: " << session->configuration().state(); - qDebug() << "tst_QNetworkSession::closeSession() session state is: " << session->state(); - return result; -} - -void tst_QNetworkSession::sessionAutoClose_data() -{ - QTest::addColumn("configuration"); - - bool testData = false; - foreach (const QNetworkConfiguration &config, - manager.allConfigurations(QNetworkConfiguration::Discovered)) { - QNetworkSession session(config); - if (!session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")).isValid()) - continue; - - testData = true; - - const QString name = config.name().isEmpty() ? QString("") : config.name(); - QTest::newRow(name.toLocal8Bit().constData()) << config; - } - - if (!testData) - QSKIP("No applicable configurations to test"); -} - -void tst_QNetworkSession::sessionAutoClose() -{ - QFETCH(QNetworkConfiguration, configuration); - - QNetworkSession session(configuration); - - QCOMPARE(session.configuration(), configuration); - - QVariant autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); - - QVERIFY(autoCloseSession.isValid()); - - // property defaults to false - QCOMPARE(autoCloseSession.toInt(), -1); - - QSignalSpy closeSpy(&session, SIGNAL(closed())); - - session.open(); - session.waitForOpened(); - - if (!session.isOpen()) - QSKIP("Session not open"); - - // set session to auto close at next polling interval. - session.setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), 0); - - QTRY_VERIFY_WITH_TIMEOUT(!closeSpy.isEmpty(), TestTimeOut); - - QCOMPARE(session.state(), QNetworkSession::Connected); - - QVERIFY(!session.isOpen()); - - QCOMPARE(session.configuration(), configuration); - - autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); - - QVERIFY(autoCloseSession.isValid()); - - QCOMPARE(autoCloseSession.toInt(), -1); -} - -void tst_QNetworkSession::usagePolicies() -{ - QNetworkSession session(manager.defaultConfiguration()); - QNetworkSession::UsagePolicies initial; - initial = session.usagePolicies(); - if (initial != 0) - QNetworkSessionPrivate::setUsagePolicies(session, { }); - QSignalSpy spy(&session, SIGNAL(usagePoliciesChanged(QNetworkSession::UsagePolicies))); - QNetworkSessionPrivate::setUsagePolicies(session, QNetworkSession::NoBackgroundTrafficPolicy); - QCOMPARE(spy.count(), 1); - QNetworkSession::UsagePolicies policies = qvariant_cast(spy.at(0).at(0)); - QCOMPARE(policies, QNetworkSession::NoBackgroundTrafficPolicy); - QCOMPARE(session.usagePolicies(), QNetworkSession::NoBackgroundTrafficPolicy); - QNetworkSessionPrivate::setUsagePolicies(session, initial); - spy.clear(); - - session.open(); - QVERIFY(session.waitForOpened()); - - //policies may be changed when session is opened, if so, signal should have been emitted - if (session.usagePolicies() != initial) - QCOMPARE(spy.count(), 1); - else - QCOMPARE(spy.count(), 0); -} - - -#endif - -QTEST_MAIN(tst_QNetworkSession) -#include "tst_qnetworksession.moc" diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index a603b2d879..c4364aeb4e 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -47,12 +47,6 @@ #include #include -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#include -#endif - #include #if defined(Q_OS_WIN) #include @@ -121,11 +115,6 @@ private: bool lookupDone; int lookupsDoneCounter; QHostInfo lookupResults; -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager *netConfMan; - QNetworkConfiguration networkConfiguration; - QScopedPointer networkSession; -#endif }; void tst_QHostInfo::swapFunction() @@ -180,17 +169,6 @@ void tst_QHostInfo::staticInformation() void tst_QHostInfo::initTestCase() { -#ifndef QT_NO_BEARERMANAGEMENT - //start the default network - netConfMan = new QNetworkConfigurationManager(this); - networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - networkSession->waitForOpened(30000); - } -#endif - ipv6Available = false; ipv6LookupsAvailable = false; diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index bc6e5435df..47dd80a1c2 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -33,10 +33,6 @@ #include #include #include -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#endif #include "../../../network-settings.h" #include "emulationdetector.h" @@ -54,7 +50,6 @@ public: private slots: void initTestCase(); - void cleanupTestCase(); void dump(); void consistencyCheck(); void loopbackIPv4(); @@ -64,13 +59,6 @@ private slots: void interfaceFromXXX_data(); void interfaceFromXXX(); void copyInvalidInterface(); - -private: -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager *netConfMan; - QNetworkConfiguration networkConfiguration; - QScopedPointer networkSession; -#endif }; tst_QNetworkInterface::tst_QNetworkInterface() @@ -92,27 +80,6 @@ void tst_QNetworkInterface::initTestCase() { if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); -#ifndef QT_NO_BEARERMANAGEMENT - netConfMan = new QNetworkConfigurationManager(this); - if (netConfMan->capabilities() - & QNetworkConfigurationManager::NetworkSessionRequired) { - networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); - } - } -#endif -} - -void tst_QNetworkInterface::cleanupTestCase() -{ -#ifndef QT_NO_BEARERMANAGEMENT - if (networkSession && networkSession->isOpen()) { - networkSession->close(); - } -#endif } void tst_QNetworkInterface::dump() diff --git a/tests/auto/network/network.pro b/tests/auto/network/network.pro index 9a3ababe61..2572bb235f 100644 --- a/tests/auto/network/network.pro +++ b/tests/auto/network/network.pro @@ -2,10 +2,8 @@ TEMPLATE=subdirs SUBDIRS=\ selftest \ access \ - bearer \ kernel \ ssl \ socket \ 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/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 849d8b0ed1..094e28149c 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -55,12 +55,10 @@ #include #include #include +#include #include -#include -#include -#include #include "../../../network-settings.h" #if defined(Q_OS_LINUX) @@ -123,9 +121,6 @@ private: bool ipv6GetsockoptionMissing(int level, int optname); #endif -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkSession *networkSession; -#endif QString crashingServerDir; }; @@ -169,12 +164,6 @@ void tst_QTcpServer::initTestCase() if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); #endif -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager man; - networkSession = new QNetworkSession(man.defaultConfiguration(), this); - networkSession->open(); - QVERIFY(networkSession->waitForOpened()); -#endif } void tst_QTcpServer::init() diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 6dd390ccbd..88d2c46f3d 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #if QT_CONFIG(process) diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 396e23da0c..ebdad53e31 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -35,12 +35,6 @@ #include #include -#ifndef QT_NO_BEARERMANAGEMENT -#include -#include -#include -#endif - #include "../../network-settings.h" class tst_NetworkSelfTest: public QObject @@ -83,12 +77,6 @@ private slots: // ssl supported test void supportsSsl(); -private: -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager *netConfMan; - QNetworkConfiguration networkConfiguration; - QScopedPointer networkSession; -#endif }; class Chat @@ -372,15 +360,6 @@ void tst_NetworkSelfTest::initTestCase() { if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); -#ifndef QT_NO_BEARERMANAGEMENT - netConfMan = new QNetworkConfigurationManager(this); - networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); - } -#endif } void tst_NetworkSelfTest::hostTest() diff --git a/tests/manual/.prev_CMakeLists.txt b/tests/manual/.prev_CMakeLists.txt new file mode 100644 index 0000000000..8c872a2f39 --- /dev/null +++ b/tests/manual/.prev_CMakeLists.txt @@ -0,0 +1,68 @@ +# Generated from manual.pro. + +add_subdirectory(filetest) +add_subdirectory(embeddedintoforeignwindow) +add_subdirectory(foreignwindows) +add_subdirectory(gestures) +add_subdirectory(highdpi) +add_subdirectory(inputmethodhints) +add_subdirectory(keypadnavigation) +add_subdirectory(lance) +add_subdirectory(qcursor) +add_subdirectory(qdesktopservices) +add_subdirectory(qdesktopwidget) +add_subdirectory(qgraphicsitem) +add_subdirectory(qgraphicsitemgroup) +add_subdirectory(qgraphicslayout/flicker) +add_subdirectory(qhttpnetworkconnection) +add_subdirectory(qimagereader) +add_subdirectory(qlayout) +add_subdirectory(qlocale) +add_subdirectory(qmimedatabase) +add_subdirectory(qnetconmonitor) +add_subdirectory(qnetworkaccessmanager/qget) +add_subdirectory(qnetworkreply) +add_subdirectory(qstorageinfo) +add_subdirectory(qscreen) +add_subdirectory(qsslsocket) +add_subdirectory(qsysinfo) +add_subdirectory(qtabletevent) +add_subdirectory(qtexteditlist) +add_subdirectory(qtexttableborders) +add_subdirectory(qtbug-8933) +add_subdirectory(qtbug-52641) +add_subdirectory(qtouchevent) +add_subdirectory(touch) +add_subdirectory(qwidget_zorder) +add_subdirectory(repaint) +add_subdirectory(socketengine) +add_subdirectory(textrendering) +add_subdirectory(widgets) +add_subdirectory(windowflags) +add_subdirectory(windowgeometry) +add_subdirectory(windowmodality) +add_subdirectory(widgetgrab) +add_subdirectory(xembed-raster) +add_subdirectory(xembed-widgets) +add_subdirectory(shortcuts) +add_subdirectory(dialogs) +add_subdirectory(windowtransparency) +add_subdirectory(unc) +add_subdirectory(qtabbar) +add_subdirectory(rhi) +if(UNIX) + add_subdirectory(network_remote_stresstest) + add_subdirectory(network_stresstest) +endif() +if(QT_FEATURE_openssl) + add_subdirectory(qssloptions) +endif() +if(QT_FEATURE_opengl) + add_subdirectory(qopengltextureblitter) +endif() +if(QT_FEATURE_egl AND QT_FEATURE_opengl) + add_subdirectory(qopenglcontext) +endif() +if(QT_FEATURE_vulkan) + add_subdirectory(qvulkaninstance) +endif() diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index 20a810a8c1..7fd2f93966 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -1,13 +1,12 @@ # Generated from manual.pro. -# special case begn +# special case begin # Don't build manual tests when targeting iOS. if(UIKIT) return() endif() # special case end -add_subdirectory(bearerex) add_subdirectory(filetest) # special case begin # diaglib is broken in dev due to missing @@ -33,8 +32,6 @@ add_subdirectory(qlocale) add_subdirectory(qmimedatabase) add_subdirectory(qnetconmonitor) add_subdirectory(qnetworkaccessmanager/qget) -add_subdirectory(qnetworkconfigurationmanager) -add_subdirectory(qnetworkconfiguration) #special case begin if (QT_FEATURE_openssl AND UNIX) add_subdirectory(qnetworkreply) diff --git a/tests/manual/bearerex/CMakeLists.txt b/tests/manual/bearerex/CMakeLists.txt deleted file mode 100644 index 3a09ac5358..0000000000 --- a/tests/manual/bearerex/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Generated from bearerex.pro. - -##################################################################### -## BearerEx Binary: -##################################################################### - -add_qt_manual_test(BearerEx - GUI - SOURCES - bearerex.cpp bearerex.h bearerex.ui - datatransferer.cpp datatransferer.h - detailedinfodialog.ui - main.cpp - sessiondialog.ui - xqlistwidget.cpp xqlistwidget.h - PUBLIC_LIBRARIES - Qt::Gui - Qt::Network - Qt::Widgets - ENABLE_AUTOGEN_TOOLS - uic -) - -#### Keys ignored in scope 1:.:.:bearerex.pro:: -# TEMPLATE = "app" diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp deleted file mode 100644 index d9b916907b..0000000000 --- a/tests/manual/bearerex/bearerex.cpp +++ /dev/null @@ -1,569 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bearerex.h" -#include "datatransferer.h" - -#include -#include - -BearerEx::BearerEx(QWidget* parent) - : QMainWindow(parent) -{ - setupUi(this); - - createMenus(); - - connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), this, SLOT(configurationsUpdateCompleted())); - connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(QNetworkConfiguration)), - this, SLOT(configurationAdded(QNetworkConfiguration))); - connect(&m_NetworkConfigurationManager, SIGNAL(configurationRemoved(QNetworkConfiguration)), - this, SLOT(configurationRemoved(QNetworkConfiguration))); - connect(&m_NetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), - this, SLOT(onlineStateChanged(bool))); - connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(QNetworkConfiguration)), - this, SLOT(configurationChanged(QNetworkConfiguration))); - showConfigurations(); -} - -void BearerEx::createMenus() -{ - QAction* act1 = new QAction(tr("Show Details"), this); - menuBar()->addAction(act1); - connect(act1, SIGNAL(triggered()), this, SLOT(on_showDetailsButton_clicked())); - - QAction* exitAct = new QAction(tr("Exit"), this); - menuBar()->addAction(exitAct); - connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); -} - -void BearerEx::showConfigurations() -{ - listWidget->clear(); - QListWidgetItem* listItem; - - QNetworkConfiguration defaultConfig = m_NetworkConfigurationManager.defaultConfiguration(); - if (defaultConfig.type() == QNetworkConfiguration::UserChoice) { - listItem = new QListWidgetItem(); - QFont font = listItem->font(); - font.setBold(true); - font.setUnderline(true); - listItem->setFont(font); - listItem->setText(" UserChoice"); - listItem->setData(Qt::UserRole, QVariant::fromValue(defaultConfig)); - listWidget->addItem(listItem); - } - - QList configurations = m_NetworkConfigurationManager.allConfigurations(); - for (int i=0; ifont(); - font.setBold(true); - font.setUnderline(true); - listItem->setFont(font); - } - listItem->setText(text); - listItem->setData(Qt::UserRole, QVariant::fromValue(configurations[i])); - listWidget->addItem(listItem); - } -} - -void BearerEx::on_updateConfigurationsButton_clicked() -{ - m_NetworkConfigurationManager.updateConfigurations(); -} - -void BearerEx::on_updateListButton_clicked() -{ - showConfigurations(); -} - -void BearerEx::on_showDetailsButton_clicked() -{ - QListWidgetItem* item = listWidget->currentItem(); - if (!item) { - return; - } - - QNetworkConfiguration networkConfiguration = qvariant_cast(item->data(Qt::UserRole)); - DetailedInfoDialog infoDialog(&networkConfiguration,this); - infoDialog.exec(); -} - -void BearerEx::on_createSessionButton_clicked() -{ - QListWidgetItem* item = listWidget->currentItem(); - if (!item) { - return; - } - QNetworkConfiguration networkConfiguration = qvariant_cast(item->data(Qt::UserRole)); - int newTabIndex = mainTabWidget->count(); - SessionTab* newTab = new SessionTab(&networkConfiguration,&m_NetworkConfigurationManager,eventListWidget,newTabIndex-1); - QString label = QLatin1Char('S') + QString::number(newTabIndex-1); - mainTabWidget->insertTab(newTabIndex,newTab,label); - mainTabWidget->setCurrentIndex(newTabIndex); -} - -void BearerEx::on_clearEventListButton_clicked() -{ - eventListWidget->clear(); -} - -void BearerEx::configurationAdded(const QNetworkConfiguration& config) -{ - QListWidgetItem* listItem = new QListWidgetItem(); - listItem->setText(QString("Added: ")+config.name()); - eventListWidget->addItem(listItem); -} - -void BearerEx::configurationRemoved(const QNetworkConfiguration& config) -{ - QListWidgetItem* listItem = new QListWidgetItem(); - listItem->setText(QString("Removed: ")+config.name()); - eventListWidget->addItem(listItem); -} - -void BearerEx::onlineStateChanged(bool isOnline) -{ - QListWidgetItem* listItem = new QListWidgetItem(); - QFont font = listItem->font(); - font.setBold(true); - listItem->setFont(font); - if (isOnline) { - listItem->setText(QString("> Online")); - } else { - listItem->setText(QString("< Offline")); - } - eventListWidget->addItem(listItem); -} - -void BearerEx::configurationChanged(const QNetworkConfiguration & config) -{ - QListWidgetItem* listItem = new QListWidgetItem(); - QString state; - switch (config.state()) - { - case QNetworkConfiguration::Undefined: - state = "Undef : "; - break; - case QNetworkConfiguration::Defined: - state = "Def : "; - break; - case QNetworkConfiguration::Discovered: - state = "Disc : "; - break; - case QNetworkConfiguration::Active: - state = "Act : "; - break; - } - listItem->setText(state+config.name()); - eventListWidget->addItem(listItem); -} - -void BearerEx::configurationsUpdateCompleted() -{ - QMessageBox msgBox; - msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText("Configurations update completed."); - msgBox.exec(); -} - -DetailedInfoDialog::DetailedInfoDialog(QNetworkConfiguration* apNetworkConfiguration, QWidget * parent) - : QDialog(parent) -{ - setupUi(this); - - tableWidget->setColumnCount(2); - int rowCount = 2; - - if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) { - rowCount = rowCount + apNetworkConfiguration->children().count(); - } - - tableWidget->setRowCount(rowCount); - tableWidget->setColumnWidth(1,250); - tableWidget->setItem(0, 0, new QTableWidgetItem(tr("Name"))); - tableWidget->setItem(0, 1, new QTableWidgetItem(apNetworkConfiguration->name())); - tableWidget->setItem(1, 0, new QTableWidgetItem(tr("Id"))); - tableWidget->setItem(1, 1, new QTableWidgetItem(apNetworkConfiguration->identifier())); - if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) { - for (int i=0; ichildren().count(); i++) { - tableWidget->setItem(i+2, 0, new QTableWidgetItem(QString("IAP")+QString::number(i+1))); - tableWidget->setItem(i+2, 1, new QTableWidgetItem(apNetworkConfiguration->children()[i].name())); - } - } - - tableWidget->setFocusPolicy(Qt::NoFocus); -} - -SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, - QNetworkConfigurationManager* configManager, - QListWidget* eventListWidget, - int index, - BearerEx * parent) - : QWidget(parent), m_dataTransferer(0), m_eventListWidget(eventListWidget), - m_index(index), m_alrEnabled (false) -{ - setupUi(this); - - m_ConfigManager = configManager; - m_NetworkSession = new QNetworkSession(*apNetworkConfiguration); - - // Update initial Session state to UI - newState(m_NetworkSession->state()); - - connect(m_NetworkSession, SIGNAL(newConfigurationActivated()), this, SLOT(newConfigurationActivated())); - connect(m_NetworkSession, SIGNAL(stateChanged(QNetworkSession::State)), - this, SLOT(stateChanged(QNetworkSession::State))); - connect(m_NetworkSession, SIGNAL(opened()), this, SLOT(opened())); - connect(m_NetworkSession, SIGNAL(closed()), this, SLOT(closed())); - connect(m_NetworkSession, SIGNAL(error(QNetworkSession::SessionError)), this, SLOT(error(QNetworkSession::SessionError))); - - if (apNetworkConfiguration->type() == QNetworkConfiguration::InternetAccessPoint) { - snapLabel->hide(); - snapLineEdit->hide(); - alrButton->hide(); - iapLineEdit->setText(apNetworkConfiguration->name()+ " (" + apNetworkConfiguration->identifier() - + QLatin1Char(')')); - } else if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) { - snapLineEdit->setText(apNetworkConfiguration->name()+ " (" + apNetworkConfiguration->identifier() - + QLatin1Char(')')); - } - bearerLineEdit->setText(apNetworkConfiguration->bearerTypeName()); - sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+ - QString(" / ")+ - QString::number(m_NetworkSession->bytesReceived())); - snapLineEdit->setFocusPolicy(Qt::NoFocus); - iapLineEdit->setFocusPolicy(Qt::NoFocus); - bearerLineEdit->setFocusPolicy(Qt::NoFocus); - sentRecDataLineEdit->setFocusPolicy(Qt::NoFocus); - stateLineEdit->setFocusPolicy(Qt::NoFocus); -} - -SessionTab::~SessionTab() -{ - delete m_NetworkSession; m_NetworkSession = 0; - delete m_dataTransferer; m_dataTransferer = 0; -} - -void SessionTab::on_createQNetworkAccessManagerButton_clicked() -{ - if (m_dataTransferer) { - disconnect(m_dataTransferer, 0, 0, 0); - delete m_dataTransferer; - m_dataTransferer = 0; - } - // Create new object according to current selection - QString type(comboBox->currentText()); - if (type == "QNAM") { - m_dataTransferer = new DataTransfererQNam(this); - } else if (type == "QTcpSocket") { - m_dataTransferer = new DataTransfererQTcp(this); - } else { - qDebug("BearerEx Warning, unknown data transfer object requested, not creating anything."); - return; - } - createQNetworkAccessManagerButton->setText("Recreate"); - connect(m_dataTransferer, SIGNAL(finished(quint32,qint64,QString)), this, SLOT(finished(quint32,qint64,QString))); -} - -void SessionTab::on_sendRequestButton_clicked() -{ - if (m_dataTransferer) { - if (!m_dataTransferer->transferData()) { - QMessageBox msgBox; - msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText("Data transfer not started. \nVery likely data transfer ongoing."); - msgBox.exec(); - } - } else { - QMessageBox msgBox; - msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText("Data object not created.\nCreate data object first."); - msgBox.exec(); - } -} - -void SessionTab::on_openSessionButton_clicked() -{ - m_NetworkSession->open(); - if (m_NetworkSession->isOpen()) { - newState(m_NetworkSession->state()); - } -} - -void SessionTab::on_closeSessionButton_clicked() -{ - m_NetworkSession->close(); - if (!m_NetworkSession->isOpen()) { - newState(m_NetworkSession->state()); - } -} - -void SessionTab::on_stopConnectionButton_clicked() -{ - m_NetworkSession->stop(); -} - -void SessionTab::on_alrButton_clicked() -{ - if (!m_alrEnabled) { - connect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)), - this, SLOT(preferredConfigurationChanged(QNetworkConfiguration,bool))); - alrButton->setText("Disable ALR"); - m_alrEnabled = true; - } else { - disconnect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)), 0, 0); - alrButton->setText("Enable ALR"); - m_alrEnabled = false; - } -} - -void SessionTab::on_deleteSessionButton_clicked() -{ - setWindowTitle("Bearer Example"); - delete this; -} - -void SessionTab::newConfigurationActivated() -{ - QMessageBox msgBox; - msgBox.setText("New configuration activated."); - msgBox.setInformativeText("Do you want to accept new configuration?"); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - if (msgBox.exec() == QMessageBox::Yes) { - m_NetworkSession->accept(); - iapLineEdit->setText(m_config.name() + " (" + m_config.identifier() + QLatin1Char(')')); - } else { - m_NetworkSession->reject(); - } -} - -void SessionTab::preferredConfigurationChanged(const QNetworkConfiguration& config, bool /*isSeamless*/) -{ - m_config = config; - QMessageBox msgBox; - msgBox.setText("Roaming to new configuration."); - msgBox.setInformativeText("Do you want to migrate to " + config.name() + QLatin1Char('?')); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - if (msgBox.exec() == QMessageBox::Yes) { - m_NetworkSession->migrate(); - } else { - m_NetworkSession->ignore(); - } -} - -void SessionTab::opened() -{ - QListWidgetItem* listItem = new QListWidgetItem(); - QFont font = listItem->font(); - font.setBold(true); - listItem->setFont(font); - listItem->setText(QLatin1Char('S') + QString::number(m_index) + QLatin1String(" - Opened")); - m_eventListWidget->addItem(listItem); - - QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration"); - if (!identifier.isNull()) { - QString configId = identifier.toString(); - QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); - if (config.isValid()) { - iapLineEdit->setText(config.name() + " (" + config.identifier() + QLatin1Char(')')); - } - } - newState(m_NetworkSession->state()); // Update the "(open)" - - if (m_NetworkSession->configuration().type() == QNetworkConfiguration::UserChoice) { - QVariant identifier = m_NetworkSession->sessionProperty("UserChoiceConfiguration"); - if (!identifier.isNull()) { - QString configId = identifier.toString(); - QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); - if (config.isValid() && (config.type() == QNetworkConfiguration::ServiceNetwork)) { - snapLineEdit->setText(config.name()); - } - } - } -} - -void SessionTab::closed() -{ - QListWidgetItem* listItem = new QListWidgetItem(); - QFont font = listItem->font(); - font.setBold(true); - listItem->setFont(font); - listItem->setText(QLatin1Char('S') + QString::number(m_index) + QLatin1String(" - Closed")); - m_eventListWidget->addItem(listItem); -} - -QString SessionTab::stateString(QNetworkSession::State state) -{ - QString stateString; - switch (state) - { - case QNetworkSession::Invalid: - stateString = "Invalid"; - break; - case QNetworkSession::NotAvailable: - stateString = "NotAvailable"; - break; - case QNetworkSession::Connecting: - stateString = "Connecting"; - break; - case QNetworkSession::Connected: - stateString = "Connected"; - break; - case QNetworkSession::Closing: - stateString = "Closing"; - break; - case QNetworkSession::Disconnected: - stateString = "Disconnected"; - break; - case QNetworkSession::Roaming: - stateString = "Roaming"; - break; - } - return stateString; -} - -void SessionTab::on_dataObjectChanged(const QString &newObjectType) -{ - qDebug() << "BearerEx SessionTab dataObjectChanged to: " << newObjectType; - if (m_dataTransferer) { - disconnect(m_dataTransferer, 0, 0, 0); - delete m_dataTransferer; m_dataTransferer = 0; - qDebug() << "BearerEx SessionTab, previous data object deleted."; - } - createQNetworkAccessManagerButton->setText("Create"); -} - - -void SessionTab::stateChanged(QNetworkSession::State state) -{ - newState(state); - - QListWidgetItem* listItem = new QListWidgetItem(); - listItem->setText(QLatin1Char('S') + QString::number(m_index) + QLatin1String(" - ") + stateString(state)); - m_eventListWidget->addItem(listItem); -} - -void SessionTab::newState(QNetworkSession::State state) -{ - QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration"); - if (state == QNetworkSession::Connected && !identifier.isNull()) { - QString configId = identifier.toString(); - QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); - if (config.isValid()) { - iapLineEdit->setText(config.name() + " (" + config.identifier() + QLatin1Char(')')); - bearerLineEdit->setText(config.bearerTypeName()); - } - } else { - bearerLineEdit->setText(m_NetworkSession->configuration().bearerTypeName()); - } - - QString active; - if (m_NetworkSession->isOpen()) { - active = " (open)"; - } - stateLineEdit->setText(stateString(state)+active); -} - -void SessionTab::error(QNetworkSession::SessionError error) -{ - QListWidgetItem* listItem = new QListWidgetItem(); - QMessageBox msgBox; - msgBox.setStandardButtons(QMessageBox::Close); - - QString errorString; - switch (error) - { - case QNetworkSession::UnknownSessionError: - errorString = "UnknownSessionError"; - break; - case QNetworkSession::SessionAbortedError: - errorString = "SessionAbortedError"; - break; - case QNetworkSession::RoamingError: - errorString = "RoamingError"; - break; - case QNetworkSession::OperationNotSupportedError: - errorString = "OperationNotSupportedError"; - break; - case QNetworkSession::InvalidConfigurationError: - errorString = "InvalidConfigurationError"; - break; - } - listItem->setText(QLatin1Char('S') + QString::number(m_index) + QString(" - ") + errorString); - m_eventListWidget->addItem(listItem); - - msgBox.setText(errorString); - msgBox.exec(); -} - -void SessionTab::finished(quint32 errorCode, qint64 dataReceived, QString errorType) -{ - QMessageBox msgBox; - msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText(QString("Data transfer completed. \nError code: ") + - QString::number(int(errorCode)) + - "\nError type: " + errorType + - "\nBytes received: " + - QString::number(dataReceived)); - msgBox.exec(); - // Check if the networksession still exists - it may have gone after returning from - // the modal dialog (in the case that app has been closed, and deleting QHttp will - // trigger the done() invocation). - if (m_NetworkSession) { - sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+ - QString(" / ")+ - QString::number(m_NetworkSession->bytesReceived())); - } else { - sentRecDataLineEdit->setText("Data amounts not available."); - } -} - -// End of file - diff --git a/tests/manual/bearerex/bearerex.h b/tests/manual/bearerex/bearerex.h deleted file mode 100644 index 7af033e59f..0000000000 --- a/tests/manual/bearerex/bearerex.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ACCESSPOINTMANAGEREX_H -#define ACCESSPOINTMANAGEREX_H - -#include - -#include "ui_detailedinfodialog.h" - -#include "ui_bearerex.h" -#include "ui_sessiondialog.h" -#include "qnetworkconfigmanager.h" -#include "qnetworksession.h" -#include "datatransferer.h" -#include "xqlistwidget.h" - -QT_BEGIN_NAMESPACE -class QNetworkAccessManager; -class QNetworkReply; -QT_END_NAMESPACE - -class SessionTab; -class DataTransferer; - -QT_USE_NAMESPACE - -class BearerEx : public QMainWindow, public Ui::BearerExMainWindow -{ - Q_OBJECT - -public: - BearerEx(QWidget* parent = 0); - void createMenus(); - void showConfigurations(); - -private Q_SLOTS: - void on_updateConfigurationsButton_clicked(); - void on_updateListButton_clicked(); - void on_showDetailsButton_clicked(); - void on_createSessionButton_clicked(); - void on_clearEventListButton_clicked(); - - void configurationsUpdateCompleted(); - void configurationAdded(const QNetworkConfiguration& config); - void configurationRemoved(const QNetworkConfiguration& config); - void onlineStateChanged(bool isOnline); - void configurationChanged(const QNetworkConfiguration & config); - -private: - QNetworkConfigurationManager m_NetworkConfigurationManager; - QAction* m_openAction; -}; - -class DetailedInfoDialog : public QDialog, public Ui::DetailedInfoDialog -{ - Q_OBJECT - -public: - DetailedInfoDialog(QNetworkConfiguration* apNetworkConfiguration = 0, QWidget* parent = 0); -}; - - -class SessionTab : public QWidget, public Ui::SessionTab -{ - Q_OBJECT - -public: - SessionTab(QNetworkConfiguration* apNetworkConfiguration = 0, QNetworkConfigurationManager* configManager = 0, - QListWidget* eventListWidget = 0, int index = 0, BearerEx* parent = 0); - ~SessionTab(); - - QString stateString(QNetworkSession::State state); - -private Q_SLOTS: - void on_createQNetworkAccessManagerButton_clicked(); - void on_sendRequestButton_clicked(); - void on_openSessionButton_clicked(); - void on_closeSessionButton_clicked(); - void on_stopConnectionButton_clicked(); - void on_deleteSessionButton_clicked(); - void on_dataObjectChanged(const QString& newObjectType); - void on_alrButton_clicked(); - void finished(quint32 errorCode, qint64 dataReceived, QString errorType); - - void newConfigurationActivated(); - void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless); - void stateChanged(QNetworkSession::State state); - void newState(QNetworkSession::State state); - void opened(); - void closed(); - void error(QNetworkSession::SessionError error); - -private: //data - // QNetworkAccessManager* m_networkAccessManager; - DataTransferer* m_dataTransferer; - QNetworkSession* m_NetworkSession; - QNetworkConfigurationManager* m_ConfigManager; - QListWidget* m_eventListWidget; - QNetworkConfiguration m_config; - int m_index; - bool m_dataTransferOngoing; - bool m_alrEnabled; -}; - -#endif // ACCESSPOINTMANAGEREX_H - -// End of file - diff --git a/tests/manual/bearerex/bearerex.pro b/tests/manual/bearerex/bearerex.pro deleted file mode 100644 index e643657660..0000000000 --- a/tests/manual/bearerex/bearerex.pro +++ /dev/null @@ -1,21 +0,0 @@ -TEMPLATE = app -TARGET = BearerEx - -QT += core \ - gui \ - widgets \ - network - -FORMS += detailedinfodialog.ui \ - sessiondialog.ui \ - bearerex.ui - -# Example headers and sources -HEADERS += bearerex.h \ - xqlistwidget.h \ - datatransferer.h - -SOURCES += bearerex.cpp \ - main.cpp \ - xqlistwidget.cpp \ - datatransferer.cpp diff --git a/tests/manual/bearerex/bearerex.ui b/tests/manual/bearerex/bearerex.ui deleted file mode 100644 index e5ab62f5b3..0000000000 --- a/tests/manual/bearerex/bearerex.ui +++ /dev/null @@ -1,95 +0,0 @@ - - BearerExMainWindow - - - - 0 - 0 - 360 - 640 - - - - Bearer Example - - - - - - - - Main - - - - - - Network Configurations - - - Qt::AlignCenter - - - - - - - - - - - - Update Configs - - - - - - - Update List - - - - - - - Create Session - - - - - - - Show Details - - - - - - - - - - Events - - - - - - - - - Clear - - - - - - - - - - - - - diff --git a/tests/manual/bearerex/bearerex_maemo.ui b/tests/manual/bearerex/bearerex_maemo.ui deleted file mode 100644 index cb17e3807c..0000000000 --- a/tests/manual/bearerex/bearerex_maemo.ui +++ /dev/null @@ -1,100 +0,0 @@ - - - BearerExMainWindow - - - - 0 - 0 - 360 - 640 - - - - Bearer Example - - - - - - - - Main - - - - - - - - Network Configurations - - - Qt::AlignCenter - - - - - - - - - - - - - - Update Configs - - - - - - - Update List - - - - - - - Create Session - - - - - - - Show Details - - - - - - - - - - Events - - - - - - - - - Clear - - - - - - - - - - - - - diff --git a/tests/manual/bearerex/datatransferer.cpp b/tests/manual/bearerex/datatransferer.cpp deleted file mode 100644 index b4409ce52c..0000000000 --- a/tests/manual/bearerex/datatransferer.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include "datatransferer.h" - -DataTransferer::DataTransferer(QObject *parent) : - QObject(parent), m_dataTransferOngoing(false) -{ -} - -bool DataTransferer::dataTransferOngoing() -{ - return m_dataTransferOngoing; -} - - - -// -------- Based on QTcp - -DataTransfererQTcp::DataTransfererQTcp(QObject* parent) -: DataTransferer(parent) -{ - qDebug("BearerEx DataTransferer QTcp created."); - - connect(&m_qsocket, SIGNAL(readyRead()), this, SLOT(readyRead())); - connect(&m_qsocket, SIGNAL(connected()), this, SLOT(connected())); - connect(&m_qsocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), - this, SLOT(error(QAbstractSocket::SocketError))); -} - -DataTransfererQTcp::~DataTransfererQTcp() -{ - qDebug("BearerEx DataTransferer QTcp destroyed."); - m_qsocket.abort(); -} - -bool DataTransfererQTcp::transferData() -{ - if (m_dataTransferOngoing) { - return false; - } - qDebug("BearerEx datatransfer for QTcp requested."); - // Connect to host - QUrl url("http://www.google.com.au"); - m_qsocket.connectToHost(url.host(), url.port(80)); - - // m_qsocket.connectToHost("http://www.google.com", 80); - // Wait for connected() signal. - m_dataTransferOngoing = true; - return true; -} - -void DataTransfererQTcp::connected() -{ - qDebug("BearerEx DataTransfererQtcp connected, requesting data."); - // Establish HTTP request - //QByteArray request("GET / HTTP/1.1 \nHost: www.google.com\n\n"); - QByteArray request("GET / HTTP/1.1\n\n"); - - // QByteArray request("GET /index.html HTTP/1.1 \n Host: www.google.com \n\n"); - qint64 dataWritten = m_qsocket.write(request); - m_qsocket.flush(); - - qDebug() << "BearerEx DataTransferQTcp wrote " << dataWritten << " bytes"; - // Start waiting for readyRead() of error() -} - -void DataTransfererQTcp::readyRead() -{ - qDebug() << "BearerEx DataTransfererQTcp readyRead() with "; - qint64 bytesAvailable = m_qsocket.bytesAvailable(); - qDebug() << bytesAvailable << " bytes available."; - - // QDataStream in(&m_qsocket); - QByteArray array = m_qsocket.readAll(); - QString data = QString::fromLatin1(array); - - // in >> data; - - qDebug() << "BearerEx DataTransferQTcp data received: " << data; - m_dataTransferOngoing = false; - // m_qsocket.error() returns uninitialized value in case no error has occurred, - // so emit '0' - emit finished(0, bytesAvailable, "QAbstractSocket::SocketError"); -} - -void DataTransfererQTcp::error(QAbstractSocket::SocketError socketError) -{ - qDebug("BearerEx DataTransfererQTcp error(), aborting socket."); - m_qsocket.abort(); - m_dataTransferOngoing = false; - emit finished(socketError, 0, "QAbstractSocket::SocketError"); -} - -// -------- Based on QNetworkAccessManager - -DataTransfererQNam::DataTransfererQNam(QObject* parent) -: DataTransferer(parent) -{ - connect(&m_qnam, SIGNAL(finished(QNetworkReply*)), - this, SLOT(replyFinished(QNetworkReply*))); - qDebug("BearerEx DataTransferer QNam created."); -} - -DataTransfererQNam::~DataTransfererQNam() -{ - qDebug("BearerEx DataTransferer QNam destroyed."); -} - -bool DataTransfererQNam::transferData() -{ - qDebug("BearerEx datatransfer for QNam requested."); - if (m_dataTransferOngoing) { - return false; - } - m_qnam.get(QNetworkRequest(QUrl("http://www.google.com"))); - m_dataTransferOngoing = true; - return true; -} - -void DataTransfererQNam::replyFinished(QNetworkReply *reply) -{ - qDebug("BearerEx DatatransfererQNam reply was finished (error code is type QNetworkReply::NetworkError)."); - qint64 dataReceived = 0; - quint32 errorCode = (quint32)reply->error(); - - if (reply->error() == QNetworkReply::NoError) { - QString result(reply->readAll()); - dataReceived = result.length(); - } - m_dataTransferOngoing = false; - emit finished(errorCode, dataReceived, "QNetworkReply::NetworkError"); - reply->deleteLater(); -} - - - diff --git a/tests/manual/bearerex/datatransferer.h b/tests/manual/bearerex/datatransferer.h deleted file mode 100644 index 645ad17c3a..0000000000 --- a/tests/manual/bearerex/datatransferer.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DATATRANSFERER_H -#define DATATRANSFERER_H - -#include -#include -#include -#include -#include -#include - -// Interface-class for data transferring object - -class DataTransferer : public QObject -{ - Q_OBJECT -public: - explicit DataTransferer(QObject *parent = 0); - virtual ~DataTransferer() { - if (m_dataTransferOngoing) { - qDebug("BearerEx Warning: dataobjects transfer was ongoing when destroyed."); - } - } - virtual bool transferData() = 0; - bool dataTransferOngoing(); - -signals: - void finished(quint32 errorCode, qint64 dataReceived, QString errorType); - -public slots: - -protected: - bool m_dataTransferOngoing; -}; - - -// Specializations/concrete classes - -class DataTransfererQTcp : public DataTransferer -{ - Q_OBJECT -public: - DataTransfererQTcp(QObject* parent = 0); - ~DataTransfererQTcp(); - - virtual bool transferData(); - -public slots: - void readyRead(); - void error(QAbstractSocket::SocketError socketError); - void connected(); - -private: - QTcpSocket m_qsocket; -}; - -class DataTransfererQNam : public DataTransferer -{ - Q_OBJECT -public: - DataTransfererQNam(QObject* parent = 0); - ~DataTransfererQNam(); - - virtual bool transferData(); - -public slots: - void replyFinished(QNetworkReply* reply); - -private: - QNetworkAccessManager m_qnam; -}; - -#endif // DATATRANSFERER_H diff --git a/tests/manual/bearerex/detailedinfodialog.ui b/tests/manual/bearerex/detailedinfodialog.ui deleted file mode 100644 index c4a21faf39..0000000000 --- a/tests/manual/bearerex/detailedinfodialog.ui +++ /dev/null @@ -1,54 +0,0 @@ - - DetailedInfoDialog - - - - 0 - 0 - 308 - 396 - - - - Bearer Example - - - - - - Detailed information - - - - - - - - - - QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - DetailedInfoDialog - accept() - - - 205 - 371 - - - 223 - 8 - - - - - diff --git a/tests/manual/bearerex/main.cpp b/tests/manual/bearerex/main.cpp deleted file mode 100644 index 47b074ebb4..0000000000 --- a/tests/manual/bearerex/main.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "bearerex.h" - -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - BearerEx bearerEx; - bearerEx.show(); - return app.exec(); -} - -// End of file - diff --git a/tests/manual/bearerex/sessiondialog.ui b/tests/manual/bearerex/sessiondialog.ui deleted file mode 100644 index c50af70f16..0000000000 --- a/tests/manual/bearerex/sessiondialog.ui +++ /dev/null @@ -1,187 +0,0 @@ - - - SessionTab - - - - 0 - 0 - 192 - 262 - - - - - - - - - SNAP - - - - - - - true - - - - - - - IAP - - - - - - - true - - - true - - - - - - - Bearer - - - - - - - true - - - - - - - Sent/Rec. - - - - - - - true - - - - - - - State - - - - - - - true - - - - - - - - - - - Open Session - - - - - - - Close Session - - - - - - - Stop Conn. - - - - - - - Enable ALR - - - - - - - Send Test Req. - - - - - - - Create - - - - - - - - QNAM - - - - - QTcpSocket - - - - - QHttp - - - - - - - - Delete Session - - - - - - - - - - - comboBox - currentIndexChanged(QString) - SessionTab - on_dataObjectChanged(QString) - - - 40 - 211 - - - 10 - 258 - - - - - - on_dataObjectChanged(QString) - - diff --git a/tests/manual/bearerex/sessiondialog_maemo.ui b/tests/manual/bearerex/sessiondialog_maemo.ui deleted file mode 100644 index 5eb98ce3d3..0000000000 --- a/tests/manual/bearerex/sessiondialog_maemo.ui +++ /dev/null @@ -1,151 +0,0 @@ - - - SessionTab - - - - 0 - 0 - 423 - 214 - - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - SNAP - - - - - - - true - - - - - - - IAP - - - - - - - true - - - true - - - - - - - Bearer - - - - - - - true - - - - - - - Sent/Rec. - - - - - - - true - - - - - - - State - - - - - - - true - - - - - - - - - - - Open Session - - - - - - - Close Session - - - - - - - Stop Conn. - - - - - - - Send Test Req. - - - - - - - Create QHttp - - - - - - - Delete Session - - - - - - - Enable ALR - - - - - - - - - - diff --git a/tests/manual/bearerex/xqlistwidget.cpp b/tests/manual/bearerex/xqlistwidget.cpp deleted file mode 100644 index 33206d0102..0000000000 --- a/tests/manual/bearerex/xqlistwidget.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xqlistwidget.h" - -XQListWidget::XQListWidget(QWidget* parent) : QListWidget(parent) -{ -} - -void XQListWidget::keyPressEvent(QKeyEvent* event) -{ - switch (event->key()) - { - case Qt::Key_Left: - { - focusPreviousChild(); - break; - } - case Qt::Key_Right: - { - focusNextChild(); - break; - } - default: - { - QListWidget::keyPressEvent(event); - } - } -} diff --git a/tests/manual/bearerex/xqlistwidget.h b/tests/manual/bearerex/xqlistwidget.h deleted file mode 100644 index a05c266e1b..0000000000 --- a/tests/manual/bearerex/xqlistwidget.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XQLISTWIDGET_H -#define XQLISTWIDGET_H - -#include -#include - -class XQListWidget: public QListWidget -{ -public: - XQListWidget(QWidget* parent = 0); - -protected: - void keyPressEvent(QKeyEvent* event); -}; - -#endif // XQLISTWIDGET_H - - diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index de13bc799e..a5a82e30cc 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -1,7 +1,7 @@ TEMPLATE=subdirs QT_FOR_CONFIG += network-private gui-private -SUBDIRS = bearerex \ +SUBDIRS = \ filetest \ embeddedintoforeignwindow \ foreignwindows \ @@ -25,8 +25,6 @@ qlocale \ qmimedatabase \ qnetconmonitor \ qnetworkaccessmanager/qget \ -qnetworkconfigurationmanager \ -qnetworkconfiguration \ qnetworkreply \ qstorageinfo \ qscreen \ diff --git a/tests/manual/qnetworkaccessmanager/qget/qget.cpp b/tests/manual/qnetworkaccessmanager/qget/qget.cpp index 14bdb589ff..14415ee890 100644 --- a/tests/manual/qnetworkaccessmanager/qget/qget.cpp +++ b/tests/manual/qnetworkaccessmanager/qget/qget.cpp @@ -33,9 +33,6 @@ #include #include #include -#include -#include -#include void printShortUsage() { diff --git a/tests/manual/qnetworkconfiguration/CMakeLists.txt b/tests/manual/qnetworkconfiguration/CMakeLists.txt deleted file mode 100644 index f843446888..0000000000 --- a/tests/manual/qnetworkconfiguration/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Generated from qnetworkconfiguration.pro. - -##################################################################### -## tst_manual_qnetworkconfiguration Binary: -##################################################################### - -add_qt_manual_test(tst_manual_qnetworkconfiguration - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Network - Qt::Test -) - -#### Keys ignored in scope 1:.:.:qnetworkconfiguration.pro:: -# TEMPLATE = "app" diff --git a/tests/manual/qnetworkconfiguration/main.cpp b/tests/manual/qnetworkconfiguration/main.cpp deleted file mode 100644 index ad1810b016..0000000000 --- a/tests/manual/qnetworkconfiguration/main.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Research in Motion. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -class tst_qnetworkconfiguration : public QObject -{ - Q_OBJECT - -private slots: - void bearerType(); - void bearerTypeFamily(); -}; - -void tst_qnetworkconfiguration::bearerType() -{ - QNetworkConfigurationManager m; - QList allConfs = m.allConfigurations(); - QElapsedTimer timer; - for (int a = 0; a < allConfs.count(); a++) { - timer.start(); - QNetworkConfiguration::BearerType type = allConfs.at(a).bearerType(); - qint64 elapsed = timer.elapsed(); - QString typeString; - switch (type) { - case QNetworkConfiguration::BearerUnknown: - typeString = QLatin1String("Unknown"); - break; - case QNetworkConfiguration::BearerEthernet: - typeString = QLatin1String("Ethernet"); - break; - case QNetworkConfiguration::BearerWLAN: - typeString = QLatin1String("WLAN"); - break; - case QNetworkConfiguration::Bearer2G: - typeString = QLatin1String("2G"); - break; - case QNetworkConfiguration::BearerCDMA2000: - typeString = QLatin1String("CDMA2000"); - break; - case QNetworkConfiguration::BearerWCDMA: - typeString = QLatin1String("WCDMA"); - break; - case QNetworkConfiguration::BearerHSPA: - typeString = QLatin1String("HSPA"); - break; - case QNetworkConfiguration::BearerBluetooth: - typeString = QLatin1String("Bluetooth"); - break; - case QNetworkConfiguration::BearerWiMAX: - typeString = QLatin1String("WiMAX"); - break; - case QNetworkConfiguration::BearerEVDO: - typeString = QLatin1String("EVDO"); - break; - case QNetworkConfiguration::BearerLTE: - typeString = QLatin1String("LTE"); - break; - default: - typeString = "unknown bearer (?)"; - } - - const char *isDefault = (allConfs.at(a) == m.defaultConfiguration()) - ? "*DEFAULT*" : ""; - qDebug() << isDefault << "identifier:" << allConfs.at(a).identifier() - << "bearer type name:" << allConfs.at(a).bearerTypeName() - << "bearer type:" << type << "(" << typeString << ")" - << "elapsed:" << elapsed; - QCOMPARE(allConfs.at(a).bearerTypeName(), typeString); - } -} - -void tst_qnetworkconfiguration::bearerTypeFamily() -{ - QNetworkConfigurationManager m; - foreach (const QNetworkConfiguration &config, - m.allConfigurations(QNetworkConfiguration::Active)) { - QString family; - switch (config.bearerTypeFamily()) { - case QNetworkConfiguration::Bearer3G: - family = QLatin1String("Bearer3G"); - break; - case QNetworkConfiguration::Bearer4G: - family = QLatin1String("Bearer4G"); - break; - default: - family = config.bearerTypeName(); - } - qDebug() << config.name() << "has bearer type" - << config.bearerTypeName() << "of bearer type family" - << family; - } -} - -QTEST_MAIN(tst_qnetworkconfiguration) - -#include "main.moc" diff --git a/tests/manual/qnetworkconfiguration/qnetworkconfiguration.pro b/tests/manual/qnetworkconfiguration/qnetworkconfiguration.pro deleted file mode 100644 index 13c229e885..0000000000 --- a/tests/manual/qnetworkconfiguration/qnetworkconfiguration.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = app -TARGET = tst_manual_qnetworkconfiguration - -QT -= gui -QT += network testlib - -SOURCES += main.cpp diff --git a/tests/manual/qnetworkconfigurationmanager/CMakeLists.txt b/tests/manual/qnetworkconfigurationmanager/CMakeLists.txt deleted file mode 100644 index 4bea8449ff..0000000000 --- a/tests/manual/qnetworkconfigurationmanager/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Generated from qnetworkconfigurationmanager.pro. - -##################################################################### -## tst_manual_qnetworkconfigurationmanager Binary: -##################################################################### - -add_qt_manual_test(tst_manual_qnetworkconfigurationmanager - SOURCES - main.cpp - PUBLIC_LIBRARIES - Qt::Network - Qt::Test -) - -#### Keys ignored in scope 1:.:.:qnetworkconfigurationmanager.pro:: -# TEMPLATE = "app" diff --git a/tests/manual/qnetworkconfigurationmanager/main.cpp b/tests/manual/qnetworkconfigurationmanager/main.cpp deleted file mode 100644 index e2edb20092..0000000000 --- a/tests/manual/qnetworkconfigurationmanager/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -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 deleted file mode 100644 index 072b330894..0000000000 --- a/tests/manual/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = app -TARGET = tst_manual_qnetworkconfigurationmanager - -QT -= gui -QT += network testlib - -SOURCES += main.cpp diff --git a/tests/manual/socketengine/main.cpp b/tests/manual/socketengine/main.cpp index 3e3e7e53e5..46d62b9a9c 100644 --- a/tests/manual/socketengine/main.cpp +++ b/tests/manual/socketengine/main.cpp @@ -36,9 +36,6 @@ #include #include #include -#include -#include -#include #include const int bufsize = 16*1024; -- cgit v1.2.3