Update contrib.
1 // Copyright (c) 2006-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // SQL security - copying secure test databases to C:
15 // Please, ensure that t_sqlenvcreate test is executed before the other sql tests
22 RTest TheTest(_L("t_sqlenvcreate - copying secure test databases to C:"));
24 _LIT(KSqlServerPrivateDirC, "c:\\private\\10281e17\\");
26 _LIT(KDbZFileName1, "z:\\private\\10281e17\\[21212122]AADb2.db");
27 _LIT(KDbZFileName2, "z:\\private\\10281e17\\[21212122]BBDb2.db");
28 _LIT(KDbZFileName3, "z:\\private\\10281e17\\[21212125]T_AB.db");
29 _LIT(KDbZFileName4, "z:\\private\\10281e17\\[1111CCCC]T_AB.db");
30 _LIT(KDbZFileName5, "z:\\private\\10281e17\\[21212125]T_OneDefPolicy.db");
32 _LIT(KDbCFileName1, "c:\\private\\10281e17\\[21212122]AADb2.db");
33 _LIT(KDbCFileName2, "c:\\private\\10281e17\\[21212122]BBDb2.db");
34 _LIT(KDbCFileName3, "c:\\private\\10281e17\\[21212125]T_AB.db");
35 _LIT(KDbCFileName4, "c:\\private\\10281e17\\[1111CCCC]T_AB.db");
36 _LIT(KDbCFileName5, "c:\\private\\10281e17\\[21212125]T_OneDefPolicy.db");
38 _LIT(KDb1org, "z:\\private\\10281e17\\[98765432]t_nosettings.db");
39 _LIT(KDb1, "c:\\private\\10281e17\\[98765432]t_nosettings.db");
41 _LIT(KDb2org, "z:\\private\\10281e17\\[98765432]t_emptysettings.db");
42 _LIT(KDb2, "c:\\private\\10281e17\\[98765432]t_emptysettings.db");
44 _LIT(KDb3org, "z:\\private\\10281e17\\[98765432]t_invversion.db");
45 _LIT(KDb3, "c:\\private\\10281e17\\[98765432]t_invversion.db");
47 _LIT(KDb4org, "z:\\private\\10281e17\\[98765432]t_nocollation.db");
48 _LIT(KDb4, "c:\\private\\10281e17\\[98765432]t_nocollation.db");
50 _LIT(KDb5org, "z:\\private\\10281e17\\[98765432]t_longcollation.db");
51 _LIT(KDb5, "c:\\private\\10281e17\\[98765432]t_longcollation.db");
53 _LIT(KDb6org, "z:\\private\\10281e17\\[98765432]t_nodefaultpolicy.db");
54 _LIT(KDb6, "c:\\private\\10281e17\\[98765432]t_nodefaultpolicy.db");
56 _LIT(KDb7org, "z:\\private\\10281e17\\[98765432]t_invobject.db");
57 _LIT(KDb7, "c:\\private\\10281e17\\[98765432]t_invobject.db");
59 _LIT(KDb8org, "z:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
60 _LIT(KDb8, "c:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
62 _LIT(KPrivateSubDir, "c:\\private\\10281e17\\cfg-TestDir.db\\");
64 ///////////////////////////////////////////////////////////////////////////////////////
65 ///////////////////////////////////////////////////////////////////////////////////////
66 //Test macros and functions
67 static void Check(TInt aValue, TInt aLine)
71 RDebug::Print(_L("*** Line %d\r\n"), aLine);
72 TheTest(EFalse, aLine);
75 static void Check(TInt aValue, TInt aExpected, TInt aLine)
77 if(aValue != aExpected)
79 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
80 TheTest(EFalse, aLine);
83 #define TEST(arg) ::Check((arg), __LINE__)
84 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
86 ///////////////////////////////////////////////////////////////////////////////////////
91 TInt err = fs.Connect();
94 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-LEGACY-T_SQLENVCREATE-0001 Copy secure databases from Z: to C: "));
96 //Create a subdir in the private datacage. The SQL production code should properly detects
97 //KPrivateSubDir is a directory not a database file
98 err = fs.MkDir(KPrivateSubDir);
99 TEST(err == KErrNone || err == KErrAlreadyExists);
101 err = BaflUtils::CopyFile(fs, KDbZFileName1, KDbCFileName1);
102 TEST2(err, KErrNone);
103 err = fs.SetAtt(KDbCFileName1, 0, KEntryAttReadOnly);
104 TEST2(err, KErrNone);
106 err = BaflUtils::CopyFile(fs, KDbZFileName2, KDbCFileName2);
107 TEST2(err, KErrNone);
108 err = fs.SetAtt(KDbCFileName2, 0, KEntryAttReadOnly);
109 TEST2(err, KErrNone);
111 err = BaflUtils::CopyFile(fs, KDbZFileName3, KDbCFileName3);
112 TEST2(err, KErrNone);
113 err = fs.SetAtt(KDbCFileName3, 0, KEntryAttReadOnly);
114 TEST2(err, KErrNone);
116 err = BaflUtils::CopyFile(fs, KDbZFileName4, KDbCFileName4);
117 TEST2(err, KErrNone);
118 err = fs.SetAtt(KDbCFileName4, 0, KEntryAttReadOnly);
119 TEST2(err, KErrNone);
121 err = BaflUtils::CopyFile(fs, KDbZFileName5, KDbCFileName5);
122 TEST2(err, KErrNone);
123 err = fs.SetAtt(KDbCFileName5, 0, KEntryAttReadOnly);
124 TEST2(err, KErrNone);
126 err = BaflUtils::CopyFile(fs, KDb1org, KDb1);
127 TEST2(err, KErrNone);
128 err = fs.SetAtt(KDb1, 0, KEntryAttReadOnly);
129 TEST2(err, KErrNone);
131 err = BaflUtils::CopyFile(fs, KDb2org, KDb2);
132 TEST2(err, KErrNone);
133 err = fs.SetAtt(KDb2, 0, KEntryAttReadOnly);
134 TEST2(err, KErrNone);
136 err = BaflUtils::CopyFile(fs, KDb3org, KDb3);
137 TEST2(err, KErrNone);
138 err = fs.SetAtt(KDb3, 0, KEntryAttReadOnly);
139 TEST2(err, KErrNone);
141 err = BaflUtils::CopyFile(fs, KDb4org, KDb4);
142 TEST2(err, KErrNone);
143 err = fs.SetAtt(KDb4, 0, KEntryAttReadOnly);
144 TEST2(err, KErrNone);
146 err = BaflUtils::CopyFile(fs, KDb5org, KDb5);
147 TEST2(err, KErrNone);
148 err = fs.SetAtt(KDb5, 0, KEntryAttReadOnly);
149 TEST2(err, KErrNone);
151 err = BaflUtils::CopyFile(fs, KDb6org, KDb6);
152 TEST2(err, KErrNone);
153 err = fs.SetAtt(KDb6, 0, KEntryAttReadOnly);
154 TEST2(err, KErrNone);
156 err = BaflUtils::CopyFile(fs, KDb7org, KDb7);
157 TEST2(err, KErrNone);
158 err = fs.SetAtt(KDb7, 0, KEntryAttReadOnly);
159 TEST2(err, KErrNone);
161 err = BaflUtils::CopyFile(fs, KDb8org, KDb8);
162 TEST2(err, KErrNone);
163 err = fs.SetAtt(KDb8, 0, KEntryAttReadOnly);
164 TEST2(err, KErrNone);
169 void CreateSqlServerPrivateDir()
172 TInt err = fs.Connect();
173 TEST2(err, KErrNone);
175 TRAP(err, BaflUtils::EnsurePathExistsL(fs, KSqlServerPrivateDirC));
176 TEST2(err, KErrNone);
185 CTrapCleanup* tc = CTrapCleanup::New();
189 CreateSqlServerPrivateDir();
200 User::Heap().Check();