localisation/apparchitecture/tef/T_EnvSlots/T_EnvSlots.CPP
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2005-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Test Application for verification of environment slots\n
       
    15 // Calls the EnvironmentSlotsReaderL function and verfies the CApaCommandLine object returned  \n
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalComponent - Internal Symbian test code 
       
    24 */
       
    25 
       
    26 
       
    27 #include "T_EnvSlots.H"
       
    28 
       
    29 /**
       
    30   
       
    31    Application invoked as part of CommandLine tests
       
    32   
       
    33    @SYMPREQ 280 File Handle Support
       
    34   
       
    35    FunctionDesc Tests Environment slots . 
       
    36    Acquires a Mutex for log file access
       
    37    Invokes EnvironmentSlotsReaderL() which returns an CApaCommandLine Object
       
    38    Verifies the values returned by the GET APIs of CApaCommandLine object with those of predefined values
       
    39    Writes "Pass" to the logfile if verification passes else "Fail" is written.
       
    40   
       
    41  */
       
    42 void testEnvironmentSlotsL()
       
    43 	{
       
    44 
       
    45 	TPtrC appName;
       
    46 	TPtrC docName;
       
    47 	TApaCommand command = EApaCommandOpen;
       
    48 	TBool testResult = PASS;
       
    49 	
       
    50 		
       
    51 	//Get the Mutex to access the log file
       
    52 	RMutex fileAccess;
       
    53 	fileAccess.OpenGlobal(KTLogFileAccess);
       
    54 	fileAccess.Wait();
       
    55 			
       
    56 	/** Invoke EnvironmenstSlotsReaderL() function which would constuct the CApaCommandLine class object
       
    57 	from the environment slots and return the pointer to that object */
       
    58 	//CApaCommandLine* cmdLine = CApaCommandLine::EnvironmentSlotsReaderL(); 
       
    59 	
       
    60 	//Method CApaCommandLine::EnvironmentSlotsReaderL has been implemented in a different fashion
       
    61 	CApaCommandLine* cmdLine;
       
    62 	CApaCommandLine::GetCommandLineFromProcessEnvironment(cmdLine);
       
    63 
       
    64 	CleanupStack::PushL(cmdLine);
       
    65     				
       
    66     appName.Set(KTAppName);
       
    67 	docName.Set(KTDocName);
       
    68 	
       
    69 	RFs fSession;
       
    70 	fSession.Connect();
       
    71 	RFile logFile;
       
    72 	TBufC<KMaxFilePath> testFilePath(KFilePath);
       
    73 	
       
    74 	//Open the Log file in Write Mode			
       
    75 	User::LeaveIfError(logFile.Replace(fSession,testFilePath,EFileWrite));
       
    76 		
       
    77 	// Compare the values returned by GET APIs with pre defined values	
       
    78 	TESTCOND(appName,cmdLine->ExecutableName());
       
    79 	
       
    80 	if(appName != cmdLine->ExecutableName())
       
    81 	{
       
    82 		logFile.Write(KTFail);
       
    83 		logFile.Write(KTApp);
       
    84 	}
       
    85 		
       
    86 	TESTCOND(docName,cmdLine->DocumentName());
       
    87 	if(docName != cmdLine->DocumentName())
       
    88 	{
       
    89 		logFile.Write(KTFail);
       
    90 		logFile.Write(KTDoc);
       
    91 	}
       
    92 	
       
    93     TESTCOND(command,cmdLine->Command());
       
    94 	
       
    95 	if(command != cmdLine->Command())
       
    96 	{
       
    97 		logFile.Write(KTFail);
       
    98 		logFile.Write(KTCommand);
       
    99 	}
       
   100 	          
       
   101     if(testResult == PASS)
       
   102     	{
       
   103     	logFile.Write(KTPass);
       
   104     	}
       
   105   
       
   106     	
       
   107     //Close the file and the file session
       
   108     logFile.Close();
       
   109     fSession.Close();
       
   110     
       
   111     //Signal the Mutex
       
   112     fileAccess.Signal();  
       
   113     CleanupStack::PopAndDestroy(cmdLine); 
       
   114 
       
   115 	}
       
   116 
       
   117 
       
   118 GLDEF_C TInt E32Main()
       
   119 /**
       
   120    EXE Entry Point
       
   121    @return - Standard Epoc error code on exit
       
   122  */
       
   123 	{
       
   124 	
       
   125 	__UHEAP_MARK;
       
   126 	
       
   127 	CTrapCleanup* cleanupStack = CTrapCleanup::New();
       
   128 	
       
   129 	TRAPD(error,testEnvironmentSlotsL());
       
   130 	
       
   131 	__ASSERT_ALWAYS(!error,User::Panic(KTEnvSlots,error));
       
   132 	
       
   133 	delete cleanupStack;
       
   134 	
       
   135 	__UHEAP_MARKEND;
       
   136 	
       
   137 	return KErrNone;
       
   138 	}