sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
//This is a dummy source file to be used to create a dummy exe
|
sl@0
|
26 |
#include <e32base.h>
|
sl@0
|
27 |
#include <f32file.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
#include "captestframework.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
void MainL();
|
sl@0
|
33 |
|
sl@0
|
34 |
GLDEF_D TInt E32Main()
|
sl@0
|
35 |
{
|
sl@0
|
36 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
37 |
if(cleanup == NULL)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
return KErrNoMemory;
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
TRAPD(err,MainL());
|
sl@0
|
43 |
delete cleanup;
|
sl@0
|
44 |
return err;
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
HBufC* GetDesParameterL(TInt aParam)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
// Get Dll name
|
sl@0
|
50 |
TInt length=User::ParameterLength(aParam);
|
sl@0
|
51 |
User::LeaveIfError(length);
|
sl@0
|
52 |
|
sl@0
|
53 |
HBufC* des=HBufC::NewLC(length);
|
sl@0
|
54 |
TPtr desPtr=des->Des();
|
sl@0
|
55 |
User::LeaveIfError(User::GetDesParameter(aParam, desPtr));
|
sl@0
|
56 |
|
sl@0
|
57 |
CleanupStack::Pop(des);
|
sl@0
|
58 |
return des;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
HBufC* GetDllNameL()
|
sl@0
|
63 |
{
|
sl@0
|
64 |
return GetDesParameterL(KDllNameTransferSlot);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
void MainL()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
TInt err=KErrNone;
|
sl@0
|
70 |
|
sl@0
|
71 |
// figure out which test we're supposed to be running
|
sl@0
|
72 |
HBufC* dllName=GetDllNameL();
|
sl@0
|
73 |
|
sl@0
|
74 |
HBufC* logFileName=GetDesParameterL(KLogFileNameTransferSlot);
|
sl@0
|
75 |
|
sl@0
|
76 |
TBool shouldPass;
|
sl@0
|
77 |
err = User::GetTIntParameter(KShouldPassTransferSlot, shouldPass);
|
sl@0
|
78 |
TInt testNumber;
|
sl@0
|
79 |
err = User::GetTIntParameter(KTestNumberTransferSlot, testNumber);
|
sl@0
|
80 |
|
sl@0
|
81 |
// session
|
sl@0
|
82 |
RFs fs;
|
sl@0
|
83 |
User::LeaveIfError(fs.Connect());
|
sl@0
|
84 |
CleanupClosePushL(fs);
|
sl@0
|
85 |
|
sl@0
|
86 |
//logfile
|
sl@0
|
87 |
RFile logFile;
|
sl@0
|
88 |
User::LeaveIfError(logFile.Replace(fs, *logFileName, 0));
|
sl@0
|
89 |
CleanupClosePushL(logFile);
|
sl@0
|
90 |
|
sl@0
|
91 |
// load library
|
sl@0
|
92 |
RLibrary lib;
|
sl@0
|
93 |
User::LeaveIfError(lib.Load(*dllName));
|
sl@0
|
94 |
CleanupClosePushL(lib);
|
sl@0
|
95 |
|
sl@0
|
96 |
//runtests
|
sl@0
|
97 |
TLibraryFunction testFactory=lib.Lookup(1);
|
sl@0
|
98 |
MCapabilityTestFactory* factory=reinterpret_cast<MCapabilityTestFactory*>(testFactory());
|
sl@0
|
99 |
factory->Test(testNumber)->SetExpectPermissionDenied(!shouldPass);
|
sl@0
|
100 |
|
sl@0
|
101 |
TRAP(err, factory->Test(testNumber)->RunTestL(logFile));
|
sl@0
|
102 |
|
sl@0
|
103 |
delete factory;
|
sl@0
|
104 |
CleanupStack::PopAndDestroy(3, &fs); // lib, logFile, fs
|
sl@0
|
105 |
|
sl@0
|
106 |
User::LeaveIfError(err);
|
sl@0
|
107 |
}
|