aboutsummaryrefslogtreecommitdiff
path: root/tests/ut_mextensionrunner/ut_mextensionrunner.cpp
blob: 709fce2be2f7550da13c24bf3f548d4d438cd171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include "ut_mextensionrunner.h"
#include <mextensionrunner.h>
#include <mappletclient.h>
#include <mappletmetadata.h>
#include <mappletmousemessage.h>
#include <mappletvisibilitymessage.h>
#include <mappletorientationmessage.h>
#include <mappletsetgeometrymessage.h>
#include <mappletalivemessagerequest.h>
#include <mappletpixmapmodifiedmessage.h>
#include <mappletupdategeometrymessage.h>
#include <mappletobjectmenurequestmessage.h>
#include <mappletobjectmenumessage.h>
#include <mcomponentdata.h>
#include <mappletsharedmutex_stub.h>
#include <mappletid_stub.h>
#include <mappletsettings_stub.h>
#include <mgconfdatastore.h>
#include <MAction>
#include <MWidget>
#include <MApplication>
#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),
      d_ptr(0)
{
}
MWindow::~MWindow()
{
}

// QTimer stubs (used by MExtensionRunner)
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()
{
    Ut_MExtensionRunner::quitCalled = true;
}

// MComponentData stubs
bool MComponentData::emulateTwoFingerGestures()
{
    return false;
}

// QGraphicsScene stubs
bool sceneRenderCalled;
void QGraphicsScene::render(QPainter *, const QRectF &, const QRectF &, Qt::AspectRatioMode)
{
    sceneRenderCalled = true;
}


MouseEventFilter::~MouseEventFilter()
{
    foreach(QGraphicsSceneMouseEvent * e, events) {
        delete e;
    }
}

bool MouseEventFilter::eventFilter(QObject *o, QEvent *e)
{
    Q_UNUSED(o);

    if (e->type() == QEvent::GraphicsSceneMousePress || e->type() == QEvent::GraphicsSceneMouseRelease || e->type() == QEvent::GraphicsSceneMouseMove) {
        QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(e);
        QGraphicsSceneMouseEvent *storedEvent = new QGraphicsSceneMouseEvent(e->type());
        storedEvent->setButton(mouseEvent->button());
        storedEvent->setButtons(mouseEvent->buttons());
        events.append(storedEvent);
    }

    return false;
}

bool MAppletCommunicator_connectToProcessReturn = true;
bool MAppletClient::connectToServer(const QString &serverName)
{
    Q_UNUSED(serverName);
    return MAppletCommunicator_connectToProcessReturn;
}
MAppletMessage::MAppletMessageType MAppletCommunicator_sentMessageType;
QRectF MAppletCommunicator_sentPixmapModifiedMessageGeometry;
QList<QString> MAppletCommunicator_sentObjectMenuActionList;
QVector<QSizeF> MAppletCommunicator_sentUpdateGeometryMessageSizeHints;
bool MAppletCommunicator::sendMessage(const MAppletMessage &message)
{
    MAppletCommunicator_sentMessageType = message.type();
    if (MAppletCommunicator_sentMessageType == MAppletMessage::PixmapModifiedMessage) {
        const MAppletPixmapModifiedMessage pixmapModifiedMessage = dynamic_cast<const MAppletPixmapModifiedMessage &>(message);
        MAppletCommunicator_sentPixmapModifiedMessageGeometry = pixmapModifiedMessage.geometry();
    } else if (MAppletCommunicator_sentMessageType == MAppletMessage::UpdateGeometryMessage) {
        const MAppletUpdateGeometryMessage updateGeometryMessage = dynamic_cast<const MAppletUpdateGeometryMessage &>(message);
        MAppletCommunicator_sentUpdateGeometryMessageSizeHints = updateGeometryMessage.sizeHints();
    } else if (MAppletCommunicator_sentMessageType == MAppletMessage::ObjectMenuMessage) {
        const MAppletObjectMenuMessage objectMenuMessage = dynamic_cast<const MAppletObjectMenuMessage &>(message);
        MAppletCommunicator_sentObjectMenuActionList = objectMenuMessage.actionList();
    }
    return true;
}

bool MAppletMetaData_isValidReturn = true;
bool MAppletMetaData::isValid() const
{
    return MAppletMetaData_isValidReturn;
}

bool Ut_MExtensionRunner::timerImmediateTimeout;
bool Ut_MExtensionRunner::quitCalled;

// Unit test cases
void Ut_MExtensionRunner::init()
{
    m_instance = new MExtensionRunner();
    connect(this, SIGNAL(sendMessage(MAppletMessage)), m_instance, SLOT(messageReceived(MAppletMessage)));

    timerImmediateTimeout = false;
    gQTimerStartCalls.clear();
    gQTimerStopCalls.clear();
    quitCalled = false;
    gMAppletSharedMutexStub->stubReset();
    gMAppletSharedMutexStub->stubSetReturnValue("init", true);
    gMAppletSharedMutexStub->stubSetReturnValue("lock", true);
    gMAppletSharedMutexStub->stubSetReturnValue("unlock", true);
    gMAppletSharedMutexStub->stubSetReturnValue("tryLock", true);
    MAppletCommunicator_connectToProcessReturn = true;
    MAppletCommunicator_sentMessageType = MAppletMessage::InvalidMessage;
    MAppletCommunicator_sentPixmapModifiedMessageGeometry = QRectF();
    MAppletCommunicator_sentUpdateGeometryMessageSizeHints = QVector<QSizeF>(Qt::NSizeHints);
    sceneRenderCalled = false;
    gMAppletSettingsStub->stubReset();

#ifdef HAVE_CONTEXTSUBSCRIBER
    gContextPropertyValue = "";
#endif
}

void Ut_MExtensionRunner::cleanup()
{
    delete m_instance;
    m_instance = NULL;
}

void Ut_MExtensionRunner::initTestCase()
{
}

void Ut_MExtensionRunner::cleanupTestCase()
{
}

void Ut_MExtensionRunner::testInitializationSuccess()
{
    QCOMPARE(m_instance->init("servername"), true);
    QCOMPARE(gMAppletSharedMutexStub->stubLastCallTo("init").parameter<QString>(0), QString("servername"));
}

void Ut_MExtensionRunner::testInitializationFailCommunicationFails()
{
    MAppletCommunicator_connectToProcessReturn = false;
    QCOMPARE(m_instance->init("servername"), false);
}

void Ut_MExtensionRunner::testInitializationFailSharedMemoryAttachFails()
{
    gMAppletSharedMutexStub->stubSetReturnValue("init", false);
    QCOMPARE(m_instance->init("servername"), false);
}

void Ut_MExtensionRunner::testRelayingMouseEvents()
{
    m_instance->init("servername");

    // Install event filter
    MouseEventFilter filter;
    QCoreApplication::instance()->installEventFilter(&filter);

    // Emit mouse press message
    MAppletMouseMessage message1(MAppletMessage::MousePressMessage, QPointF(-5, 2), Qt::RightButton, Qt::RightButton | Qt::MidButton);
    emit sendMessage(message1);
    QCOMPARE(filter.events.count(), 1);
    QCOMPARE(filter.events.at(0)->type(), QEvent::GraphicsSceneMousePress);
    QCOMPARE(filter.events.at(0)->button(), Qt::RightButton);
    QCOMPARE(filter.events.at(0)->buttons(), Qt::RightButton | Qt::MidButton);

    // Emit mouse release message
    MAppletMouseMessage message2(MAppletMessage::MouseReleaseMessage, QPointF(0, 4), Qt::LeftButton, Qt::LeftButton | Qt::MidButton);
    emit sendMessage(message2);
    QCOMPARE(filter.events.count(), 2);
    QCOMPARE(filter.events.at(1)->type(), QEvent::GraphicsSceneMouseRelease);
    QCOMPARE(filter.events.at(1)->button(), Qt::LeftButton);
    QCOMPARE(filter.events.at(1)->buttons(), Qt::LeftButton | Qt::MidButton);

    // Emit mouse move message
    MAppletMouseMessage message3(MAppletMessage::MouseMoveMessage, QPointF(-5, 2), Qt::MidButton, Qt::MidButton);
    emit sendMessage(message3);
    QCOMPARE(filter.events.count(), 3);
    QCOMPARE(filter.events.at(2)->type(), QEvent::GraphicsSceneMouseMove);
    QCOMPARE(filter.events.at(2)->button(), Qt::MidButton);
    QCOMPARE(filter.events.at(2)->buttons(), Qt::MidButton);

    // Remove event filter
    QCoreApplication::instance()->removeEventFilter(&filter);
}

void Ut_MExtensionRunner::testAppletRunnerQuitsIfMessageReceivingTimeouts()
{
    m_instance->init("servername");

    // Verify that the quit is not always called
    MAppletMouseMessage message1(MAppletMessage::MousePressMessage, QPointF(-5, 2), Qt::RightButton, Qt::RightButton | Qt::MidButton);
    emit sendMessage(message1);
    QVERIFY(!quitCalled);

    // Verify that quit is called when the timer times out
    timerImmediateTimeout = true;
    emit sendMessage(message1);
    QVERIFY(quitCalled);
}

// This test is here to test to nothing happens. Not segfaults or anything. That's why it doesn't really compare anything
void Ut_MExtensionRunner::testMessageReceivedBeforeAppletInit()
{
    {
        // Mouse messages are more or less the same so it's enough to test only one
        MAppletMouseMessage msg(MAppletMessage::MousePressMessage, QPointF(-5, 2), Qt::RightButton, Qt::RightButton | Qt::MidButton);
        emit sendMessage(msg);
    }

    {
        MAppletVisibilityMessage msg(true);
        emit sendMessage(msg);
    }

    {
        MAppletOrientationMessage msg;
        emit sendMessage(msg);
    }

    {
        MAppletSetGeometryMessage msg;
        emit sendMessage(msg);
    }

    {
        MAppletAliveMessageRequest msg;
        emit sendMessage(msg);
    }
}

void Ut_MExtensionRunner::testPaintingOnPixmap()
{
    connect(this, SIGNAL(changeScene(QList<QRectF>)), m_instance, SLOT(sceneChanged(QList<QRectF>)));

    m_instance->init("servername");

    // Create target pixmap and fill it with full opaque white
    QRectF targetRect(0, 0, 150, 100);
#ifdef Q_WS_X11
    // create a 32bit pixmap with enabled alpha channel
    Pixmap pixmap = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), targetRect.width(), targetRect.height(), 32);
    QApplication::syncX();
    QPixmap targetPixmap = QPixmap::fromX11Pixmap(pixmap, QPixmap::ExplicitlyShared);
#else
    QPixmap targetPixmap(targetRect.width(), targetRect.height());
    // Painting with transparent will activate the alpha channel in the pixmap
    targetPixmap.fill(Qt::transparent);
#endif
    targetPixmap.fill(Qt::white);

    // Assign the pixmap to the applet runner to be painted to.
    MAppletSetGeometryMessage msg(targetRect, targetPixmap.handle());
    emit sendMessage(msg);

    // Update subregion of the pixmap
    QList<QRectF> region;
    region.append(QRectF(25, 26, 30, 25));
    emit changeScene(region);

    // Verify that subregion was cleared to full transparent
    QImage result = targetPixmap.toImage();
    QVERIFY(!result.isNull());
    QCOMPARE(result.pixel(QPoint(25, 26)), qRgba(0, 0, 0, 0));
    QCOMPARE(result.pixel(QPoint(54, 26)), qRgba(0, 0, 0, 0));
    QCOMPARE(result.pixel(QPoint(54, 50)), qRgba(0, 0, 0, 0));
    QCOMPARE(result.pixel(QPoint(25, 50)), qRgba(0, 0, 0, 0));
    QCOMPARE(result.pixel(QPoint(40, 38)), qRgba(0, 0, 0, 0));

    // Verify that the rest of the pixmap is intact
    QCOMPARE(result.pixel(QPoint(0, 0)), qRgba(255, 255, 255, 255));
    QCOMPARE(result.pixel(QPoint(24, 25)), qRgba(255, 255, 255, 255));
    QCOMPARE(result.pixel(QPoint(24, 50)), qRgba(255, 255, 255, 255));
    QCOMPARE(result.pixel(QPoint(75, 75)), qRgba(255, 255, 255, 255));
    QCOMPARE(result.pixel(QPoint(40, 70)), qRgba(255, 255, 255, 255));
}

void Ut_MExtensionRunner::testSendUpdateGeometryMessage()
{
    m_instance->init("servername");
    m_instance->widget = new MWidget;
    m_instance->widget->setMinimumSize(QSizeF(50, 50));
    m_instance->widget->setPreferredSize(QSizeF(100, 100));
    m_instance->widget->setMaximumSize(QSizeF(150, 150));

    // Put the widget into the parent widget's layout for layout request watching
    QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(m_instance->parentWidget->layout());
    QVERIFY(layout != NULL);
    layout->addItem(m_instance->widget);

    m_instance->sendUpdateGeometryMessage();
    QCOMPARE(MAppletCommunicator_sentMessageType, MAppletMessage::UpdateGeometryMessage);
    QCOMPARE(MAppletCommunicator_sentUpdateGeometryMessageSizeHints.at(Qt::MinimumSize), QSizeF(50, 50));
    QCOMPARE(MAppletCommunicator_sentUpdateGeometryMessageSizeHints.at(Qt::PreferredSize), QSizeF(100, 100));
    QCOMPARE(MAppletCommunicator_sentUpdateGeometryMessageSizeHints.at(Qt::MaximumSize), QSizeF(150, 150));
}

void Ut_MExtensionRunner::testSceneChanged()
{
    connect(this, SIGNAL(changeScene(QList<QRectF>)), m_instance, SLOT(sceneChanged(QList<QRectF>)));

    m_instance->init("servername");

    // Create target pixmap
    QRectF targetRect(0, 0, 30, 30);
#ifdef Q_WS_X11
    Pixmap pixmap = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), targetRect.width(), targetRect.height(), QX11Info::appDepth());
    QApplication::syncX();
    QPixmap targetPixmap = QPixmap::fromX11Pixmap(pixmap, QPixmap::ExplicitlyShared);
#else
    QPixmap targetPixmap(targetRect.width(), targetRect.height());
#endif

    // Assign the pixmap to the applet runner to be painted to.
    MAppletSetGeometryMessage msg(targetRect, targetPixmap.handle());
    emit sendMessage(msg);

    // Update subregion of the pixmap
    QList<QRectF> region;
    region.append(QRectF(0, 0, 10, 10));
    region.append(QRectF(10, 10, 10, 10));
    emit changeScene(region);

    QCOMPARE(MAppletCommunicator_sentMessageType, MAppletMessage::PixmapModifiedMessage);
    QCOMPARE(MAppletCommunicator_sentPixmapModifiedMessageGeometry, QRectF(0, 0, 20, 20));
    QVERIFY(sceneRenderCalled);

    // Check that no pixmap modified messages are sent when invisible
    MAppletCommunicator_sentMessageType = MAppletMessage::InvalidMessage;
    MAppletCommunicator_sentPixmapModifiedMessageGeometry = QRectF();
    sceneRenderCalled = false;

    emit sendMessage(MAppletVisibilityMessage(false));
    emit changeScene(region);
    QCOMPARE(MAppletCommunicator_sentMessageType, MAppletMessage::InvalidMessage);
    QCOMPARE(MAppletCommunicator_sentPixmapModifiedMessageGeometry, QRectF());
    QVERIFY(!sceneRenderCalled);

    region.append(QRectF(20, 20, 10, 10));
    emit changeScene(region);
    QCOMPARE(MAppletCommunicator_sentMessageType, MAppletMessage::InvalidMessage);
    QCOMPARE(MAppletCommunicator_sentPixmapModifiedMessageGeometry, QRectF());
    QVERIFY(!sceneRenderCalled);

    // Check that pixmap modified message with cumulated rect is sent when set visible again
    emit sendMessage(MAppletVisibilityMessage(true));
    QCOMPARE(MAppletCommunicator_sentMessageType, MAppletMessage::PixmapModifiedMessage);
    QCOMPARE(MAppletCommunicator_sentPixmapModifiedMessageGeometry, QRectF(0, 0, 30, 30));
    QVERIFY(sceneRenderCalled);

    // Check that cumulation of changed rect doesn't happen when applet is visible
    region.clear();
    region.append(QRectF(5, 5, 15, 15));
    sceneRenderCalled = false;
    emit changeScene(region);
    QCOMPARE(MAppletCommunicator_sentMessageType, MAppletMessage::PixmapModifiedMessage);
    QCOMPARE(MAppletCommunicator_sentPixmapModifiedMessageGeometry, QRectF(5, 5, 15, 15));
    QVERIFY(sceneRenderCalled);
}

void Ut_MExtensionRunner::testObjectMenuRequestMessage()
{
    m_instance->init("servername");
    m_instance->widget = new MWidget;

    // Put the widget into the parent widget's layout for layout request watching
    QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(m_instance->parentWidget->layout());
    QVERIFY(layout != NULL);
    layout->addItem(m_instance->widget);

    MAction action1(m_instance->widget);
    action1.setText("objectmenuaction1");
    action1.setLocation(MAction::ObjectMenuLocation);
    m_instance->widget->addAction(&action1);

    MAction action2(m_instance->widget);
    action2.setText("normalaction");
    action2.setLocation(MAction::ToolBarLocation);
    m_instance->widget->addAction(&action2);

    MAction action3(m_instance->widget);
    action3.setText("objectmenuaction2");
    action3.setLocation(MAction::ObjectMenuLocation);
    m_instance->widget->addAction(&action3);

    MAction action4(m_instance->widget);
    action4.setText("actionforallplaces");
    action4.setLocation(MAction::EveryLocation);
    m_instance->widget->addAction(&action4);

    m_instance->widget->setGeometry(3, 4, 10, 10);

    MAppletObjectMenuRequestMessage message(QPoint(3, 4));
    emit sendMessage(message);

    QCOMPARE(MAppletCommunicator_sentObjectMenuActionList.size(), 3);
    QCOMPARE(MAppletCommunicator_sentObjectMenuActionList.at(0), QString("objectmenuaction1"));
    QCOMPARE(MAppletCommunicator_sentObjectMenuActionList.at(1), QString("objectmenuaction2"));
    QCOMPARE(MAppletCommunicator_sentObjectMenuActionList.at(2), QString("actionforallplaces"));

    emit sendMessage(message);
    QCOMPARE(MAppletCommunicator_sentObjectMenuActionList.size(), 3);
}

void Ut_MExtensionRunner::testObjectMenuRequestMessageGetsPropagated()
{
    m_instance->init("servername");

    // Bottommost widget. This widget has an action that shouldn't get selected
    m_instance->widget = new MWidget;
    // Middle widget. This widget has an action that is supposed to get selected
    MWidget widget2(m_instance->widget);
    // Topmost widget. This widget has no actions so the search for actions should continue below this widget
    MWidget widget3(&widget2);

    // Put the widget into the parent widget's layout for layout request watching
    QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(m_instance->parentWidget->layout());
    QVERIFY(layout != NULL);
    layout->addItem(m_instance->widget);

    // Add action to bottommost widget
    MAction action(m_instance->widget);
    action.setText("wrong_action");
    action.setLocation(MAction::ObjectMenuLocation);
    m_instance->widget->addAction(&action);

    // Add action to middle widget
    MAction action2(&widget2);
    action2.setText("correct_action");
    action2.setLocation(MAction::ObjectMenuLocation);
    widget2.addAction(&action2);

    m_instance->widget->setGeometry(0, 0, 10, 10);
    widget2.setGeometry(0, 0, 10, 10);
    widget3.setGeometry(0, 0, 10, 10);

    MAppletObjectMenuRequestMessage message(QPoint(3, 4));
    emit sendMessage(message);

    QCOMPARE(MAppletCommunicator_sentObjectMenuActionList.size(), 1);
    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)