|
1 /* |
|
2 * Copyright (c) 2004 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: Test for settings model for the slideshow |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "t_cshwsettingsmodel.h" |
|
23 |
|
24 // CLASS UNDER TEST |
|
25 #include "shwsettingsmodel.h" |
|
26 |
|
27 // EXTERNAL INCLUDES |
|
28 #include <digia/eunit/EUnitMacros.h> |
|
29 #include <centralrepository.h> |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 |
|
33 |
|
34 // CONSTRUCTION |
|
35 T_CShwSettingsModel* T_CShwSettingsModel::NewL() |
|
36 { |
|
37 T_CShwSettingsModel* self = T_CShwSettingsModel::NewLC(); |
|
38 CleanupStack::Pop( self ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 T_CShwSettingsModel* T_CShwSettingsModel::NewLC() |
|
43 { |
|
44 T_CShwSettingsModel* self = new (ELeave) T_CShwSettingsModel(); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 // Destructor (virtual by CBase) |
|
52 T_CShwSettingsModel::~T_CShwSettingsModel() |
|
53 { |
|
54 } |
|
55 |
|
56 |
|
57 // Default constructor |
|
58 T_CShwSettingsModel::T_CShwSettingsModel() |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // Second phase construct |
|
64 void T_CShwSettingsModel::ConstructL() |
|
65 { |
|
66 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
67 // It generates the test case table. |
|
68 CEUnitTestSuiteClass::ConstructL(); |
|
69 } |
|
70 |
|
71 // METHODS |
|
72 |
|
73 |
|
74 void T_CShwSettingsModel::SetupL() |
|
75 { |
|
76 iShwSettingsModel = CShwSettingsModel::NewL(); |
|
77 } |
|
78 |
|
79 void T_CShwSettingsModel::Teardown() |
|
80 { |
|
81 delete iShwSettingsModel; |
|
82 iShwSettingsModel = NULL; |
|
83 |
|
84 const TInt KEngineId = 0x200071D3; |
|
85 const TUid KEngineUid = TUid::Uid(KEngineId); |
|
86 TRAP_IGNORE( |
|
87 { |
|
88 CRepository* repository = CRepository::NewL(KEngineUid); |
|
89 TInt err = repository->Reset(); |
|
90 User::LeaveIfError(err); |
|
91 delete repository; |
|
92 } ); |
|
93 } |
|
94 |
|
95 |
|
96 |
|
97 void T_CShwSettingsModel::TestGetDefaultValues() |
|
98 { |
|
99 TBuf<KMaxFileName> fileNamePath; |
|
100 iShwSettingsModel->MusicNamePathL(fileNamePath); |
|
101 _LIT(KDefaultFileName, "None"); |
|
102 EUNIT_ASSERT(fileNamePath == KDefaultFileName); |
|
103 |
|
104 const TUint KDefaultUid = 0x200071D6; |
|
105 TUid defaultUId; |
|
106 defaultUId.iUid = KDefaultUid; |
|
107 |
|
108 TUid uId; |
|
109 TUint index = 0; |
|
110 iShwSettingsModel->TransitionTypeL(uId, index); |
|
111 EUNIT_ASSERT(defaultUId.iUid == uId.iUid); |
|
112 EUNIT_ASSERT_EQUALS_DESC( 1, index, "default index is 0"); |
|
113 } |
|
114 |
|
115 void T_CShwSettingsModel::TestSetAndGetMusicPathL() |
|
116 { |
|
117 // Set music name and path field. |
|
118 _LIT(KTestFileName, "c:\\test\\knightrider.mp3"); |
|
119 iShwSettingsModel->SaveMusicNamePathL( KTestFileName() ); |
|
120 |
|
121 // Compare returned values to those set. |
|
122 TFileName fileNamePath; |
|
123 iShwSettingsModel->MusicNamePathL(fileNamePath); |
|
124 EUNIT_ASSERT(fileNamePath == KTestFileName); |
|
125 |
|
126 // try setting an empty music name |
|
127 iShwSettingsModel->SaveMusicNamePathL( KNullDesC() ); |
|
128 // test that it was not set |
|
129 iShwSettingsModel->MusicNamePathL(fileNamePath); |
|
130 EUNIT_ASSERT(fileNamePath == KTestFileName); |
|
131 } |
|
132 |
|
133 |
|
134 void T_CShwSettingsModel::TestSetAndGetMusicOnOffL() |
|
135 { |
|
136 iShwSettingsModel->SaveMusicStateL(ETrue); |
|
137 EUNIT_ASSERT(iShwSettingsModel->MusicOnL() == ETrue); |
|
138 } |
|
139 |
|
140 |
|
141 void T_CShwSettingsModel::TestSetAndGetTransDelayL() |
|
142 { |
|
143 const TUint KTimeDelay = 5; |
|
144 iShwSettingsModel->SaveTransDelayL(KTimeDelay); |
|
145 EUNIT_ASSERT(iShwSettingsModel->TransDelayL() == KTimeDelay); |
|
146 } |
|
147 |
|
148 |
|
149 void T_CShwSettingsModel::TestSetAndGetTransitionTypeL() |
|
150 { |
|
151 const TUint KUid = 0x01234567; |
|
152 TUid uId1; |
|
153 uId1.iUid = KUid; |
|
154 iShwSettingsModel->SaveTransitionTypeL(uId1, 1); |
|
155 |
|
156 TUid uId2; |
|
157 TUint index = 0; |
|
158 iShwSettingsModel->TransitionTypeL(uId2, index); |
|
159 EUNIT_ASSERT(uId1.iUid == uId2.iUid); |
|
160 EUNIT_ASSERT(index == 1); |
|
161 } |
|
162 |
|
163 // TEST TABLE |
|
164 |
|
165 EUNIT_BEGIN_TEST_TABLE( |
|
166 T_CShwSettingsModel, |
|
167 "Test suite for CShwSettingsModel", |
|
168 "MODULE" ) |
|
169 |
|
170 EUNIT_TEST( |
|
171 "Test Get Default Values", |
|
172 "TestGetDefaultValues", |
|
173 "Central Repositoy getter - default values", |
|
174 "FUNCTIONALITY", |
|
175 SetupL, TestGetDefaultValues, Teardown) |
|
176 |
|
177 |
|
178 EUNIT_TEST( |
|
179 "Test Set And Get Music Path", |
|
180 "TestSetAndGetMusicPath", |
|
181 "Music name and path Central Repositoy setter and getter", |
|
182 "FUNCTIONALITY", |
|
183 SetupL, TestSetAndGetMusicPathL, Teardown) |
|
184 |
|
185 |
|
186 EUNIT_TEST( |
|
187 "Test Set And Get Music On/Off", |
|
188 "TestSetAndGetMusicOnOffL", |
|
189 "Music On/Off Central Repositoy setter and getter", |
|
190 "FUNCTIONALITY", |
|
191 SetupL, TestSetAndGetMusicOnOffL, Teardown) |
|
192 |
|
193 |
|
194 EUNIT_TEST( |
|
195 "Test Set And Get Transition Delay", |
|
196 "TestSetAndGetTransDelayL", |
|
197 "Transition Delay Central Repositoy setter and getter", |
|
198 "FUNCTIONALITY", |
|
199 SetupL, TestSetAndGetTransDelayL, Teardown) |
|
200 |
|
201 |
|
202 EUNIT_TEST( |
|
203 "Test Set And Get Transition Type", |
|
204 "TestSetAndGetTransitionTypeL", |
|
205 "Transition Type Central Repositoy setter and getter", |
|
206 "FUNCTIONALITY", |
|
207 SetupL, TestSetAndGetTransitionTypeL, Teardown) |
|
208 |
|
209 |
|
210 EUNIT_END_TEST_TABLE |
|
211 |
|
212 // END OF FILE |