diff options
author | Adrian Yanes <ext-adrian.yanes@nokia.com> | 2010-06-17 12:49:05 +0300 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@nokia.com> | 2010-06-24 09:46:17 +0300 |
commit | 85161a08258d88bb71d1cea783f7dfa4144407d4 (patch) | |
tree | 8be2ea82020d41d5e511ecb2b24f7c0f637b2e29 /tests/ut_mbanner | |
parent | b831818a749a7968bb734f12ddbdb984cc6ac983 (diff) |
Changes: MBanner - small improvements
RevBy: Daniel d'Andrada
Details:
documentation improved, unit test added, code style reviewed.
Diffstat (limited to 'tests/ut_mbanner')
-rw-r--r-- | tests/ut_mbanner/.gitignore | 1 | ||||
-rw-r--r-- | tests/ut_mbanner/ut_mbanner.cpp | 132 | ||||
-rw-r--r-- | tests/ut_mbanner/ut_mbanner.h | 48 | ||||
-rw-r--r-- | tests/ut_mbanner/ut_mbanner.pro | 24 |
4 files changed, 205 insertions, 0 deletions
diff --git a/tests/ut_mbanner/.gitignore b/tests/ut_mbanner/.gitignore new file mode 100644 index 00000000..e58a9d9a --- /dev/null +++ b/tests/ut_mbanner/.gitignore @@ -0,0 +1 @@ +ut_mbanner diff --git a/tests/ut_mbanner/ut_mbanner.cpp b/tests/ut_mbanner/ut_mbanner.cpp new file mode 100644 index 00000000..fb43e44f --- /dev/null +++ b/tests/ut_mbanner/ut_mbanner.cpp @@ -0,0 +1,132 @@ +/*************************************************************************** +** +** 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 <QTest> +#include <QSignalSpy> + +#include <QObject> +#include <QGraphicsSceneMouseEvent> + +#include "mapplication.h" +#include "mbanner.h" +#include "ut_mbanner.h" + + + +MApplication *app; + +void Ut_MBanner::init() +{ + m_subject = new MBanner(); + QApplication::processEvents(QEventLoop::WaitForMoreEvents, 10); + m_tmp = 0; +} + +void Ut_MBanner::cleanup() +{ + delete m_subject; + m_subject = 0; +} + +void Ut_MBanner::initTestCase() +{ + static int argc = 1; + static char *app_name[1] = { (char *) "./ut_mbanner" }; + app = new MApplication(argc, app_name); +} + +void Ut_MBanner::cleanupTestCase() +{ + delete app; +} + +void Ut_MBanner::testTitle() +{ + QString title("Title 1"); + m_subject->setTitle(title); + QCOMPARE(m_subject->title(), title); +} + +void Ut_MBanner::testSubTitle() +{ + QString subtitle("Title 1"); + m_subject->setSubtitle(subtitle); + QCOMPARE(m_subject->subtitle(), subtitle); +} + + +void Ut_MBanner::testIcon() +{ + QString icon("icon-image"); + m_subject->setIconID(icon);; + QCOMPARE(m_subject->iconID(), icon); +} + + +void Ut_MBanner::testBannerCreation() +{ + /* Style configured as Event Banner */ + + MBanner *bannerEvent = new MBanner(); + + bannerEvent->setTitle("MBanner the new title"); + bannerEvent->setSubtitle("New subtitle"); + bannerEvent->setIconID("icon-1"); + + QCOMPARE(bannerEvent->title(), QString("MBanner the new title")); + QCOMPARE(bannerEvent->subtitle(), QString("New subtitle")); + QCOMPARE(bannerEvent->iconID(), QString("icon-1")); + + /* Style configured as Information Banner */ + + MBanner *bannerInformation = new MBanner(); + + bannerInformation->setSubtitle("New subtitle"); + + QCOMPARE(bannerInformation->subtitle(), QString("New subtitle")); + + /* Style configured as System Banner */ + + MBanner *bannerSystem = new MBanner(); + + bannerSystem->setSubtitle("New subtitle"); + bannerSystem->setIconID("icon-1"); + + QCOMPARE(bannerSystem->iconID(), QString("icon-1")); + QCOMPARE(bannerSystem->subtitle(), QString("New subtitle")); + + delete bannerEvent; + delete bannerInformation; + delete bannerSystem; +} + +void Ut_MBanner::testBannerClicking() +{ + MBanner *banner = new MBanner(); + + // click the banner + + QSignalSpy clickedSpy(banner, SIGNAL(clicked())); + banner->click(); + QCOMPARE(clickedSpy.count(), 1); + + delete banner; +} + +QTEST_APPLESS_MAIN(Ut_MBanner) diff --git a/tests/ut_mbanner/ut_mbanner.h b/tests/ut_mbanner/ut_mbanner.h new file mode 100644 index 00000000..d8164ca0 --- /dev/null +++ b/tests/ut_mbanner/ut_mbanner.h @@ -0,0 +1,48 @@ +/*************************************************************************** +** +** 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. +** +****************************************************************************/ + +#ifndef UT_MBANNER_H +#define UT_MBANNER_H + +#include <QtTest/QtTest> +#include <QObject> +#include "mbanner.h" + +class Ut_MBanner : public QObject +{ + Q_OBJECT + +private slots: + void init(); + void cleanup(); + void initTestCase(); + void cleanupTestCase(); + + void testTitle(); + void testSubTitle(); + void testIcon(); + void testBannerCreation(); + void testBannerClicking(); + +private: + MBanner *m_subject; + MBanner *m_tmp; +}; + +#endif diff --git a/tests/ut_mbanner/ut_mbanner.pro b/tests/ut_mbanner/ut_mbanner.pro new file mode 100644 index 00000000..83d2f3fe --- /dev/null +++ b/tests/ut_mbanner/ut_mbanner.pro @@ -0,0 +1,24 @@ +include(../common_top.pri) +INCLUDEPATH += $$MSRCDIR/corelib/style +TARGET = ut_mbanner + +# unit + +# unit test and unit +SOURCES += \ + ut_mbanner.cpp \ + +# service classes +SOURCES += \ +# $$STUBSDIR/stubbase.cpp \ + +# unit test and unit +HEADERS += \ + ut_mbanner.h + +# service classes +HEADERS += \ +# $$STUBSDIR/mstyle_stub.h \ +# $$STUBSDIR/mtheme_stub.h \ + +include(../common_bot.pri) |