0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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 |
* Demonstration use of the TestExecute standalone logger client API
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file TestExecuteLoggerTest.cpp
|
|
23 |
*/
|
|
24 |
#include <TestExecuteLog.h>
|
|
25 |
#include <e32Cons.h>
|
|
26 |
#include <wrapperutilsplugin.h>
|
|
27 |
|
|
28 |
_LIT(KLogFile1,"?:\\TestExecuteLoggerTest.txt");
|
|
29 |
|
|
30 |
_LIT(K16BitText,"This is a short line of 16 Bit Text");
|
|
31 |
_LIT8(K8BitText,"This is a short line of 8 Bit Text");
|
|
32 |
|
|
33 |
_LIT(K16BitFormatText,"This is a short line of 16 Bit Format Text int = %d string = %S");
|
|
34 |
_LIT8(K8BitFormatText,"This is a short line of 8 Bit Format Text int = %d string = %S");
|
|
35 |
_LIT(K16BitString,"The String16");
|
|
36 |
_LIT8(K8BitString,"The String8");
|
|
37 |
|
|
38 |
LOCAL_C void MainL()
|
|
39 |
{
|
|
40 |
TDriveName defaultSysDrive(KTEFLegacySysDrive);
|
|
41 |
|
|
42 |
RFs fileServer;
|
|
43 |
TVersionName version(fileServer.Version().Name());
|
|
44 |
|
|
45 |
if (fileServer.Version().iMajor >= 2 &&
|
|
46 |
fileServer.Version().iBuild >= 1100)
|
|
47 |
{
|
|
48 |
RLibrary pluginLibrary;
|
|
49 |
TInt pluginErr = pluginLibrary.Load(KTEFWrapperPluginDll);
|
|
50 |
if (pluginErr == KErrNone)
|
|
51 |
{
|
|
52 |
TLibraryFunction newl;
|
|
53 |
newl = pluginLibrary.Lookup(2);
|
|
54 |
CWrapperUtilsPlugin* plugin = (CWrapperUtilsPlugin*)newl();
|
|
55 |
TDriveUnit driveUnit(plugin->GetSystemDrive());
|
|
56 |
defaultSysDrive.Copy(driveUnit.Name());
|
|
57 |
delete plugin;
|
|
58 |
pluginLibrary.Close();
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
TFileName logFile1(KLogFile1);
|
|
63 |
logFile1.Replace(0, 2, defaultSysDrive);
|
|
64 |
|
|
65 |
_LIT(KTitle,"TestExecute Standalone Logger Test Code");
|
|
66 |
CConsoleBase* console = Console::NewL(KTitle,TSize(KConsFullScreen,KConsFullScreen));
|
|
67 |
CleanupStack::PushL(console);
|
|
68 |
|
|
69 |
_LIT(KMessage1,"Connect() To Logger and Close() immediately\r\n");
|
|
70 |
console->Printf(KMessage1);
|
|
71 |
RTestExecuteLogServ logger;
|
|
72 |
User::LeaveIfError(logger.Connect());
|
|
73 |
logger.Close();
|
|
74 |
|
|
75 |
_LIT(KMessage2,"Immediate re-Connect() To Logger and Close() immediately\r\n");
|
|
76 |
console->Printf(KMessage2);
|
|
77 |
User::LeaveIfError(logger.Connect());
|
|
78 |
logger.Close();
|
|
79 |
|
|
80 |
_LIT(KMessage3,"Immediate re-Connect() To Logger CreateLog() and Close() immediately\r\n");
|
|
81 |
console->Printf(KMessage3);
|
|
82 |
User::LeaveIfError(logger.Connect());
|
|
83 |
User::LeaveIfError(logger.CreateLog(logFile1,RTestExecuteLogServ::ELogModeOverWrite));
|
|
84 |
logger.Close();
|
|
85 |
|
|
86 |
// OS needs time to shutdown the server
|
|
87 |
// No delay means we get server terminated from the OS
|
|
88 |
User::After(1000000);
|
|
89 |
|
|
90 |
_LIT(KMessage4,"Connect() To Logger CreateLog() %S Call API's\r\n");
|
|
91 |
console->Printf(KMessage4,&logFile1);
|
|
92 |
User::LeaveIfError(logger.Connect());
|
|
93 |
User::LeaveIfError(logger.CreateLog(logFile1,RTestExecuteLogServ::ELogModeOverWrite));
|
|
94 |
TBuf<20> buf16(K16BitString);
|
|
95 |
TBuf8<20> buf8(K8BitString);
|
|
96 |
logger.Write(K16BitText);
|
|
97 |
logger.Write(K8BitText);
|
|
98 |
logger.WriteFormat(K16BitFormatText,16,&buf16);
|
|
99 |
logger.WriteFormat(K8BitFormatText,8,&buf8);
|
|
100 |
logger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16);
|
|
101 |
|
|
102 |
_LIT(KMessage5,"ALL API's Called - Call Close(),\r\nHit Any Key\r\n");
|
|
103 |
console->Printf(KMessage5);
|
|
104 |
console->Getch();
|
|
105 |
logger.Close();
|
|
106 |
|
|
107 |
CleanupStack::PopAndDestroy(console);
|
|
108 |
|
|
109 |
}
|
|
110 |
|
|
111 |
// Entry point for all Epoc32 executables
|
|
112 |
// See PSP Chapter 2 Getting Started
|
|
113 |
GLDEF_C TInt E32Main()
|
|
114 |
{
|
|
115 |
// Heap balance checking
|
|
116 |
// See PSP Chapter 6 Error Handling
|
|
117 |
__UHEAP_MARK;
|
|
118 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
119 |
if(cleanup == NULL)
|
|
120 |
{
|
|
121 |
return KErrNoMemory;
|
|
122 |
}
|
|
123 |
TRAPD(err,MainL());
|
|
124 |
_LIT(KPanic,"LoggerTest");
|
|
125 |
__ASSERT_ALWAYS(!err, User::Panic(KPanic,err));
|
|
126 |
delete cleanup;
|
|
127 |
__UHEAP_MARKEND;
|
|
128 |
return KErrNone;
|
|
129 |
}
|