4231 User::WaitForRequest(reqStatNotify1); |
4233 User::WaitForRequest(reqStatNotify1); |
4232 test_KErrNone(reqStatNotify1.Int()); |
4234 test_KErrNone(reqStatNotify1.Int()); |
4233 |
4235 |
4234 } |
4236 } |
4235 |
4237 |
4236 |
4238 _LIT(KTestNotifyFileSystemExeName,"t_tfsys_notify.fsy"); |
|
4239 _LIT(KNotifyTestFileSystem,"CNotifyTestFileSystem"); |
|
4240 |
|
4241 TInt TestExternalNotificationsWellformedness() |
|
4242 { |
|
4243 //Do Something to cause a notification: |
|
4244 |
|
4245 //******************************************** |
|
4246 // |
|
4247 // Opening(Replacing) \\Wellformed_functionWrite, |
|
4248 // will issue a create notification on file \PhantomFile_functionWrite.txt |
|
4249 TRequestStatus status1, status2; |
|
4250 TheFs.NotifyChange(ENotifyFile,status1,_L("\\PhantomFile_functionReplace.txt")); |
|
4251 RFile file; |
|
4252 TInt r = file.Replace(TheFs,_L("\\Wellformed_functionReplace.txt"),EFileWrite); |
|
4253 test_KErrNone(r); |
|
4254 |
|
4255 |
|
4256 RTimer timer1; |
|
4257 r = timer1.CreateLocal(); |
|
4258 test_KErrNone(r); |
|
4259 TTimeIntervalMicroSeconds32 time = 10000000; |
|
4260 timer1.After(status2,time); |
|
4261 User::WaitForRequest(status1,status2); |
|
4262 test_Compare(status1.Int(),!=,KRequestPending) |
|
4263 timer1.Cancel(); |
|
4264 timer1.Close(); |
|
4265 User::WaitForRequest(status2); |
|
4266 |
|
4267 //******************************************** |
|
4268 // |
|
4269 // Rename \Wellformed_functionWrite.txt --> \Wellformed_functionRename.txt, |
|
4270 // will issue a rename notification on \PhantomFile_functionWrite.txt --> \PhantomFile_functionRename.txt |
|
4271 TheFs.NotifyChange(ENotifyEntry,status1,_L("\\PhantomFile_functionRename.txt")); |
|
4272 r = file.Rename(_L("\\Wellformed_functionWrite.txt")); |
|
4273 test_KErrNone(r); |
|
4274 |
|
4275 r = timer1.CreateLocal(); |
|
4276 test_KErrNone(r); |
|
4277 timer1.After(status2,time); |
|
4278 User::WaitForRequest(status1,status2); |
|
4279 test_Compare(status1.Int(),!=,KRequestPending); |
|
4280 timer1.Cancel(); |
|
4281 timer1.Close(); |
|
4282 User::WaitForRequest(status2); |
|
4283 file.Close(); |
|
4284 |
|
4285 //******************************************** |
|
4286 // |
|
4287 // SetAttributes |
|
4288 // |
|
4289 TheFs.NotifyChange(ENotifyAttributes,status1,_L("\\PhantomFile_functionAttributes.txt")); |
|
4290 r = file.Open(TheFs,_L("\\Wellformed_functionAttributes.txt"),EFileWrite); |
|
4291 test_KErrNone(r); |
|
4292 r = file.SetAtt(KEntryAttHidden,KEntryAttSystem); |
|
4293 test_KErrNone(r); |
|
4294 |
|
4295 { |
|
4296 r = timer1.CreateLocal(); |
|
4297 test_KErrNone(r); |
|
4298 timer1.After(status2,time); |
|
4299 User::WaitForRequest(status1,status2); |
|
4300 test_Compare(status1.Int(),!=,KRequestPending); |
|
4301 timer1.Cancel(); |
|
4302 timer1.Close(); |
|
4303 User::WaitForRequest(status2); |
|
4304 } |
|
4305 file.Close(); |
|
4306 |
|
4307 //******************************************** |
|
4308 // |
|
4309 // File Write |
|
4310 // \\Wellformed_functionWrite.txt -> \\PhantomFile_functionWrite.txt |
|
4311 // |
|
4312 TheFs.NotifyChange(ENotifyWrite,status1,_L("\\PhantomFile_functionWrite.txt")); |
|
4313 r = file.Replace(TheFs,_L("\\Wellformed_functionWrite.txt"),EFileWrite); |
|
4314 test_KErrNone(r); |
|
4315 TBuf8<4> blah; |
|
4316 blah.Append(_L("Blah")); |
|
4317 r = file.Write(blah); |
|
4318 test_KErrNone(r); |
|
4319 { |
|
4320 r = timer1.CreateLocal(); |
|
4321 test_KErrNone(r); |
|
4322 timer1.After(status2,time); |
|
4323 User::WaitForRequest(status1,status2); |
|
4324 test_Compare(status1.Int(),!=,KRequestPending); |
|
4325 timer1.Cancel(); |
|
4326 timer1.Close(); |
|
4327 User::WaitForRequest(status2); |
|
4328 } |
|
4329 |
|
4330 file.Close(); |
|
4331 return KErrNone; |
|
4332 } |
|
4333 |
|
4334 TInt TestExternalNotificationsMalformed() |
|
4335 { |
|
4336 |
|
4337 TRequestStatus status1, status2; |
|
4338 RTimer timer1; |
|
4339 TInt r = timer1.CreateLocal(); |
|
4340 test_KErrNone(r); |
|
4341 TTimeIntervalMicroSeconds32 time = 5000000; |
|
4342 |
|
4343 //******************************************** |
|
4344 // |
|
4345 // Don't set file size |
|
4346 // |
|
4347 TheFs.NotifyChange(ENotifyWrite,status1,_L("\\PhantomFileMalformed_functionWrite.txt")); |
|
4348 RFile file; |
|
4349 r = file.Open(TheFs,_L("\\Malformed_functionWrite.txt"),EFileWrite); |
|
4350 test_KErrNone(r); |
|
4351 r = file.Write(_L8("abcd")); |
|
4352 test_Value(KErrArgument,r); |
|
4353 { |
|
4354 r = timer1.CreateLocal(); |
|
4355 test_KErrNone(r); |
|
4356 timer1.After(status2,time); |
|
4357 test.Printf(_L("Wait for timeout..")); |
|
4358 User::WaitForRequest(status1,status2); |
|
4359 test_Compare(status1.Int(),==,KRequestPending); |
|
4360 timer1.Cancel(); |
|
4361 timer1.Close(); |
|
4362 TheFs.NotifyChangeCancel(status1); |
|
4363 User::WaitForRequest(status1); |
|
4364 } |
|
4365 |
|
4366 //******************************************** |
|
4367 // |
|
4368 // Set new name incorrectly |
|
4369 // |
|
4370 TheFs.NotifyChange(ENotifyFile,status1,_L("\\PhantomFileMalformed_functionRename.txt")); |
|
4371 r = file.Rename(_L("\\Malformed_functionRename.txt")); |
|
4372 test_Value(KErrArgument,r); |
|
4373 { |
|
4374 r = timer1.CreateLocal(); |
|
4375 test_KErrNone(r); |
|
4376 timer1.After(status2,time); |
|
4377 test.Printf(_L("Wait for timeout..")); |
|
4378 User::WaitForRequest(status1,status2); |
|
4379 test_Compare(status1.Int(),==,KRequestPending) |
|
4380 timer1.Cancel(); |
|
4381 timer1.Close(); |
|
4382 TheFs.NotifyChangeCancel(status1); |
|
4383 User::WaitForRequest(status1); |
|
4384 } |
|
4385 |
|
4386 |
|
4387 file.Close(); |
|
4388 return KErrNone; |
|
4389 } |
|
4390 |
|
4391 void TestExternalNotifications() |
|
4392 { |
|
4393 test.Printf(_L("Test External Notifications (Load test file system)")); |
|
4394 |
|
4395 if(F32_Test_Utils::Is_SimulatedSystemDrive(TheFs,gDriveNum)) |
|
4396 { |
|
4397 test.Printf(_L("Not testing External Notifications on SimulatedSystemDrive")); |
|
4398 return; |
|
4399 } |
|
4400 |
|
4401 test.Printf(_L("Test External Notifications (get file system name)")); |
|
4402 TBuf<50> filesystem; |
|
4403 TInt r = TheFs.FileSystemName(filesystem,gDriveNum); |
|
4404 test_KErrNone(r); |
|
4405 test.Printf(_L("Test External Notifications (add new file system)")); |
|
4406 r = TheFs.AddFileSystem(KTestNotifyFileSystemExeName); |
|
4407 if(r != KErrNone && r!=KErrAlreadyExists) |
|
4408 { |
|
4409 test_KErrNone(r); |
|
4410 } |
|
4411 test.Printf(_L("Test External Notifications (dismount existing file system)")); |
|
4412 r = TheFs.DismountFileSystem(filesystem,gDriveNum); |
|
4413 test_KErrNone(r); |
|
4414 test.Printf(_L("Test External Notifications (mount new file system)")); |
|
4415 r = TheFs.MountFileSystem(KNotifyTestFileSystem,gDriveNum); |
|
4416 test_KErrNone(r); |
|
4417 |
|
4418 CHECK_NO_PENDING_REQUESTS; |
|
4419 |
|
4420 test.Printf(_L("Test External Notifications (Perform tests)")); |
|
4421 r = TestExternalNotificationsWellformedness(); |
|
4422 test_KErrNone(r); |
|
4423 |
|
4424 CHECK_NO_PENDING_REQUESTS; |
|
4425 |
|
4426 // only test this in UREL |
|
4427 // as in DEBUG it PANICS. |
|
4428 #if !defined _DEBUG |
|
4429 test.Printf(_L("Test External Notifications (Perform malformed tests (UREL only))")); |
|
4430 r = TestExternalNotificationsMalformed(); |
|
4431 test_KErrNone(r); |
|
4432 CHECK_NO_PENDING_REQUESTS; |
|
4433 #endif |
|
4434 |
|
4435 test.Printf(_L("Test External Notifications (Replace FS)")); |
|
4436 //Replace old FS. |
|
4437 r = TheFs.DismountFileSystem(KNotifyTestFileSystem,gDriveNum); |
|
4438 test_KErrNone(r); |
|
4439 r = TheFs.MountFileSystem(filesystem,gDriveNum); |
|
4440 test_KErrNone(r); |
|
4441 r = TheFs.RemoveFileSystem(KNotifyTestFileSystem); |
|
4442 test_KErrNone(r); |
|
4443 } |
4237 |
4444 |
4238 //----------------------------------------------------------------------- |
4445 //----------------------------------------------------------------------- |
4239 |
4446 |
4240 // |
4447 // |
4241 // Do all tests |
4448 // Do all tests |
4242 // |
4449 // |
4243 GLDEF_C void CallTestsL() |
4450 GLDEF_C void CallTestsL() |
4244 { |
4451 { |
4245 |
4452 TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum); |
|
4453 test_KErrNone(nRes); |
|
4454 |
4246 CreateTestDirectory(_L("\\F32-TST\\NOTIFY\\")); |
4455 CreateTestDirectory(_L("\\F32-TST\\NOTIFY\\")); |
4247 |
4456 |
4248 // Test RFs::NotifyChange() |
4457 // Test RFs::NotifyChange() |
4249 CHECK_NO_PENDING_REQUESTS; |
4458 CHECK_NO_PENDING_REQUESTS; |
4250 Test1(); |
4459 Test1(); |