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