|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32test.h> |
|
17 #include <bautils.h> |
|
18 #include <sqldb.h> |
|
19 |
|
20 /////////////////////////////////////////////////////////////////////////////////////// |
|
21 |
|
22 #define UNUSED_VAR(a) (a) = (a) |
|
23 #define IGNORE_ERR(a) (a) = (a) |
|
24 |
|
25 RTest TheTest(_L("t_sqlpanic test")); |
|
26 |
|
27 _LIT(KTestDir, "c:\\test\\"); |
|
28 _LIT(KTestDbName, "c:\\test\\t_sqlpanic.db"); |
|
29 |
|
30 _LIT(KCategory, "SqlDb"); |
|
31 |
|
32 /////////////////////////////////////////////////////////////////////////////////////// |
|
33 |
|
34 void DeleteTestFiles() |
|
35 { |
|
36 RSqlDatabase::Delete(KTestDbName); |
|
37 } |
|
38 |
|
39 /////////////////////////////////////////////////////////////////////////////////////// |
|
40 /////////////////////////////////////////////////////////////////////////////////////// |
|
41 //Test macros and functions |
|
42 void Check(TInt aValue, TInt aLine) |
|
43 { |
|
44 if(!aValue) |
|
45 { |
|
46 DeleteTestFiles(); |
|
47 TheTest(EFalse, aLine); |
|
48 } |
|
49 } |
|
50 void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
51 { |
|
52 if(aValue != aExpected) |
|
53 { |
|
54 DeleteTestFiles(); |
|
55 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
56 TheTest(EFalse, aLine); |
|
57 } |
|
58 } |
|
59 #define TEST(arg) ::Check((arg), __LINE__) |
|
60 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
61 |
|
62 /////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
64 void CreateTestDir() |
|
65 { |
|
66 RFs fs; |
|
67 TInt err = fs.Connect(); |
|
68 TEST2(err, KErrNone); |
|
69 |
|
70 err = fs.MkDir(KTestDir); |
|
71 TEST(err == KErrNone || err == KErrAlreadyExists); |
|
72 |
|
73 fs.Close(); |
|
74 } |
|
75 |
|
76 /////////////////////////////////////////////////////////////////////////////////////// |
|
77 |
|
78 //Panic thread function. |
|
79 //It will cast aData parameter to a TFunctor pointer and call it. |
|
80 //The expectation is that the called function will panic and kill the panic thread. |
|
81 TInt ThreadFunc(void* aData) |
|
82 { |
|
83 CTrapCleanup* tc = CTrapCleanup::New(); |
|
84 TEST(tc != NULL); |
|
85 |
|
86 User::SetJustInTime(EFalse); // disable debugger panic handling |
|
87 |
|
88 TFunctor* obj = reinterpret_cast<TFunctor*> (aData); |
|
89 TEST(obj != NULL); |
|
90 (*obj)();//call the panic function |
|
91 |
|
92 delete tc; |
|
93 |
|
94 return KErrNone; |
|
95 } |
|
96 |
|
97 //Panic test. |
|
98 //PanicTest function will create a new thread - panic thread, giving it a pointer to the function which has to |
|
99 //be executed and the expectation is that the function will panic and kill the panic thread. |
|
100 //PanicTest function will check the panic thread exit code, exit category and the panic code. |
|
101 void PanicTest(TFunctor& aFunctor, TExitType aExpectedExitType, const TDesC& aExpectedCategory, TInt aExpectedPanicCode) |
|
102 { |
|
103 RThread thread; |
|
104 _LIT(KThreadName,"SqlDbPanicThread"); |
|
105 TEST2(thread.Create(KThreadName, &ThreadFunc, 0x2000, 0x1000, 0x10000, (void*)&aFunctor, EOwnerThread), KErrNone); |
|
106 |
|
107 TRequestStatus status; |
|
108 thread.Logon(status); |
|
109 TEST2(status.Int(), KRequestPending); |
|
110 thread.Resume(); |
|
111 User::WaitForRequest(status); |
|
112 User::SetJustInTime(ETrue); // enable debugger panic handling |
|
113 |
|
114 TEST2(thread.ExitType(), aExpectedExitType); |
|
115 TEST(thread.ExitCategory() == aExpectedCategory); |
|
116 TEST2(thread.ExitReason(), aExpectedPanicCode); |
|
117 |
|
118 CLOSE_AND_WAIT(thread); |
|
119 } |
|
120 |
|
121 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
122 ////////////////////////////// Panic test functions ///////////////////////////////////////////////// |
|
123 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
124 |
|
125 //Panic when calling RSqlDatabase::Exec() on an invalid RSqlDatabase object. |
|
126 class TSqlDatabase_NotCreated_Exec8 : public TFunctor |
|
127 { |
|
128 private: |
|
129 virtual void operator()() |
|
130 { |
|
131 RSqlDatabase db; |
|
132 db.Exec(_L8("CREATE TABLE A(f integer)"));//panic here |
|
133 } |
|
134 }; |
|
135 static TSqlDatabase_NotCreated_Exec8 TheSqlDatabase_NotCreated_Exec8; |
|
136 |
|
137 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
138 //Panic when calling RSqlDatabase::Exec() on an invalid RSqlDatabase object. |
|
139 class TSqlDatabase_NotCreated_Exec : public TFunctor |
|
140 { |
|
141 private: |
|
142 virtual void operator()() |
|
143 { |
|
144 RSqlDatabase db; |
|
145 db.Exec(_L("CREATE TABLE A(f integer)"));//panic here |
|
146 } |
|
147 }; |
|
148 static TSqlDatabase_NotCreated_Exec TheSqlDatabase_NotCreated_Exec; |
|
149 |
|
150 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
151 //Panic when calling RSqlDatabase::GetSecuritySettings() on an invalid RSqlDatabase object. |
|
152 class TSqlDatabase_NotCreated_SecuritySettings : public TFunctor |
|
153 { |
|
154 private: |
|
155 virtual void operator()() |
|
156 { |
|
157 RSqlDatabase db; |
|
158 RSqlSecurityPolicy securityPolicy; |
|
159 (void)db.GetSecurityPolicy(securityPolicy);//panic here |
|
160 } |
|
161 }; |
|
162 static TSqlDatabase_NotCreated_SecuritySettings TheSqlDatabase_NotCreated_SecuritySettings; |
|
163 |
|
164 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
165 //Panic when calling RSqlDatabase::SetIsolationLevel() on an invalid RSqlDatabase object. |
|
166 class TSqlDatabase_NotCreated_SetIsolationLevel : public TFunctor |
|
167 { |
|
168 private: |
|
169 virtual void operator()() |
|
170 { |
|
171 RSqlDatabase db; |
|
172 db.SetIsolationLevel(RSqlDatabase::EReadUncommitted);//panic here |
|
173 } |
|
174 }; |
|
175 static TSqlDatabase_NotCreated_SetIsolationLevel TheSqlDatabase_NotCreated_SetIsolationLevel; |
|
176 |
|
177 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
178 //Panic when calling RSqlDatabase::LastErrorMessage() on an invalid RSqlDatabase object. |
|
179 class TSqlDatabase_NotCreated_LastErrorMessage : public TFunctor |
|
180 { |
|
181 private: |
|
182 virtual void operator()() |
|
183 { |
|
184 RSqlDatabase db; |
|
185 db.LastErrorMessage();//panic here |
|
186 } |
|
187 }; |
|
188 static TSqlDatabase_NotCreated_LastErrorMessage TheSqlDatabase_NotCreated_LastErrorMessage; |
|
189 |
|
190 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
191 //Panic when calling RSqlDatabase::LastInsertedRowId() on an invalid RSqlDatabase object. |
|
192 class TSqlDatabase_NotCreated_LastInsertedRowId : public TFunctor |
|
193 { |
|
194 private: |
|
195 virtual void operator()() |
|
196 { |
|
197 RSqlDatabase db; |
|
198 db.LastInsertedRowId();//panic here |
|
199 } |
|
200 }; |
|
201 static TSqlDatabase_NotCreated_LastInsertedRowId TheSqlDatabase_NotCreated_LastInsertedRowId; |
|
202 |
|
203 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
204 //Panic when calling RSqlDatabase::Size() on an invalid RSqlDatabase object. |
|
205 class TSqlDatabase_NotCreated_Size : public TFunctor |
|
206 { |
|
207 private: |
|
208 virtual void operator()() |
|
209 { |
|
210 RSqlDatabase db; |
|
211 (void)db.Size();//panic here |
|
212 } |
|
213 }; |
|
214 static TSqlDatabase_NotCreated_Size TheSqlDatabase_NotCreated_Size; |
|
215 |
|
216 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
217 //Panic when calling RSqlDatabase::Size(TSize&) on an invalid RSqlDatabase object. |
|
218 class TSqlDatabase_NotCreated_Size2 : public TFunctor |
|
219 { |
|
220 private: |
|
221 virtual void operator()() |
|
222 { |
|
223 RSqlDatabase db; |
|
224 RSqlDatabase::TSize size; |
|
225 (void)db.Size(size);//panic here |
|
226 } |
|
227 }; |
|
228 static TSqlDatabase_NotCreated_Size2 TheSqlDatabase_NotCreated_Size2; |
|
229 |
|
230 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
231 //Panic when calling RSqlDatabase::InTransaction() on an invalid RSqlDatabase object. |
|
232 class TSqlDatabase_NotCreated_InTransaction : public TFunctor |
|
233 { |
|
234 private: |
|
235 virtual void operator()() |
|
236 { |
|
237 RSqlDatabase db; |
|
238 (void)db.InTransaction();//panic here |
|
239 } |
|
240 }; |
|
241 static TSqlDatabase_NotCreated_InTransaction TheSqlDatabase_NotCreated_InTransaction; |
|
242 |
|
243 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
244 //Panic when calling RSqlDatabase::Attach() on an invalid RSqlDatabase object. |
|
245 class TSqlDatabase_NotCreated_Attach : public TFunctor |
|
246 { |
|
247 private: |
|
248 virtual void operator()() |
|
249 { |
|
250 RSqlDatabase db; |
|
251 db.Attach(_L("C:\\TEST\\A.DB"), _L("A"));//panic here |
|
252 } |
|
253 }; |
|
254 static TSqlDatabase_NotCreated_Attach TheSqlDatabase_NotCreated_Attach; |
|
255 |
|
256 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
257 //Panic when calling RSqlDatabase::Detach() on an invalid RSqlDatabase object. |
|
258 class TSqlDatabase_NotCreated_Detach : public TFunctor |
|
259 { |
|
260 private: |
|
261 virtual void operator()() |
|
262 { |
|
263 RSqlDatabase db; |
|
264 db.Detach(_L("A"));//panic here |
|
265 } |
|
266 }; |
|
267 static TSqlDatabase_NotCreated_Detach TheSqlDatabase_NotCreated_Detach; |
|
268 |
|
269 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
270 //Panic when calling RSqlDatabase::Compact() on an invalid RSqlDatabase object. |
|
271 class TSqlDatabase_NotCreated_Compact : public TFunctor |
|
272 { |
|
273 private: |
|
274 virtual void operator()() |
|
275 { |
|
276 RSqlDatabase db; |
|
277 db.Compact(2048);//panic here |
|
278 } |
|
279 }; |
|
280 static TSqlDatabase_NotCreated_Compact TheSqlDatabase_NotCreated_Compact; |
|
281 |
|
282 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
283 //Panic when calling async RSqlDatabase::Compact() on an invalid RSqlDatabase object. |
|
284 class TSqlDatabase_NotCreated_Compact2 : public TFunctor |
|
285 { |
|
286 private: |
|
287 virtual void operator()() |
|
288 { |
|
289 RSqlDatabase db; |
|
290 TRequestStatus stat; |
|
291 db.Compact(2048, stat);//panic here |
|
292 } |
|
293 }; |
|
294 static TSqlDatabase_NotCreated_Compact2 TheSqlDatabase_NotCreated_Compact2; |
|
295 |
|
296 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
297 //Panic when calling RSqlStatement::Reset() on an invalid RSqlStatement object. |
|
298 class TSqlStatement_NotCreated_Reset : public TFunctor |
|
299 { |
|
300 private: |
|
301 virtual void operator()() |
|
302 { |
|
303 RSqlStatement stmt; |
|
304 stmt.Reset();//panic here |
|
305 } |
|
306 }; |
|
307 static TSqlStatement_NotCreated_Reset TheSqlStatement_NotCreated_Reset; |
|
308 |
|
309 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
310 //Panic when calling RSqlStatement::Exec() on an invalid RSqlStatement object. |
|
311 class TSqlStatement_NotCreated_Exec : public TFunctor |
|
312 { |
|
313 private: |
|
314 virtual void operator()() |
|
315 { |
|
316 RSqlStatement stmt; |
|
317 stmt.Exec();//panic here |
|
318 } |
|
319 }; |
|
320 static TSqlStatement_NotCreated_Exec TheSqlStatement_NotCreated_Exec; |
|
321 |
|
322 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
323 //Panic when calling RSqlStatement::Next() on an invalid RSqlStatement object. |
|
324 class TSqlStatement_NotCreated_Next : public TFunctor |
|
325 { |
|
326 private: |
|
327 virtual void operator()() |
|
328 { |
|
329 RSqlStatement stmt; |
|
330 stmt.Next();//panic here |
|
331 } |
|
332 }; |
|
333 static TSqlStatement_NotCreated_Next TheSqlStatement_NotCreated_Next; |
|
334 |
|
335 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
336 //Panic when calling RSqlStatement::ParameterIndex() on an invalid RSqlStatement object. |
|
337 class TSqlStatement_NotCreated_ParameterIndex : public TFunctor |
|
338 { |
|
339 private: |
|
340 virtual void operator()() |
|
341 { |
|
342 RSqlStatement stmt; |
|
343 stmt.ParameterIndex(_L("ABV"));//panic here |
|
344 } |
|
345 }; |
|
346 static TSqlStatement_NotCreated_ParameterIndex TheSqlStatement_NotCreated_ParameterIndex; |
|
347 |
|
348 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
349 //Panic when calling RSqlStatement::ColumnIndex() on an invalid RSqlStatement object. |
|
350 class TSqlStatement_NotCreated_ColumnIndex : public TFunctor |
|
351 { |
|
352 private: |
|
353 virtual void operator()() |
|
354 { |
|
355 RSqlStatement stmt; |
|
356 stmt.ColumnIndex(_L("ABV"));//panic here |
|
357 } |
|
358 }; |
|
359 static TSqlStatement_NotCreated_ColumnIndex TheSqlStatement_NotCreated_ColumnIndex; |
|
360 |
|
361 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
362 //Panic when calling RSqlStatement::ColumnType() on an invalid RSqlStatement object. |
|
363 class TSqlStatement_NotCreated_ColumnType : public TFunctor |
|
364 { |
|
365 private: |
|
366 virtual void operator()() |
|
367 { |
|
368 RSqlStatement stmt; |
|
369 stmt.ColumnType(1);//panic here |
|
370 } |
|
371 }; |
|
372 static TSqlStatement_NotCreated_ColumnType TheSqlStatement_NotCreated_ColumnType; |
|
373 |
|
374 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
375 //Panic when calling RSqlStatement::ColumnSize() on an invalid RSqlStatement object. |
|
376 class TSqlStatement_NotCreated_ColumnSize : public TFunctor |
|
377 { |
|
378 private: |
|
379 virtual void operator()() |
|
380 { |
|
381 RSqlStatement stmt; |
|
382 stmt.ColumnSize(1);//panic here |
|
383 } |
|
384 }; |
|
385 static TSqlStatement_NotCreated_ColumnSize TheSqlStatement_NotCreated_ColumnSize; |
|
386 |
|
387 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
388 //Panic when calling RSqlStatement::BindNull() on an invalid RSqlStatement object. |
|
389 class TSqlStatement_NotCreated_BindNull : public TFunctor |
|
390 { |
|
391 private: |
|
392 virtual void operator()() |
|
393 { |
|
394 RSqlStatement stmt; |
|
395 stmt.BindNull(1);//panic here |
|
396 } |
|
397 }; |
|
398 static TSqlStatement_NotCreated_BindNull TheSqlStatement_NotCreated_BindNull; |
|
399 |
|
400 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
401 //Panic when calling RSqlStatement::BindInt() on an invalid RSqlStatement object. |
|
402 class TSqlStatement_NotCreated_BindInt : public TFunctor |
|
403 { |
|
404 private: |
|
405 virtual void operator()() |
|
406 { |
|
407 RSqlStatement stmt; |
|
408 stmt.BindInt(1, 2);//panic here |
|
409 } |
|
410 }; |
|
411 static TSqlStatement_NotCreated_BindInt TheSqlStatement_NotCreated_BindInt; |
|
412 |
|
413 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
414 //Panic when calling RSqlStatement::BindInt64() on an invalid RSqlStatement object. |
|
415 class TSqlStatement_NotCreated_BindInt64 : public TFunctor |
|
416 { |
|
417 private: |
|
418 virtual void operator()() |
|
419 { |
|
420 RSqlStatement stmt; |
|
421 stmt.BindInt64(1, TInt64(2));//panic here |
|
422 } |
|
423 }; |
|
424 static TSqlStatement_NotCreated_BindInt64 TheSqlStatement_NotCreated_BindInt64; |
|
425 |
|
426 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
427 //Panic when calling RSqlStatement::BindReal() on an invalid RSqlStatement object. |
|
428 class TSqlStatement_NotCreated_BindReal : public TFunctor |
|
429 { |
|
430 private: |
|
431 virtual void operator()() |
|
432 { |
|
433 RSqlStatement stmt; |
|
434 stmt.BindReal(1, 2.5);//panic here |
|
435 } |
|
436 }; |
|
437 static TSqlStatement_NotCreated_BindReal TheSqlStatement_NotCreated_BindReal; |
|
438 |
|
439 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
440 //Panic when calling RSqlStatement::BindText() on an invalid RSqlStatement object. |
|
441 class TSqlStatement_NotCreated_BindText : public TFunctor |
|
442 { |
|
443 private: |
|
444 virtual void operator()() |
|
445 { |
|
446 RSqlStatement stmt; |
|
447 stmt.BindText(1, _L("ABV"));//panic here |
|
448 } |
|
449 }; |
|
450 static TSqlStatement_NotCreated_BindText TheSqlStatement_NotCreated_BindText; |
|
451 |
|
452 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
453 //Panic when calling RSqlStatement::BindBinary() on an invalid RSqlStatement object. |
|
454 class TSqlStatement_NotCreated_BindBinary : public TFunctor |
|
455 { |
|
456 private: |
|
457 virtual void operator()() |
|
458 { |
|
459 RSqlStatement stmt; |
|
460 stmt.BindBinary(1, _L8("ABV"));//panic here |
|
461 } |
|
462 }; |
|
463 static TSqlStatement_NotCreated_BindBinary TheSqlStatement_NotCreated_BindBinary; |
|
464 |
|
465 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
466 //Panic when calling RSqlStatement::BindZeroBlob() on an invalid RSqlStatement object. |
|
467 class TSqlStatement_NotCreated_BindZeroBlob : public TFunctor |
|
468 { |
|
469 private: |
|
470 virtual void operator()() |
|
471 { |
|
472 RSqlStatement stmt; |
|
473 stmt.BindZeroBlob(1, 100);//panic here |
|
474 } |
|
475 }; |
|
476 static TSqlStatement_NotCreated_BindZeroBlob TheSqlStatement_NotCreated_BindZeroBlob; |
|
477 |
|
478 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
479 //Panic when an attempt is made to call RSqlStatement::BindZeroBlob() giving an invalid parameter index. |
|
480 class TSqlStatement_OutOfBounds_BindZeroBlob : public TFunctor |
|
481 { |
|
482 private: |
|
483 virtual void operator()() |
|
484 { |
|
485 RSqlDatabase db; |
|
486 TEST2(db.Create(KTestDbName), KErrNone); |
|
487 TEST2(db.Exec(_L8("CREATE TABLE D(A INTEGER, B BLOB)")), 1); |
|
488 RSqlStatement stmt; |
|
489 TEST2(stmt.Prepare(db, _L8("INSERT INTO D VALUES(1, :Prm1)")), KErrNone); |
|
490 stmt.BindZeroBlob(12, 100);//panic here |
|
491 stmt.Close(); |
|
492 db.Close(); |
|
493 } |
|
494 }; |
|
495 static TSqlStatement_OutOfBounds_BindZeroBlob TheSqlStatement_OutOfBounds_BindZeroBlob; |
|
496 |
|
497 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
498 //Panic when calling RSqlStatement::IsNull() on an invalid RSqlStatement object. |
|
499 class TSqlStatement_NotCreated_IsNull : public TFunctor |
|
500 { |
|
501 private: |
|
502 virtual void operator()() |
|
503 { |
|
504 RSqlStatement stmt; |
|
505 stmt.IsNull(1);//panic here |
|
506 } |
|
507 }; |
|
508 static TSqlStatement_NotCreated_IsNull TheSqlStatement_NotCreated_IsNull; |
|
509 |
|
510 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
511 //Panic when calling RSqlStatement::ColumnInt() on an invalid RSqlStatement object. |
|
512 class TSqlStatement_NotCreated_ColumnInt : public TFunctor |
|
513 { |
|
514 private: |
|
515 virtual void operator()() |
|
516 { |
|
517 RSqlStatement stmt; |
|
518 stmt.ColumnInt(1);//panic here |
|
519 } |
|
520 }; |
|
521 static TSqlStatement_NotCreated_ColumnInt TheSqlStatement_NotCreated_ColumnInt; |
|
522 |
|
523 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
524 //Panic when calling RSqlStatement::ColumnInt64() on an invalid RSqlStatement object. |
|
525 class TSqlStatement_NotCreated_ColumnInt64 : public TFunctor |
|
526 { |
|
527 private: |
|
528 virtual void operator()() |
|
529 { |
|
530 RSqlStatement stmt; |
|
531 stmt.ColumnInt64(1);//panic here |
|
532 } |
|
533 }; |
|
534 static TSqlStatement_NotCreated_ColumnInt64 TheSqlStatement_NotCreated_ColumnInt64; |
|
535 |
|
536 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
537 //Panic when calling RSqlStatement::ColumnReal() on an invalid RSqlStatement object. |
|
538 class TSqlStatement_NotCreated_ColumnReal : public TFunctor |
|
539 { |
|
540 private: |
|
541 virtual void operator()() |
|
542 { |
|
543 RSqlStatement stmt; |
|
544 stmt.ColumnReal(1);//panic here |
|
545 } |
|
546 }; |
|
547 static TSqlStatement_NotCreated_ColumnReal TheSqlStatement_NotCreated_ColumnReal; |
|
548 |
|
549 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
550 //Panic when calling RSqlStatement::ColumnText() on an invalid RSqlStatement object. |
|
551 class TSqlStatement_NotCreated_ColumnText : public TFunctor |
|
552 { |
|
553 private: |
|
554 virtual void operator()() |
|
555 { |
|
556 RSqlStatement stmt; |
|
557 TPtrC ptr; |
|
558 (void)stmt.ColumnText(1, ptr);//panic here |
|
559 } |
|
560 }; |
|
561 static TSqlStatement_NotCreated_ColumnText TheSqlStatement_NotCreated_ColumnText; |
|
562 |
|
563 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
564 //Panic when calling RSqlStatement::ColumnText() on an invalid RSqlStatement object. |
|
565 class TSqlStatement_NotCreated_ColumnText2 : public TFunctor |
|
566 { |
|
567 private: |
|
568 virtual void operator()() |
|
569 { |
|
570 RSqlStatement stmt; |
|
571 TBuf<10> buf; |
|
572 stmt.ColumnText(1, buf);//panic here |
|
573 } |
|
574 }; |
|
575 static TSqlStatement_NotCreated_ColumnText2 TheSqlStatement_NotCreated_ColumnText2; |
|
576 |
|
577 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
578 //Panic when calling RSqlStatement::ColumnBinary() on an invalid RSqlStatement object. |
|
579 class TSqlStatement_NotCreated_ColumnBinary : public TFunctor |
|
580 { |
|
581 private: |
|
582 virtual void operator()() |
|
583 { |
|
584 RSqlStatement stmt; |
|
585 TPtrC8 ptr; |
|
586 (void)stmt.ColumnBinary(1, ptr);//panic here |
|
587 } |
|
588 }; |
|
589 static TSqlStatement_NotCreated_ColumnBinary TheSqlStatement_NotCreated_ColumnBinary; |
|
590 |
|
591 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
592 //Panic when calling RSqlStatement::ColumnBinary() on an invalid RSqlStatement object. |
|
593 class TSqlStatement_NotCreated_ColumnBinary2 : public TFunctor |
|
594 { |
|
595 private: |
|
596 virtual void operator()() |
|
597 { |
|
598 RSqlStatement stmt; |
|
599 TBuf8<10> buf; |
|
600 stmt.ColumnBinary(1, buf);//panic here |
|
601 } |
|
602 }; |
|
603 static TSqlStatement_NotCreated_ColumnBinary2 TheSqlStatement_NotCreated_ColumnBinary2; |
|
604 |
|
605 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
606 //Panic when calling RSqlStatement::Prepare() giving an invalid RSqlDatabase object. |
|
607 class TSqlStatement_DbNotCreated_Prepare : public TFunctor |
|
608 { |
|
609 private: |
|
610 virtual void operator()() |
|
611 { |
|
612 RSqlDatabase db; |
|
613 RSqlStatement stmt; |
|
614 stmt.Prepare(db, _L("CREATE TABLE A(d INTEGER)"));//panic here |
|
615 } |
|
616 }; |
|
617 static TSqlStatement_DbNotCreated_Prepare TheSqlStatement_DbNotCreated_Prepare; |
|
618 |
|
619 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
620 //Panic when calling RSqlStatement::Prepare() giving an invalid RSqlDatabase object. |
|
621 class TSqlStatement_DbNotCreated_Prepare8 : public TFunctor |
|
622 { |
|
623 private: |
|
624 virtual void operator()() |
|
625 { |
|
626 RSqlDatabase db; |
|
627 RSqlStatement stmt; |
|
628 stmt.Prepare(db, _L8("CREATE TABLE A(d INTEGER)"));//panic here |
|
629 } |
|
630 }; |
|
631 static TSqlStatement_DbNotCreated_Prepare8 TheSqlStatement_DbNotCreated_Prepare8; |
|
632 |
|
633 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
634 /* |
|
635 //Panic when an attempt is made to call RSqlStatement::Prepare() twice on the same RSqlStatement object. |
|
636 class TSqlStatement_CreateTwice : public TFunctor |
|
637 { |
|
638 private: |
|
639 virtual void operator()() |
|
640 { |
|
641 RSqlDatabase db; |
|
642 TEST2(db.Create(KTestDbName), KErrNone); |
|
643 RSqlStatement stmt; |
|
644 TEST2(stmt.Prepare(db, _L("CREATE TABLE A(d INTEGER)")), KErrNone); |
|
645 stmt.Prepare(db, _L("CREATE TABLE A(d INTEGER)"));//panic here |
|
646 stmt.Close(); |
|
647 db.Close(); |
|
648 } |
|
649 }; |
|
650 static TSqlStatement_CreateTwice TheSqlStatement_CreateTwice; |
|
651 |
|
652 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
653 //Panic when an attempt is made to call RSqlStatement::Prepare() twice on the same RSqlStatement object. |
|
654 class TSqlStatement_CreateTwice8 : public TFunctor |
|
655 { |
|
656 private: |
|
657 virtual void operator()() |
|
658 { |
|
659 RSqlDatabase db; |
|
660 TEST2(db.Create(KTestDbName), KErrNone); |
|
661 RSqlStatement stmt; |
|
662 TEST2(stmt.Prepare(db, _L8("CREATE TABLE A(d INTEGER)")), KErrNone); |
|
663 stmt.Prepare(db, _L8("CREATE TABLE A(d INTEGER)"));//panic here |
|
664 stmt.Close(); |
|
665 db.Close(); |
|
666 } |
|
667 }; |
|
668 static TSqlStatement_CreateTwice8 TheSqlStatement_CreateTwice8; |
|
669 */ |
|
670 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
671 //Panic when an attempt is made to call RSqlStatement::ColumnType() giving an invalid column index. |
|
672 class TSqlStatement_OutOfBounds_ColumnType : public TFunctor |
|
673 { |
|
674 private: |
|
675 virtual void operator()() |
|
676 { |
|
677 RSqlDatabase db; |
|
678 TEST2(db.Create(KTestDbName), KErrNone); |
|
679 TEST(db.Exec(_L8("CREATE TABLE D(A INTEGER, B INTEGER, C INTEGER)")) >= 0); |
|
680 RSqlStatement stmt; |
|
681 TEST2(stmt.Prepare(db, _L8("SELECT A, B, C FROM D")), KErrNone); |
|
682 stmt.ColumnType(12);//panic here |
|
683 stmt.Close(); |
|
684 db.Close(); |
|
685 } |
|
686 }; |
|
687 static TSqlStatement_OutOfBounds_ColumnType TheSqlStatement_OutOfBounds_ColumnType; |
|
688 |
|
689 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
690 //Panic when an attempt is made to call RSqlStatement::ColumnSize() giving an invalid column index. |
|
691 class TSqlStatement_OutOfBounds_ColumnSize : public TFunctor |
|
692 { |
|
693 private: |
|
694 virtual void operator()() |
|
695 { |
|
696 RSqlDatabase db; |
|
697 TEST2(db.Create(KTestDbName), KErrNone); |
|
698 TEST(db.Exec(_L8("CREATE TABLE D(A INTEGER, B INTEGER, C INTEGER)")) >= 0); |
|
699 RSqlStatement stmt; |
|
700 TEST2(stmt.Prepare(db, _L8("SELECT A, B, C FROM D")), KErrNone); |
|
701 stmt.ColumnSize(-25);//panic here |
|
702 stmt.Close(); |
|
703 db.Close(); |
|
704 } |
|
705 }; |
|
706 static TSqlStatement_OutOfBounds_ColumnSize TheSqlStatement_OutOfBounds_ColumnSize; |
|
707 |
|
708 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
709 //Panic when an attempt is made to call RSqlStatement::BindNull() giving an invalid parameter index. |
|
710 class TSqlStatement_OutOfBounds_Bind : public TFunctor |
|
711 { |
|
712 private: |
|
713 virtual void operator()() |
|
714 { |
|
715 RSqlDatabase db; |
|
716 TEST2(db.Create(KTestDbName), KErrNone); |
|
717 TEST(db.Exec(_L8("CREATE TABLE D(A INTEGER, B INTEGER, C INTEGER)")) >= 0); |
|
718 RSqlStatement stmt; |
|
719 TEST2(stmt.Prepare(db, _L8("SELECT A, B, C FROM D WHERE A = :V")), KErrNone); |
|
720 stmt.BindNull(2);//panic here |
|
721 stmt.Close(); |
|
722 db.Close(); |
|
723 } |
|
724 }; |
|
725 static TSqlStatement_OutOfBounds_Bind TheSqlStatement_OutOfBounds_Bind; |
|
726 |
|
727 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
728 //Panic when an attempt is made to call RSqlStatement::ColumnInt() giving an invalid column index. |
|
729 class TSqlStatement_OutOfBounds_ColumnValue : public TFunctor |
|
730 { |
|
731 private: |
|
732 virtual void operator()() |
|
733 { |
|
734 RSqlDatabase db; |
|
735 TEST2(db.Create(KTestDbName), KErrNone); |
|
736 TEST(db.Exec(_L8("CREATE TABLE D(A INTEGER, B INTEGER, C INTEGER)")) >= 0); |
|
737 RSqlStatement stmt; |
|
738 TEST2(stmt.Prepare(db, _L8("SELECT A, B, C FROM D")), KErrNone); |
|
739 stmt.ColumnInt(56);//panic here |
|
740 stmt.Close(); |
|
741 db.Close(); |
|
742 } |
|
743 }; |
|
744 static TSqlStatement_OutOfBounds_ColumnValue TheSqlStatement_OutOfBounds_ColumnValue; |
|
745 |
|
746 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
747 //Panic when calling RSqlStatement::ColumnCount() on an invalid RSqlStatement object. |
|
748 class TSqlStatement_NotCreated_ColumnCount : public TFunctor |
|
749 { |
|
750 private: |
|
751 virtual void operator()() |
|
752 { |
|
753 RSqlStatement stmt; |
|
754 stmt.ColumnCount();//panic here |
|
755 } |
|
756 }; |
|
757 static TSqlStatement_NotCreated_ColumnCount TheSqlStatement_NotCreated_ColumnCount; |
|
758 |
|
759 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
760 //Panic when calling RSqlStatement::DeclaredColumnType() on an invalid RSqlStatement object. |
|
761 class TSqlStatement_NotCreated_DeclaredColumnType : public TFunctor |
|
762 { |
|
763 private: |
|
764 virtual void operator()() |
|
765 { |
|
766 RSqlStatement stmt; |
|
767 TSqlColumnType colType; |
|
768 stmt.DeclaredColumnType(0, colType);//panic here |
|
769 } |
|
770 }; |
|
771 static TSqlStatement_NotCreated_DeclaredColumnType TheSqlStatement_NotCreated_DeclaredColumnType; |
|
772 |
|
773 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
774 //Panic when an attempt is made to call RSqlStatement::DeclaredColumnType() giving an invalid column index. |
|
775 class TSqlStatement_OutOfBounds_DeclaredColumnType : public TFunctor |
|
776 { |
|
777 private: |
|
778 virtual void operator()() |
|
779 { |
|
780 RSqlDatabase db; |
|
781 TEST2(db.Create(KTestDbName), KErrNone); |
|
782 TEST(db.Exec(_L8("CREATE TABLE D(A INTEGER, B INTEGER, C INTEGER)")) >= 0); |
|
783 RSqlStatement stmt; |
|
784 TEST2(stmt.Prepare(db, _L8("SELECT A, B, C FROM D")), KErrNone); |
|
785 TSqlColumnType colType; |
|
786 stmt.DeclaredColumnType(8, colType);//panic here |
|
787 stmt.Close(); |
|
788 db.Close(); |
|
789 } |
|
790 }; |
|
791 static TSqlStatement_OutOfBounds_DeclaredColumnType TheSqlStatement_OutOfBounds_DeclaredColumnType; |
|
792 |
|
793 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
794 //Panic when an attempt is made to call RSqlStatement::ColumnName() on an invalid RSqlStatement object. |
|
795 class TSqlStatement_NotCreated_ColumnName : public TFunctor |
|
796 { |
|
797 private: |
|
798 virtual void operator()() |
|
799 { |
|
800 RSqlDatabase db; |
|
801 TEST2(db.Create(KTestDbName), KErrNone); |
|
802 RSqlStatement stmt; |
|
803 TPtrC columnName; |
|
804 (void)stmt.ColumnName(0, columnName);//panic here |
|
805 stmt.Close(); |
|
806 db.Close(); |
|
807 } |
|
808 }; |
|
809 static TSqlStatement_NotCreated_ColumnName TheSqlStatement_NotCreated_ColumnName; |
|
810 |
|
811 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
812 //Panic when an attempt is made to call RSqlStatement::ParameterName() on an invalid RSqlStatement object. |
|
813 class TSqlStatement_NotCreated_ParameterName : public TFunctor |
|
814 { |
|
815 private: |
|
816 virtual void operator()() |
|
817 { |
|
818 RSqlDatabase db; |
|
819 TEST2(db.Create(KTestDbName), KErrNone); |
|
820 RSqlStatement stmt; |
|
821 TPtrC parameterName; |
|
822 (void)stmt.ParameterName(0, parameterName);//panic here |
|
823 stmt.Close(); |
|
824 db.Close(); |
|
825 } |
|
826 }; |
|
827 static TSqlStatement_NotCreated_ParameterName TheSqlStatement_NotCreated_ParameterName; |
|
828 |
|
829 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
830 //Panic when an attempt is made to call RSqlStatement::ParamName() on an invalid RSqlStatement object. |
|
831 class TSqlStatement_NotCreated_ParamName : public TFunctor |
|
832 { |
|
833 private: |
|
834 virtual void operator()() |
|
835 { |
|
836 RSqlDatabase db; |
|
837 TEST2(db.Create(KTestDbName), KErrNone); |
|
838 RSqlStatement stmt; |
|
839 TPtrC paramName; |
|
840 (void)stmt.ParamName(0, paramName);//panic here |
|
841 stmt.Close(); |
|
842 db.Close(); |
|
843 } |
|
844 }; |
|
845 static TSqlStatement_NotCreated_ParamName TheSqlStatement_NotCreated_ParamName; |
|
846 |
|
847 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
848 //Panic when an attempt is made to call RSqlColumnReadStream::ColumnText() with an invalid RSqlStatement object. |
|
849 class TColumnReadStream_ColumnText_Statement : public TFunctor |
|
850 { |
|
851 private: |
|
852 virtual void operator()() |
|
853 { |
|
854 RSqlStatement stmt; |
|
855 RSqlColumnReadStream strm; |
|
856 strm.ColumnText(stmt, 0);//panic here |
|
857 strm.Close(); |
|
858 } |
|
859 }; |
|
860 static TColumnReadStream_ColumnText_Statement TheColumnReadStream_ColumnText_Statement; |
|
861 |
|
862 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
863 //Panic when an attempt is made to call RSqlColumnReadStream::ColumnBinary() with an invalid RSqlStatement object. |
|
864 class TColumnReadStream_ColumnBinary_Statement : public TFunctor |
|
865 { |
|
866 private: |
|
867 virtual void operator()() |
|
868 { |
|
869 RSqlStatement stmt; |
|
870 RSqlColumnReadStream strm; |
|
871 strm.ColumnBinary(stmt, 0);//panic here |
|
872 strm.Close(); |
|
873 } |
|
874 }; |
|
875 static TColumnReadStream_ColumnBinary_Statement TheColumnReadStream_ColumnBinary_Statement; |
|
876 |
|
877 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
878 //Panic when an attempt is made to call RSqlColumnReadStream::ColumnText() with an invalid column index. |
|
879 class TColumnReadStream_ColumnText_Column : public TFunctor |
|
880 { |
|
881 private: |
|
882 virtual void operator()() |
|
883 { |
|
884 RSqlDatabase db; |
|
885 TEST2(db.Create(KTestDbName), KErrNone); |
|
886 TEST(db.Exec(_L8("CREATE TABLE D(A TEXT)")) >= 0); |
|
887 |
|
888 RSqlStatement stmt; |
|
889 TEST2(stmt.Prepare(db, _L8("SELECT * FROM D")), KErrNone); |
|
890 |
|
891 RSqlColumnReadStream strm; |
|
892 strm.ColumnText(stmt, 8);//panic here |
|
893 |
|
894 strm.Close(); |
|
895 stmt.Close(); |
|
896 db.Close(); |
|
897 } |
|
898 }; |
|
899 static TColumnReadStream_ColumnText_Column TheColumnReadStream_ColumnText_Column; |
|
900 |
|
901 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
902 //Panic when an attempt is made to call RSqlColumnReadStream::ColumnBinary() with an invalid column index. |
|
903 class TColumnReadStream_ColumnBinary_Column : public TFunctor |
|
904 { |
|
905 private: |
|
906 virtual void operator()() |
|
907 { |
|
908 RSqlDatabase db; |
|
909 TEST2(db.Create(KTestDbName), KErrNone); |
|
910 TEST(db.Exec(_L8("CREATE TABLE D(A BLOB)")) >= 0); |
|
911 |
|
912 RSqlStatement stmt; |
|
913 TEST2(stmt.Prepare(db, _L8("SELECT * FROM D")), KErrNone); |
|
914 |
|
915 RSqlColumnReadStream strm; |
|
916 strm.ColumnBinary(stmt, 3);//panic here |
|
917 |
|
918 strm.Close(); |
|
919 stmt.Close(); |
|
920 db.Close(); |
|
921 } |
|
922 }; |
|
923 static TColumnReadStream_ColumnBinary_Column TheColumnReadStream_ColumnBinary_Column; |
|
924 |
|
925 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
926 //Panic when an attempt is made to call RSqlColumnReadStream::ColumnText() when the statement object is not at row. |
|
927 class TColumnReadStream_ColumnText_AtRow : public TFunctor |
|
928 { |
|
929 private: |
|
930 virtual void operator()() |
|
931 { |
|
932 RSqlDatabase db; |
|
933 TEST2(db.Create(KTestDbName), KErrNone); |
|
934 TEST(db.Exec(_L8("CREATE TABLE D(A TEXT)")) >= 0); |
|
935 |
|
936 RSqlStatement stmt; |
|
937 TEST2(stmt.Prepare(db, _L8("SELECT * FROM D")), KErrNone); |
|
938 |
|
939 RSqlColumnReadStream strm; |
|
940 strm.ColumnText(stmt, 0);//panic here |
|
941 |
|
942 strm.Close(); |
|
943 stmt.Close(); |
|
944 db.Close(); |
|
945 } |
|
946 }; |
|
947 static TColumnReadStream_ColumnText_AtRow TheColumnReadStream_ColumnText_AtRow; |
|
948 |
|
949 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
950 //Panic when an attempt is made to call RSqlColumnReadStream::ColumnBinary() when the statement object is not at row. |
|
951 class TColumnReadStream_ColumnBinary_AtRow : public TFunctor |
|
952 { |
|
953 private: |
|
954 virtual void operator()() |
|
955 { |
|
956 RSqlDatabase db; |
|
957 TEST2(db.Create(KTestDbName), KErrNone); |
|
958 TEST(db.Exec(_L8("CREATE TABLE D(A BLOB)")) >= 0); |
|
959 |
|
960 RSqlStatement stmt; |
|
961 TEST2(stmt.Prepare(db, _L8("SELECT * FROM D")), KErrNone); |
|
962 |
|
963 RSqlColumnReadStream strm; |
|
964 strm.ColumnBinary(stmt, 0);//panic here |
|
965 |
|
966 strm.Close(); |
|
967 stmt.Close(); |
|
968 db.Close(); |
|
969 } |
|
970 }; |
|
971 static TColumnReadStream_ColumnBinary_AtRow TheColumnReadStream_ColumnBinary_AtRow; |
|
972 |
|
973 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
974 //Panic when an attempt is made to call RSqlParamWriteStream::BindText() with an invalid RSqlStatement object. |
|
975 class TParamWriteStream_BindText_Statement : public TFunctor |
|
976 { |
|
977 private: |
|
978 virtual void operator()() |
|
979 { |
|
980 RSqlStatement stmt; |
|
981 RSqlParamWriteStream strm; |
|
982 strm.BindText(stmt, 0);//panic here |
|
983 strm.Close(); |
|
984 } |
|
985 }; |
|
986 static TParamWriteStream_BindText_Statement TheParamWriteStream_BindText_Statement; |
|
987 |
|
988 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
989 //Panic when an attempt is made to call RSqlParamWriteStream::BindBinary() with an invalid RSqlStatement object. |
|
990 class TParamWriteStream_BindBinary_Statement : public TFunctor |
|
991 { |
|
992 private: |
|
993 virtual void operator()() |
|
994 { |
|
995 RSqlStatement stmt; |
|
996 RSqlParamWriteStream strm; |
|
997 strm.BindBinary(stmt, 0);//panic here |
|
998 strm.Close(); |
|
999 } |
|
1000 }; |
|
1001 static TParamWriteStream_BindBinary_Statement TheParamWriteStream_BindBinary_Statement; |
|
1002 |
|
1003 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1004 //Panic when an attempt is made to call RSqlParamWriteStream::BindText() with an invalid parameter index. |
|
1005 class TParamWriteStream_BindText_Column : public TFunctor |
|
1006 { |
|
1007 private: |
|
1008 virtual void operator()() |
|
1009 { |
|
1010 RSqlDatabase db; |
|
1011 TEST2(db.Create(KTestDbName), KErrNone); |
|
1012 TEST(db.Exec(_L8("CREATE TABLE D(A TEXT)")) >= 0); |
|
1013 |
|
1014 RSqlStatement stmt; |
|
1015 TEST2(stmt.Prepare(db, _L8("SELECT * FROM D WHERE A = :Val")), KErrNone); |
|
1016 |
|
1017 RSqlParamWriteStream strm; |
|
1018 strm.BindText(stmt, 8);//panic here |
|
1019 |
|
1020 strm.Close(); |
|
1021 stmt.Close(); |
|
1022 db.Close(); |
|
1023 } |
|
1024 }; |
|
1025 static TParamWriteStream_BindText_Column TheParamWriteStream_BindText_Column; |
|
1026 |
|
1027 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1028 //Panic when an attempt is made to call RSqlParamWriteStream::BindBinary() with an invalid parameter index. |
|
1029 class TParamWriteStream_BindBinary_Column : public TFunctor |
|
1030 { |
|
1031 private: |
|
1032 virtual void operator()() |
|
1033 { |
|
1034 RSqlDatabase db; |
|
1035 TEST2(db.Create(KTestDbName), KErrNone); |
|
1036 TEST(db.Exec(_L8("CREATE TABLE D(A BLOB)")) >= 0); |
|
1037 |
|
1038 RSqlStatement stmt; |
|
1039 TEST2(stmt.Prepare(db, _L8("SELECT * FROM D WHERE A = :Val")), KErrNone); |
|
1040 |
|
1041 RSqlParamWriteStream strm; |
|
1042 strm.BindBinary(stmt, 3);//panic here |
|
1043 |
|
1044 strm.Close(); |
|
1045 stmt.Close(); |
|
1046 db.Close(); |
|
1047 } |
|
1048 }; |
|
1049 static TParamWriteStream_BindBinary_Column TheParamWriteStream_BindBinary_Column; |
|
1050 |
|
1051 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1052 //Panic when an attempt is made to call RSqlSecurityPolicy::DefaultPolicy() on an invalid object. |
|
1053 class TSqlSecurity_DefaultPolicy : public TFunctor |
|
1054 { |
|
1055 private: |
|
1056 virtual void operator()() |
|
1057 { |
|
1058 RSqlSecurityPolicy securityPolicy; |
|
1059 TSecurityPolicy policy = securityPolicy.DefaultPolicy();//panic here |
|
1060 UNUSED_VAR(policy); |
|
1061 } |
|
1062 }; |
|
1063 static TSqlSecurity_DefaultPolicy TheSqlSecurity_DefaultPolicy; |
|
1064 |
|
1065 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1066 //Panic when an attempt is made to call RSqlSecurityPolicy::SetDbPolicy() with an invalid policy type. |
|
1067 class TSqlSecurity_Set1 : public TFunctor |
|
1068 { |
|
1069 private: |
|
1070 virtual void operator()() |
|
1071 { |
|
1072 TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass); |
|
1073 RSqlSecurityPolicy securityPolicy; |
|
1074 TInt err = securityPolicy.Create(defaultPolicy); |
|
1075 TEST2(err, KErrNone); |
|
1076 RSqlSecurityPolicy::TPolicyType policyType = static_cast <RSqlSecurityPolicy::TPolicyType> (12345); |
|
1077 TSecurityPolicy policy(TSecurityPolicy::EAlwaysFail); |
|
1078 securityPolicy.SetDbPolicy(policyType, policy);//panic here |
|
1079 securityPolicy.Close(); |
|
1080 } |
|
1081 }; |
|
1082 static TSqlSecurity_Set1 TheSqlSecurity_Set1; |
|
1083 |
|
1084 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1085 //Panic when an attempt is made to call RSqlSecurityPolicy::SetPolicy() with an invalid database object type. |
|
1086 class TSqlSecurity_Set2 : public TFunctor |
|
1087 { |
|
1088 private: |
|
1089 virtual void operator()() |
|
1090 { |
|
1091 TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass); |
|
1092 RSqlSecurityPolicy securityPolicy; |
|
1093 TInt err = securityPolicy.Create(defaultPolicy); |
|
1094 TEST2(err, KErrNone); |
|
1095 RSqlSecurityPolicy::TObjectType objectType = static_cast <RSqlSecurityPolicy::TObjectType> (-113); |
|
1096 TSecurityPolicy policy(TSecurityPolicy::EAlwaysFail); |
|
1097 securityPolicy.SetPolicy(objectType, _L("ATbl"), RSqlSecurityPolicy::EWritePolicy, policy);//panic here |
|
1098 securityPolicy.Close(); |
|
1099 } |
|
1100 }; |
|
1101 static TSqlSecurity_Set2 TheSqlSecurity_Set2; |
|
1102 |
|
1103 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1104 //Panic when an attempt is made to call RSqlSecurityPolicy::SetPolicy() with an invalid database object name. |
|
1105 class TSqlSecurity_Set3 : public TFunctor |
|
1106 { |
|
1107 private: |
|
1108 virtual void operator()() |
|
1109 { |
|
1110 TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass); |
|
1111 RSqlSecurityPolicy securityPolicy; |
|
1112 TInt err = securityPolicy.Create(defaultPolicy); |
|
1113 TEST2(err, KErrNone); |
|
1114 TSecurityPolicy policy(TSecurityPolicy::EAlwaysFail); |
|
1115 securityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, KNullDesC, RSqlSecurityPolicy::EReadPolicy, policy);//panic here |
|
1116 securityPolicy.Close(); |
|
1117 } |
|
1118 }; |
|
1119 static TSqlSecurity_Set3 TheSqlSecurity_Set3; |
|
1120 |
|
1121 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1122 //Panic when an attempt is made to call RSqlSecurityPolicy::DbPolicy() with an invalid policy type. |
|
1123 class TSqlSecurity_Get1 : public TFunctor |
|
1124 { |
|
1125 private: |
|
1126 virtual void operator()() |
|
1127 { |
|
1128 TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass); |
|
1129 RSqlSecurityPolicy securityPolicy; |
|
1130 TInt err = securityPolicy.Create(defaultPolicy); |
|
1131 TEST2(err, KErrNone); |
|
1132 RSqlSecurityPolicy::TPolicyType policyType = static_cast <RSqlSecurityPolicy::TPolicyType> (12345); |
|
1133 securityPolicy.DbPolicy(policyType);//panic here |
|
1134 securityPolicy.Close(); |
|
1135 } |
|
1136 }; |
|
1137 static TSqlSecurity_Get1 TheSqlSecurity_Get1; |
|
1138 |
|
1139 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1140 //Panic when an attempt is made to call RSqlSecurityPolicy::Policy() with an invalid database object type. |
|
1141 class TSqlSecurity_Get2 : public TFunctor |
|
1142 { |
|
1143 private: |
|
1144 virtual void operator()() |
|
1145 { |
|
1146 TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass); |
|
1147 RSqlSecurityPolicy securityPolicy; |
|
1148 TInt err = securityPolicy.Create(defaultPolicy); |
|
1149 TEST2(err, KErrNone); |
|
1150 RSqlSecurityPolicy::TObjectType objectType = static_cast <RSqlSecurityPolicy::TObjectType> (-113); |
|
1151 securityPolicy.Policy(objectType, _L("BTbl"), RSqlSecurityPolicy::EReadPolicy);//panic here |
|
1152 securityPolicy.Close(); |
|
1153 } |
|
1154 }; |
|
1155 static TSqlSecurity_Get2 TheSqlSecurity_Get2; |
|
1156 |
|
1157 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1158 //Panic when an attempt is made to call RSqlSecurityPolicy::Policy() with an invalid database object name. |
|
1159 class TSqlSecurity_Get3 : public TFunctor |
|
1160 { |
|
1161 private: |
|
1162 virtual void operator()() |
|
1163 { |
|
1164 TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass); |
|
1165 RSqlSecurityPolicy securityPolicy; |
|
1166 TInt err = securityPolicy.Create(defaultPolicy); |
|
1167 TEST2(err, KErrNone); |
|
1168 securityPolicy.Policy(RSqlSecurityPolicy::ETable, KNullDesC, RSqlSecurityPolicy::EWritePolicy);//panic here |
|
1169 securityPolicy.Close(); |
|
1170 } |
|
1171 }; |
|
1172 static TSqlSecurity_Get3 TheSqlSecurity_Get3; |
|
1173 |
|
1174 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1175 /* |
|
1176 //Panic when an attempt is made to call RSqlSecurityPolicy::Create() on an already created object. |
|
1177 class TSqlSecurity_CreateTwice : public TFunctor |
|
1178 { |
|
1179 private: |
|
1180 virtual void operator()() |
|
1181 { |
|
1182 TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysPass); |
|
1183 RSqlSecurityPolicy securityPolicy; |
|
1184 TInt err = securityPolicy.Create(defaultPolicy); |
|
1185 TEST2(err, KErrNone); |
|
1186 securityPolicy.Create(defaultPolicy);//panic here |
|
1187 securityPolicy.Close(); |
|
1188 } |
|
1189 }; |
|
1190 static TSqlSecurity_CreateTwice TheSqlSecurity_CreateTwice; |
|
1191 */ |
|
1192 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1193 //Panic when an attempt is made to call RSqlSecurityPolicy::ExternalizeL() on an invalid object. |
|
1194 class TSqlSecurity_Externalize : public TFunctor |
|
1195 { |
|
1196 private: |
|
1197 virtual void operator()() |
|
1198 { |
|
1199 RSqlSecurityPolicy securityPolicy; |
|
1200 RWriteStream stream; |
|
1201 TRAPD(err, securityPolicy.ExternalizeL(stream));//panic here |
|
1202 IGNORE_ERR(err); |
|
1203 } |
|
1204 }; |
|
1205 static TSqlSecurity_Externalize TheSqlSecurity_Externalize; |
|
1206 |
|
1207 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1208 //Panic when an attempt is made to call TSqlScalarFullSelectQuery method and the database is not set. |
|
1209 class TSqlScalarFullSelectQuery_InvalidDatabase : public TFunctor |
|
1210 { |
|
1211 private: |
|
1212 virtual void operator()() |
|
1213 { |
|
1214 TSqlScalarFullSelectQuery query; |
|
1215 TRAP_IGNORE((void)query.SelectIntL(_L("SELECT Id FROM A WHERE Name = 'AAA'"))); |
|
1216 } |
|
1217 }; |
|
1218 static TSqlScalarFullSelectQuery_InvalidDatabase TheSqlScalarFullSelectQuery_InvalidDatabase; |
|
1219 |
|
1220 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1221 //Panic when an attempt is made to call RSqlBlobReadStream::OpenL() with an invalid RSqlDatabase object. |
|
1222 class TBlobReadStream_Open_Database1 : public TFunctor |
|
1223 { |
|
1224 private: |
|
1225 virtual void operator()() |
|
1226 { |
|
1227 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1228 |
|
1229 RSqlDatabase db; |
|
1230 RSqlBlobReadStream strm; |
|
1231 TRAP_IGNORE(strm.OpenL(db, _L("Tbl"),_L("Col"), 1));//panic here |
|
1232 strm.Close(); |
|
1233 |
|
1234 delete tc; |
|
1235 } |
|
1236 }; |
|
1237 static TBlobReadStream_Open_Database1 TheBlobReadStream_Open_Database1; |
|
1238 |
|
1239 class TBlobReadStream_Open_Database2 : public TFunctor |
|
1240 { |
|
1241 private: |
|
1242 virtual void operator()() |
|
1243 { |
|
1244 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1245 |
|
1246 RSqlDatabase db; |
|
1247 RSqlBlobReadStream strm; |
|
1248 TRAP_IGNORE(strm.OpenL(db, _L("Tbl"),_L("Col"), 1, _L("Db")));//panic here |
|
1249 strm.Close(); |
|
1250 |
|
1251 delete tc; |
|
1252 } |
|
1253 }; |
|
1254 static TBlobReadStream_Open_Database2 TheBlobReadStream_Open_Database2; |
|
1255 |
|
1256 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1257 //Panic when an attempt is made to call RSqlBlobReadStream::SizeL() on a unitialized RSqlBlobReadStream object. |
|
1258 class TBlobReadStream_Size_Stream : public TFunctor |
|
1259 { |
|
1260 private: |
|
1261 virtual void operator()() |
|
1262 { |
|
1263 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1264 |
|
1265 RSqlBlobReadStream strm; |
|
1266 TRAP_IGNORE(strm.SizeL());//panic here |
|
1267 strm.Close(); |
|
1268 |
|
1269 delete tc; |
|
1270 } |
|
1271 }; |
|
1272 TBlobReadStream_Size_Stream TheBlobReadStream_Size_Stream; |
|
1273 |
|
1274 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1275 //Panic when an attempt is made to call RSqlBlobWriteStream::OpenL() with an invalid RSqlDatabase object. |
|
1276 class TBlobWriteStream_Open_Database1 : public TFunctor |
|
1277 { |
|
1278 private: |
|
1279 virtual void operator()() |
|
1280 { |
|
1281 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1282 |
|
1283 RSqlDatabase db; |
|
1284 RSqlBlobWriteStream strm; |
|
1285 TRAP_IGNORE(strm.OpenL(db, _L("Tbl"),_L("Col"), 1));//panic here |
|
1286 strm.Close(); |
|
1287 |
|
1288 delete tc; |
|
1289 } |
|
1290 }; |
|
1291 static TBlobWriteStream_Open_Database1 TheBlobWriteStream_Open_Database1; |
|
1292 |
|
1293 class TBlobWriteStream_Open_Database2 : public TFunctor |
|
1294 { |
|
1295 private: |
|
1296 virtual void operator()() |
|
1297 { |
|
1298 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1299 |
|
1300 RSqlDatabase db; |
|
1301 RSqlBlobWriteStream strm; |
|
1302 TRAP_IGNORE(strm.OpenL(db, _L("Tbl"),_L("Col"), 1, _L("Db")));//panic here |
|
1303 strm.Close(); |
|
1304 |
|
1305 delete tc; |
|
1306 } |
|
1307 }; |
|
1308 static TBlobWriteStream_Open_Database2 TheBlobWriteStream_Open_Database2; |
|
1309 |
|
1310 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1311 //Panic when an attempt is made to call RSqlBlobWriteStream::SizeL() on a unitialized RSqlBlobWriteStream object. |
|
1312 class TBlobWriteStream_Size_Stream : public TFunctor |
|
1313 { |
|
1314 private: |
|
1315 virtual void operator()() |
|
1316 { |
|
1317 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1318 |
|
1319 RSqlBlobWriteStream strm; |
|
1320 TRAP_IGNORE(strm.SizeL());//panic here |
|
1321 strm.Close(); |
|
1322 |
|
1323 delete tc; |
|
1324 } |
|
1325 }; |
|
1326 TBlobWriteStream_Size_Stream TheBlobWriteStream_Size_Stream; |
|
1327 |
|
1328 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1329 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1330 |
|
1331 /** |
|
1332 @SYMTestCaseID SYSLIB-SQL-CT-1619 |
|
1333 @SYMTestCaseDesc RSqlDatabase panic tests |
|
1334 Run a second thread. The second thread executes given RSqlDatabase method calling |
|
1335 it with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1336 The main thread captures and checks the panic code. |
|
1337 @SYMTestPriority High |
|
1338 @SYMTestActions RSqlDatabase panic tests |
|
1339 @SYMTestExpectedResults Test must not fail |
|
1340 @SYMREQ REQ5792 |
|
1341 REQ5793 |
|
1342 REQ10405 |
|
1343 REQ10407 |
|
1344 */ |
|
1345 void DatabaseTests() |
|
1346 { |
|
1347 TheTest.Printf(_L("'RSqlDatabase object not created - Exec 8' panic\r\n")); |
|
1348 PanicTest(TheSqlDatabase_NotCreated_Exec8, EExitPanic, KCategory, 2); |
|
1349 |
|
1350 TheTest.Printf(_L("'RSqlDatabase object not created - Exec' panic\r\n")); |
|
1351 PanicTest(TheSqlDatabase_NotCreated_Exec, EExitPanic, KCategory, 2); |
|
1352 |
|
1353 TheTest.Printf(_L("'RSqlDatabase object not created - GetSecuritySettings' panic\r\n")); |
|
1354 PanicTest(TheSqlDatabase_NotCreated_SecuritySettings, EExitPanic, KCategory, 2); |
|
1355 |
|
1356 TheTest.Printf(_L("'RSqlDatabase object not created - Attach' panic\r\n")); |
|
1357 PanicTest(TheSqlDatabase_NotCreated_Attach, EExitPanic, KCategory, 2); |
|
1358 |
|
1359 TheTest.Printf(_L("'RSqlDatabase object not created - Detach' panic\r\n")); |
|
1360 PanicTest(TheSqlDatabase_NotCreated_Detach, EExitPanic, KCategory, 2); |
|
1361 |
|
1362 TheTest.Printf(_L("'RSqlDatabase object not created - SetIsolationLevel' panic\r\n")); |
|
1363 PanicTest(TheSqlDatabase_NotCreated_SetIsolationLevel, EExitPanic, KCategory, 2); |
|
1364 |
|
1365 TheTest.Printf(_L("'RSqlDatabase object not created - LastErrorMessage' panic\r\n")); |
|
1366 PanicTest(TheSqlDatabase_NotCreated_LastErrorMessage, EExitPanic, KCategory, 2); |
|
1367 |
|
1368 TheTest.Printf(_L("'RSqlDatabase object not created - LastInsertedRowId' panic\r\n")); |
|
1369 PanicTest(TheSqlDatabase_NotCreated_LastInsertedRowId, EExitPanic, KCategory, 2); |
|
1370 |
|
1371 TheTest.Printf(_L("'RSqlDatabase object not created - Size' panic\r\n")); |
|
1372 PanicTest(TheSqlDatabase_NotCreated_Size, EExitPanic, KCategory, 2); |
|
1373 |
|
1374 TheTest.Printf(_L("'RSqlDatabase object not created - Size(TSize&)' panic\r\n")); |
|
1375 PanicTest(TheSqlDatabase_NotCreated_Size2, EExitPanic, KCategory, 2); |
|
1376 |
|
1377 TheTest.Printf(_L("'RSqlDatabase object not created - InTransaction' panic\r\n")); |
|
1378 PanicTest(TheSqlDatabase_NotCreated_InTransaction, EExitPanic, KCategory, 2); |
|
1379 |
|
1380 TheTest.Printf(_L("'RSqlDatabase object not created - Compact' panic\r\n")); |
|
1381 PanicTest(TheSqlDatabase_NotCreated_Compact, EExitPanic, KCategory, 2); |
|
1382 |
|
1383 TheTest.Printf(_L("'RSqlDatabase object not created - async Compact' panic\r\n")); |
|
1384 PanicTest(TheSqlDatabase_NotCreated_Compact2, EExitPanic, KCategory, 2); |
|
1385 } |
|
1386 |
|
1387 /** |
|
1388 @SYMTestCaseID SYSLIB-SQL-CT-1620 |
|
1389 @SYMTestCaseDesc RSqlStatement panic tests |
|
1390 Run a second thread. The second thread executes given RSqlStatement method calling |
|
1391 it with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1392 The main thread captures and checks the panic code. |
|
1393 @SYMTestPriority High |
|
1394 @SYMTestActions RSqlStatement panic tests |
|
1395 @SYMTestExpectedResults Test must not fail |
|
1396 @SYMREQ REQ5792 |
|
1397 REQ5793 |
|
1398 */ |
|
1399 void StatementTests() |
|
1400 { |
|
1401 TheTest.Printf(_L("'RSqlStatement object not created - Reset' panic\r\n")); |
|
1402 PanicTest(TheSqlStatement_NotCreated_Reset, EExitPanic, KCategory, 2); |
|
1403 |
|
1404 TheTest.Printf(_L("'RSqlStatement object not created - Exec' panic\r\n")); |
|
1405 PanicTest(TheSqlStatement_NotCreated_Exec, EExitPanic, KCategory, 2); |
|
1406 |
|
1407 TheTest.Printf(_L("'RSqlStatement object not created - Next' panic\r\n")); |
|
1408 PanicTest(TheSqlStatement_NotCreated_Next, EExitPanic, KCategory, 2); |
|
1409 |
|
1410 TheTest.Printf(_L("'RSqlStatement object not created - ParameterIndex' panic\r\n")); |
|
1411 PanicTest(TheSqlStatement_NotCreated_ParameterIndex, EExitPanic, KCategory, 2); |
|
1412 |
|
1413 TheTest.Printf(_L("'RSqlStatement object not created - ColumnIndex' panic\r\n")); |
|
1414 PanicTest(TheSqlStatement_NotCreated_ColumnIndex, EExitPanic, KCategory, 2); |
|
1415 |
|
1416 TheTest.Printf(_L("'RSqlStatement object not created - ColumnType' panic\r\n")); |
|
1417 PanicTest(TheSqlStatement_NotCreated_ColumnType, EExitPanic, KCategory, 2); |
|
1418 |
|
1419 TheTest.Printf(_L("'RSqlStatement object not created - ColumnSize' panic\r\n")); |
|
1420 PanicTest(TheSqlStatement_NotCreated_ColumnSize, EExitPanic, KCategory, 2); |
|
1421 |
|
1422 TheTest.Printf(_L("'RSqlStatement object not created - BindNull' panic\r\n")); |
|
1423 PanicTest(TheSqlStatement_NotCreated_BindNull, EExitPanic, KCategory, 2); |
|
1424 |
|
1425 TheTest.Printf(_L("'RSqlStatement object not created - BindInt' panic\r\n")); |
|
1426 PanicTest(TheSqlStatement_NotCreated_BindInt, EExitPanic, KCategory, 2); |
|
1427 |
|
1428 TheTest.Printf(_L("'RSqlStatement object not created - BindInt64' panic\r\n")); |
|
1429 PanicTest(TheSqlStatement_NotCreated_BindInt64, EExitPanic, KCategory, 2); |
|
1430 |
|
1431 TheTest.Printf(_L("'RSqlStatement object not created - BindReal' panic\r\n")); |
|
1432 PanicTest(TheSqlStatement_NotCreated_BindReal, EExitPanic, KCategory, 2); |
|
1433 |
|
1434 TheTest.Printf(_L("'RSqlStatement object not created - BindText' panic\r\n")); |
|
1435 PanicTest(TheSqlStatement_NotCreated_BindText, EExitPanic, KCategory, 2); |
|
1436 |
|
1437 TheTest.Printf(_L("'RSqlStatement object not created - BindBinary' panic\r\n")); |
|
1438 PanicTest(TheSqlStatement_NotCreated_BindBinary, EExitPanic, KCategory, 2); |
|
1439 |
|
1440 TheTest.Printf(_L("'RSqlStatement object not created - BindZeroBlob' panic\r\n")); |
|
1441 PanicTest(TheSqlStatement_NotCreated_BindZeroBlob, EExitPanic, KCategory, 2); |
|
1442 |
|
1443 TheTest.Printf(_L("'RSqlStatement::BindZeroBlob() - invalid parameter index' panic\r\n")); |
|
1444 PanicTest(TheSqlStatement_OutOfBounds_BindZeroBlob, EExitPanic, KCategory, 5); |
|
1445 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1446 |
|
1447 TheTest.Printf(_L("'RSqlStatement object not created - ColumnInt' panic\r\n")); |
|
1448 PanicTest(TheSqlStatement_NotCreated_ColumnInt, EExitPanic, KCategory, 2); |
|
1449 |
|
1450 TheTest.Printf(_L("'RSqlStatement object not created - IsNull' panic\r\n")); |
|
1451 PanicTest(TheSqlStatement_NotCreated_ColumnInt, EExitPanic, KCategory, 2); |
|
1452 |
|
1453 TheTest.Printf(_L("'RSqlStatement object not created - ColumnInt64' panic\r\n")); |
|
1454 PanicTest(TheSqlStatement_NotCreated_ColumnInt64, EExitPanic, KCategory, 2); |
|
1455 |
|
1456 TheTest.Printf(_L("'RSqlStatement object not created - ColumnReal' panic\r\n")); |
|
1457 PanicTest(TheSqlStatement_NotCreated_ColumnReal, EExitPanic, KCategory, 2); |
|
1458 |
|
1459 TheTest.Printf(_L("'RSqlStatement object not created - ColumnText' panic\r\n")); |
|
1460 PanicTest(TheSqlStatement_NotCreated_ColumnText, EExitPanic, KCategory, 2); |
|
1461 |
|
1462 TheTest.Printf(_L("'RSqlStatement object not created - ColumnText2' panic\r\n")); |
|
1463 PanicTest(TheSqlStatement_NotCreated_ColumnText2, EExitPanic, KCategory, 2); |
|
1464 |
|
1465 TheTest.Printf(_L("'RSqlStatement object not created - ColumnBinary' panic\r\n")); |
|
1466 PanicTest(TheSqlStatement_NotCreated_ColumnBinary, EExitPanic, KCategory, 2); |
|
1467 |
|
1468 TheTest.Printf(_L("'RSqlStatement object not created - ColumnBinary2' panic\r\n")); |
|
1469 PanicTest(TheSqlStatement_NotCreated_ColumnBinary2, EExitPanic, KCategory, 2); |
|
1470 |
|
1471 TheTest.Printf(_L("'RSqlStatement - database not created - Prepare' panic\r\n")); |
|
1472 PanicTest(TheSqlStatement_DbNotCreated_Prepare, EExitPanic, KCategory, 2); |
|
1473 |
|
1474 TheTest.Printf(_L("'RSqlStatement - database not created - Prepare 8' panic\r\n")); |
|
1475 PanicTest(TheSqlStatement_DbNotCreated_Prepare8, EExitPanic, KCategory, 2); |
|
1476 |
|
1477 TheTest.Printf(_L("'RSqlStatement - ColumnType - Column index out of bounds' panic\r\n")); |
|
1478 PanicTest(TheSqlStatement_OutOfBounds_ColumnType, EExitPanic, KCategory, 5); |
|
1479 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1480 |
|
1481 TheTest.Printf(_L("'RSqlStatement - ColumnSize - Column index out of bounds' panic\r\n")); |
|
1482 PanicTest(TheSqlStatement_OutOfBounds_ColumnSize, EExitPanic, KCategory, 5); |
|
1483 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1484 |
|
1485 TheTest.Printf(_L("'RSqlStatement - Bind - Parameter index out of bounds' panic\r\n")); |
|
1486 PanicTest(TheSqlStatement_OutOfBounds_Bind, EExitPanic, KCategory, 5); |
|
1487 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1488 |
|
1489 TheTest.Printf(_L("'RSqlStatement - Column value - Parameter index out of bounds' panic\r\n")); |
|
1490 PanicTest(TheSqlStatement_OutOfBounds_ColumnValue, EExitPanic, KCategory, 5); |
|
1491 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1492 |
|
1493 TheTest.Printf(_L("'RSqlStatement object not created - ColumnCount' panic\r\n")); |
|
1494 PanicTest(TheSqlStatement_NotCreated_ColumnCount, EExitPanic, KCategory, 2); |
|
1495 |
|
1496 TheTest.Printf(_L("'RSqlStatement object not created - DeclaredColumnType' panic\r\n")); |
|
1497 PanicTest(TheSqlStatement_NotCreated_DeclaredColumnType, EExitPanic, KCategory, 2); |
|
1498 |
|
1499 TheTest.Printf(_L("'RSqlStatement - DeclaredColumnType - Column index out of bounds' panic\r\n")); |
|
1500 PanicTest(TheSqlStatement_OutOfBounds_DeclaredColumnType, EExitPanic, KCategory, 5); |
|
1501 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1502 |
|
1503 TheTest.Printf(_L("'RSqlStatement - ColumnName' panic\r\n")); |
|
1504 PanicTest(TheSqlStatement_NotCreated_ColumnName, EExitPanic, KCategory, 2); |
|
1505 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1506 |
|
1507 TheTest.Printf(_L("'RSqlStatement - ParameterName' panic\r\n")); |
|
1508 PanicTest(TheSqlStatement_NotCreated_ParameterName, EExitPanic, KCategory, 2); |
|
1509 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1510 |
|
1511 TheTest.Printf(_L("'RSqlStatement - ParamName' panic\r\n")); |
|
1512 PanicTest(TheSqlStatement_NotCreated_ParamName, EExitPanic, KCategory, 2); |
|
1513 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1514 } |
|
1515 |
|
1516 /** |
|
1517 @SYMTestCaseID SYSLIB-SQL-CT-1625 |
|
1518 @SYMTestCaseDesc RSqlColumnReadStream panic tests |
|
1519 Run a second thread. The second thread executes given RSqlColumnReadStream method calling |
|
1520 it with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1521 The main thread captures and checks the panic code. |
|
1522 @SYMTestPriority High |
|
1523 @SYMTestActions RSqlColumnReadStream panic tests |
|
1524 @SYMTestExpectedResults Test must not fail |
|
1525 @SYMREQ REQ5792 |
|
1526 REQ5793 |
|
1527 */ |
|
1528 void ColumnStreamTests() |
|
1529 { |
|
1530 TheTest.Printf(_L("'RSqlColumnReadStream - ColumnText - invalid statement' panic\r\n")); |
|
1531 PanicTest(TheColumnReadStream_ColumnText_Statement, EExitPanic, KCategory, 2); |
|
1532 |
|
1533 TheTest.Printf(_L("'RSqlColumnReadStream - ColumnBinary - invalid statement' panic\r\n")); |
|
1534 PanicTest(TheColumnReadStream_ColumnBinary_Statement, EExitPanic, KCategory, 2); |
|
1535 |
|
1536 TheTest.Printf(_L("'RSqlColumnReadStream - ColumnText - invalid column index' panic\r\n")); |
|
1537 PanicTest(TheColumnReadStream_ColumnText_Column, EExitPanic, KCategory, 5); |
|
1538 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1539 |
|
1540 TheTest.Printf(_L("'RSqlColumnReadStream - ColumnBinary - invalid column index' panic\r\n")); |
|
1541 PanicTest(TheColumnReadStream_ColumnBinary_Column, EExitPanic, KCategory, 5); |
|
1542 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1543 |
|
1544 TheTest.Printf(_L("'RSqlColumnReadStream - ColumnText - not at row' panic\r\n")); |
|
1545 PanicTest(TheColumnReadStream_ColumnText_AtRow, EExitPanic, KCategory, 11); |
|
1546 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1547 |
|
1548 TheTest.Printf(_L("'RSqlColumnReadStream - ColumnBinary - not at row' panic\r\n")); |
|
1549 PanicTest(TheColumnReadStream_ColumnBinary_AtRow, EExitPanic, KCategory, 11); |
|
1550 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1551 } |
|
1552 |
|
1553 /** |
|
1554 @SYMTestCaseID SYSLIB-SQL-CT-1626 |
|
1555 @SYMTestCaseDesc RSqlParamWriteStream panic tests |
|
1556 Run a second thread. The second thread executes given RSqlParamWriteStream method calling |
|
1557 it with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1558 The main thread captures and checks the panic code. |
|
1559 @SYMTestPriority High |
|
1560 @SYMTestActions RSqlParamWriteStream panic tests |
|
1561 @SYMTestExpectedResults Test must not fail |
|
1562 @SYMREQ REQ5792 |
|
1563 REQ5793 |
|
1564 */ |
|
1565 void ParameterStreamTests() |
|
1566 { |
|
1567 TheTest.Printf(_L("'RSqlParamWriteStream - BindText - invalid statement' panic\r\n")); |
|
1568 PanicTest(TheParamWriteStream_BindText_Statement, EExitPanic, KCategory, 2); |
|
1569 |
|
1570 TheTest.Printf(_L("'RSqlParamWriteStream - BindBinary - invalid statement' panic\r\n")); |
|
1571 PanicTest(TheParamWriteStream_BindBinary_Statement, EExitPanic, KCategory, 2); |
|
1572 |
|
1573 TheTest.Printf(_L("'RSqlParamWriteStream - BindText - invalid parameter index' panic\r\n")); |
|
1574 PanicTest(TheParamWriteStream_BindText_Column, EExitPanic, KCategory, 5); |
|
1575 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1576 |
|
1577 TheTest.Printf(_L("'RSqlParamWriteStream - BindBinary - invalid parameter index' panic\r\n")); |
|
1578 PanicTest(TheParamWriteStream_BindBinary_Column, EExitPanic, KCategory, 5); |
|
1579 TEST2(RSqlDatabase::Delete(KTestDbName), KErrNone); |
|
1580 } |
|
1581 |
|
1582 /** |
|
1583 @SYMTestCaseID SYSLIB-SQL-CT-1638 |
|
1584 @SYMTestCaseDesc RSqlSecurityPolicy panic tests |
|
1585 Run a second thread. The second thread executes given RSqlSecurityPolicy method calling |
|
1586 it with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1587 The main thread captures and checks the panic code. |
|
1588 @SYMTestPriority High |
|
1589 @SYMTestActions RSqlSecurityPolicy panic tests |
|
1590 @SYMTestExpectedResults Test must not fail |
|
1591 @SYMREQ REQ5792 |
|
1592 REQ5793 |
|
1593 */ |
|
1594 void SecuritySettingsTests() |
|
1595 { |
|
1596 TheTest.Printf(_L("'RSqlSecurityPolicy::SetDbPolicy - invalid policy type' panic\r\n")); |
|
1597 PanicTest(TheSqlSecurity_Set1, EExitPanic, KCategory, 4); |
|
1598 |
|
1599 TheTest.Printf(_L("'RSqlSecurityPolicy::SetPolicy - invalid database object type' panic\r\n")); |
|
1600 PanicTest(TheSqlSecurity_Set2, EExitPanic, KCategory, 4); |
|
1601 |
|
1602 TheTest.Printf(_L("'RSqlSecurityPolicy::SetPolicy - invalid database object name' panic\r\n")); |
|
1603 PanicTest(TheSqlSecurity_Set3, EExitPanic, KCategory, 4); |
|
1604 |
|
1605 TheTest.Printf(_L("'RSqlSecurityPolicy::DbPolicy - invalid policy type' panic\r\n")); |
|
1606 PanicTest(TheSqlSecurity_Get1, EExitPanic, KCategory, 4); |
|
1607 |
|
1608 TheTest.Printf(_L("'RSqlSecurityPolicy::Policy - invalid database object type' panic\r\n")); |
|
1609 PanicTest(TheSqlSecurity_Get2, EExitPanic, KCategory, 4); |
|
1610 |
|
1611 TheTest.Printf(_L("'RSqlSecurityPolicy::Policy - invalid database object name' panic\r\n")); |
|
1612 PanicTest(TheSqlSecurity_Get3, EExitPanic, KCategory, 4); |
|
1613 |
|
1614 TheTest.Printf(_L("'RSqlSecurityPolicy::DefaultPolicy - invalid object' panic\r\n")); |
|
1615 PanicTest(TheSqlSecurity_DefaultPolicy, EExitPanic, KCategory, 2); |
|
1616 |
|
1617 TheTest.Printf(_L("'RSqlSecurityPolicy::Externalize - panic\r\n")); |
|
1618 PanicTest(TheSqlSecurity_Externalize, EExitPanic, KCategory, 2); |
|
1619 } |
|
1620 |
|
1621 /** |
|
1622 @SYMTestCaseID SYSLIB-SQL-CT-1812 |
|
1623 @SYMTestCaseDesc TSqlScalarFullSelectQuery panic tests |
|
1624 Run a second thread. The second thread executes given TSqlScalarFullSelectQuery method calling |
|
1625 it with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1626 The main thread captures and checks the panic code. |
|
1627 @SYMTestPriority High |
|
1628 @SYMTestActions TSqlScalarFullSelectQuery panic tests |
|
1629 @SYMTestExpectedResults Test must not fail |
|
1630 @SYMREQ REQ5792 |
|
1631 REQ5793 |
|
1632 */ |
|
1633 void ScalarFullSelectTests() |
|
1634 { |
|
1635 TheTest.Printf(_L("'TheSqlScalarFullSelectQuery, invalid database' - panic\r\n")); |
|
1636 PanicTest(TheSqlScalarFullSelectQuery_InvalidDatabase, EExitPanic, KCategory, 2); |
|
1637 } |
|
1638 |
|
1639 /** |
|
1640 @SYMTestCaseID SYSLIB-SQL-UT-4092 |
|
1641 @SYMTestCaseDesc RSqlBlobReadStream panic tests |
|
1642 Run a second thread. The second thread executes a given RSqlBlobReadStream method calling |
|
1643 the method with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1644 The main thread captures and checks the panic code. |
|
1645 @SYMTestPriority High |
|
1646 @SYMTestActions RSqlBlobReadStream panic tests |
|
1647 @SYMTestExpectedResults Test must not fail |
|
1648 @SYMREQ REQ5792 |
|
1649 REQ5793 |
|
1650 REQ10410 |
|
1651 REQ10411 |
|
1652 */ |
|
1653 void BlobReadStreamTests() |
|
1654 { |
|
1655 TheTest.Printf(_L("'RSqlBlobReadStream::OpenL(), invalid database' - panic test 1\r\n")); |
|
1656 PanicTest(TheBlobReadStream_Open_Database1, EExitPanic, KCategory, 2); |
|
1657 |
|
1658 TheTest.Printf(_L("'RSqlBlobReadStream::OpenL(), invalid database' - panic test 2\r\n")); |
|
1659 PanicTest(TheBlobReadStream_Open_Database2, EExitPanic, KCategory, 2); |
|
1660 |
|
1661 TheTest.Printf(_L("'RSqlBlobReadStream::SizeL(), invalid stream' - panic test\r\n")); |
|
1662 PanicTest(TheBlobReadStream_Size_Stream, EExitPanic, KCategory, 2); |
|
1663 } |
|
1664 |
|
1665 /** |
|
1666 @SYMTestCaseID SYSLIB-SQL-UT-4093 |
|
1667 @SYMTestCaseDesc RSqlBlobWriteStream panic tests |
|
1668 Run a second thread. The second thread executes a given RSqlBlobWriteStream method calling |
|
1669 the method with wrong arguments, or in a bad context,...The method panics the second thread. |
|
1670 The main thread captures and checks the panic code. |
|
1671 @SYMTestPriority High |
|
1672 @SYMTestActions RSqlBlobWriteStream panic tests |
|
1673 @SYMTestExpectedResults Test must not fail |
|
1674 @SYMREQ REQ5792 |
|
1675 REQ5793 |
|
1676 REQ10418 |
|
1677 */ |
|
1678 void BlobWriteStreamTests() |
|
1679 { |
|
1680 TheTest.Printf(_L("'RSqlBlobWriteStream::OpenL(), invalid database' - panic test 1\r\n")); |
|
1681 PanicTest(TheBlobWriteStream_Open_Database1, EExitPanic, KCategory, 2); |
|
1682 |
|
1683 TheTest.Printf(_L("'RSqlBlobWriteStream::OpenL(), invalid database' - panic test 2\r\n")); |
|
1684 PanicTest(TheBlobWriteStream_Open_Database2, EExitPanic, KCategory, 2); |
|
1685 |
|
1686 TheTest.Printf(_L("'RSqlBlobWriteStream::SizeL(), invalid stream' - panic test\r\n")); |
|
1687 PanicTest(TheBlobWriteStream_Size_Stream, EExitPanic, KCategory, 2); |
|
1688 } |
|
1689 |
|
1690 void DoTests() |
|
1691 { |
|
1692 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1619 RSqlDatabase - panic tests")); |
|
1693 DatabaseTests(); |
|
1694 |
|
1695 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1620 RSqlStatement - panic tests")); |
|
1696 StatementTests(); |
|
1697 |
|
1698 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1625 RSqlColumnReadStream - panic tests")); |
|
1699 ColumnStreamTests(); |
|
1700 |
|
1701 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1626 RSqlParamWriteStream - panic tests")); |
|
1702 ParameterStreamTests(); |
|
1703 |
|
1704 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1638 RSqlSecurityPolicy - panic tests")); |
|
1705 SecuritySettingsTests(); |
|
1706 |
|
1707 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1812 TheSqlScalarFullSelectQuery - panic tests")); |
|
1708 ScalarFullSelectTests(); |
|
1709 |
|
1710 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4092 RSqlBlobReadStream - panic tests")); |
|
1711 BlobReadStreamTests(); |
|
1712 |
|
1713 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4093 RSqlBlobWriteStream - panic tests")); |
|
1714 BlobWriteStreamTests(); |
|
1715 } |
|
1716 |
|
1717 TInt E32Main() |
|
1718 { |
|
1719 TheTest.Title(); |
|
1720 |
|
1721 CTrapCleanup* tc = CTrapCleanup::New(); |
|
1722 |
|
1723 __UHEAP_MARK; |
|
1724 |
|
1725 CreateTestDir(); |
|
1726 DeleteTestFiles(); |
|
1727 DoTests(); |
|
1728 DeleteTestFiles(); |
|
1729 |
|
1730 __UHEAP_MARKEND; |
|
1731 |
|
1732 TheTest.End(); |
|
1733 TheTest.Close(); |
|
1734 |
|
1735 delete tc; |
|
1736 |
|
1737 User::Heap().Check(); |
|
1738 return KErrNone; |
|
1739 } |