sysstatemgmt/systemstatemgr/test/testapps/src/ssmtestappsucessfulafterretry.cpp
branchRCL_3
changeset 22 8cb079868133
parent 21 ccb4f6b3db21
equal deleted inserted replaced
21:ccb4f6b3db21 22:8cb079868133
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17  @file
    17  @file
    18  @test
    18  @test
    19  @internalComponent - Internal Symbian test code
    19  @internalComponent - Internal Symbian test code
    20 */
    20 */
    21 
    21 
    22 #include <s32file.h>
    22 #include <eikstart.h> 
    23 #include <f32file.h>
    23 #include <eikapp.h>
       
    24 #include "ssmtestappsucessfulafterretry.h"
    24 #include "ssmtestapps.h"
    25 #include "ssmtestapps.h"
    25 
    26 
    26 // This exe fails to start for a specified number of times given in failCount, 
    27 
    27 // decrements the failCount each time and starts successfully once the fail count is exhausted
    28 /**
    28 static void StartProcessL()
    29 Standard DLL entry point function.
    29 {
    30 Creates and returns an instance of the CApaApplication-derived class.
       
    31 @return an instance of the CApaApplication-derived class
       
    32 */
       
    33 TInt E32Main()
       
    34 	{
       
    35 	return EikStart::RunApplication(CTestFAndFApplication::NewApplication);
       
    36 	}
       
    37 
       
    38 CTestFAndFApplication::CTestFAndFApplication()
       
    39 	{
       
    40 	}
       
    41 
       
    42 CTestFAndFApplication::~CTestFAndFApplication()
       
    43 	{
       
    44 	}
       
    45 		
       
    46 /**
       
    47 @return The application's UID 
       
    48 */
       
    49 TUid CTestFAndFApplication::AppDllUid() const
       
    50 	{
       
    51 	const TUid dll = {KTestAppForFAndFUid};
       
    52 	return dll;
       
    53 	}
       
    54 
       
    55 /**
       
    56 @return CTestFAndFApplication or NULL if KErrNoMemory
       
    57 */
       
    58 CApaApplication* CTestFAndFApplication::NewApplication()
       
    59 	{
       
    60 	// As the framework has at this point not started up enough, and therefore the TRAP-harness and 
       
    61 	// exception handlers aren’t available yet, this factory function is a non-leaving function and 
       
    62 	// can't use the new(Eleave) operator.
       
    63 	return new CTestFAndFApplication();
       
    64 	}
       
    65 	
       
    66 /**
       
    67 Called by the UI framework at application start-up to create an instance of the document class.
       
    68 @leave	KErrNoMemory
       
    69 @return A CTestFAndFDocument
       
    70 */
       
    71 CApaDocument* CTestFAndFApplication::CreateDocumentL()
       
    72 	{
       
    73 	return CTestFAndFDocument::NewL(*this);
       
    74 	}
       
    75 
       
    76 CTestFAndFDocument::CTestFAndFDocument(CEikApplication& aApp) : CEikDocument(aApp)
       
    77 	{
       
    78 	}
       
    79 
       
    80 CTestFAndFDocument::~CTestFAndFDocument()
       
    81 	{
       
    82 	}
       
    83 
       
    84 /**
       
    85 Factory function for this class
       
    86 @return a new CEndTaskTestDocument instance.
       
    87 */
       
    88 CTestFAndFDocument* CTestFAndFDocument::NewL(CEikApplication& aApp)
       
    89 	{
       
    90 	return new(ELeave) CTestFAndFDocument(aApp);
       
    91 	}
       
    92 
       
    93 
       
    94 
       
    95 /**
       
    96 Called by the UI framework to construct the application UI class. 
       
    97 Note that the app UI's ConstructL() is called by the UI framework.
       
    98 */
       
    99 CEikAppUi* CTestFAndFDocument::CreateAppUiL()
       
   100 	{
       
   101 	return new(ELeave) CTestFAndFAppUi();
       
   102 	}
       
   103 
       
   104 
       
   105 
       
   106 CTestFAndFAppUi::CTestFAndFAppUi()
       
   107 	{
       
   108 	}
       
   109 
       
   110 
       
   111 
       
   112 CTestFAndFAppUi::~CTestFAndFAppUi()
       
   113 	{
       
   114 	}
       
   115 
       
   116 
       
   117 
       
   118 void CTestFAndFAppUi::ConstructL()
       
   119 	{
       
   120 	// Complete the UI framework's construction of the App UI.
       
   121 	BaseConstructL(CEikAppUi::ENoAppResourceFile);
       
   122 	
    30 	RFs fs;
   123 	RFs fs;
    31 	RFileReadStream readStream;
   124 	RFileReadStream readStream;
    32 	RFileWriteStream writeStream;
   125 	RFileWriteStream writeStream;
    33 					
   126 					
    34 	CleanupClosePushL(fs);
   127 	CleanupClosePushL(fs);
    64 
   157 
    65 		// StartSafe will restart the process
   158 		// StartSafe will restart the process
    66 		RProcess::Rendezvous(KErrGeneral);
   159 		RProcess::Rendezvous(KErrGeneral);
    67 		}
   160 		}
    68 	CleanupStack::PopAndDestroy(3, &fs);
   161 	CleanupStack::PopAndDestroy(3, &fs);
    69 }
       
    70 
       
    71 /**
       
    72 Process entry point function.
       
    73 @return KErrNone if successful; KErrNoMemory if there is insufficient memory; otherwise, one of the other system-wide error codes.
       
    74 */
       
    75 TInt E32Main()
       
    76 	{
       
    77     CTrapCleanup* cleanup=CTrapCleanup::New();
       
    78 	
       
    79 	TInt error = KErrNoMemory;
       
    80 	if (cleanup)
       
    81 		{
       
    82 		TRAP(error, StartProcessL());
       
    83 		delete cleanup;
       
    84 		}
       
    85 
       
    86 	if (KErrNone != error)
       
    87 		{
       
    88 		User::Panic(_L("SUCCESSFULRETRY"),error);
       
    89 		}
       
    90 	User::WaitForAnyRequest();
       
    91 	return error;
       
    92 	}
   162 	}
    93 
   163 
    94 
   164