os/persistentdata/loggingservices/eventlogger/test/src/t_logcontact.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-2010 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 <logview.h>
    17 #include "t_logutil2.h"
    18 
    19 RTest TheTest(_L("t_logcontact"));
    20 
    21 /**
    22 @SYMTestCaseID          SYSLIB-LOGENG-CT-1018
    23 @SYMTestCaseDesc	    Tests for backup operations
    24 @SYMTestPriority 	    High
    25 @SYMTestActions  	    Check by adding events and closing the backup file.
    26                         Check for ErrNone flag. 
    27 @SYMTestExpectedResults Test must not fail
    28 @SYMREQ                 REQ0000
    29 */
    30 static void TestBackupL(CLogClient& aClient)
    31 	{
    32 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1018 "));
    33 	CTestActive* active = new (ELeave) CTestActive;
    34 	CleanupStack::PushL(active);
    35 
    36 	CLogEvent* event = CLogEvent::NewL();
    37 	CleanupStack::PushL(event);
    38 	event->SetEventType(KLogCallEventTypeUid);
    39 
    40    	CBaBackupSessionWrapper* backup = CBaBackupSessionWrapper::NewL();
    41    	CleanupStack::PushL(backup);
    42 
    43 	// Add event
    44 	active->StartL();
    45 	aClient.AddEvent(*event, active->iStatus);
    46 	CActiveScheduler::Start();
    47 	TEST2(active->iStatus.Int(), KErrNone);
    48 
    49 	TDriveUnit driveUnit(EDriveC);
    50 	TDriveName name = driveUnit.Name();
    51 
    52 	TParse parse;
    53 	LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL));
    54 
    55 	//Close, then delete LogEng database file. Restart backup operations monitoring
    56 	//on LogEng database.
    57     backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
    58  	User::After(1000000);
    59 	TestUtils::DeleteDatabaseL(EFalse);
    60 	backup->RestartFile(parse.FullName());
    61  	User::After(1000000);
    62 
    63 	// Add event
    64 	active->StartL();
    65 	aClient.AddEvent(*event, active->iStatus);
    66 	CActiveScheduler::Start();
    67 	TEST2(active->iStatus.Int(), KErrNone);
    68 
    69 	// Add event
    70 	active->StartL();
    71 	aClient.AddEvent(*event, active->iStatus);
    72 	CActiveScheduler::Start();
    73 	TEST2(active->iStatus.Int(), KErrNone);
    74 
    75 	//Close LogEng database file
    76 	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
    77 	//Delete LogEng database file
    78  	User::After(1000000);
    79 	TestUtils::DeleteDatabaseL(EFalse);
    80 	//Restart backup operations monitoring on LogEng database.
    81 	backup->RestartFile(parse.FullName());
    82 	User::After(1000000);
    83 
    84 	// Add event
    85 	active->StartL();
    86 	aClient.AddEvent(*event, active->iStatus);
    87 	CActiveScheduler::Start();
    88 	TEST2(active->iStatus.Int(), KErrNone);
    89 	
    90 	//Close LogEng database file.
    91 	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
    92 	//Delete LogEng database file.
    93  	User::After(1000000);
    94 	TestUtils::DeleteDatabaseL(EFalse);
    95 	//Restart backup operations monitoring on LogEng database.
    96 	backup->RestartFile(parse.FullName());
    97 	User::After(1000000);
    98 
    99 	// Add event
   100 	active->StartL();
   101 	aClient.AddEvent(*event, active->iStatus);
   102 	CActiveScheduler::Start();
   103 	TEST2(active->iStatus.Int(), KErrNone);
   104 
   105 	//Close LogEng database
   106 	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
   107  	User::After(1000000);
   108  	//Delete LogEng database
   109 	TestUtils::DeleteDatabaseL(EFalse);
   110 	//Restart backup operations monitoring on LogEng database.
   111 	backup->RestartFile(parse.FullName());
   112 
   113 	// Add event
   114 	active->StartL();
   115 	aClient.AddEvent(*event, active->iStatus);
   116 	CActiveScheduler::Start();
   117 	TEST2(active->iStatus.Int(), KErrNone);
   118 	//Close LogEng database
   119 	backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
   120 	User::After(1000000);
   121  	//Delete LogEng database
   122 	TestUtils::DeleteDatabaseL(EFalse);
   123 	//Restart backup operations monitoring on LogEng database.
   124 	backup->RestartFile(parse.FullName());
   125 	User::After(1000000);
   126 
   127 	// Add event
   128 	active->StartL();
   129 	aClient.AddEvent(*event, active->iStatus);
   130 	CActiveScheduler::Start();
   131 	TEST2(active->iStatus.Int(), KErrNone);
   132 
   133 	active->StartL();
   134 	backup->CloseAll(MBackupObserver::EReleaseLockNoAccess, active->iStatus);
   135 	CActiveScheduler::Start();
   136 	TEST2(active->iStatus.Int(), KErrNone);
   137  	User::After(1000000);
   138 
   139 	TestUtils::DeleteDatabaseL(EFalse);
   140 	backup->RestartAll();
   141  	User::After(1000000);
   142 
   143 	// Add event
   144 	active->StartL();
   145 	aClient.AddEvent(*event, active->iStatus);
   146 	CActiveScheduler::Start();
   147 	TEST2(active->iStatus.Int(), KErrNone);
   148 
   149 	CleanupStack::PopAndDestroy(3); // backup, event, active
   150 	}
   151 	
   152 
   153 void doTestsL()
   154 	{
   155 	TestUtils::Initialize(_L("t_logcontact"));
   156 
   157 	TheTest.Start(_L("Prepare the test environment"));
   158 	
   159 	// Create log client
   160 	CLogClient* client = CLogClient::NewL(theFs);
   161 	CleanupStack::PushL(client);
   162 
   163 	// Send a message to the hicap helper to delete logeng DB 
   164 	TestUtils::DeleteDatabaseL();
   165 			
   166 	TheTest.Next(_L("Backup"));
   167 	TestBackupL(*client);
   168 	TheTest.Next(_L("Backup completed ok"));
   169 	theLog.Write(_L8("Test 2 OK\n"));
   170 	
   171 	CleanupStack::PopAndDestroy(client);
   172 	}