summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-18 09:46:27 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-18 09:46:27 (GMT)
commitb6d03bb2658c9926f2e8ad424e3014a5db0451ec (patch)
tree0eea339c7408437aadf551cdc684aebc8cb2d450 /tests/auto
parent6dcdab8d9ee66f420a525400d873cfccf78c7003 (diff)
parente5c386c39065c640b938b33994af28a6589e4523 (diff)
downloadQt-b6d03bb2658c9926f2e8ad424e3014a5db0451ec.zip
Qt-b6d03bb2658c9926f2e8ad424e3014a5db0451ec.tar.gz
Qt-b6d03bb2658c9926f2e8ad424e3014a5db0451ec.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: (46 commits) Build and run QElapsedTimer test. Fix license headers. Add flag to indicate that network sessions are expected on a platform. Don't fail unit test when there is no default network configuration. Make destructor virtual. Optimized QLocale to access system locale on demand. Remove unwanted code in f8d5f2594a9b268b9eeecf95b24b23fc940c71ce Compile fix on keypad-navigation systems Force qt-zlib to be used for host system when cross compiling. qmake: fix to create proper install target in Makefile at first run compile fix for Windows Fixed focus handling when Qt is embedded into Cocoa app. Do not beep on Mac when pressing some keys. Do not deliver the same key event multiple times in Cocoa. Implement Idle-priority threads for Linux. Improved qt_x11_wait_for_window_manager Doc: document QElapsedTimer Added missing "const" for mac. qdoc3: Fixed some ifdef typos and removed some whitespace. Manual test for QTBUG-8933. ...
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib.pro1
-rw-r--r--tests/auto/qdatetime/tst_qdatetime.cpp75
-rw-r--r--tests/auto/qelapsedtimer/qelapsedtimer.pro13
-rw-r--r--tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp152
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp6
-rw-r--r--tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp8
6 files changed, 250 insertions, 5 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/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..912226d
--- /dev/null
+++ b/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** 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();
+ quint64 value2 = t1.msecsSinceReference();
+ QCOMPARE(elapsed, qint64(value2 - value1));
+ QVERIFY(elapsed < minResolution);
+}
+
+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/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/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp b/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp
index 3052330..b11868a 100644
--- a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp
+++ b/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.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);