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