253
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "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 |
// @file main.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <e32base_private.h>
|
|
21 |
#include <e32test.h>
|
|
22 |
|
|
23 |
#include "testdebug.h"
|
|
24 |
#include "TestEngine.h"
|
253
|
25 |
#include "OstTraceDefinitions.h"
|
|
26 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
27 |
#include "mainTraces.h"
|
|
28 |
#endif
|
0
|
29 |
|
|
30 |
using namespace NUnitTesting_USBDI;
|
|
31 |
|
|
32 |
// The test object
|
|
33 |
|
|
34 |
RTest gtest(_L("USBDI Unit Testing"));
|
|
35 |
|
|
36 |
static void MainL()
|
|
37 |
{
|
253
|
38 |
OstTraceFunctionEntry0( _MAINL_ENTRY );
|
0
|
39 |
// Leave the hooks in for platform security
|
|
40 |
#ifdef __DATA_CAGING__
|
|
41 |
RProcess().DataCaging(RProcess::EDataCagingOn);
|
|
42 |
RProcess().SecureApi(RProcess::ESecureApiOn);
|
|
43 |
#endif
|
|
44 |
|
|
45 |
// Identify the process and main thread
|
|
46 |
RProcess testProcess;
|
|
47 |
RThread().Process(testProcess);
|
|
48 |
testProcess.RenameMe(_L("t_usbdi.exe"));
|
|
49 |
RThread().RenameMe(_L("t_usbdi.exe main thread"));
|
|
50 |
|
|
51 |
// Create a new active scheduler for this main thread
|
|
52 |
CActiveScheduler* sched = new (ELeave) CActiveScheduler;
|
|
53 |
CleanupStack::PushL(sched);
|
|
54 |
CActiveScheduler::Install(sched);
|
|
55 |
|
|
56 |
// create test engine for host or client depending upon command line arguments.
|
|
57 |
CTestEngine* testEngine = NULL;
|
|
58 |
TRAPD(err, testEngine = CTestEngine::NewL());
|
|
59 |
if(err == KErrNone)
|
|
60 |
{
|
|
61 |
CleanupStack::PushL(testEngine);
|
|
62 |
|
|
63 |
// Synchronise with the client and start the active scheduler
|
|
64 |
RProcess::Rendezvous(KErrNone);
|
|
65 |
|
|
66 |
User::After(150000);
|
253
|
67 |
OstTrace0(TRACE_NORMAL, MAINL_MAINL, "CActiveScheduler::Start MainL");
|
0
|
68 |
CActiveScheduler::Start();
|
|
69 |
|
|
70 |
CleanupStack::PopAndDestroy(testEngine);
|
|
71 |
}
|
|
72 |
else
|
|
73 |
{
|
|
74 |
gtest.Printf(_L("Unable to create the test engine: %d\n"),err);
|
253
|
75 |
OstTrace1(TRACE_NORMAL, MAINL_MAINL_DUP01, "Unable to create the test engine: %d\n",err);
|
0
|
76 |
}
|
|
77 |
|
|
78 |
User::After(5000000);
|
|
79 |
CleanupStack::PopAndDestroy(sched);
|
253
|
80 |
OstTraceFunctionExit0( _MAINL_EXIT );
|
0
|
81 |
}
|
|
82 |
|
|
83 |
TInt E32Main()
|
|
84 |
{
|
253
|
85 |
OstTraceFunctionEntry0( _E32MAIN_ENTRY );
|
0
|
86 |
// Create the new trap-cleanup mechanism
|
|
87 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
88 |
|
|
89 |
if(cleanup == NULL)
|
|
90 |
{
|
253
|
91 |
OstTraceFunctionExit0( _E32MAIN_EXIT );
|
0
|
92 |
return KErrNoMemory;
|
|
93 |
}
|
|
94 |
|
|
95 |
// Perform the tests
|
|
96 |
TRAPD(err,MainL());
|
|
97 |
if(err != KErrNone)
|
|
98 |
{
|
|
99 |
gtest.Printf(_L("MainL error: %d\n"),err);
|
253
|
100 |
OstTrace1(TRACE_NORMAL, E32MAIN_E32MAIN, "MainL error: %d\n",err);
|
0
|
101 |
}
|
|
102 |
|
|
103 |
delete cleanup;
|
|
104 |
|
|
105 |
// Provide no error
|
253
|
106 |
OstTraceFunctionExit0( _E32MAIN_EXIT_DUP01 );
|
0
|
107 |
return KErrNone;
|
|
108 |
}
|
|
109 |
|
|
110 |
|