|
1 // Copyright (c) 1998-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 // Name of test harness: T_IAPPREFS |
|
15 // Component: IMCM |
|
16 // Owner: KG |
|
17 // Brief description of test harness: |
|
18 // Tests IAP Preferences |
|
19 // Detailed description of test harness: |
|
20 // As above |
|
21 // Input files required to run test harness: |
|
22 // None |
|
23 // Intermediate files produced while running test harness: |
|
24 // None |
|
25 // Output files produced by running test harness: |
|
26 // <DRIVE>:\msglogs\T_IAPPREFS.<PLATFORM>.<VARIANT>.LOG.txt |
|
27 // Description of how to build test harness: |
|
28 // cd \msg\imcm\ |
|
29 // bldmake bldfiles |
|
30 // abld test build |
|
31 // Description of how to run test harness: |
|
32 // WINS running instructions: |
|
33 // 1. \epoc32\release\wins\<VARIANT>\T_IAPPREFS.exe can be used at the command prompt |
|
34 // or executable can be run from Windows Explorer. |
|
35 // All other platform running instructions: |
|
36 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_IAPPREFS.exe onto the other platform |
|
37 // 2. Run T_IAPPREFS.exe on the other platform |
|
38 // |
|
39 // |
|
40 |
|
41 #include "emailtestutils.h" |
|
42 #include "t_iapprefs.h" |
|
43 #include <e32test.h> |
|
44 #include <msvids.h> |
|
45 |
|
46 RTest test(_L("T_IAPP")); |
|
47 LOCAL_D CTrapCleanup* theCleanup; |
|
48 LOCAL_D CEmailTestUtils* testUtils; |
|
49 |
|
50 |
|
51 CT_iapprefs* CT_iapprefs::NewLC() |
|
52 { |
|
53 CT_iapprefs* self = new (ELeave) CT_iapprefs(); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 return self; |
|
57 } |
|
58 |
|
59 void CT_iapprefs::ConstructL() |
|
60 { |
|
61 iPref = CImIAPPreferences::NewLC(); |
|
62 CleanupStack::Pop(); |
|
63 } |
|
64 |
|
65 CT_iapprefs::CT_iapprefs() |
|
66 { |
|
67 } |
|
68 |
|
69 CT_iapprefs::~CT_iapprefs() |
|
70 { |
|
71 delete iPref; |
|
72 } |
|
73 |
|
74 void CT_iapprefs::HeapTestL() |
|
75 { |
|
76 #ifdef _DEBUG // stop compiler complaining that i isn't used in release builds. |
|
77 TInt i = 0; |
|
78 #endif |
|
79 TInt err = KErrNone; |
|
80 do |
|
81 { |
|
82 __UHEAP_FAILNEXT(i++); |
|
83 |
|
84 TRAP(err, TestAllButStoreL()); |
|
85 |
|
86 __UHEAP_RESET; |
|
87 } while (err == KErrNoMemory); |
|
88 |
|
89 User::LeaveIfError(err); |
|
90 |
|
91 } |
|
92 |
|
93 void CT_iapprefs::TestL() |
|
94 { |
|
95 TestAllButStoreL(); |
|
96 } |
|
97 |
|
98 void CT_iapprefs::TestAllButStoreL() |
|
99 { |
|
100 TestVersionL(); |
|
101 TestNoIAPsL(); |
|
102 TestAddIAPL(); |
|
103 TestRemoveIAPL(); |
|
104 } |
|
105 |
|
106 void CT_iapprefs::TestVersionL() |
|
107 { |
|
108 TestL(iPref->Version()==2); // MLM 13/08/01. Changed to version 2 for Messaging 6.2. |
|
109 } |
|
110 |
|
111 |
|
112 void CT_iapprefs::TestNoIAPsL() |
|
113 { |
|
114 PopulateChoicesL(0); |
|
115 TestL(iPref->NumberOfIAPs() == 0); |
|
116 PopulateChoicesL(2); |
|
117 TestL(iPref->NumberOfIAPs() == 2); |
|
118 } |
|
119 |
|
120 void CT_iapprefs::TestAddIAPL() |
|
121 { |
|
122 PopulateChoicesL(4); |
|
123 for(TUint i = 0; i < 4; ++i) |
|
124 TestL(iPref->IAPPreference(i).iIAP==i); |
|
125 } |
|
126 |
|
127 void CT_iapprefs::TestRemoveIAPL() |
|
128 { |
|
129 PopulateChoicesL(4); |
|
130 iPref->RemoveIAPL(0); |
|
131 TestL(iPref->NumberOfIAPs()==3); |
|
132 TUint i; |
|
133 for(i = 0; i < 3; ++i) |
|
134 TestL(iPref->IAPPreference(i).iIAP==i+1); |
|
135 |
|
136 iPref->RemoveIAPL(2); // the last one |
|
137 TestL(iPref->NumberOfIAPs()==2); |
|
138 for(i = 0; i < 2; ++i) |
|
139 TestL(iPref->IAPPreference(i).iIAP==i+1); |
|
140 } |
|
141 |
|
142 void CT_iapprefs::PopulateChoicesL(TInt n) |
|
143 { |
|
144 for(;iPref->NumberOfIAPs() > 0; iPref->RemoveIAPL(0)) {}; |
|
145 |
|
146 TestL(iPref->NumberOfIAPs()==0); |
|
147 for(TInt j = 0; j < n; ++j) |
|
148 { |
|
149 TImIAPChoice choice = {j,(TCommDbDialogPref)1}; |
|
150 iPref->AddIAPL(choice, j); |
|
151 } |
|
152 } |
|
153 |
|
154 void CT_iapprefs::TestL(TBool aCondition) |
|
155 { |
|
156 if(!aCondition) |
|
157 User::Leave(KErrTestFailed); |
|
158 } |
|
159 |
|
160 void doMainL() |
|
161 { |
|
162 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
163 CleanupStack::PushL(scheduler); |
|
164 CActiveScheduler::Install( scheduler ); |
|
165 testUtils = CEmailTestUtils::NewLC(test); |
|
166 CT_iapprefs* iapp = CT_iapprefs::NewLC(); |
|
167 |
|
168 testUtils->TestStart(1); |
|
169 iapp->TestL(); |
|
170 testUtils->TestFinish(1); |
|
171 testUtils->TestStart(2); |
|
172 iapp->HeapTestL(); |
|
173 testUtils->TestFinish(2); |
|
174 testUtils->TestHarnessCompleted(); |
|
175 CleanupStack::PopAndDestroy(3);//iapp, scheduler, testUtils |
|
176 } |
|
177 |
|
178 GLDEF_C TInt E32Main() |
|
179 { |
|
180 __UHEAP_MARK; |
|
181 test.Start(_L("T_IAPP Test CImIAPPreferences class\n")); |
|
182 theCleanup=CTrapCleanup::New(); |
|
183 TRAPD(ret,doMainL()); |
|
184 test(ret==KErrNone); |
|
185 delete theCleanup; |
|
186 test.End(); |
|
187 test.Close(); |
|
188 __UHEAP_MARKEND; |
|
189 return (KErrNone); |
|
190 } |