diff options
author | axis <qt-info@nokia.com> | 2009-10-26 13:58:31 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-10-26 16:17:49 (GMT) |
commit | e4ea97959e1fbbc99e80023a6c3229ba0a1d7c8b (patch) | |
tree | b4debb70a22dfcf44ad2d903df7deeb277503e82 /tests/auto | |
parent | 91823996c00b1ba952be45eaa69a98816e6f27fd (diff) | |
download | Qt-e4ea97959e1fbbc99e80023a6c3229ba0a1d7c8b.zip Qt-e4ea97959e1fbbc99e80023a6c3229ba0a1d7c8b.tar.gz Qt-e4ea97959e1fbbc99e80023a6c3229ba0a1d7c8b.tar.bz2 |
Removed the need for extra Symbian traps after QApp construction.
This was achieved by putting back the old trap handler after the S60
framework construction has finished.
Task: QTBUG-4960
AutoTest: Included and passed
RevBy: Shane Kearns
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qapplication/tst_qapplication.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 97aa092..675e559 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -136,6 +136,9 @@ private slots: void windowsCommandLine(); void touchEventPropagation(); + + void symbianNeedForTraps(); + void symbianLeaveThroughMain(); }; class EventSpy : public QObject @@ -2011,6 +2014,66 @@ void tst_QApplication::touchEventPropagation() } } +#ifdef Q_OS_SYMBIAN +class CBaseDummy : public CBase +{ +public: + CBaseDummy(int *numDestroyed) : numDestroyed(numDestroyed) + { + } + ~CBaseDummy() + { + (*numDestroyed)++; + } + +private: + int *numDestroyed; +}; + +static void fakeMain(int *numDestroyed) +{ + // Push a few objects, just so that the cleanup stack has something to clean up. + CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed)); + int argc = 0; + QApplication app(argc, 0); + CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed)); + + User::Leave(KErrGeneral); // Fake error +} +#endif + +void tst_QApplication::symbianNeedForTraps() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian-only test", SkipAll); +#else + int argc = 0; + QApplication app(argc, 0); + int numDestroyed = 0; + + // This next part should not require a trap. If it does, the test will crash. + CleanupStack::PushL(new (ELeave) CBaseDummy(&numDestroyed)); + CleanupStack::PopAndDestroy(); + + QCOMPARE(numDestroyed, 1); + + // No other failure condition. The program will crash if it does not pass. +#endif +} + +void tst_QApplication::symbianLeaveThroughMain() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian-only test", SkipAll); +#else + int numDestroyed = 0; + TInt err; + TRAP(err, fakeMain(&numDestroyed)); + + QCOMPARE(numDestroyed, 2); +#endif +} + //QTEST_APPLESS_MAIN(tst_QApplication) int main(int argc, char *argv[]) { |