Changes: Added unit tests for BoosterPluginRegistry

RevBy: Alexey Shilov
pull/1/head
Dmitry Rozenshtein 15 years ago
parent ac557d5f54
commit c1b4ec4d9d

@ -11,4 +11,8 @@ usr/share/applauncherd-tests/ut_socketmanager
usr/share/applauncherd-tests/ut_singleinstance
usr/share/applauncherd-tests/libutwithlock.so
usr/share/applauncherd-tests/libutwithlockunlock.so
usr/share/applauncherd-tests/ut_boosterpluginregistry
usr/share/applauncherd-tests/libutwithcreate.so
usr/share/applauncherd-tests/libutwithcreatetype.so
usr/share/applauncherd-tests/libutwithcreatetypesocketname.so
usr/share/applauncherd-tests/libutplugin.so

1
debian/changelog vendored

@ -5,6 +5,7 @@ applauncherd (0.30.6) unstable; urgency=low
* Changes: Language corrections into documentation.
* Changes: Added unittests for mbooster, qtbooster, ebooster, dbooster
* Changes: Added unittests for SingleInstance
* Changes: Added unittests for BoosterPluginRegistry
-- Alexey Shilov <alexey.shilov@nokia.com> Tue, 28 Jun 2011 13:55:48 +0300

@ -92,6 +92,10 @@ private:
//! Registry
typedef vector<shared_ptr<BoosterPluginEntry> > RegistryType;
static RegistryType m_registry;
#ifdef UNIT_TEST
friend class Ut_BoosterPluginRegistry;
#endif
};
#endif // BOOSTERPLUGINREGISTRY_H

@ -8,6 +8,7 @@ add_subdirectory(ut_mbooster)
add_subdirectory(ut_qtbooster)
add_subdirectory(ut_socketmanager)
add_subdirectory(ut_singleinstance)
add_subdirectory(ut_boosterpluginregistry)
install(FILES tests.xml DESTINATION /usr/share/applauncherd-tests)

@ -78,6 +78,21 @@
</get-->
</set>
<set name="boosterpluginregistry-test" description="BoosterPluginRegistry unit tests" feature="AF BoosterPluginRegistry for Launcher daemon" requirement="1131430" >
<case name="BoosterPluginRegistry" type="Functional" description="Unit tests for BoosterPluginRegistry class" level="Component" timeout="20">
<step expected_result="0">su - user -c 'source /tmp/session_bus_address.user &amp;&amp; DISPLAY=:0 /usr/share/applauncherd-tests/ut_boosterpluginregistry'</step>
</case>
<environments>
<scratchbox>true</scratchbox>
<hardware>true</hardware>
</environments>
<!--get>
</get-->
</set>
</suite>
</testdefinition>

@ -0,0 +1,110 @@
/***************************************************************************
**
** 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_boosterpluginregistry.h"
#include "boosterpluginregistry.h"
#include <dlfcn.h>
Ut_BoosterPluginRegistry::Ut_BoosterPluginRegistry()
{}
Ut_BoosterPluginRegistry::~Ut_BoosterPluginRegistry()
{}
void Ut_BoosterPluginRegistry::initTestCase()
{}
void Ut_BoosterPluginRegistry::cleanupTestCase()
{}
void Ut_BoosterPluginRegistry::testValidateAndRegisterPlugin()
{
void * handle = NULL;
//positive
handle = dlopen(TEST_LIB_PLUGIN_PATH, RTLD_NOW);
QVERIFY(handle);
char pluginType = BoosterPluginRegistry::validateAndRegisterPlugin(handle);
QVERIFY(pluginType == 'z');
//negative invalid handle
handle = NULL;
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
//negative no "type" symbol in the plugin (only create)
handle = dlopen(TEST_LIB_CREATE_PATH, RTLD_NOW);
QVERIFY(handle);
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
//negative no "socketName" symbol in the plugin (only create and type)
handle = dlopen(TEST_LIB_CREATETYPE_PATH, RTLD_NOW);
QVERIFY(handle);
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
//negative no "temporaryProcessName" symbol in the plugin (only create, type and sockeName)
handle = dlopen(TEST_LIB_CREATETYPESOCKETNAME_PATH, RTLD_NOW);
QVERIFY(handle);
QVERIFY(BoosterPluginRegistry::validateAndRegisterPlugin(handle) == false);
}
void Ut_BoosterPluginRegistry::testRegisterPlugin()
{
void * handle = dlopen(TEST_LIB_PLUGIN_PATH, RTLD_NOW);
QVERIFY(handle);
dlerror();
create_func_t createFunc = (create_func_t)dlsym(handle, "create");
QVERIFY(dlerror() == NULL);
sn_func_t socketNameFunc = (sn_func_t)dlsym(handle, "socketName");
QVERIFY(dlerror() == NULL);
tpn_func_t temporaryProcessNameFunc = (tpn_func_t)dlsym(handle, "temporaryProcessName");
QVERIFY(dlerror() == NULL);
BoosterPluginRegistry::registerPlugin('0', createFunc, socketNameFunc, temporaryProcessNameFunc); //register new plugin with type '0'
BoosterPluginEntry * pluginEntry = BoosterPluginRegistry::pluginEntry('0');
QVERIFY(pluginEntry);
QVERIFY(pluginEntry->type == '0');
}
void Ut_BoosterPluginRegistry::testPluginEntry()
{
//positive
void * handle = dlopen(TEST_LIB_PLUGIN_PATH, RTLD_NOW);
QVERIFY(handle);
BoosterPluginRegistry::validateAndRegisterPlugin(handle);
BoosterPluginEntry * pluginEntry = BoosterPluginRegistry::pluginEntry('z');
QVERIFY(pluginEntry);
QVERIFY(pluginEntry->type == 'z');
//negative with negative index for int type constructor
QVERIFY(BoosterPluginRegistry::pluginEntry(-100) == false);
//negative with index larger then registered plugins count
int index;
index = BoosterPluginRegistry::pluginCount() + 1;
QVERIFY(BoosterPluginRegistry::pluginEntry(index) == false);
//negative with unregistered plugin type
QVERIFY(BoosterPluginRegistry::pluginEntry('1') == false);
}
QTEST_APPLESS_MAIN(Ut_BoosterPluginRegistry)

@ -0,0 +1,47 @@
/***************************************************************************
**
** 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_BOOSTERPLUGINREGISTRY_H
#define UT_BOOSTERPLUGINREGISTRY_H
#include<QtTest/QtTest>
#include<QObject>
#define UNIT_TEST
class BoosterPluginRegistry;
class Ut_BoosterPluginRegistry : public QObject
{
Q_OBJECT
public:
Ut_BoosterPluginRegistry();
virtual ~Ut_BoosterPluginRegistry();
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void testValidateAndRegisterPlugin();
void testRegisterPlugin();
void testPluginEntry();
};
#endif // UT_BOOSTERPLUGINREGISTRY_H

@ -0,0 +1,42 @@
/***************************************************************************
**
** 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.
**
****************************************************************************/
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
extern "C"
{
DECL_EXPORT void create()
{
}
DECL_EXPORT char type()
{
return 'z';
}
DECL_EXPORT const char * socketName()
{
return 0;
}
DECL_EXPORT const char * temporaryProcessName()
{
return 0;
}
}

@ -0,0 +1,26 @@
/***************************************************************************
**
** 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.
**
****************************************************************************/
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
extern "C"
{
DECL_EXPORT void create()
{
}
}

@ -0,0 +1,31 @@
/***************************************************************************
**
** 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.
**
****************************************************************************/
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
extern "C"
{
DECL_EXPORT void create()
{
}
DECL_EXPORT void type()
{
}
}

@ -0,0 +1,35 @@
/***************************************************************************
**
** 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.
**
****************************************************************************/
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
extern "C"
{
DECL_EXPORT void create()
{
}
DECL_EXPORT void type()
{
}
DECL_EXPORT void socketName()
{
}
}

@ -1,3 +1,22 @@
/***************************************************************************
**
** 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.
**
****************************************************************************/
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
extern "C"
{

@ -1,3 +1,22 @@
/***************************************************************************
**
** 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.
**
****************************************************************************/
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
extern "C"
{

Loading…
Cancel
Save