testexecfw/stf/stfext/testmodules/testcombiner/src/TestKeywords.cpp
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 2009 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: This module contains the implementation of 
       
    15 * TTCKeywords class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "TestKeywords.h"
       
    22 
       
    23 // EXTERNAL DATA STRUCTURES
       
    24 // None
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES  
       
    27 // None
       
    28 
       
    29 // CONSTANTS
       
    30 // None
       
    31 
       
    32 // MACROS
       
    33 // None
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 // None
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 // None
       
    40 
       
    41 // LOCAL FUNCTION PROTOTYPES
       
    42 // None
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 // None
       
    46 
       
    47 // ==================== LOCAL FUNCTIONS =======================================
       
    48 // None
       
    49 
       
    50 
       
    51 // ================= MEMBER FUNCTIONS =========================================
       
    52 
       
    53 /*
       
    54 -------------------------------------------------------------------------------
       
    55 
       
    56      Class: TTCKeywords
       
    57 
       
    58      Method: Keyword
       
    59 
       
    60      Description: Returns a string desrciptor corresponding to keyword number. 
       
    61 
       
    62      Parameters:    TKeywords aKeyword: in: keyword index.
       
    63      
       
    64      Return Values: TPtrC8: keyword descriptor
       
    65 
       
    66      Errors/Exceptions: None
       
    67      
       
    68      Status: Approved 
       
    69     
       
    70 -------------------------------------------------------------------------------
       
    71 */      
       
    72 TPtrC TTCKeywords::Keyword( TInt aKeyword )
       
    73     {
       
    74     static TText* const keywords[] =
       
    75         {
       
    76         (TText*)L"title",
       
    77         (TText*)L"run",
       
    78         (TText*)L"cancel",
       
    79         (TText*)L"pause",
       
    80         (TText*)L"resume",
       
    81         (TText*)L"complete",
       
    82         (TText*)L"request",
       
    83         (TText*)L"wait",
       
    84         (TText*)L"release",
       
    85         (TText*)L"set",
       
    86         (TText*)L"unset",
       
    87         (TText*)L"timeout",
       
    88         (TText*)L"priority",
       
    89         (TText*)L"print",
       
    90         (TText*)L"allocate",
       
    91         (TText*)L"free",
       
    92         (TText*)L"remote",
       
    93         (TText*)L"sendreceive",
       
    94         (TText*)L"canceliferror",
       
    95         (TText*)L"measurement",
       
    96         (TText*)L"loop",
       
    97         (TText*)L"endloop",
       
    98         (TText*)L"pausecombiner",        
       
    99         };
       
   100     
       
   101     if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) )
       
   102           {
       
   103           TPtrC null;
       
   104           return null;
       
   105           } 
       
   106     
       
   107     TPtrC keyword( keywords[ aKeyword ] ); 
       
   108     return keyword;
       
   109     
       
   110     }
       
   111 
       
   112 /*
       
   113 -------------------------------------------------------------------------------
       
   114 
       
   115      Class: TTCKeywords
       
   116 
       
   117      Method: RunOptArg
       
   118 
       
   119      Description: Returns a string desrciptor corresponding to run keyword 
       
   120                   optional argument number. 
       
   121 
       
   122      Parameters:    TRunOptArgs aArg: in: run keyword optional argument index
       
   123      
       
   124      Return Values: TPtrC8: argument descriptor
       
   125 
       
   126      Errors/Exceptions: None
       
   127      
       
   128      Status: Approved 
       
   129     
       
   130 -------------------------------------------------------------------------------
       
   131 */
       
   132 TPtrC TTCKeywords::RunOptArg( TInt aArg )
       
   133     {
       
   134     static TText* const runOptArgs[] =
       
   135         {
       
   136         (TText*)L"expect",
       
   137         (TText*)L"testid",
       
   138         (TText*)L"ini",
       
   139         (TText*)L"category",
       
   140         (TText*)L"timeout",
       
   141         (TText*)L"title",
       
   142         };
       
   143 
       
   144     if( aArg >= (TInt)(sizeof( runOptArgs )/sizeof(TText*)) )
       
   145           {
       
   146           TPtrC null;
       
   147           return null;
       
   148           }
       
   149 
       
   150     TPtrC arg( runOptArgs[ aArg ] );
       
   151     return arg;
       
   152     
       
   153     }
       
   154 
       
   155 /*
       
   156 -------------------------------------------------------------------------------
       
   157 
       
   158      Class: TTCKeywords
       
   159 
       
   160      Method: PauseOptArg
       
   161 
       
   162      Description: Returns a string desrciptor corresponding to pause keyword 
       
   163                       optional argument number. 
       
   164 
       
   165      Parameters:    TPauseOptArgs aArg: in: argument index.
       
   166      
       
   167      Return Values: TPtrC8: argument descriptor
       
   168 
       
   169      Errors/Exceptions: None
       
   170      
       
   171      Status: Approved 
       
   172     
       
   173 -------------------------------------------------------------------------------
       
   174 */
       
   175 TPtrC TTCKeywords::PauseOptArg( TInt aArg )
       
   176     {
       
   177     static TText* const pauseOptArgs[] =
       
   178         {
       
   179         (TText*)L"time",
       
   180         };
       
   181     
       
   182     if( aArg >= (TInt)(sizeof( pauseOptArgs )/sizeof(TText*)) )
       
   183           {
       
   184           TPtrC null;
       
   185           return null;
       
   186           } 
       
   187     
       
   188     TPtrC arg( pauseOptArgs[ aArg ] ); 
       
   189     return arg;
       
   190     
       
   191     }
       
   192       
       
   193 /*
       
   194 -------------------------------------------------------------------------------
       
   195 
       
   196      Class: TTCKeywords
       
   197 
       
   198      Method: EventOptArg
       
   199 
       
   200      Description: Returns a string desrciptor corresponding to event keywords 
       
   201                       optional argument number. 
       
   202 
       
   203      Parameters:    TEventOptArgs aArg: in: argument index.
       
   204      
       
   205      Return Values: TPtrC8: keyword descriptor
       
   206 
       
   207      Errors/Exceptions: None
       
   208      
       
   209      Status: Approved 
       
   210     
       
   211 -------------------------------------------------------------------------------
       
   212 */              
       
   213 TPtrC TTCKeywords::EventOptArg( TInt aArg )
       
   214     {
       
   215     static TText* const optArgs[] =
       
   216         {
       
   217         (TText*)L"state",
       
   218         };
       
   219     
       
   220     if( aArg >= (TInt)(sizeof( optArgs )/sizeof(TText*)) )
       
   221         {
       
   222         TPtrC null;
       
   223           return null;
       
   224           } 
       
   225     
       
   226     TPtrC arg( optArgs[ aArg ] ); 
       
   227     return arg;
       
   228     
       
   229     }
       
   230     
       
   231 /*
       
   232 -------------------------------------------------------------------------------
       
   233 
       
   234      Class: TTCKeywords
       
   235 
       
   236      Method: ResultCategory
       
   237 
       
   238      Description: Returns a string desrciptor corresponding to event keywords 
       
   239                       optional argument number. 
       
   240 
       
   241      Parameters:    TEventOptArgs aArg: in: argument index.
       
   242      
       
   243      Return Values: TPtrC8: keyword descriptor
       
   244 
       
   245      Errors/Exceptions: None
       
   246      
       
   247      Status: Approved 
       
   248     
       
   249 -------------------------------------------------------------------------------
       
   250 */              
       
   251 TPtrC TTCKeywords::Priority( TInt aArg )
       
   252     {
       
   253     static TText* const priority[] =
       
   254         {
       
   255         (TText*)L"high",
       
   256         (TText*)L"normal",
       
   257         (TText*)L"low",
       
   258         };
       
   259         
       
   260     if( aArg >= (TInt)(sizeof( priority )/sizeof(TText*)) )
       
   261         {
       
   262         TPtrC null;
       
   263         return null;
       
   264         } 
       
   265     
       
   266     TPtrC arg( priority[ aArg ] ); 
       
   267     return arg;
       
   268     
       
   269     }
       
   270    
       
   271 /*
       
   272 -------------------------------------------------------------------------------
       
   273 
       
   274      Class: TTCKeywords
       
   275 
       
   276      Method: Parse
       
   277 
       
   278      Description: Returns a keyword enum corresponding to keyword 
       
   279                       string descriptor.
       
   280 
       
   281      Parameters:    TPtrC aKeyword: in: keyword descriptor.
       
   282                     KeywordFunc aFunc: in: Function pointer to keyword parser 
       
   283      
       
   284      Return Values: TInt: keyword index
       
   285                     KErrNotFound: keyword not found
       
   286 
       
   287      Errors/Exceptions: None
       
   288      
       
   289      Status: Proposal 
       
   290     
       
   291 -------------------------------------------------------------------------------
       
   292 */
       
   293 TInt TTCKeywords::Parse( TDesC& aKeyword, KeywordFunc aFunc )
       
   294     {
       
   295     TInt ind;
       
   296     for( ind = 0; aFunc( ind ).Length() > 0; ind++ )
       
   297         {
       
   298         if( aFunc( ind ) == aKeyword )
       
   299             {
       
   300             return ind;
       
   301             }
       
   302         }
       
   303     return KErrNotFound;
       
   304     };
       
   305     
       
   306 /*
       
   307 -------------------------------------------------------------------------------
       
   308 
       
   309      Class: TTCKeywords
       
   310 
       
   311      Method: ResultCategory
       
   312 
       
   313      Description: Returns a string desrciptor corresponding to result 
       
   314         category number. 
       
   315 
       
   316      Parameters:    TInt aArg: in: argument index.
       
   317      
       
   318      Return Values: TPtrC: keyword descriptor
       
   319 
       
   320      Errors/Exceptions: None
       
   321      
       
   322      Status: Proposal
       
   323     
       
   324 -------------------------------------------------------------------------------
       
   325 */              
       
   326 TPtrC TTCKeywords::ResultCategory( TInt aArg )
       
   327     {
       
   328     static TText* const category[] =
       
   329         {
       
   330         (TText*)L"ongoing",
       
   331         (TText*)L"normal",
       
   332         (TText*)L"cancelled",
       
   333         (TText*)L"errorfrommodule",
       
   334         (TText*)L"leave",
       
   335         (TText*)L"panic",
       
   336         (TText*)L"exception",
       
   337         (TText*)L"timeout",
       
   338         };
       
   339         
       
   340     if( aArg >= (TInt)(sizeof( category )/sizeof(TText*)) )
       
   341         {
       
   342         TPtrC null;
       
   343         return null;
       
   344         } 
       
   345     
       
   346     TPtrC arg( category[ aArg ] ); 
       
   347     return arg;
       
   348     
       
   349     }
       
   350     
       
   351 /*
       
   352 -------------------------------------------------------------------------------
       
   353 
       
   354      Class: TTCKeywords
       
   355 
       
   356      Method: ResultCategory
       
   357 
       
   358      Description: Returns a string desrciptor corresponding to event keywords 
       
   359                       optional argument number. 
       
   360 
       
   361      Parameters:    TEventOptArgs aArg: in: argument index.
       
   362      
       
   363      Return Values: TPtrC8: keyword descriptor
       
   364 
       
   365      Errors/Exceptions: None
       
   366      
       
   367      Status: Proposal 
       
   368     
       
   369 -------------------------------------------------------------------------------
       
   370 */              
       
   371 TFullTestResult::TCaseExecutionResult 
       
   372     TTCKeywords::GetResultCategory( TDesC& aCategory )
       
   373     {
       
   374     
       
   375     TInt ind;
       
   376     for( ind = 0; ResultCategory( ind ).Length() > 0; ind++ )
       
   377         {
       
   378         if( ResultCategory( ind ) == aCategory )
       
   379             {
       
   380             switch( ind )
       
   381                 {
       
   382                 case TFullTestResult::ECaseExecuted:
       
   383                 case TFullTestResult::ECaseLeave:
       
   384                 case TFullTestResult::ECasePanic:
       
   385                 case TFullTestResult::ECaseException:
       
   386                 case TFullTestResult::ECaseTimeout:
       
   387                     return (TFullTestResult::TCaseExecutionResult)ind;
       
   388                 default:
       
   389                     break;
       
   390                 }        
       
   391             }
       
   392         }      
       
   393     return TFullTestResult::ECaseOngoing;    
       
   394     }
       
   395 
       
   396 // ================= OTHER EXPORTED FUNCTIONS =================================
       
   397 // None
       
   398 
       
   399 // End of File