classicui_plat/findutil_api/tsrc/src/testdomfindutilblocks.cpp
changeset 26 62ef28f7b435
equal deleted inserted replaced
22:75713bee6484 26:62ef28f7b435
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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:    test findutil.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // [INCLUDE FILES]
       
    23 #include <e32svr.h>
       
    24 #include <stifparser.h>
       
    25 #include <stiftestinterface.h>
       
    26 #include <findutil.h>
       
    27 
       
    28 #include "testdomfindutil.h"
       
    29 
       
    30 // CONSTANTS
       
    31 const TInt KMaxLength = 10;
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CTestDOMFindUtil::RunMethodL
       
    37 // Run specified method. Contains also table of test mothods and their names.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 TInt CTestDOMFindUtil::RunMethodL( CStifItemParser& aItem ) 
       
    41     {
       
    42 
       
    43     static TStifFunctionInfo const KFunctions[] =
       
    44         {  
       
    45         // First string is the function name used in TestScripter script file.
       
    46         // Second is the actual implementation member function. 
       
    47         ENTRY( "TestMatchRefineL", CTestDOMFindUtil::TestMatchRefineL ),
       
    48         ENTRY( "TestMatch", CTestDOMFindUtil::TestMatchL ),
       
    49         ENTRY( "TestIsWordValidForMatching",
       
    50                 CTestDOMFindUtil::TestIsWordValidForMatchingL ),
       
    51         ENTRY( "TestMatchAdaptiveRefineL",
       
    52                 CTestDOMFindUtil::TestMatchAdaptiveRefineL),
       
    53 
       
    54         ENTRY( "TestNewL", CTestDOMFindUtil::TestNewL ),
       
    55 
       
    56         // [test cases entries]
       
    57 
       
    58         };
       
    59 
       
    60     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
       
    61 
       
    62     return RunInternalL( KFunctions, count, aItem );
       
    63 
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CTestDOMFindUtil::TestMatchRefineL
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 TInt CTestDOMFindUtil::TestMatchRefineL( CStifItemParser& aItem )
       
    71     {
       
    72 
       
    73     // Print to UI
       
    74     _LIT( KTestDOMFindUtil, "testdomfindutil" );
       
    75     _LIT( KTestMatchRefineL, "In MatchRefineL" );
       
    76     TestModuleIf().Printf( 0, KTestDOMFindUtil, KTestMatchRefineL );
       
    77     // Print to log file
       
    78     iLog->Log( KTestMatchRefineL );
       
    79 
       
    80     CFindUtil* util = CFindUtil::NewL();
       
    81     CleanupStack::PushL( util );
       
    82     MFindUtil* findUtil = util->Interface();
       
    83 
       
    84     TPtrC firstRow, stringToFind;
       
    85     aItem.GetNextString( firstRow );
       
    86     aItem.GetNextString( stringToFind );
       
    87 
       
    88     TInt result = findUtil->MatchRefineL( firstRow, stringToFind );
       
    89     STIF_ASSERT_EQUALS( 0, result );
       
    90 
       
    91     CleanupStack::PopAndDestroy( util );
       
    92     return KErrNone;
       
    93 
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CTestDOMFindUtil::TestMatchL
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 TInt CTestDOMFindUtil::TestMatchL( CStifItemParser& aItem )
       
   101     {
       
   102 
       
   103     // Print to UI
       
   104     _LIT( KTestDOMFindUtil, "testdomfindutil" );
       
   105     _LIT( KTestMatch, "In Match" );
       
   106     TestModuleIf().Printf( 0, KTestDOMFindUtil, KTestMatch );
       
   107     // Print to log file
       
   108     iLog->Log( KTestMatch );
       
   109 
       
   110     CFindUtil* util = CFindUtil::NewL();
       
   111     CleanupStack::PushL( util );
       
   112     MFindUtil* findUtil = util->Interface();
       
   113 
       
   114     TPtrC firstWord, secondWord;
       
   115     aItem.GetNextString( firstWord );
       
   116     aItem.GetNextString( secondWord );
       
   117 
       
   118     TBool result = findUtil->Match( firstWord, secondWord );
       
   119 
       
   120     CleanupStack::PopAndDestroy( util );
       
   121 
       
   122     return KErrNone;
       
   123 
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CTestDOMFindUtil::TestIsWordValidForMatchingL
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 TInt CTestDOMFindUtil::TestIsWordValidForMatchingL(
       
   131         CStifItemParser& aItem )
       
   132     {
       
   133 
       
   134     // Print to UI
       
   135     _LIT( KTestDOMFindUtil, "testdomfindutil" );
       
   136     _LIT( KTestIsWordValidForMatching, "In IsWordValidForMatching" );
       
   137     TestModuleIf().Printf( 0, KTestDOMFindUtil, KTestIsWordValidForMatching );
       
   138     // Print to log file
       
   139     iLog->Log( KTestIsWordValidForMatching );
       
   140 
       
   141     CFindUtil* util = CFindUtil::NewL();
       
   142     CleanupStack::PushL( util );
       
   143     MFindUtil* findUtil = util->Interface();
       
   144 
       
   145     TPtrC word;
       
   146     aItem.GetNextString( word );
       
   147 
       
   148     TBool result = findUtil->IsWordValidForMatching( word );
       
   149     STIF_ASSERT_TRUE( result );
       
   150 
       
   151     CleanupStack::PopAndDestroy( util );
       
   152     return KErrNone;
       
   153 
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CTestDOMFindUtil::TestMatchAdaptiveRefineL
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 TInt CTestDOMFindUtil::TestMatchAdaptiveRefineL( CStifItemParser& aItem )
       
   161     {
       
   162 
       
   163     // Print to UI
       
   164     _LIT( KTestDOMFindUtil, "testdomfindutil" );
       
   165     _LIT( KTestMatchAdaptiveRefineL, "In MatchAdaptiveRefineL" );
       
   166     TestModuleIf().Printf( 0, KTestDOMFindUtil, KTestMatchAdaptiveRefineL );
       
   167     // Print to log file
       
   168     iLog->Log( KTestMatchAdaptiveRefineL );
       
   169 
       
   170     CFindUtil* util = CFindUtil::NewL();
       
   171     CleanupStack::PushL( util );
       
   172     MFindUtil* findUtil = util->Interface();
       
   173 
       
   174     TPtrC firstWord, secondWord, temp;
       
   175 
       
   176     HBufC* nextChar = HBufC::NewL( KMaxLength );
       
   177     CleanupStack::PushL( nextChar );
       
   178 
       
   179     aItem.GetNextString( firstWord );
       
   180     aItem.GetNextString( secondWord );
       
   181     aItem.GetNextString( temp );
       
   182     nextChar->Des().Copy( temp );
       
   183 
       
   184     TBool result = findUtil->MatchAdaptiveRefineL( firstWord, secondWord,
       
   185             nextChar );
       
   186     STIF_ASSERT_FALSE( result );
       
   187 
       
   188     CleanupStack::PopAndDestroy( nextChar );
       
   189     CleanupStack::PopAndDestroy( util );
       
   190     return KErrNone;
       
   191 
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CTestDOMFindUtil::TestNewL
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 TInt CTestDOMFindUtil::TestNewL( CStifItemParser& /*aItem*/ )
       
   199     {
       
   200 
       
   201     // Print to UI
       
   202     _LIT( KTestDOMFindUtil, "testdomfindutil" );
       
   203     _LIT( KTestNewL, "In NewL" );
       
   204     TestModuleIf().Printf( 0, KTestDOMFindUtil, KTestNewL );
       
   205     // Print to log file
       
   206     iLog->Log( KTestNewL );
       
   207 
       
   208     CFindUtil* findUtil = CFindUtil::NewL();
       
   209     CleanupStack::PushL( findUtil );
       
   210     STIF_ASSERT_NOT_NULL( findUtil );
       
   211 
       
   212     CleanupStack::Pop( findUtil );
       
   213     delete findUtil;
       
   214     findUtil = NULL;
       
   215 
       
   216     return KErrNone;
       
   217 
       
   218     }
       
   219 
       
   220 
       
   221 //  [End of File]