installationservices/swinstallationfw/test/securitytests/source/scrreaduserdata.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
child 27 e8965914fac7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     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 "scrreaduserdata.h"
       
    25 #include <scs/cleanuputils.h>
       
    26 #include <usif/scr/scr.h>
       
    27 #include <e32def.h>
       
    28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    29 #include "screntries_internal.h"
       
    30 #endif
       
    31 
       
    32 _LIT(KScrReadUserDataSecName, "SCR ReadUserData APIs test");
       
    33 
       
    34 using namespace Usif;
       
    35 
       
    36 CScrReadUserDataSecTest* CScrReadUserDataSecTest::NewL()
       
    37 	{
       
    38 	CScrReadUserDataSecTest* self=new(ELeave) CScrReadUserDataSecTest();
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL();
       
    41 	CleanupStack::Pop(self);
       
    42 	return self;
       
    43 	}
       
    44 
       
    45 CScrReadUserDataSecTest::CScrReadUserDataSecTest()
       
    46 	{
       
    47 	SetCapabilityRequired(ECapabilityReadUserData);
       
    48 	}
       
    49 	
       
    50 void CScrReadUserDataSecTest::ConstructL()
       
    51 	{
       
    52 	SetNameL(KScrReadUserDataSecName);
       
    53 	}
       
    54 
       
    55 void CScrReadUserDataSecTest::RunTestL()
       
    56 	{
       
    57 	RSoftwareComponentRegistry scrSession;
       
    58 	User::LeaveIfError(scrSession.Connect());
       
    59 	CleanupClosePushL(scrSession);
       
    60 
       
    61 	TInt err(0);
       
    62 	TComponentId testComponentId(1);
       
    63 	// Check subsession APIs
       
    64 	CComponentFilter* componentFilter = CComponentFilter::NewLC();
       
    65 
       
    66 	RSoftwareComponentRegistryView compRegistryView;
       
    67 	TRAP(err, compRegistryView.OpenViewL(scrSession, componentFilter));
       
    68 	CheckFailL(err, _L("CComponentFilter::OpenViewL"));
       
    69 	if (err == KErrNone)
       
    70 		{
       
    71 		// In a negative test, we should fail opening a sub-session. In this case we cannot continue with NextComponentL
       
    72 		TRAP(err, compRegistryView.NextComponentL());
       
    73 		CheckFailL(err, _L("CComponentFilter::NextComponentL"));		
       
    74 		compRegistryView.Close();
       
    75 		}
       
    76 
       
    77 	RArray<TComponentId> componentIds;
       
    78 	TRAP(err, scrSession.GetComponentIdsL(componentIds));
       
    79 	if(KErrNone==err && componentIds.Count()!=0)
       
    80 	    testComponentId=componentIds[0];       //The testComponentId retrieved, is used in the subsequent tests to get its localized information
       
    81 	CleanupClosePushL(componentIds);
       
    82 	CheckFailL(err, _L("RSoftwareComponentRegistry::GetComponentIdsL"));
       
    83 
       
    84 	RPointerArray<Usif::CLocalizableComponentInfo> compLocalizedInfoArray;
       
    85 	CleanupResetAndDestroyPushL(compLocalizedInfoArray);
       
    86 	TRAP(err, scrSession.GetComponentLocalizedInfoL(testComponentId, compLocalizedInfoArray));
       
    87 	CheckFailL(err, _L("RSoftwareComponentRegistry::GetComponentLocalizedInfoL"));
       
    88 	CleanupStack::Pop(&compLocalizedInfoArray);
       
    89 	compLocalizedInfoArray.ResetAndDestroy();
       
    90 	
       
    91 	
       
    92 	RArray<TLanguage> matchingSupportedLanguages;
       
    93 	CleanupClosePushL(matchingSupportedLanguages);
       
    94 	TRAP(err, scrSession.GetComponentSupportedLocalesListL(testComponentId, matchingSupportedLanguages));
       
    95 	CheckFailL(err, _L("RSoftwareComponentRegistry::GetComponentSupportedLocalesListL"));
       
    96     CleanupStack::PopAndDestroy(&matchingSupportedLanguages);
       
    97 	
       
    98 	RPointerArray<CScrLogEntry> logEntries;
       
    99 	TRAP(err, scrSession.RetrieveLogEntriesL(logEntries));
       
   100 	logEntries.ResetAndDestroy();
       
   101 	CheckFailL(err, _L("RSoftwareComponentRegistry::RetrieveLogEntriesL"));
       
   102 		
       
   103 	CleanupStack::PopAndDestroy(2, componentFilter); // componentIds,  componentFilter  
       
   104 
       
   105 	CleanupStack::PopAndDestroy(&scrSession);
       
   106 	}