|
1 /* |
|
2 * Copyright (c) 2002 - 2007 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: functions implement of testalfext |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <stiftestinterface.h> |
|
22 #include <settingserverclient.h> |
|
23 #include <screensaverinternalpskeys.h> |
|
24 #include <e32property.h> |
|
25 #include <eikenv.h> |
|
26 #include <coemain.h> |
|
27 #include "testalfext.h" |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT( KModuleName, "testalfext.dll" ); |
|
31 const TInt KHuiCtrlGroupId = 1; |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CTestAlfExt::CTestAlfExt |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CTestAlfExt::CTestAlfExt( CTestModuleIf& aTestModuleIf ): |
|
41 CScriptBase( aTestModuleIf ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CTestAlfExt::~CTestAlfExt |
|
47 // Destructor. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CTestAlfExt::~CTestAlfExt() |
|
51 { |
|
52 // Delete logger |
|
53 delete iLog; |
|
54 delete iInterface; |
|
55 delete iHuiEnv; |
|
56 |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CTestAlfExt::ConstructL |
|
61 // Symbian 2nd phase constructor can leave. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CTestAlfExt::ConstructL() |
|
65 { |
|
66 //Read logger settings to check whether test case name is to be |
|
67 //appended to log file name. |
|
68 RSettingServer settingServer; |
|
69 CleanupClosePushL( settingServer ); |
|
70 TInt ret = settingServer.Connect(); |
|
71 if ( ret != KErrNone ) |
|
72 { |
|
73 User::Leave(ret); |
|
74 } |
|
75 // Struct to StifLogger settigs. |
|
76 TLoggerSettings loggerSettings; |
|
77 // Parse StifLogger defaults from STIF initialization file. |
|
78 ret = settingServer.GetLoggerSettings( loggerSettings ); |
|
79 if ( ret != KErrNone ) |
|
80 { |
|
81 User::Leave( ret ); |
|
82 } |
|
83 // Close Setting server session |
|
84 settingServer.Close(); |
|
85 CleanupStack::PopAndDestroy( &settingServer ); |
|
86 |
|
87 TFileName logFileName; |
|
88 |
|
89 if ( loggerSettings.iAddTestCaseTitle ) |
|
90 { |
|
91 TName title; |
|
92 TestModuleIf().GetTestCaseTitleL( title ); |
|
93 logFileName.Format( KtestalfextLogFileWithTitle, &title ); |
|
94 } |
|
95 else |
|
96 { |
|
97 logFileName.Copy( KtestalfextLogFile ); |
|
98 } |
|
99 |
|
100 iLog = CStifLogger::NewL( KtestalfextLogPath, |
|
101 logFileName, |
|
102 CStifLogger::ETxt, |
|
103 CStifLogger::EFile, |
|
104 EFalse ); |
|
105 |
|
106 iInterface = new ( ELeave ) |
|
107 CTestAlfInterfacePorvider; |
|
108 |
|
109 iHuiEnv = CHuiEnv::NewL( EHuiRendererBitgdi ); |
|
110 iHuiControlGroup = &( iHuiEnv->NewControlGroupL( KHuiCtrlGroupId ) ); |
|
111 //Construct the iHuiControl |
|
112 iHuiControl = new( ELeave ) CHuiControl( *iHuiEnv ); |
|
113 iHuiControl->ConstructL(); |
|
114 iHuiControlGroup->AppendL( iHuiControl ); |
|
115 iHuiVisual = CHuiVisual::AddNewL( *iHuiControl); |
|
116 |
|
117 SendTestClassVersion(); |
|
118 |
|
119 TurnOffScreenSaver(); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CTestAlfExt::NewL |
|
124 // Two-phased constructor. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 CTestAlfExt* CTestAlfExt::NewL( CTestModuleIf& aTestModuleIf ) |
|
128 { |
|
129 CTestAlfExt* self = new( ELeave ) CTestAlfExt( aTestModuleIf ); |
|
130 |
|
131 CleanupStack::PushL( self ); |
|
132 self->ConstructL(); |
|
133 CleanupStack::Pop( self ); |
|
134 |
|
135 return self; |
|
136 |
|
137 } |
|
138 |
|
139 //----------------------------------------------------------------------------- |
|
140 // CTestAlfExt::SendTestClassVersion |
|
141 // Method used to send version of test class |
|
142 //----------------------------------------------------------------------------- |
|
143 // |
|
144 void CTestAlfExt::SendTestClassVersion() |
|
145 { |
|
146 TVersion moduleVersion; |
|
147 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
148 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
149 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
150 |
|
151 TFileName moduleName; |
|
152 moduleName = KModuleName; |
|
153 |
|
154 TBool newVersionOfMethod = ETrue; |
|
155 TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, |
|
156 newVersionOfMethod ); |
|
157 } |
|
158 |
|
159 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // LibEntryL is a polymorphic Dll entry point. |
|
163 // Returns: CScriptBase: New CScriptBase derived object |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C CScriptBase* LibEntryL( |
|
167 CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
168 { |
|
169 return ( CScriptBase* ) CTestAlfExt::NewL( aTestModuleIf ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // Turn off ScreenSaver |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CTestAlfExt::TurnOffScreenSaver() |
|
177 { |
|
178 TInt err1 = RProperty::Get( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, |
|
179 iOldScreenSaverProperty ); |
|
180 TInt err2 = RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, |
|
181 KScreenSaverAllowScreenSaver ); |
|
182 RDebug::Printf( "screensaver property=%d err1=%d err2=%d\n", |
|
183 iOldScreenSaverProperty, err1, err2 ); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // Restore ScreenSaver |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 void CTestAlfExt::RestoreScreenSaver() |
|
191 { |
|
192 RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, |
|
193 iOldScreenSaverProperty ); |
|
194 User::ResetInactivityTime(); |
|
195 } |
|
196 |
|
197 |
|
198 // End of File |