author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:33:04 +0300 | |
branch | RCL_3 |
changeset 46 | ed95320285d0 |
parent 35 | 5f281e37a2f5 |
permissions | -rw-r--r-- |
35 | 1 |
/* |
2 |
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0"" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Implementation of class CDasClientApiTest |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
46
ed95320285d0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
20 |
#include <Stiftestinterface.h> |
35 | 21 |
#include <SettingServerClient.h> |
22 |
#include <ScreensaverInternalPSKeys.h> |
|
23 |
#include <e32property.h> |
|
24 |
||
25 |
#include "DasClientApiTest.h" |
|
26 |
||
27 |
// ============================ MEMBER FUNCTIONS =============================== |
|
28 |
||
29 |
// ----------------------------------------------------------------------------- |
|
30 |
// CDasClientApiTest::CDasClientApiTest |
|
31 |
// C++ default constructor can NOT contain any code, that |
|
32 |
// might leave. |
|
33 |
// ----------------------------------------------------------------------------- |
|
34 |
// |
|
35 |
CDasClientApiTest::CDasClientApiTest( CTestModuleIf& aTestModuleIf ): |
|
36 |
CScriptBase( aTestModuleIf ) |
|
37 |
{ |
|
38 |
} |
|
39 |
||
40 |
// ----------------------------------------------------------------------------- |
|
41 |
// CDasClientApiTest::ConstructL |
|
42 |
// Symbian 2nd phase constructor can leave. |
|
43 |
// ----------------------------------------------------------------------------- |
|
44 |
// |
|
45 |
void CDasClientApiTest::ConstructL() |
|
46 |
{ |
|
47 |
//Read logger settings to check whether test case name is to be |
|
48 |
//appended to log file name. |
|
49 |
RSettingServer settingServer; |
|
50 |
TInt ret = settingServer.Connect(); |
|
51 |
if(ret != KErrNone) |
|
52 |
{ |
|
53 |
User::Leave(ret); |
|
54 |
} |
|
55 |
// Struct to StifLogger settigs. |
|
56 |
TLoggerSettings loggerSettings; |
|
57 |
// Parse StifLogger defaults from STIF initialization file. |
|
58 |
ret = settingServer.GetLoggerSettings(loggerSettings); |
|
59 |
if(ret != KErrNone) |
|
60 |
{ |
|
61 |
User::Leave(ret); |
|
62 |
} |
|
63 |
// Close Setting server session |
|
64 |
settingServer.Close(); |
|
65 |
||
66 |
TFileName logFileName; |
|
67 |
||
68 |
if(loggerSettings.iAddTestCaseTitle) |
|
69 |
{ |
|
70 |
TName title; |
|
71 |
TestModuleIf().GetTestCaseTitleL(title); |
|
72 |
logFileName.Format(KDasClientApiTestLogFileWithTitle, &title); |
|
73 |
} |
|
74 |
else |
|
75 |
{ |
|
76 |
logFileName.Copy(KDasClientApiTestLogFile); |
|
77 |
} |
|
78 |
||
79 |
iLog = CStifLogger::NewL( KDasClientApiTestLogPath, |
|
80 |
logFileName, |
|
81 |
CStifLogger::ETxt, |
|
82 |
CStifLogger::EFile, |
|
83 |
EFalse ); |
|
84 |
||
85 |
SendTestClassVersion(); |
|
86 |
||
87 |
TurnOffScreenSaver(); |
|
88 |
} |
|
89 |
||
90 |
// ----------------------------------------------------------------------------- |
|
91 |
// CDasClientApiTest::NewL |
|
92 |
// Two-phased constructor. |
|
93 |
// ----------------------------------------------------------------------------- |
|
94 |
// |
|
95 |
CDasClientApiTest* CDasClientApiTest::NewL( CTestModuleIf& aTestModuleIf ) |
|
96 |
{ |
|
97 |
CDasClientApiTest* self = new( ELeave ) CDasClientApiTest( aTestModuleIf ); |
|
98 |
||
99 |
CleanupStack::PushL( self ); |
|
100 |
self->ConstructL(); |
|
101 |
CleanupStack::Pop(); |
|
102 |
||
103 |
return self; |
|
104 |
||
105 |
} |
|
106 |
||
107 |
// Destructor |
|
108 |
CDasClientApiTest::~CDasClientApiTest() |
|
109 |
{ |
|
110 |
||
111 |
// Delete resources allocated from test methods |
|
112 |
Delete(); |
|
113 |
||
114 |
// Delete logger |
|
115 |
delete iLog; |
|
116 |
||
117 |
} |
|
118 |
||
119 |
//----------------------------------------------------------------------------- |
|
120 |
// CDasClientApiTest::SendTestClassVersion |
|
121 |
// Method used to send version of test class |
|
122 |
//----------------------------------------------------------------------------- |
|
123 |
// |
|
124 |
void CDasClientApiTest::SendTestClassVersion() |
|
125 |
{ |
|
126 |
TVersion moduleVersion; |
|
127 |
moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
128 |
moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
129 |
moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
130 |
||
131 |
TFileName moduleName; |
|
132 |
moduleName = _L( "DasClientApiTest.dll" ); |
|
133 |
||
134 |
TBool newVersionOfMethod = ETrue; |
|
135 |
TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, |
|
136 |
newVersionOfMethod ); |
|
137 |
} |
|
138 |
||
139 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
140 |
||
141 |
// ----------------------------------------------------------------------------- |
|
142 |
// LibEntryL is a polymorphic Dll entry point. |
|
143 |
// Returns: CScriptBase: New CScriptBase derived object |
|
144 |
// ----------------------------------------------------------------------------- |
|
145 |
// |
|
146 |
EXPORT_C CScriptBase* LibEntryL( |
|
147 |
CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
148 |
{ |
|
149 |
return ( CScriptBase* ) CDasClientApiTest::NewL( aTestModuleIf ); |
|
150 |
} |
|
151 |
||
152 |
// ----------------------------------------------------------------------------- |
|
153 |
// Turn off ScreenSaver |
|
154 |
// ----------------------------------------------------------------------------- |
|
155 |
// |
|
156 |
void CDasClientApiTest::TurnOffScreenSaver() |
|
157 |
{ |
|
158 |
//TInt Get(TUid aCategory, TUint aKey, TInt &aValue); |
|
159 |
TInt err1 = RProperty::Get( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, |
|
160 |
iOldScreenSaverProperty ); |
|
161 |
TInt err2 = RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, |
|
162 |
KScreenSaverAllowScreenSaver ); |
|
163 |
RDebug::Printf( "screensaver property=%d err1=%d err2=%d\n", |
|
164 |
iOldScreenSaverProperty, err1, err2 ); |
|
165 |
} |
|
166 |
||
167 |
// ----------------------------------------------------------------------------- |
|
168 |
// Restore ScreenSaver |
|
169 |
// ----------------------------------------------------------------------------- |
|
170 |
// |
|
171 |
void CDasClientApiTest::RestoreScreenSaver() |
|
172 |
{ |
|
173 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, |
|
174 |
iOldScreenSaverProperty ); |
|
175 |
User::ResetInactivityTime(); |
|
176 |
} |
|
177 |
||
178 |
||
179 |
// End of File |
|
180 |
||
181 |