diff -r efe85016a067 -r 7cbcb2896f0e contactwidgethsplugin/t_contactwidgethsplugin/src/t_contactwidgethsplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contactwidgethsplugin/t_contactwidgethsplugin/src/t_contactwidgethsplugin.cpp Tue Jul 06 14:05:47 2010 +0300 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main test class for contactwidgethsplugin library. +* +*/ + + +#include +#include "t_contactwidgethsplugin.h" +#include "contactwidgethsplugin.h" + +#include +#include +#include +#include + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void TestContactWidgetPlugin::init() +{ + mContactWidgetPlugin = new ContactWidgetHsPlugin; + QVERIFY(mContactWidgetPlugin); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void TestContactWidgetPlugin::cleanup() +{ + if (mContactWidgetPlugin) { + delete mContactWidgetPlugin; + mContactWidgetPlugin = 0; + QVERIFY(mContactWidgetPlugin == 0); + } +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void TestContactWidgetPlugin::testCreateInstance() +{ + QServiceManager serviceManager; + ContactWidgetHsPlugin plugin; + QServiceFilter serviceFilter("com.nokia.symbian.IHomeScreenWidget"); + serviceFilter.setServiceName("contactwidgethsplugin"); + QList serviceInterfaceDescriptorList = + serviceManager.findInterfaces(serviceFilter); + int len = serviceInterfaceDescriptorList.size(); + QVERIFY(len > 0); + QServiceInterfaceDescriptor serviceInterfaceDescriptor = + serviceInterfaceDescriptorList[0]; + QObject *handler = plugin.createInstance( + serviceInterfaceDescriptor, NULL, NULL); + QVERIFY(handler); + delete handler; +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void TestContactWidgetPlugin::testCreateInvalidInstance() +{ + QServiceInterfaceDescriptor descriptor; + + QObject *instanceValue = NULL; + instanceValue = mContactWidgetPlugin->createInstance(descriptor, NULL, NULL); + + QVERIFY(instanceValue == NULL); + delete instanceValue; +} + +QTEST_MAIN(TestContactWidgetPlugin)