|
1 /* |
|
2 * Copyright (c) 2009 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 "piprofilertest.h" |
|
21 #include <e32base.h> |
|
22 #include <e32std.h> |
|
23 #include <e32cons.h> // Console |
|
24 #include <e32debug.h> |
|
25 #include "rtestsampler.h" |
|
26 |
|
27 // Constants |
|
28 |
|
29 _LIT(KTextConsoleTitle, "Console"); |
|
30 _LIT(KTextFailed, " failed, leave code = %d"); |
|
31 _LIT(KTextPressAnyKey, " [press any key]\n"); |
|
32 |
|
33 // Global Variables |
|
34 |
|
35 LOCAL_D CConsoleBase* console; // write all messages to this |
|
36 |
|
37 |
|
38 // Local Functions |
|
39 |
|
40 LOCAL_C void MainL() |
|
41 { |
|
42 // |
|
43 // add your program code here, example code below |
|
44 // |
|
45 //console->Write(_L("Hello, world!\n")); |
|
46 RDebug::Printf("hallo welt\n"); |
|
47 //LoadProfilerLDD(); |
|
48 |
|
49 RDebug::Printf("hallo ldd\n"); |
|
50 LoadProfilerDLL(); |
|
51 RDebug::Printf("hallo2\n"); |
|
52 } |
|
53 |
|
54 LOCAL_C void DoStartL() |
|
55 { |
|
56 // Create active scheduler (to run active objects) |
|
57 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); |
|
58 CleanupStack::PushL(scheduler); |
|
59 CActiveScheduler::Install(scheduler); |
|
60 |
|
61 MainL(); |
|
62 |
|
63 // Delete active scheduler |
|
64 CleanupStack::PopAndDestroy(scheduler); |
|
65 } |
|
66 |
|
67 // Global Functions |
|
68 |
|
69 GLDEF_C TInt E32Main() |
|
70 { |
|
71 // Create cleanup stack |
|
72 __UHEAP_MARK; |
|
73 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
74 // Create output console |
|
75 // TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize( |
|
76 // KConsFullScreen, KConsFullScreen))); |
|
77 // if (createError) |
|
78 // { |
|
79 // delete cleanup; |
|
80 // return createError; |
|
81 // } |
|
82 |
|
83 // Run application code inside TRAP harness, wait keypress when terminated |
|
84 TRAPD(mainError, DoStartL()); |
|
85 if (mainError) |
|
86 // console->Printf(KTextFailed, mainError); |
|
87 // console->Printf(KTextPressAnyKey); |
|
88 // console->Getch(); |
|
89 |
|
90 // delete console; |
|
91 delete cleanup; |
|
92 __UHEAP_MARKEND; |
|
93 return KErrNone; |
|
94 } |
|
95 |
|
96 LOCAL_C TInt LoadProfilerLDD() |
|
97 { |
|
98 RDebug::Printf("LoadProfilerLDD >"); |
|
99 TInt err; |
|
100 _LIT(KPluginSamplerName,"PIProfilerGeneralsSampler"); |
|
101 err = User::LoadLogicalDevice(KPluginSamplerName); |
|
102 RDebug::Printf("Err2 : %d", err); |
|
103 if(err == KErrAlreadyExists) |
|
104 { |
|
105 err = User::FreeLogicalDevice(KPluginSamplerName); |
|
106 RDebug::Printf("Err2.1 : %d", err); |
|
107 err = User::LoadLogicalDevice(KPluginSamplerName); |
|
108 RDebug::Printf("Err2.2 : %d", err); |
|
109 } |
|
110 RtestSampler aGeneralsSampler; |
|
111 err = aGeneralsSampler.Open(); |
|
112 RDebug::Printf("Err3 : %d", err); |
|
113 if(err = KErrNone) |
|
114 { |
|
115 RDebug::Printf("test - Could not open sampler device: %d", err); |
|
116 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
117 _LIT( KDescription, "Could not open sampler device" ); |
|
118 //aResult.SetResult( KErrNone, KDescription ); |
|
119 } |
|
120 |
|
121 // Case was executed |
|
122 err = User::FreeLogicalDevice(KPluginSamplerName); |
|
123 RDebug::Printf("Err4 : %d", err); |
|
124 |
|
125 RDebug::Printf("LoadProfilerLDD <"); |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 LOCAL_C TInt LoadProfilerDLL() |
|
130 { |
|
131 RDebug::Printf("LoadProfilerDLL >"); |
|
132 RLibrary lib; |
|
133 TInt err = lib.Load(_L("PIProfilerGenerals.dll"), _L("c:\\sys\\bin")); |
|
134 RDebug::Printf("Err0 : %d", err); |
|
135 |
|
136 const TInt KNewLOrdinal = 2; |
|
137 TLibraryFunction NewL =lib.Lookup(KNewLOrdinal); |
|
138 RDebug::Printf("library.lookup returns 0x%x", NewL); |
|
139 CSamplerPluginInterface* mydll; |
|
140 //STF_ASSERT_LEAVES_WITH (KErrPermissionDenied, (mydll=(CSamplerPluginInterface*)NewL())); |
|
141 mydll=(CSamplerPluginInterface*)NewL(); |
|
142 |
|
143 if( mydll ) |
|
144 { |
|
145 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
146 _LIT( KDescription, "mydll exists" ); |
|
147 //aResult.SetResult( KErrAccessDenied, KDescription ); |
|
148 |
|
149 } |
|
150 else |
|
151 { |
|
152 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
153 _LIT( KDescription, "passed" ); |
|
154 //aResult.SetResult( KErrNone, KDescription ); |
|
155 } |
|
156 |
|
157 // Case was executed |
|
158 RDebug::Printf("LoadProfilerDLL <"); |
|
159 return KErrNone; |
|
160 } |
|
161 |