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