os/persistentdata/loggingservices/eventlogger/test/src/t_logviewfail.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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 <s32file.h>
sl@0
    17
#include "t_logutil2.h"
sl@0
    18
#include <logview.h>
sl@0
    19
sl@0
    20
RTest TheTest(_L("t_logviewfail"));
sl@0
    21
sl@0
    22
const TLogContactItemId KTestContact = 0x123;
sl@0
    23
_LIT(KTestStatus, "Test Status Text");
sl@0
    24
sl@0
    25
sl@0
    26
/**
sl@0
    27
@SYMTestCaseID          SYSLIB-LOGENG-CT-0961-0001
sl@0
    28
@SYMTestCaseDesc	    Tests for CLogViewEvent::NewL() function
sl@0
    29
@SYMTestPriority 	    High
sl@0
    30
@SYMTestActions  	    Add an event to the client,Create a new CLogViewEvent on heap,if no error check if the view works
sl@0
    31
                        Check for memory errors
sl@0
    32
@SYMTestExpectedResults Test must not fail
sl@0
    33
@SYMREQ                 REQ0000
sl@0
    34
*/
sl@0
    35
LOCAL_C void TestEventViewConstructWithHeapFailL(CLogClient& aClient)
sl@0
    36
	{
sl@0
    37
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0961-0001 "));
sl@0
    38
	CTestActive* active = new(ELeave)CTestActive;
sl@0
    39
	CleanupStack::PushL(active);
sl@0
    40
sl@0
    41
	CLogEvent* event = CLogEvent::NewL();
sl@0
    42
	CleanupStack::PushL(event);
sl@0
    43
	event->SetEventType(KLogCallEventTypeUid);
sl@0
    44
sl@0
    45
	// Add an event
sl@0
    46
	aClient.AddEvent(*event, active->iStatus);
sl@0
    47
	active->StartL();
sl@0
    48
	CActiveScheduler::Start();
sl@0
    49
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
    50
sl@0
    51
	CLogViewEvent* view = NULL;
sl@0
    52
sl@0
    53
#ifdef _DEBUG
sl@0
    54
	TInt failCount = 0;
sl@0
    55
#endif
sl@0
    56
	TBool finished = EFalse;
sl@0
    57
	TInt error;
sl@0
    58
sl@0
    59
	while(!finished)
sl@0
    60
		{
sl@0
    61
		__UHEAP_FAILNEXT(failCount++);
sl@0
    62
sl@0
    63
		TRAP(error, view = CLogViewEvent::NewL(aClient));
sl@0
    64
sl@0
    65
		__UHEAP_RESET;
sl@0
    66
		
sl@0
    67
		if (!error)
sl@0
    68
			{
sl@0
    69
			finished = ETrue;
sl@0
    70
			CleanupStack::PushL(view);
sl@0
    71
		
sl@0
    72
			// Check the view works
sl@0
    73
			CLogFilter* filter = CLogFilter::NewL();
sl@0
    74
			CleanupStack::PushL(filter);
sl@0
    75
			
sl@0
    76
			TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
    77
			active->StartL();
sl@0
    78
			CActiveScheduler::Start();
sl@0
    79
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
    80
			TEST(view->CountL() >= 1);
sl@0
    81
			TEST(TestUtils::EventsEqual(*event, view->Event()));
sl@0
    82
sl@0
    83
			CleanupStack::PopAndDestroy(2); // filter, view
sl@0
    84
			}
sl@0
    85
		else
sl@0
    86
			TEST2(error, KErrNoMemory);
sl@0
    87
		}
sl@0
    88
sl@0
    89
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
    90
	}
sl@0
    91
sl@0
    92
/**
sl@0
    93
@SYMTestCaseID          SYSLIB-LOGENG-CT-0962-0001
sl@0
    94
@SYMTestCaseDesc	    Tests for CLogViewRecent::NewL(),CLogViewRecent::SetRecentListL() functions
sl@0
    95
@SYMTestPriority 	    High
sl@0
    96
@SYMTestActions  	    Create a new view object,if no errors and test of initialising of the view for the specified recent event list. 
sl@0
    97
                        Check for no memory errors.                         
sl@0
    98
@SYMTestExpectedResults Test must not fail
sl@0
    99
@SYMREQ                 REQ0000
sl@0
   100
*/
sl@0
   101
LOCAL_C void TestRecentViewConstructWithHeapFailL(CLogClient& aClient)
sl@0
   102
	{
sl@0
   103
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0962-0001 "));
sl@0
   104
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   105
	CleanupStack::PushL(active);
sl@0
   106
sl@0
   107
	CLogEvent* event = CLogEvent::NewL();
sl@0
   108
	CleanupStack::PushL(event);
sl@0
   109
sl@0
   110
	// Incoming
sl@0
   111
	TLogString buf;
sl@0
   112
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   113
sl@0
   114
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   115
	event->SetDirection(buf);
sl@0
   116
sl@0
   117
	// Add an event
sl@0
   118
	aClient.AddEvent(*event, active->iStatus);
sl@0
   119
	active->StartL();
sl@0
   120
	CActiveScheduler::Start();
sl@0
   121
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   122
sl@0
   123
	CLogViewRecent* view = NULL;
sl@0
   124
sl@0
   125
#ifdef _DEBUG
sl@0
   126
	TInt failCount = 0;
sl@0
   127
#endif
sl@0
   128
sl@0
   129
	TBool finished = EFalse;
sl@0
   130
	TInt error;
sl@0
   131
sl@0
   132
	while(!finished)
sl@0
   133
		{
sl@0
   134
		__UHEAP_FAILNEXT(failCount++);
sl@0
   135
sl@0
   136
		TRAP(error, view = CLogViewRecent::NewL(aClient));
sl@0
   137
sl@0
   138
		__UHEAP_RESET;
sl@0
   139
		
sl@0
   140
		if (!error)
sl@0
   141
			{
sl@0
   142
			finished = ETrue;
sl@0
   143
			CleanupStack::PushL(view);
sl@0
   144
					
sl@0
   145
			TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   146
			active->StartL();
sl@0
   147
			CActiveScheduler::Start();
sl@0
   148
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   149
			TEST(view->CountL() >= 1);
sl@0
   150
			TEST(TestUtils::EventsEqual(*event, view->Event()));
sl@0
   151
sl@0
   152
			CleanupStack::PopAndDestroy(); // view
sl@0
   153
			}
sl@0
   154
		else
sl@0
   155
			TEST2(error, KErrNoMemory);
sl@0
   156
		}
sl@0
   157
sl@0
   158
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   159
	}
sl@0
   160
sl@0
   161
/**
sl@0
   162
@SYMTestCaseID          SYSLIB-LOGENG-CT-0963-0001
sl@0
   163
@SYMTestCaseDesc	    Tests for CLogViewDuplicate::NewL() functions
sl@0
   164
@SYMTestPriority 	    High
sl@0
   165
@SYMTestActions  	    Create a new logviewrecent object,set the recent log view,
sl@0
   166
                        List out the duplicates of the current event in the recent event list view,
sl@0
   167
                        Check for no memory errors.
sl@0
   168
@SYMTestExpectedResults Test must not fail
sl@0
   169
@SYMREQ                 REQ0000
sl@0
   170
*/
sl@0
   171
LOCAL_C void TestDuplicateViewConstructWithHeapFailL(CLogClient& aClient)
sl@0
   172
	{
sl@0
   173
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0963-0001 "));
sl@0
   174
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   175
	CleanupStack::PushL(active);
sl@0
   176
sl@0
   177
	CLogEvent* event = CLogEvent::NewL();
sl@0
   178
	CleanupStack::PushL(event);
sl@0
   179
sl@0
   180
	// Incoming
sl@0
   181
	TLogString buf;
sl@0
   182
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   183
sl@0
   184
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   185
	event->SetDirection(buf);
sl@0
   186
	event->SetContact(KTestContact);
sl@0
   187
sl@0
   188
	// Add events
sl@0
   189
	aClient.AddEvent(*event, active->iStatus);
sl@0
   190
	active->StartL();
sl@0
   191
	CActiveScheduler::Start();
sl@0
   192
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   193
sl@0
   194
	aClient.AddEvent(*event, active->iStatus);
sl@0
   195
	active->StartL();
sl@0
   196
	CActiveScheduler::Start();
sl@0
   197
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   198
sl@0
   199
	CLogViewDuplicate* view = NULL;
sl@0
   200
sl@0
   201
#ifdef _DEBUG
sl@0
   202
	TInt failCount = 0;
sl@0
   203
#endif
sl@0
   204
sl@0
   205
	TBool finished = EFalse;
sl@0
   206
	TInt error;
sl@0
   207
sl@0
   208
	while(!finished)
sl@0
   209
		{
sl@0
   210
		__UHEAP_FAILNEXT(failCount++);
sl@0
   211
sl@0
   212
		TRAP(error, view = CLogViewDuplicate::NewL(aClient));
sl@0
   213
sl@0
   214
		__UHEAP_RESET;
sl@0
   215
		
sl@0
   216
		if (!error)
sl@0
   217
			{
sl@0
   218
			finished = ETrue;
sl@0
   219
			CleanupStack::PushL(view);
sl@0
   220
			
sl@0
   221
			CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
sl@0
   222
			CleanupStack::PushL(recent);
sl@0
   223
			TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   224
			active->StartL();
sl@0
   225
			CActiveScheduler::Start();
sl@0
   226
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   227
			TEST(recent->CountL() >= 1);
sl@0
   228
sl@0
   229
			TEST(recent->DuplicatesL(*view, active->iStatus));
sl@0
   230
			active->StartL();
sl@0
   231
			CActiveScheduler::Start();
sl@0
   232
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   233
			TEST(view->CountL() >= 1);
sl@0
   234
sl@0
   235
			CleanupStack::PopAndDestroy(2); // recent, view
sl@0
   236
			}
sl@0
   237
		else
sl@0
   238
			TEST2(error, KErrNoMemory);
sl@0
   239
		}
sl@0
   240
sl@0
   241
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   242
	}
sl@0
   243
sl@0
   244
/**
sl@0
   245
@SYMTestCaseID          SYSLIB-LOGENG-CT-0964-0001
sl@0
   246
@SYMTestCaseDesc	    Tests for CLogViewEvent::SetFilterL() function 
sl@0
   247
@SYMTestPriority 	    High
sl@0
   248
@SYMTestActions  	    Create a log filter and set the filter on logview.Check for equality of events on the view and events
sl@0
   249
						added.Check for memory errors.
sl@0
   250
@SYMTestExpectedResults Test must not fail
sl@0
   251
@SYMREQ                 REQ0000
sl@0
   252
*/
sl@0
   253
LOCAL_C void TestEventViewSetupWithHeapFailL(CLogClient& aClient)
sl@0
   254
	{
sl@0
   255
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0964-0001 "));
sl@0
   256
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   257
	CleanupStack::PushL(active);
sl@0
   258
sl@0
   259
	CLogEvent* event = CLogEvent::NewL();
sl@0
   260
	CleanupStack::PushL(event);
sl@0
   261
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   262
	event->SetStatus(KTestStatus);
sl@0
   263
sl@0
   264
	// Add an event
sl@0
   265
	aClient.AddEvent(*event, active->iStatus);
sl@0
   266
	active->StartL();
sl@0
   267
	CActiveScheduler::Start();
sl@0
   268
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   269
sl@0
   270
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   271
	CleanupStack::PushL(view);
sl@0
   272
sl@0
   273
	CLogFilterList* list = new(ELeave)CLogFilterList;
sl@0
   274
	CleanupStack::PushL(list);
sl@0
   275
sl@0
   276
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   277
	CleanupStack::PushL(filter);
sl@0
   278
	filter->SetStatus(KTestStatus);
sl@0
   279
sl@0
   280
#ifdef _DEBUG
sl@0
   281
	TInt failCount = 0;
sl@0
   282
#endif
sl@0
   283
sl@0
   284
	TBool finished = EFalse;
sl@0
   285
	TInt error;
sl@0
   286
sl@0
   287
	while(!finished)
sl@0
   288
		{
sl@0
   289
		__UHEAP_FAILNEXT(failCount++);
sl@0
   290
sl@0
   291
		TBool result = EFalse;
sl@0
   292
		TRAP(error, result = view->SetFilterL(*filter, active->iStatus));
sl@0
   293
		
sl@0
   294
		if (!error)
sl@0
   295
			{
sl@0
   296
			TEST(result);
sl@0
   297
sl@0
   298
			active->StartL();
sl@0
   299
			CActiveScheduler::Start();
sl@0
   300
sl@0
   301
			if (active->iStatus.Int() == KErrNone)
sl@0
   302
				{
sl@0
   303
				finished = ETrue;		
sl@0
   304
				
sl@0
   305
				TEST(view->CountL() >= 1);
sl@0
   306
				TEST(TestUtils::EventsEqual(*event, view->Event()));
sl@0
   307
				}
sl@0
   308
			else
sl@0
   309
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   310
			}
sl@0
   311
		else
sl@0
   312
			TEST2(error, KErrNoMemory);
sl@0
   313
sl@0
   314
		__UHEAP_RESET;
sl@0
   315
		}
sl@0
   316
sl@0
   317
	list->AppendL(filter);
sl@0
   318
	CleanupStack::Pop(); // filter
sl@0
   319
	
sl@0
   320
	filter = CLogFilter::NewL();
sl@0
   321
	CleanupStack::PushL(filter);
sl@0
   322
	filter->SetEventType(KLogCallEventTypeUid);
sl@0
   323
	list->AppendL(filter);
sl@0
   324
	CleanupStack::Pop(); // filter
sl@0
   325
sl@0
   326
#ifdef _DEBUG
sl@0
   327
	failCount = 0;
sl@0
   328
#endif
sl@0
   329
sl@0
   330
	while(!finished)
sl@0
   331
		{
sl@0
   332
		__UHEAP_FAILNEXT(failCount++);
sl@0
   333
sl@0
   334
		TBool result = EFalse;
sl@0
   335
		TRAP(error, result = view->SetFilterL(*list, active->iStatus));
sl@0
   336
		
sl@0
   337
		if (!error)
sl@0
   338
			{
sl@0
   339
			TEST(result);
sl@0
   340
sl@0
   341
			active->StartL();
sl@0
   342
			CActiveScheduler::Start();
sl@0
   343
sl@0
   344
			if (active->iStatus.Int() == KErrNone)
sl@0
   345
				{
sl@0
   346
				finished = ETrue;		
sl@0
   347
				
sl@0
   348
				TEST(view->CountL() >= 1);
sl@0
   349
				TEST(TestUtils::EventsEqual(*event, view->Event()));
sl@0
   350
				}
sl@0
   351
			else
sl@0
   352
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   353
			}
sl@0
   354
		else
sl@0
   355
			TEST2(error, KErrNoMemory);
sl@0
   356
sl@0
   357
		__UHEAP_RESET;
sl@0
   358
		}
sl@0
   359
sl@0
   360
	list->ResetAndDestroy();
sl@0
   361
	CleanupStack::PopAndDestroy(4); // list, view, event, active
sl@0
   362
	}
sl@0
   363
sl@0
   364
/**
sl@0
   365
@SYMTestCaseID          SYSLIB-LOGENG-CT-0965-0001
sl@0
   366
@SYMTestCaseDesc	    Tests for CLogViewRecent::SetRecentListL() function 
sl@0
   367
@SYMTestPriority 	    High
sl@0
   368
@SYMTestActions  	    Set recent view list first without a filter and later with log filter,check for memory errors
sl@0
   369
@SYMTestExpectedResults Test must not fail
sl@0
   370
@SYMREQ                 REQ0000
sl@0
   371
*/
sl@0
   372
LOCAL_C void TestRecentViewSetupWithHeapFailL(CLogClient& aClient)
sl@0
   373
	{
sl@0
   374
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0965-0001 "));
sl@0
   375
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   376
	CleanupStack::PushL(active);
sl@0
   377
sl@0
   378
	CLogEvent* event = CLogEvent::NewL();
sl@0
   379
	CleanupStack::PushL(event);
sl@0
   380
sl@0
   381
	// Incoming
sl@0
   382
	TLogString buf;
sl@0
   383
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   384
sl@0
   385
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   386
	event->SetDirection(buf);
sl@0
   387
	event->SetStatus(KTestStatus);
sl@0
   388
sl@0
   389
	// Add an event
sl@0
   390
	aClient.AddEvent(*event, active->iStatus);
sl@0
   391
	active->StartL();
sl@0
   392
	CActiveScheduler::Start();
sl@0
   393
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   394
sl@0
   395
	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
sl@0
   396
	CleanupStack::PushL(view);
sl@0
   397
sl@0
   398
#ifdef _DEBUG
sl@0
   399
	TInt failCount = 0;
sl@0
   400
#endif
sl@0
   401
sl@0
   402
	TBool finished = EFalse;
sl@0
   403
	TInt error;
sl@0
   404
sl@0
   405
	while(!finished)
sl@0
   406
		{
sl@0
   407
		__UHEAP_FAILNEXT(failCount++);
sl@0
   408
sl@0
   409
		TBool result = EFalse;
sl@0
   410
		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   411
		
sl@0
   412
		if (!error)
sl@0
   413
			{
sl@0
   414
			TEST(result);
sl@0
   415
sl@0
   416
			active->StartL();
sl@0
   417
			CActiveScheduler::Start();
sl@0
   418
sl@0
   419
			if (active->iStatus.Int() == KErrNone)
sl@0
   420
				{
sl@0
   421
				finished = ETrue;		
sl@0
   422
				TEST(view->CountL() >= 1);
sl@0
   423
				}
sl@0
   424
			else
sl@0
   425
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   426
			}
sl@0
   427
		else
sl@0
   428
			TEST2(error, KErrNoMemory);
sl@0
   429
sl@0
   430
		__UHEAP_RESET;
sl@0
   431
		}
sl@0
   432
sl@0
   433
	CLogFilterList* list = new(ELeave)CLogFilterList;
sl@0
   434
	CleanupStack::PushL(list);
sl@0
   435
sl@0
   436
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   437
	CleanupStack::PushL(filter);
sl@0
   438
	filter->SetStatus(KTestStatus);
sl@0
   439
sl@0
   440
#ifdef _DEBUG
sl@0
   441
	failCount = 0;
sl@0
   442
#endif
sl@0
   443
	finished = EFalse;
sl@0
   444
sl@0
   445
	while(!finished)
sl@0
   446
		{
sl@0
   447
		__UHEAP_FAILNEXT(failCount++);
sl@0
   448
sl@0
   449
		TBool result = EFalse;
sl@0
   450
		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *filter, active->iStatus));
sl@0
   451
		
sl@0
   452
		if (!error)
sl@0
   453
			{
sl@0
   454
			TEST(result);
sl@0
   455
sl@0
   456
			active->StartL();
sl@0
   457
			CActiveScheduler::Start();
sl@0
   458
sl@0
   459
			if (active->iStatus.Int() == KErrNone)
sl@0
   460
				{
sl@0
   461
				finished = ETrue;		
sl@0
   462
				TEST(view->CountL() >= 1);
sl@0
   463
				}
sl@0
   464
			else
sl@0
   465
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   466
			}
sl@0
   467
		else
sl@0
   468
			TEST2(error, KErrNoMemory);
sl@0
   469
sl@0
   470
		__UHEAP_RESET;
sl@0
   471
		}
sl@0
   472
sl@0
   473
	list->AppendL(filter);
sl@0
   474
	CleanupStack::Pop(); // filter
sl@0
   475
sl@0
   476
	filter = CLogFilter::NewL();
sl@0
   477
	CleanupStack::PushL(filter);
sl@0
   478
	filter->SetEventType(KLogCallEventTypeUid);
sl@0
   479
	list->AppendL(filter);
sl@0
   480
	CleanupStack::Pop(); // filter
sl@0
   481
sl@0
   482
#ifdef _DEBUG
sl@0
   483
	failCount = 0;
sl@0
   484
#endif
sl@0
   485
	finished = EFalse;
sl@0
   486
sl@0
   487
	while(!finished)
sl@0
   488
		{
sl@0
   489
		__UHEAP_FAILNEXT(failCount++);
sl@0
   490
sl@0
   491
		TBool result = EFalse;
sl@0
   492
		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *list, active->iStatus));
sl@0
   493
		
sl@0
   494
		if (!error)
sl@0
   495
			{
sl@0
   496
			TEST(result);
sl@0
   497
sl@0
   498
			active->StartL();
sl@0
   499
			CActiveScheduler::Start();
sl@0
   500
sl@0
   501
			if (active->iStatus.Int() == KErrNone)
sl@0
   502
				{
sl@0
   503
				finished = ETrue;		
sl@0
   504
				TEST(view->CountL() >= 1);
sl@0
   505
				}
sl@0
   506
			else
sl@0
   507
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   508
			}
sl@0
   509
		else
sl@0
   510
			TEST2(error, KErrNoMemory);
sl@0
   511
sl@0
   512
		__UHEAP_RESET;
sl@0
   513
		}
sl@0
   514
sl@0
   515
	list->ResetAndDestroy();
sl@0
   516
	CleanupStack::PopAndDestroy(4); // list, view, event, active
sl@0
   517
	}
sl@0
   518
sl@0
   519
/**
sl@0
   520
@SYMTestCaseID          SYSLIB-LOGENG-CT-0966
sl@0
   521
@SYMTestCaseDesc	    Tests for CLogViewRecent::DuplicatesL() function
sl@0
   522
@SYMTestPriority 	    High
sl@0
   523
@SYMTestActions  	    Set the specified duplicate event view with logview duplicates.
sl@0
   524
                        Check for memory errors 
sl@0
   525
@SYMTestExpectedResults Test must not fail
sl@0
   526
@SYMREQ                 REQ0000
sl@0
   527
*/
sl@0
   528
LOCAL_C void TestDuplicateViewSetupWithHeapFailL(CLogClient& aClient)
sl@0
   529
	{
sl@0
   530
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0966 "));
sl@0
   531
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   532
	CleanupStack::PushL(active);
sl@0
   533
sl@0
   534
	CLogEvent* event = CLogEvent::NewL();
sl@0
   535
	CleanupStack::PushL(event);
sl@0
   536
sl@0
   537
	// Incoming
sl@0
   538
	TLogString buf;
sl@0
   539
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   540
sl@0
   541
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   542
	event->SetDirection(buf);
sl@0
   543
	event->SetContact(KTestContact);
sl@0
   544
	event->SetStatus(KTestStatus);
sl@0
   545
sl@0
   546
	// Add events
sl@0
   547
	aClient.AddEvent(*event, active->iStatus);
sl@0
   548
	active->StartL();
sl@0
   549
	CActiveScheduler::Start();
sl@0
   550
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   551
sl@0
   552
	aClient.AddEvent(*event, active->iStatus);
sl@0
   553
	active->StartL();
sl@0
   554
	CActiveScheduler::Start();
sl@0
   555
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   556
sl@0
   557
	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
sl@0
   558
	CleanupStack::PushL(view);
sl@0
   559
sl@0
   560
	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   561
	active->StartL();
sl@0
   562
	CActiveScheduler::Start();
sl@0
   563
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   564
	
sl@0
   565
	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
sl@0
   566
	CleanupStack::PushL(duplicate);
sl@0
   567
sl@0
   568
#ifdef _DEBUG
sl@0
   569
	TInt failCount = 0;
sl@0
   570
#endif
sl@0
   571
sl@0
   572
	TBool finished = EFalse;
sl@0
   573
	TInt error;
sl@0
   574
sl@0
   575
	while(!finished)
sl@0
   576
		{
sl@0
   577
		__UHEAP_FAILNEXT(failCount++);
sl@0
   578
sl@0
   579
		TBool result = EFalse;
sl@0
   580
		TRAP(error, result = view->DuplicatesL(*duplicate, active->iStatus));
sl@0
   581
		
sl@0
   582
		if (!error)
sl@0
   583
			{
sl@0
   584
			TEST(result);
sl@0
   585
sl@0
   586
			active->StartL();
sl@0
   587
			CActiveScheduler::Start();
sl@0
   588
sl@0
   589
			if (active->iStatus.Int() == KErrNone)
sl@0
   590
				{
sl@0
   591
				finished = ETrue;		
sl@0
   592
				TEST(duplicate->CountL() >= 1);
sl@0
   593
				}
sl@0
   594
			else
sl@0
   595
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   596
			}
sl@0
   597
		else
sl@0
   598
			TEST2(error, KErrNoMemory);
sl@0
   599
sl@0
   600
		__UHEAP_RESET;
sl@0
   601
		}
sl@0
   602
sl@0
   603
	CLogFilterList* list = new(ELeave)CLogFilterList;
sl@0
   604
	CleanupStack::PushL(list);
sl@0
   605
sl@0
   606
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   607
	CleanupStack::PushL(filter);
sl@0
   608
	filter->SetStatus(KTestStatus);
sl@0
   609
sl@0
   610
#ifdef _DEBUG
sl@0
   611
	failCount = 0;
sl@0
   612
#endif
sl@0
   613
	finished = EFalse;
sl@0
   614
sl@0
   615
	while(!finished)
sl@0
   616
		{
sl@0
   617
		__UHEAP_FAILNEXT(failCount++);
sl@0
   618
sl@0
   619
		TBool result = EFalse;
sl@0
   620
		TRAP(error, result = view->DuplicatesL(*duplicate, *filter, active->iStatus));
sl@0
   621
		
sl@0
   622
		if (!error)
sl@0
   623
			{
sl@0
   624
			TEST(result);
sl@0
   625
sl@0
   626
			active->StartL();
sl@0
   627
			CActiveScheduler::Start();
sl@0
   628
sl@0
   629
			if (active->iStatus.Int() == KErrNone)
sl@0
   630
				{
sl@0
   631
				finished = ETrue;		
sl@0
   632
				TEST(duplicate->CountL() >= 1);
sl@0
   633
				}
sl@0
   634
			else
sl@0
   635
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   636
			}
sl@0
   637
		else
sl@0
   638
			TEST2(error, KErrNoMemory);
sl@0
   639
sl@0
   640
		__UHEAP_RESET;
sl@0
   641
		}
sl@0
   642
sl@0
   643
	list->AppendL(filter);
sl@0
   644
	CleanupStack::Pop(); // filter
sl@0
   645
sl@0
   646
	filter = CLogFilter::NewL();
sl@0
   647
	CleanupStack::PushL(filter);
sl@0
   648
	filter->SetEventType(KLogCallEventTypeUid);
sl@0
   649
	list->AppendL(filter);
sl@0
   650
	CleanupStack::Pop(); // filter
sl@0
   651
sl@0
   652
#ifdef _DEBUG
sl@0
   653
	failCount = 0;
sl@0
   654
#endif
sl@0
   655
	finished = EFalse;
sl@0
   656
sl@0
   657
	while(!finished)
sl@0
   658
		{
sl@0
   659
		__UHEAP_FAILNEXT(failCount++);
sl@0
   660
sl@0
   661
		TBool result = EFalse;
sl@0
   662
		TRAP(error, result = view->DuplicatesL(*duplicate, *list, active->iStatus));
sl@0
   663
		
sl@0
   664
		if (!error)
sl@0
   665
			{
sl@0
   666
			TEST(result);
sl@0
   667
sl@0
   668
			active->StartL();
sl@0
   669
			CActiveScheduler::Start();
sl@0
   670
sl@0
   671
			if (active->iStatus.Int() == KErrNone)
sl@0
   672
				{
sl@0
   673
				finished = ETrue;		
sl@0
   674
				TEST(duplicate->CountL() >= 1);
sl@0
   675
				}
sl@0
   676
			else
sl@0
   677
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   678
			}
sl@0
   679
		else
sl@0
   680
			TEST2(error, KErrNoMemory);
sl@0
   681
sl@0
   682
		__UHEAP_RESET;
sl@0
   683
		}
sl@0
   684
sl@0
   685
	list->ResetAndDestroy();
sl@0
   686
	CleanupStack::PopAndDestroy(5); // list, duplicate, view, event, active
sl@0
   687
	}
sl@0
   688
sl@0
   689
/**
sl@0
   690
@SYMTestCaseID          SYSLIB-LOGENG-CT-0967
sl@0
   691
@SYMTestCaseDesc	    Tests for CLogViewEvent::NextL(),CLogViewEvent::LastL(),CLogViewEvent::PreviousL(),
sl@0
   692
                        CLogViewEvent::FirstL() functions
sl@0
   693
@SYMTestPriority 	    High
sl@0
   694
@SYMTestActions  	    Tests for all the navigation functions in the view. 
sl@0
   695
@SYMTestExpectedResults Test must not fail
sl@0
   696
@SYMREQ                 REQ0000
sl@0
   697
*/
sl@0
   698
LOCAL_C void TestNavigationWithHeapFailL(CLogClient& aClient)
sl@0
   699
	{
sl@0
   700
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0967 "));
sl@0
   701
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   702
	CleanupStack::PushL(active);
sl@0
   703
sl@0
   704
	CLogEvent* event = CLogEvent::NewL();
sl@0
   705
	CleanupStack::PushL(event);
sl@0
   706
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   707
sl@0
   708
	// Add an event
sl@0
   709
	aClient.AddEvent(*event, active->iStatus);
sl@0
   710
	active->StartL();
sl@0
   711
	CActiveScheduler::Start();
sl@0
   712
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   713
sl@0
   714
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   715
	CleanupStack::PushL(view);
sl@0
   716
sl@0
   717
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   718
	CleanupStack::PushL(filter);
sl@0
   719
sl@0
   720
#ifdef _DEBUG
sl@0
   721
	TInt failCount = 0;
sl@0
   722
#endif
sl@0
   723
sl@0
   724
	TBool finished = EFalse;
sl@0
   725
	TInt error;
sl@0
   726
sl@0
   727
	while(!finished)
sl@0
   728
		{
sl@0
   729
		TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   730
		active->StartL();
sl@0
   731
		CActiveScheduler::Start();
sl@0
   732
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   733
		TEST(view->CountL() > 1);
sl@0
   734
		event->CopyL(view->Event());
sl@0
   735
sl@0
   736
		__UHEAP_FAILNEXT(failCount++);
sl@0
   737
sl@0
   738
		TBool result = EFalse;
sl@0
   739
		TRAP(error, result = view->NextL(active->iStatus));
sl@0
   740
		
sl@0
   741
		if (!error)
sl@0
   742
			{
sl@0
   743
			TEST(result);
sl@0
   744
sl@0
   745
			active->StartL();
sl@0
   746
			CActiveScheduler::Start();
sl@0
   747
sl@0
   748
			if (active->iStatus.Int() == KErrNone)
sl@0
   749
				{
sl@0
   750
				finished = ETrue;
sl@0
   751
				TEST(!TestUtils::EventsEqual(*event, view->Event()));
sl@0
   752
				}
sl@0
   753
			else
sl@0
   754
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   755
			}
sl@0
   756
		else
sl@0
   757
			TEST2(error, KErrNoMemory);
sl@0
   758
sl@0
   759
		__UHEAP_RESET;
sl@0
   760
		}
sl@0
   761
sl@0
   762
#ifdef _DEBUG
sl@0
   763
	failCount = 0;
sl@0
   764
#endif
sl@0
   765
	finished = EFalse;
sl@0
   766
sl@0
   767
	while(!finished)
sl@0
   768
		{
sl@0
   769
		TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   770
		active->StartL();
sl@0
   771
		CActiveScheduler::Start();
sl@0
   772
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   773
		TEST(view->CountL() > 1);
sl@0
   774
sl@0
   775
		TEST(view->LastL(active->iStatus));
sl@0
   776
		active->StartL();
sl@0
   777
		CActiveScheduler::Start();
sl@0
   778
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   779
sl@0
   780
		event->CopyL(view->Event());
sl@0
   781
sl@0
   782
		__UHEAP_FAILNEXT(failCount++);
sl@0
   783
sl@0
   784
		TBool result = EFalse;
sl@0
   785
		TRAP(error, result = view->PreviousL(active->iStatus));
sl@0
   786
		
sl@0
   787
		if (!error)
sl@0
   788
			{
sl@0
   789
			TEST(result);
sl@0
   790
sl@0
   791
			active->StartL();
sl@0
   792
			CActiveScheduler::Start();
sl@0
   793
sl@0
   794
			if (active->iStatus.Int() == KErrNone)
sl@0
   795
				{
sl@0
   796
				finished = ETrue;
sl@0
   797
				TEST(!TestUtils::EventsEqual(*event, view->Event()));
sl@0
   798
				}
sl@0
   799
			else
sl@0
   800
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   801
			}
sl@0
   802
		else
sl@0
   803
			TEST2(error, KErrNoMemory);
sl@0
   804
sl@0
   805
		__UHEAP_RESET;
sl@0
   806
		}
sl@0
   807
sl@0
   808
#ifdef _DEBUG
sl@0
   809
	failCount = 0;
sl@0
   810
#endif
sl@0
   811
	finished = EFalse;
sl@0
   812
sl@0
   813
	while(!finished)
sl@0
   814
		{
sl@0
   815
		TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   816
		active->StartL();
sl@0
   817
		CActiveScheduler::Start();
sl@0
   818
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   819
		TEST(view->CountL() > 1);
sl@0
   820
sl@0
   821
		TEST(view->LastL(active->iStatus));
sl@0
   822
		active->StartL();
sl@0
   823
		CActiveScheduler::Start();
sl@0
   824
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   825
sl@0
   826
		event->CopyL(view->Event());
sl@0
   827
sl@0
   828
		__UHEAP_FAILNEXT(failCount++);
sl@0
   829
sl@0
   830
		TBool result = EFalse;
sl@0
   831
		TRAP(error, result = view->FirstL(active->iStatus));
sl@0
   832
		
sl@0
   833
		if (!error)
sl@0
   834
			{
sl@0
   835
			TEST(result);
sl@0
   836
sl@0
   837
			active->StartL();
sl@0
   838
			CActiveScheduler::Start();
sl@0
   839
sl@0
   840
			if (active->iStatus.Int() == KErrNone)
sl@0
   841
				{
sl@0
   842
				finished = ETrue;
sl@0
   843
				TEST(!TestUtils::EventsEqual(*event, view->Event()));
sl@0
   844
				}
sl@0
   845
			else
sl@0
   846
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   847
			}
sl@0
   848
		else
sl@0
   849
			TEST2(error, KErrNoMemory);
sl@0
   850
sl@0
   851
		__UHEAP_RESET;
sl@0
   852
		}
sl@0
   853
sl@0
   854
#ifdef _DEBUG
sl@0
   855
	failCount = 0;
sl@0
   856
#endif
sl@0
   857
	finished = EFalse;
sl@0
   858
sl@0
   859
	while(!finished)
sl@0
   860
		{
sl@0
   861
		TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   862
		active->StartL();
sl@0
   863
		CActiveScheduler::Start();
sl@0
   864
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   865
		TEST(view->CountL() > 1);
sl@0
   866
sl@0
   867
		TEST(view->FirstL(active->iStatus));
sl@0
   868
		active->StartL();
sl@0
   869
		CActiveScheduler::Start();
sl@0
   870
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   871
sl@0
   872
		event->CopyL(view->Event());
sl@0
   873
sl@0
   874
		__UHEAP_FAILNEXT(failCount++);
sl@0
   875
sl@0
   876
		TBool result = EFalse;
sl@0
   877
		TRAP(error, result = view->LastL(active->iStatus));
sl@0
   878
		
sl@0
   879
		if (!error)
sl@0
   880
			{
sl@0
   881
			TEST(result);
sl@0
   882
sl@0
   883
			active->StartL();
sl@0
   884
			CActiveScheduler::Start();
sl@0
   885
sl@0
   886
			if (active->iStatus.Int() == KErrNone)
sl@0
   887
				{
sl@0
   888
				finished = ETrue;
sl@0
   889
				TEST(!TestUtils::EventsEqual(*event, view->Event()));
sl@0
   890
				}
sl@0
   891
			else
sl@0
   892
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   893
			}
sl@0
   894
		else
sl@0
   895
			TEST2(error, KErrNoMemory);
sl@0
   896
sl@0
   897
		__UHEAP_RESET;
sl@0
   898
		}
sl@0
   899
sl@0
   900
	CleanupStack::PopAndDestroy(4); // filter, view, event, active
sl@0
   901
	}
sl@0
   902
sl@0
   903
/**
sl@0
   904
@SYMTestCaseID          SYSLIB-LOGENG-CT-0968
sl@0
   905
@SYMTestCaseDesc	    Tests for CLogViewEvent::CountL() function
sl@0
   906
@SYMTestPriority 	    High
sl@0
   907
@SYMTestActions  	    Test for getting the number of events in the view.Check for memory errors
sl@0
   908
@SYMTestExpectedResults Test must not fail
sl@0
   909
@SYMREQ                 REQ0000
sl@0
   910
*/
sl@0
   911
LOCAL_C void TestViewCountWithHeapFailL(CLogClient& aClient)
sl@0
   912
	{
sl@0
   913
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0968 "));
sl@0
   914
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   915
	CleanupStack::PushL(active);
sl@0
   916
sl@0
   917
	CLogEvent* event = CLogEvent::NewL();
sl@0
   918
	CleanupStack::PushL(event);
sl@0
   919
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   920
sl@0
   921
	// Add an event
sl@0
   922
	aClient.AddEvent(*event, active->iStatus);
sl@0
   923
	active->StartL();
sl@0
   924
	CActiveScheduler::Start();
sl@0
   925
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   926
sl@0
   927
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   928
	CleanupStack::PushL(view);
sl@0
   929
sl@0
   930
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   931
	CleanupStack::PushL(filter);
sl@0
   932
sl@0
   933
	TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   934
	active->StartL();
sl@0
   935
	CActiveScheduler::Start();
sl@0
   936
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   937
sl@0
   938
#ifdef _DEBUG
sl@0
   939
	TInt failCount = 0;
sl@0
   940
#endif
sl@0
   941
sl@0
   942
	TBool finished = EFalse;
sl@0
   943
	TInt error;
sl@0
   944
sl@0
   945
	while(!finished)
sl@0
   946
		{
sl@0
   947
		__UHEAP_FAILNEXT(failCount++);
sl@0
   948
sl@0
   949
		TInt result = 0;
sl@0
   950
		TRAP(error, result = view->CountL());
sl@0
   951
		
sl@0
   952
		if (!error)
sl@0
   953
			{
sl@0
   954
			finished = ETrue;
sl@0
   955
			TEST(result > 0);
sl@0
   956
			}
sl@0
   957
		else
sl@0
   958
			TEST2(error, KErrNoMemory);
sl@0
   959
sl@0
   960
		__UHEAP_RESET;
sl@0
   961
		}
sl@0
   962
sl@0
   963
	CleanupStack::PopAndDestroy(4); // filter, view, event, active
sl@0
   964
	}
sl@0
   965
sl@0
   966
/**
sl@0
   967
@SYMTestCaseID          SYSLIB-LOGENG-CT-0969
sl@0
   968
@SYMTestCaseDesc	    Tests for CLogViewRecent::RemoveL() function
sl@0
   969
@SYMTestPriority 	    High
sl@0
   970
@SYMTestActions  	    Test for removing the event with the specified unique event ID from the view.Check for memory error
sl@0
   971
@SYMTestExpectedResults Test must not fail
sl@0
   972
@SYMREQ                 REQ0000
sl@0
   973
*/
sl@0
   974
LOCAL_C void TestRecentViewRemoveWithHeapFailL(CLogClient& aClient)
sl@0
   975
	{
sl@0
   976
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0969 "));
sl@0
   977
	CTestActive* active = new(ELeave)CTestActive;
sl@0
   978
	CleanupStack::PushL(active);
sl@0
   979
sl@0
   980
	CLogEvent* event = CLogEvent::NewL();
sl@0
   981
	CleanupStack::PushL(event);
sl@0
   982
sl@0
   983
	// Incoming
sl@0
   984
	TLogString buf;
sl@0
   985
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   986
sl@0
   987
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   988
	event->SetDirection(buf);
sl@0
   989
	event->SetContact(1);
sl@0
   990
sl@0
   991
	// Add events
sl@0
   992
	aClient.AddEvent(*event, active->iStatus);
sl@0
   993
	active->StartL();
sl@0
   994
	CActiveScheduler::Start();
sl@0
   995
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   996
sl@0
   997
	event->SetContact(2);
sl@0
   998
sl@0
   999
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1000
	active->StartL();
sl@0
  1001
	CActiveScheduler::Start();
sl@0
  1002
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1003
sl@0
  1004
	event->SetContact(3);
sl@0
  1005
sl@0
  1006
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1007
	active->StartL();
sl@0
  1008
	CActiveScheduler::Start();
sl@0
  1009
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1010
sl@0
  1011
	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
sl@0
  1012
	CleanupStack::PushL(view);
sl@0
  1013
sl@0
  1014
	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
  1015
	active->StartL();
sl@0
  1016
	CActiveScheduler::Start();
sl@0
  1017
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1018
sl@0
  1019
	TInt count = view->CountL();
sl@0
  1020
	TEST(count > 1);
sl@0
  1021
sl@0
  1022
#ifdef _DEBUG
sl@0
  1023
	TInt failCount = 0;
sl@0
  1024
#endif
sl@0
  1025
sl@0
  1026
	TBool finished = EFalse;
sl@0
  1027
	TInt error;
sl@0
  1028
sl@0
  1029
	while(!finished)
sl@0
  1030
		{
sl@0
  1031
		__UHEAP_FAILNEXT(failCount++);
sl@0
  1032
sl@0
  1033
		TRAP(error, view->RemoveL(view->Event().Id()));
sl@0
  1034
sl@0
  1035
		__UHEAP_RESET;
sl@0
  1036
sl@0
  1037
		if (!error)
sl@0
  1038
			{
sl@0
  1039
			finished = ETrue;
sl@0
  1040
sl@0
  1041
			TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
  1042
			active->StartL();
sl@0
  1043
			CActiveScheduler::Start();
sl@0
  1044
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1045
sl@0
  1046
			TEST(count == view->CountL() + 1);
sl@0
  1047
			}
sl@0
  1048
		else
sl@0
  1049
			TEST2(error, KErrNoMemory);
sl@0
  1050
		}
sl@0
  1051
sl@0
  1052
#ifdef _DEBUG
sl@0
  1053
	failCount = 0;
sl@0
  1054
#endif
sl@0
  1055
	finished = EFalse;
sl@0
  1056
sl@0
  1057
	while(!finished)
sl@0
  1058
		{
sl@0
  1059
		TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
  1060
		active->StartL();
sl@0
  1061
		CActiveScheduler::Start();
sl@0
  1062
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1063
sl@0
  1064
		count = view->CountL();
sl@0
  1065
		TEST(count > 1);
sl@0
  1066
sl@0
  1067
		__UHEAP_FAILNEXT(failCount++);
sl@0
  1068
sl@0
  1069
		TBool ret = EFalse;
sl@0
  1070
		TRAP(error, ret = view->RemoveL(active->iStatus));
sl@0
  1071
sl@0
  1072
		__UHEAP_RESET;
sl@0
  1073
sl@0
  1074
		if (!error)
sl@0
  1075
			{
sl@0
  1076
			TEST(ret);
sl@0
  1077
sl@0
  1078
			active->StartL();
sl@0
  1079
			CActiveScheduler::Start();
sl@0
  1080
sl@0
  1081
			if (active->iStatus == KErrNone)
sl@0
  1082
				{
sl@0
  1083
				TEST(count == view->CountL() + 1);
sl@0
  1084
				finished = ETrue;
sl@0
  1085
				}
sl@0
  1086
			else
sl@0
  1087
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
  1088
			}
sl@0
  1089
		else
sl@0
  1090
			TEST2(error, KErrNoMemory);
sl@0
  1091
		}
sl@0
  1092
sl@0
  1093
	CleanupStack::PopAndDestroy(3); // view, event, active
sl@0
  1094
	}
sl@0
  1095
sl@0
  1096
/**
sl@0
  1097
@SYMTestCaseID          SYSLIB-LOGENG-CT-0970
sl@0
  1098
@SYMTestCaseDesc	    Tests for CLogViewDuplicate::RemoveL() function
sl@0
  1099
@SYMTestPriority 	    High
sl@0
  1100
@SYMTestActions  	    Test for removing the event with the specified unique event ID from the view.Check for memory error
sl@0
  1101
@SYMTestExpectedResults Test must not fail
sl@0
  1102
@SYMREQ                 REQ0000
sl@0
  1103
*/
sl@0
  1104
LOCAL_C void TestDuplicateViewRemoveWithHeapFailL(CLogClient& aClient)
sl@0
  1105
	{
sl@0
  1106
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0970 "));
sl@0
  1107
	CTestActive* active = new(ELeave)CTestActive;
sl@0
  1108
	CleanupStack::PushL(active);
sl@0
  1109
sl@0
  1110
	CLogEvent* event = CLogEvent::NewL();
sl@0
  1111
	CleanupStack::PushL(event);
sl@0
  1112
sl@0
  1113
	// Incoming
sl@0
  1114
	TLogString buf;
sl@0
  1115
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
  1116
sl@0
  1117
	event->SetEventType(KLogCallEventTypeUid);
sl@0
  1118
	event->SetDirection(buf);
sl@0
  1119
	event->SetContact(KTestContact);
sl@0
  1120
sl@0
  1121
	// Add events
sl@0
  1122
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1123
	active->StartL();
sl@0
  1124
	CActiveScheduler::Start();
sl@0
  1125
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1126
sl@0
  1127
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1128
	active->StartL();
sl@0
  1129
	CActiveScheduler::Start();
sl@0
  1130
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1131
sl@0
  1132
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1133
	active->StartL();
sl@0
  1134
	CActiveScheduler::Start();
sl@0
  1135
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1136
sl@0
  1137
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1138
	active->StartL();
sl@0
  1139
	CActiveScheduler::Start();
sl@0
  1140
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1141
sl@0
  1142
	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
sl@0
  1143
	CleanupStack::PushL(view);
sl@0
  1144
sl@0
  1145
	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
  1146
	active->StartL();
sl@0
  1147
	CActiveScheduler::Start();
sl@0
  1148
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1149
sl@0
  1150
	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
sl@0
  1151
	CleanupStack::PushL(duplicate);
sl@0
  1152
sl@0
  1153
	TEST(view->DuplicatesL(*duplicate, active->iStatus));
sl@0
  1154
	active->StartL();
sl@0
  1155
	CActiveScheduler::Start();
sl@0
  1156
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1157
	
sl@0
  1158
	TInt count = duplicate->CountL();
sl@0
  1159
	TEST(count > 0);
sl@0
  1160
sl@0
  1161
#ifdef _DEBUG
sl@0
  1162
	TInt failCount = 0;
sl@0
  1163
#endif
sl@0
  1164
sl@0
  1165
	TBool finished = EFalse;
sl@0
  1166
	TInt error;
sl@0
  1167
sl@0
  1168
	while(!finished)
sl@0
  1169
		{
sl@0
  1170
		__UHEAP_FAILNEXT(failCount++);
sl@0
  1171
sl@0
  1172
		TRAP(error, duplicate->RemoveL(duplicate->Event().Id()));
sl@0
  1173
sl@0
  1174
		__UHEAP_RESET;
sl@0
  1175
sl@0
  1176
		if (!error)
sl@0
  1177
			{
sl@0
  1178
			finished = ETrue;
sl@0
  1179
sl@0
  1180
			TEST(view->DuplicatesL(*duplicate, active->iStatus));
sl@0
  1181
			active->StartL();
sl@0
  1182
			CActiveScheduler::Start();
sl@0
  1183
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1184
sl@0
  1185
			TEST(count == duplicate->CountL() + 1);
sl@0
  1186
			}
sl@0
  1187
		else
sl@0
  1188
			TEST2(error, KErrNoMemory);
sl@0
  1189
		}
sl@0
  1190
sl@0
  1191
#ifdef _DEBUG
sl@0
  1192
	failCount = 0;
sl@0
  1193
#endif
sl@0
  1194
	finished = EFalse;
sl@0
  1195
sl@0
  1196
	while(!finished)
sl@0
  1197
		{
sl@0
  1198
		TEST(view->DuplicatesL(*duplicate, active->iStatus));
sl@0
  1199
		active->StartL();
sl@0
  1200
		CActiveScheduler::Start();
sl@0
  1201
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1202
sl@0
  1203
		count = duplicate->CountL();
sl@0
  1204
		TEST(count > 1);
sl@0
  1205
sl@0
  1206
		__UHEAP_FAILNEXT(failCount++);
sl@0
  1207
sl@0
  1208
		TBool ret = EFalse;
sl@0
  1209
		TRAP(error, ret = duplicate->RemoveL(active->iStatus));
sl@0
  1210
sl@0
  1211
		__UHEAP_RESET;
sl@0
  1212
sl@0
  1213
		if (!error)
sl@0
  1214
			{
sl@0
  1215
			TEST(ret);
sl@0
  1216
sl@0
  1217
			active->StartL();
sl@0
  1218
			CActiveScheduler::Start();
sl@0
  1219
sl@0
  1220
			if (active->iStatus == KErrNone)
sl@0
  1221
				{
sl@0
  1222
				finished = ETrue;
sl@0
  1223
				TEST(count == duplicate->CountL() + 1);
sl@0
  1224
				}
sl@0
  1225
			else
sl@0
  1226
				TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
  1227
			}
sl@0
  1228
		else
sl@0
  1229
			TEST2(error, KErrNoMemory);
sl@0
  1230
		}
sl@0
  1231
sl@0
  1232
	CleanupStack::PopAndDestroy(4); // duplicate, view, event, active
sl@0
  1233
	}
sl@0
  1234
sl@0
  1235
void doTestsL()
sl@0
  1236
	{
sl@0
  1237
	TestUtils::Initialize(_L("t_logviewfail"));
sl@0
  1238
	TestUtils::DeleteDatabaseL();
sl@0
  1239
sl@0
  1240
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
  1241
	CleanupStack::PushL(client);
sl@0
  1242
sl@0
  1243
	TheTest.Start(_L("Heap Failure in Client"));
sl@0
  1244
sl@0
  1245
	TheTest.Next(_L("View Construction"));
sl@0
  1246
	TestEventViewConstructWithHeapFailL(*client);
sl@0
  1247
	TestRecentViewConstructWithHeapFailL(*client);
sl@0
  1248
	TestDuplicateViewConstructWithHeapFailL(*client);
sl@0
  1249
	theLog.Write(_L8("Test 1 OK\n"));
sl@0
  1250
sl@0
  1251
	TheTest.Next(_L("View Setup"));
sl@0
  1252
	TestEventViewSetupWithHeapFailL(*client);
sl@0
  1253
	TestRecentViewSetupWithHeapFailL(*client);
sl@0
  1254
	TestDuplicateViewSetupWithHeapFailL(*client);
sl@0
  1255
	theLog.Write(_L8("Test 2 OK\n"));
sl@0
  1256
sl@0
  1257
	TheTest.Next(_L("View Navigation"));
sl@0
  1258
	TestNavigationWithHeapFailL(*client);
sl@0
  1259
	theLog.Write(_L8("Test 3 OK\n"));
sl@0
  1260
sl@0
  1261
	TheTest.Next(_L("Other"));
sl@0
  1262
	TestViewCountWithHeapFailL(*client);
sl@0
  1263
	TestRecentViewRemoveWithHeapFailL(*client);
sl@0
  1264
	TestDuplicateViewRemoveWithHeapFailL(*client);
sl@0
  1265
	theLog.Write(_L8("Test 4 OK\n"));
sl@0
  1266
sl@0
  1267
	CleanupStack::PopAndDestroy(); // client;
sl@0
  1268
	}