|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __TEALARMTESTMULTIPLEALARMSSTEP_H__ |
|
17 #define __TEALARMTESTMULTIPLEALARMSSTEP_H__ |
|
18 |
|
19 |
|
20 #include <asshdalarm.h> |
|
21 |
|
22 #include "TEAlarmTestMANEventEntry.h" |
|
23 #include "TEAlarmTestMANEventObserver.h" |
|
24 #include "TEAlarmTestStepBase.h" |
|
25 |
|
26 |
|
27 _LIT(KTEAlarmTestMultipleAlarmsStep,"TestMultipleAlarmsStep"); |
|
28 |
|
29 |
|
30 const TInt KGranularity = 3; |
|
31 const TInt KReconnectTimeout = 1; // in seconds |
|
32 |
|
33 class CTEAlarmTestMultipleAlarmsStep : public CTEAlarmTestStepBase, public MMANEventHandler |
|
34 { |
|
35 private: |
|
36 enum TTestFailureCode { |
|
37 EUnexpectedEvent, |
|
38 EUnexpectedAlarmState |
|
39 }; |
|
40 |
|
41 struct TAlarmEntry |
|
42 { |
|
43 TInt iAlarmIdx; // alarm's index from .ini file |
|
44 TASShdAlarm iASShdAlarm; // shared alarm object itself |
|
45 TInt iOffset; // in seconds |
|
46 TInt iDelay; // in seconds |
|
47 TBool iNotifying; |
|
48 TBool iVisible; |
|
49 TBool iSoundPlaying; |
|
50 }; |
|
51 |
|
52 public: |
|
53 CTEAlarmTestMultipleAlarmsStep(); |
|
54 ~CTEAlarmTestMultipleAlarmsStep(); |
|
55 |
|
56 TVerdict doTestStepPreambleL(); |
|
57 TVerdict doTestStepL(); |
|
58 |
|
59 public: |
|
60 void HandleEventL(TEventEntry aEvent); |
|
61 |
|
62 // Utility methods for reading from Config |
|
63 TBool GetAlarmsFromConfigL(const TDesC& aSectName, CArrayFixFlat<TAlarmEntry>& aResult); |
|
64 TBool GetEventsFromConfigL(const TDesC& aSectName, RArray<TEventEntry>& aResult); |
|
65 |
|
66 private: |
|
67 // Event observers |
|
68 void AddObserverL(const TEventEntry& aEvent); |
|
69 void AddDelayedHandlerL(const TEventEntry& anAction); |
|
70 void StartEventObserversL(); |
|
71 void RegisterAlarmsL(); |
|
72 void UserWaitL(TInt aSeconds); |
|
73 void ReconnectToASL(); |
|
74 |
|
75 // Actions and Events |
|
76 void DoProcessEventL(const TEventEntry& aEvent); |
|
77 TBool DoImmediateActionL(const TEventEntry& aEvent); |
|
78 TBool DoDelayedActionL(const TEventEntry& aEvent); |
|
79 TBool GetNextEvent(TEventEntry& aEvent); |
|
80 TBool DidWeExpectThisEvent(const TEventEntry& aEvent); |
|
81 |
|
82 // Logging |
|
83 const TDesC& AlarmStateToStrL(TAlarmState aState); |
|
84 void LogEventL(TEventEntry aEvent); |
|
85 void LogAlarmStateL(TInt aAlarmIdx); |
|
86 void ReportFailureAndStopL(TTestFailureCode aCode); |
|
87 |
|
88 // Alarms and Alarms list |
|
89 TInt GetAlarmListIdxbyAlarmId(TEventEntry& aEvent); |
|
90 inline TAlarmEntry& AlarmAt(TInt aIdx) { return (*iAlarmListPtr)[aIdx]; } |
|
91 inline TASShdAlarm& ShdAlarmAt(TInt aIdx) { return (*iAlarmListPtr)[aIdx].iASShdAlarm; } |
|
92 void UpdateAlarmDetails(TInt aAlarmIdx); |
|
93 TBool CheckAlarmState(const TEventEntry& aEvent); |
|
94 TBool CheckAlarmStateOnly(const TEventEntry& aEvent); |
|
95 |
|
96 void AddAlarm(TInt aAlarmIdx); |
|
97 void RemoveAlarms(); |
|
98 |
|
99 // Private Utility methods for reading from config |
|
100 TBool GetAlarmFromConfig(const TDesC& aSectName, TInt aAlarmIdx, TAlarmEntry& aResult); |
|
101 TBool GetEventFromConfigL(const TDesC& aSectName, TInt aEventIdx, TEventEntry& aResult); |
|
102 TEventType GetEventTypeFromString(const TDesC& aEventString); |
|
103 TAlarmState GetAlarmStateFromStringL(TPtrC& aStateString); |
|
104 TBool GetVisibilityFromStringL(TPtrC& aVisibilityString); |
|
105 TBool GetBoolFromStringL(TPtrC& aBoolString); |
|
106 TBool GetSoundPlayingFromStringL(TPtrC& aPlayingString); |
|
107 |
|
108 private: |
|
109 RPointerArray<CMANEventObserver> iBunchOfObservers; |
|
110 RPointerArray<CMANDelayedActionHandler> iBunchOfDelayedHandlers; |
|
111 CArrayFixFlat<TAlarmEntry> *iAlarmListPtr; |
|
112 RArray<TEventEntry> iEventList; |
|
113 TInt iCurrentEventIdx; |
|
114 TBool iInUserWaitMode; |
|
115 TTime iStarted; |
|
116 }; |
|
117 |
|
118 |
|
119 #endif // __TEALARMTESTMULTIPLEALARMSSTEP_H__ |