sysstatemgmt/systemstarter/test/tstartupproperties/src/tstartupproperties_stepdefval.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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 <barsread.h> //TResourceReader
       
    23 #include <barsc.h> //RResourceFile
       
    24 #include <e32modes.h> //EStartupModeUndefined
       
    25 #include <startupproperties.h>
       
    26 #include <tstartupproperties.rsg> 
       
    27 #include "tstartupproperties_stepdefval.h"
       
    28 
       
    29 _LIT(KStartupPropertiesTestRsc,"z:\\resource\\test\\tstartupproperties.rsc");
       
    30 
       
    31 CStartupPropertiesTestStepDefVal::CStartupPropertiesTestStepDefVal()
       
    32 	{
       
    33 	SetTestStepName (KCTestCaseDefVal);
       
    34 	}
       
    35 
       
    36 /**
       
    37 Old Test CaseID 		APPFWK-STARTUPPROPERTIES-0001
       
    38 New Test CaseID 		DEVSRVS-SYSSTART-STARTUPPROPERTIES-0001
       
    39  */
       
    40 TVerdict CStartupPropertiesTestStepDefVal::doTestStepL()
       
    41 	{
       
    42 	INFO_PRINTF1(_L("APPFWK-STARTUPPROPERTIES-0001"));
       
    43 	
       
    44 	RFs fsSession;
       
    45 	User::LeaveIfError(fsSession.Connect());
       
    46 	CleanupClosePushL (fsSession);
       
    47 	
       
    48 	RResourceFile rFile;
       
    49 	TRAPD(err, rFile.OpenL(fsSession, KStartupPropertiesTestRsc));
       
    50 	if(err)
       
    51 		{
       
    52 		ERR_PRINTF3(_L("Problem %d with test resource file %S"), err, &KStartupPropertiesTestRsc );
       
    53 		User::Leave(err);
       
    54 		}
       
    55 	CleanupClosePushL (rFile);
       
    56 	
       
    57 	TestDefaultValues_CtorL();
       
    58 	TestDefaultValues_START_APP_INFOL(rFile);
       
    59 	TestDefaultValues_START_APP_INFO2L(rFile);
       
    60 	TestDefaultValues_START_PROCESS_INFOL(rFile);
       
    61 	TestDefaultValues_START_PROCESS_INFO2L(rFile);
       
    62 	
       
    63 	CleanupStack::PopAndDestroy(&rFile);
       
    64 	CleanupStack::PopAndDestroy(&fsSession);
       
    65 
       
    66 	return TestStepResult();
       
    67 	}
       
    68 
       
    69 CStartupProperties* CStartupPropertiesTestStepDefVal::CreateFromResourceLC(RResourceFile& aRFile, TInt aResourceId)
       
    70 	{
       
    71 	HBufC8* resource = aRFile.AllocReadLC (aResourceId);
       
    72 	TResourceReader reader;
       
    73 	reader.SetBuffer(resource);
       
    74 	CStartupProperties* prop = CStartupProperties::NewL(reader);
       
    75 	CleanupStack::PopAndDestroy(); //resource
       
    76 	CleanupStack::PushL (prop);
       
    77 	return prop;
       
    78 	}
       
    79 
       
    80 /** Verify default values set by C++ c'tor */
       
    81 void CStartupPropertiesTestStepDefVal::TestDefaultValues_CtorL()
       
    82 	{
       
    83 	INFO_PRINTF1(_L("Verifying default values set by C++ c'tor"));	
       
    84 	CStartupProperties* cprop = CStartupProperties::NewLC();
       
    85 	TEST(cprop->Version() 				== 1);
       
    86 	TEST(cprop->StartupType() 			== EStartProcess);
       
    87 	TEST(cprop->StartMethod() 			== EFireAndForget);
       
    88 	TEST(cprop->RecoveryMethod()		== EIgnoreOnFailure);
       
    89 	TEST(cprop->RestartMode() 			== EStartupModeUndefined);
       
    90 	// values here below not explicit initialised in c'tor
       
    91 	TEST(cprop->ActionOnCommandFailure()== EIgnoreCommandFailure);
       
    92 	TEST(cprop->FileName() 				== KNullDesC);
       
    93 	TEST(cprop->Args() 					== KNullDesC);
       
    94 	TEST(cprop->Viewless() 				== EFalse);
       
    95 	TEST(cprop->StartInBackground()		== EFalse);
       
    96 	TEST(cprop->Timeout() 				== 0);
       
    97 	TEST(cprop->NoOfRetries() 			== 0);
       
    98 	TEST(cprop->Version() 				== 1);
       
    99 	TEST(cprop->Monitored() 			== EFalse);
       
   100 	CleanupStack::PopAndDestroy (cprop);
       
   101 	}
       
   102 
       
   103 /** Verify default values set in struct START_APP_INFO */
       
   104 void CStartupPropertiesTestStepDefVal::TestDefaultValues_START_APP_INFOL(RResourceFile& aRFile)
       
   105 	{
       
   106 	INFO_PRINTF1(_L("Verifying default values set in struct START_APP_INFO"));	
       
   107 	CStartupProperties* rapp = CreateFromResourceLC(aRFile, R_APP_INFO_DEFAULT);
       
   108 	TEST(rapp->StartupType() 			== EStartApp);
       
   109 	TEST(rapp->FileName() 				== KNullDesC);
       
   110 	TEST(rapp->Args() 					== KNullDesC);
       
   111 	TEST(rapp->StartMethod() 			== EFireAndForget);
       
   112 	TEST(rapp->Viewless() 				== EFalse);
       
   113 	TEST(rapp->StartInBackground()		== EFalse);
       
   114 	TEST(rapp->Timeout() 				== 0);
       
   115 	TEST(rapp->ActionOnCommandFailure() == EPanicOnCommandFailure);
       
   116 	TEST(rapp->NoOfRetries() 			== 0);
       
   117 	// verify the ones not used by this struct as well
       
   118 	TEST(rapp->RecoveryMethod()			== ERestartOS);
       
   119 	TEST(rapp->Version() 				== 1);
       
   120 	TEST(rapp->RestartMode() 			== EStartupModeUndefined);
       
   121 	TEST(rapp->Monitored() 				== EFalse);
       
   122 	CleanupStack::PopAndDestroy (rapp);
       
   123 	}
       
   124 	
       
   125 /** Verify default values set in struct START_APP_INFO2 */
       
   126 void CStartupPropertiesTestStepDefVal::TestDefaultValues_START_APP_INFO2L(RResourceFile& aRFile)
       
   127 	{
       
   128 	INFO_PRINTF1(_L("Verifying default values set in struct START_APP_INFO2"));	
       
   129 	CStartupProperties* rapp2 = CreateFromResourceLC(aRFile, R_APP_INFO2_DEFAULT);
       
   130 	TEST(rapp2->StartupType() 			== EStartApp);
       
   131 	TEST(rapp2->FileName() 				== KNullDesC);
       
   132 	TEST(rapp2->Args() 					== KNullDesC);
       
   133 	TEST(rapp2->StartMethod() 			== EFireAndForget);
       
   134 	TEST(rapp2->Viewless() 				== EFalse);
       
   135 	TEST(rapp2->StartInBackground()		== EFalse);
       
   136 	TEST(rapp2->Timeout() 				== 0);
       
   137 	TEST(rapp2->RecoveryMethod()		== ERestartOS);
       
   138 	TEST(rapp2->NoOfRetries() 			== 0);
       
   139 	TEST(rapp2->Monitored() 			== EFalse);
       
   140 	TEST(rapp2->RestartMode() 			== EStartupModeUndefined);
       
   141 	// verify the ones not used by this struct as well
       
   142 	TEST(rapp2->ActionOnCommandFailure()== EPanicOnCommandFailure);
       
   143 	TEST(rapp2->Version() 				== 1);
       
   144 	CleanupStack::PopAndDestroy (rapp2);
       
   145 	}
       
   146 
       
   147 /** Verify default values set in struct START_PROCESS_INFO */
       
   148 void CStartupPropertiesTestStepDefVal::TestDefaultValues_START_PROCESS_INFOL(RResourceFile& aRFile)
       
   149 	{
       
   150 	INFO_PRINTF1(_L("Verifying default values set in struct START_PROCESS_INFO"));		
       
   151 	CStartupProperties* rproc = CreateFromResourceLC(aRFile, R_PROCESS_INFO_DEFAULT);
       
   152 	TEST(rproc->StartupType() 			== EStartProcess);
       
   153 	TEST(rproc->FileName() 				== KNullDesC);
       
   154 	TEST(rproc->Args() 					== KNullDesC);
       
   155 	TEST(rproc->StartMethod() 			== EFireAndForget);
       
   156 	TEST(rproc->Timeout() 				== 0);
       
   157 	TEST(rproc->ActionOnCommandFailure()== EPanicOnCommandFailure);
       
   158 	TEST(rproc->NoOfRetries() 			== 0);
       
   159 	// verify the ones not used by this struct as well
       
   160 	TEST(rproc->RecoveryMethod()		== ERestartOS);
       
   161 	TEST(rproc->Version() 				== 1);	
       
   162 	TEST(rproc->Viewless() 				== EFalse);
       
   163 	TEST(rproc->StartInBackground()		== EFalse);
       
   164 	TEST(rproc->Monitored() 			== EFalse);
       
   165 	TEST(rproc->RestartMode() 			== EStartupModeUndefined);
       
   166 	CleanupStack::PopAndDestroy (rproc);
       
   167 	}
       
   168 	
       
   169 /** Verify default values set in struct START_PROCESS_INFO2 */
       
   170 void CStartupPropertiesTestStepDefVal::TestDefaultValues_START_PROCESS_INFO2L(RResourceFile& aRFile)
       
   171 	{
       
   172 	INFO_PRINTF1(_L("Verifying default values set in struct START_PROCESS_INFO2"));			
       
   173 	CStartupProperties* rproc2 = CreateFromResourceLC(aRFile, R_PROCESS_INFO2_DEFAULT);
       
   174 	TEST(rproc2->StartupType() 			== EStartProcess);
       
   175 	TEST(rproc2->FileName() 			== KNullDesC);
       
   176 	TEST(rproc2->Args() 				== KNullDesC);
       
   177 	TEST(rproc2->StartMethod() 			== EFireAndForget);
       
   178 	TEST(rproc2->Timeout() 				== 0);
       
   179 	TEST(rproc2->RecoveryMethod()		== ERestartOS);
       
   180 	TEST(rproc2->NoOfRetries() 			== 0);
       
   181 	TEST(rproc2->Monitored() 			== EFalse);
       
   182 	TEST(rproc2->RestartMode() 			== EStartupModeUndefined);
       
   183 	// verify the ones not used by this struct as well
       
   184 	TEST(rproc2->ActionOnCommandFailure()== EPanicOnCommandFailure);
       
   185 	TEST(rproc2->Version() 				== 1);	
       
   186 	TEST(rproc2->Viewless() 			== EFalse);
       
   187 	TEST(rproc2->StartInBackground()	== EFalse);
       
   188 	CleanupStack::PopAndDestroy(rproc2);
       
   189 	}