localisation/apparchitecture/tef/T_Capability1.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // The following test case is used to test whether apparctestserver has the capability
       
    15 // to access writable apis
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalComponent - Internal Symbian test code
       
    24 */
       
    25 
       
    26 #include "T_Capability1.h"
       
    27 #include "tstapp.h"
       
    28 #include "testableapalssession.h"
       
    29 #include <appfwk_test.h>
       
    30 
       
    31 /**
       
    32    @SYMTestCaseID		APPFWK-APPARC-0030
       
    33   
       
    34    @SYMPREQ			Policing server apis		
       
    35   
       
    36    @SYMTestCaseDesc 	Testing whether apparctestserver has the capability to access writable apis
       
    37   
       
    38    @SYMTestPriority 	High
       
    39   
       
    40    @SYMTestStatus 		Implemented
       
    41    
       
    42    @SYMTestActions  
       
    43    To connect to RApaLsSession and to check whether uiktestserver process
       
    44    has the permission to access the mentioned apis
       
    45    API Calls:\n	
       
    46    RApaLsSession::Connect();
       
    47    RApaLsSession::SetAcceptedConfidence(TInt aConfidence);
       
    48    RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid);
       
    49    RApaLsSession::InsertDataMappingIfHigher(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid, TBool& aInserted);
       
    50    RApaLsSession::DeleteDataMapping(const TDataType& aDataType);
       
    51    
       
    52    @SYMTestExpectedResults Test should complete without any panic.
       
    53   
       
    54  */
       
    55 void CT_Capability1::ExecuteL(RApaLsSession& aLs)
       
    56 	{
       
    57 	TInt ret;
       
    58 	TInt temp=1234;
       
    59 	TBool added=EFalse;
       
    60 	_LIT8(KLitPlainText,"text/plain");
       
    61 	const TDataTypePriority KPriLow = 1;
       
    62 	const TDataTypePriority KPriHigh = 2;
       
    63 	
       
    64 
       
    65 	TSecurityInfo info;
       
    66 	info.Set(RProcess());
       
    67 	
       
    68 	APPFWK_NEGATIVE_PLATSEC_START;
       
    69 	ret=aLs.SetAcceptedConfidence(temp);
       
    70 	APPFWK_NEGATIVE_PLATSEC_FINISH;
       
    71 	INFO_PRINTF1(_L("Capability check of SetAcceptedConfidence"));
       
    72 	INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrPermissionDenied, ret);
       
    73 	TEST(ret==KErrPermissionDenied);
       
    74 
       
    75 	APPFWK_NEGATIVE_PLATSEC_START;
       
    76 	ret=aLs.InsertDataMapping(TDataType(KLitPlainText), KPriLow, KUidTestApp);
       
    77 	APPFWK_NEGATIVE_PLATSEC_FINISH;
       
    78 	INFO_PRINTF1(_L("Capability check of InsertDataMapping"));
       
    79 	INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrPermissionDenied, ret);
       
    80 	TEST(ret==KErrPermissionDenied);
       
    81 
       
    82 	APPFWK_NEGATIVE_PLATSEC_START;
       
    83 	ret=aLs.InsertDataMappingIfHigher(TDataType(KLitPlainText), KPriHigh, KUidTestApp, added);
       
    84 	APPFWK_NEGATIVE_PLATSEC_FINISH;
       
    85 	INFO_PRINTF1(_L("Capability check of InsertDataMappingIfHigher"));
       
    86 	INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrPermissionDenied, ret);
       
    87 	TEST(ret==KErrPermissionDenied);
       
    88 
       
    89 	APPFWK_NEGATIVE_PLATSEC_START;
       
    90 	ret=aLs.DeleteDataMapping(TDataType(KLitPlainText));
       
    91 	APPFWK_NEGATIVE_PLATSEC_FINISH;
       
    92 	INFO_PRINTF1(_L("Capability check of DeleteDataMapping"));
       
    93 	INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrPermissionDenied, ret);
       
    94 	TEST(ret==KErrPermissionDenied);
       
    95 
       
    96 
       
    97 	}
       
    98 
       
    99 CT_Capability1::CT_Capability1()
       
   100 /**
       
   101    Constructor
       
   102  */
       
   103 	{
       
   104 	// Call base class method to set up the human readable name for logging
       
   105 	SetTestStepName(KT_Capability1);
       
   106 	}
       
   107 
       
   108 CT_Capability1::~CT_Capability1()
       
   109 	{
       
   110 	}
       
   111 
       
   112 TVerdict CT_Capability1::doTestStepL()
       
   113     {
       
   114 	INFO_PRINTF1(_L("APPFWK-APPARC-0030: Capability1 - Started"));
       
   115 	
       
   116 	RTestableApaLsSession apaLsSession;
       
   117 	TEST(apaLsSession.Connect()==KErrNone);
       
   118 	CleanupClosePushL(apaLsSession);
       
   119 	
       
   120 	HEAP_TEST_LS_SESSION(apaLsSession, 0, 0, ExecuteL(apaLsSession), NO_CLEANUP);
       
   121 	
       
   122 
       
   123 	CleanupStack::PopAndDestroy(&apaLsSession);
       
   124 
       
   125 	INFO_PRINTF1(_L("APPFWK-APPARC-0030: Capability1 - Finished"));
       
   126 
       
   127 	return TestStepResult();
       
   128 	}