|
1 /* |
|
2 * Copyright (c) 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: Implementation of the T_MProfile test class. |
|
15 * |
|
16 */ |
|
17 |
|
18 //////////////////////////////////////////////////////////////////////// |
|
19 // T_MProfile.cpp |
|
20 // |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32math.h> |
|
24 #include <e32svr.h> |
|
25 |
|
26 #include <EUnitMacros.h> |
|
27 #include <TEUnitAssertionInfo.h> |
|
28 |
|
29 #include <BAMDESCA.H> |
|
30 #include <RSSSettings.h> |
|
31 #include "MProfileEngine.h" |
|
32 #include "MProfileEngineExtended.h" |
|
33 #include "MProfile.h" |
|
34 #include "MProfileName.h" |
|
35 #include "MProfileExtraTones.h" |
|
36 #include "MProfileSetExtraTones.h" |
|
37 #include "MProfileExtraSettings.h" |
|
38 #include "MProfilesLocalFeatures.h" |
|
39 #include "MProfileTones.h" |
|
40 #include <TProfileToneSettings.h> |
|
41 #include "MProfileExtended.h" |
|
42 #include "MProfileSetTones.h" |
|
43 //#include "T_ProfileTestTools.h" |
|
44 #include "ProfilesVariant.hrh" |
|
45 |
|
46 // the header for the tested class |
|
47 #include "T_MProfile.h" |
|
48 |
|
49 //CONSTS |
|
50 |
|
51 // create the testing class |
|
52 T_MProfile* T_MProfile::NewLC() |
|
53 { |
|
54 T_MProfile* self = new(ELeave) T_MProfile; |
|
55 |
|
56 CleanupStack::PushL( self ); |
|
57 // need to generate the table, so call base classes |
|
58 // second phase constructor |
|
59 self->ConstructL(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 void T_MProfile::ConstructL() |
|
64 { |
|
65 CEUnitTestSuiteClass::ConstructL(); |
|
66 } |
|
67 |
|
68 T_MProfile::~T_MProfile() |
|
69 { |
|
70 if( iProfileEngine ) |
|
71 { |
|
72 iProfileEngine->Release(); |
|
73 } |
|
74 if( iProfile ) |
|
75 { |
|
76 iProfile->Release(); |
|
77 } |
|
78 } |
|
79 |
|
80 /** |
|
81 * Assistance methods |
|
82 */ |
|
83 |
|
84 |
|
85 void T_MProfile::SetupL() |
|
86 { |
|
87 iActiveId = 0; |
|
88 |
|
89 iProfileEngine = CreateProfileEngineL(); |
|
90 |
|
91 iProfileEngine->SetActiveProfileL( iActiveId ); |
|
92 iProfile = iProfileEngine->ActiveProfileL(); |
|
93 } |
|
94 |
|
95 |
|
96 /** |
|
97 * Teardown |
|
98 */ |
|
99 |
|
100 void T_MProfile::Teardown() |
|
101 { |
|
102 if( iProfile ) |
|
103 { |
|
104 iProfile->Release(); |
|
105 iProfile = NULL; |
|
106 } |
|
107 if( iProfileEngine ) |
|
108 { |
|
109 iProfileEngine->Release(); |
|
110 iProfileEngine = NULL; |
|
111 } |
|
112 } |
|
113 |
|
114 /** |
|
115 * Tests |
|
116 */ |
|
117 void T_MProfile::EmptyTestL() |
|
118 { |
|
119 //EUNIT_ASSERT( ETrue ); |
|
120 } |
|
121 |
|
122 void T_MProfile::CreateTestL() |
|
123 { |
|
124 MProfile* profile = NULL; |
|
125 profile = iProfileEngine->ActiveProfileL(); |
|
126 EUNIT_ASSERT( profile ); |
|
127 profile->Release(); |
|
128 profile = NULL; |
|
129 |
|
130 profile = iProfileEngine->ActiveProfileL(); |
|
131 EUNIT_ASSERT( profile ); |
|
132 CleanupReleasePushL( *profile ); |
|
133 CleanupStack::PopAndDestroy(); |
|
134 profile = NULL; |
|
135 |
|
136 profile = iProfileEngine->ActiveProfileLC(); |
|
137 EUNIT_ASSERT( profile ); |
|
138 CleanupStack::PopAndDestroy(); |
|
139 profile = NULL; |
|
140 } |
|
141 |
|
142 void T_MProfile::GetAlertForTestL() |
|
143 { |
|
144 __UHEAP_MARK; |
|
145 TArray<TContactItemId> array = iProfile->AlertForL(); |
|
146 __UHEAP_MARKEND; |
|
147 |
|
148 EUNIT_ASSERT( array.Count() == 0 ); |
|
149 } |
|
150 |
|
151 void T_MProfile::IsSilentTestL() |
|
152 { |
|
153 __UHEAP_MARK; |
|
154 TBool isSilent( iProfile->IsSilent() ); |
|
155 __UHEAP_MARKEND; |
|
156 if( iActiveId == 1 || iActiveId == 4 ) |
|
157 { |
|
158 EUNIT_ASSERT( isSilent ); |
|
159 } |
|
160 else |
|
161 { |
|
162 EUNIT_ASSERT( !isSilent ); |
|
163 } |
|
164 } |
|
165 |
|
166 void T_MProfile::GetProfileNameTestL() |
|
167 { |
|
168 const MProfileName* profileName = NULL; |
|
169 __UHEAP_MARK; |
|
170 profileName = &( iProfile->ProfileName() ); |
|
171 __UHEAP_MARKEND; |
|
172 EUNIT_ASSERT( profileName ); |
|
173 } |
|
174 |
|
175 void T_MProfile::GetProfileTonesTestL() |
|
176 { |
|
177 const MProfileTones* profileTones = NULL; |
|
178 __UHEAP_MARK; |
|
179 profileTones = &( iProfile->ProfileTones() ); |
|
180 __UHEAP_MARKEND; |
|
181 EUNIT_ASSERT( profileTones ); |
|
182 } |
|
183 |
|
184 void T_MProfile::GetProfileExtraTonesTestL() |
|
185 { |
|
186 const MProfileExtraTones* profileExtraTones = NULL; |
|
187 __UHEAP_MARK; |
|
188 profileExtraTones = &( iProfile->ProfileExtraTones() ); |
|
189 __UHEAP_MARKEND; |
|
190 EUNIT_ASSERT( profileExtraTones ); |
|
191 } |
|
192 |
|
193 void T_MProfile::GetProfileExtraSettingsTestL() |
|
194 { |
|
195 const MProfileExtraSettings* profileExtraSettings = NULL; |
|
196 __UHEAP_MARK; |
|
197 profileExtraSettings = &( iProfile->ProfileExtraSettings() ); |
|
198 __UHEAP_MARKEND; |
|
199 EUNIT_ASSERT( profileExtraSettings ); |
|
200 } |
|
201 |
|
202 |
|
203 // Test case table for this test suite class |
|
204 EUNIT_BEGIN_TEST_TABLE( T_MProfile, "T_MProfile test suite", "MODULE" ) |
|
205 |
|
206 EUNIT_TESTCASE("Create test ", SetupL, CreateTestL, Teardown) |
|
207 EUNIT_TESTCASE("Get alert for test ", SetupL, GetAlertForTestL, Teardown) |
|
208 EUNIT_TESTCASE("Is silent test ", SetupL, IsSilentTestL, Teardown) |
|
209 EUNIT_TESTCASE("Get profile name test ", SetupL, GetProfileNameTestL, Teardown) |
|
210 EUNIT_TESTCASE("Get profile tones test ", SetupL, GetProfileTonesTestL, Teardown) |
|
211 EUNIT_TESTCASE("Get profile extra tones test ", SetupL, GetProfileExtraTonesTestL, Teardown) |
|
212 EUNIT_TESTCASE("Get profile extra settings test ", SetupL, GetProfileExtraSettingsTestL, Teardown) |
|
213 |
|
214 EUNIT_END_TESTCASE_TABLE |
|
215 |
|
216 // End of File |