lafagnosticuifoundation/cone/tef/TErrMsgApp.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #include "TErrMsgApp.h"
       
    23 #include <e32std.h>
       
    24 
       
    25 CApaCommandLine* iCmdLine;
       
    26 
       
    27 void CErrMsgTestAppUi::ConstructL()
       
    28     {
       
    29     BaseConstructL(ENoAppResourceFile | ENoScreenFurniture);
       
    30 	ExecuteCmdLineL();
       
    31 	}
       
    32 
       
    33 CErrMsgTestAppUi::~CErrMsgTestAppUi()
       
    34 	{
       
    35 	delete iCmdLine;
       
    36 	}
       
    37 
       
    38 void CErrMsgTestAppUi::HandleCommandL(TInt /*aCommand*/)
       
    39 	{
       
    40 	// app is designed to execute the cmdline and exit, so should not reach
       
    41 	// this point
       
    42 	User::Leave(KErrGeneral);
       
    43 	}
       
    44 
       
    45 
       
    46 void CErrMsgTestAppUi::HandleSystemEventL(const TWsEvent& /*aEvent*/)
       
    47 	{
       
    48 	// app is designed to execute the cmdline and exit, so should not reach
       
    49 	// this point
       
    50 	User::Leave(KErrGeneral);
       
    51 	}
       
    52 
       
    53 void CErrMsgTestAppUi::ExecuteCmdLineL()
       
    54 	{
       
    55 	TPtrC8 tailEnd = iCmdLine->TailEnd();
       
    56 	_LIT8(KTestCaseErrMsg,"UIF-CONE-0015 ErrMsg");
       
    57 	_LIT8(KTestCaseErrAndConMsg,"UIF-CONE-0014 ErrAndConMsg");
       
    58 	
       
    59 	TBuf<32> tailEndBuf;
       
    60 	tailEndBuf.Copy(tailEnd);
       
    61 	RDebug::Print(_L("tail:%S"),&tailEndBuf);
       
    62 	
       
    63 	_LIT(KTestErrMsg, "Test Error Message");
       
    64 	TBuf<80> errText(KTestErrMsg);
       
    65 	RBuf testMsg;
       
    66 	testMsg.CreateL(errText);
       
    67 	testMsg.CleanupClosePushL();
       
    68 	
       
    69 	if(tailEnd==KTestCaseErrAndConMsg)
       
    70 		{
       
    71 		_LIT(KTestErrConMsg, "Test Context Error Message");
       
    72 		TBuf<40> errConText(KTestErrConMsg);
       
    73 		RBuf testConMsg;
       
    74 		testConMsg.CreateL(errConText);
       
    75 		testConMsg.CleanupClosePushL();
       
    76 		
       
    77 		iCoeEnv->LeaveWithErrorText(testMsg, &testConMsg);
       
    78 		CleanupStack::PopAndDestroy(&testConMsg);
       
    79 		}
       
    80 	else if (tailEnd==KTestCaseErrMsg)
       
    81 		{
       
    82 		iCoeEnv->LeaveWithErrorText(testMsg);
       
    83 		}
       
    84 		
       
    85 	CleanupStack::PopAndDestroy(&testMsg);
       
    86 	}
       
    87 
       
    88 CErrMsgTestDocument::CErrMsgTestDocument(CEikApplication& aApp)
       
    89 		: CEikDocument(aApp)
       
    90 	{
       
    91 	}
       
    92 
       
    93 CEikAppUi* CErrMsgTestDocument::CreateAppUiL()
       
    94 	{
       
    95     return new(ELeave) CErrMsgTestAppUi;
       
    96 	}
       
    97 
       
    98 
       
    99 const TUid KUidTErrMsgApp = { 0x102827C5 }; 
       
   100 
       
   101 TUid CErrMsgTestApp::AppDllUid() const
       
   102 	{
       
   103 	return KUidTErrMsgApp;
       
   104 	}
       
   105 
       
   106 
       
   107 TFileName CErrMsgTestApp::ResourceFileName() const
       
   108 {
       
   109 	return TFileName(); // this app doesn't have a resource file
       
   110 }
       
   111 
       
   112 CApaDocument* CErrMsgTestApp::CreateDocumentL()
       
   113 	{
       
   114 	return new (ELeave) CErrMsgTestDocument(*this);
       
   115 	}
       
   116 
       
   117 
       
   118 LOCAL_C CApaApplication* NewApplication()
       
   119 	{
       
   120 	return new CErrMsgTestApp;
       
   121 	}
       
   122 
       
   123 
       
   124 GLDEF_C TInt E32Main()
       
   125 	{
       
   126 	CApaCommandLine::GetCommandLineFromProcessEnvironment(iCmdLine);
       
   127 
       
   128 	return EikStart::RunApplication(NewApplication);
       
   129 	}
       
   130