sl@0: // Copyright (c) 2007-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: // sl@0: sl@0: #include "uloggerfileplugintest.h" sl@0: #include "uloggerdatatypes.h" sl@0: using namespace Ulogger; sl@0: sl@0: /* sl@0: * TestNewL: Test that the NewL method correctly constructs a CFileWriter object sl@0: * sl@0: * Expected Verdict: PASS/FAIL/PANIC sl@0: * sl@0: * Prerequisites: sl@0: * sl@0: * Description: Invoke CFileWriter::NewL() and check that a non-NULL pointer is sl@0: * returned. sl@0: * sl@0: */ sl@0: void CFile0Step::TestNewL() sl@0: { sl@0: CFileWriter* fileWriter = CFileWriter::NewL(); sl@0: INFO_PRINTF1(_L("Checking that pointer returned by CFileWriter::NewL() is not NULL")); sl@0: ASSERT_NOT_NULL(fileWriter); sl@0: delete fileWriter; sl@0: } sl@0: /* sl@0: * TestUnlockResourcesL: Test that the CloseOutputPlugin method ??? sl@0: * sl@0: * Expected Verdict: PASS/FAIL/PANIC sl@0: * sl@0: * Prerequisites: sl@0: * sl@0: * Description: Retrieve and print some data from an external ini data file sl@0: * sl@0: */ sl@0: void CFile0Step::TestUnlockResourcesL() sl@0: { sl@0: CFileWriter* fileWriter = CFileWriter::NewL(); sl@0: INFO_PRINTF1(_L("Invoking CFileWriter::CloseOutputPlugin(). CloseOutputPlugin() is supposed to do nothing.")); sl@0: fileWriter->CloseOutputPlugin(); sl@0: ASSERT_TRUE(ETrue); sl@0: delete fileWriter; sl@0: } sl@0: sl@0: /* sl@0: * TestSettingsL: Test that the Settings method ??? sl@0: * sl@0: * Expected Verdict: PASS/FAIL/PANIC sl@0: * sl@0: * Prerequisites: sl@0: * sl@0: * Description: Retrieve and print some data from an external ini data file sl@0: * sl@0: */ sl@0: void CFile0Step::TestSettingsL() sl@0: { sl@0: CFileWriter* fileWriter = CFileWriter::NewL(); sl@0: INFO_PRINTF1(_L("Passing empty RPointerArray to CFileWriter::ConfigureOutputPlugin()")); sl@0: RPointerArray emptyPointerArray; sl@0: fileWriter->ConfigureOutputPlugin(emptyPointerArray); sl@0: sl@0: delete fileWriter; sl@0: } sl@0: sl@0: /* sl@0: * TestWriteL: Test that the Write method ??? sl@0: * sl@0: * Expected Verdict: PASS/FAIL/PANIC sl@0: * sl@0: * Prerequisites: sl@0: * sl@0: * Description: Invoke CFileWriter::Write() and check that test string is sl@0: * written to KLogDefaultFileName correctly. sl@0: * sl@0: */ sl@0: // The implementation for this is not working correctly! Check this sl@0: void CFile0Step::TestWriteL() sl@0: { sl@0: INFO_PRINTF1(_L("Checking that CFileWriter::Write(const TDesC8&) writes a String correctly to C:\\logs\\log.txt")); sl@0: sl@0: // Create new CFileWriter instance sl@0: CFileWriter* fileWriter = CFileWriter::NewL(); sl@0: _LIT8(KTxt, "Test"); sl@0: INFO_PRINTF1(_L("Writing 'Test' to the log using CFileWriter::Write()")); sl@0: ASSERT_EQUALS(KErrNone, fileWriter->Write(KTxt)); sl@0: sl@0: delete fileWriter; sl@0: } sl@0: sl@0: sl@0: CFile0Step::~CFile0Step() sl@0: { sl@0: } sl@0: sl@0: CFile0Step::CFile0Step() sl@0: /** sl@0: * Constructor sl@0: */ sl@0: { sl@0: // **MUST** call SetTestStepName in the constructor as the controlling sl@0: // framework uses the test step name immediately following construction to set sl@0: // up the step's unique logging ID. sl@0: SetTestStepName(KFile0Step); sl@0: } sl@0: sl@0: TVerdict CFile0Step::doTestStepPreambleL() sl@0: { sl@0: CTe_fileSuiteStepBase::doTestStepPreambleL(); sl@0: sl@0: INFO_PRINTF1(_L("Connecting to file server")); sl@0: User::LeaveIfError(iFileServer.Connect()); sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict CFile0Step::doTestStepL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class pure virtual sl@0: * Our implementation only gets called if the base class doTestStepPreambleL() did sl@0: * not leave. That being the case, the current test result value will be EPass. sl@0: */ sl@0: { sl@0: if (TestStepResult()==EPass) sl@0: { sl@0: TestNewL(); sl@0: TestUnlockResourcesL(); sl@0: TestSettingsL(); sl@0: TestWriteL(); sl@0: sl@0: if(iErrors == 0) sl@0: SetTestStepResult(EPass); sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: TBuf<64> buf; sl@0: INFO_PRINTF1(_L("********")); sl@0: buf.AppendFormat(_L("%d errors were found!"), iErrors); sl@0: INFO_PRINTF1(buf); sl@0: INFO_PRINTF1(_L("********")); sl@0: } sl@0: } sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict CFile0Step::doTestStepPostambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: CTe_fileSuiteStepBase::doTestStepPostambleL(); sl@0: iFileServer.Close(); sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: }