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