|
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: |
|
15 * The file contains the implementation of the STS Tester. |
|
16 */ |
|
17 |
|
18 #include "ststester.h" |
|
19 |
|
20 #include <systemtoneservice.h> |
|
21 #define PROFILE_TIME 1 |
|
22 #include "profileutilmacro.h" |
|
23 |
|
24 const TInt KKeyMapPageCount = 1; |
|
25 |
|
26 const TInt KFontSize = 15; |
|
27 |
|
28 const TOperationsPage KKeyMap[KKeyMapPageCount] = |
|
29 { |
|
30 {STR("Standard controls"), 5, // default softkey index |
|
31 { |
|
32 // Enter |
|
33 {STR(""), KOperation_ExecuteOption}, |
|
34 // Up / Down / Left / Right |
|
35 {STR(""), KOperation_PreviousOption}, |
|
36 {STR(""), KOperation_NextOption}, |
|
37 {STR(""), KOperation_PreviousOptionPage}, |
|
38 {STR(""), KOperation_NextOptionPage}, |
|
39 // 0 - 9 |
|
40 {STR("Play Default Beep"), EOperation_PlayDefaultBeep}, |
|
41 {STR("Play Clock Alarm"), EOperation_PlayClockAlarm}, |
|
42 {STR("Stop Clock Alarm"), EOperation_StopClockAlarm}, |
|
43 {STR(""), KOperation_None}, |
|
44 {STR(""), KOperation_None}, |
|
45 {STR(""), KOperation_None}, |
|
46 {STR(""), KOperation_None}, |
|
47 {STR(""), KOperation_None}, |
|
48 {STR(""), KOperation_None}, |
|
49 {STR("Exit"), KOperation_Exit} |
|
50 } |
|
51 } |
|
52 }; |
|
53 |
|
54 void CStsTester::ExecuteL() |
|
55 { |
|
56 CStsTester* self = new (ELeave) CStsTester; |
|
57 CleanupStack::PushL(self); |
|
58 self->InitL(); |
|
59 self->Main(); |
|
60 CleanupStack::PopAndDestroy(self); |
|
61 } |
|
62 |
|
63 CStsTester::CStsTester() : |
|
64 CTestAppBase(KFontSize), iPlayState(EStopped) |
|
65 { |
|
66 } |
|
67 |
|
68 CStsTester::~CStsTester() |
|
69 { |
|
70 CSystemToneService::Delete( iSts); |
|
71 } |
|
72 |
|
73 void CStsTester::InitL() |
|
74 { |
|
75 BaseConstructL(KKeyMap, KKeyMapPageCount); |
|
76 iSts = CSystemToneService::Create(); |
|
77 } |
|
78 |
|
79 void CStsTester::Main() |
|
80 { |
|
81 TRAP_IGNORE( MainL() ); |
|
82 } |
|
83 |
|
84 void CStsTester::MainL() |
|
85 { |
|
86 _LIT( KPlayDefault, "Play Default Beep" ); |
|
87 _LIT( KPlayClockAlarm, "Play Clock Alarm" ); |
|
88 _LIT( KStopClockAlarm, "Stop Clock Alarm" ); |
|
89 _LIT( KExit, "Exit"); |
|
90 |
|
91 bool done = false; |
|
92 |
|
93 while (!done) |
|
94 { |
|
95 RPointerArray<TDesC> operations; |
|
96 operations.Append(&KPlayDefault); |
|
97 operations.Append(&KPlayClockAlarm); |
|
98 operations.Append(&KStopClockAlarm); |
|
99 operations.Append(&KExit); |
|
100 |
|
101 TInt index = SelectFromListL(TPoint(0, 0), iDisplaySize, |
|
102 _L("Select STS operation to perform:"), operations); |
|
103 |
|
104 operations.Reset(); |
|
105 |
|
106 TPtrC operationName(STR("Play Default Beep")); |
|
107 |
|
108 switch (index) |
|
109 { |
|
110 case -1: |
|
111 done = true; |
|
112 break; |
|
113 case 0: |
|
114 ExecuteOperation(EOperation_PlayDefaultBeep, operationName); |
|
115 break; |
|
116 case 1: |
|
117 ExecuteOperation(EOperation_PlayClockAlarm, operationName); |
|
118 break; |
|
119 case 2: |
|
120 ExecuteOperation(EOperation_StopClockAlarm, operationName); |
|
121 break; |
|
122 case 3: |
|
123 done = true; |
|
124 break; |
|
125 } |
|
126 } |
|
127 } |
|
128 |
|
129 void CStsTester::ExecuteOperation(TInt aOperation, const TDesC& /*aOperationText*/) |
|
130 { |
|
131 switch (aOperation) |
|
132 { |
|
133 case EOperation_PlayDefaultBeep: |
|
134 { |
|
135 TAG_TIME_PROFILING_BEGIN; |
|
136 iSts->PlayTone(CSystemToneService::EDefaultBeep); |
|
137 TAG_TIME_PROFILING_END; |
|
138 PRINT_TO_CONSOLE_TIME_DIFF; |
|
139 break; |
|
140 } |
|
141 case EOperation_PlayClockAlarm: |
|
142 { |
|
143 // Only play if not already playing |
|
144 if (iPlayState != EPlaying) |
|
145 { |
|
146 TAG_TIME_PROFILING_BEGIN; |
|
147 iSts->PlayTone(CSystemToneService::EClockAlarm, |
|
148 iCurrentContext); |
|
149 TAG_TIME_PROFILING_END; |
|
150 PRINT_TO_CONSOLE_TIME_DIFF; |
|
151 iPlayState = EPlaying; |
|
152 } |
|
153 break; |
|
154 } |
|
155 case EOperation_StopClockAlarm: |
|
156 { |
|
157 TAG_TIME_PROFILING_BEGIN; |
|
158 iSts->StopTone(iCurrentContext); |
|
159 TAG_TIME_PROFILING_END; |
|
160 PRINT_TO_CONSOLE_TIME_DIFF; |
|
161 iPlayState = EStopped; |
|
162 break; |
|
163 } |
|
164 default: |
|
165 { |
|
166 break; |
|
167 } |
|
168 } |
|
169 } |