testdev/ite/test/com.nokia.testfw.cmdtool.test/test.resource/unittest/standard/testThread/src/testThread.cpp
changeset 1 96906a986c3b
equal deleted inserted replaced
0:f1112f777ce9 1:96906a986c3b
       
     1 /*
       
     2 ============================================================================
       
     3  Name		: testThread.cpp
       
     4  Author	  : Yue Zhang
       
     5  Copyright   : Test Product Team, Symbian
       
     6  Description : Exe source file
       
     7 ============================================================================
       
     8 */
       
     9 
       
    10 //  Include Files  
       
    11 
       
    12 #include "testThread.h"
       
    13 #include <e32base.h>
       
    14 #include <e32std.h>
       
    15 #include <e32cons.h>			// Console
       
    16 #include "child.h"
       
    17 
       
    18 
       
    19 //  Constants
       
    20 
       
    21 _LIT(KTextConsoleTitle, "Console");
       
    22 _LIT(KTextFailed, " failed, leave code = %d");
       
    23 _LIT(KTextPressAnyKey, " [press any key]\n");
       
    24 
       
    25 //  Global Variables
       
    26 
       
    27 LOCAL_D CConsoleBase* console;  // write all messages to this
       
    28 
       
    29 /*
       
    30 TInt threadFunc(TAny*)
       
    31 	{
       
    32 	for(TInt i=0;i<10;++i)
       
    33 		{
       
    34 		User::InfoPrint(_L("Thread..."));
       
    35 		User::After(4000000);
       
    36 		}
       
    37 	return 0;
       
    38 	}
       
    39 */
       
    40 
       
    41 //  Local Functions
       
    42 LOCAL_C void MainL()
       
    43 	{
       
    44 	//
       
    45 	// add your program code here, example code below
       
    46 	//
       
    47 	MParent* a = new (ELeave)CChild();
       
    48 	static_cast<CChild*>(a)->Add();
       
    49 	delete a;
       
    50 	a = NULL;
       
    51 	console->Write(_L("Hello, world!\n"));
       
    52 	
       
    53 	//RThread thd;
       
    54 	//User::LeaveIfError(thd.Create(_L("MyThread"), threadFunc, KDefaultStackSize,NULL, NULL));
       
    55 	//thd.Resume();
       
    56 	}
       
    57 
       
    58 LOCAL_C void DoStartL()
       
    59 	{
       
    60 	// Create active scheduler (to run active objects)
       
    61 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
       
    62 	CleanupStack::PushL(scheduler);
       
    63 	CActiveScheduler::Install(scheduler);
       
    64 	
       
    65 	MainL();
       
    66 
       
    67 	// Delete active scheduler
       
    68 	CleanupStack::PopAndDestroy(scheduler);
       
    69 	}
       
    70 
       
    71 
       
    72 //  Global Functions
       
    73 
       
    74 GLDEF_C TInt E32Main()
       
    75 	{
       
    76 	// Create cleanup stack
       
    77 	__UHEAP_MARK;
       
    78 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    79 
       
    80 	// Create output console
       
    81 	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
       
    82 	if (createError)
       
    83 		return createError;
       
    84 
       
    85 	// Run application code inside TRAP harness, wait keypress when terminated
       
    86 	TRAPD(mainError, DoStartL());
       
    87 	if (mainError)
       
    88 		console->Printf(KTextFailed, mainError);
       
    89 	console->Printf(KTextPressAnyKey);
       
    90 	console->Getch();
       
    91 	
       
    92 	delete console;
       
    93 	delete cleanup;
       
    94 	__UHEAP_MARKEND;
       
    95 	return KErrNone;
       
    96 	}
       
    97 
       
    98 
       
    99