From c12ae5a2c0f61ba2c394ec8e57a7c1908f9775dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pertti=20Kellom=C3=A4ki?= Date: Thu, 20 Jan 2011 17:06:15 +0200 Subject: [PATCH] Changes: Unit tests for the qdeclarativebooster. --- debian/applauncherd-tests.install | 1 + tests/Common/unittests/CMakeLists.txt | 1 + .../unittests/ut_dbooster/CMakeLists.txt | 31 ++++++++++ .../unittests/ut_dbooster/ut_dbooster.cpp | 61 +++++++++++++++++++ .../unittests/ut_dbooster/ut_dbooster.h | 51 ++++++++++++++++ 5 files changed, 145 insertions(+) create mode 100644 tests/Common/unittests/ut_dbooster/CMakeLists.txt create mode 100644 tests/Common/unittests/ut_dbooster/ut_dbooster.cpp create mode 100644 tests/Common/unittests/ut_dbooster/ut_dbooster.h diff --git a/debian/applauncherd-tests.install b/debian/applauncherd-tests.install index 68966c6..df05579 100644 --- a/debian/applauncherd-tests.install +++ b/debian/applauncherd-tests.install @@ -3,6 +3,7 @@ usr/share/applauncherd-tests/ut_booster usr/share/applauncherd-tests/ut_boosterfactory usr/share/applauncherd-tests/ut_daemon usr/share/applauncherd-tests/ut_connection +usr/share/applauncherd-tests/ut_dbooster usr/share/applauncherd-tests/ut_mbooster usr/share/applauncherd-tests/ut_qtbooster usr/share/applauncherd-tests/ut_socketmanager diff --git a/tests/Common/unittests/CMakeLists.txt b/tests/Common/unittests/CMakeLists.txt index e42ecf9..191e5f6 100644 --- a/tests/Common/unittests/CMakeLists.txt +++ b/tests/Common/unittests/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory(ut_booster) add_subdirectory(ut_boosterfactory) add_subdirectory(ut_connection) add_subdirectory(ut_daemon) +add_subdirectory(ut_dbooster) add_subdirectory(ut_mbooster) add_subdirectory(ut_qtbooster) add_subdirectory(ut_socketmanager) diff --git a/tests/Common/unittests/ut_dbooster/CMakeLists.txt b/tests/Common/unittests/ut_dbooster/CMakeLists.txt new file mode 100644 index 0000000..ad594ba --- /dev/null +++ b/tests/Common/unittests/ut_dbooster/CMakeLists.txt @@ -0,0 +1,31 @@ +set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib) +set(DBOOSTER ${CMAKE_HOME_DIRECTORY}/src/qdeclarativebooster) + +# Set sources +set(SRC ut_dbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp +${LAUNCHER}/connection.cpp +${LAUNCHER}/logger.cpp ${DBOOSTER}/qdeclarativebooster.cpp +${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp) + +# Set moc headers +set(MOC_HDRS ut_dbooster.h ${DBOOSTER}/qdeclarativebooster.h) + +# Run moc +qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) + +# Enable test library +set(QT_USE_QTTEST TRUE) + +# Set include paths +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER} ${DBOOSTER}) + +link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${MEEGOTOUCH_LIBRARIES} ${LIBCREDS} "-L${CMAKE_SOURCE_DIR}/src/qdeclarativebooster -lqdeclarativeboostercache") + +# Enable Qt (may not be needed, because already defined on higher level) +include(${QT_USE_FILE}) + +add_executable(ut_dbooster ${SRC} ${MOC_SRC} ) + +# Install +install(PROGRAMS ut_dbooster DESTINATION /usr/share/applauncherd-tests/) + diff --git a/tests/Common/unittests/ut_dbooster/ut_dbooster.cpp b/tests/Common/unittests/ut_dbooster/ut_dbooster.cpp new file mode 100644 index 0000000..2981f5e --- /dev/null +++ b/tests/Common/unittests/ut_dbooster/ut_dbooster.cpp @@ -0,0 +1,61 @@ +/*************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of applauncherd +** +** 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_dbooster.h" +#include "qdeclarativebooster.h" +#include "qdeclarativeboostercache.h" + +Ut_DBooster::Ut_DBooster() : + m_subject(new QDeclarativeBooster) +{} + +Ut_DBooster::~Ut_DBooster() +{} + +void Ut_DBooster::initTestCase() +{} + +void Ut_DBooster::cleanupTestCase() +{} + +void Ut_DBooster::testSocketName() +{ + QVERIFY(QDeclarativeBooster::socketName() == QDeclarativeBooster::m_socketId); + QVERIFY(m_subject->socketId() == QDeclarativeBooster::m_socketId); +} + +void Ut_DBooster::testType() +{ + QVERIFY(QDeclarativeBooster::type() == 'd'); + QVERIFY(m_subject->boosterType() == 'd'); +} + +void Ut_DBooster::testPreload() +{ + m_subject->preload(); + + const char * argv[] = {"foo"}; + int argc = 1; + + QVERIFY(QDeclarativeBoosterCache::qApplication(argc, const_cast(argv))); + QVERIFY(QDeclarativeBoosterCache::qDeclarativeView()); +} + +QTEST_APPLESS_MAIN(Ut_DBooster); + diff --git a/tests/Common/unittests/ut_dbooster/ut_dbooster.h b/tests/Common/unittests/ut_dbooster/ut_dbooster.h new file mode 100644 index 0000000..b7186df --- /dev/null +++ b/tests/Common/unittests/ut_dbooster/ut_dbooster.h @@ -0,0 +1,51 @@ +/*************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of applauncherd +** +** 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_DBOOSTER_H +#define UT_DBOOSTER_H + +#include +#include + +#include + +#define UNIT_TEST + +class QDeclarativeBooster; + +class Ut_DBooster : public QObject +{ + Q_OBJECT + +public: + Ut_DBooster(); + virtual ~Ut_DBooster(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void testSocketName(); + void testType(); + void testPreload(); + +private: + std::tr1::shared_ptr m_subject; +}; + +#endif // UT_DBOOSTER_H