sl@0: // Copyright (c) 2004-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 "uloggerserialplugintest.h" sl@0: #include "uloggerdatatypes.h" sl@0: using namespace Ulogger; sl@0: sl@0: sl@0: /* sl@0: * TestNewL: Test that the NewL method correctly constructs a CSerialWriter object sl@0: * sl@0: * Expected Verdict: PASS/FAIL/PANIC sl@0: * sl@0: * Prerequisites: sl@0: * sl@0: * Description: Invoke CSerialWriter::NewL() and check that a non-NULL pointer is sl@0: * returned. sl@0: * sl@0: */ sl@0: void CSerial0Step::TestNewL() sl@0: { sl@0: Ulogger::CSerialWriter* serialWriter = Ulogger::CSerialWriter::NewL(); sl@0: INFO_PRINTF1(_L("Checking that pointer returned by CSerialWriter::NewL() is not NULL")); sl@0: ASSERT_NOT_NULL(serialWriter); sl@0: delete serialWriter; sl@0: } sl@0: sl@0: /* sl@0: * TestNewL: 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 CSerial0Step::TestUnlockResourcesL() sl@0: { sl@0: Ulogger::CSerialWriter* serialWriter = Ulogger::CSerialWriter::NewL(); sl@0: INFO_PRINTF1(_L("Invoking CSerialWriter::CloseOutputPlugin(). CloseOutputPlugin() is supposed to do nothing.")); sl@0: serialWriter->CloseOutputPlugin(); sl@0: ASSERT_TRUE(ETrue); sl@0: delete serialWriter; sl@0: } sl@0: sl@0: /* sl@0: * TestNewL: 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 CSerial0Step::TestSettingsL() sl@0: { sl@0: Ulogger::CSerialWriter* serialWriter = Ulogger::CSerialWriter::NewL(); sl@0: INFO_PRINTF1(_L("Passing empty RPointerArray to CSerialWriter::ConfigureOutputPlugin()")); sl@0: RPointerArray emptyPointerArray; sl@0: serialWriter->ConfigureOutputPlugin(emptyPointerArray); sl@0: sl@0: // sl@0: // Need More thorough testing of CSerialWriter::ConfigureOutputPlugin() sl@0: // sl@0: sl@0: delete serialWriter; sl@0: } sl@0: sl@0: /* sl@0: * TestNewL: 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 CSerialWriter::Write() and check that test string is sl@0: * written to KLogDefaultSerialName correctly. sl@0: * sl@0: */ sl@0: // The implementation for this is not working correctly! Check this sl@0: void CSerial0Step::TestWriteL() sl@0: { sl@0: INFO_PRINTF1(_L("Checking that CSerialWriter::Write(const TDesC8&) writes a string correctly to the serial port")); sl@0: sl@0: // Create new CSerialWriter instance and write a test string to it sl@0: Ulogger::CSerialWriter* serialWriter = Ulogger::CSerialWriter::NewL(); sl@0: _LIT8(KTxt, "Test"); sl@0: INFO_PRINTF1(_L("Writing 'Test' to the log using CSerialWriter::Write()")); sl@0: ASSERT_EQUALS(KErrNone, serialWriter->Write(KTxt)); sl@0: sl@0: // sl@0: // More thorough testing of CSerialWriter::Write() sl@0: // sl@0: sl@0: // Destroy CSerialWriter instance sl@0: delete serialWriter; sl@0: } sl@0: sl@0: sl@0: sl@0: CSerial0Step::~CSerial0Step() sl@0: { sl@0: } sl@0: sl@0: CSerial0Step::CSerial0Step() 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(KSerial0Step); sl@0: } sl@0: sl@0: TVerdict CSerial0Step::doTestStepPreambleL() sl@0: { sl@0: CTe_serialSuiteStepBase::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 CSerial0Step::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 CSerial0Step::doTestStepPostambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: CTe_serialSuiteStepBase::doTestStepPostambleL(); sl@0: iFileServer.Close(); sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: