|
1 /* |
|
2 * Copyright (c) 2010 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: Unit test class for testing 12-key predictive search table |
|
15 * |
|
16 */ |
|
17 |
|
18 // INTERNAL INCLUDES |
|
19 #include "t_cpredictivesearchsettingstable.h" |
|
20 #include "cpredictivesearchsettingstable.h" |
|
21 //#include "dbsqlconstants.h" |
|
22 #include "t_predictivesearchtabledefs.h" |
|
23 |
|
24 // SYSTEM INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 |
|
27 // Used to create HbKeymapFactory singleton to get rid of resource leak |
|
28 #include <QLocale> |
|
29 #include <hbinputkeymapfactory.h> |
|
30 |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // UT_CPredictiveSearchSettingsTable::NewL |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 UT_CPredictiveSearchSettingsTable* UT_CPredictiveSearchSettingsTable::NewL() |
|
37 { |
|
38 UT_CPredictiveSearchSettingsTable* self = |
|
39 UT_CPredictiveSearchSettingsTable::NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // UT_CPredictiveSearchSettingsTable::NewLC |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 UT_CPredictiveSearchSettingsTable* UT_CPredictiveSearchSettingsTable::NewLC() |
|
49 { |
|
50 UT_CPredictiveSearchSettingsTable* self = |
|
51 new ( ELeave ) UT_CPredictiveSearchSettingsTable(); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // UT_CPredictiveSearchSettingsTable::~UT_CPredictiveSearchSettingsTable |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 UT_CPredictiveSearchSettingsTable::~UT_CPredictiveSearchSettingsTable() |
|
62 { |
|
63 delete iTable; |
|
64 iTable = NULL; |
|
65 |
|
66 iDB.Close(); // Must close DB before it can be deleted |
|
67 RSqlDatabase::Delete(KDBFile); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // UT_CPredictiveSearchSettingsTable::UT_CPredictiveSearchSettingsTable |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 UT_CPredictiveSearchSettingsTable::UT_CPredictiveSearchSettingsTable() |
|
75 { |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // UT_CPredictiveSearchSettingsTable::ConstructL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void UT_CPredictiveSearchSettingsTable::ConstructL() |
|
83 { |
|
84 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
85 // It generates the test case table. |
|
86 CEUnitTestSuiteClass::ConstructL(); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // UT_CPredictiveSearchSettingsTable::SetupL |
|
91 // Must start with an empty DB file for each test case |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void UT_CPredictiveSearchSettingsTable::SetupL() |
|
95 { |
|
96 // Ignore error |
|
97 RSqlDatabase::Delete(KDBFile); |
|
98 // If this causes KErrAlreadyExists, iDB won't be fully constructed |
|
99 iDB.Create(KDBFile); |
|
100 |
|
101 iTable = CPredictiveSearchSettingsTable::NewL(iDB); |
|
102 // Create (empty) predictive search tables to DB |
|
103 iTable->CreateTableL(); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // UT_CPredictiveSearchSettingsTable::Teardown |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void UT_CPredictiveSearchSettingsTable::Teardown() |
|
111 { |
|
112 delete iTable; |
|
113 iTable = NULL; |
|
114 |
|
115 iDB.Close(); // Must close DB before it can be deleted |
|
116 RSqlDatabase::Delete(KDBFile); |
|
117 } |
|
118 |
|
119 |
|
120 // TEST CASES |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // UT_CPredictiveSearchSettingsTable::UT_CreateTableLL |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void UT_CPredictiveSearchSettingsTable::UT_CreateTableLL() |
|
127 { |
|
128 // Check that when starting w/o DB file, the settings table is created and |
|
129 // filled correctly. |
|
130 enum QLocale::Language currLang = iTable->GetCurrentLanguageL(); |
|
131 enum QLocale::Language storedLang = iTable->ReadStoredLanguageL(); |
|
132 EUNIT_ASSERT_EQUALS(currLang, storedLang); |
|
133 } |
|
134 |
|
135 |
|
136 // TEST TABLE |
|
137 |
|
138 EUNIT_BEGIN_TEST_TABLE( |
|
139 UT_CPredictiveSearchSettingsTable, |
|
140 "UT_CPredictiveSearchSettingsTable", |
|
141 "UNIT" ) |
|
142 |
|
143 EUNIT_TEST( |
|
144 "CreateInDbL - test", |
|
145 "UT_CPredictiveSearchSettingsTable", |
|
146 "CreateTableL", |
|
147 "FUNCTIONALITY", |
|
148 SetupL, UT_CreateTableLL, Teardown ) |
|
149 |
|
150 EUNIT_END_TEST_TABLE |
|
151 |
|
152 // END OF FILE |