installationservices/swinstallationfw/test/securitytests/source/scrpluginmanagement.cpp
changeset 24 84a16765cd86
child 42 d17dc5398051
equal deleted inserted replaced
6:aba6b8104af3 24:84a16765cd86
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @test
       
    22 */
       
    23 
       
    24 #include "scrpluginmanagement.h"
       
    25 
       
    26 #include <usif/scr/scr.h>
       
    27 #include <scs/cleanuputils.h>
       
    28 #include <e32def.h>
       
    29 
       
    30 _LIT_SECURE_ID(KSisRegistryServerSid, 0x10202DCA);
       
    31 _LIT(KScrPluginManagementSecName, "SCR Plugin Management APIs test");
       
    32 
       
    33 using namespace Usif;
       
    34 
       
    35 CScrPluginManagementSecTest* CScrPluginManagementSecTest::NewL()
       
    36 	{
       
    37 	CScrPluginManagementSecTest* self=new(ELeave) CScrPluginManagementSecTest();
       
    38 	CleanupStack::PushL(self);
       
    39 	self->ConstructL();
       
    40 	CleanupStack::Pop(self);
       
    41 	return self;
       
    42 	}
       
    43 
       
    44 CScrPluginManagementSecTest::CScrPluginManagementSecTest()
       
    45 	{
       
    46 	SetSidRequired(KSisRegistryServerSid);
       
    47 	}
       
    48 	
       
    49 void CScrPluginManagementSecTest::ConstructL()
       
    50 	{
       
    51 	SetNameL(KScrPluginManagementSecName);
       
    52 	}
       
    53 
       
    54 void CScrPluginManagementSecTest::RunTestL()
       
    55 	{
       
    56 	RSoftwareComponentRegistry scrSession;
       
    57 	User::LeaveIfError(scrSession.Connect());
       
    58 	CleanupClosePushL(scrSession);
       
    59 	
       
    60 	// The transaction APIs are tested separately. If this command fails, then we can proceed, as the following operations would fail also, and no transaction management would be required
       
    61 	TRAP_IGNORE(scrSession.CreateTransactionL()); 
       
    62 	
       
    63 	TInt err(0);
       
    64 	
       
    65 	// First, add a new sofwtare type
       
    66 	_LIT(KSwTypeName, "usifsecuritytestsoftwaretype");
       
    67 	TUid sifPluginUid = {0xA01B7211};
       
    68 	_LIT_SECURE_ID(installerSecureId, 0xAAFFEE11);
       
    69 	_LIT_SECURE_ID(executionLayerSecureId, 0xAAEEDD11);
       
    70 	
       
    71 	_LIT(KMimeType, "usifsecuritytestmimetype");
       
    72 	RPointerArray<HBufC> mimeTypes;
       
    73 	CleanupResetAndDestroyPushL(mimeTypes);
       
    74 	mimeTypes.Append(KMimeType().AllocL());
       
    75 	
       
    76 	TRAP(err, scrSession.AddSoftwareTypeL(KSwTypeName, sifPluginUid, installerSecureId, executionLayerSecureId, mimeTypes));
       
    77 	CheckFailL(err, _L("AddSoftwareTypeL"));
       
    78 	CleanupStack::PopAndDestroy(&mimeTypes);
       
    79 	
       
    80 	// Then, delete the newly added sofwtare type. 
       
    81 	RPointerArray<HBufC> deletedMimeTypes;
       
    82 	CleanupResetAndDestroyPushL(deletedMimeTypes);
       
    83 	TRAP(err, scrSession.DeleteSoftwareTypeL(KSwTypeName,deletedMimeTypes));
       
    84 	CheckFailL(err, _L("DeleteSoftwareTypeL"));
       
    85 	CleanupStack::PopAndDestroy(&deletedMimeTypes); 
       
    86 		
       
    87 	TRAP_IGNORE(scrSession.CommitTransactionL());
       
    88 	CleanupStack::PopAndDestroy(&scrSession);
       
    89 	}