1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth10/TSU_MmTsth10.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,224 @@
1.4 +// Copyright (c) 2002-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 +// This file contains the test steps for Unit Test Suite 10 : Log.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +// EPOC includes
1.22 +#include <e32base.h>
1.23 +
1.24 +// Test system includes
1.25 +#include <testframework.h>
1.26 +
1.27 +// Specific includes for this test suite
1.28 +#include "TSU_MmTsthSuite10.h"
1.29 +
1.30 +// Specific includes for these test steps
1.31 +#include "TSU_MmTsth10.h"
1.32 +
1.33 +// --------------------------------------------
1.34 +
1.35 +// Unit Test Suite 10 : Log.cpp
1.36 +// Depends on : none
1.37 +
1.38 +// Tests :-
1.39 +// 1 RTestFrameworkClientSession : check connect
1.40 +// 11 Log : create
1.41 +// 12 Log : open log file (existing)
1.42 +// 13 Log : write format - no test specified as this is called every time the INFO_PRINTF or ERR_PRINTF
1.43 +// macro is called by the framework or suite(s)
1.44 +// 14 Log : status (incorporated in test 12)
1.45 +
1.46 +// ---------------------
1.47 +// RTestMmTsthU1001
1.48 +
1.49 +RTestMmTsthU1001* RTestMmTsthU1001::NewL()
1.50 + {
1.51 + RTestMmTsthU1001* self = new(ELeave) RTestMmTsthU1001;
1.52 + return self;
1.53 + }
1.54 +
1.55 +// Each test step initialises its own name.
1.56 +RTestMmTsthU1001::RTestMmTsthU1001()
1.57 + {
1.58 + iTestStepName = _L("MM-TSTH-U-1001");
1.59 + }
1.60 +
1.61 +// Do the test step.
1.62 +TVerdict RTestMmTsthU1001::DoTestStepL()
1.63 + {
1.64 + INFO_PRINTF1(_L("Unit test for RTestFrameworkServerSession"));
1.65 +
1.66 + // Check we can connect to the existing server.
1.67 + // NB - open, write, close, status will be called by Log tests
1.68 +
1.69 + TVerdict currentVerdict = EPass;
1.70 +
1.71 + TInt ret;
1.72 + RTestFrameworkClientSession testSession;
1.73 + ret = testSession.Connect();
1.74 + if(ret != KErrNone)
1.75 + {
1.76 + ERR_PRINTF2(_L("Could not connect to server, error %d"), ret);
1.77 + return iTestStepResult = EFail;
1.78 + }
1.79 +
1.80 + INFO_PRINTF1(_L("Successfully connected to server with a new session"));
1.81 +
1.82 + testSession.Close(); // cleanup session
1.83 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.84 + }
1.85 +
1.86 +// ---------------------
1.87 +// RTestMmTsthU1011
1.88 +
1.89 +RTestMmTsthU1011* RTestMmTsthU1011::NewL()
1.90 + {
1.91 + RTestMmTsthU1011* self = new(ELeave) RTestMmTsthU1011;
1.92 + return self;
1.93 + }
1.94 +
1.95 +// Each test step initialises its own name.
1.96 +RTestMmTsthU1011::RTestMmTsthU1011()
1.97 + {
1.98 + iTestStepName = _L("MM-TSTH-U-1011");
1.99 + }
1.100 +
1.101 +// Do the test step.
1.102 +TVerdict RTestMmTsthU1011::DoTestStepL()
1.103 + {
1.104 + INFO_PRINTF1(_L("Unit test for Log : create"));
1.105 +
1.106 + TVerdict currentVerdict = EPass;
1.107 +
1.108 + CLog* theLog = NULL;
1.109 + TRAPD(err, theLog = CLog::NewL());
1.110 + if(err != KErrNone)
1.111 + {
1.112 + ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
1.113 + return iTestStepResult = EFail;
1.114 + }
1.115 +
1.116 + INFO_PRINTF1(_L("CLog created successfully"));
1.117 + delete theLog;
1.118 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.119 + }
1.120 +
1.121 +// ---------------------
1.122 +// RTestMmTsthU1012
1.123 +
1.124 +RTestMmTsthU1012* RTestMmTsthU1012::NewL()
1.125 + {
1.126 + RTestMmTsthU1012* self = new(ELeave) RTestMmTsthU1012;
1.127 + return self;
1.128 + }
1.129 +
1.130 +// Each test step initialises its own name.
1.131 +RTestMmTsthU1012::RTestMmTsthU1012()
1.132 + {
1.133 + iTestStepName = _L("MM-TSTH-U-1012");
1.134 + }
1.135 +
1.136 +// Do the test step.
1.137 +TVerdict RTestMmTsthU1012::DoTestStepL()
1.138 +{
1.139 + INFO_PRINTF1(_L("Unit test for Log : open"));
1.140 +
1.141 + TVerdict currentVerdict = EPass;
1.142 +
1.143 + CLog* theLog = NULL;
1.144 + TRAPD(err, theLog = CLog::NewL());
1.145 + if(err != KErrNone)
1.146 + {
1.147 + ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
1.148 + return iTestStepResult = EInconclusive;
1.149 + }
1.150 +
1.151 + // Open the current logfile (it's already open at the server)
1.152 + TRAP(err, theLog->OpenLogFileL());
1.153 + if(err != KErrNone)
1.154 + {
1.155 + ERR_PRINTF2(_L("CLog::OpenLogFileL() left, error code %d"), err);
1.156 + delete theLog;
1.157 + return iTestStepResult = EFail;
1.158 + }
1.159 +
1.160 + // Attempt to open a new log file. This will complete without opening the log file and
1.161 + // without disturbing the server; we can
1.162 + // ascertain this by checking the log status, which will be unchanged.
1.163 + TInt theStatus = theLog->LogStatus();
1.164 + delete theLog;
1.165 + theLog = NULL;
1.166 +
1.167 + _LIT(KDummyLogName, "DummyLog");
1.168 + TRAP(err, theLog = CLog::NewL());
1.169 + if(err != KErrNone)
1.170 + {
1.171 + ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
1.172 + return iTestStepResult = EInconclusive;
1.173 + }
1.174 +
1.175 + TRAP(err, theLog->OpenLogFileL(KDummyLogName, theStatus - 1));
1.176 + if(err != KErrNone)
1.177 + {
1.178 + ERR_PRINTF2(_L("CLog::OpenLogFileL(KDummyLogName) left, error code %d"), err);
1.179 + delete theLog;
1.180 + return iTestStepResult = EFail;
1.181 + }
1.182 +
1.183 + TInt theNewStatus = theLog->LogStatus();
1.184 + if(theNewStatus != theStatus)
1.185 + {
1.186 + ERR_PRINTF1(_L("CLog::OpenLogFileL(KDummyLogName) changed log status!"));
1.187 + delete theLog;
1.188 + return iTestStepResult = EFail;
1.189 + }
1.190 +
1.191 + // NB no test for CloseLogFileL - as this acts at the server and is something we only ever
1.192 + // want to do at the end of the TestFramework run
1.193 +
1.194 + INFO_PRINTF1(_L("CLog opened existing log file successfully"));
1.195 + delete theLog;
1.196 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.197 + }
1.198 +
1.199 +// ---------------------
1.200 +// RTestMmTsthU1013
1.201 +
1.202 +RTestMmTsthU1013* RTestMmTsthU1013::NewL()
1.203 + {
1.204 + RTestMmTsthU1013* self = new(ELeave) RTestMmTsthU1013;
1.205 + return self;
1.206 + }
1.207 +
1.208 +// Each test step initialises its own name.
1.209 +RTestMmTsthU1013::RTestMmTsthU1013()
1.210 + {
1.211 + iTestStepName = _L("MM-TSTH-U-1013");
1.212 + }
1.213 +
1.214 +// Do the test step.
1.215 +TVerdict RTestMmTsthU1013::DoTestStepL()
1.216 +{
1.217 + INFO_PRINTF1(_L("Unit test for Log : write format"));
1.218 +
1.219 + TVerdict currentVerdict = EPass;
1.220 +
1.221 + // any call to LogExtra will test this. if it doesn't crash, consider it passed
1.222 +
1.223 + INFO_PRINTF1(_L("Testing WriteFormat..."));
1.224 +
1.225 + return iTestStepResult = currentVerdict;
1.226 + }
1.227 +