mirror of https://github.com/cutefishos/appmotor
Merge commit 'origin/master' into my-master
commit
912a2fa8f1
@ -0,0 +1,27 @@
|
|||||||
|
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcher)
|
||||||
|
|
||||||
|
# Set sources
|
||||||
|
set(SRC ut_boosterfactory.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/mbooster.cpp ${LAUNCHER}/qtbooster.cpp ${LAUNCHER}/wrtbooster.cpp ${LAUNCHER}/boosterfactory.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp)
|
||||||
|
|
||||||
|
# Set moc headers
|
||||||
|
set(MOC_HDRS ut_boosterfactory.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_boosterfactory ${SRC} ${MOC_SRC})
|
||||||
|
|
||||||
|
# Install
|
||||||
|
install(PROGRAMS ut_boosterfactory DESTINATION /usr/share/applauncherd-tests/)
|
||||||
|
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** 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_boosterfactory.h"
|
||||||
|
#include "boosterfactory.h"
|
||||||
|
#include "booster.h"
|
||||||
|
#include "mbooster.h"
|
||||||
|
#include "qtbooster.h"
|
||||||
|
#include "wrtbooster.h"
|
||||||
|
|
||||||
|
Ut_BoosterFactory::Ut_BoosterFactory()
|
||||||
|
{}
|
||||||
|
|
||||||
|
Ut_BoosterFactory::~Ut_BoosterFactory()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Ut_BoosterFactory::initTestCase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ut_BoosterFactory::cleanupTestCase()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Ut_BoosterFactory::testCreate()
|
||||||
|
{
|
||||||
|
Booster * booster = BoosterFactory::create('q');
|
||||||
|
QVERIFY(dynamic_cast<QtBooster *>(booster));
|
||||||
|
delete booster;
|
||||||
|
|
||||||
|
booster = BoosterFactory::create('m');
|
||||||
|
QVERIFY(dynamic_cast<MBooster *>(booster));
|
||||||
|
delete booster;
|
||||||
|
|
||||||
|
booster = BoosterFactory::create('w');
|
||||||
|
QVERIFY(dynamic_cast<WRTBooster *>(booster));
|
||||||
|
delete booster;
|
||||||
|
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
unsigned char t = static_cast<unsigned char>(i);
|
||||||
|
if (t != 'q' && t != 'm' && t != 'w')
|
||||||
|
{
|
||||||
|
QVERIFY(!BoosterFactory::create(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ut_BoosterFactory::testSetProcessIdToBooster()
|
||||||
|
{
|
||||||
|
BoosterFactory::setProcessIdToBooster('q', 123);
|
||||||
|
QVERIFY(QtBooster::processId() == 123);
|
||||||
|
|
||||||
|
BoosterFactory::setProcessIdToBooster('m', 234);
|
||||||
|
QVERIFY(MBooster::processId() == 234);
|
||||||
|
|
||||||
|
BoosterFactory::setProcessIdToBooster('w', 345);
|
||||||
|
QVERIFY(WRTBooster::processId() == 345);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ut_BoosterFactory::testGetBoosterTypeForPid()
|
||||||
|
{
|
||||||
|
BoosterFactory::setProcessIdToBooster('q', 1);
|
||||||
|
BoosterFactory::setProcessIdToBooster('m', 2);
|
||||||
|
BoosterFactory::setProcessIdToBooster('w', 3);
|
||||||
|
|
||||||
|
QVERIFY(BoosterFactory::getBoosterTypeForPid(1) == 'q');
|
||||||
|
QVERIFY(BoosterFactory::getBoosterTypeForPid(2) == 'm');
|
||||||
|
QVERIFY(BoosterFactory::getBoosterTypeForPid(3) == 'w');
|
||||||
|
|
||||||
|
QVERIFY(BoosterFactory::getBoosterTypeForPid(0) == 0);
|
||||||
|
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
unsigned char t = static_cast<unsigned char>(i);
|
||||||
|
if (t != 'q' && t != 'm' && t != 'w')
|
||||||
|
{
|
||||||
|
BoosterFactory::setProcessIdToBooster(t, 1000);
|
||||||
|
QVERIFY(BoosterFactory::getBoosterTypeForPid(1000) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_APPLESS_MAIN(Ut_BoosterFactory);
|
||||||
|
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** 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_BOOSTERFACTORY_H
|
||||||
|
#define UT_BOOSTERFACTORY_H
|
||||||
|
|
||||||
|
#include<QtTest/QtTest>
|
||||||
|
#include<QObject>
|
||||||
|
|
||||||
|
#define UNIT_TEST
|
||||||
|
|
||||||
|
class BoosterFactory;
|
||||||
|
|
||||||
|
class Ut_BoosterFactory : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Ut_BoosterFactory();
|
||||||
|
virtual ~Ut_BoosterFactory();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void initTestCase();
|
||||||
|
void cleanupTestCase();
|
||||||
|
void testCreate();
|
||||||
|
void testSetProcessIdToBooster();
|
||||||
|
void testGetBoosterTypeForPid();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // UT_BOOSTERFACTORY_H
|
||||||
Loading…
Reference in New Issue