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