sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This file contains the test steps for Unit Test Suite 10 : Log.cpp sl@0: // sl@0: // sl@0: sl@0: // EPOC includes sl@0: #include sl@0: sl@0: // Test system includes sl@0: #include sl@0: sl@0: // Specific includes for this test suite sl@0: #include "TSU_MmTsthSuite10.h" sl@0: sl@0: // Specific includes for these test steps sl@0: #include "TSU_MmTsth10.h" sl@0: sl@0: // -------------------------------------------- sl@0: sl@0: // Unit Test Suite 10 : Log.cpp sl@0: // Depends on : none sl@0: sl@0: // Tests :- sl@0: // 1 RTestFrameworkClientSession : check connect sl@0: // 11 Log : create sl@0: // 12 Log : open log file (existing) sl@0: // 13 Log : write format - no test specified as this is called every time the INFO_PRINTF or ERR_PRINTF sl@0: // macro is called by the framework or suite(s) sl@0: // 14 Log : status (incorporated in test 12) sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1001 sl@0: sl@0: RTestMmTsthU1001* RTestMmTsthU1001::NewL() sl@0: { sl@0: RTestMmTsthU1001* self = new(ELeave) RTestMmTsthU1001; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1001::RTestMmTsthU1001() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1001"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU1001::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for RTestFrameworkServerSession")); sl@0: sl@0: // Check we can connect to the existing server. sl@0: // NB - open, write, close, status will be called by Log tests sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: TInt ret; sl@0: RTestFrameworkClientSession testSession; sl@0: ret = testSession.Connect(); sl@0: if(ret != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Could not connect to server, error %d"), ret); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("Successfully connected to server with a new session")); sl@0: sl@0: testSession.Close(); // cleanup session sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1011 sl@0: sl@0: RTestMmTsthU1011* RTestMmTsthU1011::NewL() sl@0: { sl@0: RTestMmTsthU1011* self = new(ELeave) RTestMmTsthU1011; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1011::RTestMmTsthU1011() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1011"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU1011::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for Log : create")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: CLog* theLog = NULL; sl@0: TRAPD(err, theLog = CLog::NewL()); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("CLog created successfully")); sl@0: delete theLog; sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1012 sl@0: sl@0: RTestMmTsthU1012* RTestMmTsthU1012::NewL() sl@0: { sl@0: RTestMmTsthU1012* self = new(ELeave) RTestMmTsthU1012; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1012::RTestMmTsthU1012() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1012"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU1012::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for Log : open")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: CLog* theLog = NULL; sl@0: TRAPD(err, theLog = CLog::NewL()); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err); sl@0: return iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: // Open the current logfile (it's already open at the server) sl@0: TRAP(err, theLog->OpenLogFileL()); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CLog::OpenLogFileL() left, error code %d"), err); sl@0: delete theLog; sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: // Attempt to open a new log file. This will complete without opening the log file and sl@0: // without disturbing the server; we can sl@0: // ascertain this by checking the log status, which will be unchanged. sl@0: TInt theStatus = theLog->LogStatus(); sl@0: delete theLog; sl@0: theLog = NULL; sl@0: sl@0: _LIT(KDummyLogName, "DummyLog"); sl@0: TRAP(err, theLog = CLog::NewL()); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err); sl@0: return iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: TRAP(err, theLog->OpenLogFileL(KDummyLogName, theStatus - 1)); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CLog::OpenLogFileL(KDummyLogName) left, error code %d"), err); sl@0: delete theLog; sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: TInt theNewStatus = theLog->LogStatus(); sl@0: if(theNewStatus != theStatus) sl@0: { sl@0: ERR_PRINTF1(_L("CLog::OpenLogFileL(KDummyLogName) changed log status!")); sl@0: delete theLog; sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: // NB no test for CloseLogFileL - as this acts at the server and is something we only ever sl@0: // want to do at the end of the TestFramework run sl@0: sl@0: INFO_PRINTF1(_L("CLog opened existing log file successfully")); sl@0: delete theLog; sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1013 sl@0: sl@0: RTestMmTsthU1013* RTestMmTsthU1013::NewL() sl@0: { sl@0: RTestMmTsthU1013* self = new(ELeave) RTestMmTsthU1013; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1013::RTestMmTsthU1013() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1013"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU1013::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for Log : write format")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: // any call to LogExtra will test this. if it doesn't crash, consider it passed sl@0: sl@0: INFO_PRINTF1(_L("Testing WriteFormat...")); sl@0: sl@0: return iTestStepResult = currentVerdict; sl@0: } sl@0: