First public contribution.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include <test/testexecutelog.h>
20 #include <caf/content.h>
21 #include <caf/attribute.h>
22 #include "cafserver.h"
26 #include "CafApaRecognizer.h"
34 using namespace ContentAccess;
37 * Base class for all CAF test steps
49 void CCAFStep:: InitialiseFileHandleParametersL()
51 GetStringFromConfig(ConfigSection(),_L("uri"),iUri);
52 GetStringFromConfig(ConfigSection(),_L("uniqueid"),iUniqueId);
53 GetIntFromConfig(ConfigSection(),_L("result"),iExpectedResult);
56 CleanupClosePushL(iFs);
57 User::LeaveIfError(iFs.ShareProtected());
58 User::LeaveIfError(iFile.Open(iFs, iUri, EFileShareReadersOnly| EFileRead | EFileStream));
59 CleanupClosePushL(iFile);
62 void CCAFStep::ReadBufferL(TDesC16& aFileName, TDes8& aBuffer)
67 User::LeaveIfError(fs.Connect());
68 CleanupClosePushL(fs);
69 result = handle.Open(fs,aFileName,EFileRead | EFileStream | EFileShareAny);
70 User::LeaveIfError(result);
71 CleanupClosePushL(handle);
73 CleanupStack::PopAndDestroy(2, &fs);
76 HBufC8* CCAFStep::ConvertDes16toHBufC8LC(TDesC& source)
79 HBufC8 *buf = HBufC8::NewL(source.Length());
80 CleanupStack::PushL(buf);
83 CCnvCharacterSetConverter *converter = CCnvCharacterSetConverter::NewLC();
84 User::LeaveIfError(fs.Connect());
85 CleanupClosePushL(fs);
86 converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierAscii, fs);
87 converter->ConvertFromUnicode(ptr, source);
88 CleanupStack::PopAndDestroy(2, converter);
92 HBufC16* CCAFStep::ConvertDes8toHBufC16LC(TDesC8& source)
96 HBufC16 *buf = HBufC16::NewL(source.Length());
97 CleanupStack::PushL(buf);
98 TPtr16 ptr=buf->Des();
99 CCnvCharacterSetConverter *converter = CCnvCharacterSetConverter::NewLC();
100 User::LeaveIfError(fs.Connect());
101 CleanupClosePushL(fs);
102 converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierAscii, fs);
103 converter->ConvertToUnicode(ptr, source, status);
104 CleanupStack::PopAndDestroy(2, converter);
108 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
110 HBufC8* CCAFStep::CreateWmdrmHeaderLC()
112 // create dummy header data.
113 const TInt KMaxBufferLen = 64;
114 _LIT8(KHeaderData, "W\0R\0M\0H\0E\0A\0D\0E\0R\0");
116 HBufC8* headerData = HBufC8::NewMaxLC(KMaxBufferLen);
117 TPtr8 headerPtr = headerData->Des();
118 headerPtr.Repeat(KHeaderData);
121 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
124 void CCAFStep::LoadCafRecognizerL()
126 static const TUid KImplementationUID= {0x102031E9};
128 TAny* ptr = REComSession::CreateImplementationL(KImplementationUID, iDtorIDKey);
129 iRecognizer = static_cast <CApaDataRecognizerType*>(ptr);
132 void CCAFStep::UnLoadCafRecognizer()
136 REComSession::DestroyedImplementation(iDtorIDKey);
137 REComSession::FinalClose();
140 TInt CCAFStep::Delete(const TDesC& aFile)
147 err = fs.Delete(aFile);
155 TVerdict CCAFStep::doTestStepPreambleL()
157 iActiveScheduler = new (ELeave) CActiveScheduler;
158 CActiveScheduler::Install(iActiveScheduler);
159 return TestStepResult();
162 TVerdict CCAFStep::doTestStepPostambleL()
164 CActiveScheduler::Install(NULL);
165 delete iActiveScheduler;
166 return TestStepResult();
170 // Dummy class required to create an apparc server (below)
171 class CT_Serv2DummyShell : public CBase, public MApaAppStarter
174 TThreadId StartAppL(const CApaCommandLine&) { return *(TThreadId*)this; }
181 void CT_Serv2DummyShell::ConstructL()
183 User::LeaveIfError(iFs.Connect());
184 User::LeaveIfError(iFbs.Connect());
188 void CCAFStep::StartApparcServerL()
190 INFO_PRINTF1(_L("Starting Apparc Server"));
192 TInt ret=RFbsSession::Connect();
199 // set up an app starter
200 CT_Serv2DummyShell* dummy=new(ELeave) CT_Serv2DummyShell();
203 ret=StartupApaServerProcess();
206 TEST(((ret==KErrNone)||(ret==KErrAlreadyExists)));
210 INFO_PRINTF1(_L("Apparc Startup Complete"));