os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-outfrwkchans/te-file/uloggerfileplugintest.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-outfrwkchans/te-file/uloggerfileplugintest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,168 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "uloggerfileplugintest.h"
1.20 +#include "uloggerdatatypes.h"
1.21 +using namespace Ulogger;
1.22 +
1.23 +/*
1.24 + * TestNewL: Test that the NewL method correctly constructs a CFileWriter object
1.25 + *
1.26 + * Expected Verdict: PASS/FAIL/PANIC
1.27 + *
1.28 + * Prerequisites:
1.29 + *
1.30 + * Description: Invoke CFileWriter::NewL() and check that a non-NULL pointer is
1.31 + * returned.
1.32 + *
1.33 + */
1.34 +void CFile0Step::TestNewL()
1.35 + {
1.36 + CFileWriter* fileWriter = CFileWriter::NewL();
1.37 + INFO_PRINTF1(_L("Checking that pointer returned by CFileWriter::NewL() is not NULL"));
1.38 + ASSERT_NOT_NULL(fileWriter);
1.39 + delete fileWriter;
1.40 + }
1.41 +/*
1.42 + * TestUnlockResourcesL: Test that the CloseOutputPlugin method ???
1.43 + *
1.44 + * Expected Verdict: PASS/FAIL/PANIC
1.45 + *
1.46 + * Prerequisites:
1.47 + *
1.48 + * Description: Retrieve and print some data from an external ini data file
1.49 + *
1.50 + */
1.51 +void CFile0Step::TestUnlockResourcesL()
1.52 + {
1.53 + CFileWriter* fileWriter = CFileWriter::NewL();
1.54 + INFO_PRINTF1(_L("Invoking CFileWriter::CloseOutputPlugin(). CloseOutputPlugin() is supposed to do nothing."));
1.55 + fileWriter->CloseOutputPlugin();
1.56 + ASSERT_TRUE(ETrue);
1.57 + delete fileWriter;
1.58 + }
1.59 +
1.60 +/*
1.61 + * TestSettingsL: Test that the Settings method ???
1.62 + *
1.63 + * Expected Verdict: PASS/FAIL/PANIC
1.64 + *
1.65 + * Prerequisites:
1.66 + *
1.67 + * Description: Retrieve and print some data from an external ini data file
1.68 + *
1.69 + */
1.70 +void CFile0Step::TestSettingsL()
1.71 + {
1.72 + CFileWriter* fileWriter = CFileWriter::NewL();
1.73 + INFO_PRINTF1(_L("Passing empty RPointerArray to CFileWriter::ConfigureOutputPlugin()"));
1.74 + RPointerArray<TPluginConfiguration> emptyPointerArray;
1.75 + fileWriter->ConfigureOutputPlugin(emptyPointerArray);
1.76 +
1.77 + delete fileWriter;
1.78 + }
1.79 +
1.80 +/*
1.81 + * TestWriteL: Test that the Write method ???
1.82 + *
1.83 + * Expected Verdict: PASS/FAIL/PANIC
1.84 + *
1.85 + * Prerequisites:
1.86 + *
1.87 + * Description: Invoke CFileWriter::Write() and check that test string is
1.88 + * written to KLogDefaultFileName correctly.
1.89 + *
1.90 + */
1.91 +// The implementation for this is not working correctly! Check this
1.92 +void CFile0Step::TestWriteL()
1.93 + {
1.94 + INFO_PRINTF1(_L("Checking that CFileWriter::Write(const TDesC8&) writes a String correctly to C:\\logs\\log.txt"));
1.95 +
1.96 + // Create new CFileWriter instance
1.97 + CFileWriter* fileWriter = CFileWriter::NewL();
1.98 + _LIT8(KTxt, "Test");
1.99 + INFO_PRINTF1(_L("Writing 'Test' to the log using CFileWriter::Write()"));
1.100 + ASSERT_EQUALS(KErrNone, fileWriter->Write(KTxt));
1.101 +
1.102 + delete fileWriter;
1.103 + }
1.104 +
1.105 +
1.106 +CFile0Step::~CFile0Step()
1.107 + {
1.108 + }
1.109 +
1.110 +CFile0Step::CFile0Step()
1.111 +/**
1.112 + * Constructor
1.113 + */
1.114 + {
1.115 + // **MUST** call SetTestStepName in the constructor as the controlling
1.116 + // framework uses the test step name immediately following construction to set
1.117 + // up the step's unique logging ID.
1.118 + SetTestStepName(KFile0Step);
1.119 + }
1.120 +
1.121 +TVerdict CFile0Step::doTestStepPreambleL()
1.122 + {
1.123 + CTe_fileSuiteStepBase::doTestStepPreambleL();
1.124 +
1.125 + INFO_PRINTF1(_L("Connecting to file server"));
1.126 + User::LeaveIfError(iFileServer.Connect());
1.127 + SetTestStepResult(EPass);
1.128 + return TestStepResult();
1.129 + }
1.130 +
1.131 +TVerdict CFile0Step::doTestStepL()
1.132 +/**
1.133 + * @return - TVerdict code
1.134 + * Override of base class pure virtual
1.135 + * Our implementation only gets called if the base class doTestStepPreambleL() did
1.136 + * not leave. That being the case, the current test result value will be EPass.
1.137 + */
1.138 + {
1.139 + if (TestStepResult()==EPass)
1.140 + {
1.141 + TestNewL();
1.142 + TestUnlockResourcesL();
1.143 + TestSettingsL();
1.144 + TestWriteL();
1.145 +
1.146 + if(iErrors == 0)
1.147 + SetTestStepResult(EPass);
1.148 + else
1.149 + {
1.150 + SetTestStepResult(EFail);
1.151 + TBuf<64> buf;
1.152 + INFO_PRINTF1(_L("********"));
1.153 + buf.AppendFormat(_L("%d errors were found!"), iErrors);
1.154 + INFO_PRINTF1(buf);
1.155 + INFO_PRINTF1(_L("********"));
1.156 + }
1.157 + }
1.158 + return TestStepResult();
1.159 + }
1.160 +
1.161 +TVerdict CFile0Step::doTestStepPostambleL()
1.162 +/**
1.163 + * @return - TVerdict code
1.164 + * Override of base class virtual
1.165 + */
1.166 + {
1.167 + CTe_fileSuiteStepBase::doTestStepPostambleL();
1.168 + iFileServer.Close();
1.169 + SetTestStepResult(EPass);
1.170 + return TestStepResult();
1.171 + }