forked from nemomobile-graveyard/meegotouch-systemui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: Close event eater needs to ignore() the close events
RevBy: TrustMe
- Loading branch information
Vesa Halttunen
committed
Nov 4, 2010
1 parent
894a27c
commit b8424d5
Showing
6 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ut_closeeventeater |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** All rights reserved. | ||
** Contact: Nokia Corporation ([email protected]) | ||
** | ||
** This file is part of mhome. | ||
** | ||
** If you have questions regarding the use of this file, please contact | ||
** Nokia at [email protected]. | ||
** | ||
** 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 <QtTest/QtTest> | ||
#include <MApplication> | ||
#include "closeeventeater.h" | ||
#include "ut_closeeventeater.h" | ||
|
||
bool qObjectEventFilterReturnValue = false; | ||
bool QObject::eventFilter(QObject *, QEvent *) | ||
{ | ||
return qObjectEventFilterReturnValue; | ||
} | ||
|
||
void Ut_CloseEventEater::initTestCase() | ||
{ | ||
static int argc = 1; | ||
static char *app_name[1] = { (char *) "./ut_closeeventeater" }; | ||
app = new MApplication(argc, app_name); | ||
} | ||
|
||
void Ut_CloseEventEater::cleanupTestCase() | ||
{ | ||
delete app; | ||
} | ||
|
||
void Ut_CloseEventEater::init() | ||
{ | ||
m_subject = new CloseEventEater(); | ||
} | ||
|
||
void Ut_CloseEventEater::cleanup() | ||
{ | ||
delete m_subject; | ||
qObjectEventFilterReturnValue = false; | ||
} | ||
|
||
void Ut_CloseEventEater::testCloseEventIsIgnored() | ||
{ | ||
QCloseEvent event; | ||
event.accept(); | ||
QVERIFY(m_subject->eventFilter(this, &event)); | ||
QVERIFY(!event.isAccepted()); | ||
} | ||
|
||
void Ut_CloseEventEater::testOtherEventsArePassedOn_data() | ||
{ | ||
QTest::addColumn<bool>("eventFilterReturnValue"); | ||
QTest::addColumn<bool>("accepted"); | ||
|
||
QTest::newRow("Event filter returns false, accepted was false") << false << false; | ||
QTest::newRow("Event filter returns false, accepted was true") << false << true; | ||
QTest::newRow("Event filter returns true, accepted was false") << true << false; | ||
QTest::newRow("Event filter returns true, accepted was true") << true << true; | ||
} | ||
|
||
void Ut_CloseEventEater::testOtherEventsArePassedOn() | ||
{ | ||
QFETCH(bool, eventFilterReturnValue); | ||
QFETCH(bool, accepted); | ||
|
||
qObjectEventFilterReturnValue = eventFilterReturnValue; | ||
|
||
QEvent event(QEvent::None); | ||
event.setAccepted(accepted); | ||
QCOMPARE(m_subject->eventFilter(this, &event), eventFilterReturnValue); | ||
QCOMPARE(event.isAccepted(), accepted); | ||
} | ||
|
||
QTEST_APPLESS_MAIN(Ut_CloseEventEater) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** All rights reserved. | ||
** Contact: Nokia Corporation ([email protected]) | ||
** | ||
** This file is part of mhome. | ||
** | ||
** If you have questions regarding the use of this file, please contact | ||
** Nokia at [email protected]. | ||
** | ||
** 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. | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef UT_CLOSEEVENTEATER_H | ||
#define UT_CLOSEEVENTEATER_H | ||
|
||
#include <QObject> | ||
|
||
class MApplication; | ||
class CloseEventEater; | ||
|
||
class Ut_CloseEventEater : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
private slots: | ||
// Called before the first testfunction is executed | ||
void initTestCase(); | ||
// Called after the last testfunction was executed | ||
void cleanupTestCase(); | ||
// Called before each testfunction is executed | ||
void init(); | ||
// Called after every testfunction | ||
void cleanup(); | ||
|
||
// Test cases | ||
void testCloseEventIsIgnored(); | ||
void testOtherEventsArePassedOn_data(); | ||
void testOtherEventsArePassedOn(); | ||
|
||
private: | ||
// MApplication | ||
MApplication *app; | ||
// The object being tested | ||
CloseEventEater *m_subject; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include(../coverage.pri) | ||
include(../common_top.pri) | ||
TARGET = ut_closeeventeater | ||
|
||
# unit test and unit | ||
SOURCES += \ | ||
ut_closeeventeater.cpp \ | ||
$$SRCDIR/closeeventeater.cpp | ||
|
||
# unit test and unit | ||
HEADERS += \ | ||
ut_closeeventeater.h \ | ||
$$SRCDIR/closeeventeater.h | ||
|
||
include(../common_bot.pri) |