35 _LIT( KFeaturesFile, "C:\\Private\\102836E5\\features.dat" ); |
36 _LIT( KFeaturesFile, "C:\\Private\\102836E5\\features.dat" ); |
36 _LIT( KFeaturesDir, "C:\\Private\\102836E5\\" ); |
37 _LIT( KFeaturesDir, "C:\\Private\\102836E5\\" ); |
37 #endif |
38 #endif |
38 |
39 |
39 /////////////////////////////////////////////////////////////////////////////////////// |
40 /////////////////////////////////////////////////////////////////////////////////////// |
|
41 //Test macros and functions |
|
42 void Check1(TInt aValue, TInt aLine) |
|
43 { |
|
44 if(!aValue) |
|
45 { |
|
46 DestroyTestEnv(); |
|
47 RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); |
|
48 TheTest(EFalse, aLine); |
|
49 } |
|
50 } |
|
51 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
|
52 { |
|
53 if(aValue != aExpected) |
|
54 { |
|
55 DestroyTestEnv(); |
|
56 RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine); |
|
57 TheTest(EFalse, aLine); |
|
58 } |
|
59 } |
|
60 #define TEST(arg) ::Check1((arg), __LINE__) |
|
61 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) |
|
62 |
|
63 /////////////////////////////////////////////////////////////////////////////////////// |
|
64 void CreateTestEnv() |
|
65 { |
|
66 //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined |
|
67 #ifdef EXTENDED_FEATURE_MANAGER_TEST |
|
68 RFs fs; |
|
69 TInt err = fs.Connect(); |
|
70 TEST2(err, KErrNone); |
|
71 |
|
72 err = fs.MkDir(KFeaturesDir); |
|
73 TEST (err == KErrNone || err == KErrAlreadyExists); |
|
74 |
|
75 (void)fs.Delete(KFeaturesFile); |
|
76 err = BaflUtils::CopyFile(fs, KZOrgFeaturesFile, KFeaturesDir); |
|
77 TEST2 (err, KErrNone); |
|
78 err = fs.SetAtt(KFeaturesFile, KEntryAttNormal, KEntryAttReadOnly); |
|
79 TEST2 (err, KErrNone); |
|
80 fs.Close(); |
|
81 #endif |
|
82 } |
40 |
83 |
41 //Deletes all created test files. |
84 //Deletes all created test files. |
42 void DestroyTestEnv() |
85 void DestroyTestEnv() |
43 { |
86 { |
44 //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined |
87 //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined |
45 #ifdef EXTENDED_FEATURE_MANAGER_TEST |
88 #ifdef EXTENDED_FEATURE_MANAGER_TEST |
46 RFs fs; |
89 RFs fs; |
47 TInt err = fs.Connect(); |
90 TInt err = fs.Connect(); |
48 if(err == KErrNone) |
91 if(err == KErrNone) |
49 { |
92 { |
50 (void)fs.Delete(KFeaturesFile); |
93 err = fs.Delete(KFeaturesFile); |
|
94 if (err != KErrNone) |
|
95 { |
|
96 RDebug::Print(_L("Warning: Clean test enviroment failed with error %d"), err); |
|
97 } |
51 } |
98 } |
52 fs.Close(); |
99 fs.Close(); |
53 #endif |
100 #endif |
54 } |
101 } |
55 |
|
56 /////////////////////////////////////////////////////////////////////////////////////// |
|
57 /////////////////////////////////////////////////////////////////////////////////////// |
|
58 //Test macros and functions |
|
59 void Check1(TInt aValue, TInt aLine) |
|
60 { |
|
61 if(!aValue) |
|
62 { |
|
63 DestroyTestEnv(); |
|
64 RDebug::Print(_L("*** Expression evaluated to false. Line %d\r\n"), aLine); |
|
65 TheTest(EFalse, aLine); |
|
66 } |
|
67 } |
|
68 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
|
69 { |
|
70 if(aValue != aExpected) |
|
71 { |
|
72 DestroyTestEnv(); |
|
73 RDebug::Print(_L("*** Expected: %d, got: %d. Line %d\r\n"), aExpected, aValue, aLine); |
|
74 TheTest(EFalse, aLine); |
|
75 } |
|
76 } |
|
77 #define TEST(arg) ::Check1((arg), __LINE__) |
|
78 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) |
|
79 |
|
80 /////////////////////////////////////////////////////////////////////////////////////// |
102 /////////////////////////////////////////////////////////////////////////////////////// |
81 |
103 |
82 static void MarkHandles() |
104 static void MarkHandles() |
83 { |
105 { |
84 RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount); |
106 RThread().HandleCount(TheProcessHandleCount, TheThreadHandleCount); |
191 } |
213 } |
192 fs.Close(); |
214 fs.Close(); |
193 TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt); |
215 TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt); |
194 } |
216 } |
195 |
217 |
196 void CreateTestEnv() |
|
197 { |
|
198 //KFeaturesDir is defined only if EXTENDED_FEATURE_MANAGER_TEST is defined |
|
199 #ifdef EXTENDED_FEATURE_MANAGER_TEST |
|
200 RFs fs; |
|
201 TInt err = fs.Connect(); |
|
202 TEST2(err, KErrNone); |
|
203 |
|
204 err = fs.MkDir(KFeaturesDir); |
|
205 TEST (err == KErrNone || err == KErrAlreadyExists); |
|
206 |
|
207 (void)fs.Delete(KFeaturesFile); |
|
208 err = BaflUtils::CopyFile(fs, KZOrgFeaturesFile, KFeaturesDir); |
|
209 TEST2 (err, KErrNone); |
|
210 |
|
211 fs.Close(); |
|
212 #endif |
|
213 } |
|
214 |
218 |
215 void DoTestsL() |
219 void DoTestsL() |
216 { |
220 { |
217 CActiveScheduler* scheduler = new CActiveScheduler; |
221 CActiveScheduler* scheduler = new CActiveScheduler; |
218 TEST(scheduler != NULL); |
222 TEST(scheduler != NULL); |