phonebookengines/contactsmodel/tsrc/cntplsql/src/t_cpplpredictivesearchtable.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 15:42:23 +0300
changeset 31 2a11b5b00470
parent 27 de1630741fbe
child 46 efe85016a067
permissions -rw-r--r--
Revision: 201017 Kit: 201019

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Unit test class for character to key mappings
*
*/

#ifndef __UT_CPPLPREDICTIVESEARCHTABLE_H__
#define __UT_CPPLPREDICTIVESEARCHTABLE_H__

//  EXTERNAL INCLUDES
#include <digia/eunit/ceunittestsuiteclass.h>
#include <digia/eunit/eunitmacros.h>
#include <sqldb.h>
#include "cntdef.h" // TContactItemId

//  FORWARD DECLARATIONS
class CPplPredictiveSearchTable;

//  CONSTANTS

//  CLASS DEFINITION
/**
 * Tester class for CPcsKeyMap.
 */
NONSHARABLE_CLASS( UT_CPplPredictiveSearchTable ): public CEUnitTestSuiteClass
    {
    public: // Constructors and destructors

        /**
         * Two phase construction
         */
        static UT_CPplPredictiveSearchTable* NewL();
        static UT_CPplPredictiveSearchTable* NewLC();
        
        /**
         * Destructor
         */
        ~UT_CPplPredictiveSearchTable();

    private: // Constructors

        UT_CPplPredictiveSearchTable();
        void ConstructL();
        
    private: // Test case setup and teardown

        void SetupL();
        void Setup2L();
        void Teardown();

    private: // Test functions

		void UT_DummyL();
        void UT_CreateInDbLL();
        void UT_CreateInDbManyContactsL();
        void UT_UpdateLL();
        void UT_UpdateLBothFieldsL();
        void UT_SearchL();
        void UT_SearchWithSpacesL();
        void UT_DeleteLL();
        void UT_DeleteContactsL();
        void UT_DeleteNonexistingContactL();
        void UT_CheckIfTableExistsL();
        void UT_CheckIfTableExists2L();
        void UT_SynchronizeTableL();
		void UT_DeleteTablesL();
        void UT_TokenizeNamesL();
		void UT_WriteToDbL();
		void UT_ConvertToHexL();
        
    private: // New functions

        void CheckItemCountL(
            TInt aCountInTable0 = 0,
            TInt aCountInTable1 = 0,
            TInt aCountInTable2 = 0,
            TInt aCountInTable3 = 0,
            TInt aCountInTable4 = 0,
            TInt aCountInTable5 = 0,
            TInt aCountInTable6 = 0,
            TInt aCountInTable7 = 0,
            TInt aCountInTable8 = 0,
            TInt aCountInTable9 = 0,
			TInt aCountInTable10 = 0,
			TInt aCountInTable11 = 0);
        
        /**
         * Adds a new contact to table.
         */
        void AddContactL(const TDesC& aFirstName,
                         const TDesC& aLastName,
                         TContactItemId aContactId);
        
        /**
         * Searches the table for matches, and returns an array containing
         * matching contact's ids.
         */
        RArray<TContactItemId> DoPredictiveSearchL(const TDesC& aSearchString);

        const TDesC& DetermineTableName(const TDesC& aSearchString);

		TInt64 LowerLimitL(const TDesC& aString) const;
		TInt64 UpperLimitL(const TDesC& aString) const;
		TInt64 ConvertToNbrL(const TDesC& aString, TChar aPadChar) const;

		TInt CPplContactItemManager_DoesPredSearchTableExistL();
		void CPplContactItemManager_DeletePredSearchTablesL();

    private:    // Data

        CPplPredictiveSearchTable* iTable;
        
        RSqlDatabase iDB;

        EUNIT_DECLARE_TEST_TABLE;
    };

#endif      //  __UT_CPPLPREDICTIVESEARCHTABLE_H__

// End of file