summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
index e3a70e9..420962d 100644
--- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
+++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
@@ -49,8 +49,8 @@ QT_USE_NAMESPACE
// this test only works with
// * GLIBC
// * MSVC - only debug builds (we need the crtdbg.h helpers)
-// * SYMBIAN - only when __UHEAP_BURSTFAILNEXT is available
-#if (defined(QT_NO_EXCEPTIONS) || (!defined(__GLIBC__) && !defined(Q_CC_MSVC) && (!defined(Q_OS_SYMBIAN) || !defined(__UHEAP_BURSTFAILNEXT)))) && !defined(Q_MOC_RUN)
+// * SYMBIAN
+#if (defined(QT_NO_EXCEPTIONS) || (!defined(__GLIBC__) && !defined(Q_CC_MSVC) && !defined(Q_OS_SYMBIAN))) && !defined(Q_MOC_RUN)
QTEST_NOOP_MAIN
#else
@@ -65,6 +65,7 @@ class tst_ExceptionSafetyObjects: public QObject
public slots:
void initTestCase();
+ void cleanupTestCase();
private slots:
void objects_data();
@@ -81,6 +82,10 @@ private slots:
void linkedList_data();
void linkedList();
+
+private:
+ static QtMsgHandler testMessageHandler;
+ static void safeMessageHandler(QtMsgType, const char *);
};
// helper structs to create an arbitrary widget
@@ -268,8 +273,22 @@ public:
}
};
+QtMsgHandler tst_ExceptionSafetyObjects::testMessageHandler;
+
+void tst_ExceptionSafetyObjects::safeMessageHandler(QtMsgType type, const char *msg)
+{
+ // this temporarily suspends OOM testing while handling a message
+ int currentIndex = mallocFailIndex;
+ AllocFailer allocFailer(0);
+ allocFailer.deactivate();
+ (*testMessageHandler)(type, msg);
+ allocFailer.reactivateAt(currentIndex);
+}
+
void tst_ExceptionSafetyObjects::initTestCase()
{
+ testMessageHandler = qInstallMsgHandler(safeMessageHandler);
+
QVERIFY(AllocFailer::initialize());
// sanity check whether OOM simulation works
@@ -307,6 +326,11 @@ void tst_ExceptionSafetyObjects::initTestCase()
QCOMPARE(malloc2Failed, 1);
}
+void tst_ExceptionSafetyObjects::cleanupTestCase()
+{
+ qInstallMsgHandler(testMessageHandler);
+}
+
void tst_ExceptionSafetyObjects::objects()
{
QFETCH(AbstractTester *, objectCreator);