os/persistentdata/loggingservices/eventlogger/test/src/t_logcontact.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/test/src/t_logcontact.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,172 @@
     1.4 +// Copyright (c) 2002-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 <logview.h>
    1.20 +#include "t_logutil2.h"
    1.21 +
    1.22 +RTest TheTest(_L("t_logcontact"));
    1.23 +
    1.24 +/**
    1.25 +@SYMTestCaseID          SYSLIB-LOGENG-CT-1018
    1.26 +@SYMTestCaseDesc	    Tests for backup operations
    1.27 +@SYMTestPriority 	    High
    1.28 +@SYMTestActions  	    Check by adding events and closing the backup file.
    1.29 +                        Check for ErrNone flag. 
    1.30 +@SYMTestExpectedResults Test must not fail
    1.31 +@SYMREQ                 REQ0000
    1.32 +*/
    1.33 +static void TestBackupL(CLogClient& aClient)
    1.34 +	{
    1.35 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1018 "));
    1.36 +	CTestActive* active = new (ELeave) CTestActive;
    1.37 +	CleanupStack::PushL(active);
    1.38 +
    1.39 +	CLogEvent* event = CLogEvent::NewL();
    1.40 +	CleanupStack::PushL(event);
    1.41 +	event->SetEventType(KLogCallEventTypeUid);
    1.42 +
    1.43 +   	CBaBackupSessionWrapper* backup = CBaBackupSessionWrapper::NewL();
    1.44 +   	CleanupStack::PushL(backup);
    1.45 +
    1.46 +	// Add event
    1.47 +	active->StartL();
    1.48 +	aClient.AddEvent(*event, active->iStatus);
    1.49 +	CActiveScheduler::Start();
    1.50 +	TEST2(active->iStatus.Int(), KErrNone);
    1.51 +
    1.52 +	TDriveUnit driveUnit(EDriveC);
    1.53 +	TDriveName name = driveUnit.Name();
    1.54 +
    1.55 +	TParse parse;
    1.56 +	LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL));
    1.57 +
    1.58 +	//Close, then delete LogEng database file. Restart backup operations monitoring
    1.59 +	//on LogEng database.
    1.60 +    backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
    1.61 + 	User::After(1000000);
    1.62 +	TestUtils::DeleteDatabaseL(EFalse);
    1.63 +	backup->RestartFile(parse.FullName());
    1.64 + 	User::After(1000000);
    1.65 +
    1.66 +	// Add event
    1.67 +	active->StartL();
    1.68 +	aClient.AddEvent(*event, active->iStatus);
    1.69 +	CActiveScheduler::Start();
    1.70 +	TEST2(active->iStatus.Int(), KErrNone);
    1.71 +
    1.72 +	// Add event
    1.73 +	active->StartL();
    1.74 +	aClient.AddEvent(*event, active->iStatus);
    1.75 +	CActiveScheduler::Start();
    1.76 +	TEST2(active->iStatus.Int(), KErrNone);
    1.77 +
    1.78 +	//Close LogEng database file
    1.79 +	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
    1.80 +	//Delete LogEng database file
    1.81 + 	User::After(1000000);
    1.82 +	TestUtils::DeleteDatabaseL(EFalse);
    1.83 +	//Restart backup operations monitoring on LogEng database.
    1.84 +	backup->RestartFile(parse.FullName());
    1.85 +	User::After(1000000);
    1.86 +
    1.87 +	// Add event
    1.88 +	active->StartL();
    1.89 +	aClient.AddEvent(*event, active->iStatus);
    1.90 +	CActiveScheduler::Start();
    1.91 +	TEST2(active->iStatus.Int(), KErrNone);
    1.92 +	
    1.93 +	//Close LogEng database file.
    1.94 +	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
    1.95 +	//Delete LogEng database file.
    1.96 + 	User::After(1000000);
    1.97 +	TestUtils::DeleteDatabaseL(EFalse);
    1.98 +	//Restart backup operations monitoring on LogEng database.
    1.99 +	backup->RestartFile(parse.FullName());
   1.100 +	User::After(1000000);
   1.101 +
   1.102 +	// Add event
   1.103 +	active->StartL();
   1.104 +	aClient.AddEvent(*event, active->iStatus);
   1.105 +	CActiveScheduler::Start();
   1.106 +	TEST2(active->iStatus.Int(), KErrNone);
   1.107 +
   1.108 +	//Close LogEng database
   1.109 +	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
   1.110 + 	User::After(1000000);
   1.111 + 	//Delete LogEng database
   1.112 +	TestUtils::DeleteDatabaseL(EFalse);
   1.113 +	//Restart backup operations monitoring on LogEng database.
   1.114 +	backup->RestartFile(parse.FullName());
   1.115 +
   1.116 +	// Add event
   1.117 +	active->StartL();
   1.118 +	aClient.AddEvent(*event, active->iStatus);
   1.119 +	CActiveScheduler::Start();
   1.120 +	TEST2(active->iStatus.Int(), KErrNone);
   1.121 +	//Close LogEng database
   1.122 +	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
   1.123 +	User::After(1000000);
   1.124 + 	//Delete LogEng database
   1.125 +	TestUtils::DeleteDatabaseL(EFalse);
   1.126 +	//Restart backup operations monitoring on LogEng database.
   1.127 +	backup->RestartFile(parse.FullName());
   1.128 +	User::After(1000000);
   1.129 +
   1.130 +	// Add event
   1.131 +	active->StartL();
   1.132 +	aClient.AddEvent(*event, active->iStatus);
   1.133 +	CActiveScheduler::Start();
   1.134 +	TEST2(active->iStatus.Int(), KErrNone);
   1.135 +
   1.136 +	active->StartL();
   1.137 +	backup->CloseAll(MBackupObserver::EReleaseLockNoAccess, active->iStatus);
   1.138 +	CActiveScheduler::Start();
   1.139 +	TEST2(active->iStatus.Int(), KErrNone);
   1.140 + 	User::After(1000000);
   1.141 +
   1.142 +	TestUtils::DeleteDatabaseL(EFalse);
   1.143 +	backup->RestartAll();
   1.144 + 	User::After(1000000);
   1.145 +
   1.146 +	// Add event
   1.147 +	active->StartL();
   1.148 +	aClient.AddEvent(*event, active->iStatus);
   1.149 +	CActiveScheduler::Start();
   1.150 +	TEST2(active->iStatus.Int(), KErrNone);
   1.151 +
   1.152 +	CleanupStack::PopAndDestroy(3); // backup, event, active
   1.153 +	}
   1.154 +	
   1.155 +
   1.156 +void doTestsL()
   1.157 +	{
   1.158 +	TestUtils::Initialize(_L("t_logcontact"));
   1.159 +
   1.160 +	TheTest.Start(_L("Prepare the test environment"));
   1.161 +	
   1.162 +	// Create log client
   1.163 +	CLogClient* client = CLogClient::NewL(theFs);
   1.164 +	CleanupStack::PushL(client);
   1.165 +
   1.166 +	// Send a message to the hicap helper to delete logeng DB 
   1.167 +	TestUtils::DeleteDatabaseL();
   1.168 +			
   1.169 +	TheTest.Next(_L("Backup"));
   1.170 +	TestBackupL(*client);
   1.171 +	TheTest.Next(_L("Backup completed ok"));
   1.172 +	theLog.Write(_L8("Test 2 OK\n"));
   1.173 +	
   1.174 +	CleanupStack::PopAndDestroy(client);
   1.175 +	}