|
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 <e32base.h> |
|
17 #include <bautils.h> |
|
18 #include <f32file.h> |
|
19 #include "../EcomTestUtils/EcomTestIniFileUtils.h" |
|
20 #include "../EcomTestUtils/EcomTestUtils.h" |
|
21 |
|
22 _LIT(KCDriveIniFileName, "c:\\private\\10009D8F\\EComSrvr.ini"); |
|
23 _LIT(KZDriveIniFileName, "z:\\private\\10009D8F\\EComSrvr.ini"); |
|
24 _LIT(KIniBackupFileName, "c:\\private\\10009D8F\\EComSrvr_backup.ini"); |
|
25 _LIT(KIniFileName, "z:\\test\\data\\EComSrvr.ini"); |
|
26 |
|
27 |
|
28 // |
|
29 // |
|
30 //Helper functions |
|
31 // |
|
32 // |
|
33 |
|
34 /** |
|
35 Disable Ssa by using the EComSrvr_SsaDisabled.ini |
|
36 The function will make a backup of the existing EComSrvr.ini if there is one. |
|
37 @param aTest the RTest that this method is called from |
|
38 @param aFs A reference to an connected file server session. |
|
39 */ |
|
40 void DisableSsa(RTest& aTest, RFs& /*aFs*/) |
|
41 { |
|
42 TInt err = KErrNone; |
|
43 TParse iniFileName; |
|
44 TParse backupIniFileName; |
|
45 TParse tempFileName; |
|
46 |
|
47 //check if ecomsrvr.ini file exists. If so make a backup |
|
48 iniFileName.Set(KCDriveIniFileName, NULL, NULL); |
|
49 backupIniFileName.Set(KIniBackupFileName, NULL, NULL); |
|
50 TRAP(err, EComTestUtils::RfsReplaceFileL( |
|
51 iniFileName.FullName(), |
|
52 backupIniFileName.FullName())); |
|
53 if(err != KErrNotFound) //it is ok if the file does not exist |
|
54 { |
|
55 TESTC(aTest, err, KErrNone); |
|
56 } |
|
57 |
|
58 //copy ecomsrvr.ini to disable ssa |
|
59 tempFileName.Set(KIniFileName, NULL, NULL); |
|
60 TRAP(err, EComTestUtils::FileManCopyFileL( |
|
61 tempFileName.FullName(), |
|
62 iniFileName.FullName())); |
|
63 TESTC(aTest, err, KErrNone); |
|
64 } |
|
65 |
|
66 /** |
|
67 Enable Ssa by removing EComSrvr.ini if there is one |
|
68 The function will make a backup of the existing EComSrvr.ini if there is one. |
|
69 @param aTest the RTest that this method is called from |
|
70 @param aFs A reference to an connected file server session. |
|
71 */ |
|
72 void EnableSsa(RTest& aTest, RFs& /*aFs*/) |
|
73 { |
|
74 TInt err = KErrNone; |
|
75 TParse iniFileName; |
|
76 TParse backupIniFileName; |
|
77 TParse tempFileName; |
|
78 |
|
79 //check if ecomsrvr.ini file exists. If so make a backup |
|
80 iniFileName.Set(KCDriveIniFileName, NULL, NULL); |
|
81 backupIniFileName.Set(KIniBackupFileName, NULL, NULL); |
|
82 TRAP(err, EComTestUtils::RfsReplaceFileL( |
|
83 iniFileName.FullName(), |
|
84 backupIniFileName.FullName())); |
|
85 if(err != KErrNotFound) //it is ok if the file does not exist |
|
86 { |
|
87 TESTC(aTest, err, KErrNone); |
|
88 } |
|
89 } |
|
90 |
|
91 /** |
|
92 Reset the ssa by replacing the ini file with the backup if |
|
93 a backup was created in the first place |
|
94 @param aTest the RTest that this method is called from |
|
95 @param aFs A reference to an connected file server session. |
|
96 */ |
|
97 void ResetSsa(RTest& aTest, RFs& /*aFs*/) |
|
98 { |
|
99 TInt err = KErrNone; |
|
100 TParse iniFileName; |
|
101 TParse backupIniFileName; |
|
102 |
|
103 iniFileName.Set(KCDriveIniFileName, NULL, NULL); |
|
104 backupIniFileName.Set(KIniBackupFileName, NULL, NULL); |
|
105 |
|
106 //remove ecomsrvr.ini |
|
107 TRAP(err, EComTestUtils::RfsDeleteFileL(iniFileName.FullName())); |
|
108 TESTC(aTest, err, KErrNone); |
|
109 |
|
110 //if the ecomsrvr.ini file initially existed put it back using |
|
111 //the backup |
|
112 TRAP(err, EComTestUtils::RfsReplaceFileL( |
|
113 backupIniFileName.FullName(), |
|
114 iniFileName.FullName())); |
|
115 if(err != KErrNotFound) //it is ok if the file does not exist |
|
116 { |
|
117 TESTC(aTest, err, KErrNone); |
|
118 } |
|
119 } |
|
120 |
|
121 /** |
|
122 Cheks if z:\\private\\10009D8F\\EComSrvr.ini exists. If it does |
|
123 then fails the test to ensure the following tests are not run. |
|
124 @param aTest the RTest that this method is called from |
|
125 @param aFs A reference to an connected file server session. |
|
126 */ |
|
127 void TestEnableDisableSsaL(RTest& aTest, RFs& aFs) |
|
128 { |
|
129 TParse iniFileName; |
|
130 iniFileName.Set(KZDriveIniFileName, NULL, NULL); |
|
131 TBool isFileExisting = BaflUtils::FileExists(aFs, iniFileName.FullName()); |
|
132 |
|
133 if(isFileExisting) |
|
134 { |
|
135 //If the file already exists on z: drive then the test that calls |
|
136 //this method cannot be executed. Probably the test is trying to |
|
137 //disable/enable SSA behaviour using the c: drive location. Since |
|
138 //z:drive has higher priority it will never be possible to enable |
|
139 //SSA behaviour. |
|
140 TESTC(aTest, isFileExisting, EFalse); |
|
141 RDebug::Print(_L("EcomSrvr.ini file exists in z: drive. This test cannot be executed.\n")); |
|
142 } |
|
143 } |