aboutsummaryrefslogtreecommitdiff
path: root/tests/ut_mextensionhandle/ut_mextensionhandle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ut_mextensionhandle/ut_mextensionhandle.cpp')
-rw-r--r--tests/ut_mextensionhandle/ut_mextensionhandle.cpp65
1 files changed, 61 insertions, 4 deletions
diff --git a/tests/ut_mextensionhandle/ut_mextensionhandle.cpp b/tests/ut_mextensionhandle/ut_mextensionhandle.cpp
index 1f99efd7..ce67cc71 100644
--- a/tests/ut_mextensionhandle/ut_mextensionhandle.cpp
+++ b/tests/ut_mextensionhandle/ut_mextensionhandle.cpp
@@ -55,6 +55,10 @@
#include <mappletid_stub.h>
#include <mscenemanager.h>
+#ifdef HAVE_CONTEXTSUBSCRIBER
+#include "contextproperty.h"
+#endif
+
MApplication *app;
bool visibility;
@@ -74,6 +78,15 @@ void MWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
Ut_MExtensionHandle::contextMenuOpened = true;
}
+// ContextProperty stubs
+#ifdef HAVE_CONTEXTSUBSCRIBER
+QString gContextPropertyValue = "";
+QVariant ContextProperty::value() const
+{
+ return gContextPropertyValue;
+}
+#endif
+
// MSceneManager stubs (used by MExtensionHandle)
void MSceneManager::appearSceneWindow(MSceneWindow *, MSceneWindow::DeletionPolicy)
{
@@ -163,11 +176,26 @@ bool MAppletCommunicator::sendMessage(const MAppletMessage &message)
}
// QTimer stubs
-bool timerCalled = false;
+QList<QTimer*> gQTimerStartCalls;
+void QTimer::start()
+{
+ gQTimerStartCalls.append(this);
+ id = 1;
+}
+
+void QTimer::start(int)
+{
+ start();
+}
+
+bool gQTimerStopCalled = false;
+QList<QTimer*> gQTimerStopCalls;
void QTimer::stop()
{
- timerCalled = true;
+ gQTimerStopCalled = true;
+ gQTimerStopCalls.append(this);
+ id = -1;
}
int elapsedQTime = 0;
@@ -234,7 +262,13 @@ void Ut_MExtensionHandle::init()
listenForConnection = true;
elapsedQTime = 0;
- timerCalled = false;
+ gQTimerStartCalls.clear();
+ gQTimerStopCalled = false;
+ gQTimerStopCalls.clear();
+
+#ifdef HAVE_CONTEXTSUBSCRIBER
+ gContextPropertyValue = "";
+#endif
gStartQProcess = true;
@@ -405,7 +439,7 @@ void Ut_MExtensionHandle::testAppletCommunication()
handle->init("/bin/true", "metaDataFileName");
MAppletAliveMessageResponse message;
handle->messageReceivedFromRunner(message);
- QCOMPARE(timerCalled, true);
+ QCOMPARE(gQTimerStopCalled, true);
}
void Ut_MExtensionHandle::testRelayingMousePress()
@@ -644,4 +678,27 @@ void Ut_MExtensionHandle::testSetSizeHints()
QCOMPARE(handle->model()->sizeHints(), sizeHints);
}
+#ifdef HAVE_CONTEXTSUBSCRIBER
+void Ut_MExtensionHandle::testWhenDisplayBlankedThenAliveCheckingStops()
+{
+ handle->init("/bin/true", "metaDataFileName");
+ emit connectionFromRunnerEstablished();
+ QVERIFY(qFind(gQTimerStartCalls, &handle->privateClass()->aliveTimer) != gQTimerStartCalls.end());
+ QVERIFY(qFind(gQTimerStartCalls, &handle->privateClass()->communicationTimer) != gQTimerStartCalls.end());
+
+ gContextPropertyValue = "blanked";
+ gQTimerStopCalls.clear();
+ handle->updateDisplayState();
+ QVERIFY(qFind(gQTimerStopCalls, &handle->privateClass()->aliveTimer) != gQTimerStopCalls.end());
+ QVERIFY(qFind(gQTimerStopCalls, &handle->privateClass()->communicationTimer) != gQTimerStopCalls.end());
+
+ gContextPropertyValue = "";
+ gQTimerStartCalls.clear();
+ handle->updateDisplayState();
+ QVERIFY(qFind(gQTimerStartCalls, &handle->privateClass()->aliveTimer) != gQTimerStartCalls.end());
+ QVERIFY(qFind(gQTimerStartCalls, &handle->privateClass()->communicationTimer) != gQTimerStartCalls.end());
+}
+#endif
+
+
QTEST_APPLESS_MAIN(Ut_MExtensionHandle)