|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file UloggerServerTest2Step.cpp |
|
20 @internalTechnology |
|
21 */ |
|
22 #include "uloggerservertest2step.h" |
|
23 #include "te_uloggerservertestsuitedefs.h" |
|
24 #include "uloggerserver.h" |
|
25 #include "uloggersession.h" |
|
26 |
|
27 using namespace Ulogger; |
|
28 |
|
29 CUloggerServerTest2Step::~CUloggerServerTest2Step() |
|
30 /** |
|
31 * Destructor |
|
32 */ |
|
33 { |
|
34 } |
|
35 |
|
36 CUloggerServerTest2Step::CUloggerServerTest2Step() |
|
37 /** |
|
38 * Constructor |
|
39 */ |
|
40 { |
|
41 // **MUST** call SetTestStepName in the constructor as the controlling |
|
42 // framework uses the test step name immediately following construction to set |
|
43 // up the step's unique logging ID. |
|
44 SetTestStepName(KUloggerServerTest2Step); |
|
45 } |
|
46 |
|
47 TVerdict CUloggerServerTest2Step::doTestStepPreambleL() |
|
48 /** |
|
49 * @return - TVerdict code |
|
50 * Override of base class virtual |
|
51 */ |
|
52 { |
|
53 iScheduler = new (ELeave) CActiveScheduler(); |
|
54 CActiveScheduler::Install(iScheduler); |
|
55 |
|
56 SetTestStepResult(EPass); |
|
57 return TestStepResult(); |
|
58 } |
|
59 |
|
60 |
|
61 TVerdict CUloggerServerTest2Step::doTestStepL() |
|
62 { |
|
63 if (TestStepResult()==EPass) |
|
64 { |
|
65 TInt errors = 0; |
|
66 |
|
67 errors += Test1L();//CULoggerSession::NewL |
|
68 errors += Test2L();//CULoggerSession::NewLC |
|
69 |
|
70 |
|
71 |
|
72 /* |
|
73 * Method CULoggerSession::ServiceL cannot be tested here because it require |
|
74 * of passing RMessage2 reference with valid RMessagePtr (IPC) |
|
75 * If we are going to pass empty RMessage2 system will panic our process with |
|
76 * User Panic 70. |
|
77 * */ |
|
78 |
|
79 //display results |
|
80 TBuf<128> res; |
|
81 res.AppendFormat(_L("%d errors"), errors); |
|
82 INFO_PRINTF1(_L("****Results****")); |
|
83 INFO_PRINTF1(res); |
|
84 if(errors == 0) |
|
85 SetTestStepResult(EPass); |
|
86 else |
|
87 SetTestStepResult(EFail); |
|
88 } |
|
89 return TestStepResult(); |
|
90 } |
|
91 |
|
92 |
|
93 |
|
94 TVerdict CUloggerServerTest2Step::doTestStepPostambleL() |
|
95 /** |
|
96 * @return - TVerdict code |
|
97 * Override of base class virtual |
|
98 */ |
|
99 { |
|
100 delete iScheduler; |
|
101 iScheduler = NULL; |
|
102 return TestStepResult(); |
|
103 } |
|
104 |
|
105 TInt CUloggerServerTest2Step::Test1L() |
|
106 {//CULoggerSession::NewL |
|
107 TInt errors = 0; |
|
108 INFO_PRINTF1(_L("Testing - CULoggerSession::NewL method")); |
|
109 CULoggerServer *server = NULL; |
|
110 server = CULoggerServer::NewLC(EPriorityBackground); |
|
111 if(server != NULL) |
|
112 { |
|
113 RThread thread; |
|
114 CULoggerSession *serverSession = CULoggerSession::NewL(thread, *server); |
|
115 if(serverSession != NULL) |
|
116 { |
|
117 //delete serverSession; //don't need to delete session |
|
118 } |
|
119 else |
|
120 { |
|
121 INFO_PRINTF1(_L("error")); |
|
122 ++errors; |
|
123 } |
|
124 |
|
125 CleanupStack::PopAndDestroy(); |
|
126 } |
|
127 else |
|
128 { |
|
129 INFO_PRINTF1(_L("server creation error")); |
|
130 ++errors; |
|
131 } |
|
132 return errors; |
|
133 } |
|
134 |
|
135 TInt CUloggerServerTest2Step::Test2L() |
|
136 {//CULoggerSession::NewLC |
|
137 TInt errors = 0; |
|
138 INFO_PRINTF1(_L("Testing - CULoggerSession::NewLC method")); |
|
139 CULoggerServer *server = NULL; |
|
140 server = CULoggerServer::NewLC(EPriorityBackground); |
|
141 if(server != NULL) |
|
142 { |
|
143 RThread thread; |
|
144 CULoggerSession *serverSession = CULoggerSession::NewLC(thread, *server); |
|
145 if(serverSession != NULL) |
|
146 { |
|
147 CleanupStack::Pop();//serverSession |
|
148 } |
|
149 else |
|
150 { |
|
151 INFO_PRINTF1(_L("error")); |
|
152 ++errors; |
|
153 } |
|
154 |
|
155 CleanupStack::PopAndDestroy(); |
|
156 } |
|
157 else |
|
158 { |
|
159 INFO_PRINTF1(_L("server creation error")); |
|
160 ++errors; |
|
161 } |
|
162 return errors; |
|
163 } |