1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
64 if(err == KErrNone) |
64 if(err == KErrNone) |
65 { |
65 { |
66 TEntry entry; |
66 TEntry entry; |
67 if(fsSession.Entry(KTestDatabase, entry) == KErrNone) |
67 if(fsSession.Entry(KTestDatabase, entry) == KErrNone) |
68 { |
68 { |
69 RDebug::Print(_L("Deleting \"%S\" file.\n"), &KTestDatabase); |
69 TheTest.Printf(_L("Deleting \"%S\" file.\n"), &KTestDatabase); |
70 err = fsSession.SetAtt(KTestDatabase, 0, KEntryAttReadOnly); |
70 err = fsSession.SetAtt(KTestDatabase, 0, KEntryAttReadOnly); |
71 if(err != KErrNone) |
71 if(err != KErrNone) |
72 { |
72 { |
73 RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &KTestDatabase); |
73 TheTest.Printf(_L("Error %d changing \"%S\" file attributes.\n"), err, &KTestDatabase); |
74 } |
74 } |
75 err = fsSession.Delete(KTestDatabase); |
75 err = fsSession.Delete(KTestDatabase); |
76 if(err != KErrNone) |
76 if(err != KErrNone) |
77 { |
77 { |
78 RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &KTestDatabase); |
78 TheTest.Printf(_L("Error %d deleting \"%S\" file.\n"), err, &KTestDatabase); |
79 } |
79 } |
80 } |
80 } |
81 fsSession.Close(); |
81 fsSession.Close(); |
82 } |
82 } |
83 else |
83 else |
84 { |
84 { |
85 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &KTestDatabase); |
85 TheTest.Printf(_L("Error %d connecting file session. File: %S.\n"), err, &KTestDatabase); |
86 } |
86 } |
87 } |
87 } |
88 |
88 |
89 LOCAL_C void CloseDatabase() |
89 LOCAL_C void CloseDatabase() |
90 { |
90 { |
103 //If (!aValue) then the test will be panicked, the test data files will be deleted. |
103 //If (!aValue) then the test will be panicked, the test data files will be deleted. |
104 static void Check(TInt aValue, TInt aLine) |
104 static void Check(TInt aValue, TInt aLine) |
105 { |
105 { |
106 if(!aValue) |
106 if(!aValue) |
107 { |
107 { |
108 RDebug::Print(_L("*** Expression evaluated to false\r\n")); |
108 TheTest.Printf(_L("*** Expression evaluated to false\r\n")); |
109 ::TestCleanup(); |
109 ::TestCleanup(); |
110 TheTest(EFalse, aLine); |
110 TheTest(EFalse, aLine); |
111 } |
111 } |
112 } |
112 } |
113 //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted. |
113 //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted. |
114 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
114 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
115 { |
115 { |
116 if(aValue != aExpected) |
116 if(aValue != aExpected) |
117 { |
117 { |
118 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
118 TheTest.Printf(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
119 ::TestCleanup(); |
119 ::TestCleanup(); |
120 TheTest(EFalse, aLine); |
120 TheTest(EFalse, aLine); |
121 } |
121 } |
122 } |
122 } |
123 //Use these to test conditions. |
123 //Use these to test conditions. |
181 // Test the predicate on the table, then on the indexed table |
181 // Test the predicate on the table, then on the indexed table |
182 void TestPredicateBase::Test(const TSelectTest* aTest,TInt aCount,TInt aRows, TBool aLog) |
182 void TestPredicateBase::Test(const TSelectTest* aTest,TInt aCount,TInt aRows, TBool aLog) |
183 { |
183 { |
184 if(aLog) |
184 if(aLog) |
185 { |
185 { |
186 TheTest.Printf(_L("TestPredicateBase::Test\r\n")); |
186 TheTest.Printf(_L("TestPredicateBase::Test\r\n")); |
187 } |
187 } |
188 TheTable.Close(); |
188 TheTable.Close(); |
189 TInt r=TheDatabase.Commit(); |
189 TInt r=TheDatabase.Commit(); |
190 if(aLog) |
190 if(aLog) |
191 { |
191 { |
192 TheTest.Printf(_L("Commit %d\r\n"), r); |
192 TheTest.Printf(_L("Commit %d\r\n"), r); |
193 } |
193 } |
194 TEST2(r, KErrNone); |
194 TEST2(r, KErrNone); |
195 TRAPD(errCode, TestViewL(aTest,aCount,aRows, aLog)); |
195 TRAPD(errCode, TestViewL(aTest,aCount,aRows, aLog)); |
196 if(aLog) |
196 if(aLog) |
197 { |
197 { |
198 TheTest.Printf(_L("TestViewL %d"), errCode); |
198 TheTest.Printf(_L("TestViewL %d"), errCode); |
199 } |
199 } |
200 |
200 |
201 TEST2(errCode, KErrNone); |
201 TEST2(errCode, KErrNone); |
202 r=TheDatabase.Execute(_L("CREATE INDEX Key ON Compare (Test)")); |
202 r=TheDatabase.Execute(_L("CREATE INDEX Key ON Compare (Test)")); |
203 if(aLog) |
203 if(aLog) |
204 { |
204 { |
205 TheTest.Printf(_L("Execute %d"), r); |
205 TheTest.Printf(_L("Execute %d"), r); |
206 } |
206 } |
207 |
207 |
208 TEST2(r, KErrNone); |
208 TEST2(r, KErrNone); |
209 TRAP(errCode,TestViewL(aTest,aCount,aRows, aLog)); |
209 TRAP(errCode,TestViewL(aTest,aCount,aRows, aLog)); |
210 if(aLog) |
210 if(aLog) |
211 { |
211 { |
212 TheTest.Printf(_L("TestViewL %d"), errCode); |
212 TheTest.Printf(_L("TestViewL %d"), errCode); |
213 } |
213 } |
214 |
214 |
215 TEST2(errCode, KErrNone); |
215 TEST2(errCode, KErrNone); |
216 r=TheDatabase.Execute(_L("DROP TABLE Compare")); |
216 r=TheDatabase.Execute(_L("DROP TABLE Compare")); |
217 if(aLog) |
217 if(aLog) |
218 { |
218 { |
219 TheTest.Printf(_L("Execute %d"), r); |
219 TheTest.Printf(_L("Execute %d"), r); |
220 } |
220 } |
221 |
221 |
222 TEST2(r, KErrNone); |
222 TEST2(r, KErrNone); |
223 } |
223 } |
224 |
224 |
230 { |
230 { |
231 TheSql.Format(_L("SELECT Id FROM Compare WHERE Test %s"),aTest->iSearchCondition); |
231 TheSql.Format(_L("SELECT Id FROM Compare WHERE Test %s"),aTest->iSearchCondition); |
232 TInt r=TheView.Prepare(TheDatabase,TheSql,TheView.EReadOnly); |
232 TInt r=TheView.Prepare(TheDatabase,TheSql,TheView.EReadOnly); |
233 if(r!=KErrNone) |
233 if(r!=KErrNone) |
234 { |
234 { |
235 TheTest.Printf(_L("Prepare r= %d aCount= %d statement %S\r\n"), r, aCount, &TheSql); |
235 TheTest.Printf(_L("Prepare r= %d aCount= %d statement %S\r\n"), r, aCount, &TheSql); |
236 } |
236 } |
237 TEST2(r, KErrNone); |
237 TEST2(r, KErrNone); |
238 TBool ignoreRow0=TheView.Unevaluated(); |
238 TBool ignoreRow0=TheView.Unevaluated(); |
239 r=TheView.EvaluateAll(); |
239 r=TheView.EvaluateAll(); |
240 TEST2(r, KErrNone); |
240 TEST2(r, KErrNone); |
786 _LIT(KTypeTextKTests46, "Z:\\test\\TypeTextKTests46.dat"); |
786 _LIT(KTypeTextKTests46, "Z:\\test\\TypeTextKTests46.dat"); |
787 _LIT(KTypeTextKTests47, "Z:\\test\\TypeTextKTests47.dat"); |
787 _LIT(KTypeTextKTests47, "Z:\\test\\TypeTextKTests47.dat"); |
788 |
788 |
789 static void ReadDesc(TDes& aDes, const TDesC& aFilename, RFs& aFs) |
789 static void ReadDesc(TDes& aDes, const TDesC& aFilename, RFs& aFs) |
790 { |
790 { |
791 TheTest.Printf(_L("---ReadDesc(), aFilename=%S\r\n"), &aFilename); |
791 TheTest.Printf(_L("---ReadDesc(), aFilename=%S\r\n"), &aFilename); |
792 RFile file; |
792 RFile file; |
793 TInt err = file.Open(aFs, aFilename, EFileRead); |
793 TInt err = file.Open(aFs, aFilename, EFileRead); |
794 TheTest.Printf(_L("Open file aFilename=%S err = %d\r\n"), &aFilename, err); |
794 TheTest.Printf(_L("Open file aFilename=%S err = %d\r\n"), &aFilename, err); |
795 TEST2(err, KErrNone); |
795 TEST2(err, KErrNone); |
796 |
796 |