1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_appins.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,621 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32test\server\t_appins.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <f32file.h>
1.22 +#include <e32test.h>
1.23 +#include <hal.h>
1.24 +#include "t_server.h"
1.25 +#include "t_chlffs.h"
1.26 +
1.27 +#if defined(__WINS__)
1.28 +#define WIN32_LEAN_AND_MEAN
1.29 +#pragma warning (disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
1.30 +#pragma warning (default:4201) // warning C4201: nonstandard extension used : nameless struct/union
1.31 +#endif
1.32 +
1.33 +#if defined(_UNICODE)
1.34 +#if !defined(UNICODE)
1.35 +#define UNICODE
1.36 +#endif
1.37 +#endif
1.38 +
1.39 +GLDEF_D RTest test(_L("T_APPINS"));
1.40 +LOCAL_D RFs TheNotifyFs; // Fileserver session to receive/request change notification
1.41 +TInt RemovableDrive;
1.42 +/*
1.43 +
1.44 + What this test is for:
1.45 + Tests bug fix for the bug which doesn't notify drive D: when files are installed onto it
1.46 +
1.47 +*/
1.48 +
1.49 +LOCAL_C void Test1()
1.50 +//
1.51 +// Test notification when session path of notification session is set to be explicitly different
1.52 +// from the drive and directory into which files and directories are created
1.53 +//
1.54 + {
1.55 + TFileName path;
1.56 + path=_L("?:\\F32-TST\\T_APPINS\\");
1.57 +
1.58 + TInt r=TheNotifyFs.SessionPath(gSessionPath);
1.59 + test(r==KErrNone);
1.60 +
1.61 + TChar driveChar;
1.62 + r=RFs::DriveToChar(RemovableDrive,driveChar);
1.63 + test(r==KErrNone);
1.64 +
1.65 + if (gSessionPath[0]=='C')
1.66 + (gSessionPath[0] == (TText)gDriveToTest)? (path[0] = (TText)driveChar):(path[0] = (TText)gDriveToTest);
1.67 + else if (gSessionPath[0]=='Y')
1.68 + path[0]='X';
1.69 + else if (gSessionPath[0]=='X')
1.70 + path[0]='Y';
1.71 + else
1.72 + path[0]='C'; //invalid drive numbers shouldn't reach here, must be filtered out from t_main
1.73 + //return;
1.74 +
1.75 + TRequestStatus statEntry(KRequestPending);
1.76 + TRequestStatus statFile(KRequestPending);
1.77 + TRequestStatus statDir(KRequestPending);
1.78 + TRequestStatus statWild(KRequestPending);
1.79 + TRequestStatus statWilder(KRequestPending);
1.80 +
1.81 + r=TheFs.RmDir(path);
1.82 + test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
1.83 +
1.84 + test.Printf(_L("Notify Session Path %S\n"),&gSessionPath);
1.85 +
1.86 +// Submit notify change requests (requesting ahead)
1.87 + test.Printf(_L("Create a directory %S\n"),&path);
1.88 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.89 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.90 + TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
1.91 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.92 + TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
1.93 +
1.94 + r=TheFs.MkDir(path);
1.95 + test((r==KErrNone)||(r==KErrAlreadyExists));
1.96 + User::WaitForAnyRequest();
1.97 + test(statEntry==KErrNone);
1.98 + test(statFile==KErrNone);
1.99 + test(statDir==KErrNone);
1.100 + test(statWild==KErrNone);
1.101 + test(statWilder==KErrNone);
1.102 +
1.103 +// Resubmit notify change requests (requesting ahead)
1.104 + test.Next(_L("Create a file in the directory"));
1.105 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.106 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.107 + TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
1.108 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.109 + TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\"));
1.110 +
1.111 + TFileName filePath;
1.112 + filePath=path;
1.113 + filePath+=_L("TestFile.app");
1.114 + RFile file;
1.115 + r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
1.116 + file.Close();
1.117 + User::WaitForAnyRequest();
1.118 + test(r==KErrNone);
1.119 + test (statEntry==KErrNone);
1.120 + test(statFile==KErrNone);
1.121 + test(statDir==KRequestPending);
1.122 + test(statWild==KErrNone);
1.123 + test(statWilder==KErrNone);
1.124 +
1.125 +// Resubmit notify change requests
1.126 + test.Next(_L("Remove the file from the directory"));
1.127 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.128 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.129 + TheNotifyFs.NotifyChange(ENotifyDir,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.130 + TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
1.131 +
1.132 + r=TheFs.Delete(filePath);
1.133 + test(r==KErrNone);
1.134 + User::WaitForAnyRequest();
1.135 + test (statEntry==KErrNone);
1.136 + test(statFile==KErrNone);
1.137 + test(statDir==KRequestPending);
1.138 + test(statWild==KRequestPending);
1.139 + test(statWilder==KErrNone);
1.140 +
1.141 +// Resubmit notify change requests
1.142 + test.Next(_L("Remove the directory"));
1.143 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.144 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.145 +// TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.146 + TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\"));
1.147 +
1.148 + r=TheFs.RmDir(path);
1.149 + test(r==KErrNone);
1.150 + User::WaitForAnyRequest();
1.151 + test (statEntry==KErrNone);
1.152 + test(statFile==KRequestPending);
1.153 + test(statDir==KErrNone);
1.154 + test(statWild==KErrNone);
1.155 + test(statWilder==KRequestPending);
1.156 +
1.157 +// In case any outstanding notification requests exist
1.158 + TheNotifyFs.NotifyChangeCancel();
1.159 + }
1.160 +
1.161 +LOCAL_C void Test2()
1.162 +//
1.163 +// Test notification when session path of the notification session is implicitly different
1.164 +// to the drive and directory into which files and directories are created
1.165 +//
1.166 + {
1.167 + TFileName sessionPath;
1.168 + sessionPath=_L("?:\\F32-TST\\");
1.169 +
1.170 + TChar driveChar;
1.171 + TInt err=RFs::DriveToChar(RemovableDrive,driveChar);
1.172 + test(err==KErrNone);
1.173 +
1.174 + if (gSessionPath[0]=='C')
1.175 + (gSessionPath[0] == (TText)gDriveToTest)? (sessionPath[0] = (TText)driveChar):(sessionPath[0] = (TText)gDriveToTest);
1.176 + else if (gSessionPath[0]=='Y')
1.177 + sessionPath[0]='X';
1.178 + else if (gSessionPath[0]=='X')
1.179 + sessionPath[0]='Y';
1.180 + else
1.181 + sessionPath[0]='C'; //invalid drive numbers shouldn't reach here, must be filtered out from t_main
1.182 + //return;
1.183 +
1.184 + TInt r=TheFs.SetSessionPath(sessionPath);
1.185 + test(r==KErrNone);
1.186 +
1.187 + TFileName path;
1.188 + path=_L("\\F32-TST\\T_APPINS\\"); // Takes drive implicitly from associated session path
1.189 +
1.190 + r=TheFs.RmDir(path);
1.191 + test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
1.192 +
1.193 + TRequestStatus statEntry(KRequestPending);
1.194 + TRequestStatus statFile(KRequestPending);
1.195 + TRequestStatus statDir(KRequestPending);
1.196 + TRequestStatus statWild(KRequestPending);
1.197 + TRequestStatus statWilder(KRequestPending);
1.198 +
1.199 + test.Printf(_L("Notify Session Path %S\n"),&gSessionPath);
1.200 + test.Printf(_L("File Creation Session Path %S\n"),&sessionPath);
1.201 +
1.202 +// Submit notify change requests (requesting ahead)
1.203 + test.Printf(_L("Create a directory %S\n"),&path);
1.204 +
1.205 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); // Watches drive associated with
1.206 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.207 + TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
1.208 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.209 + TheNotifyFs.NotifyChange(ENotifyAll,statWilder,_L("*:\\"));
1.210 +
1.211 + r=TheFs.MkDir(path); // Creates the directory on the drive
1.212 + test((r==KErrNone)||(r==KErrAlreadyExists)); // associated with TheFs session path
1.213 + test (statEntry==KRequestPending);
1.214 + test(statFile==KRequestPending);
1.215 + test(statDir==KRequestPending); // No notification because it's watching a different drive!
1.216 + test(statWild==KErrNone); // BUG FIX TEST
1.217 + test(statWilder==KErrNone);
1.218 +
1.219 +// Don't need to resubmit notify change requests
1.220 + test.Next(_L("Create a file in the directory"));
1.221 + TheNotifyFs.NotifyChange(ENotifyFile,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.222 + TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\"));
1.223 +
1.224 + TFileName filePath;
1.225 + filePath=path;
1.226 + filePath+=_L("TestFile.app");
1.227 + RFile file;
1.228 + r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
1.229 + file.Close();
1.230 + test(r==KErrNone);
1.231 +
1.232 + test (statEntry==KRequestPending); // No notification!
1.233 + test(statFile==KRequestPending);
1.234 + test(statDir==KRequestPending);
1.235 + test(statWild==KErrNone);
1.236 + test(statWilder==KErrNone);
1.237 +
1.238 +// No need to resubmit notify change requests
1.239 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.240 + TheNotifyFs.NotifyChange(ENotifyDir,statWilder,_L("*:\\"));
1.241 +
1.242 + r=TheFs.Delete(filePath);
1.243 + test(r==KErrNone);
1.244 +// Still no notification
1.245 + test (statEntry==KRequestPending);
1.246 + test(statFile==KRequestPending);
1.247 + test(statDir==KRequestPending);
1.248 + test(statWild==KErrNone);
1.249 + test(statWilder==KRequestPending);
1.250 +
1.251 +// No need to resubmit notify change requests
1.252 + test.Next(_L("Remove the directory"));
1.253 + TheNotifyFs.NotifyChange(ENotifyDir,statWild,_L("?:\\F32-TST\\T_APPINS\\"));
1.254 +// TheNotifyFs.NotifyChange(ENotifyDir,statWilder,_L("*:\\"));
1.255 + r=TheFs.RmDir(path);
1.256 + test(r==KErrNone);
1.257 +// Still no notification
1.258 + test (statEntry==KRequestPending);
1.259 + test(statFile==KRequestPending);
1.260 + test(statDir==KRequestPending);
1.261 + test(statWild==KErrNone);
1.262 + test(statWilder==KErrNone);
1.263 +
1.264 +// Cancel the outstanding requests
1.265 + TheNotifyFs.NotifyChangeCancel();
1.266 + }
1.267 +
1.268 +LOCAL_C void Test3()
1.269 +//
1.270 +// Test notification when session path of the notification session is set to be the
1.271 +// same as the drive and directory into which files and directories are created
1.272 +//
1.273 + {
1.274 + TFileName path;
1.275 + path=_L("\\F32-TST\\T_APPINS\\");
1.276 + TInt r=TheFs.RmDir(path);
1.277 + test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
1.278 +
1.279 + TRequestStatus statEntry(KRequestPending);
1.280 + TRequestStatus statFile(KRequestPending);
1.281 + TRequestStatus statDir(KRequestPending);
1.282 + TRequestStatus statWild(KRequestPending);
1.283 + TRequestStatus statWilder(KRequestPending);
1.284 +
1.285 + test.Printf(_L("Session Path %S\n"),&gSessionPath);
1.286 +// Set the session path of the session which creates the file/directory to be
1.287 +// the same as the notification session's session path
1.288 + r=TheFs.SetSessionPath(gSessionPath);
1.289 + test(r==KErrNone);
1.290 +
1.291 +// Submit notify change requests (requesting ahead)
1.292 + test.Printf(_L("Create a directory %S\n"),&path);
1.293 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.294 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.295 + TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
1.296 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
1.297 + TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
1.298 +
1.299 + r=TheFs.MkDir(path);
1.300 + test((r==KErrNone)||(r==KErrAlreadyExists));
1.301 + User::WaitForAnyRequest();
1.302 + test (statEntry==KErrNone);
1.303 + test(statFile==KErrNone);
1.304 + test(statDir==KErrNone);
1.305 + test(statWild==KErrNone);
1.306 + test(statWilder==KErrNone);
1.307 +
1.308 +// Resubmit notify change requests (requesting ahead)
1.309 + test.Next(_L("Create a file in the directory"));
1.310 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.311 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.312 + TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
1.313 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
1.314 + TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
1.315 +
1.316 +
1.317 + TFileName filePath;
1.318 + filePath=path;
1.319 + filePath+=_L("TestFile.app");
1.320 + RFile file;
1.321 + r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
1.322 + file.Close();
1.323 + User::WaitForAnyRequest();
1.324 + test(r==KErrNone);
1.325 + test (statEntry==KErrNone);
1.326 + test(statFile==KErrNone);
1.327 + test(statDir==KRequestPending);
1.328 + test(statWild==KErrNone);
1.329 + test(statWilder==KErrNone);
1.330 +
1.331 +// Resubmit notify change requests
1.332 + test.Next(_L("Remove the file from the directory"));
1.333 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.334 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.335 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
1.336 + TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
1.337 +
1.338 + r=TheFs.Delete(filePath);
1.339 + test(r==KErrNone);
1.340 + User::WaitForAnyRequest();
1.341 + test (statEntry==KErrNone);
1.342 + test(statFile==KErrNone);
1.343 + test(statDir==KRequestPending);
1.344 + test(statWild==KErrNone);
1.345 + test(statWilder==KErrNone);
1.346 +
1.347 +// Resubmit notify change requests
1.348 + test.Next(_L("Remove the directory"));
1.349 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.350 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.351 + TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\"));
1.352 + TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\"));
1.353 +
1.354 + r=TheFs.RmDir(path);
1.355 + test(r==KErrNone);
1.356 + User::WaitForAnyRequest();
1.357 + test (statEntry==KErrNone);
1.358 + test(statFile==KRequestPending);
1.359 + test(statDir==KErrNone);
1.360 + test(statWild==KErrNone);
1.361 + test(statWilder==KErrNone);
1.362 +
1.363 +// Cancel any outstanding notification change requests
1.364 + TheNotifyFs.NotifyChangeCancel();
1.365 + }
1.366 +
1.367 +#if !defined(__WINS__)
1.368 +
1.369 +LOCAL_C void Test4()
1.370 +//
1.371 +// Test notification when session path is set to be different from the drive and directory
1.372 +// into which files and directories are created
1.373 +//
1.374 + {
1.375 + TFileName path;
1.376 + TBuf<23> pathBuf=_L("?:\\F32-TST\\T_APPINS\\");
1.377 +
1.378 + TChar driveChar;
1.379 + TInt r=RFs::DriveToChar(RemovableDrive,driveChar);
1.380 + test(r==KErrNone);
1.381 +
1.382 + if (gDriveToTest =='C')
1.383 + pathBuf[0]=driveChar;
1.384 + else
1.385 + pathBuf[0] =gDriveToTest;
1.386 +
1.387 + path = pathBuf;
1.388 + r=TheFs.RmDir(path);
1.389 + test((r==KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound));
1.390 +
1.391 + TInt result;
1.392 + result=TheFs.MkDir(_L("C:\\SILLY\\"));
1.393 + test((result==KErrNone)||(result==KErrAlreadyExists));
1.394 + result=TheFs.MkDir(_L("C:\\SILLY\\SILLIER\\"));
1.395 + test((result==KErrNone)||(result==KErrAlreadyExists));
1.396 + result=TheFs.MkDir(_L("C:\\SILLY\\SILLIER\\SILLIEST\\"));
1.397 + test((result==KErrNone)||(result==KErrAlreadyExists));
1.398 +
1.399 + result=TheNotifyFs.SetSessionPath(_L("C:\\SILLY\\SILLIER\\SILLIEST\\"));
1.400 + test(result==KErrNone);
1.401 +
1.402 + result=TheNotifyFs.SessionPath(gSessionPath);
1.403 + test(result==KErrNone);
1.404 + test.Printf(_L("Session Path %S\n"),&gSessionPath);
1.405 +
1.406 + TRequestStatus statEntry(KRequestPending);
1.407 + TRequestStatus statFile(KRequestPending);
1.408 + TRequestStatus statDir(KRequestPending);
1.409 +
1.410 +// Submit notify change requests (requesting ahead)
1.411 + test.Printf(_L("Create a directory %S\n"),&path);
1.412 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.413 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.414 + TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
1.415 +
1.416 + r=TheFs.MkDir(path);
1.417 + test((r==KErrNone)||(r==KErrAlreadyExists));
1.418 + User::WaitForAnyRequest();
1.419 + test (statEntry==KErrNone);
1.420 + test(statFile==KErrNone);
1.421 + test(statDir==KErrNone);
1.422 +
1.423 +// Resubmit notify change requests (requesting ahead)
1.424 + test.Next(_L("Create a file in the directory"));
1.425 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.426 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.427 + TheNotifyFs.NotifyChange(ENotifyDir,statDir,path);
1.428 +
1.429 + TFileName filePath;
1.430 + filePath=path;
1.431 + filePath+=_L("TestFile.app");
1.432 + RFile file;
1.433 + r=file.Replace(TheFs,filePath,EFileRead|EFileWrite);
1.434 + file.Close();
1.435 + User::WaitForAnyRequest();
1.436 + test(r==KErrNone);
1.437 + test (statEntry==KErrNone);
1.438 + test(statFile==KErrNone);
1.439 + test(statDir==KRequestPending);
1.440 +
1.441 +// Resubmit notify change requests
1.442 + test.Next(_L("Remove the file from the directory"));
1.443 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.444 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.445 +
1.446 + r=TheFs.Delete(filePath);
1.447 + test(r==KErrNone);
1.448 + User::WaitForAnyRequest();
1.449 + test (statEntry==KErrNone);
1.450 + test(statFile==KErrNone);
1.451 + test(statDir==KRequestPending);
1.452 +
1.453 +// Resubmit notify change requests
1.454 + test.Next(_L("Remove the directory"));
1.455 + TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path);
1.456 + TheNotifyFs.NotifyChange(ENotifyFile,statFile,path);
1.457 + r=TheFs.RmDir(path);
1.458 + test(r==KErrNone);
1.459 + User::WaitForAnyRequest();
1.460 + test (statEntry==KErrNone);
1.461 + test(statFile==KRequestPending);
1.462 + test(statDir==KErrNone);
1.463 +
1.464 + result=TheFs.RmDir(_L("C:\\SILLY\\SILLIER\\SILLIEST\\"));
1.465 + test((result==KErrNone)||(result==KErrAlreadyExists));
1.466 + result=TheFs.RmDir(_L("C:\\SILLY\\SILLIER\\"));
1.467 + test((result==KErrNone)||(result==KErrAlreadyExists));
1.468 + result=TheFs.RmDir(_L("C:\\SILLY\\"));
1.469 + test((result==KErrNone)||(result==KErrAlreadyExists));
1.470 + }
1.471 +
1.472 +#endif
1.473 +LOCAL_C void DoTests()
1.474 +//
1.475 +// Do all tests
1.476 +//
1.477 + {
1.478 + Test1();
1.479 + Test2();
1.480 + Test3();
1.481 + }
1.482 +
1.483 +GLDEF_D void CallTestsL(void)
1.484 +//
1.485 +//
1.486 +//
1.487 + {
1.488 + test.Title();
1.489 +
1.490 + TChar driveLetter;
1.491 + TChar driveChar;
1.492 + TDriveList drvList;
1.493 + TBuf<13> dirBuf=_L("?:\\F32-TST\\");
1.494 +
1.495 +
1.496 + if (IsSessionDriveLFFS(TheFs,driveLetter))
1.497 + {
1.498 + test.Printf(_L("DoTestsL(): Skipped: test does not run on LFFS.\n"));
1.499 + return;
1.500 + }
1.501 +
1.502 + test.Start(_L("Testing filesystem"));
1.503 + TInt r=TheNotifyFs.Connect();
1.504 + test(r==KErrNone);
1.505 + TFileName sessionPath;
1.506 + TInt uid;
1.507 + test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
1.508 + if(uid==HAL::EMachineUid_Cogent || uid==HAL::EMachineUid_IQ80310 || uid==HAL::EMachineUid_X86PC)
1.509 + {
1.510 + test.Printf(_L("WARNING: d: not tested on cogent or IQ80310 \n"));
1.511 + goto End;
1.512 + }
1.513 +
1.514 +#if !defined(__WINS__)
1.515 +// MARM TESTS
1.516 + r=TheFs.MkDir(_L("C:\\F32-TST\\"));
1.517 + test((r==KErrNone)||(r==KErrAlreadyExists));
1.518 +
1.519 + if(KErrNone == TheFs.DriveList(drvList))
1.520 + {
1.521 + TInt i;
1.522 + //should be successful, otherwise it means a system w/o any drive!!!
1.523 + for(i=0;i<KMaxDrives;i++)
1.524 + {
1.525 + TDriveInfo driveInfo;
1.526 + if((drvList[i] != 0)
1.527 + && (KErrNone == TheFs.Drive(driveInfo, i))
1.528 + && (driveInfo.iType == EMediaHardDisk)
1.529 + && (driveInfo.iDriveAtt & KDriveAttRemovable))
1.530 + {
1.531 + RemovableDrive = i;
1.532 + test.Printf(_L("RemovableDrive = %d\n"),RemovableDrive);
1.533 + break;
1.534 + }
1.535 + }
1.536 + if(i == KMaxDrives)
1.537 + {
1.538 + test.Printf(_L("No Removable media found! Testing discontinued.\n"));
1.539 + User::Exit(KErrNone);
1.540 + }
1.541 + }
1.542 + else
1.543 + {
1.544 + test.Printf(_L("No Drive found! Testing discontinued.\n"));
1.545 + User::Exit(KErrNone);
1.546 + }
1.547 +
1.548 + r=RFs::DriveToChar(RemovableDrive,driveChar);
1.549 + test(r==KErrNone);
1.550 +
1.551 + if(gDriveToTest == 'C')
1.552 + dirBuf[0] = (TText)driveChar;
1.553 + else
1.554 + dirBuf[0] = (TText)gDriveToTest;
1.555 +
1.556 + r=TheFs.MkDir(dirBuf);
1.557 + if ((r!=KErrNone)||(r!=KErrAlreadyExists))
1.558 + {
1.559 + test.Printf(_L("TEST REQUIRES A CF CARD - "));
1.560 + //test.Printf(_L("PUT A VALID CARD IN AND PRESS A KEY..."));
1.561 + //test.Getch();
1.562 + r=TheFs.MkDir(dirBuf);
1.563 + }
1.564 + test((r==KErrNone)||(r==KErrAlreadyExists));
1.565 +
1.566 +// Set the notification session path to the test directory on C drive
1.567 + sessionPath=_L("C:\\F32-TST\\");
1.568 + r=TheNotifyFs.SetSessionPath(sessionPath);
1.569 + test(r==KErrNone);
1.570 +// Run tests
1.571 + TRAP(r,DoTests());
1.572 + if (r!=KErrNone)
1.573 + test.Printf(_L("Error: %d\n"),r);
1.574 + Test4();
1.575 + CheckDisk();
1.576 +
1.577 +// Set the notification session path to the test directory on gDriveToTest
1.578 + if(gDriveToTest == 'C')
1.579 + sessionPath[0] = (TText)driveChar;
1.580 + else
1.581 + sessionPath[0] = (TText)gDriveToTest;
1.582 +
1.583 +
1.584 + r=TheNotifyFs.SetSessionPath(sessionPath);
1.585 + test(r==KErrNone);
1.586 +
1.587 + test(r==KErrNone);
1.588 + TRAP(r,DoTests());
1.589 + if (r!=KErrNone)
1.590 + test.Printf(_L("Error: %d\n"),r);
1.591 + Test4();
1.592 + CheckDisk();
1.593 +#elif defined (__WINS__)
1.594 + r=TheFs.MkDir(_L("X:\\F32-TST\\"));
1.595 + test((r==KErrNone)||(r==KErrAlreadyExists));
1.596 + r=TheFs.MkDir(_L("Y:\\F32-TST\\"));
1.597 + test((r==KErrNone)||(r==KErrAlreadyExists));
1.598 +// Set session path to test directory on Y drive
1.599 + r=TheNotifyFs.SetSessionPath(_L("Y:\\F32-TST\\"));
1.600 + test(r==KErrNone);
1.601 + TRAP(r,DoTests());
1.602 + if (r!=KErrNone)
1.603 + test.Printf(_L("Error: %d\n"),r);
1.604 +
1.605 + CheckDisk();
1.606 +
1.607 + //we have no X drive on eka2 yet
1.608 +// Set session path to test directory on X drive
1.609 +// r=TheNotifyFs.SetSessionPath(_L("X:\\F32-TST\\"));
1.610 +// test(r==KErrNone);
1.611 +// TRAP(r,DoTests());
1.612 +
1.613 + if (r!=KErrNone)
1.614 + test.Printf(_L("Error: %d\n"),r);
1.615 +
1.616 + CheckDisk();
1.617 +#endif
1.618 +
1.619 +End:
1.620 + TheNotifyFs.Close();
1.621 + test.End();
1.622 + test.Close();
1.623 + }
1.624 +