diff -r e4f038c420f7 -r 3ac3aaebaee5 homescreenapp/serviceproviders/hsmenuserviceprovider/tsrc/t_hsmenuserviceprovider/src/t_hsmenuentryremovedhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/homescreenapp/serviceproviders/hsmenuserviceprovider/tsrc/t_hsmenuserviceprovider/src/t_hsmenuentryremovedhandler.cpp Mon Sep 20 10:19:07 2010 +0300 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2010 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: + * + */ + +#include +#include + +#include "t_hsmenuserviceprovider.h" +#include "hsmenuentryremovedhandler.h" +#include "t_hsmenuentryremovedcallback.h" +#include +#include "caservice.h" +#include "canotifier.h" +#include "canotifierfilter.h" + + + +void MenuServiceTest::HsMenuEntryRemovedHandlerTest_data() +{ + // define testing data table + QTest::addColumn("subscribedId"); + QTest::addColumn("notifiedChangeType"); + QTest::addColumn("notificationsCount"); + QTest::addColumn("callbacksCount"); + // prepare concrete rows for testing + // id changeType + QTest::newRow("non_matching_id") << 0 << static_cast(RemoveChangeType) << 1 << 0; + + QTest::newRow("non_matching_change_type") << 1 << static_cast(AddChangeType) << 1 << 0; + + QTest::newRow("many_notifications") << 1 << static_cast(RemoveChangeType) << 3 << 1; + + QTest::newRow("one_notification") << 1 << static_cast(RemoveChangeType) << 1 << 1; + + QTest::newRow("no_notification") << 1 << static_cast(RemoveChangeType) << 0 << 0; +} + +void MenuServiceTest::HsMenuEntryRemovedHandlerTest() +{ + QFETCH(int, subscribedId); + QFETCH(int, notifiedChangeType); + QFETCH(int, notificationsCount); + QFETCH(int, callbacksCount); + + QPointer caNotifierMock(new CaNotifier()); + CaService::instance()->mCreateNotifierResult = caNotifierMock.data(); + + T_HsMenuEntryRemovedCallback callbackObj; + HsMenuEntryRemovedHandler handler(subscribedId, &callbackObj, SLOT(callback())); + + QSignalSpy spy(&handler, SIGNAL(notify())); + + for (int i = 0 ; i < notificationsCount && !caNotifierMock.isNull(); ++i) { + caNotifierMock->issueEntryChanged(subscribedId, + static_cast(notifiedChangeType)); + qApp->processEvents(); + } + + QCOMPARE(callbackObj.callsCount(), callbacksCount); + QCOMPARE(spy.count(), callbackObj.callsCount()); +}