diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-22 12:29:40 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-22 12:29:40 (GMT) |
commit | 61d324fae094680c0ce48d4b0cc23073790f383c (patch) | |
tree | dd8048175d015e68eb60d9946a7cab99e8524b8e /tests/auto | |
parent | da7c6cc8995f063435b25938ac10739a6e7f0067 (diff) | |
parent | f725e2b9cae1866ff6510cb339cc4ada363f9e4f (diff) | |
download | Qt-61d324fae094680c0ce48d4b0cc23073790f383c.zip Qt-61d324fae094680c0ce48d4b0cc23073790f383c.tar.gz Qt-61d324fae094680c0ce48d4b0cc23073790f383c.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (78 commits)
Moc: Add support for rvalue references in signals and slots.
Add support for polyphonic greek
Fix build failure on WinCE.
Autotests: if you use X11 libs, you must link to X11 libs explicitly.
Disable C++0x mode for QtWebKit and QtScript since WebKit will not compile any time soon with C++0x
Compile Phonon in C++0x mode.
Compile Qt in C++0x mode.
Avoid a data relocation by not trying to store a pointer in the .data section of plugins.
Fix cast-from-ascii warning
Fix compilation on Linux
Fix compilation with WINSCW: #include doesn't find files in the same dir
Rename m_volume to m_vol
Add 2 signals, introduce side widget, make it possible to reset startId
Do not create native window handle just because a parent has one.
Tab color fix for document mode on Snow Leopard.
Revert "Don't emit open signal on session close/error."
Rename networkAccess property to networkAccessible.
Don't emit open signal on session close/error.
Rename private signal.
Autotest: fix instability by accepting rounding errors
...
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib.pro | 1 | ||||
-rw-r--r-- | tests/auto/guiapplauncher/guiapplauncher.pro | 3 | ||||
-rw-r--r-- | tests/auto/network.pro | 1 | ||||
-rw-r--r-- | tests/auto/qdatetime/tst_qdatetime.cpp | 75 | ||||
-rw-r--r-- | tests/auto/qelapsedtimer/qelapsedtimer.pro | 13 | ||||
-rw-r--r-- | tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp | 157 | ||||
-rw-r--r-- | tests/auto/qglthreads/qglthreads.pro | 3 | ||||
-rw-r--r-- | tests/auto/qkeysequence/tst_qkeysequence.cpp | 52 | ||||
-rw-r--r-- | tests/auto/qlocale/tst_qlocale.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro | 5 | ||||
-rw-r--r-- | tests/auto/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp | 111 | ||||
-rw-r--r-- | tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp | 75 | ||||
-rw-r--r-- | tests/auto/qwidget/qwidget.pro | 4 | ||||
-rw-r--r-- | tests/auto/qwidget_window/qwidget_window.pro | 3 | ||||
-rw-r--r-- | tests/auto/qwizard/tst_qwizard.cpp | 97 |
16 files changed, 608 insertions, 6 deletions
diff --git a/tests/auto/corelib.pro b/tests/auto/corelib.pro index c08e372..259be4c 100644 --- a/tests/auto/corelib.pro +++ b/tests/auto/corelib.pro @@ -24,6 +24,7 @@ SUBDIRS=\ qdebug \ qdiriterator \ qeasingcurve \ + qelapsedtimer \ qevent \ qexplicitlyshareddatapointer \ qfileinfo \ diff --git a/tests/auto/guiapplauncher/guiapplauncher.pro b/tests/auto/guiapplauncher/guiapplauncher.pro index 2f81061..30f5cf4 100644 --- a/tests/auto/guiapplauncher/guiapplauncher.pro +++ b/tests/auto/guiapplauncher/guiapplauncher.pro @@ -16,3 +16,6 @@ HEADERS += windowmanager.h # process enumeration,etc. win32:LIBS+=-luser32 +x11 { + LIBS += $$QMAKE_LIBS_X11 +} diff --git a/tests/auto/network.pro b/tests/auto/network.pro index dbefa91..4f205fe 100644 --- a/tests/auto/network.pro +++ b/tests/auto/network.pro @@ -16,6 +16,7 @@ SUBDIRS=\ qhttpnetworkreply \ qhttpsocketengine \ qnativesocketengine \ + qnetworkaccessmanager \ qnetworkaddressentry \ qnetworkconfiguration \ qnetworkconfigurationmanager \ diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index 86a4c80..a6b9a5f 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -106,6 +106,8 @@ private slots: void secsTo(); void operator_eqeq(); void currentDateTime(); + void currentDateTimeUtc(); + void currentDateTimeUtc2(); void fromStringTextDate_data(); void fromStringTextDate(); @@ -880,6 +882,79 @@ void tst_QDateTime::currentDateTime() QVERIFY(dt3.timeSpec() == Qt::UTC); } +void tst_QDateTime::currentDateTimeUtc() +{ +#if defined(Q_OS_WINCE) + __time64_t buf1, buf2; + ::_time64(&buf1); +#else + time_t buf1, buf2; + ::time(&buf1); +#endif + QDateTime lowerBound; + lowerBound.setTime_t(buf1); + + QDateTime dt1 = QDateTime::currentDateTimeUtc(); + QDateTime dt2 = QDateTime::currentDateTimeUtc().toLocalTime(); + QDateTime dt3 = QDateTime::currentDateTimeUtc().toUTC(); + +#if defined(Q_OS_WINCE) + ::_time64(&buf2); +#else + ::time(&buf2); +#endif + QDateTime upperBound; + upperBound.setTime_t(buf2); + upperBound = upperBound.addSecs(1); + + QVERIFY(lowerBound < upperBound); + + QVERIFY(lowerBound <= dt1); + QVERIFY(dt1 < upperBound); + QVERIFY(lowerBound <= dt2); + QVERIFY(dt2 < upperBound); + QVERIFY(lowerBound <= dt3); + QVERIFY(dt3 < upperBound); + + QVERIFY(dt1.timeSpec() == Qt::UTC); + QVERIFY(dt2.timeSpec() == Qt::LocalTime); + QVERIFY(dt3.timeSpec() == Qt::UTC); +} + +void tst_QDateTime::currentDateTimeUtc2() +{ + QDateTime local, utc; + qint64 msec; + + // check that we got all down to the same milliseconds + int i = 2; + bool ok = false; + do { + local = QDateTime::currentDateTime(); + utc = QDateTime::currentDateTimeUtc(); + msec = QDateTime::currentMsecsSinceEpoch(); + ok = local.time().msec() == utc.time().msec() + && utc.time().msec() == (msec % 1000); + } while (--i && !ok); + + if (!i) + QSKIP("Failed to get the dates within 1 ms of each other", SkipAll); + + // seconds and milliseconds should be the same: + QCOMPARE(utc.time().second(), local.time().second()); + QCOMPARE(utc.time().msec(), local.time().msec()); + QCOMPARE(msec % 1000, qint64(local.time().msec())); + QCOMPARE(msec / 1000 % 60, qint64(local.time().second())); + + // the two dates should be equal, actually + QCOMPARE(local.toUTC(), utc); + QCOMPARE(utc.toLocalTime(), local); + + // and finally, the time_t should equal our number + QCOMPARE(qint64(utc.toTime_t()), msec / 1000); + QCOMPARE(qint64(local.toTime_t()), msec / 1000); +} + void tst_QDateTime::toTime_t_data() { QTest::addColumn<QString>("dateTimeStr"); diff --git a/tests/auto/qelapsedtimer/qelapsedtimer.pro b/tests/auto/qelapsedtimer/qelapsedtimer.pro new file mode 100644 index 0000000..ed75228 --- /dev/null +++ b/tests/auto/qelapsedtimer/qelapsedtimer.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +QT -= gui + +SOURCES += tst_qelapsedtimer.cpp +wince* { + DEFINES += SRCDIR=\\\"\\\" +} else:symbian { + # do not define SRCDIR at all + TARGET.EPOCHEAPSIZE = 0x100000 0x3000000 +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + diff --git a/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp b/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp new file mode 100644 index 0000000..9ea422c --- /dev/null +++ b/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QString> +#include <QtCore/QTime> +#include <QtCore/QElapsedTimer> +#include <QtTest/QtTest> + +static const int minResolution = 50; // the minimum resolution for the tests + +class tst_QElapsedTimer : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void statics(); + void validity(); + void basics(); + void elapsed(); +}; + +void tst_QElapsedTimer::statics() +{ + qDebug() << "Clock type is" << QElapsedTimer::clockType(); + qDebug() << "Said clock is" << (QElapsedTimer::isMonotonic() ? "monotonic" : "not monotonic"); + QElapsedTimer t; + t.start(); + qDebug() << "Current time is" << t.msecsSinceReference(); +} + +void tst_QElapsedTimer::validity() +{ + QElapsedTimer t; + + t.invalidate(); + QVERIFY(!t.isValid()); + + t.start(); + QVERIFY(t.isValid()); + + t.invalidate(); + QVERIFY(!t.isValid()); +} + +void tst_QElapsedTimer::basics() +{ + QElapsedTimer t1; + t1.start(); + + QVERIFY(t1.msecsSinceReference() != 0); + + QCOMPARE(t1, t1); + QVERIFY(!(t1 != t1)); + QVERIFY(!(t1 < t1)); + QCOMPARE(t1.msecsTo(t1), qint64(0)); + QCOMPARE(t1.secsTo(t1), qint64(0)); +// QCOMPARE(t1 + 0, t1); +// QCOMPARE(t1 - 0, t1); + +#if 0 + QElapsedTimer t2 = t1; + t2 += 1000; // so we can use secsTo + + QVERIFY(t1 != t2); + QVERIFY(!(t1 == t2)); + QVERIFY(t1 < t2); + QVERIFY(!(t2 < t1)); + QCOMPARE(t1.msecsTo(t2), qint64(1000)); + QCOMPARE(t1.secsTo(t2), qint64(1)); +// QCOMPARE(t2 - t1, qint64(1000)); +// QCOMPARE(t1 - t2, qint64(-1000)); +#endif + + quint64 value1 = t1.msecsSinceReference(); + qint64 elapsed = t1.restart(); + QVERIFY(elapsed < minResolution); + + quint64 value2 = t1.msecsSinceReference(); + // in theory, elapsed == value2 - value1 + + // However, since QElapsedTimer keeps internally the full resolution, + // we have here a rounding error due to integer division + QVERIFY(qAbs(elapsed - qint64(value2 - value1)) < 1); +} + +void tst_QElapsedTimer::elapsed() +{ + QElapsedTimer t1; + t1.start(); + + QTest::qSleep(4*minResolution); + QElapsedTimer t2; + t2.start(); + + QVERIFY(t1 != t2); + QVERIFY(!(t1 == t2)); + QVERIFY(t1 < t2); + QVERIFY(t1.msecsTo(t2) > 0); + // don't check: t1.secsTo(t2) +// QVERIFY(t1 - t2 < 0); + + QVERIFY(t1.elapsed() > 0); + QVERIFY(t1.hasExpired(minResolution)); + QVERIFY(!t1.hasExpired(8*minResolution)); + QVERIFY(!t2.hasExpired(minResolution)); + + QVERIFY(!t1.hasExpired(-1)); + QVERIFY(!t2.hasExpired(-1)); + + qint64 elapsed = t1.restart(); + QVERIFY(elapsed > 3*minResolution); + QVERIFY(elapsed < 5*minResolution); + qint64 diff = t2.msecsTo(t1); + QVERIFY(diff < minResolution); +} + +QTEST_MAIN(tst_QElapsedTimer); + +#include "tst_qelapsedtimer.moc" diff --git a/tests/auto/qglthreads/qglthreads.pro b/tests/auto/qglthreads/qglthreads.pro index 4d20a19..73b75d4 100644 --- a/tests/auto/qglthreads/qglthreads.pro +++ b/tests/auto/qglthreads/qglthreads.pro @@ -5,3 +5,6 @@ QT += opengl HEADERS += tst_qglthreads.h SOURCES += tst_qglthreads.cpp +x11 { + LIBS += $$QMAKE_LIBS_X11 +} diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp index b1ef223..1faae6a 100644 --- a/tests/auto/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp @@ -134,6 +134,8 @@ private slots: void keyBindings(); void translated_data(); void translated(); + void i18nKeys_data(); + void i18nKeys(); void initTestCase(); @@ -570,5 +572,55 @@ void tst_QKeySequence::translated() } +void tst_QKeySequence::i18nKeys_data() +{ + QTest::addColumn<int>("keycode"); + QTest::addColumn<QString>("keystring"); + + // Japanese keyboard support + QTest::newRow("Kanji") << (int)Qt::Key_Kanji << QString("Kanji"); + QTest::newRow("Muhenkan") << (int)Qt::Key_Muhenkan << QString("Muhenkan"); + QTest::newRow("Henkan") << (int)Qt::Key_Henkan << QString("Henkan"); + QTest::newRow("Romaji") << (int)Qt::Key_Romaji << QString("Romaji"); + QTest::newRow("Hiragana") << (int)Qt::Key_Hiragana << QString("Hiragana"); + QTest::newRow("Katakana") << (int)Qt::Key_Katakana << QString("Katakana"); + QTest::newRow("Hiragana Katakana") << (int)Qt::Key_Hiragana_Katakana << QString("Hiragana Katakana"); + QTest::newRow("Zenkaku") << (int)Qt::Key_Zenkaku << QString("Zenkaku"); + QTest::newRow("Hankaku") << (int)Qt::Key_Hankaku << QString("Hankaku"); + QTest::newRow("Zenkaku Hankaku") << (int)Qt::Key_Zenkaku_Hankaku << QString("Zenkaku Hankaku"); + QTest::newRow("Touroku") << (int)Qt::Key_Touroku << QString("Touroku"); + QTest::newRow("Massyo") << (int)Qt::Key_Massyo << QString("Massyo"); + QTest::newRow("Kana Lock") << (int)Qt::Key_Kana_Lock << QString("Kana Lock"); + QTest::newRow("Kana Shift") << (int)Qt::Key_Kana_Shift << QString("Kana Shift"); + QTest::newRow("Eisu Shift") << (int)Qt::Key_Eisu_Shift << QString("Eisu Shift"); + QTest::newRow("Eisu_toggle") << (int)Qt::Key_Eisu_toggle << QString("Eisu toggle"); + QTest::newRow("Code input") << (int)Qt::Key_Codeinput << QString("Code input"); + QTest::newRow("Multiple Candidate") << (int)Qt::Key_MultipleCandidate << QString("Multiple Candidate"); + QTest::newRow("Previous Candidate") << (int)Qt::Key_PreviousCandidate << QString("Previous Candidate"); + + // Korean keyboard support + QTest::newRow("Hangul") << (int)Qt::Key_Hangul << QString("Hangul"); + QTest::newRow("Hangul Start") << (int)Qt::Key_Hangul_Start << QString("Hangul Start"); + QTest::newRow("Hangul End") << (int)Qt::Key_Hangul_End << QString("Hangul End"); + QTest::newRow("Hangul Hanja") << (int)Qt::Key_Hangul_Hanja << QString("Hangul Hanja"); + QTest::newRow("Hangul Jamo") << (int)Qt::Key_Hangul_Jamo << QString("Hangul Jamo"); + QTest::newRow("Hangul Romaja") << (int)Qt::Key_Hangul_Romaja << QString("Hangul Romaja"); + QTest::newRow("Hangul Jeonja") << (int)Qt::Key_Hangul_Jeonja << QString("Hangul Jeonja"); + QTest::newRow("Hangul Banja") << (int)Qt::Key_Hangul_Banja << QString("Hangul Banja"); + QTest::newRow("Hangul PreHanja") << (int)Qt::Key_Hangul_PreHanja << QString("Hangul PreHanja"); + QTest::newRow("Hangul PostHanja") << (int)Qt::Key_Hangul_PostHanja << QString("Hangul PostHanja"); + QTest::newRow("Hangul Special") << (int)Qt::Key_Hangul_Special << QString("Hangul Special"); +} + +void tst_QKeySequence::i18nKeys() +{ + QFETCH(int, keycode); + QFETCH(QString, keystring); + QKeySequence seq(keycode); + + QCOMPARE(seq, QKeySequence(keystring)); + QCOMPARE(seq.toString(), keystring); +} + QTEST_MAIN(tst_QKeySequence) #include "tst_qkeysequence.moc" diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 5a87154..9363e4e 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -158,9 +158,15 @@ void tst_QLocale::ctor() QCoreApplication app(argc, (char**)&argv); #endif QLocale default_locale = QLocale::system(); + + QVERIFY(!default_locale.monthName(1, QLocale::LongFormat).isEmpty()); + QVERIFY(!default_locale.monthName(1, QLocale::ShortFormat).isEmpty()); + QVERIFY(default_locale.language() != 0); + QLocale::Language default_lang = default_locale.language(); QLocale::Country default_country = default_locale.country(); + qDebug("Default: %s/%s", QLocale::languageToString(default_lang).toLatin1().constData(), QLocale::countryToString(default_country).toLatin1().constData()); diff --git a/tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro b/tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro new file mode 100644 index 0000000..e2889c1 --- /dev/null +++ b/tests/auto/qnetworkaccessmanager/qnetworkaccessmanager.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +SOURCES += tst_qnetworkaccessmanager.cpp +QT = core network + + diff --git a/tests/auto/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp b/tests/auto/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp new file mode 100644 index 0000000..9267389 --- /dev/null +++ b/tests/auto/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtNetwork/QNetworkAccessManager> +#include <QtNetwork/QNetworkConfigurationManager> + +#include <QtCore/QDebug> + +Q_DECLARE_METATYPE(QNetworkAccessManager::NetworkAccessibility); + +class tst_QNetworkAccessManager : public QObject +{ + Q_OBJECT + +public: + tst_QNetworkAccessManager(); + +private slots: + void networkAccessible(); +}; + +tst_QNetworkAccessManager::tst_QNetworkAccessManager() +{ +} + +void tst_QNetworkAccessManager::networkAccessible() +{ + QNetworkAccessManager manager; + + qRegisterMetaType<QNetworkAccessManager::NetworkAccessibility>("QNetworkAccessManager::NetworkAccessibility"); + + QSignalSpy spy(&manager, + SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility))); + + QCOMPARE(manager.isNetworkAccessible(), QNetworkAccessManager::UnknownAccessibility); + + manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible); + + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), + QNetworkAccessManager::NotAccessible); + QCOMPARE(manager.isNetworkAccessible(), QNetworkAccessManager::NotAccessible); + + manager.setNetworkAccessible(QNetworkAccessManager::Accessible); + + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), + QNetworkAccessManager::UnknownAccessibility); + QCOMPARE(manager.isNetworkAccessible(), QNetworkAccessManager::UnknownAccessibility); + + QNetworkConfigurationManager configManager; + QNetworkConfiguration defaultConfig = configManager.defaultConfiguration(); + if (defaultConfig.isValid()) { + manager.setConfiguration(defaultConfig); + + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), + QNetworkAccessManager::Accessible); + QCOMPARE(manager.isNetworkAccessible(), QNetworkAccessManager::Accessible); + + manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible); + + QCOMPARE(spy.count(), 1); + QCOMPARE(QNetworkAccessManager::NetworkAccessibility(spy.takeFirst().at(0).toInt()), + QNetworkAccessManager::NotAccessible); + QCOMPARE(manager.isNetworkAccessible(), QNetworkAccessManager::NotAccessible); + } +} + +QTEST_MAIN(tst_QNetworkAccessManager) +#include "tst_qnetworkaccessmanager.moc" diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 8b68006..30c5a74 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -285,14 +285,12 @@ void tst_QNetworkConfigurationManager::defaultConfiguration() QNetworkConfiguration defaultConfig = manager.defaultConfiguration(); bool confirm = configs.contains(defaultConfig); - bool isUserChoice = (defaultConfig.type() == QNetworkConfiguration::UserChoice); - //user choice config is not part of allConfigurations() - QVERIFY(isUserChoice != confirm); - if (!isUserChoice) { + 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); diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp index 6de3f59..841f5b9 100644 --- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp @@ -99,6 +99,7 @@ private slots: void kannada(); void malayalam(); void sinhala(); + void greek(); void khmer(); void linearB(); @@ -998,6 +999,80 @@ void tst_QTextScriptEngine::linearB() #endif } +#if defined(Q_WS_X11) +static bool decomposedShaping( const QFont &f, const QChar &ch) +{ + QString str = QString().append(ch); + QTextLayout layout(str, f); + QTextEngine *e = layout.d; + e->itemize(); + e->shape(0); + + QTextLayout decomposed(str.normalized(QString::NormalizationForm_D), f); + QTextEngine *de = decomposed.d; + de->itemize(); + de->shape(0); + + if( e->layoutData->items[0].num_glyphs != de->layoutData->items[0].num_glyphs ) + goto error; + + for (int i = 0; i < e->layoutData->items[0].num_glyphs; ++i) { + if ((e->layoutData->glyphLayout.glyphs[i] & 0xffffff) != (de->layoutData->glyphLayout.glyphs[i] & 0xffffff)) + goto error; + } + return true; + error: + qDebug("%s: decomposedShaping of char %4x failed, nglyphs=%d, decomposed nglyphs %d", + f.family().toLatin1().constData(), + ch.unicode(), + e->layoutData->items[0].num_glyphs, + de->layoutData->items[0].num_glyphs); + + str = ""; + int i = 0; + while (i < e->layoutData->items[0].num_glyphs) { + str += QString("%1 ").arg(e->layoutData->glyphLayout.glyphs[i], 4, 16); + ++i; + } + qDebug(" composed glyph result = %s", str.toLatin1().constData()); + str = ""; + i = 0; + while (i < de->layoutData->items[0].num_glyphs) { + str += QString("%1 ").arg(de->layoutData->glyphLayout.glyphs[i], 4, 16); + ++i; + } + qDebug(" decomposed glyph result = %s", str.toLatin1().constData()); + return false; +} +#endif + + +void tst_QTextScriptEngine::greek() +{ +#if defined(Q_WS_X11) + { + if (QFontDatabase().families(QFontDatabase::Any).contains("DejaVu Sans")) { + QFont f("DejaVu Sans"); + for (int uc = 0x1f00; uc <= 0x1fff; ++uc) { + QString str; + str.append(uc); + if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) { + //qDebug() << "skipping" << hex << uc; + continue; + } + if (uc == 0x1fc1 || uc == 0x1fed) + continue; + QVERIFY( decomposedShaping(f, QChar(uc)) ); + } + } else { + QSKIP("couln't find DejaVu Sans", SkipAll); + } + } +#else + QSKIP("X11 specific test", SkipAll); +#endif +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" diff --git a/tests/auto/qwidget/qwidget.pro b/tests/auto/qwidget/qwidget.pro index 61db2ee..e39431b 100644 --- a/tests/auto/qwidget/qwidget.pro +++ b/tests/auto/qwidget/qwidget.pro @@ -14,6 +14,10 @@ mac { OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm } +x11 { + LIBS += $$QMAKE_LIBS_X11 +} + symbian { INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE LIBS += -leikcore -lcone -leikcoctl diff --git a/tests/auto/qwidget_window/qwidget_window.pro b/tests/auto/qwidget_window/qwidget_window.pro index e375fab..df7d687 100644 --- a/tests/auto/qwidget_window/qwidget_window.pro +++ b/tests/auto/qwidget_window/qwidget_window.pro @@ -1,4 +1,7 @@ load(qttest_p4) SOURCES += tst_qwidget_window.cpp +x11 { + LIBS += $$QMAKE_LIBS_X11 +} diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp index 764cd3e..f797227 100644 --- a/tests/auto/qwizard/tst_qwizard.cpp +++ b/tests/auto/qwizard/tst_qwizard.cpp @@ -104,6 +104,7 @@ private slots: void setCommitPage(); void setWizardStyle(); void removePage(); + void sideWidget(); // task-specific tests below me: void task161660_buttonSpacing(); @@ -569,12 +570,16 @@ void tst_QWizard::addPage() QWizard wizard; const int N = 100; QWizardPage *pages[N]; + QSignalSpy spy(&wizard, SIGNAL(pageAdded(int))); for (int i = 0; i < N; ++i) { pages[i] = new QWizardPage(parent); QCOMPARE(wizard.addPage(pages[i]), i); QCOMPARE(pages[i]->window(), (QWidget *)&wizard); QCOMPARE(wizard.startId(), 0); + QCOMPARE(spy.count(), 1); + QList<QVariant> arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), i); } for (int i = 0; i < N; ++i) { @@ -585,16 +590,29 @@ void tst_QWizard::addPage() QVERIFY(!wizard.page(N + 1)); wizard.setPage(N + 50, new QWizardPage); + QCOMPARE(spy.count(), 1); + QList<QVariant> arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), N + 50); wizard.setPage(-3000, new QWizardPage); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), -3000); QWizardPage *pageX = new QWizardPage; QCOMPARE(wizard.addPage(pageX), N + 51); QCOMPARE(wizard.page(N + 51), pageX); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), N + 51); QCOMPARE(wizard.addPage(new QWizardPage), N + 52); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), N + 52); QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert null page"); wizard.addPage(0); // generates a warning + QCOMPARE(spy.count(), 0); delete parent; } @@ -611,6 +629,7 @@ void tst_QWizard::setPage() QWidget *parent = new QWidget; QWizard wizard; QWizardPage *page; + QSignalSpy spy(&wizard, SIGNAL(pageAdded(int))); QCOMPARE(wizard.startId(), -1); QCOMPARE(wizard.currentId(), -1); @@ -620,6 +639,7 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert page with ID -1"); wizard.setPage(-1, page); // gives a warning and does nothing + QCOMPARE(spy.count(), 0); QVERIFY(!wizard.page(-2)); QVERIFY(!wizard.page(-1)); QVERIFY(!wizard.page(0)); @@ -631,6 +651,9 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(0, page); + QCOMPARE(spy.count(), 1); + QList<QVariant> arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 0); QCOMPARE(page->window(), (QWidget *)&wizard); QCOMPARE(wizard.page(0), page); QCOMPARE(wizard.startId(), 0); @@ -641,6 +664,9 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(-2, page); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), -2); QCOMPARE(page->window(), (QWidget *)&wizard); QCOMPARE(wizard.page(-2), page); QCOMPARE(wizard.startId(), -2); @@ -659,6 +685,9 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(2, page); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.page(2), page); QCOMPARE(wizard.startId(), -2); QCOMPARE(wizard.currentId(), -2); @@ -675,6 +704,9 @@ void tst_QWizard::setPage() page = new QWizardPage(parent); wizard.setPage(-3, page); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), -3); QCOMPARE(wizard.page(-3), page); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), -2); @@ -743,6 +775,7 @@ void tst_QWizard::setPage() QCOMPARE(wizard.nextId(), -2); CHECK_VISITED(wizard, QList<int>() << -3); } + QCOMPARE(spy.count(), 0); delete parent; } @@ -766,7 +799,17 @@ void tst_QWizard::setStartId() wizard.setPage(INT_MAX, new QWizardPage); QCOMPARE(wizard.startId(), INT_MIN); - QTest::ignoreMessage(QtWarningMsg,"QWizard::setStartId: Invalid page ID -1"); + QTest::ignoreMessage(QtWarningMsg,"QWizard::setStartId: Invalid page ID 123"); + wizard.setStartId(123); + QCOMPARE(wizard.startId(), INT_MIN); + + wizard.setStartId(-1); + QCOMPARE(wizard.startId(), INT_MIN); + + wizard.setStartId(-2); + QCOMPARE(wizard.startId(), -2); + QCOMPARE(wizard.nextId(), -1); + wizard.setStartId(-1); QCOMPARE(wizard.startId(), INT_MIN); @@ -2209,6 +2252,7 @@ void tst_QWizard::removePage() QWizardPage *page1 = new QWizardPage; QWizardPage *page2 = new QWizardPage; QWizardPage *page3 = new QWizardPage; + QSignalSpy spy(&wizard, SIGNAL(pageRemoved(int))); wizard.setPage(0, page0); wizard.setPage(1, page1); @@ -2218,26 +2262,36 @@ void tst_QWizard::removePage() wizard.restart(); QCOMPARE(wizard.pageIds().size(), 4); QCOMPARE(wizard.visitedPages().size(), 1); + QCOMPARE(spy.count(), 0); // Removing a non-existent page wizard.removePage(4); QCOMPARE(wizard.pageIds().size(), 4); + QCOMPARE(spy.count(), 0); // Removing and then reinserting a page QCOMPARE(wizard.pageIds().size(), 4); QVERIFY(wizard.pageIds().contains(2)); wizard.removePage(2); + QCOMPARE(spy.count(), 1); + QList<QVariant> arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.pageIds().size(), 3); QVERIFY(!wizard.pageIds().contains(2)); wizard.setPage(2, page2); + QCOMPARE(spy.count(), 0); QCOMPARE(wizard.pageIds().size(), 4); QVERIFY(wizard.pageIds().contains(2)); // Removing the same page twice wizard.removePage(2); // restore + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.pageIds().size(), 3); QVERIFY(!wizard.pageIds().contains(2)); wizard.removePage(2); + QCOMPARE(spy.count(), 0); QCOMPARE(wizard.pageIds().size(), 3); QVERIFY(!wizard.pageIds().contains(2)); @@ -2247,7 +2301,11 @@ void tst_QWizard::removePage() wizard.next(); QCOMPARE(wizard.visitedPages().size(), 2); QCOMPARE(wizard.currentPage(), page1); + QCOMPARE(spy.count(), 0); wizard.removePage(2); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.visitedPages().size(), 2); QVERIFY(!wizard.pageIds().contains(2)); QCOMPARE(wizard.currentPage(), page1); @@ -2256,9 +2314,13 @@ void tst_QWizard::removePage() wizard.setPage(2, page2); // restore wizard.restart(); wizard.next(); + QCOMPARE(spy.count(), 0); QCOMPARE(wizard.visitedPages().size(), 2); QCOMPARE(wizard.currentPage(), page1); wizard.removePage(0); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 0); QCOMPARE(wizard.visitedPages().size(), 1); QVERIFY(!wizard.visitedPages().contains(0)); QVERIFY(!wizard.pageIds().contains(0)); @@ -2268,9 +2330,13 @@ void tst_QWizard::removePage() wizard.setPage(0, page0); // restore wizard.restart(); wizard.next(); + QCOMPARE(spy.count(), 0); QCOMPARE(wizard.visitedPages().size(), 2); QCOMPARE(wizard.currentPage(), page1); wizard.removePage(1); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 1); QCOMPARE(wizard.visitedPages().size(), 1); QVERIFY(!wizard.visitedPages().contains(1)); QVERIFY(!wizard.pageIds().contains(1)); @@ -2278,6 +2344,9 @@ void tst_QWizard::removePage() // Remove the current page which is the first (and only) one in the history wizard.removePage(0); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 0); QCOMPARE(wizard.visitedPages().size(), 1); QVERIFY(!wizard.visitedPages().contains(0)); QCOMPARE(wizard.pageIds().size(), 2); @@ -2285,6 +2354,9 @@ void tst_QWizard::removePage() QCOMPARE(wizard.currentPage(), page2); // wizard.removePage(2); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 2); QCOMPARE(wizard.visitedPages().size(), 1); QVERIFY(!wizard.visitedPages().contains(2)); QCOMPARE(wizard.pageIds().size(), 1); @@ -2292,11 +2364,34 @@ void tst_QWizard::removePage() QCOMPARE(wizard.currentPage(), page3); // wizard.removePage(3); + QCOMPARE(spy.count(), 1); + arguments = spy.takeFirst(); + QCOMPARE(arguments.at(0).toInt(), 3); QVERIFY(wizard.visitedPages().empty()); QVERIFY(wizard.pageIds().empty()); QCOMPARE(wizard.currentPage(), static_cast<QWizardPage *>(0)); } +void tst_QWizard::sideWidget() +{ + QWizard wizard; + + wizard.setSideWidget(0); + QVERIFY(wizard.sideWidget() == 0); + QWidget *w1 = new QWidget(&wizard); + wizard.setSideWidget(w1); + QVERIFY(wizard.sideWidget() == w1); + QWidget *w2 = new QWidget(&wizard); + wizard.setSideWidget(w2); + QVERIFY(wizard.sideWidget() == w2); + QVERIFY(w1->parent() != 0); + QCOMPARE(w1->window(), static_cast<QWidget *>(&wizard)); + QCOMPARE(w2->window(), static_cast<QWidget *>(&wizard)); + w1->setParent(0); + wizard.setSideWidget(0); + QVERIFY(wizard.sideWidget() == 0); +} + void tst_QWizard::task161660_buttonSpacing() { #ifndef QT_NO_STYLE_PLASTIQUE |