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