|
1 // Copyright (c) 2007-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 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" |
|
25 |
|
26 using namespace NUnitTesting_USBDI; |
|
27 |
|
28 // The test object |
|
29 |
|
30 RTest gtest(_L("USBDI Unit Testing")); |
|
31 |
|
32 static void MainL() |
|
33 { |
|
34 LOG_CFUNC |
|
35 // Leave the hooks in for platform security |
|
36 #ifdef __DATA_CAGING__ |
|
37 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
38 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
39 #endif |
|
40 |
|
41 // Identify the process and main thread |
|
42 RProcess testProcess; |
|
43 RThread().Process(testProcess); |
|
44 testProcess.RenameMe(_L("t_usbdi.exe")); |
|
45 RThread().RenameMe(_L("t_usbdi.exe main thread")); |
|
46 |
|
47 // Create a new active scheduler for this main thread |
|
48 CActiveScheduler* sched = new (ELeave) CActiveScheduler; |
|
49 CleanupStack::PushL(sched); |
|
50 CActiveScheduler::Install(sched); |
|
51 |
|
52 // create test engine for host or client depending upon command line arguments. |
|
53 CTestEngine* testEngine = NULL; |
|
54 TRAPD(err, testEngine = CTestEngine::NewL()); |
|
55 if(err == KErrNone) |
|
56 { |
|
57 CleanupStack::PushL(testEngine); |
|
58 |
|
59 // Synchronise with the client and start the active scheduler |
|
60 RProcess::Rendezvous(KErrNone); |
|
61 |
|
62 User::After(150000); |
|
63 RDebug::Print(_L("CActiveScheduler::Start MainL")); |
|
64 CActiveScheduler::Start(); |
|
65 |
|
66 CleanupStack::PopAndDestroy(testEngine); |
|
67 } |
|
68 else |
|
69 { |
|
70 gtest.Printf(_L("Unable to create the test engine: %d\n"),err); |
|
71 } |
|
72 |
|
73 User::After(5000000); |
|
74 CleanupStack::PopAndDestroy(sched); |
|
75 } |
|
76 |
|
77 TInt E32Main() |
|
78 { |
|
79 LOG_CFUNC |
|
80 // Create the new trap-cleanup mechanism |
|
81 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
82 |
|
83 if(cleanup == NULL) |
|
84 { |
|
85 return KErrNoMemory; |
|
86 } |
|
87 |
|
88 // Perform the tests |
|
89 TRAPD(err,MainL()); |
|
90 if(err != KErrNone) |
|
91 { |
|
92 gtest.Printf(_L("MainL error: %d\n"),err); |
|
93 } |
|
94 |
|
95 delete cleanup; |
|
96 |
|
97 // Provide no error |
|
98 return KErrNone; |
|
99 } |
|
100 |
|
101 |