aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllocale
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-08-15 18:40:58 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-08-15 18:44:54 +0200
commit2be575b4b1e6f6e11a8dbd0b1c05c003828d2598 (patch)
tree55d2bfaff9583b3e1e9f3291f4b91f34adae1d92 /tests/auto/qml/qqmllocale
parent4a5939d26d1e36efdb2b30cdee1f3672587c3fa5 (diff)
parent9e32b23a1514f367921b4a9ee25bc864a008463c (diff)
Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Diffstat (limited to 'tests/auto/qml/qqmllocale')
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index cc13fb4b5f..a90749208c 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -32,6 +32,8 @@
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlcontext.h>
#include <QtCore/QDateTime>
+#include <QtCore/qscopeguard.h>
+#include <QtCore/qscopedpointer.h>
#include <qcolor.h>
#include "../../shared/util.h"
@@ -1270,13 +1272,21 @@ void tst_qqmllocale::timeZoneUpdated()
// Set the timezone to Brisbane time, AEST-10:00
setTimeZone(QByteArray("Australia/Brisbane"));
+ QScopedPointer<QObject> obj;
+ auto cleanup = qScopeGuard([&original, &obj] {
+ // Restore to original time zone
+ setTimeZone(original);
+ QMetaObject::invokeMethod(obj.data(), "resetTimeZone");
+ });
+
DateFormatter formatter;
QQmlEngine e;
e.rootContext()->setContextObject(&formatter);
QQmlComponent c(&e, testFileUrl("timeZoneUpdated.qml"));
- QScopedPointer<QObject> obj(c.create());
+ QVERIFY2(!c.isError(), qPrintable(c.errorString()));
+ obj.reset(c.create());
QVERIFY(obj);
QVERIFY(obj->property("success").toBool());
@@ -1284,11 +1294,6 @@ void tst_qqmllocale::timeZoneUpdated()
setTimeZone(QByteArray("Asia/Kolkata"));
QMetaObject::invokeMethod(obj.data(), "check");
-
- // Reset to original time
- setTimeZone(original);
- QMetaObject::invokeMethod(obj.data(), "resetTimeZone");
-
QVERIFY(obj->property("success").toBool());
}
#endif