builder/com.nokia.carbide.cdt.builder.test/data/TestProject/src/TestProject.cpp
author tzelaw
Tue, 14 Apr 2009 15:03:19 -0500
changeset 94 d74b720418db
parent 2 d760517a8095
permissions -rw-r--r--
Test framework support: Ask debugger to remember DebugTarget so test framework can use it to setup test framework related utility. With this we can use the DebugUI way of launching while keeping test framework functionality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
cawthron
parents:
diff changeset
     1
/*
cawthron
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
cawthron
parents:
diff changeset
     3
* All rights reserved.
cawthron
parents:
diff changeset
     4
* This component and the accompanying materials are made available
cawthron
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
cawthron
parents:
diff changeset
     6
* which accompanies this distribution, and is available
cawthron
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
cawthron
parents:
diff changeset
     8
*
cawthron
parents:
diff changeset
     9
* Initial Contributors:
cawthron
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
cawthron
parents:
diff changeset
    11
*
cawthron
parents:
diff changeset
    12
* Contributors:
cawthron
parents:
diff changeset
    13
*
cawthron
parents:
diff changeset
    14
* Description: 
cawthron
parents:
diff changeset
    15
*
cawthron
parents:
diff changeset
    16
*/
cawthron
parents:
diff changeset
    17
cawthron
parents:
diff changeset
    18
//  Include Files  
cawthron
parents:
diff changeset
    19
cawthron
parents:
diff changeset
    20
#include "TestProject.h"
cawthron
parents:
diff changeset
    21
#include <e32base.h>
cawthron
parents:
diff changeset
    22
#include <e32std.h>
cawthron
parents:
diff changeset
    23
#include <e32cons.h>			// Console
cawthron
parents:
diff changeset
    24
cawthron
parents:
diff changeset
    25
//  Constants
cawthron
parents:
diff changeset
    26
cawthron
parents:
diff changeset
    27
_LIT(KTextConsoleTitle, "Console");
cawthron
parents:
diff changeset
    28
_LIT(KTextFailed, " failed, leave code = %d");
cawthron
parents:
diff changeset
    29
_LIT(KTextPressAnyKey, " [press any key]\n");
cawthron
parents:
diff changeset
    30
cawthron
parents:
diff changeset
    31
//  Global Variables
cawthron
parents:
diff changeset
    32
cawthron
parents:
diff changeset
    33
LOCAL_D CConsoleBase* console; // write all messages to this
cawthron
parents:
diff changeset
    34
cawthron
parents:
diff changeset
    35
cawthron
parents:
diff changeset
    36
//  Local Functions
cawthron
parents:
diff changeset
    37
cawthron
parents:
diff changeset
    38
LOCAL_C void MainL()
cawthron
parents:
diff changeset
    39
	{
cawthron
parents:
diff changeset
    40
	//
cawthron
parents:
diff changeset
    41
	// add your program code here, example code below
cawthron
parents:
diff changeset
    42
	//
cawthron
parents:
diff changeset
    43
	console->Write(_L("Hello, world!\n"));
cawthron
parents:
diff changeset
    44
	}
cawthron
parents:
diff changeset
    45
cawthron
parents:
diff changeset
    46
LOCAL_C void DoStartL()
cawthron
parents:
diff changeset
    47
	{
cawthron
parents:
diff changeset
    48
	// Create active scheduler (to run active objects)
cawthron
parents:
diff changeset
    49
	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
cawthron
parents:
diff changeset
    50
	CleanupStack::PushL(scheduler);
cawthron
parents:
diff changeset
    51
	CActiveScheduler::Install(scheduler);
cawthron
parents:
diff changeset
    52
cawthron
parents:
diff changeset
    53
	MainL();
cawthron
parents:
diff changeset
    54
cawthron
parents:
diff changeset
    55
	// Delete active scheduler
cawthron
parents:
diff changeset
    56
	CleanupStack::PopAndDestroy(scheduler);
cawthron
parents:
diff changeset
    57
	}
cawthron
parents:
diff changeset
    58
cawthron
parents:
diff changeset
    59
//  Global Functions
cawthron
parents:
diff changeset
    60
cawthron
parents:
diff changeset
    61
GLDEF_C TInt E32Main()
cawthron
parents:
diff changeset
    62
	{
cawthron
parents:
diff changeset
    63
	// Create cleanup stack
cawthron
parents:
diff changeset
    64
	__UHEAP_MARK;
cawthron
parents:
diff changeset
    65
	CTrapCleanup* cleanup = CTrapCleanup::New();
cawthron
parents:
diff changeset
    66
cawthron
parents:
diff changeset
    67
	// Create output console
cawthron
parents:
diff changeset
    68
	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(
cawthron
parents:
diff changeset
    69
			KConsFullScreen, KConsFullScreen)));
cawthron
parents:
diff changeset
    70
	if (createError)
cawthron
parents:
diff changeset
    71
		return createError;
cawthron
parents:
diff changeset
    72
cawthron
parents:
diff changeset
    73
	// Run application code inside TRAP harness, wait keypress when terminated
cawthron
parents:
diff changeset
    74
	TRAPD(mainError, DoStartL());
cawthron
parents:
diff changeset
    75
	if (mainError)
cawthron
parents:
diff changeset
    76
		console->Printf(KTextFailed, mainError);
cawthron
parents:
diff changeset
    77
	console->Printf(KTextPressAnyKey);
cawthron
parents:
diff changeset
    78
	console->Getch();
cawthron
parents:
diff changeset
    79
cawthron
parents:
diff changeset
    80
	delete console;
cawthron
parents:
diff changeset
    81
	delete cleanup;
cawthron
parents:
diff changeset
    82
	__UHEAP_MARKEND;
cawthron
parents:
diff changeset
    83
	return KErrNone;
cawthron
parents:
diff changeset
    84
	}
cawthron
parents:
diff changeset
    85