contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/inc/PsClientTestSuite.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002 - 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: Header file for client test suite
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PS_CLIENT_TEST_SUITE_H
       
    20 #define PS_CLIENT_TEST_SUITE_H
       
    21 
       
    22 // SYSTEM INCLUDES
       
    23 #include <StifLogger.h>
       
    24 #include <TestScripterInternal.h>
       
    25 #include <StifTestModule.h>
       
    26 #include <MPsResultsObserver.h>
       
    27 #include <CPcsDefs.h>
       
    28 
       
    29 // USER INCLUDES
       
    30 #include "TestSuiteInputData.h"
       
    31 #include "psclienttestsuitedefs.h"
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CPcsTestContactsHandler;
       
    35 class CPsQuery;
       
    36 class CPSRequestHandler;
       
    37 class CPsSettings;
       
    38 
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /*** CPsClientTestSuite test class for STIF Test Framework TestScripter.
       
    43 * @since S60 v3.2
       
    44 */
       
    45 
       
    46 NONSHARABLE_CLASS(CPsClientTestSuite) : public CScriptBase,  public MPsResultsObserver
       
    47 {
       
    48     public:  // Constructors and destructor
       
    49 
       
    50         /**
       
    51         * First phase constructor constructor.
       
    52         */
       
    53         static CPsClientTestSuite* NewL( CTestModuleIf& aTestModuleIf );
       
    54 
       
    55         /**
       
    56         * Destructor.
       
    57         */
       
    58         virtual ~CPsClientTestSuite();
       
    59 
       
    60     public: // Functions from base classes
       
    61 
       
    62         /**
       
    63         * From CScriptBase Runs a script line.
       
    64         *
       
    65         * @param aItem Script line containing method name and parameters
       
    66         * @return Symbian OS error code
       
    67         */
       
    68         virtual TInt RunMethodL( CStifItemParser& aItem );
       
    69 
       
    70     public: // Function from base class MPsResultsObserver
       
    71 
       
    72         /**
       
    73         * HandlePsResultsUpdateL.
       
    74         * Handle updates from the Ps server.
       
    75         *
       
    76         * @param searchResults Search results returned from the server.
       
    77         * @param searchSeqs List of matching character sequences.
       
    78         */
       
    79         void HandlePsResultsUpdate(RPointerArray<CPsClientData>& searchResults,
       
    80                                    RPointerArray<CPsPattern>& searchSeqs);
       
    81 
       
    82         /**
       
    83         * HandlePsError.
       
    84         * Handle errors from the server.
       
    85         *
       
    86         * @param aErrorCode Search errors returned from the server.
       
    87         */
       
    88         void HandlePsError(TInt aErrorCode);
       
    89 
       
    90         /**
       
    91         * CachingStatus
       
    92         * Gets called when caching is completed.
       
    93         * Observers need to implement this function accordingly
       
    94         * to take action after cache completion
       
    95         *
       
    96         * @param aStatus - caching status,
       
    97         *   20 - Caching completes succesfully,
       
    98         *   30 - Caching completed with errors
       
    99         * @param aError - Any error that occurred while caching. KErrNone if no error else the error code
       
   100         */
       
   101         void CachingStatus(TCachingStatus& aStatus, TInt& aError);
       
   102 
       
   103     private:
       
   104 
       
   105         /**
       
   106         * C++ default constructor.
       
   107         */
       
   108         CPsClientTestSuite( CTestModuleIf& aTestModuleIf );
       
   109 
       
   110         /**
       
   111         * Symbian 2nd phase constructor.
       
   112         */
       
   113         void ConstructL();
       
   114 
       
   115         /**
       
   116         * Frees all resources allocated from test methods.
       
   117         */
       
   118         void Delete();
       
   119 
       
   120     private:  //Test cases
       
   121 
       
   122         /**
       
   123         * This method writes the test case title to the log file
       
   124         */
       
   125         TInt WriteTitleToLog( );
       
   126 
       
   127         /**
       
   128         * This test case creates contacts in the phonebook
       
   129         *
       
   130         * @param aItem Script line containing parameters.
       
   131         */
       
   132         TInt CreateContactsL( CStifItemParser& aItem );
       
   133 
       
   134         /**
       
   135         * This test case creates groups in the phonebook. It creats only
       
   136         * empty groups, i.e the groups do not have any members.
       
   137         *
       
   138         * @param aItem Script line containing parameters.
       
   139         */
       
   140         TInt CreateGroupsInPhoneL( CStifItemParser& aItem );
       
   141 
       
   142         /**
       
   143         * This test case fires a search query to the psengine
       
   144         *
       
   145         * @param aItem Script line containing parameters.
       
   146         * @return - error status - KErrNone if test case is successful
       
   147         */
       
   148         TInt SearchCacheL( CStifItemParser& aItem );
       
   149 
       
   150         /**
       
   151         * This test case cancels a search query to the psengine
       
   152         *
       
   153         * @param aItem Script line containing parameters.
       
   154         * @return - error status - KErrNone if test case is successful
       
   155         */
       
   156         TInt CancelSearchL( CStifItemParser& aItem );
       
   157 
       
   158         /**
       
   159         * This test case searches for a query in the given input string
       
   160         *
       
   161         * @param aItem Script line containing parameters.
       
   162         * @return - error status - KErrNone if test case is successful
       
   163         */
       
   164         TInt SearchOnInputStringL(CStifItemParser& aItem);
       
   165 
       
   166         /**
       
   167         * This test case searches for a query with LookupMatch
       
   168         * and ensures the result string is correct
       
   169         *
       
   170         * @param aItem Script line containing parameters.
       
   171         * @return - error status - KErrNone if test case is successful
       
   172         */
       
   173         TInt SearchLookupMatchStringL(CStifItemParser& aItem);
       
   174 
       
   175         /**
       
   176         * This test case requests the Adaptive Grid
       
   177         * and ensures the result string is correct
       
   178         *
       
   179         * @param aItem Script line containing parameters.
       
   180         * @return - error status - KErrNone if test case is successful
       
   181         */
       
   182         TInt CheckAdaptiveStringL(CStifItemParser& aItem);
       
   183 
       
   184         /**
       
   185         * This method deletes all the contacts in the phonebook
       
   186         *
       
   187         * @param aItem Script line containing parameters.
       
   188         * @return - error status - KErrNone if test case is successful
       
   189         */
       
   190         TInt DeleteAllContactsInPhonebookL(CStifItemParser& aItem);
       
   191 
       
   192         /**
       
   193         * This method checks the caching status
       
   194         *
       
   195         * @return - error status - KErrNone if test case is successful
       
   196         */
       
   197         TInt CheckCachingStatusL();
       
   198 
       
   199         /**
       
   200         * This method checks the version of the ps server
       
   201         *
       
   202         * @return - error status - KErrNone if test case is successful
       
   203         */
       
   204         TInt CheckVersion();
       
   205 
       
   206         /**
       
   207         * This method checks if a particular language is supported by the ps server
       
   208         *
       
   209         * @return - error status - KErrNone if test case is successful
       
   210         */
       
   211         TInt TestIsLanguageSupportedL(CStifItemParser& aItem);
       
   212 
       
   213         /**
       
   214         * This method waits for time equal to the input parameter
       
   215         *
       
   216         * @param aInterval  The wait interval
       
   217         */
       
   218         void RTimerWait(TTimeIntervalMicroSeconds32 aInterval);
       
   219 
       
   220         /**
       
   221         * This method checks gets all the contents from a particular URI (as specified in the configuration)
       
   222         *
       
   223         * @return - error status - KErrNone if test case is successful
       
   224         */
       
   225         TInt GetAllContentsL( CStifItemParser& aItem );
       
   226 
       
   227         /**
       
   228         * This method searches in a particular group. The group name is given as a
       
   229         * configuration parameter.
       
   230         *
       
   231         * @return - error status - KErrNone if test case is successful
       
   232         */
       
   233         TInt SearchWithInGroupL(CStifItemParser& aItem );
       
   234 
       
   235         /**
       
   236         * This method tests the sort order
       
   237         *
       
   238         * @return - error status - KErrNone if test case is successful
       
   239         */
       
   240         TInt TestSortOrderL( CStifItemParser& aItem );
       
   241 
       
   242         /**
       
   243         * This method tests the sort order for error case
       
   244         *
       
   245         * @return - error status - KErrNone if test case is successful
       
   246         */
       
   247         TInt TestSortOrderErrCaseL( CStifItemParser& aItem );
       
   248 
       
   249         /**
       
   250         * This method removes the observer from ps searchengine
       
   251         *
       
   252         * @return - error status - KErrNone if test case is successful
       
   253         */
       
   254         TInt RemoveObserverL(CStifItemParser& aItem);
       
   255 
       
   256         /**
       
   257         * Tests if contact Id returns correct vpbklink
       
   258         *
       
   259         * @return -  - error status - KErrNone if test case is successful
       
   260         */
       
   261         TInt ConvertToVpbkLinkL(CStifItemParser& aItem);
       
   262 
       
   263         /**
       
   264         * Tests for bookmarked contacts
       
   265         *
       
   266         * @return error status - KErrNone if test case is successful
       
   267         */
       
   268         TInt AddMarkedContactsTestL(CStifItemParser& aItem);
       
   269 
       
   270         /**
       
   271         * Tests for data order
       
   272         *
       
   273         * @return error status - KErrNone if test case is successful
       
   274         */
       
   275         TInt TestDataOrderL(CStifItemParser& aItem);
       
   276 
       
   277         /**
       
   278         * Tests for data order
       
   279         *
       
   280         * @return error status - KErrNone if test case is successful
       
   281         */
       
   282         TInt TestDataOrderForErrL(CStifItemParser& aItem);
       
   283 
       
   284         /**
       
   285         * This method shuts the server down
       
   286         *
       
   287         * @return - error status - KErrNone if test case is successful
       
   288         */
       
   289         TInt ShutDownL();
       
   290 
       
   291     private: // Data
       
   292 
       
   293         /**
       
   294         * The input data parser
       
   295         * own
       
   296         */
       
   297         CTestSuiteInputData* iInputParsedData;
       
   298 
       
   299         /**
       
   300         * The search query
       
   301         */
       
   302         CPsQuery *iPsQuery;
       
   303 
       
   304         /**
       
   305         * The CPSRequestHandler instance
       
   306         */
       
   307         CPSRequestHandler* iPsClientHandler;
       
   308 
       
   309         /**
       
   310         * The search settings
       
   311         */
       
   312         CPsSettings* iSettings ;
       
   313 
       
   314         /**
       
   315         * The error return status
       
   316         */
       
   317         TInt iReturnStatus;
       
   318 
       
   319         /**
       
   320         * The group Id of the group name entered in the configuration file
       
   321         */
       
   322         TInt iGroupToBeSearchedId;
       
   323 
       
   324         /**
       
   325         * The current operation being performed
       
   326         */
       
   327         TTestCase iCurrentOperation;
       
   328 
       
   329         /**
       
   330         * RTimer variable to set the timer before RunL calls any function.
       
   331         * This is required to allow other threads to run since contact fetch
       
   332         * is CPU intensive task.
       
   333         */
       
   334         RTimer iTimer;
       
   335 
       
   336         /**
       
   337         * The caching status of the psengine
       
   338         */
       
   339         TCachingStatus iCachingStatus;
       
   340 
       
   341         /**
       
   342         * The marked contacts
       
   343         */
       
   344         RPointerArray<CPsClientData> iMarkedContacts;
       
   345 };
       
   346 
       
   347 #endif // PS_CLIENT_TEST_SUITE_H
       
   348 
       
   349 // End of File