summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-09-08 11:56:16 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-09-08 11:56:16 (GMT)
commitb3f22c1e9568e0e9b6c2898a879032f725587351 (patch)
tree7c6de455791d94b4047edbce4484711fd5d9d6d4 /tests
parent3d247e0ae09bcd1b75f92a587ab5b28569a3f0f6 (diff)
parent1af67c36b6064dfb4ec51217993c6a99ead493c9 (diff)
downloadQt-b3f22c1e9568e0e9b6c2898a879032f725587351.zip
Qt-b3f22c1e9568e0e9b6c2898a879032f725587351.tar.gz
Qt-b3f22c1e9568e0e9b6c2898a879032f725587351.tar.bz2
Merge branch 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration into 4.7-integration
* 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: Fix compilation on Windows CE Add missing license header Fixed input context trying to squeeze content into a full widget. Cleaned up position tracking in the Symbian input methods. Revert "Long-press shortcuts for symbols on QWERTY keyboard don't work" Compile fix MinGW, 5738dcd705e7edde816940f9c0ab2c364c81ad20 broke it. Compile fix WinCE Ensure that we load system libraries from the correct location. Some small Solaris fixes. Fix QtScript Date <--> QDateTime (local time) conversion Fix Qt applications freezing until mouse/keyboard events occur. Recognize GL_ARB_shader_objects as indicating shaders
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 4cff043..f96aea6 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -174,6 +174,10 @@ private slots:
void reentrency();
void newFixedStaticScopeObject();
void newGrowingStaticScopeObject();
+ void dateRoundtripJSQtJS();
+ void dateRoundtripQtJSQt();
+ void dateConversionJSQt();
+ void dateConversionQtJS();
};
tst_QScriptEngine::tst_QScriptEngine()
@@ -5037,6 +5041,68 @@ void tst_QScriptEngine::qRegExpInport()
}
}
+// QScriptValue::toDateTime() returns a local time, whereas JS dates
+// are always stored as UTC. QtScript must respect the current time
+// zone, and correctly adjust for daylight saving time that may be in
+// effect at a given date (QTBUG-9770).
+void tst_QScriptEngine::dateRoundtripJSQtJS()
+{
+ uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
+ QDateTime qtDate = jsDate.toDateTime();
+ QScriptValue jsDate2 = eng.newDate(qtDate);
+ if (jsDate2.toNumber() != jsDate.toNumber())
+ QFAIL(qPrintable(jsDate.toString()));
+ secs += 2*60*60;
+ }
+}
+
+void tst_QScriptEngine::dateRoundtripQtJSQt()
+{
+ QDateTime qtDate = QDateTime(QDate(2009, 1, 1));
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.newDate(qtDate);
+ QDateTime qtDate2 = jsDate.toDateTime();
+ if (qtDate2 != qtDate)
+ QFAIL(qPrintable(qtDate.toString()));
+ qtDate = qtDate.addSecs(2*60*60);
+ }
+}
+
+void tst_QScriptEngine::dateConversionJSQt()
+{
+ uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
+ QDateTime qtDate = jsDate.toDateTime();
+ QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate);
+ QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString();
+ jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z")
+ if (qtUTCDateStr != jsUTCDateStr)
+ QFAIL(qPrintable(jsDate.toString()));
+ secs += 2*60*60;
+ }
+}
+
+void tst_QScriptEngine::dateConversionQtJS()
+{
+ QDateTime qtDate = QDateTime(QDate(2009, 1, 1));
+ QScriptEngine eng;
+ for (int i = 0; i < 8000; ++i) {
+ QScriptValue jsDate = eng.newDate(qtDate);
+ QString jsUTCDateStr = jsDate.property("toISOString").call(jsDate).toString();
+ jsUTCDateStr.chop(5); // get rid of milliseconds (".000Z")
+ QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate);
+ if (jsUTCDateStr != qtUTCDateStr)
+ QFAIL(qPrintable(qtDate.toString()));
+ qtDate = qtDate.addSecs(2*60*60);
+ }
+}
+
static QScriptValue createAnotherEngine(QScriptContext *, QScriptEngine *)
{
QScriptEngine eng;