os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-server/uloggerservertest3step.cpp
Update contrib.
1 // Copyright (c) 2007-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.
17 @file UloggerServerTest3Step.cpp
22 #include "uloggerservertest3step.h"
23 #include "te_uloggerservertestsuitedefs.h"
24 #include "uloggerwatcher.h"
25 #include "pluginallocator.h"
28 CUloggerServerTest3Step::~CUloggerServerTest3Step()
35 CUloggerServerTest3Step::CUloggerServerTest3Step()
40 SetTestStepName(KUloggerServerTest3Step);
43 TVerdict CUloggerServerTest3Step::doTestStepPreambleL()
45 * @return - TVerdict code
46 * Override of base class virtual
49 INFO_PRINTF1(_L("****This is unit test for CPluginAllocator class****"));
52 iScheduler = new (ELeave) CActiveScheduler();
53 CActiveScheduler::Install(iScheduler);
55 SetTestStepResult(EPass);
56 return TestStepResult();
60 TVerdict CUloggerServerTest3Step::doTestStepL()
62 * @return - TVerdict code
63 * Override of base class pure virtual
64 * Our implementation only gets called if the base class doTestStepPreambleL() did
65 * not leave. That being the case, the current test result value will be EPass.
69 if (TestStepResult()==EPass)
72 iErrors += this->Test1L();//CPluginAllocator::NewL, GetOutputPlugin, GetControlPlugin
73 iErrors += this->Test1_2L();//CPluginAllocator::NewL.... - condition 2
74 iErrors += this->Test2L();//CPluginAllocator::NewLC
75 iErrors += this->Test1_3L(); //CPluginAllocator::NewL - condition 3
76 iErrors += this->Test1_4L(); //CPluginAllocator::NewL - condition 4
80 res.AppendFormat(_L("%d errors"), iErrors);
81 INFO_PRINTF1(_L("****Results****"));
84 SetTestStepResult(EPass);
86 SetTestStepResult(EFail);
89 return TestStepResult();
94 TVerdict CUloggerServerTest3Step::doTestStepPostambleL()
96 * @return - TVerdict code
97 * Override of base class virtual
102 return TestStepResult();
106 TInt CUloggerServerTest3Step::Test1L()
110 INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 1"));
111 CPluginAllocator *obj = CPluginAllocator::NewL(KFileTestPlugin(), KNullTestPlugin());
114 INFO_PRINTF1(_L("error"));
119 MOutputPlugin* output = obj->GetOutputPlugin(); //should exists
120 MInputPlugin* input = obj->GetInputPlugin(); //should not exists
132 TInt CUloggerServerTest3Step::Test1_2L()
136 INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 2"));
137 CPluginAllocator *obj = NULL;
138 obj = CPluginAllocator::NewL(KNullTestPlugin(), KNullTestPlugin());
147 INFO_PRINTF1(_L("error - obj not exists!"));
154 TInt CUloggerServerTest3Step::Test1_3L()
158 INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 3"));
159 CPluginAllocator *obj = NULL;
160 TRAPD(err, obj = CPluginAllocator::NewL(KFileTestPlugin(), KUsbTestPlugin()));
161 if(obj && err==KErrNone)
163 MOutputPlugin* output = obj->GetOutputPlugin(); //should exists
164 MInputPlugin* input = obj->GetInputPlugin(); //does not matter
173 INFO_PRINTF1(_L("plugin allocator not create. probably there is no usb plugin."));
180 TInt CUloggerServerTest3Step::Test1_4L()
184 INFO_PRINTF1(_L("Testing - CPluginAllocator::NewL method - condition 4"));
185 CPluginAllocator *obj = NULL;
187 TRAPD(errCode, obj=CPluginAllocator::NewL(KFileTestPlugin(), KBadNameTestPlugin()));
188 if(errCode == KErrNone)
191 INFO_PRINTF1(_L("error - method should leave!"));
196 INFO_PRINTF1(_L("error - obj should not exist!"));
205 TInt CUloggerServerTest3Step::Test2L()
209 INFO_PRINTF1(_L("Testing - CPluginAllocator::NewLC method"));
210 CPluginAllocator *obj = CPluginAllocator::NewLC(KFileTestPlugin(), KNullTestPlugin());
213 INFO_PRINTF1(_L("error"));
218 MOutputPlugin* output = obj->GetOutputPlugin(); //should exists
219 MInputPlugin* input = obj->GetInputPlugin(); //should not exists
222 INFO_PRINTF1(_L("error"));
227 CleanupStack::PopAndDestroy(); //obj