testdev/ite/test/com.nokia.testfw.cmdtool.test/test.resource/unittest/several.mmp.in.one.path/SysLibs/CommonFramework/CommonFramework.h
author Johnson Ma <johnson.ma@nokia.com>
Tue, 30 Mar 2010 14:39:29 +0800
changeset 1 96906a986c3b
permissions -rw-r--r--
contribute ITE to symbian foundation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     1
// CommonFramework.h
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     2
//
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     3
// Copyright (c) 2000 Symbian Ltd.  All rights reserved.
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     4
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     5
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     6
#ifndef __CommonFramework_H
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     7
#define __CommonFramework_H
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     8
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     9
#include <e32base.h>
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    10
#include <e32cons.h>
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    11
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    12
_LIT(KTxtEPOC32EX,"EXAMPLES");
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    13
_LIT(KTxtExampleCode,"Symbian OS Example Code");
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    14
_LIT(KFormatFailed,"failed: leave code=%d");
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    15
_LIT(KTxtOK,"ok");
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    16
_LIT(KTxtPressAnyKey," [press any key]");
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    17
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    18
// public
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    19
LOCAL_D CConsoleBase* console; // write all your messages to this
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    20
LOCAL_C void doExampleL(); // code this function for the real example
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    21
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    22
// private
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    23
LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    24
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    25
GLDEF_C TInt E32Main() // main function called by E32
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    26
    {
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    27
	__UHEAP_MARK;
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    28
	CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    29
	TRAPD(error,callExampleL()); // more initialization, then do example
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    30
	__ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    31
	delete cleanup; // destroy clean-up stack
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    32
	__UHEAP_MARKEND;
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    33
	return 0; // and return
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    34
    }
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    35
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    36
LOCAL_C void callExampleL() // initialize and call example code under cleanup stack
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    37
    {
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    38
	console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    39
	CleanupStack::PushL(console);
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    40
	TRAPD(error,doExampleL()); // perform example function
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    41
	if (error)
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    42
		console->Printf(KFormatFailed, error);
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    43
	else
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    44
		console->Printf(KTxtOK);
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    45
	console->Printf(KTxtPressAnyKey);
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    46
	console->Getch(); // get and ignore character
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    47
	CleanupStack::PopAndDestroy(); // close console
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    48
    }
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    49
96906a986c3b contribute ITE to symbian foundation
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    50
#endif