installationservices/swinstallationfw/test/securitytests/source/scrnonrestricted.cpp
changeset 24 84a16765cd86
child 25 98b66e4fb0be
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 "scrnonrestricted.h"
       
    25 
       
    26 #include <usif/scr/scr.h>
       
    27 #include <scs/cleanuputils.h>
       
    28 #include <e32def.h>
       
    29 
       
    30 _LIT(KScrNonRestrictedSecName, "SCR non-restricted APIs test");
       
    31 
       
    32 using namespace Usif;
       
    33 
       
    34 CScrNonRestrictedSecTest* CScrNonRestrictedSecTest::NewL()
       
    35 	{
       
    36 	CScrNonRestrictedSecTest* self=new(ELeave) CScrNonRestrictedSecTest();
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop(self);
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 CScrNonRestrictedSecTest::CScrNonRestrictedSecTest()
       
    44 	{
       
    45 	}
       
    46 	
       
    47 void CScrNonRestrictedSecTest::ConstructL()
       
    48 	{
       
    49 	SetNameL(KScrNonRestrictedSecName);
       
    50 	}
       
    51 
       
    52 _LIT(KFileName, "c:\test.fil");
       
    53 _LIT(KPropertyName, "DummyProperty");
       
    54 
       
    55 void CScrNonRestrictedSecTest::RunTestL()
       
    56 	{
       
    57 
       
    58 	// Throughout the tests we assume that at least one component is present, i.e. that component id 1 is valid
       
    59 	const TComponentId KExistingComponentId = 1;	
       
    60 	
       
    61 	RSoftwareComponentRegistry scrSession;
       
    62 	User::LeaveIfError(scrSession.Connect());
       
    63 	CleanupClosePushL(scrSession);
       
    64 	
       
    65 	TInt err(0);
       
    66 	
       
    67 	// Check component query APIs
       
    68 	
       
    69 	CComponentEntry* entry = CComponentEntry::NewLC();
       
    70 	TRAP(err, scrSession.GetComponentL(KExistingComponentId, *entry));
       
    71 	CheckFailL(err, _L("GetComponent"));
       
    72 	CleanupStack::PopAndDestroy(entry);
       
    73 
       
    74 	RArray<TComponentId> componentIds;
       
    75 	TRAP(err, scrSession.GetComponentsL(KFileName, componentIds));
       
    76 	CleanupClosePushL(componentIds);
       
    77 	CheckFailL(err, _L("GetComponentsL"));
       
    78 	CleanupStack::PopAndDestroy(&componentIds);	
       
    79 	
       
    80 	RPointerArray<CPropertyEntry> properties;
       
    81 	CleanupResetAndDestroyPushL(properties);
       
    82 	TRAP(err, scrSession.GetFilePropertiesL(KExistingComponentId, KFileName, properties));
       
    83 	CheckFailL(err, _L("GetFilePropertiesL"));
       
    84 	CleanupStack::PopAndDestroy(&properties);
       
    85 	
       
    86 	CPropertyEntry* propertyEntry(NULL);
       
    87 	TRAP(err, propertyEntry = scrSession.GetFilePropertyL(KExistingComponentId, KFileName, KPropertyName));
       
    88 	CleanupStack::PushL(propertyEntry);
       
    89 	CheckFailL(err, _L("GetFilePropertyL"));
       
    90 	CleanupStack::PopAndDestroy(propertyEntry);
       
    91 	
       
    92 	propertyEntry = NULL;
       
    93 	TRAP(err, propertyEntry = scrSession.GetComponentPropertyL(KExistingComponentId, KPropertyName));
       
    94 	CleanupStack::PushL(propertyEntry);
       
    95 	CheckFailL(err, _L("GetComponentPropertyL"));
       
    96 	CleanupStack::PopAndDestroy(propertyEntry);
       
    97 	
       
    98 	propertyEntry = NULL;
       
    99 	TRAP(err, propertyEntry = scrSession.GetComponentPropertyL(KExistingComponentId, KPropertyName, ELangEnglish));
       
   100 	CleanupStack::PushL(propertyEntry);
       
   101 	CheckFailL(err, _L("GetComponentPropertyL - localised"));
       
   102 	CleanupStack::PopAndDestroy(propertyEntry);	
       
   103 	
       
   104 	TRAP(err, scrSession.GetComponentPropertiesL(KExistingComponentId, properties));
       
   105 	CleanupResetAndDestroyPushL(properties);
       
   106 	CheckFailL(err, _L("GetFilePropertiesL"));
       
   107 	CleanupStack::PopAndDestroy(&properties);
       
   108 	
       
   109 	TRAP(err, scrSession.GetComponentPropertiesL(KExistingComponentId, properties, ELangEnglish));
       
   110 	CleanupResetAndDestroyPushL(properties);
       
   111 	CheckFailL(err, _L("GetFilePropertiesL - localised"));
       
   112 	CleanupStack::PopAndDestroy(&properties);
       
   113 	
       
   114 	TRAP(err, scrSession.GetComponentFilesCountL(KExistingComponentId));
       
   115 	CheckFailL(err, _L("GetComponentFilesCountL"));
       
   116 	
       
   117 	entry = NULL;
       
   118 	TRAP(err, entry = scrSession.GetComponentL(_L("GlobalId"), _L("dummy")));
       
   119 	CheckFailL(err, _L("GetComponentL - global id"));
       
   120 	if(entry)
       
   121 		delete entry;
       
   122 	
       
   123 	TRAP(err, scrSession.GetComponentIdL(_L("GlobalId"), _L("dummy")));
       
   124 	CheckFailL(err, _L("GetComponentIdL"));
       
   125 	
       
   126 	RPointerArray<CVersionedComponentId> globalIdList;
       
   127 	CGlobalComponentId *dependantGlobalId = CGlobalComponentId::NewLC(_L("DependantGlobalId"), _L("dummy"));
       
   128 	TRAP(err, scrSession.GetSupplierComponentsL(*dependantGlobalId, globalIdList));
       
   129 	CheckFailL(err, _L("GetSupplierComponentsL"));
       
   130 	CleanupStack::PopAndDestroy(dependantGlobalId);
       
   131 	globalIdList.Reset();
       
   132 	
       
   133 	CGlobalComponentId *supplierGlobalId = CGlobalComponentId::NewLC(_L("SupplierGlobalId"), _L("dummy"));
       
   134 	TRAP(err, scrSession.GetDependantComponentsL(*supplierGlobalId, globalIdList));
       
   135 	CheckFailL(err, _L("GetDependantComponentsL"));
       
   136 	CleanupStack::PopAndDestroy(supplierGlobalId);
       
   137 	globalIdList.ResetAndDestroy();
       
   138 	
       
   139 	// Check application manager APIs
       
   140 	
       
   141 	TRAP(err, scrSession.IsMediaPresentL(1));
       
   142 	CheckFailL(err, _L("IsMediaPresentL"));
       
   143 	
       
   144 	TRAP(err, scrSession.IsComponentOrphanedL(KExistingComponentId));
       
   145 	CheckFailL(err, _L("IsComponentOrphanedL"));
       
   146 	
       
   147 	TRAP(err, scrSession.CompareVersionsL(_L("1.2"), _L("3.2")));
       
   148 	CheckFailL(err, _L("CompareVersionsL"));
       
   149 
       
   150 	TRAP(err, scrSession.IsComponentOnReadOnlyDriveL(KExistingComponentId));
       
   151 	CheckFailL(err, _L("IsComponentOnReadOnlyDriveL"));
       
   152 	
       
   153 	TRAP(err, scrSession.IsComponentPresentL(KExistingComponentId));
       
   154 	CheckFailL(err, _L("IsComponentPresentL"));
       
   155 		
       
   156 	// Check sub-session APIs
       
   157 	RSoftwareComponentRegistryFilesList compFilesListView;
       
   158 	TRAP(err, compFilesListView.OpenListL(scrSession, KExistingComponentId));
       
   159 	CheckFailL(err, _L("RSoftwareComponentRegistryFilesList::OpenListL"));
       
   160 	CleanupClosePushL(compFilesListView);
       
   161 
       
   162 	TRAP(err, compFilesListView.NextFileL());
       
   163 	CheckFailL(err, _L("RSoftwareComponentRegistryFilesList::NextFileL"));
       
   164 	
       
   165 	CleanupStack::PopAndDestroy(&compFilesListView);
       
   166 	
       
   167 	CleanupStack::PopAndDestroy(&scrSession);
       
   168 	}
       
   169