|
1 // Copyright (c) 2006-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 // SQL security - deleting secure test databases from C: |
|
15 // Please, ensure that t_sqlenvdestroy test is executed after the other sql security tests |
|
16 // |
|
17 // |
|
18 |
|
19 #include <e32test.h> |
|
20 #include <bautils.h> |
|
21 |
|
22 RTest TheTest(_L("t_sqlenvdestroy - deleting secure test databases from C:")); |
|
23 |
|
24 _LIT(KDbCFileName1, "c:\\private\\10281e17\\[21212122]AADb2.db"); |
|
25 _LIT(KDbCFileName2, "c:\\private\\10281e17\\[21212122]BBDb2.db"); |
|
26 _LIT(KDbCFileName3, "c:\\private\\10281e17\\[21212125]T_AB.db"); |
|
27 _LIT(KDbCFileName4, "c:\\private\\10281e17\\[1111CCCC]T_AB.db"); |
|
28 _LIT(KDbCFileName5, "c:\\private\\10281e17\\[21212125]T_OneDefPolicy.db"); |
|
29 |
|
30 _LIT(KDb1, "c:\\private\\10281e17\\[98765432]t_nosettings.db"); |
|
31 _LIT(KDb2, "c:\\private\\10281e17\\[98765432]t_emptysettings.db"); |
|
32 _LIT(KDb3, "c:\\private\\10281e17\\[98765432]t_invversion.db"); |
|
33 _LIT(KDb4, "c:\\private\\10281e17\\[98765432]t_nocollation.db"); |
|
34 _LIT(KDb5, "c:\\private\\10281e17\\[98765432]t_longcollation.db"); |
|
35 _LIT(KDb6, "c:\\private\\10281e17\\[98765432]t_nodefaultpolicy.db"); |
|
36 _LIT(KDb7, "c:\\private\\10281e17\\[98765432]t_invobject.db"); |
|
37 _LIT(KDb8, "c:\\private\\10281e17\\[98765432]t_2defaultpolicies.db"); |
|
38 |
|
39 /////////////////////////////////////////////////////////////////////////////////////// |
|
40 /////////////////////////////////////////////////////////////////////////////////////// |
|
41 //Test macros and functions |
|
42 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
43 { |
|
44 if(aValue != aExpected) |
|
45 { |
|
46 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
47 TheTest(EFalse, aLine); |
|
48 } |
|
49 } |
|
50 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
51 |
|
52 /////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
54 void DoDeleteFile(RFs& aFs, const TDesC& aFilePath) |
|
55 { |
|
56 TInt err = BaflUtils::DeleteFile(aFs, aFilePath); |
|
57 if(err != KErrNone && err != KErrNotFound) |
|
58 { |
|
59 TheTest.Printf(_L("Error %d deleting \"%S\" file.\n"), err, &aFilePath); |
|
60 } |
|
61 } |
|
62 |
|
63 void DoRun() |
|
64 { |
|
65 RFs fs; |
|
66 TInt err = fs.Connect(); |
|
67 TEST2(err, KErrNone); |
|
68 |
|
69 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-LEGACY-T_SQLENVDESTROY-0001 Delete secure databases from C: ")); |
|
70 |
|
71 DoDeleteFile(fs, KDbCFileName1); |
|
72 DoDeleteFile(fs, KDbCFileName2); |
|
73 DoDeleteFile(fs, KDbCFileName3); |
|
74 DoDeleteFile(fs, KDbCFileName4); |
|
75 DoDeleteFile(fs, KDbCFileName5); |
|
76 |
|
77 DoDeleteFile(fs, KDb1); |
|
78 DoDeleteFile(fs, KDb2); |
|
79 DoDeleteFile(fs, KDb3); |
|
80 DoDeleteFile(fs, KDb4); |
|
81 DoDeleteFile(fs, KDb5); |
|
82 DoDeleteFile(fs, KDb6); |
|
83 DoDeleteFile(fs, KDb7); |
|
84 DoDeleteFile(fs, KDb8); |
|
85 |
|
86 fs.Close(); |
|
87 } |
|
88 |
|
89 TInt E32Main() |
|
90 { |
|
91 TheTest.Title(); |
|
92 |
|
93 CTrapCleanup* tc = CTrapCleanup::New(); |
|
94 |
|
95 __UHEAP_MARK; |
|
96 |
|
97 DoRun(); |
|
98 |
|
99 __UHEAP_MARKEND; |
|
100 |
|
101 TheTest.End(); |
|
102 TheTest.Close(); |
|
103 |
|
104 delete tc; |
|
105 |
|
106 User::Heap().Check(); |
|
107 return KErrNone; |
|
108 } |