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