diff -r 2c7f27287390 -r 053c6c7c14f3 homescreensrv_plat/hs_settings_api/tsrc/src/mt_hspluginsettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/homescreensrv_plat/hs_settings_api/tsrc/src/mt_hspluginsettings.cpp Thu Aug 19 10:13:44 2010 +0300 @@ -0,0 +1,178 @@ +/* +* 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: EUnit test for homescreen settings API, main suite +* +*/ + +// External includes +#include +#include +#include + +// Internal includes +#include +#include +#include + +// ======== MEMBER FUNCTIONS ======== + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::NewL( ) +//---------------------------------------------------------------------------- +// +MT_HsPluginSettings* MT_HsPluginSettings::NewL() + { + MT_HsPluginSettings* self = MT_HsPluginSettings::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::NewLC( ) +//---------------------------------------------------------------------------- +// +MT_HsPluginSettings* MT_HsPluginSettings::NewLC() + { + MT_HsPluginSettings* self = new( ELeave ) MT_HsPluginSettings(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::~MT_HsPluginSettings( ) +//---------------------------------------------------------------------------- +// +MT_HsPluginSettings::~MT_HsPluginSettings() + { + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::MT_HsPluginSettings( ) +//---------------------------------------------------------------------------- +// +MT_HsPluginSettings::MT_HsPluginSettings() + { + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::ConstructL( ) +//---------------------------------------------------------------------------- +// +void MT_HsPluginSettings::ConstructL() + { + // The ConstructL from the base class CEUnitTestSuiteClass must be called. + // It generates the test case table. + CEUnitTestSuiteClass::ConstructL(); + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::SetupL( ) +//---------------------------------------------------------------------------- +// +void MT_HsPluginSettings::SetupL( ) + { + iObserver = CHomescreenSettingsObserver::NewL(); + HSPluginSettingsIf::CHomescreenSettings::InitializeL( _L8( "271012080" ) ); + iHomescreenSettings = HSPluginSettingsIf::CHomescreenSettings::Instance(); + iHomescreenSettings->AddObserverL( iObserver ); + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::Teardown( ) +//---------------------------------------------------------------------------- +// +void MT_HsPluginSettings::Teardown( ) + { + iHomescreenSettings->RemoveObserver( iObserver ); + HSPluginSettingsIf::CHomescreenSettings::UnInitialize(); + iHomescreenSettings = NULL; + + if( iObserver ) + { + delete iObserver; + iObserver = NULL; + } + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::TestGetSettingsL( ) +//---------------------------------------------------------------------------- +// +void MT_HsPluginSettings::TestGetSettingsL() + { + _LIT8( KId, "1" ); // Plugin with ID 1 should be present - usually + //_LIT8( KId, "0x2001f482" ); // root config UId - GetSettingsL does not work with uids + + RPointerArray settingItems; + CleanupClosePushL( settingItems ); + + TInt err = iHomescreenSettings->GetSettingsL( KId, settingItems ); + if ( err ) + { + EUNIT_PRINT( _L( "Warning: Get plugin settings failed" ) ); + } + + CleanupStack::Pop( &settingItems ); + settingItems.ResetAndDestroy(); + + EUNIT_ASSERT( ETrue ); + } + +//---------------------------------------------------------------------------- +// MT_HsPluginSettings::TestSetSettingsL( ) +//---------------------------------------------------------------------------- +// +void MT_HsPluginSettings::TestSetSettingsL() + { + _LIT8( KId, "1" ); // Plugin with ID 1 should be present - usually + //_LIT8( KId, "0x2001f482" ); // root config UId - does not work with uids + + RPointerArray settingItems; + CleanupClosePushL( settingItems ); + + TInt err = iHomescreenSettings->SetSettingsL( KId, settingItems, EFalse ); + if ( err ) + { + EUNIT_PRINT( _L( "Warning: Set plugin settings function failed" ) ); + } + + CleanupStack::Pop( &settingItems ); + settingItems.ResetAndDestroy(); + + EUNIT_ASSERT( ETrue ); + } + +// EUnit test table + +EUNIT_BEGIN_TEST_TABLE( + MT_HsPluginSettings, + "Test hspluginsettings", + "MODULE") + +EUNIT_TEST( + "Test GetSettingsL", + "GetSettingsL", + "All", + "FUNCTIONALITY", + SetupL, TestGetSettingsL, Teardown) + +EUNIT_TEST( + "Test SetSettingsL", + "SetSettingsL", + "All", + "FUNCTIONALITY", + SetupL, TestSetSettingsL, Teardown) + +EUNIT_END_TEST_TABLE