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