|
1 // Copyright (c) 1999-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 // Test harness |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 #pragma warning( disable : 4100 ) |
|
21 |
|
22 // Includes... |
|
23 #include <e32test.h> |
|
24 #include <bsp.h> |
|
25 #include <e32uid.h> |
|
26 #include <msvruids.h> |
|
27 #include <biouids.h> |
|
28 |
|
29 // Global functions.. |
|
30 // functions() |
|
31 GLDEF_C void doMainL(); |
|
32 GLDEF_C TInt E32Main(); |
|
33 |
|
34 #define DataComponentFileName _L("c:\\system\\mtm\\cbiomtmu.dat") |
|
35 |
|
36 //forward reference |
|
37 class CTestScheduler; |
|
38 LOCAL_C void DisplayErrorReason(TInt& aReason); |
|
39 |
|
40 // Resources.. |
|
41 GLDEF_C RTest test(_L("BIO Test Logger Tester")); |
|
42 LOCAL_D CTrapCleanup* myCleanup; |
|
43 LOCAL_D RFs rFs; |
|
44 |
|
45 |
|
46 // |
|
47 // CExampleScheduler // |
|
48 // |
|
49 |
|
50 class CTestScheduler : public CActiveScheduler |
|
51 { |
|
52 public: |
|
53 void ErrorL(TInt aError) const; |
|
54 }; |
|
55 |
|
56 void CTestScheduler::ErrorL(TInt aError) const |
|
57 { |
|
58 CActiveScheduler::Stop(); |
|
59 test.Printf(_L("\nLeave signalled, reason=%d\n"),aError); |
|
60 test.Getch(); |
|
61 } |
|
62 // end CExampleScheduler::Error(TInt) const |
|
63 |
|
64 LOCAL_D CTestScheduler* theScheduler; |
|
65 |
|
66 // |
|
67 // CTestSaveBioMsg // |
|
68 // |
|
69 |
|
70 class CTestSaveBioMsg : public CBase, public MMsvSessionObserver |
|
71 { |
|
72 public: |
|
73 static CTestSaveBioMsg* NewL(); |
|
74 ~CTestSaveBioMsg(); |
|
75 |
|
76 void CreateMessageL(); |
|
77 private: |
|
78 // some private functions |
|
79 CTestSaveBioMsg(); |
|
80 void ConstructL(); |
|
81 |
|
82 // from MMsvSessionObserver |
|
83 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
84 |
|
85 private: |
|
86 // some private members |
|
87 }; |
|
88 |
|
89 // |
|
90 // CSaveBIOMessage create the message entry via client |
|
91 // |
|
92 CTestSaveBioMsg* CTestSaveBioMsg::NewL() |
|
93 { |
|
94 CTestSaveBioMsg* self = new (ELeave) CTestSaveBioMsg(); |
|
95 CleanupStack::PushL(self); |
|
96 self->ConstructL(); |
|
97 CleanupStack::Pop(); |
|
98 return self; |
|
99 } |
|
100 |
|
101 CTestSaveBioMsg::~CTestSaveBioMsg() |
|
102 { |
|
103 } |
|
104 |
|
105 |
|
106 CTestSaveBioMsg::CTestSaveBioMsg() |
|
107 { |
|
108 } |
|
109 |
|
110 void CTestSaveBioMsg::ConstructL() |
|
111 { |
|
112 TUid mtmDllTypeUids[4]; |
|
113 TUid smartMtmDllTypeUids[4]; |
|
114 TInt smartMtmDllEntryPoints[4]; |
|
115 |
|
116 mtmDllTypeUids[0] = KUidMtmServerComponent; |
|
117 mtmDllTypeUids[1] = KUidMtmClientComponent; |
|
118 mtmDllTypeUids[2] = KUidMtmUiComponent; |
|
119 mtmDllTypeUids[3] = KUidMtmUiDataComponent; |
|
120 |
|
121 smartMtmDllTypeUids[0] = KUidBIOMessageServerMtmDll; |
|
122 smartMtmDllTypeUids[1] = KUidBIOMessageClientMtmDll; |
|
123 smartMtmDllTypeUids[2] = KUidBIOMessageUiLayerMtmDll; //TUid for Bium - UI |
|
124 smartMtmDllTypeUids[3] = KUidBIOMessageUiLayerMtmDll; // - UI data |
|
125 |
|
126 |
|
127 smartMtmDllEntryPoints[0] = 1; |
|
128 smartMtmDllEntryPoints[1] = 1; |
|
129 smartMtmDllEntryPoints[2] = 1; |
|
130 smartMtmDllEntryPoints[3] = 2; |
|
131 |
|
132 |
|
133 // Make a data component for the text mtm, so the server puts the MTMs into the registry |
|
134 CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray; |
|
135 CleanupStack::PushL(mtmdllinfoarray); |
|
136 |
|
137 TBuf<20> name(_S("BIO UI")); |
|
138 for (TInt ii=0; ii < KMsvNumMtmDllTypes; ++ii) // There are 4 mtm types |
|
139 { |
|
140 TUidType mtmUid(KDynamicLibraryUid, mtmDllTypeUids[ii], smartMtmDllTypeUids[ii]); |
|
141 TVersion mtmVersion(1, 0, 100); |
|
142 CMtmDllInfo* dllInfo = CMtmDllInfo::NewL(name, mtmUid, smartMtmDllEntryPoints[ii], mtmVersion); |
|
143 CleanupStack::PushL(dllInfo); |
|
144 mtmdllinfoarray->AppendL(dllInfo); |
|
145 CleanupStack::Pop(); |
|
146 } |
|
147 |
|
148 CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(KUidBIOMessageTypeMtm, KNullUid, *mtmdllinfoarray); |
|
149 CleanupStack::PushL(mtmgroupdata); |
|
150 |
|
151 CFileStore* filestore = CPermanentFileStore::ReplaceLC(rFs,DataComponentFileName,EFileShareExclusive|EFileStream|EFileWrite); |
|
152 TUidType uidtype(KPermanentFileStoreLayoutUid, KUidMsvDataComponent, KUidBIOMessageTypeMtm); |
|
153 filestore->SetTypeL(uidtype); |
|
154 RStoreWriteStream out; |
|
155 TStreamId streamid=out.CreateLC(*filestore); // Push to stack |
|
156 mtmgroupdata->ExternalizeL(out); |
|
157 out.CommitL(); |
|
158 CleanupStack::PopAndDestroy(); // out |
|
159 filestore->SetRootL(streamid); |
|
160 filestore->CommitL(); |
|
161 CleanupStack::PopAndDestroy(3); // filestore, mtmgroupdata, mtmdllinfoarray |
|
162 |
|
163 CMsvSession* msvSession = CMsvSession::OpenSyncL(*this); |
|
164 CClientMtmRegistry* mtmReg=CClientMtmRegistry::NewL(*msvSession); |
|
165 if (!mtmReg->IsPresent(KUidBIOMessageTypeMtm)) |
|
166 { |
|
167 User::LeaveIfError(msvSession->InstallMtmGroup(DataComponentFileName)); |
|
168 } |
|
169 |
|
170 delete mtmReg; |
|
171 delete msvSession; |
|
172 } |
|
173 |
|
174 void CTestSaveBioMsg::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
175 { |
|
176 } |
|
177 |
|
178 void CTestSaveBioMsg::CreateMessageL() |
|
179 { |
|
180 TUid wibbleParser = {0x1000552F}; |
|
181 CSaveBIOMessage* saveBioMsg = CSaveBIOMessage::NewL(wibbleParser); |
|
182 CleanupStack::PushL(saveBioMsg); |
|
183 |
|
184 // Create and fill a CRichText object for the jobbie.. |
|
185 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); |
|
186 CleanupStack::PushL(paraFormatLayer); |
|
187 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); |
|
188 CleanupStack::PushL(charFormatLayer); |
|
189 CRichText* richText = CRichText::NewL(paraFormatLayer,charFormatLayer); |
|
190 CleanupStack::PushL(richText); |
|
191 |
|
192 TInt pos = richText->DocumentLength(); // Ought to be 0 |
|
193 richText->InsertL(pos,_L("Here's some random cobblers, cobblers wibble hatstand")); |
|
194 |
|
195 TTime theTime; |
|
196 saveBioMsg->CreateMessageL(_L("Bloody bugger test msg"), |
|
197 theTime, |
|
198 *richText); |
|
199 CleanupStack::PopAndDestroy(3); // |
|
200 |
|
201 CleanupStack::PopAndDestroy(); |
|
202 } |
|
203 |
|
204 |
|
205 |
|
206 //***************************************************************************** |
|
207 // |
|
208 // Implementation; global stuff |
|
209 // |
|
210 //***************************************************************************** |
|
211 GLDEF_C TInt E32Main() |
|
212 { |
|
213 __UHEAP_MARK; |
|
214 myCleanup = CTrapCleanup::New(); |
|
215 TRAPD(err,doMainL()); |
|
216 test(err==KErrNone); |
|
217 delete myCleanup; |
|
218 test.End(); |
|
219 test.Close(); |
|
220 __UHEAP_MARKEND; |
|
221 return(KErrNone); |
|
222 } |
|
223 |
|
224 GLDEF_C void doMainL() |
|
225 { |
|
226 // Create an active scheduler for the program session |
|
227 theScheduler = new (ELeave) CTestScheduler(); |
|
228 CleanupStack::PushL(theScheduler); |
|
229 CActiveScheduler::Install(theScheduler); |
|
230 test.Title(); |
|
231 test.Printf(_L("\n")); |
|
232 test.Start(_L("Starting save BIO msg test harness")); |
|
233 |
|
234 // install our mtm |
|
235 rFs.Connect(); |
|
236 |
|
237 CTestSaveBioMsg* tester = CTestSaveBioMsg::NewL(); |
|
238 CleanupStack::PushL(tester); |
|
239 tester->CreateMessageL(); |
|
240 |
|
241 CleanupStack::PopAndDestroy(2); // theScheduler, tester |
|
242 } |