1 /* |
|
2 * Copyright (c) 2009 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL INCLUDES |
|
20 #include <CTSYDomainPSKeys.h> |
|
21 #include "etelmm.h" |
|
22 #include "ut_musfactorysettings.h" |
|
23 #include "musfactorysettings.h" |
|
24 #include "centralrepository.h" |
|
25 #include "e32property.h" |
|
26 |
|
27 |
|
28 // SYSTEM INCLUDES |
|
29 #include <eunitmacros.h> |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // Two phase symbian constructor |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 UT_CMusFactorySettings* UT_CMusFactorySettings::NewL() |
|
36 { |
|
37 UT_CMusFactorySettings* self = UT_CMusFactorySettings::NewLC(); |
|
38 CleanupStack::Pop( self ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // Two phase symbian constructor |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 UT_CMusFactorySettings* UT_CMusFactorySettings::NewLC() |
|
48 { |
|
49 UT_CMusFactorySettings* self = new( ELeave ) UT_CMusFactorySettings(); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // Destructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 UT_CMusFactorySettings::~UT_CMusFactorySettings() |
|
61 { |
|
62 |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // Default constructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 UT_CMusFactorySettings::UT_CMusFactorySettings() |
|
71 { |
|
72 // NOP |
|
73 } |
|
74 |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // Second phase construct |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void UT_CMusFactorySettings::ConstructL() |
|
81 { |
|
82 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
83 // It generates the test case table. |
|
84 CEUnitTestSuiteClass::ConstructL(); |
|
85 |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void UT_CMusFactorySettings::SetupL() |
|
94 { |
|
95 iMusCentralRepository = CRepository::NewL( MusSettingsKeys::KRepositoryUid ); |
|
96 CRepository::ResetStubGlobal(); |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void UT_CMusFactorySettings::Teardown() |
|
105 { |
|
106 delete iMusCentralRepository; |
|
107 iMusCentralRepository = NULL; |
|
108 CRepository::ResetStubGlobal(); |
|
109 PropertyHelper::Close(); // CRepository puts stuff to RProperty static |
|
110 } |
|
111 |
|
112 // TEST CASES |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // SetCallInfo test function |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void UT_CMusFactorySettings::UT_CMusFactorySettings_IsSupportedLL() |
|
119 { |
|
120 // call cases |
|
121 // all call types allowed |
|
122 TPSCTsyCallType callType = EPSCTsyCallTypeCSVoice; |
|
123 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyWithActiveCSCall, |
|
124 MusSettingsKeys::EAllowedAllCalls) ); |
|
125 EUNIT_ASSERT( MusFactorySettings::IsSupportedL( callType )); |
|
126 |
|
127 // allowed csonly and call type is voip |
|
128 callType = EPSCTsyCallTypeVoIP; |
|
129 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyWithActiveCSCall, |
|
130 MusSettingsKeys::EAllowedCSOnly) ); |
|
131 EUNIT_ASSERT( !MusFactorySettings::IsSupportedL( callType )); |
|
132 |
|
133 // allowed csonly and call type is cs |
|
134 callType = EPSCTsyCallTypeCSVoice; |
|
135 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyWithActiveCSCall, |
|
136 MusSettingsKeys::EAllowedCSOnly) ); |
|
137 EUNIT_ASSERT( MusFactorySettings::IsSupportedL( callType )); |
|
138 |
|
139 // allowed csonly and call type is EPSCTsyCallTypeNone |
|
140 callType = EPSCTsyCallTypeNone; |
|
141 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyWithActiveCSCall, |
|
142 MusSettingsKeys::EAllowedCSOnly) ); |
|
143 EUNIT_ASSERT( !MusFactorySettings::IsSupportedL( callType )); |
|
144 |
|
145 // network cases |
|
146 // all bearer types allowed |
|
147 RMobilePhone::TMobilePhoneNetworkMode networkType = RMobilePhone::ENetworkModeGsm; |
|
148 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyIn3GNetwork, |
|
149 MusSettingsKeys::EAllowedAllBearers) ); |
|
150 EUNIT_ASSERT( MusFactorySettings::IsSupportedL( networkType )); |
|
151 |
|
152 // 3g only and network type is gsm |
|
153 networkType = RMobilePhone::ENetworkModeGsm; |
|
154 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyIn3GNetwork, |
|
155 MusSettingsKeys::EAllowed3GOnly) ); |
|
156 EUNIT_ASSERT( !MusFactorySettings::IsSupportedL( networkType )); |
|
157 |
|
158 // 3g only and network type is 3g |
|
159 networkType = RMobilePhone::ENetworkModeWcdma; |
|
160 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyIn3GNetwork, |
|
161 MusSettingsKeys::EAllowed3GOnly) ); |
|
162 EUNIT_ASSERT( MusFactorySettings::IsSupportedL( networkType )); |
|
163 |
|
164 // if allowed3gonly setting cenrep key not found |
|
165 // then function should not leave and should behave like in default |
|
166 // case ie all bearer supported. so it should return ETrue |
|
167 networkType = RMobilePhone::ENetworkModeGsm; |
|
168 User::LeaveIfError( CRepository::SetStubGlobal(MusSettingsKeys::KAllowOnlyIn3GNetwork, |
|
169 MusSettingsKeys::EAllowed3GOnly) ); |
|
170 CRepository::iForceFailWithCode = KErrNotFound; |
|
171 TBool supported = EFalse; |
|
172 EUNIT_ASSERT_NO_LEAVE( supported = MusFactorySettings::IsSupportedL( networkType )) |
|
173 EUNIT_ASSERT( supported ); |
|
174 } |
|
175 |
|
176 // TEST TABLE |
|
177 |
|
178 EUNIT_BEGIN_TEST_TABLE( |
|
179 UT_CMusFactorySettings, |
|
180 "UT_CMusFactorySettings", |
|
181 "UNIT" ) |
|
182 |
|
183 EUNIT_TEST( |
|
184 "IsSupportedL - test", |
|
185 "CMusFactorySettings", |
|
186 "IsSupportedL", |
|
187 "FUNCTIONALITY", |
|
188 SetupL, UT_CMusFactorySettings_IsSupportedLL, Teardown) |
|
189 |
|
190 EUNIT_END_TEST_TABLE |
|
191 |
|
192 // END OF FILE |
|
193 |
|
194 |
|