|
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 // Contains implementation of CTestAlarmControlStateStep class |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 // User Include |
|
24 #include "TestAlarmControlStateStep.h" |
|
25 #include "DummyAlarmControl.h" |
|
26 |
|
27 /** |
|
28 Constructor. Sets the test step name. Testserver reference passed to make use |
|
29 of TEF's method of sharing data between test steps |
|
30 @internalTechnology |
|
31 @test |
|
32 */ |
|
33 CTestAlarmControlStateStep::CTestAlarmControlStateStep(CTestMultipleAlarmsServer& aTestServer) |
|
34 : CTestBaseStep(aTestServer) |
|
35 { |
|
36 //Call base class method to set human readable name for test step |
|
37 SetTestStepName(KTestAlarmControlStateStep); |
|
38 } |
|
39 |
|
40 /** |
|
41 Base class pure virtual. |
|
42 @return EPass or EFail indicating the result of the test step. |
|
43 @internalTechnology |
|
44 @test |
|
45 */ |
|
46 TVerdict CTestAlarmControlStateStep::doTestStepL() |
|
47 { |
|
48 TPtrC alarmMessage; |
|
49 TPtrC expectedCalls; |
|
50 if(!ReadStringsFromConfig(ConfigSection(), &KIniAlarmMessage(), &alarmMessage, NULL)) |
|
51 { |
|
52 IniProblem(); |
|
53 } |
|
54 else |
|
55 { |
|
56 TRAPD(error, TestAlarmControlStateL(alarmMessage)); |
|
57 PrintIfError(error); |
|
58 } |
|
59 return TestStepResult(); |
|
60 } |
|
61 |
|
62 /** |
|
63 Tests the state of the alarm control object associated with an alarm whose message |
|
64 is the one that is passed as parameter. Also performs other checks such as if the |
|
65 no. of currently notifying alarms <= max alarms value etc. |
|
66 @param aAlarmMessage Message to identify the alarm control object |
|
67 @internalTechnology |
|
68 @test |
|
69 */ |
|
70 void CTestAlarmControlStateStep::TestAlarmControlStateL(const TPtrC& aAlarmMessage) |
|
71 { |
|
72 TPtrC temp; |
|
73 TBool isPlaying = EFalse; |
|
74 TBool isSnoozed = EFalse; |
|
75 TBool isShowing = EFalse; |
|
76 |
|
77 if(TestServer()->CurrentMaxAlarms() == 1) |
|
78 {// if maxalarms == 1, then only one alarm control object must have been created |
|
79 INFO_PRINTF1(_L("MaxAlarms = 1. Testing no. of alarm control objects created to be 1")); |
|
80 TEST(TestServer()->AlarmControlsManager()->GetAlarmControlListCount() == 1); |
|
81 } |
|
82 |
|
83 // In case of maxalarms value more than 1, the number of currently |
|
84 // notifying alarms must never be more than the maxalarms value |
|
85 INFO_PRINTF1(_L("Testing if no. of currently notifying alarms <= maxalarms value")); |
|
86 TEST(TestServer()->NoOfCurrentlyNotifyingAlarms() <= TestServer()->CurrentMaxAlarms()); |
|
87 |
|
88 // Read the expected flags from ini. If not provided, will be considedered |
|
89 // as EFalse by default |
|
90 if(GetStringFromConfig(ConfigSection(), KIniIsPlaying(), temp)) |
|
91 { |
|
92 isPlaying = GetBool(temp); |
|
93 } |
|
94 if(GetStringFromConfig(ConfigSection(), KIniIsShowing(), temp)) |
|
95 { |
|
96 isShowing = GetBool(temp); |
|
97 } |
|
98 if(GetStringFromConfig(ConfigSection(), KIniIsSnoozed(), temp)) |
|
99 { |
|
100 isSnoozed = GetBool(temp); |
|
101 } |
|
102 |
|
103 // Get the owner of the alarm message provided in ini. |
|
104 CDummyAlarmControl* alarmControl = dynamic_cast<CDummyAlarmControl*>(TestServer()->AlarmControlsManager()->GetAlarmControlObjectL(aAlarmMessage)); |
|
105 |
|
106 INFO_PRINTF1(_L("Testing IsSnoozed")); |
|
107 TEST(!alarmControl->IsSnoozed() == !isSnoozed); |
|
108 |
|
109 if(isSnoozed) |
|
110 { |
|
111 TInt minsToSnooze = 0; |
|
112 if(GetIntFromConfig(ConfigSection(), KIniMinsToSnooze(), minsToSnooze)) |
|
113 { |
|
114 INFO_PRINTF1(_L("Testing Mins To Snooze")); |
|
115 TEST(alarmControl->MinsToSnooze() == minsToSnooze); |
|
116 } |
|
117 } |
|
118 |
|
119 INFO_PRINTF1(_L("Testing IsShowing")); |
|
120 TEST(!alarmControl->IsShowing() == !isShowing); |
|
121 |
|
122 INFO_PRINTF1(_L("Testing IsPlaying")); |
|
123 // Whoever is playing now, would have updated the test server's |
|
124 // CurrentlyPlayingAlarmId with his id. ! operator inserted to keep |
|
125 // TBool comparison safe. |
|
126 User::After(1000000); |
|
127 TEST(!isPlaying == !(alarmControl->AlarmObject().Id() == TestServer()->CurrentlyPlayingAlarmId())); |
|
128 } |
|
129 |
|
130 |