loggingservices/eventlogger/test/src/t_logbackup.cpp
branchRCL_3
changeset 9 667e88a979d7
parent 0 08ec8eefde2f
equal deleted inserted replaced
8:fa9941cf3867 9:667e88a979d7
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
    16 #include <s32file.h>
    16 #include <s32file.h>
    17 #include <babackup.h>
    17 #include <babackup.h>
    18 
    18 #include "t_logutil2.h"
    19 #include "TEST.H"
       
    20 #include <logview.h>
    19 #include <logview.h>
    21 
    20 
    22 #undef test  //there is a "test" macro which hides "RTest test" declaration.
    21 RTest TheTest(_L("t_logbackup"));
    23 
    22 
    24 RTest test(_L("Log Backup Test Harness"));
       
    25 CBaBackupSessionWrapper* theBackup = NULL;
    23 CBaBackupSessionWrapper* theBackup = NULL;
    26 
    24 
    27 /////////////////////////////////////////////////////////////////////////////////////
    25 /////////////////////////////////////////////////////////////////////////////////////
    28 /////////////////////////////////////////////////////////////////////////////////////
    26 /////////////////////////////////////////////////////////////////////////////////////
    29 /////////////////////////////////////////////////////////////////////////////////////
    27 /////////////////////////////////////////////////////////////////////////////////////
    75 @SYMTestExpectedResults Test must not fail
    73 @SYMTestExpectedResults Test must not fail
    76 @SYMREQ                 REQ0000
    74 @SYMREQ                 REQ0000
    77 */
    75 */
    78 LOCAL_C void TestLogOpenL()
    76 LOCAL_C void TestLogOpenL()
    79 	{
    77 	{
    80 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0993 "));
    78 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0993 "));
    81 	TEST(IsLogOpenL());
    79 	TEST(IsLogOpenL());
    82 	}
    80 	}
    83 
    81 
    84 /**
    82 /**
    85 @SYMTestCaseID          SYSLIB-LOGENG-CT-0994
    83 @SYMTestCaseID          SYSLIB-LOGENG-CT-0994
    89 @SYMTestExpectedResults Test must not fail
    87 @SYMTestExpectedResults Test must not fail
    90 @SYMREQ                 REQ0000
    88 @SYMREQ                 REQ0000
    91 */
    89 */
    92 LOCAL_C void TestLogClosedL()
    90 LOCAL_C void TestLogClosedL()
    93 	{
    91 	{
    94 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0994 "));
    92 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0994 "));
    95 	TEST(!IsLogOpenL());
    93 	TEST(!IsLogOpenL());
    96 	}
    94 	}
    97 
    95 
    98 LOCAL_C void StartBackupL()
    96 LOCAL_C void StartBackupL()
    99 	{
    97 	{
   164 @SYMTestExpectedResults Test must not fail
   162 @SYMTestExpectedResults Test must not fail
   165 @SYMREQ                 REQ0000
   163 @SYMREQ                 REQ0000
   166 */
   164 */
   167 LOCAL_C void TestLockingL()
   165 LOCAL_C void TestLockingL()
   168 	{
   166 	{
   169 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0995 "));
   167 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0995 "));
   170 	CLogClient* client = CLogClient::NewL(theFs);
   168 	CLogClient* client = CLogClient::NewL(theFs);
   171 	CleanupStack::PushL(client);
   169 	CleanupStack::PushL(client);
   172 
   170 
   173 	ForceClientImplInstL(*client);
   171 	ForceClientImplInstL(*client);
   174 
   172 
   194 @SYMTestExpectedResults Test must not fail
   192 @SYMTestExpectedResults Test must not fail
   195 @SYMREQ                 REQ0000
   193 @SYMREQ                 REQ0000
   196 */
   194 */
   197 LOCAL_C void TestDeleteWhileLockedL()
   195 LOCAL_C void TestDeleteWhileLockedL()
   198 	{
   196 	{
   199 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0996 "));
   197 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0996 "));
   200 	CLogClient* client = CLogClient::NewL(theFs);
   198 	CLogClient* client = CLogClient::NewL(theFs);
   201 	CleanupStack::PushL(client);
   199 	CleanupStack::PushL(client);
   202 	ForceClientImplInstL(*client);
   200 	ForceClientImplInstL(*client);
   203 
   201 
   204 	TestLogOpenL();
   202 	TestLogOpenL();
   232 @SYMTestExpectedResults Test must not fail
   230 @SYMTestExpectedResults Test must not fail
   233 @SYMREQ                 REQ0000
   231 @SYMREQ                 REQ0000
   234 */
   232 */
   235 LOCAL_C void TestDeleteViewWhileLockedL()
   233 LOCAL_C void TestDeleteViewWhileLockedL()
   236 	{
   234 	{
   237 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0997 "));
   235 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0997 "));
   238 	CLogClient* client = CLogClient::NewL(theFs);
   236 	CLogClient* client = CLogClient::NewL(theFs);
   239 	CleanupStack::PushL(client);
   237 	CleanupStack::PushL(client);
   240 	ForceClientImplInstL(*client);
   238 	ForceClientImplInstL(*client);
   241 
   239 
   242 	CLogFilter* filter = CLogFilter::NewL();
   240 	CLogFilter* filter = CLogFilter::NewL();
   282 @SYMTestExpectedResults Test must not fail
   280 @SYMTestExpectedResults Test must not fail
   283 @SYMREQ                 REQ0000
   281 @SYMREQ                 REQ0000
   284 */
   282 */
   285 LOCAL_C void TestMultipleClientLockingL()
   283 LOCAL_C void TestMultipleClientLockingL()
   286 	{
   284 	{
   287 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0998 "));
   285 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0998 "));
   288 	CLogClient* client1 = CLogClient::NewL(theFs);
   286 	CLogClient* client1 = CLogClient::NewL(theFs);
   289 	CleanupStack::PushL(client1);
   287 	CleanupStack::PushL(client1);
   290 	ForceClientImplInstL(*client1);
   288 	ForceClientImplInstL(*client1);
   291 
   289 
   292 	TestLogOpenL();
   290 	TestLogOpenL();
   318 @SYMTestExpectedResults Test must not fail
   316 @SYMTestExpectedResults Test must not fail
   319 @SYMREQ                 REQ0000
   317 @SYMREQ                 REQ0000
   320 */
   318 */
   321 LOCAL_C void TestMultipleViewLockingL()
   319 LOCAL_C void TestMultipleViewLockingL()
   322 	{
   320 	{
   323 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0999 "));
   321 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0999 "));
   324 	CLogClient* client = CLogClient::NewL(theFs);
   322 	CLogClient* client = CLogClient::NewL(theFs);
   325 	CleanupStack::PushL(client);
   323 	CleanupStack::PushL(client);
   326 	ForceClientImplInstL(*client);
   324 	ForceClientImplInstL(*client);
   327 
   325 
   328 	CLogFilter* filter = CLogFilter::NewL();
   326 	CLogFilter* filter = CLogFilter::NewL();
   446 	TEST2(active->iStatus.Int(), aError);
   444 	TEST2(active->iStatus.Int(), aError);
   447 
   445 
   448 	active->StartL();
   446 	active->StartL();
   449 	aClient.GetEvent(*event, active->iStatus);
   447 	aClient.GetEvent(*event, active->iStatus);
   450 	CActiveScheduler::Start();
   448 	CActiveScheduler::Start();
   451 	RDebug::Print(_L("*** active->iStatus.Int()=%d\n"), active->iStatus.Int());
   449 	TheTest.Printf(_L("*** active->iStatus.Int()=%d\n"), active->iStatus.Int());
   452 	TEST(active->iStatus.Int() == aError || active->iStatus.Int() == KErrNotFound);
   450 	TEST(active->iStatus.Int() == aError || active->iStatus.Int() == KErrNotFound);
   453 
   451 
   454 	CleanupStack::PopAndDestroy(2); // event, active
   452 	CleanupStack::PopAndDestroy(2); // event, active
   455 	}
   453 	}
   456 
   454 
   464 @SYMTestExpectedResults Test must not fail
   462 @SYMTestExpectedResults Test must not fail
   465 @SYMREQ                 REQ0000
   463 @SYMREQ                 REQ0000
   466 */
   464 */
   467 LOCAL_C void TestClientRequestsL()
   465 LOCAL_C void TestClientRequestsL()
   468 	{
   466 	{
   469 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1000 "));
   467 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1000 "));
   470 	CLogClient* client1 = CLogClient::NewL(theFs);
   468 	CLogClient* client1 = CLogClient::NewL(theFs);
   471 	CleanupStack::PushL(client1);
   469 	CleanupStack::PushL(client1);
   472 	ForceClientImplInstL(*client1);
   470 	ForceClientImplInstL(*client1);
   473 
   471 
   474 	TestLogOpenL();
   472 	TestLogOpenL();
   507 @SYMTestExpectedResults Test must not fail
   505 @SYMTestExpectedResults Test must not fail
   508 @SYMREQ                 REQ0000
   506 @SYMREQ                 REQ0000
   509 */
   507 */
   510 LOCAL_C void TestNotificationsL()
   508 LOCAL_C void TestNotificationsL()
   511 	{
   509 	{
   512 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1001 "));
   510 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1001 "));
   513 	CTestActive* notify = new(ELeave)CTestActive;
   511 	CTestActive* notify = new(ELeave)CTestActive;
   514 	CleanupStack::PushL(notify);
   512 	CleanupStack::PushL(notify);
   515 
   513 
   516 	CTestTimer* timer = CTestTimer::NewL();
   514 	CTestTimer* timer = CTestTimer::NewL();
   517 	CleanupStack::PushL(timer);
   515 	CleanupStack::PushL(timer);
   643 @SYMTestExpectedResults Test must not fail
   641 @SYMTestExpectedResults Test must not fail
   644 @SYMREQ                 REQ0000
   642 @SYMREQ                 REQ0000
   645 */
   643 */
   646 LOCAL_C void TestRequestInProgressL()
   644 LOCAL_C void TestRequestInProgressL()
   647 	{
   645 	{
   648 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1002 "));
   646 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1002 "));
   649 	CLogClient* client = CLogClient::NewL(theFs);
   647 	CLogClient* client = CLogClient::NewL(theFs);
   650 	CleanupStack::PushL(client);
   648 	CleanupStack::PushL(client);
   651 	ForceClientImplInstL(*client);
   649 	ForceClientImplInstL(*client);
   652 	EndBackupL();
   650 	EndBackupL();
   653 
   651 
   721 @SYMTestExpectedResults Test must not fail
   719 @SYMTestExpectedResults Test must not fail
   722 @SYMREQ                 REQ0000
   720 @SYMREQ                 REQ0000
   723 */
   721 */
   724 LOCAL_C void TestViewRequestInProgressL()
   722 LOCAL_C void TestViewRequestInProgressL()
   725 	{
   723 	{
   726 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1003 "));
   724 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1003 "));
   727 	CLogClient* client = CLogClient::NewL(theFs);
   725 	CLogClient* client = CLogClient::NewL(theFs);
   728 	CleanupStack::PushL(client);
   726 	CleanupStack::PushL(client);
   729 	ForceClientImplInstL(*client);
   727 	ForceClientImplInstL(*client);
   730 	EndBackupL();
   728 	EndBackupL();
   731 
   729 
   829 @SYMTestExpectedResults Test must not fail
   827 @SYMTestExpectedResults Test must not fail
   830 @SYMREQ                 REQ0000
   828 @SYMREQ                 REQ0000
   831 */
   829 */
   832 LOCAL_C void TestViewSetup1L()
   830 LOCAL_C void TestViewSetup1L()
   833 	{
   831 	{
   834 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1004 "));
   832 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1004 "));
   835 	CLogClient* client = CLogClient::NewL(theFs);
   833 	CLogClient* client = CLogClient::NewL(theFs);
   836 	CleanupStack::PushL(client);
   834 	CleanupStack::PushL(client);
   837 	ForceClientImplInstL(*client);
   835 	ForceClientImplInstL(*client);
   838 	EndBackupL();
   836 	EndBackupL();
   839 
   837 
   889 @SYMTestExpectedResults Test must not fail
   887 @SYMTestExpectedResults Test must not fail
   890 @SYMREQ                 REQ0000
   888 @SYMREQ                 REQ0000
   891 */
   889 */
   892 LOCAL_C void TestViewSetup2L()
   890 LOCAL_C void TestViewSetup2L()
   893  	{
   891  	{
   894 	test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1005 "));
   892 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1005 "));
   895  	CLogClient* client = CLogClient::NewL(theFs);
   893  	CLogClient* client = CLogClient::NewL(theFs);
   896  	CleanupStack::PushL(client);
   894  	CleanupStack::PushL(client);
   897  	ForceClientImplInstL(*client);
   895  	ForceClientImplInstL(*client);
   898  	EndBackupL();
   896  	EndBackupL();
   899  
   897  
   963 @SYMTestExpectedResults Test must not fail
   961 @SYMTestExpectedResults Test must not fail
   964 @SYMREQ                 REQ0000
   962 @SYMREQ                 REQ0000
   965 */
   963 */
   966 LOCAL_C void TestRefreshViewL()
   964 LOCAL_C void TestRefreshViewL()
   967 {
   965 {
   968     test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1006 "));
   966     TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1006 "));
   969 	CLogClient* client = CLogClient::NewL(theFs);
   967 	CLogClient* client = CLogClient::NewL(theFs);
   970 	CleanupStack::PushL(client);
   968 	CleanupStack::PushL(client);
   971 
   969 
   972 	// Create a test observer MLogClientChangeObserver
   970 	// Create a test observer MLogClientChangeObserver
   973 	TBool logRefreshViewFlag = EFalse;
   971 	TBool logRefreshViewFlag = EFalse;
  1002 /////////////////////////////////////////////////////////////////////////////////////
  1000 /////////////////////////////////////////////////////////////////////////////////////
  1003 /////////////////////////////////////////////////////////////////////////////////////
  1001 /////////////////////////////////////////////////////////////////////////////////////
  1004 /////////////////////////////////////////////////////////////////////////////////////
  1002 /////////////////////////////////////////////////////////////////////////////////////
  1005 
  1003 
  1006 void doTestsL()
  1004 void doTestsL()
  1007 //
  1005 	{
  1008 //
  1006 	TestUtils::Initialize(_L("t_logbackup"));
  1009 //
       
  1010 	{
       
  1011 	test.Start(_L("T_LogBackup"));
       
  1012 	TestUtils::Initialize(_L("T_BACKUP"));
       
  1013 	TestUtils::DeleteDatabaseL();
  1007 	TestUtils::DeleteDatabaseL();
       
  1008 
       
  1009     TheTest.Start(_L("t_logbackup"));
       
  1010 	
  1014 #ifndef __WINS__
  1011 #ifndef __WINS__
  1015 	test.Printf(_L("This test harness will only work on WINS\n"));
  1012 	TheTest.Printf(_L("This test harness will only work on WINS\n"));
  1016 	User::After(5000000);
  1013 	User::After(5000000);
  1017 #else//__WINS__
  1014 #else//__WINS__
  1018 	CLogChangeNotifier* notifier = CLogChangeNotifier::NewL();
  1015 	CLogChangeNotifier* notifier = CLogChangeNotifier::NewL();
  1019 	CleanupStack::PushL(notifier);
  1016 	CleanupStack::PushL(notifier);
  1020 
  1017 
  1021 	test.Next(_L("Locking"));
  1018 	TheTest.Next(_L("Locking"));
  1022 	TestLockingL();
  1019 	TestLockingL();
  1023 	theLog.Write(_L8("Test 1 OK\n"));
  1020 	theLog.Write(_L8("Test 1 OK\n"));
  1024 
  1021 
  1025 	test.Next(_L("Delete client while locked"));
  1022 	TheTest.Next(_L("Delete client while locked"));
  1026 	TestDeleteWhileLockedL();
  1023 	TestDeleteWhileLockedL();
  1027 	theLog.Write(_L8("Test 2 OK\n"));
  1024 	theLog.Write(_L8("Test 2 OK\n"));
  1028 
  1025 
  1029 	test.Next(_L("Delete view while locked"));
  1026 	TheTest.Next(_L("Delete view while locked"));
  1030 	TestDeleteViewWhileLockedL();
  1027 	TestDeleteViewWhileLockedL();
  1031 	theLog.Write(_L8("Test 3 OK\n"));
  1028 	theLog.Write(_L8("Test 3 OK\n"));
  1032 
  1029 
  1033 	test.Next(_L("Multiple clients"));
  1030 	TheTest.Next(_L("Multiple clients"));
  1034 	TestMultipleClientLockingL();
  1031 	TestMultipleClientLockingL();
  1035 	theLog.Write(_L8("Test 4 OK\n"));
  1032 	theLog.Write(_L8("Test 4 OK\n"));
  1036 
  1033 
  1037 	test.Next(_L("Multiple views"));
  1034 	TheTest.Next(_L("Multiple views"));
  1038 	TestMultipleViewLockingL();
  1035 	TestMultipleViewLockingL();
  1039 	theLog.Write(_L8("Test 5 OK\n"));
  1036 	theLog.Write(_L8("Test 5 OK\n"));
  1040 
  1037 
  1041 	test.Next(_L("Client Requests"));
  1038 	TheTest.Next(_L("Client Requests"));
  1042 	TestClientRequestsL();
  1039 	TestClientRequestsL();
  1043 	theLog.Write(_L8("Test 6 OK\n"));
  1040 	theLog.Write(_L8("Test 6 OK\n"));
  1044 
  1041 
  1045 	test.Next(_L("View setup"));
  1042 	TheTest.Next(_L("View setup"));
  1046 	TestViewSetup1L();
  1043 	TestViewSetup1L();
  1047 	TestViewSetup2L();
  1044 	TestViewSetup2L();
  1048 	theLog.Write(_L8("Test 7 OK\n"));
  1045 	theLog.Write(_L8("Test 7 OK\n"));
  1049 
  1046 
  1050 	test.Next(_L("Notifications"));
  1047 	TheTest.Next(_L("Notifications"));
  1051 	TestNotificationsL();
  1048 	TestNotificationsL();
  1052 	theLog.Write(_L8("Test 8 OK\n"));
  1049 	theLog.Write(_L8("Test 8 OK\n"));
  1053 
  1050 
  1054 	test.Next(_L("Request in progress"));
  1051 	TheTest.Next(_L("Request in progress"));
  1055 	TestRequestInProgressL();
  1052 	TestRequestInProgressL();
  1056 	theLog.Write(_L8("Test 9 OK\n"));
  1053 	theLog.Write(_L8("Test 9 OK\n"));
  1057 
  1054 
  1058 	test.Next(_L("View request in progress"));
  1055 	TheTest.Next(_L("View request in progress"));
  1059 	TestViewRequestInProgressL();
  1056 	TestViewRequestInProgressL();
  1060 	theLog.Write(_L8("Test 10 OK\n"));
  1057 	theLog.Write(_L8("Test 10 OK\n"));
  1061 
  1058 
  1062 	test.Next(_L("Refresh view"));
  1059 	TheTest.Next(_L("Refresh view"));
  1063 	TestRefreshViewL();
  1060 	TestRefreshViewL();
  1064 	theLog.Write(_L8("Test 11 OK\n"));
  1061 	theLog.Write(_L8("Test 11 OK\n"));
  1065 
  1062 
  1066 	CleanupStack::PopAndDestroy(notifier);
  1063 	CleanupStack::PopAndDestroy(notifier);
  1067 #endif//__WINS__
  1064 #endif//__WINS__