loggingservices/eventlogger/test/src/t_logsecureview.cpp
changeset 0 08ec8eefde2f
child 11 667e88a979d7
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "TEST.H"
       
    17 #include <logview.h>
       
    18 
       
    19 #undef test  //there is a "test" macro which hides "RTest test" declaration.
       
    20 
       
    21 #define PRECONDITION_TRUE(x) TEST((x))
       
    22 #define PRECONDITION_EQ(x,y) TEST2((x),(y))
       
    23 
       
    24 // If LOWCAP is defined in the .mmp file 'hiCapabilityTest' will be set to FALSE.
       
    25 #ifdef LOWCAP
       
    26 	TBool hiCapabilityTest = EFalse;
       
    27 	RTest test(_L("Log Client Low Capability Secure View Test"));
       
    28 	_LIT(KTestTitle, "t_logsecureview (low capability)");
       
    29 #else
       
    30 	TBool hiCapabilityTest = ETrue;
       
    31 	RTest test(_L("Log Client High Capability Secure View Test"));
       
    32 	_LIT(KTestTitle, "t_logsecureview (high capability)");
       
    33 #endif
       
    34 
       
    35 
       
    36 /**
       
    37 @SYMTestCaseID SYSLIB-LOGENG-CT-0135
       
    38 @SYMTestCaseDesc Ensures only a capable client can remove an event from a recent list
       
    39 @SYMTestActions See the description and expected results.
       
    40 @SYMTestPriority High
       
    41 @SYMTestExpectedResults Should always succeed
       
    42 @SYMREQ REQ3431
       
    43 */
       
    44 LOCAL_C void TestDuplicateRemoveIdL(CLogViewDuplicate* aView)
       
    45 	{
       
    46 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0135 "));
       
    47 	TLogId id = aView->Event().Id();
       
    48 	TRAPD(error, aView->RemoveL(id));
       
    49 	
       
    50 	if(hiCapabilityTest)
       
    51 		{
       
    52 		TEST2(error, KErrNone);
       
    53 		TEST2(aView->CountL(), 3);
       
    54 		}
       
    55 	else
       
    56 		{
       
    57 		TEST2(error, KErrPermissionDenied);
       
    58 		TEST2(aView->CountL(), 4);
       
    59 		}
       
    60 	}
       
    61 	
       
    62 /**
       
    63 @SYMTestCaseID SYSLIB-LOGENG-CT-0136
       
    64 @SYMTestCaseDesc Ensures only a capable client can remove an event from a recent list
       
    65 @SYMTestActions See the description and expected results.
       
    66 @SYMTestPriority High
       
    67 @SYMTestExpectedResults Should always succeed
       
    68 @SYMREQ REQ3431
       
    69 */
       
    70 LOCAL_C void TestDuplicateRemoveCurrentL(CLogViewDuplicate* aView, CTestActive* aTestActive)
       
    71 	{
       
    72 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0136 "));
       
    73 	aTestActive->StartL();
       
    74 	PRECONDITION_TRUE(aView->FirstL(aTestActive->iStatus));
       
    75 	CActiveScheduler::Start();
       
    76 	PRECONDITION_EQ(aTestActive->iStatus.Int(), KErrNone);
       
    77 
       
    78 	if(hiCapabilityTest)
       
    79 		{
       
    80 		aTestActive->StartL();
       
    81 		PRECONDITION_TRUE(aView->RemoveL(aTestActive->iStatus));
       
    82 		CActiveScheduler::Start();
       
    83 		PRECONDITION_EQ(aTestActive->iStatus.Int(), KErrNone);
       
    84 		
       
    85 		TEST2(aView->CountL(), 2);
       
    86 		}
       
    87 	else
       
    88 		{
       
    89 		TRAPD(error, aView->RemoveL(aTestActive->iStatus));
       
    90 	
       
    91 		TEST2(error, KErrPermissionDenied);
       
    92 		TEST2(aView->CountL(), 4);
       
    93 		}
       
    94 	}
       
    95 
       
    96 /**
       
    97 @SYMTestCaseID SYSLIB-LOGENG-CT-0137
       
    98 @SYMTestCaseDesc Ensures only a capable client can clear duplicate events from a recent list
       
    99 @SYMTestActions See the description and expected results.
       
   100 @SYMTestPriority High
       
   101 @SYMTestExpectedResults Should always succeed
       
   102 @SYMREQ REQ3431
       
   103 */
       
   104 LOCAL_C void TestRecentClearDuplicatesL(CLogViewRecent* aRecentView, CLogViewDuplicate* aDuplicateView)
       
   105 	{
       
   106 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0137 "));
       
   107 	TRAPD(error, aRecentView->ClearDuplicatesL());
       
   108 
       
   109 	if(hiCapabilityTest)
       
   110 		{
       
   111 		TEST2(error, KErrNone);
       
   112 		TEST2(aDuplicateView->CountL(), 0);
       
   113 		}
       
   114 	else
       
   115 		{
       
   116 		TEST2(error, KErrPermissionDenied);
       
   117 		TEST2(aDuplicateView->CountL(), 4);
       
   118 		}
       
   119 	}
       
   120 	
       
   121 /**
       
   122 @SYMTestCaseID SYSLIB-LOGENG-CT-0138
       
   123 @SYMTestCaseDesc Ensures only a capable client can remove an event from a duplicate list
       
   124 @SYMTestActions See the description and expected results.
       
   125 @SYMTestPriority High
       
   126 @SYMTestExpectedResults Should always succeed
       
   127 @SYMREQ REQ3431
       
   128 */
       
   129 LOCAL_C void TestRecentRemoveIdL(CLogViewRecent* aView)
       
   130 	{
       
   131 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0138 "));
       
   132 	TLogId id = aView->Event().Id();
       
   133 	TRAPD(error, aView->RemoveL(id));
       
   134 	
       
   135 	if(hiCapabilityTest)
       
   136 		{
       
   137 		TEST2(error, KErrNone);
       
   138 		TEST2(aView->CountL(), 1);
       
   139 		}
       
   140 	else
       
   141 		{
       
   142 		TEST2(error, KErrPermissionDenied);
       
   143 		TEST2(aView->CountL(), 2);
       
   144 		}
       
   145 	}
       
   146 
       
   147 /**
       
   148 @SYMTestCaseID SYSLIB-LOGENG-CT-0139
       
   149 @SYMTestCaseDesc Ensures only a capable client can remove an event from a duplicate list
       
   150 @SYMTestActions See the description and expected results.
       
   151 @SYMTestPriority High
       
   152 @SYMTestExpectedResults Should always succeed
       
   153 @SYMREQ REQ3431
       
   154 */
       
   155 LOCAL_C void TestRecentRemoveCurrentL(CLogViewRecent* aView, CTestActive* aTestActive)
       
   156 	{
       
   157 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0139 "));
       
   158 	aTestActive->StartL();
       
   159 	PRECONDITION_TRUE(aView->FirstL(aTestActive->iStatus));
       
   160 	CActiveScheduler::Start();
       
   161 	PRECONDITION_EQ(aTestActive->iStatus.Int(), KErrNone);
       
   162 
       
   163 	TRAPD(error, aView->RemoveL(aTestActive->iStatus));
       
   164 
       
   165 	if(hiCapabilityTest)
       
   166 		{
       
   167 		TEST2(error, KErrNone);
       
   168 		TEST2(aView->CountL(), 0);
       
   169 		}
       
   170 	else
       
   171 		{
       
   172 		TEST2(error, KErrPermissionDenied);
       
   173 		TEST2(aView->CountL(), 2);
       
   174 		}
       
   175 	}
       
   176 	
       
   177 LOCAL_C void TestViewsL()
       
   178 	{
       
   179 	CLogClient* client = CLogClient::NewL(theFs);
       
   180 	CleanupStack::PushL(client);
       
   181 
       
   182 	CTestActive* testActive = new(ELeave)CTestActive();
       
   183 	CleanupStack::PushL(testActive);
       
   184 
       
   185 	CLogViewRecent* recentView = CLogViewRecent::NewL(*client);
       
   186 	CleanupStack::PushL(recentView);
       
   187 
       
   188 	testActive->StartL();
       
   189 	PRECONDITION_TRUE(recentView->SetRecentListL(KLogRecentIncomingCalls, testActive->iStatus));
       
   190 	CActiveScheduler::Start();
       
   191 	PRECONDITION_EQ(testActive->iStatus.Int(), KErrNone);
       
   192 	PRECONDITION_EQ(recentView->CountL(), 2);
       
   193 
       
   194 	CLogViewDuplicate* duplicateView = CLogViewDuplicate::NewL(*client);
       
   195 	CleanupStack::PushL(duplicateView);
       
   196 
       
   197 	testActive->StartL();
       
   198 	PRECONDITION_TRUE(recentView->DuplicatesL(*duplicateView, testActive->iStatus));
       
   199 	CActiveScheduler::Start();
       
   200 	PRECONDITION_EQ(testActive->iStatus.Int(), KErrNone);
       
   201 	PRECONDITION_EQ(duplicateView->CountL(), 4);
       
   202 	
       
   203 	test.Start(_L("RemoveL on duplicate view with id as argument"));
       
   204 	TestDuplicateRemoveIdL(duplicateView);
       
   205 
       
   206 	test.Next(_L("RemoveL on duplicate view at current cursor position"));
       
   207 	TestDuplicateRemoveCurrentL(duplicateView, testActive);
       
   208 
       
   209 	test.Next(_L("ClearDuplicatesL on recent view"));
       
   210 	TestRecentClearDuplicatesL(recentView, duplicateView);
       
   211 
       
   212 	test.Next(_L("RemoveL on recent view with id as argument"));
       
   213 	TestRecentRemoveIdL(recentView);
       
   214 	
       
   215 	test.Next(_L("RemoveL on recent view at current cursor position"));
       
   216 	TestRecentRemoveCurrentL(recentView, testActive);
       
   217 
       
   218 	CleanupStack::PopAndDestroy(4);
       
   219 	}
       
   220 
       
   221 //.............................................................................
       
   222 
       
   223 void doTestsL()
       
   224 	{
       
   225 	TestUtils::Initialize(KTestTitle);
       
   226 	TestUtils::DeleteDatabaseL();
       
   227 	TestUtils::AddViewTestEventsL();
       
   228 
       
   229 	TestViewsL();
       
   230 
       
   231 	TestUtils::DeleteDatabaseL();
       
   232 	}