Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Ut_UnlockNotifications: A new unit test.
- Loading branch information
László Pere
committed
Jun 14, 2010
1 parent
e8e5939
commit a975e44
Showing
9 changed files
with
377 additions
and
3 deletions.
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
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,85 @@ | ||
/* -*- Mode: C; indent-tabs-mode: s; c-basic-offset: 4; tab-width: 4 -*- */ | ||
/* vim:set et ai sw=4 ts=4 sts=4: tw=80 cino="(0,W2s,i2s,t0,l1,:0" */ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** All rights reserved. | ||
** Contact: Nokia Corporation (directui@nokia.com) | ||
** | ||
** This file is part of systemui. | ||
** | ||
** 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 "MTester.h" | ||
|
||
#include <QGraphicsLayout> | ||
#include <QGraphicsLayoutItem> | ||
#include <QGraphicsWidget> | ||
#include <QString> | ||
|
||
#define DEBUG | ||
#include "../../src/debug.h" | ||
|
||
bool | ||
MTester::isLayoutContains ( | ||
QGraphicsLayout *layout, | ||
QGraphicsLayoutItem *item) | ||
{ | ||
bool found = false; | ||
|
||
#if 0 | ||
SYS_DEBUG ("*** layout = %p", layout); | ||
SYS_DEBUG ("*** item = %p", item); | ||
SYS_DEBUG ("*** count = %d", layout->count()); | ||
#endif | ||
for (int n = 0; n < layout->count(); ++n) { | ||
QGraphicsLayoutItem *child = layout->itemAt (n); | ||
|
||
if (item == child) | ||
found = true; | ||
|
||
#if 0 | ||
QGraphicsWidget* widget = (QGraphicsWidget*) child; | ||
SYS_DEBUG ("**********************************************"); | ||
SYS_DEBUG ("*** child = %p", child); | ||
SYS_DEBUG ("*** widget = %p", child->graphicsItem ()); | ||
SYS_DEBUG ("*** name = %s", SYS_STR(widget->objectName())); | ||
#endif | ||
} | ||
|
||
if (!found) { | ||
QGraphicsWidget* widget = (QGraphicsWidget*) item; | ||
SYS_WARNING ("Layout at %p should contain widget %p/%s.", | ||
layout, | ||
item, | ||
SYS_STR(widget->objectName())); | ||
} | ||
|
||
return found; | ||
} | ||
|
||
bool | ||
MTester::objectnameIs ( | ||
QGraphicsWidget *widget, | ||
const QString &name) | ||
{ | ||
bool retval = widget->objectName() == name; | ||
|
||
if (!retval) { | ||
QString realName = widget->objectName(); | ||
SYS_WARNING ("Widget at %p should have the name %s, but it is %s.", | ||
widget, | ||
SYS_STR(name), | ||
realName.isEmpty() ? "(empty)" : SYS_STR(realName)); | ||
} | ||
|
||
return retval; | ||
} |
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,44 @@ | ||
/* -*- Mode: C; indent-tabs-mode: s; c-basic-offset: 4; tab-width: 4 -*- */ | ||
/* vim:set et ai sw=4 ts=4 sts=4: tw=80 cino="(0,W2s,i2s,t0,l1,:0" */ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** All rights reserved. | ||
** Contact: Nokia Corporation (directui@nokia.com) | ||
** | ||
** This file is part of systemui. | ||
** | ||
** 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. | ||
** | ||
****************************************************************************/ | ||
#ifndef MTESTER_H | ||
#define MTESTER_H | ||
|
||
#include <QObject> | ||
|
||
class QGraphicsLayout; | ||
class QGraphicsLayoutItem; | ||
class QGraphicsWidget; | ||
class QString; | ||
|
||
class MTester : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
bool isLayoutContains ( | ||
QGraphicsLayout *layout, | ||
QGraphicsLayoutItem *item); | ||
|
||
bool objectnameIs ( | ||
QGraphicsWidget *widget, | ||
const QString &name); | ||
}; | ||
#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
152 changes: 152 additions & 0 deletions
152
tests/ut_unlocknotifications/ut_unlocknotifications.cpp
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,152 @@ | ||
/* -*- Mode: C; indent-tabs-mode: s; c-basic-offset: 4; tab-width: 4 -*- */ | ||
/* vim:set et ai sw=4 ts=4 sts=4: tw=80 cino="(0,W2s,i2s,t0,l1,:0" */ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** All rights reserved. | ||
** Contact: Nokia Corporation (directui@nokia.com) | ||
** | ||
** This file is part of systemui. | ||
** | ||
** 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_unlocknotifications.h" | ||
|
||
#include <notification.h> | ||
#include <notificationparameters.h> | ||
#include <genericnotificationparameterfactory.h> | ||
|
||
#include "unlockmissedevents_stub.h" | ||
#include "unlocknotifications.h" | ||
|
||
#include <MApplication> | ||
#include <MOrientationChangeEvent> | ||
|
||
#include <QGraphicsLinearLayout> | ||
#include <MImageWidget> | ||
#include <MLabel> | ||
|
||
#include <QtTest/QtTest> | ||
#include <QList> | ||
#include <QVariant> | ||
|
||
|
||
#define DEBUG | ||
#include "../../src/debug.h" | ||
|
||
static int argc = 1; | ||
static char *app_name = (char *) "./ut_unlocknotificationsink"; | ||
|
||
void | ||
Ut_UnlockNotifications::initTestCase () | ||
{ | ||
// Create a MAapplication | ||
app = new MApplication (argc, &app_name); | ||
} | ||
|
||
void | ||
Ut_UnlockNotifications::cleanupTestCase () | ||
{ | ||
// Destroy MApplication | ||
delete app; | ||
} | ||
|
||
void | ||
Ut_UnlockNotifications::init () | ||
{ | ||
m_Subject = new UnlockNotifications (); | ||
} | ||
|
||
void | ||
Ut_UnlockNotifications::cleanup () | ||
{ | ||
delete m_Subject; | ||
} | ||
|
||
void | ||
Ut_UnlockNotifications::testDefaultValues () | ||
{ | ||
if (m_Subject) { | ||
delete m_Subject; | ||
} | ||
|
||
m_Subject = new UnlockNotifications (); | ||
|
||
QVERIFY (m_Subject->m_otherevents_area); | ||
QVERIFY (m_Subject->m_mostrecent_layout); | ||
QVERIFY (m_Subject->m_last_icon); | ||
QVERIFY (m_Subject->m_last_subject); | ||
QVERIFY (m_Subject->m_icon_layout); | ||
QVERIFY (m_Subject->m_mostrecent_area); | ||
QVERIFY (m_Subject->m_vbox); | ||
|
||
QVERIFY (m_Tester.objectnameIs ( | ||
m_Subject->m_otherevents_area, | ||
"LockOtherEventsArea")); | ||
QVERIFY (m_Tester.objectnameIs ( | ||
m_Subject->m_last_icon, | ||
"LockMostRecentIcon")); | ||
QVERIFY (m_Tester.objectnameIs ( | ||
m_Subject->m_last_subject, | ||
"LockMostRecentLabel")); | ||
QVERIFY (m_Tester.objectnameIs ( | ||
m_Subject->m_mostrecent_area, | ||
"LockMostRecentArea")); | ||
} | ||
|
||
void | ||
Ut_UnlockNotifications::testOrientationChanged () | ||
{ | ||
if (!m_Subject) | ||
m_Subject = new UnlockNotifications (); | ||
|
||
/* | ||
* Testing the layout in landscape. | ||
*/ | ||
MOrientationChangeEvent landscapeEvent (M::Landscape); | ||
m_Subject->orientationChangeEvent (&landscapeEvent); | ||
QVERIFY (m_Tester.isLayoutContains( | ||
m_Subject->m_icon_layout, | ||
m_Subject->m_last_icon)); | ||
QVERIFY (m_Tester.isLayoutContains( | ||
m_Subject->m_icon_layout, | ||
m_Subject->m_last_subject)); | ||
|
||
/* | ||
* testing the layout in portrait. | ||
*/ | ||
MOrientationChangeEvent portraitEvent (M::Portrait); | ||
m_Subject->orientationChangeEvent (&portraitEvent); | ||
|
||
QVERIFY (m_Tester.isLayoutContains( | ||
m_Subject->m_mostrecent_layout, | ||
m_Subject->m_last_icon)); | ||
QVERIFY (m_Tester.isLayoutContains( | ||
m_Subject->m_mostrecent_layout, | ||
m_Subject->m_last_subject)); | ||
|
||
QVERIFY (m_Tester.isLayoutContains( | ||
m_Subject->m_vbox, | ||
m_Subject->m_mostrecent_area)); | ||
} | ||
|
||
void | ||
Ut_UnlockNotifications::testUpdateContents () | ||
{ | ||
if (!m_Subject) | ||
m_Subject = new UnlockNotifications (); | ||
|
||
m_Subject->updateContents (); | ||
} | ||
|
||
|
||
QTEST_APPLESS_MAIN(Ut_UnlockNotifications) | ||
|
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 @@ | ||
/* -*- Mode: C; indent-tabs-mode: s; c-basic-offset: 4; tab-width: 4 -*- */ | ||
/* vim:set et ai sw=4 ts=4 sts=4: tw=80 cino="(0,W2s,i2s,t0,l1,:0" */ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** All rights reserved. | ||
** Contact: Nokia Corporation (directui@nokia.com) | ||
** | ||
** This file is part of systemui. | ||
** | ||
** 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. | ||
** | ||
****************************************************************************/ | ||
#ifndef UT_UNLOCKNOTIFICATIONS_H | ||
#define UT_UNLOCKNOTIFICATIONS_H | ||
|
||
#include <QObject> | ||
#include <QGraphicsLayoutItem> | ||
|
||
#include "../common/MTester.h" | ||
|
||
#include "unlocknotifications.h" | ||
|
||
class MApplication; | ||
|
||
class Ut_UnlockNotifications : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
private slots: | ||
void init (); | ||
void cleanup (); | ||
void initTestCase (); | ||
void cleanupTestCase (); | ||
|
||
void testDefaultValues (); | ||
void testOrientationChanged (); | ||
void testUpdateContents (); | ||
|
||
private: | ||
MTester m_Tester; | ||
MApplication *app; | ||
UnlockNotifications *m_Subject; | ||
}; | ||
|
||
#endif | ||
|
Oops, something went wrong.