os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-server/uloggerservertest0step.cpp
Update contrib.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Example CTestStep derived implementation
19 @file UloggerServerTest0Step.cpp
22 #include "uloggerservertest0step.h"
23 #include "te_uloggerservertestsuitedefs.h"
24 #include "uloggerwatcher.h"
28 CUloggerServerTest0Step::~CUloggerServerTest0Step()
35 CUloggerServerTest0Step::CUloggerServerTest0Step()
40 // **MUST** call SetTestStepName in the constructor as the controlling
41 // framework uses the test step name immediately following construction to set
42 // up the step's unique logging ID.
43 SetTestStepName(KUloggerServerTest0Step);
46 TVerdict CUloggerServerTest0Step::doTestStepPreambleL()
48 * @return - TVerdict code
49 * Override of base class virtual
52 INFO_PRINTF1(_L("****This is unit test for CULoggerWatcher class****"));
54 INFO_PRINTF1(_L("************************************************"));
55 INFO_PRINTF1(_L("Note: To test CUloggerServer properly we must:"));
56 INFO_PRINTF1(_L("- change UID3 for our test unit as we need access to server private directory"));
57 INFO_PRINTF1(_L("************************************************"));
60 iScheduler = new (ELeave) CActiveScheduler();
61 CActiveScheduler::Install(iScheduler);
63 SetTestStepResult(EPass);
64 return TestStepResult();
68 TVerdict CUloggerServerTest0Step::doTestStepL()
70 * @return - TVerdict code
71 * Override of base class pure virtual
72 * Our implementation only gets called if the base class doTestStepPreambleL() did
73 * not leave. That being the case, the current test result value will be EPass.
77 if (TestStepResult()==EPass)
79 iErrors += this->Test1L();//CULoggerWatcher::NewL
80 iErrors += this->Test2L();//CULoggerWatcher::NewLC
81 iErrors += this->Test3L();//CULoggerWatcher::StartWatching
82 iErrors += this->Test4L();//CULoggerWatcher::StopWatching
83 iErrors += this->Test5L();//CULoggerWatcher::RunL
88 res.AppendFormat(_L("%d errors"), iErrors);
89 INFO_PRINTF1(_L("****Results****"));
92 SetTestStepResult(EPass);
94 SetTestStepResult(EFail);
97 return TestStepResult();
102 TVerdict CUloggerServerTest0Step::doTestStepPostambleL()
104 * @return - TVerdict code
105 * Override of base class virtual
110 return TestStepResult();
114 TInt CUloggerServerTest0Step::Test1L()
117 INFO_PRINTF1(_L("Testing - CULoggerWatcher::NewL method"));
118 CULoggerWatcher *obj = CULoggerWatcher::NewL();
121 INFO_PRINTF1(_L("error"));
132 TInt CUloggerServerTest0Step::Test2L()
135 //CULoggerWatcher::NewLC
136 INFO_PRINTF1(_L("Testing - CULoggerWatcher::NewLC method"));
137 CULoggerWatcher *obj = CULoggerWatcher::NewLC();
140 INFO_PRINTF1(_L("error"));
144 CleanupStack::PopAndDestroy();
148 TInt CUloggerServerTest0Step::Test3L()
151 //CULoggerWatcher::StartWatching
152 INFO_PRINTF1(_L("Testing - CULoggerWatcher::StartWatching method"));
153 CULoggerWatcher *obj = CULoggerWatcher::NewL();
155 * We need to create service provider for active object (RTimer is good choice)
159 timer.After(obj->GetStatus(), 2*1000*1000);
160 obj->StartWatching(this);
163 if(obj->GetStatus().Int() != KErrNone)
165 INFO_PRINTF1(_L("error"));
172 TInt CUloggerServerTest0Step::Test4L()
175 //CULoggerWatcher::StopWatching
176 INFO_PRINTF1(_L("Testing - CULoggerWatcher::StopWatching method"));
177 CULoggerWatcher *obj = CULoggerWatcher::NewL();
180 timer.After(obj->GetStatus(), 2*1000*1000);
181 obj->StartWatching(this);
185 buf.AppendFormat(_L("Result of Stopping: %d"), obj->GetStatus().Int());
187 if(obj->GetStatus().Int() != KErrNone)
189 INFO_PRINTF1(_L("error"));
197 TInt CUloggerServerTest0Step::Test5L()
200 //CULoggerWatcher::RunL
201 INFO_PRINTF1(_L("Testing - CULoggerWatcher::RunL method"));
202 CULoggerWatcher *obj = CULoggerWatcher::NewL();
205 timer.After(obj->GetStatus(), 2*1000*1000);
206 obj->StartWatching(this); //CULogger watcher must have observer initialized
207 //becouse testing null pointer is not allowed
210 TRAPD(err, obj->RunL());
213 INFO_PRINTF1(_L("error"));