1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/test/src/t_logcompat.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,691 @@
1.4 +// Copyright (c) 2009-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 +// t_logcompat.cpp - verification that old databases without SimId column in Event table can be opened
1.18 +// and events added, viewed, etc.
1.19 +//
1.20 +//
1.21 +#include <s32file.h>
1.22 +#include <s32mem.h>
1.23 +#include <e32math.h>
1.24 +#include <bautils.h>
1.25 +#include <logview.h>
1.26 +#include "t_logutil2.h"
1.27 +
1.28 +RTest TheTest(_L("t_logcompat"));
1.29 +
1.30 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.31 +
1.32 +// These values are stored in "oldLogdb.dat"
1.33 +_LIT(KEventNum1, "00000");
1.34 +_LIT(KEventNum2, "11111");
1.35 +_LIT(KEventNum3, "22222");
1.36 +_LIT(KEventNum4, "012345678901234567");
1.37 +const TLogId KEventId1 = 0;
1.38 +const TLogId KEventId2 = 1;
1.39 +const TLogId KEventId3 = 2;
1.40 +const TLogId KEventId4 = 3;
1.41 +
1.42 +//New events, added by this test
1.43 +_LIT(KEventNum5, "123411119");
1.44 +_LIT(KEventNum6, "999911221");
1.45 +TLogId TheEventId5 = KLogNullId;
1.46 +TLogId TheEventId6 = KLogNullId;
1.47 +
1.48 +//Stored events properties
1.49 +_LIT(KTestEventDesc1, "Event Type Description");
1.50 +_LIT(KTestRemoteParty1, "Remote Party");
1.51 +_LIT(KTestDirection1, "Direction");
1.52 +_LIT(KTestStatus1, "Status");
1.53 +_LIT(KTestSubject1, "Subject");
1.54 +const TUid KTestEventUid = {0x10005393};
1.55 +const TLogDurationType KTestDurationType1 = 1;
1.56 +const TLogDuration KTestDuration1 = 0x1234;
1.57 +const TLogContactItemId KTestContact1 = 0x1234;
1.58 +const TLogLink KTestLink1 = 0x1234;
1.59 +_LIT8(KTestData1, "ABCDEFGH");
1.60 +const TLogFlags KTestFlags1 = 0x5;
1.61 +
1.62 +//Sim Ids used by the test
1.63 +const TSimId KSimId1 = 1;
1.64 +const TSimId KSimId3 = 3900100200U;
1.65 +
1.66 +void CheckEventProperties(CLogEvent& aEvent, TLogId aEventId, const TDesC& aEventNumber, TSimId aSimId)
1.67 + {
1.68 + TEST(aEvent.Id() == aEventId);
1.69 + TEST(aEvent.Time() > TTime(0));
1.70 + TEST(aEvent.Description() == KTestEventDesc1);
1.71 + TEST(aEvent.EventType() == KTestEventUid);
1.72 + TEST(aEvent.RemoteParty() == KTestRemoteParty1);
1.73 + TEST(aEvent.Direction() == KTestDirection1);
1.74 + TEST(aEvent.DurationType() == KTestDurationType1);
1.75 + TEST(aEvent.Duration() == KTestDuration1);
1.76 + TEST(aEvent.Status() == KTestStatus1);
1.77 + TEST(aEvent.Subject() == KTestSubject1);
1.78 + TEST(aEvent.Contact() == KTestContact1);
1.79 + TEST(aEvent.Link() == KTestLink1);
1.80 + TEST(aEvent.Data() == KTestData1);
1.81 + TEST(aEvent.Flags() == KTestFlags1);
1.82 + TEST(aEvent.Number() == aEventNumber);
1.83 + TEST(aEvent.SimId() == aSimId);
1.84 + TPtrC eventStatus = aEvent.Subject();
1.85 + TPtrC eventNumber = aEvent.Number();
1.86 + TheTest.Printf(_L("Id:%d No:%S Sub:%S Contact Id:0x%x SimId:%u\n"), aEvent.Id(), &eventNumber, &eventStatus, aEvent.Contact(), aEvent.SimId());
1.87 + }
1.88 +
1.89 +void DoGetEventTestL(TLogId aEventId, const TDesC& aEventNumber, TSimId aSimId, CTestActive& aActive, CLogClient& aLogClient)
1.90 + {
1.91 + CLogEvent* event = CLogEvent::NewL();
1.92 + CleanupStack::PushL(event);
1.93 +
1.94 + // set the id of the event to be fetched
1.95 + event->SetId(aEventId);
1.96 +
1.97 + aActive.StartL();
1.98 + aLogClient.GetEvent(*event, aActive.iStatus);
1.99 + CActiveScheduler::Start();
1.100 + TEST2(aActive.iStatus.Int(), KErrNone);
1.101 +
1.102 + CheckEventProperties(*event, aEventId, aEventNumber, aSimId);
1.103 +
1.104 + CleanupStack::PopAndDestroy(event);
1.105 + }
1.106 +
1.107 +void DoChangeEventTestL(TLogId aEventId, const TDesC& aEventNumber, TSimId aSimId, CTestActive& aActive, CLogClient& aLogClient)
1.108 + {
1.109 + CLogEvent* event = CLogEvent::NewL();
1.110 + CleanupStack::PushL(event);
1.111 +
1.112 + //Retrieve the event.
1.113 + event->SetId(aEventId);
1.114 + aActive.StartL();
1.115 + aLogClient.GetEvent(*event, aActive.iStatus);
1.116 + CActiveScheduler::Start();
1.117 + TEST2(aActive.iStatus.Int(), KErrNone);
1.118 + CheckEventProperties(*event, aEventId, aEventNumber, KLogNullSimId);
1.119 + //Change event's SimId.
1.120 + event->SetSimId(aSimId);
1.121 + aActive.StartL();
1.122 + aLogClient.ChangeEvent(*event, aActive.iStatus);
1.123 + CActiveScheduler::Start();
1.124 + TEST2(aActive.iStatus.Int(), KErrNone);
1.125 + CheckEventProperties(*event, aEventId, aEventNumber, aSimId);
1.126 +
1.127 + CleanupStack::PopAndDestroy(event);
1.128 + }
1.129 +
1.130 +TInt DoAddEventTestL(const TDesC& aEventNumber, TSimId aSimId, CTestActive& aActive, CLogClient& aLogClient)
1.131 + {
1.132 + CLogEvent* event = CLogEvent::NewL();
1.133 + CleanupStack::PushL(event);
1.134 +
1.135 + TTime now;
1.136 + now.UniversalTime();
1.137 +
1.138 + event->SetEventType(KTestEventUid);
1.139 + event->SetRemoteParty(KTestRemoteParty1);
1.140 + event->SetDirection(KTestDirection1);
1.141 + event->SetDurationType(KTestDurationType1);
1.142 + event->SetDuration(KTestDuration1);
1.143 + event->SetStatus(KTestStatus1);
1.144 + event->SetSubject(KTestSubject1);
1.145 + event->SetNumber(aEventNumber);
1.146 + event->SetContact(KTestContact1);
1.147 + event->SetLink(KTestLink1);
1.148 + event->SetDataL(KTestData1);
1.149 + event->SetFlags(KTestFlags1);
1.150 + if(aSimId != KLogNullSimId)
1.151 + {
1.152 + event->SetSimId(aSimId);
1.153 + }
1.154 +
1.155 + aActive.StartL();
1.156 + aLogClient.AddEvent(*event, aActive.iStatus);
1.157 + CActiveScheduler::Start();
1.158 + TEST(!aActive.IsActive());
1.159 + TEST2(aActive.iStatus.Int(), KErrNone);
1.160 +
1.161 + TLogId eventId = event->Id();
1.162 + TEST(eventId != KLogNullId);
1.163 + TEST(event->Time() >= now);
1.164 +
1.165 + CleanupStack::PopAndDestroy(event);
1.166 + return eventId;
1.167 + }
1.168 +
1.169 +/**
1.170 +@SYMTestCaseID PDS-LOGENG-UT-4018
1.171 +@SYMTestCaseDesc Retrieving events from a database without "SimId" column in the "Event" table.
1.172 + The test uses the OldLogdbu.dat database, created before introducing the new
1.173 + "SimId" column. The test checks that the events in the database can be accessed and
1.174 + retrieved. The event's SimID property value should be 0.
1.175 +@SYMTestActions Retrieving events from a database without "SimId" column in the "Event" table.
1.176 +@SYMTestExpectedResults Test must not fail
1.177 +@SYMTestPriority Medium
1.178 +@SYMREQ REQ12746
1.179 +*/
1.180 +void GetEventTestL()
1.181 + {
1.182 + CLogClient* client = CLogClient::NewL(theFs);
1.183 + CleanupStack::PushL(client);
1.184 +
1.185 + CTestActive* active = new(ELeave)CTestActive();
1.186 + CleanupStack::PushL(active);
1.187 +
1.188 + DoGetEventTestL(KEventId1, KEventNum1, KLogNullSimId, *active, *client);
1.189 + DoGetEventTestL(KEventId2, KEventNum2, KLogNullSimId, *active, *client);
1.190 + DoGetEventTestL(KEventId3, KEventNum3, KLogNullSimId, *active, *client);
1.191 + DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
1.192 +
1.193 + CleanupStack::PopAndDestroy(active);
1.194 + CleanupStack::PopAndDestroy(client);
1.195 + }
1.196 +
1.197 +/**
1.198 +@SYMTestCaseID PDS-LOGENG-UT-4019
1.199 +@SYMTestCaseDesc Changing events from a database without "SimId" column in the "Event" table.
1.200 + The test uses the OldLogdbu.dat database, created before introducing the new
1.201 + "SimId" column. The test checks that the events in the database can be accessed and
1.202 + retrieved. After that the test changes some of the events, updating events properties
1.203 + with a non-zero SimId. The test checks that the updated event really got its SimId
1.204 + property value changed.
1.205 +@SYMTestActions Changing events from a database without "SimId" column in the "Event" table.
1.206 +@SYMTestExpectedResults Test must not fail
1.207 +@SYMTestPriority Medium
1.208 +@SYMREQ REQ12746
1.209 +*/
1.210 +void ChangeEventTestL()
1.211 + {
1.212 + CLogClient* client = CLogClient::NewL(theFs);
1.213 + CleanupStack::PushL(client);
1.214 +
1.215 + CTestActive* active = new(ELeave)CTestActive();
1.216 + CleanupStack::PushL(active);
1.217 +
1.218 + //Change two of the events
1.219 + DoChangeEventTestL(KEventId1, KEventNum1, KSimId1, *active, *client);
1.220 + DoChangeEventTestL(KEventId3, KEventNum3, KSimId3, *active, *client);
1.221 + //Check that the other two events are unchanged
1.222 + DoGetEventTestL(KEventId2, KEventNum2, KLogNullSimId, *active, *client);
1.223 + DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
1.224 +
1.225 + CleanupStack::PopAndDestroy(active);
1.226 + CleanupStack::PopAndDestroy(client);
1.227 + }
1.228 +
1.229 +/**
1.230 +@SYMTestCaseID PDS-LOGENG-UT-4020
1.231 +@SYMTestCaseDesc Add events to a database without "SimId" column in the "Event" table.
1.232 + The test uses the OldLogdbu.dat database, created before introducing the new
1.233 + "SimId" column. The test adds two events to the database, then checks that the
1.234 + events can be accessed and retrieved.
1.235 +@SYMTestActions Add events to a database without "SimId" column in the "Event" table.
1.236 +@SYMTestExpectedResults Test must not fail
1.237 +@SYMTestPriority Medium
1.238 +@SYMREQ REQ12746
1.239 +*/
1.240 +void AddEventTestL()
1.241 + {
1.242 + CLogClient* client = CLogClient::NewL(theFs);
1.243 + CleanupStack::PushL(client);
1.244 +
1.245 + CTestActive* active = new(ELeave)CTestActive();
1.246 + CleanupStack::PushL(active);
1.247 +
1.248 + //Add an event without SimId
1.249 + TheEventId5 = DoAddEventTestL(KEventNum5, KLogNullSimId, *active, *client);
1.250 + //Add an event with SimId
1.251 + TheEventId6 = DoAddEventTestL(KEventNum6, KSimId1, *active, *client);
1.252 + //Check that the other 4 events are unchanged
1.253 + DoGetEventTestL(KEventId1, KEventNum1, KSimId1, *active, *client);//KSimId1 - set by ChangeEventTestL()
1.254 + DoGetEventTestL(KEventId2, KEventNum2, KLogNullSimId, *active, *client);
1.255 + DoGetEventTestL(KEventId3, KEventNum3, KSimId3, *active, *client);//KSimId3 - set by ChangeEventTestL()
1.256 + DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
1.257 + //Check the first added event
1.258 + DoGetEventTestL(TheEventId5, KEventNum5, KLogNullSimId, *active, *client);
1.259 + //Check the second added event
1.260 + DoGetEventTestL(TheEventId6, KEventNum6, KSimId1, *active, *client);
1.261 +
1.262 + CleanupStack::PopAndDestroy(active);
1.263 + CleanupStack::PopAndDestroy(client);
1.264 + }
1.265 +
1.266 +/**
1.267 +@SYMTestCaseID PDS-LOGENG-UT-4021
1.268 +@SYMTestCaseDesc Delete events from a database without "SimId" column in the "Event" table.
1.269 + The test uses the OldLogdbu.dat database, created before introducing the new
1.270 + "SimId" column. The test deletes an event from the database and checks then that
1.271 + the other events are intact, the deleted event is really deleted.
1.272 +@SYMTestActions Delete events from a database without "SimId" column in the "Event" table.
1.273 +@SYMTestExpectedResults Test must not fail
1.274 +@SYMTestPriority Medium
1.275 +@SYMREQ REQ12746
1.276 +*/
1.277 +void DeleteEventTestL()
1.278 + {
1.279 + CLogClient* client = CLogClient::NewL(theFs);
1.280 + CleanupStack::PushL(client);
1.281 +
1.282 + CTestActive* active = new(ELeave)CTestActive();
1.283 + CleanupStack::PushL(active);
1.284 +
1.285 + //Delete an event
1.286 + active->StartL();
1.287 + client->DeleteEvent(KEventId2, active->iStatus);
1.288 + CActiveScheduler::Start();
1.289 + TEST(!active->IsActive());
1.290 + TEST2(active->iStatus.Int(), KErrNone);
1.291 +
1.292 + //Check that the other 5 events are unchanged
1.293 + DoGetEventTestL(KEventId1, KEventNum1, KSimId1, *active, *client);//KSimId1 - set by ChangeEventTestL()
1.294 + DoGetEventTestL(KEventId3, KEventNum3, KSimId3, *active, *client);//KSimId3 - set by ChangeEventTestL()
1.295 + DoGetEventTestL(KEventId4, KEventNum4, KLogNullSimId, *active, *client);
1.296 + DoGetEventTestL(TheEventId5, KEventNum5, KLogNullSimId, *active, *client);
1.297 + DoGetEventTestL(TheEventId6, KEventNum6, KSimId1, *active, *client);
1.298 +
1.299 + //Check that event 2 was really deleted
1.300 + CLogEvent* event = CLogEvent::NewL();
1.301 + CleanupStack::PushL(event);
1.302 + event->SetId(KEventId2);
1.303 + active->StartL();
1.304 + client->GetEvent(*event, active->iStatus);
1.305 + CActiveScheduler::Start();
1.306 + TEST2(active->iStatus.Int(), KErrNotFound);
1.307 +
1.308 + CleanupStack::PopAndDestroy(event);
1.309 + CleanupStack::PopAndDestroy(active);
1.310 + CleanupStack::PopAndDestroy(client);
1.311 + }
1.312 +
1.313 +/**
1.314 +@SYMTestCaseID PDS-LOGENG-UT-4022
1.315 +@SYMTestCaseDesc Event View test with an old database (without SimId).
1.316 + The test uses the OldLogdbu.dat database, created before introducing the new
1.317 + "SimId" column. The test creates an event view and iterates over the events in the view.
1.318 + The test checks that events without SimId property set can be retrieved.
1.319 +@SYMTestActions Event View test with an old database (without SimId).
1.320 +@SYMTestExpectedResults Test must not fail
1.321 +@SYMTestPriority Medium
1.322 +@SYMREQ REQ12747
1.323 +*/
1.324 +void EventViewTestL()
1.325 + {
1.326 + CLogClient* client = CLogClient::NewL(theFs);
1.327 + CleanupStack::PushL(client);
1.328 +
1.329 + CTestActive* active = new(ELeave)CTestActive();
1.330 + CleanupStack::PushL(active);
1.331 +
1.332 + CLogViewChangeObserver* observer = CLogViewChangeObserver::NewLC();
1.333 + observer->SetActive();
1.334 +
1.335 + CLogViewEvent* view = CLogViewEvent::NewL(*client, *observer);
1.336 + CleanupStack::PushL(view);
1.337 +
1.338 + CLogFilter* filter = CLogFilter::NewL();
1.339 + CleanupStack::PushL(filter);
1.340 + TBool res = view->SetFilterL(*filter, active->iStatus);
1.341 + TEST(res);
1.342 +
1.343 + //SimId: KSimId1 KSimId3 KLogNullSimId KLogNullSimId KSimId1
1.344 + const TLogId KLogEventIds[] ={KEventId1, KEventId3, KEventId4, TheEventId5, TheEventId6};
1.345 + TBool logEventVisited[] = {EFalse, EFalse, EFalse, EFalse, EFalse};
1.346 + const TInt KLogEventCnt = sizeof(KLogEventIds)/sizeof(KLogEventIds[0]);
1.347 +
1.348 + do {
1.349 + active->StartL();
1.350 + CActiveScheduler::Start();
1.351 + TEST2(active->iStatus.Int(), KErrNone);
1.352 +
1.353 + const TInt viewCount = view->CountL();
1.354 + TEST2(viewCount, KLogEventCnt);
1.355 +
1.356 + TInt eventId = view->Event().Id();
1.357 + TInt i = 0;
1.358 + for(;i<KLogEventCnt;++i)
1.359 + {
1.360 + if(KLogEventIds[i] == eventId)
1.361 + {
1.362 + break;
1.363 + }
1.364 + }
1.365 + TEST(i < KLogEventCnt);
1.366 + logEventVisited[i] = ETrue;
1.367 + }
1.368 + while(view->NextL(active->iStatus));
1.369 +
1.370 + //Check that all events were visited.
1.371 + for(TInt i=0;i<KLogEventCnt;++i)
1.372 + {
1.373 + TEST(logEventVisited[i]);
1.374 + }
1.375 +
1.376 + CleanupStack::PopAndDestroy(filter);
1.377 + CleanupStack::PopAndDestroy(view);
1.378 + CleanupStack::PopAndDestroy(observer);
1.379 + CleanupStack::PopAndDestroy(active);
1.380 + CleanupStack::PopAndDestroy(client);
1.381 + }
1.382 +
1.383 +/**
1.384 +@SYMTestCaseID PDS-LOGENG-UT-4023
1.385 +@SYMTestCaseDesc Event View test with an old database (without SimId).
1.386 + The test uses the OldLogdbu.dat database, created before introducing the new
1.387 + "SimId" column. The test creates an event view and iterates over the events in the view.
1.388 + The test checks that events without SimId property set can be retrieved. The test is very
1.389 + similar to the EventViewTestL() test, except the fact that the filter filters out all events
1.390 + with non-zero SimId.
1.391 +@SYMTestActions Event View test with an old database (without SimId).
1.392 +@SYMTestExpectedResults Test must not fail
1.393 +@SYMTestPriority Medium
1.394 +@SYMREQ REQ12747
1.395 +*/
1.396 +void EventViewTest2L()
1.397 + {
1.398 + CLogClient* client = CLogClient::NewL(theFs);
1.399 + CleanupStack::PushL(client);
1.400 +
1.401 + CTestActive* active = new(ELeave)CTestActive();
1.402 + CleanupStack::PushL(active);
1.403 +
1.404 + CLogViewChangeObserver* observer = CLogViewChangeObserver::NewLC();
1.405 + observer->SetActive();
1.406 +
1.407 + CLogViewEvent* view = CLogViewEvent::NewL(*client, *observer);
1.408 + CleanupStack::PushL(view);
1.409 +
1.410 + CLogFilter* filter = CLogFilter::NewL();
1.411 + CleanupStack::PushL(filter);
1.412 + filter->SetNullFields(ELogSimIdField);
1.413 + TBool res = view->SetFilterL(*filter, active->iStatus);
1.414 + TEST(res);
1.415 +
1.416 + //Only events KEventId4 and TheEventId5 are with zero SimId.
1.417 + const TLogId KLogEventIds[] ={KEventId4, TheEventId5};
1.418 + TBool logEventVisited[] = {EFalse, EFalse};
1.419 + const TInt KLogEventCnt = sizeof(KLogEventIds)/sizeof(KLogEventIds[0]);
1.420 +
1.421 + do {
1.422 + active->StartL();
1.423 + CActiveScheduler::Start();
1.424 + TEST2(active->iStatus.Int(), KErrNone);
1.425 +
1.426 + const TInt viewCount = view->CountL();
1.427 + TEST2(viewCount, KLogEventCnt);
1.428 +
1.429 + TInt eventId = view->Event().Id();
1.430 + TInt i = 0;
1.431 + for(;i<KLogEventCnt;++i)
1.432 + {
1.433 + if(KLogEventIds[i] == eventId)
1.434 + {
1.435 + break;
1.436 + }
1.437 + }
1.438 + TEST(i < KLogEventCnt);
1.439 + logEventVisited[i] = ETrue;
1.440 + }
1.441 + while(view->NextL(active->iStatus));
1.442 +
1.443 + //Check that all events were visited.
1.444 + for(TInt i=0;i<KLogEventCnt;++i)
1.445 + {
1.446 + TEST(logEventVisited[i]);
1.447 + }
1.448 +
1.449 + CleanupStack::PopAndDestroy(filter);
1.450 + CleanupStack::PopAndDestroy(view);
1.451 + CleanupStack::PopAndDestroy(observer);
1.452 + CleanupStack::PopAndDestroy(active);
1.453 + CleanupStack::PopAndDestroy(client);
1.454 + }
1.455 +
1.456 +/**
1.457 +@SYMTestCaseID PDS-LOGENG-UT-4024
1.458 +@SYMTestCaseDesc Event View test with an old database (without SimId).
1.459 + The test uses the OldLogdbu.dat database, created before introducing the new
1.460 + "SimId" column. The test creates an event view, sets a filter with a non-zero SimId
1.461 + and iterates over the events in the view. It should be possible to view events with SimId
1.462 + set, when the database was created using the old format.
1.463 +@SYMTestActions Event View test with an old database (without SimId).
1.464 +@SYMTestExpectedResults Test must not fail
1.465 +@SYMTestPriority Medium
1.466 +@SYMREQ REQ12747
1.467 +*/
1.468 +void EventViewTest3L()
1.469 + {
1.470 + CLogClient* client = CLogClient::NewL(theFs);
1.471 + CleanupStack::PushL(client);
1.472 +
1.473 + CTestActive* active = new(ELeave)CTestActive();
1.474 + CleanupStack::PushL(active);
1.475 +
1.476 + CLogViewChangeObserver* observer = CLogViewChangeObserver::NewLC();
1.477 + observer->SetActive();
1.478 +
1.479 + CLogViewEvent* view = CLogViewEvent::NewL(*client, *observer);
1.480 + CleanupStack::PushL(view);
1.481 +
1.482 + CLogFilter* filter = CLogFilter::NewL();
1.483 + CleanupStack::PushL(filter);
1.484 + filter->SetSimId(KSimId1);
1.485 + TSimId simId = filter->SimId();
1.486 + TEST2(simId, KSimId1);
1.487 + TBool res = view->SetFilterL(*filter, active->iStatus);
1.488 + TEST(res);
1.489 +
1.490 + //Only events KEventId1 and TheEventId6 are with KSimId1.
1.491 + const TLogId KLogEventIds[] ={KEventId1, TheEventId6};
1.492 + TBool logEventVisited[] = {EFalse, EFalse};
1.493 + const TInt KLogEventCnt = sizeof(KLogEventIds)/sizeof(KLogEventIds[0]);
1.494 +
1.495 + do {
1.496 + active->StartL();
1.497 + CActiveScheduler::Start();
1.498 + TEST2(active->iStatus.Int(), KErrNone);
1.499 +
1.500 + const TInt viewCount = view->CountL();
1.501 + TEST2(viewCount, KLogEventCnt);
1.502 +
1.503 + TInt eventId = view->Event().Id();
1.504 + TInt i = 0;
1.505 + for(;i<KLogEventCnt;++i)
1.506 + {
1.507 + if(KLogEventIds[i] == eventId)
1.508 + {
1.509 + break;
1.510 + }
1.511 + }
1.512 + TEST(i < KLogEventCnt);
1.513 + logEventVisited[i] = ETrue;
1.514 + }
1.515 + while(view->NextL(active->iStatus));
1.516 +
1.517 + //Check that all events were visited.
1.518 + for(TInt i=0;i<KLogEventCnt;++i)
1.519 + {
1.520 + TEST(logEventVisited[i]);
1.521 + }
1.522 +
1.523 + CleanupStack::PopAndDestroy(filter);
1.524 + CleanupStack::PopAndDestroy(view);
1.525 + CleanupStack::PopAndDestroy(observer);
1.526 + CleanupStack::PopAndDestroy(active);
1.527 + CleanupStack::PopAndDestroy(client);
1.528 + }
1.529 +
1.530 +/**
1.531 +@SYMTestCaseID PDS-LOGENG-UT-4043
1.532 +@SYMTestCaseDesc CLogEvent - data compatibility test.
1.533 + The test uses data externalized from an event prior the "dual SIM support"
1.534 + changes were introduced. The test internalizes the event data and checks
1.535 + that the data is interpreted correctly.
1.536 +@SYMTestActions CLogEvent - data compatibility test.
1.537 +@SYMTestExpectedResults Test must not fail
1.538 +@SYMTestPriority Medium
1.539 +@SYMREQ REQ12746
1.540 +*/
1.541 +void EventDataTestL()
1.542 + {
1.543 + //Externalized to a buffer event data where the following property values have been set:
1.544 + // Id=1, Type=2, "RemoteParty", "Direction", "Data"
1.545 + //The used event format is before the "dual SIM support" changes were introduced.
1.546 + const TUint8 KEvtData1[] =
1.547 + // 0 1 2 3 4 5 6 7 8 9 A B C D E F
1.548 + {
1.549 + 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1.550 + 255, 0, 0, 0, 0,255,255,255,255, 0, 0, 0, 0, 0, 0, 44,
1.551 + 82,101,109,111,116,101, 80, 97,114,116,121, 36, 68,105,114,101,
1.552 + 99,116,105,111,110, 0, 0, 0, 4, 0, 0, 0, 18, 68, 97,116,
1.553 + 97
1.554 + };
1.555 +
1.556 + CLogEvent* evt1 = CLogEvent::NewL();
1.557 + CleanupStack::PushL(evt1);
1.558 + TPtrC8 ptr1(KEvtData1, sizeof(KEvtData1) / sizeof(KEvtData1[0]));
1.559 + RDesReadStream strm1(ptr1);
1.560 + strm1 >> *evt1;
1.561 + strm1.Close();
1.562 + TEST2(evt1->Id(), 1);
1.563 + TEST(evt1->EventType() == TUid::Uid(2));
1.564 + _LIT(KRemoteParty, "RemoteParty");
1.565 + TEST(evt1->RemoteParty() == KRemoteParty);
1.566 + _LIT(KDirection, "Direction");
1.567 + TEST(evt1->Direction() == KDirection);
1.568 + _LIT8(KData, "Data");
1.569 + TEST(evt1->Data() == KData);
1.570 + TEST(evt1->SimId() == KLogNullSimId);
1.571 + CleanupStack::PopAndDestroy(evt1);
1.572 +
1.573 + //Externalized to a buffer event data where the following property values have been set:
1.574 + // Id=3, Type=4, "RemoteParty2", "Direction2"
1.575 + //The used event format is before the "dual SIM support" changes were introduced.
1.576 + const TUint8 KEvtData2[] =
1.577 + // 0 1 2 3 4 5 6 7 8 9 A B C D E F
1.578 + {
1.579 + 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1.580 + 255, 0, 0, 0, 0,255,255,255,255, 0, 0, 0, 0, 0, 0, 48,
1.581 + 82,101,109,111,116,101, 80, 97,114,116,121, 50, 40, 68,105,114,
1.582 + 101, 99,116,105,111,110, 50, 0, 0, 0, 0, 0, 0, 0
1.583 + };
1.584 +
1.585 + CLogEvent* evt2 = CLogEvent::NewL();
1.586 + CleanupStack::PushL(evt2);
1.587 + TPtrC8 ptr2(KEvtData2, sizeof(KEvtData2) / sizeof(KEvtData2[0]));
1.588 + RDesReadStream strm2(ptr2);
1.589 + strm2 >> *evt2;
1.590 + strm2.Close();
1.591 + TEST2(evt2->Id(), 3);
1.592 + TEST(evt2->EventType() == TUid::Uid(4));
1.593 + _LIT(KRemoteParty2, "RemoteParty2");
1.594 + TEST(evt2->RemoteParty() == KRemoteParty2);
1.595 + _LIT(KDirection2, "Direction2");
1.596 + TEST(evt2->Direction() == KDirection2);
1.597 + TEST(evt2->SimId() == KLogNullSimId);
1.598 + CleanupStack::PopAndDestroy(evt2);
1.599 + }
1.600 +
1.601 +/**
1.602 +@SYMTestCaseID PDS-LOGENG-UT-4046
1.603 +@SYMTestCaseDesc CLogClient::ClearLog() - data compatibility test.
1.604 + The test uses the OldLogdbu.dat database, created before introducing the new
1.605 + "SimId" column. The test verifies that CLogClient::ClearLog() can work with
1.606 + database with the old format.
1.607 +@SYMTestActions CLogClient::ClearLog() - data compatibility test.
1.608 +@SYMTestExpectedResults Test must not fail
1.609 +@SYMTestPriority Medium
1.610 +@SYMREQ REQ12748
1.611 +*/
1.612 +void ClearLogTestL()
1.613 + {
1.614 + CLogClient* client = CLogClient::NewL(theFs);
1.615 + CleanupStack::PushL(client);
1.616 +
1.617 + CTestActive* active = new(ELeave)CTestActive();
1.618 + CleanupStack::PushL(active);
1.619 +
1.620 + //Get one of the events
1.621 + CLogEvent* event = CLogEvent::NewL();
1.622 + CleanupStack::PushL(event);
1.623 + event->SetId(KEventId1);
1.624 + active->StartL();
1.625 + client->GetEvent(*event, active->iStatus);
1.626 + CActiveScheduler::Start();
1.627 + TEST2(active->iStatus.Int(), KErrNone);
1.628 + TTime evtTime = event->Time();
1.629 + CleanupStack::PopAndDestroy(event);
1.630 + event = NULL;
1.631 +
1.632 + //Delete all events with time < (evtTime + 1s).
1.633 + evtTime += TTimeIntervalSeconds(1);
1.634 + active->StartL();
1.635 + client->ClearLog(evtTime, active->iStatus);
1.636 + CActiveScheduler::Start();
1.637 + TEST2(active->iStatus.Int(), KErrNone);
1.638 +
1.639 + //The event with time "evtTime" should not be in the log anymore.
1.640 + event = CLogEvent::NewL();
1.641 + CleanupStack::PushL(event);
1.642 + event->SetId(KEventId1);
1.643 + active->StartL();
1.644 + client->GetEvent(*event, active->iStatus);
1.645 + CActiveScheduler::Start();
1.646 + TEST2(active->iStatus.Int(), KErrNotFound);
1.647 + CleanupStack::PopAndDestroy(event);
1.648 +
1.649 + CleanupStack::PopAndDestroy(active);
1.650 + CleanupStack::PopAndDestroy(client);
1.651 + }
1.652 +
1.653 +void doTestsL()
1.654 + {
1.655 + TestUtils::Initialize(_L("t_logcompat"));
1.656 +
1.657 +#ifdef _DEBUG
1.658 + TheTest.Start(_L("Copy the old LogEng database"));
1.659 + TestUtils::CopyOldDbL();
1.660 + //
1.661 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4018: \"Get Event\" compatibility test"));
1.662 + GetEventTestL();
1.663 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4019: \"Change Event\" compatibility test"));
1.664 + ChangeEventTestL();
1.665 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4020: \"Add Event\" compatibility test"));
1.666 + AddEventTestL();
1.667 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4021: \"Delete Event\" compatibility test"));
1.668 + DeleteEventTestL();
1.669 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4022: \"Event View\" compatibility test"));
1.670 + EventViewTestL();
1.671 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4023: \"Event View 2\" compatibility test"));
1.672 + EventViewTest2L();
1.673 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4024: \"Event View 3\" compatibility test"));
1.674 + EventViewTest3L();
1.675 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4043: \"CLogEvent data\" compatibility test"));
1.676 + EventDataTestL();
1.677 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4046: \"CLogClient::ClearLog()\" compatibility test"));
1.678 + ClearLogTestL();
1.679 + //
1.680 + TestUtils::DeleteDatabaseL();
1.681 +#else
1.682 + TheTest.Start(_L("This test works only in debug mode, otherwise the LogEng server cannot be stopped. See TestUtils::CopyOldDbL()"));
1.683 +#endif
1.684 + }
1.685 +
1.686 +#else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.687 +
1.688 +void doTestsL()
1.689 + {
1.690 + TestUtils::Initialize(_L("t_logcompat"));
1.691 + TheTest.Start(_L("The LogEng compatibility test cases are compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined!"));
1.692 + }
1.693 +
1.694 +#endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM