|
1 /* |
|
2 * Copyright (c) 2010 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: This file contains testclass implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // [INCLUDE FILES] - do not remove |
|
19 #include <e32svr.h> |
|
20 #include <StifParser.h> |
|
21 #include <StifTestInterface.h> |
|
22 #include <systemtoneservice.h> |
|
23 #include "systemtoneservicestif.h" |
|
24 |
|
25 |
|
26 |
|
27 TInt CSystemToneServiceStif::RunMethodL(CStifItemParser& aItem ) |
|
28 { |
|
29 |
|
30 static TStifFunctionInfo const KFunctions[] = |
|
31 { |
|
32 // Copy this line for every implemented function. |
|
33 // First string is the function name used in TestScripter script file. |
|
34 // Second is the actual implementation member function. |
|
35 ENTRY( "Create", CSystemToneServiceStif::CreateSystemToneService ), |
|
36 ENTRY( "Delete", CSystemToneServiceStif::DeleteSystemToneService ), |
|
37 ENTRY( "PlayTone", CSystemToneServiceStif::PlaySystemToneService ), |
|
38 ENTRY( "PlayToneWithContext", CSystemToneServiceStif::PlaySystemToneServiceWithContext ), |
|
39 ENTRY( "StopTone", CSystemToneServiceStif::StopSystemToneService ), |
|
40 |
|
41 |
|
42 |
|
43 }; |
|
44 |
|
45 const TInt count = sizeof( KFunctions ) / |
|
46 sizeof( TStifFunctionInfo ); |
|
47 |
|
48 return RunInternalL( KFunctions, count, aItem ); |
|
49 |
|
50 } |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 void CSystemToneServiceStif::Delete() |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CSystemToneServiceStif::ExampleL |
|
65 // Example test method function. |
|
66 // (other items were commented in a header). |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 TInt CSystemToneServiceStif::ExampleL( CStifItemParser& aItem ) |
|
70 { |
|
71 |
|
72 // Print to UI |
|
73 _LIT( Ksystemtoneservicestif, "systemtoneservicestif" ); |
|
74 _LIT( KExample, "In Example" ); |
|
75 TestModuleIf().Printf( 0, Ksystemtoneservicestif, KExample ); |
|
76 // Print to log file |
|
77 iLog->Log( KExample ); |
|
78 |
|
79 TInt i = 0; |
|
80 TPtrC string; |
|
81 _LIT( KParam, "Param[%i]: %S" ); |
|
82 while ( aItem.GetNextString ( string ) == KErrNone ) |
|
83 { |
|
84 TestModuleIf().Printf( i, Ksystemtoneservicestif, |
|
85 KParam, i, &string ); |
|
86 i++; |
|
87 } |
|
88 |
|
89 return KErrNone; |
|
90 |
|
91 } |
|
92 |
|
93 TInt CSystemToneServiceStif::CreateSystemToneService( ) |
|
94 { |
|
95 // Print to UI |
|
96 _LIT( Ksystemtoneservicestif, "systemtoneservicestif" ); |
|
97 _LIT( KPrint, "In CreateSystemToneService" ); |
|
98 TestModuleIf().Printf( 0, Ksystemtoneservicestif, KPrint ); |
|
99 // Print to log file |
|
100 iLog->Log( KPrint ); |
|
101 |
|
102 iSts = CSystemToneService::Create(); |
|
103 |
|
104 iLog->Log(_L("CreateSystemToneService complete")); |
|
105 return KErrNone; |
|
106 } |
|
107 |
|
108 TInt CSystemToneServiceStif::DeleteSystemToneService( ) |
|
109 { |
|
110 // Print to UI |
|
111 _LIT( Ksystemtoneservicestif, "systemtoneservicestif" ); |
|
112 _LIT( KPrint, "In DeleteSystemToneService" ); |
|
113 TestModuleIf().Printf( 0, Ksystemtoneservicestif, KPrint ); |
|
114 // Print to log file |
|
115 iLog->Log( KPrint ); |
|
116 |
|
117 CSystemToneService::Delete(iSts); |
|
118 return KErrNone; |
|
119 } |
|
120 |
|
121 |
|
122 TInt CSystemToneServiceStif::PlaySystemToneService( CStifItemParser& aItem ) |
|
123 { |
|
124 // Print to UI |
|
125 _LIT( Ksystemtoneservicestif, "systemtoneservicestif" ); |
|
126 _LIT( KPrint, "In PlaySystemToneService" ); |
|
127 TestModuleIf().Printf( 0, Ksystemtoneservicestif, KPrint ); |
|
128 // Print to log file |
|
129 iLog->Log( KPrint ); |
|
130 |
|
131 TInt lRetVal = KErrNone; |
|
132 TInt toneType = 0; |
|
133 |
|
134 lRetVal = aItem.GetNextInt(toneType); |
|
135 |
|
136 if ( lRetVal != KErrNone ) |
|
137 { |
|
138 iLog->Log(_L("Csystemtoneservicestif::PlaySystemToneService tone type missing in config file ")); |
|
139 iLog->Log(_L("Playing Default Tone")); |
|
140 iSts->PlayTone(CSystemToneService::EDefaultBeep); |
|
141 lRetVal = KErrNone; |
|
142 } |
|
143 else |
|
144 { |
|
145 iSts->PlayTone(CSystemToneService::TToneType(toneType)); |
|
146 iLog->Log(_L("CSystemToneService::TToneType(toneType) %d"),CSystemToneService::TToneType(toneType) ); |
|
147 } |
|
148 |
|
149 return lRetVal; |
|
150 } |
|
151 |
|
152 |
|
153 TInt CSystemToneServiceStif::PlaySystemToneServiceWithContext( CStifItemParser& aItem ) |
|
154 { |
|
155 // Print to UI |
|
156 _LIT( Ksystemtoneservicestif, "systemtoneservicestif" ); |
|
157 _LIT( KPrint, "In PlaySystemToneServiceWithContext" ); |
|
158 TestModuleIf().Printf( 0, Ksystemtoneservicestif, KPrint ); |
|
159 // Print to log file |
|
160 iLog->Log( KPrint ); |
|
161 |
|
162 TInt lRetVal = KErrNone; |
|
163 TInt toneType = 0; |
|
164 |
|
165 lRetVal = aItem.GetNextInt(toneType); |
|
166 |
|
167 if ( lRetVal != KErrNone ) |
|
168 { |
|
169 iLog->Log(_L("CSystemToneServiceStif::PlaySystemToneService tone type missing in config file ")); |
|
170 iLog->Log(_L("Playing Default Tone")); |
|
171 |
|
172 iSts->PlayTone(CSystemToneService::EDefaultBeep, iCurrentContext); |
|
173 } |
|
174 else |
|
175 { |
|
176 //iSts->PlayTone(CSystemToneService::EClockAlarm, iCurrentContext); |
|
177 iSts->PlayTone(CSystemToneService::TToneType(toneType), iCurrentContext); |
|
178 iLog->Log(_L("CSystemToneService::TToneType(toneType) %d"),CSystemToneService::TToneType(toneType) ); |
|
179 } |
|
180 |
|
181 return lRetVal; |
|
182 |
|
183 } |
|
184 |
|
185 |
|
186 TInt CSystemToneServiceStif::StopSystemToneService(CStifItemParser& aItem ) |
|
187 { |
|
188 TPtrC StopType; |
|
189 TInt error = KErrNone; |
|
190 |
|
191 error = aItem.GetNextString(StopType); |
|
192 |
|
193 |
|
194 if (StopType == KTrue) |
|
195 { |
|
196 iLog->Log(_L("Stop Tone with recognized context number")); |
|
197 |
|
198 iSts->StopTone(iCurrentContext); |
|
199 } |
|
200 else |
|
201 { |
|
202 iLog->Log(_L("Stop Tone with unrecognized context number")); |
|
203 |
|
204 iSts->StopTone(iCurrentContext+1); |
|
205 } |
|
206 |
|
207 return error; |
|
208 } |
|
209 |