From 97120632e9f39b4139db74c0799551f7eeaf3859 Mon Sep 17 00:00:00 2001 From: Jussi Lind Date: Tue, 7 Sep 2010 15:49:02 +0300 Subject: [PATCH] New: Unit tests for WRTBooster added. Cleaned up tests/unittests/tests.xml. Details: Removed duplicated entries in tests.xml, presteps removed since they didn't have any effect. --- tests/unittests/CMakeLists.txt | 1 + tests/unittests/tests.xml | 40 ++-------- tests/unittests/ut_wrtbooster/CMakeLists.txt | 28 +++++++ .../unittests/ut_wrtbooster/ut_wrtbooster.cpp | 73 +++++++++++++++++++ tests/unittests/ut_wrtbooster/ut_wrtbooster.h | 52 +++++++++++++ 5 files changed, 162 insertions(+), 32 deletions(-) create mode 100644 tests/unittests/ut_wrtbooster/CMakeLists.txt create mode 100644 tests/unittests/ut_wrtbooster/ut_wrtbooster.cpp create mode 100644 tests/unittests/ut_wrtbooster/ut_wrtbooster.h diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index d0decef..4efc2e1 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory(ut_daemon) add_subdirectory(ut_booster) add_subdirectory(ut_mbooster) add_subdirectory(ut_qtbooster) +add_subdirectory(ut_wrtbooster) add_subdirectory(ut_connection) install(FILES tests.xml DESTINATION /usr/share/applauncherd-tests) diff --git a/tests/unittests/tests.xml b/tests/unittests/tests.xml index 36e4974..b0439dc 100644 --- a/tests/unittests/tests.xml +++ b/tests/unittests/tests.xml @@ -6,11 +6,6 @@ - - export DISPLAY=:0 - source /tmp/session_bus_address.user - - /usr/share/applauncherd-tests/ut_daemon @@ -29,43 +24,24 @@ - - - export DISPLAY=:0 - source /tmp/session_bus_address.user - - - - - - /usr/share/applauncherd-tests/ut_mbooster - - + /usr/share/applauncherd-tests/ut_booster - - true - true - - - - - - - - export DISPLAY=:0 - source /tmp/session_bus_address.user - - + + /usr/share/applauncherd-tests/ut_mbooster + /usr/share/applauncherd-tests/ut_qtbooster + + source /tmp/session_bus_address.user && DISPLAY=:0 /usr/share/applauncherd-tests/ut_wrtbooster + + true true diff --git a/tests/unittests/ut_wrtbooster/CMakeLists.txt b/tests/unittests/ut_wrtbooster/CMakeLists.txt new file mode 100644 index 0000000..2eff274 --- /dev/null +++ b/tests/unittests/ut_wrtbooster/CMakeLists.txt @@ -0,0 +1,28 @@ +set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher) + +# Set sources +set(SRC ut_wrtbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp + ${LAUNCHER}/logger.cpp ${LAUNCHER}/wrtbooster.cpp) + +# Set moc headers +set(MOC_HDRS ut_wrtbooster.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}) + +link_libraries(${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${MEEGOTOUCH_LIBRARIES} ${LIBCREDS}) + +# Enable Qt (may not be needed, because already defined on higher level) +include(${QT_USE_FILE}) + +add_executable(ut_wrtbooster ${SRC} ${MOC_SRC} ) + +# Install +install(PROGRAMS ut_wrtbooster DESTINATION /usr/share/applauncherd-tests/) + diff --git a/tests/unittests/ut_wrtbooster/ut_wrtbooster.cpp b/tests/unittests/ut_wrtbooster/ut_wrtbooster.cpp new file mode 100644 index 0000000..cb84566 --- /dev/null +++ b/tests/unittests/ut_wrtbooster/ut_wrtbooster.cpp @@ -0,0 +1,73 @@ +/*************************************************************************** +** +** Copyright (C) 2010 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_wrtbooster.h" +#include "wrtbooster.h" + +#ifdef HAVE_MCOMPONENTCACHE +#include +#endif + +Ut_WRTBooster::Ut_WRTBooster() : + m_subject(new WRTBooster) +{} + +Ut_WRTBooster::~Ut_WRTBooster() +{} + +void Ut_WRTBooster::initTestCase() +{} + +void Ut_WRTBooster::cleanupTestCase() +{} + +void Ut_WRTBooster::testSocketName() +{ + QVERIFY(WRTBooster::socketName() == WRTBooster::m_socketId); + QVERIFY(m_subject->socketId() == WRTBooster::m_socketId); +} + +void Ut_WRTBooster::testType() +{ + QVERIFY(WRTBooster::type() == 'w'); + QVERIFY(m_subject->boosterType() == 'w'); +} + +void Ut_WRTBooster::testSetProcessId() +{ + WRTBooster::setProcessId(123); + QVERIFY(WRTBooster::processId() == 123); +} + +void Ut_WRTBooster::testPreload() +{ +#ifdef HAVE_MCOMPONENTCACHE + + m_subject->preload(); + + const char * argv[] = {"foo"}; + int argc = 1; + + QVERIFY(MComponentCache::mApplication(argc, const_cast(argv))); + QVERIFY(MComponentCache::mApplicationWindow()); + +#endif +} + +QTEST_APPLESS_MAIN(Ut_WRTBooster); diff --git a/tests/unittests/ut_wrtbooster/ut_wrtbooster.h b/tests/unittests/ut_wrtbooster/ut_wrtbooster.h new file mode 100644 index 0000000..f6623c2 --- /dev/null +++ b/tests/unittests/ut_wrtbooster/ut_wrtbooster.h @@ -0,0 +1,52 @@ +/*************************************************************************** +** +** Copyright (C) 2010 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_WRTBOOSTER_H +#define UT_WRTBOOSTER_H + +#include +#include + +#include + +#define UNIT_TEST + +class WRTBooster; + +class Ut_WRTBooster : public QObject +{ + Q_OBJECT + +public: + Ut_WRTBooster(); + virtual ~Ut_WRTBooster(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void testSocketName(); + void testType(); + void testSetProcessId(); + void testPreload(); + +private: + std::tr1::shared_ptr m_subject; +}; + +#endif // UT_WRTBOOSTER_H