1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/test/src/t_logsecureview.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,230 @@
1.4 +// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "t_logutil2.h"
1.20 +#include <logview.h>
1.21 +
1.22 +#define PRECONDITION_TRUE(x) TEST((x))
1.23 +#define PRECONDITION_EQ(x,y) TEST2((x),(y))
1.24 +
1.25 +// If LOWCAP is defined in the .mmp file 'hiCapabilityTest' will be set to FALSE.
1.26 +#ifdef LOWCAP
1.27 + TBool hiCapabilityTest = EFalse;
1.28 + RTest TheTest(_L("t_logsecureview_lowcap"));
1.29 + _LIT(KTestTitle, "t_logsecureview (low capability)");
1.30 +#else
1.31 + TBool hiCapabilityTest = ETrue;
1.32 + RTest TheTest(_L("t_logsecureview_hicap"));
1.33 + _LIT(KTestTitle, "t_logsecureview (high capability)");
1.34 +#endif
1.35 +
1.36 +
1.37 +/**
1.38 +@SYMTestCaseID SYSLIB-LOGENG-CT-0135
1.39 +@SYMTestCaseDesc Ensures only a capable client can remove an event from a recent list
1.40 +@SYMTestActions See the description and expected results.
1.41 +@SYMTestPriority High
1.42 +@SYMTestExpectedResults Should always succeed
1.43 +@SYMREQ REQ3431
1.44 +*/
1.45 +LOCAL_C void TestDuplicateRemoveIdL(CLogViewDuplicate* aView)
1.46 + {
1.47 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0135 "));
1.48 + TLogId id = aView->Event().Id();
1.49 + TRAPD(error, aView->RemoveL(id));
1.50 +
1.51 + if(hiCapabilityTest)
1.52 + {
1.53 + TEST2(error, KErrNone);
1.54 + TEST2(aView->CountL(), 3);
1.55 + }
1.56 + else
1.57 + {
1.58 + TEST2(error, KErrPermissionDenied);
1.59 + TEST2(aView->CountL(), 4);
1.60 + }
1.61 + }
1.62 +
1.63 +/**
1.64 +@SYMTestCaseID SYSLIB-LOGENG-CT-0136
1.65 +@SYMTestCaseDesc Ensures only a capable client can remove an event from a recent list
1.66 +@SYMTestActions See the description and expected results.
1.67 +@SYMTestPriority High
1.68 +@SYMTestExpectedResults Should always succeed
1.69 +@SYMREQ REQ3431
1.70 +*/
1.71 +LOCAL_C void TestDuplicateRemoveCurrentL(CLogViewDuplicate* aView, CTestActive* aTestActive)
1.72 + {
1.73 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0136 "));
1.74 + aTestActive->StartL();
1.75 + PRECONDITION_TRUE(aView->FirstL(aTestActive->iStatus));
1.76 + CActiveScheduler::Start();
1.77 + PRECONDITION_EQ(aTestActive->iStatus.Int(), KErrNone);
1.78 +
1.79 + if(hiCapabilityTest)
1.80 + {
1.81 + aTestActive->StartL();
1.82 + PRECONDITION_TRUE(aView->RemoveL(aTestActive->iStatus));
1.83 + CActiveScheduler::Start();
1.84 + PRECONDITION_EQ(aTestActive->iStatus.Int(), KErrNone);
1.85 +
1.86 + TEST2(aView->CountL(), 2);
1.87 + }
1.88 + else
1.89 + {
1.90 + TRAPD(error, aView->RemoveL(aTestActive->iStatus));
1.91 +
1.92 + TEST2(error, KErrPermissionDenied);
1.93 + TEST2(aView->CountL(), 4);
1.94 + }
1.95 + }
1.96 +
1.97 +/**
1.98 +@SYMTestCaseID SYSLIB-LOGENG-CT-0137
1.99 +@SYMTestCaseDesc Ensures only a capable client can clear duplicate events from a recent list
1.100 +@SYMTestActions See the description and expected results.
1.101 +@SYMTestPriority High
1.102 +@SYMTestExpectedResults Should always succeed
1.103 +@SYMREQ REQ3431
1.104 +*/
1.105 +LOCAL_C void TestRecentClearDuplicatesL(CLogViewRecent* aRecentView, CLogViewDuplicate* aDuplicateView)
1.106 + {
1.107 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0137 "));
1.108 + TRAPD(error, aRecentView->ClearDuplicatesL());
1.109 +
1.110 + if(hiCapabilityTest)
1.111 + {
1.112 + TEST2(error, KErrNone);
1.113 + TEST2(aDuplicateView->CountL(), 0);
1.114 + }
1.115 + else
1.116 + {
1.117 + TEST2(error, KErrPermissionDenied);
1.118 + TEST2(aDuplicateView->CountL(), 4);
1.119 + }
1.120 + }
1.121 +
1.122 +/**
1.123 +@SYMTestCaseID SYSLIB-LOGENG-CT-0138
1.124 +@SYMTestCaseDesc Ensures only a capable client can remove an event from a duplicate list
1.125 +@SYMTestActions See the description and expected results.
1.126 +@SYMTestPriority High
1.127 +@SYMTestExpectedResults Should always succeed
1.128 +@SYMREQ REQ3431
1.129 +*/
1.130 +LOCAL_C void TestRecentRemoveIdL(CLogViewRecent* aView)
1.131 + {
1.132 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0138 "));
1.133 + TLogId id = aView->Event().Id();
1.134 + TRAPD(error, aView->RemoveL(id));
1.135 +
1.136 + if(hiCapabilityTest)
1.137 + {
1.138 + TEST2(error, KErrNone);
1.139 + TEST2(aView->CountL(), 1);
1.140 + }
1.141 + else
1.142 + {
1.143 + TEST2(error, KErrPermissionDenied);
1.144 + TEST2(aView->CountL(), 2);
1.145 + }
1.146 + }
1.147 +
1.148 +/**
1.149 +@SYMTestCaseID SYSLIB-LOGENG-CT-0139
1.150 +@SYMTestCaseDesc Ensures only a capable client can remove an event from a duplicate list
1.151 +@SYMTestActions See the description and expected results.
1.152 +@SYMTestPriority High
1.153 +@SYMTestExpectedResults Should always succeed
1.154 +@SYMREQ REQ3431
1.155 +*/
1.156 +LOCAL_C void TestRecentRemoveCurrentL(CLogViewRecent* aView, CTestActive* aTestActive)
1.157 + {
1.158 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0139 "));
1.159 + aTestActive->StartL();
1.160 + PRECONDITION_TRUE(aView->FirstL(aTestActive->iStatus));
1.161 + CActiveScheduler::Start();
1.162 + PRECONDITION_EQ(aTestActive->iStatus.Int(), KErrNone);
1.163 +
1.164 + TRAPD(error, aView->RemoveL(aTestActive->iStatus));
1.165 +
1.166 + if(hiCapabilityTest)
1.167 + {
1.168 + TEST2(error, KErrNone);
1.169 + TEST2(aView->CountL(), 0);
1.170 + }
1.171 + else
1.172 + {
1.173 + TEST2(error, KErrPermissionDenied);
1.174 + TEST2(aView->CountL(), 2);
1.175 + }
1.176 + }
1.177 +
1.178 +LOCAL_C void TestViewsL()
1.179 + {
1.180 + CLogClient* client = CLogClient::NewL(theFs);
1.181 + CleanupStack::PushL(client);
1.182 +
1.183 + CTestActive* testActive = new(ELeave)CTestActive();
1.184 + CleanupStack::PushL(testActive);
1.185 +
1.186 + CLogViewRecent* recentView = CLogViewRecent::NewL(*client);
1.187 + CleanupStack::PushL(recentView);
1.188 +
1.189 + testActive->StartL();
1.190 + PRECONDITION_TRUE(recentView->SetRecentListL(KLogRecentIncomingCalls, testActive->iStatus));
1.191 + CActiveScheduler::Start();
1.192 + PRECONDITION_EQ(testActive->iStatus.Int(), KErrNone);
1.193 + PRECONDITION_EQ(recentView->CountL(), 2);
1.194 +
1.195 + CLogViewDuplicate* duplicateView = CLogViewDuplicate::NewL(*client);
1.196 + CleanupStack::PushL(duplicateView);
1.197 +
1.198 + testActive->StartL();
1.199 + PRECONDITION_TRUE(recentView->DuplicatesL(*duplicateView, testActive->iStatus));
1.200 + CActiveScheduler::Start();
1.201 + PRECONDITION_EQ(testActive->iStatus.Int(), KErrNone);
1.202 + PRECONDITION_EQ(duplicateView->CountL(), 4);
1.203 +
1.204 + TheTest.Start(_L("RemoveL on duplicate view with id as argument"));
1.205 + TestDuplicateRemoveIdL(duplicateView);
1.206 +
1.207 + TheTest.Next(_L("RemoveL on duplicate view at current cursor position"));
1.208 + TestDuplicateRemoveCurrentL(duplicateView, testActive);
1.209 +
1.210 + TheTest.Next(_L("ClearDuplicatesL on recent view"));
1.211 + TestRecentClearDuplicatesL(recentView, duplicateView);
1.212 +
1.213 + TheTest.Next(_L("RemoveL on recent view with id as argument"));
1.214 + TestRecentRemoveIdL(recentView);
1.215 +
1.216 + TheTest.Next(_L("RemoveL on recent view at current cursor position"));
1.217 + TestRecentRemoveCurrentL(recentView, testActive);
1.218 +
1.219 + CleanupStack::PopAndDestroy(4);
1.220 + }
1.221 +
1.222 +//.............................................................................
1.223 +
1.224 +void doTestsL()
1.225 + {
1.226 + TestUtils::Initialize(KTestTitle);
1.227 + TestUtils::DeleteDatabaseL();
1.228 + TestUtils::AddViewTestEventsL();
1.229 +
1.230 + TestViewsL();
1.231 +
1.232 + TestUtils::DeleteDatabaseL();
1.233 + }