uifw/tsrc/public/basic/AknSoundServerStifTest/inc/AknSoundServerStifTest.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  AknSoundServerStifTest test module.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef AKNSOUNDSERVERSTIFTEST_H
       
    19 #define AKNSOUNDSERVERSTIFTEST_H
       
    20 
       
    21 // INCLUDES
       
    22 #include "stiftestmodule.h"
       
    23 #include "aknsoundserversession.h"
       
    24 #include <stiflogger.h>
       
    25 
       
    26 // Officially allocated DLL UID for sound server session.
       
    27 const TInt KDllUid = 0x101FB3E7; 
       
    28 
       
    29 // For logging.
       
    30 _LIT(KAknSoundServerStifTestLogPath, "\\logs\\testframework\\AknSoundServerStifTest\\"); 
       
    31 _LIT(KAknSoundServerStifTestLogFile, "AknSoundServerStifTest.txt"); 
       
    32 _LIT(KAknSoundServerStifTestLogFileWithTitle, "AknSoundServerStifTest_[%S].txt");
       
    33 
       
    34 // CONSTANTS
       
    35 #define GETPTR &
       
    36 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
       
    37 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
       
    38 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
       
    39 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CAknSoundServerStifTest;
       
    43 class CAknAppUi;
       
    44 class CAknKeySoundSystem;
       
    45 
       
    46 // DATA TYPES
       
    47 typedef TInt (CAknSoundServerStifTest::* TestFunction)(TTestResult&);
       
    48 
       
    49 // CLASS DECLARATION
       
    50 
       
    51 /**
       
    52 *  An internal structure containing a test case name and
       
    53 *  the pointer to function doing the test
       
    54 *
       
    55 *  @lib ?library
       
    56 *  @since ?Series60_version
       
    57 */
       
    58 class TCaseInfoInternal
       
    59     {
       
    60 public:
       
    61     const TText*    iCaseName;
       
    62     TestFunction    iMethod;
       
    63     TBool           iIsOOMTest;
       
    64     TInt            iFirstMemoryAllocation;
       
    65     TInt            iLastMemoryAllocation;
       
    66     };
       
    67 
       
    68 // CLASS DECLARATION
       
    69 
       
    70 /**
       
    71 *  A structure containing a test case name and
       
    72 *  the pointer to function doing the test
       
    73 *
       
    74 *  @lib ?library
       
    75 *  @since ?Series60_version
       
    76 */
       
    77 class TCaseInfo
       
    78     {
       
    79 public:
       
    80     TPtrC        iCaseName;
       
    81     TestFunction iMethod;
       
    82     TBool        iIsOOMTest;
       
    83     TInt         iFirstMemoryAllocation;
       
    84     TInt         iLastMemoryAllocation;
       
    85 
       
    86 TCaseInfo(const TText* a) : iCaseName((TText*) a) {};
       
    87     };
       
    88 
       
    89 // CLASS DECLARATION
       
    90 
       
    91 /**
       
    92 *  This a AknSoundServerStifTest class.
       
    93 *  ?other_description_lines
       
    94 *
       
    95 *  @lib ?library
       
    96 *  @since ?Series60_version
       
    97 */
       
    98 NONSHARABLE_CLASS(CAknSoundServerStifTest) : public CTestModuleBase
       
    99     {
       
   100 public:  // Constructors and destructor
       
   101 
       
   102     /**
       
   103     * Two-phased constructor.
       
   104     */
       
   105     static CAknSoundServerStifTest* NewL();
       
   106 
       
   107     /**
       
   108     * Destructor.
       
   109     */
       
   110     virtual ~CAknSoundServerStifTest();
       
   111 
       
   112 public: // Functions from base classes
       
   113 
       
   114     /**
       
   115     * From CTestModuleBase InitL is used to initialize the 
       
   116     *       AknSoundServerStifTest. It is called once for every instance of 
       
   117     *       TestModuleAknSoundServerStifTest after its creation.
       
   118     * @since ?Series60_version
       
   119     * @param aIniFile Initialization file for the test module (optional)
       
   120     * @param aFirstTime Flag is true when InitL is executed for first 
       
   121     *               created instance of AknSoundServerStifTest.
       
   122     * @return Symbian OS error code
       
   123     */
       
   124     TInt InitL(TFileName& aIniFile, TBool aFirstTime);
       
   125 
       
   126     /**
       
   127     * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
       
   128     *   from AknSoundServerStifTest. 
       
   129     * @since ?Series60_version
       
   130     * @param aTestCaseFile Test case file (optional)
       
   131     * @param aTestCases  Array of TestCases returned to test framework
       
   132     * @return Symbian OS error code
       
   133     */
       
   134     TInt GetTestCasesL( 
       
   135         const TFileName& aTestCaseFile, 
       
   136         RPointerArray<TTestCaseInfo>& aTestCases);
       
   137 
       
   138     /**
       
   139     * From CTestModuleBase RunTestCaseL is used to run an individual 
       
   140     *   test case. 
       
   141     * @since ?Series60_version
       
   142     * @param aCaseNumber Test case number
       
   143     * @param aTestCaseFile Test case file (optional)
       
   144     * @param aResult Test case result returned to test framework (PASS/FAIL)
       
   145     * @return Symbian OS error code (test case execution error, which is 
       
   146     *           not reported in aResult parameter as test case failure).
       
   147     */   
       
   148     TInt RunTestCaseL( 
       
   149         const TInt aCaseNumber, 
       
   150         const TFileName& aTestCaseFile,
       
   151         TTestResult& aResult);
       
   152 
       
   153     /**
       
   154     * From CTestModuleBase; OOMTestQueryL is used to specify is particular
       
   155     * test case going to be executed using OOM conditions
       
   156     * @param aTestCaseFile Test case file (optional)
       
   157     * @param aCaseNumber Test case number (optional)
       
   158     * @param aFailureType OOM failure type (optional)
       
   159     * @param aFirstMemFailure The first heap memory allocation failure value (optional)
       
   160     * @param aLastMemFailure The last heap memory allocation failure value (optional)
       
   161     * @return TBool
       
   162     */
       
   163     virtual TBool OOMTestQueryL( 
       
   164         const TFileName& /* aTestCaseFile */, 
       
   165         const TInt /* aCaseNumber */, 
       
   166         TOOMFailureType& aFailureType, 
       
   167         TInt& /* aFirstMemFailure */, 
       
   168         TInt& /* aLastMemFailure */);
       
   169 
       
   170     /**
       
   171     * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
       
   172     * test environment
       
   173     * @param aTestCaseFile Test case file (optional)
       
   174     * @param aCaseNumber Test case number (optional)
       
   175     * @return None
       
   176     */
       
   177     virtual void OOMTestInitializeL( 
       
   178         const TFileName& /* aTestCaseFile */, 
       
   179         const TInt /* aCaseNumber */ ); 
       
   180 
       
   181     /**
       
   182     * From CTestModuleBase; OOMHandleWarningL
       
   183     * @param aTestCaseFile Test case file (optional)
       
   184     * @param aCaseNumber Test case number (optional)
       
   185     * @param aFailNextValue FailNextValue for OOM test execution (optional)
       
   186     * @return None
       
   187     *
       
   188     * User may add implementation for OOM test warning handling. Usually no
       
   189     * implementation is required.           
       
   190     */
       
   191     virtual void OOMHandleWarningL( 
       
   192         const TFileName& /* aTestCaseFile */,
       
   193         const TInt /* aCaseNumber */, 
       
   194         TInt& /* aFailNextValue */); 
       
   195 
       
   196     /**
       
   197     * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
       
   198     * test environment
       
   199     * @param aTestCaseFile Test case file (optional)
       
   200     * @param aCaseNumber Test case number (optional)
       
   201     * @return None
       
   202     */
       
   203     virtual void OOMTestFinalizeL( 
       
   204         const TFileName& /* aTestCaseFile */, 
       
   205         const TInt /* aCaseNumber */ );
       
   206 
       
   207 private:
       
   208     /**
       
   209     * C++ default constructor.
       
   210     */
       
   211     CAknSoundServerStifTest();
       
   212 
       
   213     /**
       
   214     * By default Symbian 2nd phase constructor is private.
       
   215     */
       
   216     void ConstructL();
       
   217 
       
   218     /**
       
   219     * Function returning test case name and pointer to test case function.
       
   220     * @since ?Series60_version
       
   221     * @param aCaseNumber test case number
       
   222     * @return TCaseInfo 
       
   223     */
       
   224     const TCaseInfo Case (const TInt aCaseNumber) const;
       
   225 
       
   226     // --------------
       
   227     // Helper methods
       
   228     // --------------
       
   229     RAknSoundServerSession CreateNewSessionL(TInt aSessionUid);
       
   230     void PushContextL(RAknSoundServerSession& aSession, TInt aResId, TInt aSessionUid);
       
   231     void PrintWithDelay(const TInt aPriority, const TDesC& aDesC1, const TDesC& aDesC2);
       
   232     
       
   233     // -----------
       
   234     // Test cases.
       
   235     // -----------
       
   236     TInt TestCaseInit(TTestResult& aResult);
       
   237     TInt TestCasePlayKey(TTestResult& aResult);
       
   238     TInt TestCasePlayKeyAsync(TTestResult& aResult);
       
   239     TInt TestCasePlaySid(TTestResult& aResult);
       
   240     TInt TestCaseStopCurrentTone(TTestResult& aResult);
       
   241     TInt TestCaseAddSidsL(TTestResult& aResult);
       
   242     TInt TestCasePushContextL(TTestResult& aResult);
       
   243     TInt TestCaseLockContextL(TTestResult& aResult);
       
   244     TInt TestCaseCloseServer(TTestResult& aResult);    
       
   245     
       
   246 private: // Data
       
   247     // Pointer to test (function) to be executed
       
   248     TestFunction iMethod;
       
   249 
       
   250     // Pointer to logger
       
   251     CStifLogger * iLog; 
       
   252 
       
   253     // Normal logger
       
   254     CStifLogger* iStdLog;
       
   255 
       
   256     // Test case logger
       
   257     CStifLogger* iTCLog;
       
   258 
       
   259     // Flag saying if test case title should be added to log file name
       
   260     TBool iAddTestCaseTitleToLogName;
       
   261     
       
   262     // Session to keysound server. Not to be used in test cases. This session is
       
   263     // for STIF application keysounds. Without this the application's keysounds 
       
   264     // would stop working when tests are executed. BringToForeground() must
       
   265     // be called for this session in the end of a test case if BringToForeground()
       
   266     // is called for some other session.    
       
   267     RAknSoundServerSession iSoundServerSession;
       
   268     };
       
   269 
       
   270 #endif // AKNSOUNDSERVERSTIFTEST_H
       
   271 
       
   272 // End of File