| 0 |      1 | // Copyright (c) 1999-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 the License "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 | // f32test\server\t_appins.cpp
 | 
|  |     15 | // 
 | 
|  |     16 | //
 | 
|  |     17 | 
 | 
|  |     18 | #include <f32file.h>
 | 
|  |     19 | #include <e32test.h>
 | 
|  |     20 | #include <hal.h>
 | 
|  |     21 | #include "t_server.h"
 | 
|  |     22 | #include "t_chlffs.h"
 | 
|  |     23 | 
 | 
|  |     24 | #if defined(__WINS__)
 | 
|  |     25 | #define WIN32_LEAN_AND_MEAN
 | 
|  |     26 | #pragma warning (disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
 | 
|  |     27 | #pragma warning (default:4201) // warning C4201: nonstandard extension used : nameless struct/union
 | 
|  |     28 | #endif
 | 
|  |     29 | 
 | 
|  |     30 | #if defined(_UNICODE)
 | 
|  |     31 | #if !defined(UNICODE)
 | 
|  |     32 | #define UNICODE
 | 
|  |     33 | #endif
 | 
|  |     34 | #endif
 | 
|  |     35 | 
 | 
|  |     36 | GLDEF_D RTest test(_L("T_APPINS"));
 | 
|  |     37 | LOCAL_D RFs TheNotifyFs;	//	Fileserver session to receive/request change notification
 | 
|  |     38 | TInt RemovableDrive;
 | 
|  |     39 | /*
 | 
|  |     40 | 
 | 
|  |     41 | 	What this test is for:
 | 
|  |     42 | 	Tests bug fix for the bug which doesn't notify drive D: when files are installed onto it
 | 
|  |     43 |  
 | 
|  |     44 | */
 | 
|  |     45 | 
 | 
|  |     46 | LOCAL_C void Test1()
 | 
|  |     47 | //
 | 
|  |     48 | //	Test notification when session path of notification session is set to be explicitly different 
 | 
|  |     49 | //	from the drive and directory into which files and directories are created
 | 
|  |     50 | //
 | 
|  |     51 | 	{
 | 
|  |     52 | 	TFileName path;
 | 
|  |     53 | 	path=_L("?:\\F32-TST\\T_APPINS\\");
 | 
|  |     54 | 		
 | 
|  |     55 | 	TInt r=TheNotifyFs.SessionPath(gSessionPath);
 | 
|  |     56 | 	test(r==KErrNone);
 | 
|  |     57 | 
 | 
|  |     58 | 	TChar driveChar;
 | 
|  |     59 | 	r=RFs::DriveToChar(RemovableDrive,driveChar);
 | 
|  |     60 | 	test(r==KErrNone);
 | 
|  |     61 | 	
 | 
|  |     62 | 	if (gSessionPath[0]=='C')
 | 
|  |     63 | 		(gSessionPath[0] == (TText)gDriveToTest)? (path[0] = (TText)driveChar):(path[0] = (TText)gDriveToTest);
 | 
|  |     64 | 	else if (gSessionPath[0]=='Y')
 | 
|  |     65 | 		path[0]='X';
 | 
|  |     66 | 	else if (gSessionPath[0]=='X')
 | 
|  |     67 | 		path[0]='Y';
 | 
|  |     68 | 	else 
 | 
|  |     69 | 		path[0]='C';	//invalid drive numbers shouldn't reach here, must be filtered out from t_main
 | 
|  |     70 | 		//return;
 | 
|  |     71 | 	
 | 
|  |     72 | 	TRequestStatus statEntry(KRequestPending);
 | 
|  |     73 | 	TRequestStatus statFile(KRequestPending);
 | 
|  |     74 | 	TRequestStatus statDir(KRequestPending);
 | 
|  |     75 | 	TRequestStatus statWild(KRequestPending);
 | 
|  |     76 | 	TRequestStatus statWilder(KRequestPending);
 | 
|  |     77 | 
 | 
|  |     78 | 	r=TheFs.RmDir(path);
 | 
|  |     79 | 	test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
 | 
|  |     80 | 
 | 
|  |     81 | 	test.Printf(_L("Notify Session Path %S\n"),&gSessionPath);
 | 
|  |     82 | 
 | 
|  |     83 | //	Submit notify change requests (requesting ahead)
 | 
|  |     84 | 	test.Printf(_L("Create a directory %S\n"),&path);
 | 
|  |     85 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |     86 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |     87 | 	TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
 | 
|  |     88 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |     89 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
 | 
|  |     90 | 
 | 
|  |     91 | 	r=TheFs.MkDir(path);	
 | 
|  |     92 | 	test((r==KErrNone)||(r==KErrAlreadyExists));
 | 
|  |     93 | 	User::WaitForAnyRequest();
 | 
|  |     94 | 	test(statEntry==KErrNone);
 | 
|  |     95 | 	test(statFile==KErrNone);
 | 
|  |     96 | 	test(statDir==KErrNone);
 | 
|  |     97 | 	test(statWild==KErrNone);
 | 
|  |     98 | 	test(statWilder==KErrNone);
 | 
|  |     99 | 	
 | 
|  |    100 | //	Resubmit notify change requests (requesting ahead)
 | 
|  |    101 | 	test.Next(_L("Create a file in the directory"));
 | 
|  |    102 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    103 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    104 | 	TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
 | 
|  |    105 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |    106 | 	TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\"));
 | 
|  |    107 | 
 | 
|  |    108 | 	TFileName filePath;
 | 
|  |    109 | 	filePath=path;
 | 
|  |    110 | 	filePath+=_L("TestFile.app");
 | 
|  |    111 | 	RFile file;
 | 
|  |    112 | 	r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
 | 
|  |    113 | 	file.Close();
 | 
|  |    114 | 	User::WaitForAnyRequest();
 | 
|  |    115 | 	test(r==KErrNone);
 | 
|  |    116 | 	test (statEntry==KErrNone);
 | 
|  |    117 | 	test(statFile==KErrNone);
 | 
|  |    118 | 	test(statDir==KRequestPending);
 | 
|  |    119 | 	test(statWild==KErrNone);
 | 
|  |    120 | 	test(statWilder==KErrNone);
 | 
|  |    121 | 
 | 
|  |    122 | //	Resubmit notify change requests	
 | 
|  |    123 | 	test.Next(_L("Remove the file from the directory"));
 | 
|  |    124 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    125 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    126 | 	TheNotifyFs.NotifyChange(ENotifyDir,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |    127 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
 | 
|  |    128 | 	
 | 
|  |    129 | 	r=TheFs.Delete(filePath);
 | 
|  |    130 | 	test(r==KErrNone);
 | 
|  |    131 | 	User::WaitForAnyRequest();
 | 
|  |    132 | 	test (statEntry==KErrNone);
 | 
|  |    133 | 	test(statFile==KErrNone);
 | 
|  |    134 | 	test(statDir==KRequestPending);
 | 
|  |    135 | 	test(statWild==KRequestPending);
 | 
|  |    136 | 	test(statWilder==KErrNone);
 | 
|  |    137 | 
 | 
|  |    138 | //	Resubmit notify change requests	
 | 
|  |    139 | 	test.Next(_L("Remove the directory"));
 | 
|  |    140 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    141 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    142 | //	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |    143 | 	TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\"));
 | 
|  |    144 | 
 | 
|  |    145 | 	r=TheFs.RmDir(path);
 | 
|  |    146 | 	test(r==KErrNone);
 | 
|  |    147 | 	User::WaitForAnyRequest();
 | 
|  |    148 | 	test (statEntry==KErrNone);
 | 
|  |    149 | 	test(statFile==KRequestPending);
 | 
|  |    150 | 	test(statDir==KErrNone);
 | 
|  |    151 | 	test(statWild==KErrNone);
 | 
|  |    152 | 	test(statWilder==KRequestPending);
 | 
|  |    153 | 
 | 
|  |    154 | //	In case any outstanding notification requests exist
 | 
|  |    155 | 	TheNotifyFs.NotifyChangeCancel();
 | 
|  |    156 | 	}
 | 
|  |    157 | 
 | 
|  |    158 | LOCAL_C void Test2()
 | 
|  |    159 | //
 | 
|  |    160 | //	Test notification when session path of the notification session is implicitly different 
 | 
|  |    161 | //	to the drive and directory into which files and directories are created
 | 
|  |    162 | //
 | 
|  |    163 | 	{
 | 
|  |    164 | 	TFileName sessionPath;
 | 
|  |    165 | 	sessionPath=_L("?:\\F32-TST\\");
 | 
|  |    166 | 		
 | 
|  |    167 | 	TChar driveChar;
 | 
|  |    168 | 	TInt err=RFs::DriveToChar(RemovableDrive,driveChar);
 | 
|  |    169 | 	test(err==KErrNone);
 | 
|  |    170 | 
 | 
|  |    171 | 	if (gSessionPath[0]=='C')
 | 
|  |    172 | 		(gSessionPath[0] == (TText)gDriveToTest)? (sessionPath[0] = (TText)driveChar):(sessionPath[0] = (TText)gDriveToTest);
 | 
|  |    173 | 	else if (gSessionPath[0]=='Y')
 | 
|  |    174 | 		sessionPath[0]='X';
 | 
|  |    175 | 	else if (gSessionPath[0]=='X')
 | 
|  |    176 | 		sessionPath[0]='Y';
 | 
|  |    177 | 	else 
 | 
|  |    178 | 		sessionPath[0]='C';	//invalid drive numbers shouldn't reach here, must be filtered out from t_main
 | 
|  |    179 | 		//return;
 | 
|  |    180 | 	
 | 
|  |    181 | 	TInt r=TheFs.SetSessionPath(sessionPath);
 | 
|  |    182 | 	test(r==KErrNone);
 | 
|  |    183 | 
 | 
|  |    184 | 	TFileName path;
 | 
|  |    185 | 	path=_L("\\F32-TST\\T_APPINS\\");	//	Takes drive implicitly from associated session path
 | 
|  |    186 | 						
 | 
|  |    187 | 	r=TheFs.RmDir(path);
 | 
|  |    188 | 	test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
 | 
|  |    189 | 	
 | 
|  |    190 | 	TRequestStatus statEntry(KRequestPending);
 | 
|  |    191 | 	TRequestStatus statFile(KRequestPending);
 | 
|  |    192 | 	TRequestStatus statDir(KRequestPending);
 | 
|  |    193 | 	TRequestStatus statWild(KRequestPending);
 | 
|  |    194 | 	TRequestStatus statWilder(KRequestPending);
 | 
|  |    195 | 
 | 
|  |    196 | 	test.Printf(_L("Notify Session Path %S\n"),&gSessionPath);
 | 
|  |    197 | 	test.Printf(_L("File Creation Session Path %S\n"),&sessionPath);
 | 
|  |    198 | 
 | 
|  |    199 | //	Submit notify change requests (requesting ahead)
 | 
|  |    200 | 	test.Printf(_L("Create a directory %S\n"),&path);
 | 
|  |    201 | 
 | 
|  |    202 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);	//	Watches drive associated with
 | 
|  |    203 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    204 | 	TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
 | 
|  |    205 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |    206 | 	TheNotifyFs.NotifyChange(ENotifyAll,statWilder,_L("*:\\"));
 | 
|  |    207 | 
 | 
|  |    208 | 	r=TheFs.MkDir(path);										//	Creates the directory on the drive
 | 
|  |    209 | 	test((r==KErrNone)||(r==KErrAlreadyExists));				//	associated with TheFs session path
 | 
|  |    210 | 	test (statEntry==KRequestPending);
 | 
|  |    211 | 	test(statFile==KRequestPending);
 | 
|  |    212 | 	test(statDir==KRequestPending);	//	No notification because it's watching a different drive!
 | 
|  |    213 | 	test(statWild==KErrNone);	//	BUG FIX TEST
 | 
|  |    214 | 	test(statWilder==KErrNone);
 | 
|  |    215 | 
 | 
|  |    216 | //	Don't need to resubmit notify change requests
 | 
|  |    217 | 	test.Next(_L("Create a file in the directory"));
 | 
|  |    218 | 	TheNotifyFs.NotifyChange(ENotifyFile,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |    219 | 	TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\"));
 | 
|  |    220 | 
 | 
|  |    221 | 	TFileName filePath;
 | 
|  |    222 | 	filePath=path;
 | 
|  |    223 | 	filePath+=_L("TestFile.app");
 | 
|  |    224 | 	RFile file;
 | 
|  |    225 | 	r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
 | 
|  |    226 | 	file.Close();
 | 
|  |    227 | 	test(r==KErrNone);
 | 
|  |    228 | 
 | 
|  |    229 | 	test (statEntry==KRequestPending);	//	No notification!
 | 
|  |    230 | 	test(statFile==KRequestPending);
 | 
|  |    231 | 	test(statDir==KRequestPending);	
 | 
|  |    232 | 	test(statWild==KErrNone);
 | 
|  |    233 | 	test(statWilder==KErrNone);
 | 
|  |    234 | 
 | 
|  |    235 | //	No need to resubmit notify change requests	
 | 
|  |    236 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |    237 | 	TheNotifyFs.NotifyChange(ENotifyDir,statWilder,_L("*:\\"));
 | 
|  |    238 | 
 | 
|  |    239 | 	r=TheFs.Delete(filePath);
 | 
|  |    240 | 	test(r==KErrNone);
 | 
|  |    241 | //	Still no notification	
 | 
|  |    242 | 	test (statEntry==KRequestPending);
 | 
|  |    243 | 	test(statFile==KRequestPending);
 | 
|  |    244 | 	test(statDir==KRequestPending);
 | 
|  |    245 | 	test(statWild==KErrNone);
 | 
|  |    246 | 	test(statWilder==KRequestPending);
 | 
|  |    247 | 
 | 
|  |    248 | //	No need to resubmit notify change requests	
 | 
|  |    249 | 	test.Next(_L("Remove the directory"));
 | 
|  |    250 | 	TheNotifyFs.NotifyChange(ENotifyDir,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
 | 
|  |    251 | //	TheNotifyFs.NotifyChange(ENotifyDir,statWilder,_L("*:\\"));
 | 
|  |    252 | 	r=TheFs.RmDir(path);
 | 
|  |    253 | 	test(r==KErrNone);
 | 
|  |    254 | //	Still no notification	
 | 
|  |    255 | 	test (statEntry==KRequestPending);
 | 
|  |    256 | 	test(statFile==KRequestPending);
 | 
|  |    257 | 	test(statDir==KRequestPending);
 | 
|  |    258 | 	test(statWild==KErrNone);
 | 
|  |    259 | 	test(statWilder==KErrNone);
 | 
|  |    260 | 
 | 
|  |    261 | //	Cancel the outstanding requests
 | 
|  |    262 | 	TheNotifyFs.NotifyChangeCancel();
 | 
|  |    263 | 	}
 | 
|  |    264 | 
 | 
|  |    265 | LOCAL_C void Test3()
 | 
|  |    266 | //
 | 
|  |    267 | //	Test notification when session path of the notification session is set to be the 
 | 
|  |    268 | //	same as the drive and directory into which files and directories are created
 | 
|  |    269 | //
 | 
|  |    270 | 	{
 | 
|  |    271 | 	TFileName path;
 | 
|  |    272 | 	path=_L("\\F32-TST\\T_APPINS\\");
 | 
|  |    273 | 	TInt r=TheFs.RmDir(path);
 | 
|  |    274 | 	test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
 | 
|  |    275 | 	
 | 
|  |    276 | 	TRequestStatus statEntry(KRequestPending);
 | 
|  |    277 | 	TRequestStatus statFile(KRequestPending);
 | 
|  |    278 | 	TRequestStatus statDir(KRequestPending);
 | 
|  |    279 | 	TRequestStatus statWild(KRequestPending);
 | 
|  |    280 | 	TRequestStatus statWilder(KRequestPending);
 | 
|  |    281 | 
 | 
|  |    282 | 	test.Printf(_L("Session Path %S\n"),&gSessionPath);
 | 
|  |    283 | //	Set the session path of the session	which creates the file/directory to be
 | 
|  |    284 | //	the same as the notification session's session path
 | 
|  |    285 | 	r=TheFs.SetSessionPath(gSessionPath);
 | 
|  |    286 | 	test(r==KErrNone);
 | 
|  |    287 | 
 | 
|  |    288 | //	Submit notify change requests (requesting ahead)
 | 
|  |    289 | 	test.Printf(_L("Create a directory %S\n"),&path);
 | 
|  |    290 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    291 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    292 | 	TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
 | 
|  |    293 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
 | 
|  |    294 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
 | 
|  |    295 | 
 | 
|  |    296 | 	r=TheFs.MkDir(path);	
 | 
|  |    297 | 	test((r==KErrNone)||(r==KErrAlreadyExists));
 | 
|  |    298 | 	User::WaitForAnyRequest();
 | 
|  |    299 | 	test (statEntry==KErrNone);
 | 
|  |    300 | 	test(statFile==KErrNone);
 | 
|  |    301 | 	test(statDir==KErrNone);
 | 
|  |    302 | 	test(statWild==KErrNone);
 | 
|  |    303 | 	test(statWilder==KErrNone);
 | 
|  |    304 | 
 | 
|  |    305 | //	Resubmit notify change requests (requesting ahead)
 | 
|  |    306 | 	test.Next(_L("Create a file in the directory"));
 | 
|  |    307 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    308 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    309 | 	TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
 | 
|  |    310 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
 | 
|  |    311 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
 | 
|  |    312 | 
 | 
|  |    313 | 
 | 
|  |    314 | 	TFileName filePath;
 | 
|  |    315 | 	filePath=path;
 | 
|  |    316 | 	filePath+=_L("TestFile.app");
 | 
|  |    317 | 	RFile file;
 | 
|  |    318 | 	r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
 | 
|  |    319 | 	file.Close();
 | 
|  |    320 | 	User::WaitForAnyRequest();
 | 
|  |    321 | 	test(r==KErrNone);
 | 
|  |    322 | 	test (statEntry==KErrNone);
 | 
|  |    323 | 	test(statFile==KErrNone);
 | 
|  |    324 | 	test(statDir==KRequestPending);	
 | 
|  |    325 | 	test(statWild==KErrNone);
 | 
|  |    326 | 	test(statWilder==KErrNone);
 | 
|  |    327 | 
 | 
|  |    328 | //	Resubmit notify change requests	
 | 
|  |    329 | 	test.Next(_L("Remove the file from the directory"));
 | 
|  |    330 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    331 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    332 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
 | 
|  |    333 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
 | 
|  |    334 | 
 | 
|  |    335 | 	r=TheFs.Delete(filePath);
 | 
|  |    336 | 	test(r==KErrNone);
 | 
|  |    337 | 	User::WaitForAnyRequest();
 | 
|  |    338 | 	test (statEntry==KErrNone);
 | 
|  |    339 | 	test(statFile==KErrNone);
 | 
|  |    340 | 	test(statDir==KRequestPending);
 | 
|  |    341 | 	test(statWild==KErrNone);
 | 
|  |    342 | 	test(statWilder==KErrNone);
 | 
|  |    343 | 
 | 
|  |    344 | //	Resubmit notify change requests	
 | 
|  |    345 | 	test.Next(_L("Remove the directory"));
 | 
|  |    346 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    347 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    348 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
 | 
|  |    349 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
 | 
|  |    350 | 
 | 
|  |    351 | 	r=TheFs.RmDir(path);
 | 
|  |    352 | 	test(r==KErrNone);
 | 
|  |    353 | 	User::WaitForAnyRequest();
 | 
|  |    354 | 	test (statEntry==KErrNone);
 | 
|  |    355 | 	test(statFile==KRequestPending);
 | 
|  |    356 | 	test(statDir==KErrNone);
 | 
|  |    357 | 	test(statWild==KErrNone);
 | 
|  |    358 | 	test(statWilder==KErrNone);
 | 
|  |    359 | 
 | 
|  |    360 | //	Cancel any outstanding notification change requests
 | 
|  |    361 | 	TheNotifyFs.NotifyChangeCancel();
 | 
|  |    362 | 	}
 | 
|  |    363 | 
 | 
|  |    364 | #if !defined(__WINS__)
 | 
|  |    365 | 
 | 
|  |    366 | LOCAL_C void Test4()
 | 
|  |    367 | //
 | 
|  |    368 | //	Test notification when session path is set to be different from the drive and directory
 | 
|  |    369 | //	into which files and directories are created
 | 
|  |    370 | //
 | 
|  |    371 | 	{
 | 
|  |    372 | 	TFileName path;
 | 
|  |    373 | 	TBuf<23> pathBuf=_L("?:\\F32-TST\\T_APPINS\\");
 | 
|  |    374 | 	
 | 
|  |    375 | 	TChar driveChar;
 | 
|  |    376 | 	TInt r=RFs::DriveToChar(RemovableDrive,driveChar);
 | 
|  |    377 | 	test(r==KErrNone);
 | 
|  |    378 | 	
 | 
|  |    379 | 	if (gDriveToTest =='C')
 | 
|  |    380 | 		pathBuf[0]=driveChar;
 | 
|  |    381 | 	else
 | 
|  |    382 | 		pathBuf[0] =gDriveToTest;
 | 
|  |    383 | 	
 | 
|  |    384 | 	path = pathBuf;
 | 
|  |    385 | 	r=TheFs.RmDir(path);
 | 
|  |    386 | 	test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
 | 
|  |    387 | 		
 | 
|  |    388 | 	TInt result;
 | 
|  |    389 | 	result=TheFs.MkDir(_L("C:\\SILLY\\"));
 | 
|  |    390 | 	test((result==KErrNone)||(result==KErrAlreadyExists));
 | 
|  |    391 | 	result=TheFs.MkDir(_L("C:\\SILLY\\SILLIER\\"));
 | 
|  |    392 | 	test((result==KErrNone)||(result==KErrAlreadyExists));
 | 
|  |    393 | 	result=TheFs.MkDir(_L("C:\\SILLY\\SILLIER\\SILLIEST\\"));
 | 
|  |    394 | 	test((result==KErrNone)||(result==KErrAlreadyExists));
 | 
|  |    395 | 
 | 
|  |    396 | 	result=TheNotifyFs.SetSessionPath(_L("C:\\SILLY\\SILLIER\\SILLIEST\\"));
 | 
|  |    397 | 	test(result==KErrNone);
 | 
|  |    398 | 	
 | 
|  |    399 | 	result=TheNotifyFs.SessionPath(gSessionPath);
 | 
|  |    400 | 	test(result==KErrNone);
 | 
|  |    401 | 	test.Printf(_L("Session Path %S\n"),&gSessionPath);
 | 
|  |    402 | 
 | 
|  |    403 | 	TRequestStatus statEntry(KRequestPending);
 | 
|  |    404 | 	TRequestStatus statFile(KRequestPending);
 | 
|  |    405 | 	TRequestStatus statDir(KRequestPending);
 | 
|  |    406 | 
 | 
|  |    407 | //	Submit notify change requests (requesting ahead)
 | 
|  |    408 | 	test.Printf(_L("Create a directory %S\n"),&path);
 | 
|  |    409 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    410 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    411 | 	TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
 | 
|  |    412 | 
 | 
|  |    413 | 	r=TheFs.MkDir(path);	
 | 
|  |    414 | 	test((r==KErrNone)||(r==KErrAlreadyExists));
 | 
|  |    415 | 	User::WaitForAnyRequest();
 | 
|  |    416 | 	test (statEntry==KErrNone);
 | 
|  |    417 | 	test(statFile==KErrNone);
 | 
|  |    418 | 	test(statDir==KErrNone);
 | 
|  |    419 | 
 | 
|  |    420 | //	Resubmit notify change requests (requesting ahead)
 | 
|  |    421 | 	test.Next(_L("Create a file in the directory"));
 | 
|  |    422 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    423 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    424 | 	TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
 | 
|  |    425 | 
 | 
|  |    426 | 	TFileName filePath;
 | 
|  |    427 | 	filePath=path;
 | 
|  |    428 | 	filePath+=_L("TestFile.app");
 | 
|  |    429 | 	RFile file;
 | 
|  |    430 | 	r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
 | 
|  |    431 | 	file.Close();
 | 
|  |    432 | 	User::WaitForAnyRequest();
 | 
|  |    433 | 	test(r==KErrNone);
 | 
|  |    434 | 	test (statEntry==KErrNone);
 | 
|  |    435 | 	test(statFile==KErrNone);
 | 
|  |    436 | 	test(statDir==KRequestPending);
 | 
|  |    437 | 
 | 
|  |    438 | //	Resubmit notify change requests	
 | 
|  |    439 | 	test.Next(_L("Remove the file from the directory"));
 | 
|  |    440 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    441 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    442 | 	
 | 
|  |    443 | 	r=TheFs.Delete(filePath);
 | 
|  |    444 | 	test(r==KErrNone);
 | 
|  |    445 | 	User::WaitForAnyRequest();
 | 
|  |    446 | 	test (statEntry==KErrNone);
 | 
|  |    447 | 	test(statFile==KErrNone);
 | 
|  |    448 | 	test(statDir==KRequestPending);
 | 
|  |    449 | 
 | 
|  |    450 | //	Resubmit notify change requests	
 | 
|  |    451 | 	test.Next(_L("Remove the directory"));
 | 
|  |    452 | 	TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
 | 
|  |    453 | 	TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
 | 
|  |    454 | 	r=TheFs.RmDir(path);
 | 
|  |    455 | 	test(r==KErrNone);
 | 
|  |    456 | 	User::WaitForAnyRequest();
 | 
|  |    457 | 	test (statEntry==KErrNone);
 | 
|  |    458 | 	test(statFile==KRequestPending);
 | 
|  |    459 | 	test(statDir==KErrNone);
 | 
|  |    460 | 
 | 
|  |    461 | 	result=TheFs.RmDir(_L("C:\\SILLY\\SILLIER\\SILLIEST\\"));
 | 
|  |    462 | 	test((result==KErrNone)||(result==KErrAlreadyExists));
 | 
|  |    463 | 	result=TheFs.RmDir(_L("C:\\SILLY\\SILLIER\\"));
 | 
|  |    464 | 	test((result==KErrNone)||(result==KErrAlreadyExists));
 | 
|  |    465 | 	result=TheFs.RmDir(_L("C:\\SILLY\\"));
 | 
|  |    466 | 	test((result==KErrNone)||(result==KErrAlreadyExists));	
 | 
|  |    467 | 	}
 | 
|  |    468 | 
 | 
|  |    469 | #endif
 | 
|  |    470 | LOCAL_C void DoTests()
 | 
|  |    471 | //
 | 
|  |    472 | // Do all tests
 | 
|  |    473 | //
 | 
|  |    474 | 	{
 | 
|  |    475 | 	Test1();
 | 
|  |    476 | 	Test2();
 | 
|  |    477 | 	Test3();
 | 
|  |    478 | 	}
 | 
|  |    479 | 
 | 
|  |    480 | GLDEF_D void CallTestsL(void)
 | 
|  |    481 | //
 | 
|  |    482 | //
 | 
|  |    483 | //
 | 
|  |    484 |     {
 | 
|  |    485 | 	test.Title();
 | 
|  |    486 | 	
 | 
|  |    487 | 	TChar driveLetter;
 | 
|  |    488 | 	TChar driveChar;
 | 
|  |    489 | 	TDriveList drvList;
 | 
|  |    490 | 	TBuf<13> dirBuf=_L("?:\\F32-TST\\");
 | 
|  |    491 | 
 | 
|  |    492 | 
 | 
|  |    493 | 	if (IsSessionDriveLFFS(TheFs,driveLetter))
 | 
|  |    494 | 		{
 | 
|  |    495 | 		test.Printf(_L("DoTestsL(): Skipped: test does not run on LFFS.\n"));
 | 
|  |    496 | 		return;
 | 
|  |    497 | 		}
 | 
|  |    498 | 
 | 
|  |    499 | 	test.Start(_L("Testing filesystem"));
 | 
|  |    500 | 	TInt r=TheNotifyFs.Connect();
 | 
|  |    501 | 	test(r==KErrNone);
 | 
|  |    502 | 	TFileName sessionPath;
 | 
|  |    503 | 	TInt uid;
 | 
|  |    504 | 	test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
 | 
|  |    505 | 	if(uid==HAL::EMachineUid_Cogent || uid==HAL::EMachineUid_IQ80310 || uid==HAL::EMachineUid_X86PC)
 | 
|  |    506 | 		{
 | 
|  |    507 | 		test.Printf(_L("WARNING: d: not tested on cogent or IQ80310 \n"));
 | 
|  |    508 | 		goto End;
 | 
|  |    509 | 		}
 | 
|  |    510 | 
 | 
|  |    511 | #if !defined(__WINS__)
 | 
|  |    512 | //	MARM TESTS
 | 
|  |    513 | 	r=TheFs.MkDir(_L("C:\\F32-TST\\"));
 | 
|  |    514 | 	test((r==KErrNone)||(r==KErrAlreadyExists));
 | 
|  |    515 | 
 | 
|  |    516 | 	if(KErrNone == TheFs.DriveList(drvList))
 | 
|  |    517 | 		{
 | 
|  |    518 | 		TInt i;
 | 
|  |    519 | 		//should be successful, otherwise it means a system w/o any drive!!!
 | 
|  |    520 | 		for(i=0;i<KMaxDrives;i++)
 | 
|  |    521 | 			{
 | 
|  |    522 | 			TDriveInfo driveInfo;
 | 
|  |    523 | 			if((drvList[i] != 0)
 | 
|  |    524 | 				&& (KErrNone == TheFs.Drive(driveInfo, i))
 | 
|  |    525 | 				&& (driveInfo.iType == EMediaHardDisk)
 | 
|  |    526 | 				&& (driveInfo.iDriveAtt & KDriveAttRemovable))
 | 
|  |    527 | 				{
 | 
|  |    528 | 				RemovableDrive = i;
 | 
|  |    529 | 				test.Printf(_L("RemovableDrive = %d\n"),RemovableDrive);
 | 
|  |    530 | 				break;
 | 
|  |    531 | 				}
 | 
|  |    532 | 			}
 | 
|  |    533 | 		if(i == KMaxDrives)
 | 
|  |    534 | 			{
 | 
|  |    535 | 			test.Printf(_L("No Removable media found! Testing discontinued.\n"));
 | 
|  |    536 | 			User::Exit(KErrNone);
 | 
|  |    537 | 			}			
 | 
|  |    538 | 		}
 | 
|  |    539 | 	else
 | 
|  |    540 | 		{
 | 
|  |    541 | 		test.Printf(_L("No Drive found! Testing discontinued.\n"));
 | 
|  |    542 | 		User::Exit(KErrNone);
 | 
|  |    543 | 		}
 | 
|  |    544 | 	
 | 
|  |    545 | 	r=RFs::DriveToChar(RemovableDrive,driveChar);
 | 
|  |    546 | 	test(r==KErrNone);
 | 
|  |    547 | 	
 | 
|  |    548 | 	if(gDriveToTest == 'C')
 | 
|  |    549 | 		dirBuf[0] = (TText)driveChar;
 | 
|  |    550 | 	else
 | 
|  |    551 | 		dirBuf[0] = (TText)gDriveToTest;
 | 
|  |    552 | 		
 | 
|  |    553 | 	r=TheFs.MkDir(dirBuf);
 | 
|  |    554 | 	if ((r!=KErrNone)||(r!=KErrAlreadyExists))
 | 
|  |    555 | 		{
 | 
|  |    556 | 		test.Printf(_L("TEST REQUIRES A CF CARD - "));
 | 
|  |    557 | 		//test.Printf(_L("PUT A VALID CARD IN AND PRESS A KEY..."));
 | 
|  |    558 | 		//test.Getch();
 | 
|  |    559 | 		r=TheFs.MkDir(dirBuf);
 | 
|  |    560 | 		}
 | 
|  |    561 | 	test((r==KErrNone)||(r==KErrAlreadyExists));	
 | 
|  |    562 | 		
 | 
|  |    563 | //	Set the notification session path to the test directory on C drive
 | 
|  |    564 | 	sessionPath=_L("C:\\F32-TST\\");
 | 
|  |    565 | 	r=TheNotifyFs.SetSessionPath(sessionPath);
 | 
|  |    566 | 	test(r==KErrNone);
 | 
|  |    567 | //	Run tests
 | 
|  |    568 | 	TRAP(r,DoTests());
 | 
|  |    569 | 	if (r!=KErrNone)
 | 
|  |    570 | 		test.Printf(_L("Error: %d\n"),r);
 | 
|  |    571 | 	Test4();
 | 
|  |    572 | 	CheckDisk();
 | 
|  |    573 | 
 | 
|  |    574 | //	Set the notification session path to the test directory on gDriveToTest
 | 
|  |    575 | 	if(gDriveToTest == 'C')
 | 
|  |    576 | 		sessionPath[0] = (TText)driveChar;
 | 
|  |    577 | 	else
 | 
|  |    578 | 		sessionPath[0] = (TText)gDriveToTest;
 | 
|  |    579 | 		
 | 
|  |    580 | 
 | 
|  |    581 | 	r=TheNotifyFs.SetSessionPath(sessionPath);
 | 
|  |    582 | 	test(r==KErrNone);
 | 
|  |    583 | 
 | 
|  |    584 | 	test(r==KErrNone);
 | 
|  |    585 | 	TRAP(r,DoTests());
 | 
|  |    586 | 	if (r!=KErrNone)
 | 
|  |    587 | 		test.Printf(_L("Error: %d\n"),r);
 | 
|  |    588 | 	Test4();
 | 
|  |    589 | 	CheckDisk();
 | 
|  |    590 | #elif defined (__WINS__)
 | 
|  |    591 | 	r=TheFs.MkDir(_L("X:\\F32-TST\\"));
 | 
|  |    592 | 	test((r==KErrNone)||(r==KErrAlreadyExists));
 | 
|  |    593 | 	r=TheFs.MkDir(_L("Y:\\F32-TST\\"));
 | 
|  |    594 | 	test((r==KErrNone)||(r==KErrAlreadyExists));
 | 
|  |    595 | //	Set session path to test directory on Y drive
 | 
|  |    596 | 	r=TheNotifyFs.SetSessionPath(_L("Y:\\F32-TST\\"));
 | 
|  |    597 | 	test(r==KErrNone);
 | 
|  |    598 | 	TRAP(r,DoTests());
 | 
|  |    599 | 	if (r!=KErrNone)
 | 
|  |    600 | 		test.Printf(_L("Error: %d\n"),r);
 | 
|  |    601 | 
 | 
|  |    602 | 	CheckDisk();
 | 
|  |    603 | 
 | 
|  |    604 | 	//we have no X drive on eka2 yet
 | 
|  |    605 | //	Set session path to test directory on X drive	
 | 
|  |    606 | //	r=TheNotifyFs.SetSessionPath(_L("X:\\F32-TST\\"));
 | 
|  |    607 | //	test(r==KErrNone);
 | 
|  |    608 | //	TRAP(r,DoTests());
 | 
|  |    609 | 
 | 
|  |    610 | 	if (r!=KErrNone)
 | 
|  |    611 | 		test.Printf(_L("Error: %d\n"),r);
 | 
|  |    612 | 
 | 
|  |    613 | 	CheckDisk();
 | 
|  |    614 | #endif
 | 
|  |    615 | 
 | 
|  |    616 | End:
 | 
|  |    617 | 	TheNotifyFs.Close();
 | 
|  |    618 | 	test.End();
 | 
|  |    619 | 	test.Close();
 | 
|  |    620 |     }
 | 
|  |    621 | 
 |