|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // Include Files |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <e32std.h> |
|
22 #include <e32cons.h> // Console |
|
23 |
|
24 #include "CRobustnessTest.h" |
|
25 |
|
26 // Constants |
|
27 |
|
28 _LIT(KTextConsoleTitle, "Console"); |
|
29 _LIT(KTextFailed, " failed, leave code = %d"); |
|
30 _LIT(KTextPressAnyKey, " [press any key]\n"); |
|
31 |
|
32 // Global Variables |
|
33 |
|
34 LOCAL_D CConsoleBase* console; // write all messages to this |
|
35 |
|
36 // Local Functions |
|
37 |
|
38 class CRobustnessTestDriver : public CBase, public MRobustnessTestObserver |
|
39 { |
|
40 public: |
|
41 void RunL() |
|
42 { |
|
43 iTest = new ( ELeave ) CRobustnessTest( *console, *this ); |
|
44 iTest->ConstructL(); |
|
45 iTest->StartL(); |
|
46 CActiveScheduler::Start(); |
|
47 } |
|
48 ~CRobustnessTestDriver() |
|
49 { |
|
50 delete iTest; |
|
51 } |
|
52 public: // from CRobustnessTestObserver |
|
53 |
|
54 void FinishedL(CRobustnessTest& ) |
|
55 { |
|
56 CActiveScheduler::Stop(); |
|
57 } |
|
58 |
|
59 private: |
|
60 |
|
61 CRobustnessTest* iTest; |
|
62 |
|
63 }; |
|
64 |
|
65 |
|
66 LOCAL_C void MainL() |
|
67 { |
|
68 CRobustnessTestDriver* driver = new ( ELeave ) CRobustnessTestDriver(); |
|
69 CleanupStack::PushL( driver ); |
|
70 driver->RunL(); |
|
71 CleanupStack::PopAndDestroy( driver ); |
|
72 } |
|
73 |
|
74 LOCAL_C void DoStartL() |
|
75 { |
|
76 // Create active scheduler (to run active objects) |
|
77 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); |
|
78 CleanupStack::PushL(scheduler); |
|
79 CActiveScheduler::Install(scheduler); |
|
80 |
|
81 MainL(); |
|
82 |
|
83 // Delete active scheduler |
|
84 CleanupStack::PopAndDestroy(scheduler); |
|
85 } |
|
86 |
|
87 // Global Functions |
|
88 |
|
89 GLDEF_C TInt E32Main() |
|
90 { |
|
91 // Create cleanup stack |
|
92 __UHEAP_MARK; |
|
93 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
94 |
|
95 // Create output console |
|
96 TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen))); |
|
97 if (createError) |
|
98 return createError; |
|
99 |
|
100 // Run application code inside TRAP harness, wait keypress when terminated |
|
101 TRAPD(mainError, DoStartL()); |
|
102 if (mainError) |
|
103 console->Printf(KTextFailed, mainError); |
|
104 console->Printf(KTextPressAnyKey); |
|
105 console->Getch(); |
|
106 |
|
107 delete console; |
|
108 delete cleanup; |
|
109 __UHEAP_MARKEND; |
|
110 return KErrNone; |
|
111 } |
|
112 |