diff options
author | Sachin Kundu <ext-sachin.kundu@nokia.com> | 2010-12-10 12:49:36 +0200 |
---|---|---|
committer | Sachin Kundu <ext-sachin.kundu@nokia.com> | 2010-12-10 12:49:36 +0200 |
commit | f891042021f2593d74c33de175f2c76077355649 (patch) | |
tree | 9978bde5ba22cc952a9ea278cb9d4033b26045f9 /tests | |
parent | 67aab107e8d6419c339a6cab4f2926eee0c51327 (diff) |
Fixes: NB#208330 - meegotouchhome process causing high wakeups when device is in idle state
RevBy: Vesa Halttunen, Pauli Lehtinen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stubs/mextensionhandle_stub.h | 8 | ||||
-rw-r--r-- | tests/ut_mapplethandle/ut_mapplethandle.pro | 5 | ||||
-rw-r--r-- | tests/ut_mextensionhandle/ut_mextensionhandle.cpp | 65 | ||||
-rw-r--r-- | tests/ut_mextensionhandle/ut_mextensionhandle.h | 3 | ||||
-rw-r--r-- | tests/ut_mextensionhandle/ut_mextensionhandle.pro | 5 | ||||
-rw-r--r-- | tests/ut_mextensionrunner/ut_mextensionrunner.cpp | 54 | ||||
-rw-r--r-- | tests/ut_mextensionrunner/ut_mextensionrunner.h | 3 | ||||
-rw-r--r-- | tests/ut_mextensionrunner/ut_mextensionrunner.pro | 5 |
8 files changed, 143 insertions, 5 deletions
diff --git a/tests/stubs/mextensionhandle_stub.h b/tests/stubs/mextensionhandle_stub.h index 0dd01da1..cd9cf9f6 100644 --- a/tests/stubs/mextensionhandle_stub.h +++ b/tests/stubs/mextensionhandle_stub.h @@ -63,6 +63,7 @@ class MExtensionHandleStub : public StubBase { virtual void remoteActionTriggered(); virtual void setBrokenState(); virtual void displayContextMenu(QList<QString> actions); + virtual void updateDisplayState(); }; // 2. IMPLEMENT STUB @@ -95,6 +96,10 @@ void MExtensionHandleStub::reinit() { stubMethodEntered("reinit"); } +void MExtensionHandleStub::updateDisplayState() { + stubMethodEntered("updateDisplayState"); +} + void MExtensionHandleStub::setAliveResponseTimeout(uint timeout) { QList<ParameterBase*> params; params.append( new Parameter<uint >(timeout)); @@ -394,5 +399,8 @@ void MExtensionHandle::displayContextMenu(QList<QString> actions) { gMExtensionHandleStub->displayContextMenu(actions); } +void MExtensionHandle::updateDisplayState() { + gMExtensionHandleStub->updateDisplayState(); +} #endif diff --git a/tests/ut_mapplethandle/ut_mapplethandle.pro b/tests/ut_mapplethandle/ut_mapplethandle.pro index 23870d5c..9de703f9 100644 --- a/tests/ut_mapplethandle/ut_mapplethandle.pro +++ b/tests/ut_mapplethandle/ut_mapplethandle.pro @@ -6,6 +6,11 @@ INCLUDEPATH += \ $$MSRCDIR/corelib/style QT += xml +contains(DEFINES, HAVE_CONTEXTSUBSCRIBER) { + CONFIG += link_pkgconfig + PKGCONFIG += contextsubscriber-1.0 +} + MODEL_HEADERS += \ $$MSRCDIR/corelib/widgets/mwidgetmodel.h \ $$MSRCDIR/extensions/applicationextension/mextensionhandlemodel.h \ 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) diff --git a/tests/ut_mextensionhandle/ut_mextensionhandle.h b/tests/ut_mextensionhandle/ut_mextensionhandle.h index b6867afe..47938a2c 100644 --- a/tests/ut_mextensionhandle/ut_mextensionhandle.h +++ b/tests/ut_mextensionhandle/ut_mextensionhandle.h @@ -91,6 +91,9 @@ private slots: void testInstallationOperationCompleteWithError(); void testAppletInstallationProgess(); void testSetSizeHints(); +#ifdef HAVE_CONTEXTSUBSCRIBER + void testWhenDisplayBlankedThenAliveCheckingStops(); +#endif signals: void messageReceived(const MAppletMessage &message); diff --git a/tests/ut_mextensionhandle/ut_mextensionhandle.pro b/tests/ut_mextensionhandle/ut_mextensionhandle.pro index 39f42455..0a54a9e9 100644 --- a/tests/ut_mextensionhandle/ut_mextensionhandle.pro +++ b/tests/ut_mextensionhandle/ut_mextensionhandle.pro @@ -6,6 +6,11 @@ INCLUDEPATH += \ $$MSRCDIR/corelib/style QT += xml +contains(DEFINES, HAVE_CONTEXTSUBSCRIBER) { + CONFIG += link_pkgconfig + PKGCONFIG += contextsubscriber-1.0 +} + MODEL_HEADERS += \ $$MSRCDIR/corelib/widgets/mwidgetmodel.h \ $$MSRCDIR/extensions/applicationextension/mextensionhandlemodel.h diff --git a/tests/ut_mextensionrunner/ut_mextensionrunner.cpp b/tests/ut_mextensionrunner/ut_mextensionrunner.cpp index 9223d793..709fce2b 100644 --- a/tests/ut_mextensionrunner/ut_mextensionrunner.cpp +++ b/tests/ut_mextensionrunner/ut_mextensionrunner.cpp @@ -41,10 +41,23 @@ #include <QtTest/QtTest> #include <QGraphicsLinearLayout> +#ifdef HAVE_CONTEXTSUBSCRIBER +#include "contextproperty.h" +#endif + #ifdef Q_WS_X11 #include <X11/Xlib.h> #endif +// ContextProperty stubs +#ifdef HAVE_CONTEXTSUBSCRIBER +QString gContextPropertyValue = ""; +QVariant ContextProperty::value() const +{ + return gContextPropertyValue; +} +#endif + // MWindow stubs (to prevent crashing) MWindow::MWindow(QWidget *parent) : QGraphicsView(parent), @@ -56,13 +69,28 @@ MWindow::~MWindow() } // QTimer stubs (used by MExtensionRunner) -void QTimer::start(int) +QList<QTimer*> gQTimerStartCalls; +void QTimer::start() { + gQTimerStartCalls.append(this); + id = 1; if (Ut_MExtensionRunner::timerImmediateTimeout) { emit timeout(); } } +void QTimer::start(int) +{ + start(); +} + +QList<QTimer*> gQTimerStopCalls; +void QTimer::stop() +{ + gQTimerStopCalls.append(this); + id = -1; +} + // QCoreApplication stubs (used by MExtensionRunner) void QCoreApplication::quit() { @@ -147,6 +175,8 @@ void Ut_MExtensionRunner::init() connect(this, SIGNAL(sendMessage(MAppletMessage)), m_instance, SLOT(messageReceived(MAppletMessage))); timerImmediateTimeout = false; + gQTimerStartCalls.clear(); + gQTimerStopCalls.clear(); quitCalled = false; gMAppletSharedMutexStub->stubReset(); gMAppletSharedMutexStub->stubSetReturnValue("init", true); @@ -159,6 +189,10 @@ void Ut_MExtensionRunner::init() MAppletCommunicator_sentUpdateGeometryMessageSizeHints = QVector<QSizeF>(Qt::NSizeHints); sceneRenderCalled = false; gMAppletSettingsStub->stubReset(); + +#ifdef HAVE_CONTEXTSUBSCRIBER + gContextPropertyValue = ""; +#endif } void Ut_MExtensionRunner::cleanup() @@ -486,4 +520,22 @@ void Ut_MExtensionRunner::testObjectMenuRequestMessageGetsPropagated() QCOMPARE(MAppletCommunicator_sentObjectMenuActionList.at(0), QString("correct_action")); } +#ifdef HAVE_CONTEXTSUBSCRIBER +void Ut_MExtensionRunner::testWhenDisplayBlankedThenAliveCheckingStops() +{ + gContextPropertyValue = "blanked"; + gQTimerStopCalls.clear(); + m_instance->updateDisplayState(); + QVERIFY(qFind(gQTimerStopCalls, m_instance->aliveTimer) != gQTimerStopCalls.end()); + + gQTimerStartCalls.clear(); + m_instance->messageReceived(MAppletAliveMessageRequest()); + QCOMPARE(gQTimerStartCalls.count(), 0); + + gContextPropertyValue = ""; + m_instance->updateDisplayState(); + QVERIFY(qFind(gQTimerStartCalls, m_instance->aliveTimer) != gQTimerStartCalls.end()); +} +#endif + QTEST_MAIN(Ut_MExtensionRunner) diff --git a/tests/ut_mextensionrunner/ut_mextensionrunner.h b/tests/ut_mextensionrunner/ut_mextensionrunner.h index df568732..3ded0271 100644 --- a/tests/ut_mextensionrunner/ut_mextensionrunner.h +++ b/tests/ut_mextensionrunner/ut_mextensionrunner.h @@ -76,6 +76,9 @@ private slots: void testSceneChanged(); void testObjectMenuRequestMessage(); void testObjectMenuRequestMessageGetsPropagated(); +#ifdef HAVE_CONTEXTSUBSCRIBER + void testWhenDisplayBlankedThenAliveCheckingStops(); +#endif signals: void sendMessage(const MAppletMessage &message); diff --git a/tests/ut_mextensionrunner/ut_mextensionrunner.pro b/tests/ut_mextensionrunner/ut_mextensionrunner.pro index f832419b..7f5facff 100644 --- a/tests/ut_mextensionrunner/ut_mextensionrunner.pro +++ b/tests/ut_mextensionrunner/ut_mextensionrunner.pro @@ -3,6 +3,11 @@ include(../common_mextensions.pri) QT += network xml +contains(DEFINES, HAVE_CONTEXTSUBSCRIBER) { + CONFIG += link_pkgconfig + PKGCONFIG += contextsubscriber-1.0 +} + SOURCES += ut_mextensionrunner.cpp \ $$MSRCDIR/extensions/applicationextension/mextensionrunner.cpp \ ../stubs/stubbase.cpp |