summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/cntplsql/src/t_cpredictivesearchsettingstable.cpp
blob: 0f50ee6bdfc85c7ac3a1730f19f675a5909bc04c (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
145
146
147
148
149
150
151
152
/*
* 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
*
*/

//  INTERNAL INCLUDES
#include "t_cpredictivesearchsettingstable.h"
#include "cpredictivesearchsettingstable.h"
//#include "dbsqlconstants.h"
#include "t_predictivesearchtabledefs.h"

//  SYSTEM INCLUDES
#include <digia/eunit/eunitmacros.h>

// Used to create HbKeymapFactory singleton to get rid of resource leak
#include <QLocale>
#include <hbinputkeymapfactory.h>
    

// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::NewL
// -----------------------------------------------------------------------------
//
UT_CPredictiveSearchSettingsTable* UT_CPredictiveSearchSettingsTable::NewL()
    {
    UT_CPredictiveSearchSettingsTable* self =
		UT_CPredictiveSearchSettingsTable::NewLC();
    CleanupStack::Pop( self );
    return self;
    }

// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::NewLC
// -----------------------------------------------------------------------------
//
UT_CPredictiveSearchSettingsTable* UT_CPredictiveSearchSettingsTable::NewLC()
    {
    UT_CPredictiveSearchSettingsTable* self =
		new ( ELeave ) UT_CPredictiveSearchSettingsTable();
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;
    }

// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::~UT_CPredictiveSearchSettingsTable
// -----------------------------------------------------------------------------
//
UT_CPredictiveSearchSettingsTable::~UT_CPredictiveSearchSettingsTable()
    {
    delete iTable;
    iTable = NULL;
    
    iDB.Close(); // Must close DB before it can be deleted
    RSqlDatabase::Delete(KDBFile);
    }

// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::UT_CPredictiveSearchSettingsTable
// -----------------------------------------------------------------------------
//
UT_CPredictiveSearchSettingsTable::UT_CPredictiveSearchSettingsTable()
    {
    }

// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::ConstructL
// -----------------------------------------------------------------------------
//
void UT_CPredictiveSearchSettingsTable::ConstructL()
    {
    // The ConstructL from the base class CEUnitTestSuiteClass must be called.
    // It generates the test case table.
    CEUnitTestSuiteClass::ConstructL();
    }
    
// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::SetupL
// Must start with an empty DB file for each test case
// -----------------------------------------------------------------------------
//
void UT_CPredictiveSearchSettingsTable::SetupL()
    {
    // Ignore error
	RSqlDatabase::Delete(KDBFile);
    // If this causes KErrAlreadyExists, iDB won't be fully constructed
	iDB.Create(KDBFile);

	iTable = CPredictiveSearchSettingsTable::NewL(iDB);
	// Create (empty) predictive search tables to DB
	iTable->CreateTableL();
	}
    
// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::Teardown
// -----------------------------------------------------------------------------
//
void UT_CPredictiveSearchSettingsTable::Teardown()
    {
    delete iTable;
	iTable = NULL;

	iDB.Close(); // Must close DB before it can be deleted
	RSqlDatabase::Delete(KDBFile);
    }


// TEST CASES

// -----------------------------------------------------------------------------
// UT_CPredictiveSearchSettingsTable::UT_CreateTableLL
// -----------------------------------------------------------------------------
//
void UT_CPredictiveSearchSettingsTable::UT_CreateTableLL()
    {
	// Check that when starting w/o DB file, the settings table is created and
	// filled correctly.
    enum QLocale::Language currLang = iTable->GetCurrentLanguageL();
    enum QLocale::Language storedLang = iTable->ReadStoredLanguageL();
    EUNIT_ASSERT_EQUALS(currLang, storedLang);
    }

    
//  TEST TABLE

EUNIT_BEGIN_TEST_TABLE(
    UT_CPredictiveSearchSettingsTable,
    "UT_CPredictiveSearchSettingsTable",
    "UNIT" )
        
EUNIT_TEST(
    "CreateInDbL - test",
    "UT_CPredictiveSearchSettingsTable",
    "CreateTableL",
    "FUNCTIONALITY",
    SetupL, UT_CreateTableLL, Teardown )

EUNIT_END_TEST_TABLE

//  END OF FILE