summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/cntplsql/src/t_cpplpredictivesearchtable.h
blob: 31c742f023676e00d981a2ee1f24ce6cf239458d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright (C) 2012 Digia Plc 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 testing 12-key predictive search table
*
*/

#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 CPplPredictiveSearchTableBase;
class C12keyPredictiveSearchTable;
class CQwertyPredictiveSearchTable;
class CPredictiveSearchSettingsTable;
class CPredictiveSearchSynchronizer;
class CContactItem;


//  CONSTANTS

//  CLASS DEFINITION
/**
 * Tester class for C12keyPredictiveSearchTable.
 */
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 SetupSyncL();
		void SetupSyncJust12keyExistsL();
		void SetupLanguageChangesL();
		void UseSpecificDbL(const TDesC& aDbFile);
        void Teardown();

    private: // Test functions

		void UT_DummyL();
        void UT_CreateInDbLL();
        void UT_CreateInDbManyContactsL();
		void UT_CreateInDbWithHashAndStarL();
        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_SynchronizeTableJust12keyExistsL();
		void UT_DeleteTablesL();
		void UT_LanguageChangesL();
        void UT_TokenizeNamesL();
		void UT_WriteToDbL();
		void UT_ConvertToHexL();
		void UT_HbKeymapFactoryApiL();
        
    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;

    private:    // Data

		C12keyPredictiveSearchTable* iTable; // Owned
		CQwertyPredictiveSearchTable* iPredSearchQwertyTable; // Owned 
		CPredictiveSearchSettingsTable* iPredSearchSettingsTable; // Owned
		CPredictiveSearchSynchronizer* iPredictiveSearchSynchronizer; // Owned
        
        RSqlDatabase iDB;

        EUNIT_DECLARE_TEST_TABLE;
    };

#endif      //  __UT_CPPLPREDICTIVESEARCHTABLE_H__

// End of file