kerneltest/f32test/plugins/version_2/src/t_plugin_v2.cpp
changeset 0 a41df078684a
child 8 538db54a451d
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-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 //
       
    15 
       
    16 
       
    17 
       
    18 
       
    19 #include <f32file.h>
       
    20 #include <f32dbg.h>
       
    21 #include <e32test.h>
       
    22 #include "t_server.h"
       
    23 #include "t_chlffs.h"
       
    24 #include "plugincommon.h"
       
    25 #include "premodifier_plugin.h"
       
    26 #include "modifier_plugin.h"
       
    27 #include "observer_plugin.h"
       
    28 #include "combinational_plugin.h"
       
    29 #include "combinational2_plugin.h"
       
    30 #include "stacked_plugin.h"
       
    31 #include "stacked2_plugin.h"
       
    32 #include "stacked3_plugin.h"
       
    33 #include "drivec_plugin.h"
       
    34 #include "drivez_plugin.h"
       
    35 #include "allsupporteddrives_plugin.h"
       
    36 #include "exclusiveaccess_plugin.h"
       
    37 #include "unremovable_plugin.h"
       
    38 
       
    39 #include <e32def.h>
       
    40 #include <e32def_private.h>
       
    41 
       
    42 RTest test(_L("Plugin Framework Version 2 Test"));
       
    43 
       
    44 #define _plugin_test(r)		if(!r) { dismountAllPlugins(); test(r); }
       
    45 
       
    46 
       
    47 class MyRPlugin : public RPlugin
       
    48 	{
       
    49 public:
       
    50 	void DoRequest(TInt aReqNo,TRequestStatus& aStatus) const;
       
    51 	void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1) const;
       
    52 	void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1,TDes8& a2) const;
       
    53 	TInt DoControl(TInt aFunction) const;
       
    54 	TInt DoControl(TInt aFunction,TDes8& a1) const;
       
    55 	TInt DoControl(TInt aFunction,TDes8& a1,TDes8& a2) const;
       
    56 	void DoCancel(TUint aReqMask) const;
       
    57 	};
       
    58 
       
    59 void dismountAllPlugins()
       
    60 	{
       
    61 	TheFs.DismountPlugin(KObserverPluginName);
       
    62 	TheFs.DismountPlugin(KModifierPluginName);
       
    63 	TheFs.DismountPlugin(KPreModifierPluginName);
       
    64 	TheFs.DismountPlugin(KCombinationalPluginName);
       
    65 	TheFs.DismountPlugin(KCombinational2PluginName);
       
    66 	TheFs.DismountPlugin(KAllSupportedDrivesPluginName);
       
    67 	TheFs.DismountPlugin(KDriveZPluginName);
       
    68 	TheFs.DismountPlugin(KDriveCPluginName);
       
    69 	TheFs.DismountPlugin(KStackedPluginName);
       
    70 	TheFs.DismountPlugin(KStacked2PluginName);
       
    71 	TheFs.DismountPlugin(KStacked3PluginName);
       
    72 	TheFs.DismountPlugin(KExclusiveAccessPluginName);
       
    73 	TheFs.DismountPlugin(KUnremovablePluginName);
       
    74 
       
    75 	TheFs.RemovePlugin(KObserverPluginName);
       
    76 	TheFs.RemovePlugin(KModifierPluginName);
       
    77 	TheFs.RemovePlugin(KPreModifierPluginName);
       
    78 	TheFs.RemovePlugin(KCombinationalPluginName);
       
    79 	TheFs.RemovePlugin(KCombinational2PluginName);
       
    80 	TheFs.RemovePlugin(KAllSupportedDrivesPluginName);
       
    81 	TheFs.RemovePlugin(KDriveZPluginName);
       
    82 	TheFs.RemovePlugin(KDriveCPluginName);
       
    83 	TheFs.RemovePlugin(KStackedPluginName);
       
    84 	TheFs.RemovePlugin(KStacked2PluginName);
       
    85 	TheFs.RemovePlugin(KStacked3PluginName);
       
    86 	TheFs.RemovePlugin(KExclusiveAccessPluginName);
       
    87 	TheFs.RemovePlugin(KUnremovablePluginName);
       
    88 	}
       
    89 
       
    90 inline void safe_test(TInt aError, TInt aLine, TText* aName)
       
    91 	{
       
    92 	if(aError!=KErrNone)
       
    93 		{
       
    94 		test.Printf(_L("Error: %d receieved on line %d\n"),aError,aLine);
       
    95 		dismountAllPlugins();
       
    96 		test.operator()(aError==KErrNone,aLine,(TText*)aName);
       
    97 		}
       
    98 	}
       
    99 
       
   100 inline void plugin_test(RTest& test, TInt aUniquePluginPos, TInt aLine, TText* aName)
       
   101 	{
       
   102 	__UHEAP_MARK;
       
   103 	MyRPlugin rplugin;
       
   104 	TInt error = KErrNone;
       
   105 	TInt lineNumber;
       
   106 	TPckg<TInt> errCodePckg(error);
       
   107 	TPckg<TInt> lineNumberPckg(lineNumber);
       
   108 
       
   109 	test.Next(_L("Open RPlugin connection"));
       
   110 	TInt r = rplugin.Open(TheFs,aUniquePluginPos);
       
   111 	if(r!=KErrNone)
       
   112 		{
       
   113 		dismountAllPlugins();
       
   114 		}
       
   115 
       
   116 	//This next lines aren't needed though I'm leaving them here
       
   117 	//for reference.
       
   118 	// ...
       
   119 	//const TText name[16] = (const TText *) Expand(__FILE__);
       
   120 	//TPckg<TText[16]> namePckg(name);
       
   121 	//test.operator()(r==KErrNone,aLine,(TText*)&namePckg());
       
   122 	// ...
       
   123 
       
   124 	//test for Open
       
   125 	test.operator()(r==KErrNone,aLine,(TText*)aName);
       
   126 
       
   127 	test.Next(_L("Check plugin for any errors"));
       
   128 	r = rplugin.DoControl(KPluginGetError,errCodePckg,lineNumberPckg);
       
   129 	//test for DoControl
       
   130 	if(r!=KErrNone)
       
   131 		{
       
   132 		dismountAllPlugins();
       
   133 		test.operator()(r==KErrNone,aLine,(TText*)aName);
       
   134 		}
       
   135 
       
   136 	if(error != KErrNone)
       
   137 		{
       
   138 		test.Printf(_L("Error code == %d, from lineNumber == %d"),error,lineNumber);
       
   139 		}
       
   140 
       
   141 	//test for actual error
       
   142 	if(r!=KErrNone)
       
   143 		{
       
   144 		dismountAllPlugins();
       
   145 		test.operator()(error==KErrNone,aLine,(TText*)aName);
       
   146 		}
       
   147 	rplugin.Close();
       
   148 	__UHEAP_MARKEND;
       
   149 	}
       
   150 
       
   151 
       
   152 
       
   153 void MyRPlugin::DoRequest(TInt aReqNo,TRequestStatus& aStatus) const
       
   154 	{
       
   155 	RPlugin::DoRequest(aReqNo,aStatus);
       
   156 	}
       
   157 void MyRPlugin::DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1) const
       
   158 	{
       
   159 	RPlugin::DoRequest(aReqNo,aStatus,a1);
       
   160 	}
       
   161 void MyRPlugin::DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1,TDes8& a2) const
       
   162 	{
       
   163 	RPlugin::DoRequest(aReqNo,aStatus,a1,a2);
       
   164 	}
       
   165 TInt MyRPlugin::DoControl(TInt aFunction) const
       
   166 	{
       
   167 	return RPlugin::DoControl(aFunction);
       
   168 	}
       
   169 TInt MyRPlugin::DoControl(TInt aFunction,TDes8& a1) const
       
   170 	{
       
   171 	return RPlugin::DoControl(aFunction,a1);
       
   172 	}
       
   173 TInt MyRPlugin::DoControl(TInt aFunction,TDes8& a1,TDes8& a2) const
       
   174 	{
       
   175 	return RPlugin::DoControl(aFunction,a1,a2);
       
   176 	}
       
   177 void MyRPlugin::DoCancel(TUint aReqMask) const
       
   178 	{
       
   179 	RPlugin::DoCancel(aReqMask);
       
   180 	}
       
   181 
       
   182 TInt ReplaceFiles(TDes16 &aPath, TDes8 &aContent, TInt aLine)
       
   183 	{
       
   184 	RFile file;
       
   185 	TInt r=KErrNone;
       
   186 
       
   187 	r = file.Replace(TheFs, aPath, EFileWrite);
       
   188 	test.operator()(r==KErrNone,aLine,_S("t_plugin_v2.cpp"));
       
   189 
       
   190 	r = file.Write(aContent);
       
   191 	test.operator()(r==KErrNone,aLine,_S("t_plugin_v2.cpp"));
       
   192 	file.Close();
       
   193 
       
   194 	return r;
       
   195 	}
       
   196 
       
   197 
       
   198 void SetupTestFiles()
       
   199 	{
       
   200 	test.Next(_L("Setting up test files"));
       
   201 
       
   202 	TBuf<40> path1;
       
   203 	TBuf<40> path2;
       
   204 	TBuf<40> path3;
       
   205 
       
   206 	TInt theDrive;
       
   207 	TInt r=TheFs.CharToDrive(gDriveToTest,theDrive);
       
   208 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   209 
       
   210 	path1.Append(gDriveToTest);
       
   211 	path1.Append(_L(":\\data\\oldtest.tst"));
       
   212 
       
   213 	path2.Append(gDriveToTest);
       
   214 	path2.Append(_L(":\\data\\"));
       
   215 
       
   216 	path3.Append(gDriveToTest);
       
   217 	path3.Append(_L(":\\data2\\"));
       
   218 
       
   219 
       
   220 	test.Next(_L("Setting up test files"));
       
   221 
       
   222 	r = TheFs.Delete(path1);
       
   223 	test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound);
       
   224 
       
   225 	r = TheFs.MkDir(path2);
       
   226 	test(r==KErrNone || r==KErrAlreadyExists);
       
   227 
       
   228 	r = TheFs.MkDir(path3);
       
   229 	test(r==KErrNone || r==KErrAlreadyExists);
       
   230 
       
   231 	}
       
   232 
       
   233 
       
   234 void LoadAndMountPlugins()
       
   235 	{
       
   236 	TInt r = KErrNone;
       
   237 
       
   238 	test.Next(_L("Loading Observer plugin"));
       
   239 	r = TheFs.AddPlugin(KObserverPluginFileName);
       
   240 	if (r == KErrAlreadyExists) r = KErrNone;
       
   241 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   242 
       
   243 	r = TheFs.MountPlugin(KObserverPluginName);
       
   244 	if (r == KErrInUse) r = KErrNone;
       
   245 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   246 
       
   247 	test.Next(_L("Loading PreModifier plugin"));
       
   248 	r = TheFs.AddPlugin(KPreModifierPluginFileName);
       
   249 	if (r == KErrAlreadyExists) r = KErrNone;
       
   250 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   251 
       
   252 	r = TheFs.MountPlugin(KPreModifierPluginName);
       
   253 	if (r == KErrInUse) r = KErrNone;
       
   254 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   255 
       
   256 	test.Next(_L("Loading Modifier plugin"));
       
   257 	r = TheFs.AddPlugin(KModifierPluginFileName);
       
   258 	if (r == KErrAlreadyExists) r = KErrNone;
       
   259 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   260 
       
   261 	r = TheFs.MountPlugin(KModifierPluginName,KPluginAutoAttach);
       
   262 	if (r == KErrInUse) r = KErrNone;
       
   263 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   264 
       
   265 	r = TheFs.MountPlugin(KModifierPluginName,20);
       
   266 	if(r==KErrInUse) r = KErrNone;
       
   267 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.exe"));
       
   268 
       
   269 
       
   270 	//Use RPlugin to communicate to the plugins which drive they should be
       
   271 	//testing on.
       
   272 	//This is needed because sometimes a plugin may open a different file etc and will need
       
   273 	//to know which drive it should be testing on.
       
   274 
       
   275 	MyRPlugin rplugin;
       
   276 	TPckg<TChar> drivePckg(gDriveToTest);
       
   277 
       
   278 	test.Next(_L("Open RPlugin connection for ModifierPlugin"));
       
   279 	r = rplugin.Open(TheFs,KModifierPos);
       
   280 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   281 
       
   282 	test.Next(_L("Send drive letter to test down to plugin"));
       
   283 	r = rplugin.DoControl(KPluginSetDrive,drivePckg);
       
   284 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   285 	rplugin.Close();
       
   286 
       
   287 	test.Next(_L("Open RPlugin connection for PreModifierPlugin"));
       
   288 	r = rplugin.Open(TheFs,KPreModifierPos);
       
   289 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   290 
       
   291 	test.Next(_L("Send drive letter to test down to plugin"));
       
   292 	r = rplugin.DoControl(KPluginSetDrive,drivePckg);
       
   293 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   294 
       
   295 	rplugin.Close();
       
   296 
       
   297 	// As an extra test, open an RPlugin handle but don't close to test subsession cleanup on session closure...
       
   298 
       
   299 	RFs myFs;
       
   300 	r = myFs.Connect();
       
   301 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   302 
       
   303 	r = rplugin.Open(myFs,KModifierPos);
       
   304 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   305 	
       
   306 	// Don't close:	rplugin.Close();
       
   307 
       
   308 	myFs.Close();
       
   309 	
       
   310 	// Test the memory cleanup for asynchronous request
       
   311 
       
   312 	r = rplugin.Open(TheFs,KModifierPos);
       
   313 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   314 	TRequestStatus aStatus; 
       
   315 	rplugin.DoRequest(1,aStatus,drivePckg);
       
   316 	User::WaitForRequest(aStatus);
       
   317 	rplugin.Close();
       
   318 		
       
   319 	}
       
   320 //-------------------------------------------------------------------------------------------------
       
   321 //! @SYMTestCaseID				KBASE-t_plugin_v2-1336
       
   322 //! @SYMTestType				CT
       
   323 //! @SYMTestCaseDesc			Client request to read data directly from a file
       
   324 //! @SYMPREQ					REQ7902
       
   325 //! @SYMTestPriority			High
       
   326 //! @SYMTestActions				TestReadFileDirect() disables intercepts on any mounted plugin.
       
   327 //!								Following this, it opens a test file and sends a read request directly
       
   328 //!								to the fileserver.
       
   329 //!
       
   330 //!								1.	Disable intercepts.
       
   331 //!								2.  Set up test file name and path.
       
   332 //!								3.	Open file for read access.
       
   333 //!								4.	Read data from test file.
       
   334 //!								5.	Close test file.
       
   335 //!								6.	Enable intercepts.
       
   336 //!
       
   337 //!
       
   338 //! @SYMTestExpectedResults		1.	Intercepts disabled without any panic
       
   339 //!								2.	Test file created without any panic
       
   340 //!								3.	File opened without any panic
       
   341 //!								4.	Read request completes by bypassing plug-in without any panic
       
   342 //!								5.	File close without any panic.
       
   343 //!								6.	Intercepts enabled.
       
   344 //!
       
   345 //! @SYMTestPriority			High
       
   346 //! @SYMTestStatus				Implemented
       
   347 //-------------------------------------------------------------------------------------------------
       
   348 void TestReadFileDirect()
       
   349 	{
       
   350 
       
   351 	//As the plugin is installed at this point, rather than removing it
       
   352 	//or not mounting it until after, lets disable intercepts
       
   353 	//and enabled them at the end of this function.
       
   354 	MyRPlugin rplugin;
       
   355 	TInt r = rplugin.Open(TheFs,KModifierPos);
       
   356 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   357 	TBool interceptsStatus;
       
   358 	TPckg<TBool> interceptsStatusDes(interceptsStatus);
       
   359 	test.Next(_L("RPlugin: togle itnercepts (Modifier)"));
       
   360 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   361 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   362 	test.Next(_L("Ensure that intercepts are now disabled"));
       
   363 	if(!interceptsStatus) r = KErrNone;
       
   364 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   365 	rplugin.Close();
       
   366 
       
   367 	interceptsStatus = ETrue;
       
   368 
       
   369 	r = rplugin.Open(TheFs,KObserverPos);
       
   370 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   371 	test.Next(_L("RPlugin: togle itnercepts (Observer)"));
       
   372 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   373 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   374 	test.Next(_L("Ensure that intercepts are now disabled"));
       
   375 	if(!interceptsStatus) r = KErrNone;
       
   376 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   377 	rplugin.Close();
       
   378 
       
   379 
       
   380 	RFile file;
       
   381 	TBuf8<4> narrow_buffer;
       
   382 	TBuf16<4> wide_buffer;
       
   383 	TBuf<256> filename;
       
   384 	TBuf8<10> content;
       
   385 
       
   386 	//setting up test files
       
   387 	filename.Append(gDriveToTest);
       
   388 	filename.Append(_L(":\\data\\test.txt"));
       
   389 	content.Copy(_L8("1234567890"));
       
   390 	ReplaceFiles(filename, content,__LINE__);
       
   391 
       
   392 	r = file.Open(TheFs, filename, EFileRead);
       
   393 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   394 
       
   395 	test.Next(_L("Reading from a file directly first time"));
       
   396 	r = file.Read(narrow_buffer); // -> returns data from pos 0 to 3
       
   397 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   398 	wide_buffer.Copy(narrow_buffer);
       
   399 	test.Printf(_L("read: %S\n"), &wide_buffer);
       
   400 
       
   401 	test.Next(_L("Reading from a file directly second time"));
       
   402 	r = file.Read(narrow_buffer); // -> returns data from pos 4 to 8
       
   403 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   404 	wide_buffer.Copy(narrow_buffer);
       
   405 	test.Printf(_L("read: %S\n"), &wide_buffer);
       
   406 
       
   407 	test.Next(_L("Reading from a file directly complete"));
       
   408 	file.Close();
       
   409 
       
   410 	//Turn intercepts back on.
       
   411     interceptsStatus = EFalse;
       
   412 
       
   413 	r = rplugin.Open(TheFs,KModifierPos);
       
   414 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   415 	test.Next(_L("RPlugin: togle itnercepts (Observer)"));
       
   416 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   417 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   418 	test.Next(_L("Ensure that intercepts are now enabled"));
       
   419 	if(interceptsStatus) r = KErrNone;
       
   420 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   421 	rplugin.Close();
       
   422 
       
   423 	interceptsStatus = EFalse;
       
   424 
       
   425 	r = rplugin.Open(TheFs,KObserverPos);
       
   426 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   427 	test.Next(_L("RPlugin: togle itnercepts (Observer)"));
       
   428 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   429 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   430 	test.Next(_L("Ensure that intercepts are now enabled"));
       
   431 	if(interceptsStatus) r = KErrNone;
       
   432 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   433 	rplugin.Close();
       
   434 
       
   435 	}
       
   436 //-------------------------------------------------------------------------------------------------
       
   437 //! @SYMTestCaseID				KBASE-t_plugin_v2-1337
       
   438 //! @SYMTestType				CT
       
   439 //! @SYMTestCaseDesc			Client request to read data via a plugin from a file
       
   440 //! @SYMPREQ					REQ7902
       
   441 //! @SYMTestPriority			High
       
   442 //! @SYMTestActions				TestReadFileDirect() opens a file for read access.
       
   443 //!								Following this, it sends a read request via a plugin to the fileserver.
       
   444 //!
       
   445 //!								1.	Set up test file name and path.
       
   446 //!								2.  Open file for read access.
       
   447 //!								3.	Read data from test file.
       
   448 //!								4.  Get current size of file.
       
   449 //!								5.  Read data from test file .
       
   450 //!								6.	Verify that the correct data was read from the test file.
       
   451 //!								7.	Close test file.
       
   452 //!
       
   453 //!
       
   454 //!
       
   455 //! @SYMTestExpectedResults		1.	Test file created without any panic.
       
   456 //!								2.	File opened without any panic.
       
   457 //!								3.	Read request completes by bypassing plug-in without any panic.
       
   458 //!								4.	Size of file returned without any panic.
       
   459 //!								5.	Read request completes by bypassing plug-in without any panic.
       
   460 //!								6.	Correct data read by from test file.
       
   461 //!								7.	File close without any panic.
       
   462 //!
       
   463 //!
       
   464 //! @SYMTestPriority			High
       
   465 //! @SYMTestStatus				Implemented
       
   466 //-------------------------------------------------------------------------------------------------
       
   467 void TestReadFileViaPlugin()
       
   468 	{
       
   469 	RFile file;
       
   470 	TBuf8<4> narrow_buffer;
       
   471 	narrow_buffer.FillZ(4);
       
   472 	TBuf16<4> wide_buffer;
       
   473 	wide_buffer.FillZ(4);
       
   474 
       
   475 	TBuf<256> filename;
       
   476 	TBuf8<10> content;
       
   477 
       
   478 	//setting up test files
       
   479 	filename.Append(gDriveToTest);
       
   480 	filename.Append(_L(":\\data\\test.tst"));
       
   481 	content.Copy(_L8("1234567890"));
       
   482 	ReplaceFiles(filename, content,__LINE__);
       
   483 
       
   484 	TInt r = file.Open(TheFs, filename, EFileRead);
       
   485 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   486 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   487 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   488 
       
   489 	test.Next(_L("Reading from a file via a plugin using CFsPlugin::FileRead first time"));
       
   490 	r = file.Read(narrow_buffer); // -> returns data from pos 0 to 3
       
   491 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   492 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   493 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   494 	wide_buffer.Copy(narrow_buffer);
       
   495 	RDebug::Print(_L("read: %S\n"), &wide_buffer);
       
   496 	TInt size=0;
       
   497 	r = file.Size(size);
       
   498 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   499 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   500 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   501 
       
   502 	RDebug::Print(_L("RFile::size = %d"),size);
       
   503 
       
   504 	test.Next(_L("Reading from a file via a plugin using CFsPlugin::FileRead second time"));
       
   505 	r = file.Read(narrow_buffer); // -> returns data from pos 4 to 8
       
   506 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   507 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   508 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   509 
       
   510 	wide_buffer.Copy(narrow_buffer);
       
   511 	RDebug::Print(_L("read: %S\n"), &wide_buffer);
       
   512 
       
   513 	test.Next(_L("Reading from a file via a plugin using CFsPlugin::FileRead complete"));
       
   514 	file.Close();
       
   515 	}
       
   516 //-------------------------------------------------------------------------------------------------
       
   517 //! @SYMTestCaseID				KBASE-t_plugin_v2-1338
       
   518 //! @SYMTestType				CT
       
   519 //! @SYMTestCaseDesc			Client request to write to a file directly
       
   520 //! @SYMPREQ					REQ7902
       
   521 //! @SYMTestPriority			High
       
   522 //! @SYMTestActions				TestWriteFileDirect() disables intercepts on any mounted plugin.
       
   523 //!								Following this, it opens a test file and sends a write request directly
       
   524 //!								to the fileserver.
       
   525 //!
       
   526 //!								1.	Disable intercepts.
       
   527 //!								2.  Set up test file name and path.
       
   528 //!								3.	Open file for write access.
       
   529 //!								4.	Write to test file.
       
   530 //!								5.  Seek to the beginning of test file.
       
   531 //!								6.  Read from test file.
       
   532 //!								7.  Verify that the correct data was read from the test file.
       
   533 //!								8.	Close test file.
       
   534 //!								9.	Enable intercepts.
       
   535 //!
       
   536 //!
       
   537 //! @SYMTestExpectedResults		1.	Intercepts disabled without any panic
       
   538 //!								2.	Test file created without any panic
       
   539 //!								3.	File opened without any panic
       
   540 //!								4.	Write request completes by bypassing plug-in without any panic
       
   541 //!								6.  Seek to beginning of test file completes without any panic.
       
   542 //!								5.  Read from test file completes without any panic.
       
   543 //!								6.  Correct data read by from test file.
       
   544 //!								7.	File close without any panic.
       
   545 //!								8.	Intercepts enabled.
       
   546 //!
       
   547 //! @SYMTestPriority			High
       
   548 //! @SYMTestStatus				Implemented
       
   549 //-------------------------------------------------------------------------------------------------
       
   550 void TestWriteFileDirect()
       
   551 	{
       
   552 	//As the plugin is installed at this point, rather than removing it
       
   553 	//or not mounting it until after, lets disable intercepts
       
   554 	//and enabled them at the end of this function.
       
   555 	MyRPlugin rplugin;
       
   556 	TInt r = rplugin.Open(TheFs,KModifierPos);
       
   557 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   558 	TBool interceptsStatus;
       
   559 	TPckg<TBool> interceptsStatusDes(interceptsStatus);
       
   560 	test.Next(_L("RPlugin: togle itnercepts (Modifier)"));
       
   561 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   562 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   563 	test.Next(_L("Ensure that intercepts are now disabled"));
       
   564 	r = interceptsStatus == EFalse;
       
   565 	if(r) r = KErrNone;
       
   566 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   567 	rplugin.Close();
       
   568 
       
   569 	interceptsStatus = ETrue;
       
   570 
       
   571 	r = rplugin.Open(TheFs,KObserverPos);
       
   572 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   573 	test.Next(_L("RPlugin: togle itnercepts (Observer)"));
       
   574 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   575 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   576 	test.Next(_L("Ensure that intercepts are now disabled"));
       
   577 	r = interceptsStatus == EFalse;
       
   578 	if(r) r = KErrNone;
       
   579 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   580 	rplugin.Close();
       
   581 
       
   582 
       
   583 
       
   584 	RFile file;
       
   585 	TBuf8<64> buffer;
       
   586 	buffer.FillZ(64);
       
   587     TBuf8<64> wbuffer;
       
   588 	wbuffer.FillZ(64);
       
   589     wbuffer.Copy(_L8("TestTestTest"));
       
   590 
       
   591 	TBuf<256> filename;
       
   592 	TBuf8<10> content;
       
   593 
       
   594 	//setting up test files
       
   595 	filename.Append(gDriveToTest);
       
   596 	filename.Append(_L(":\\data\\test.txt"));
       
   597 	content.Copy(_L8("1234567890"));
       
   598 	ReplaceFiles(filename, content,__LINE__);
       
   599 
       
   600     test.Next(_L("Opening file test.txt"));
       
   601     // we assume that file test.txt still exists
       
   602     r = file.Open(TheFs,filename, EFileWrite);
       
   603 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   604 
       
   605 	test.Next(_L("Writing to file test.txt"));
       
   606     r = file.Write(wbuffer);
       
   607 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   608 
       
   609 	test.Next(_L("Seeking to beginning of file test.txt"));
       
   610 	TInt pos = 0;
       
   611 	r = file.Seek(ESeekStart, pos);
       
   612 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   613 
       
   614 	test.Next(_L("Reading file test.txt"));
       
   615     r = file.Read(buffer);
       
   616 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   617 
       
   618 	test.Next(_L("Comparing buffers"));
       
   619 	r = wbuffer.Compare(buffer);
       
   620 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   621 
       
   622 	test.Next(_L("Closing file test.txt"));
       
   623     file.Close();
       
   624 
       
   625     //Turn intercepts back on.
       
   626     interceptsStatus = EFalse;
       
   627 
       
   628 	r = rplugin.Open(TheFs,KModifierPos);
       
   629 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   630 	test.Next(_L("RPlugin: togle itnercepts (Observer)"));
       
   631 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   632 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   633 	test.Next(_L("Ensure that intercepts are now enabled"));
       
   634 	if(interceptsStatus) r = KErrNone;
       
   635 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   636 	rplugin.Close();
       
   637 
       
   638 	interceptsStatus = EFalse;
       
   639 
       
   640 	r = rplugin.Open(TheFs,KObserverPos);
       
   641 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   642 	test.Next(_L("RPlugin: togle itnercepts (Observer)"));
       
   643 	r = rplugin.DoControl(KPluginToggleIntercepts,interceptsStatusDes);
       
   644 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   645 	test.Next(_L("Ensure that intercepts are now enabled"));
       
   646 	if(interceptsStatus) r = KErrNone;
       
   647 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   648 	rplugin.Close();
       
   649 
       
   650 	}
       
   651 //-------------------------------------------------------------------------------------------------
       
   652 //! @SYMTestCaseID				KBASE-t_plugin_v2-1339
       
   653 //! @SYMTestType				CT
       
   654 //! @SYMTestCaseDesc			Client request to write to a file via a plug-in
       
   655 //! @SYMPREQ					REQ7902
       
   656 //! @SYMTestPriority			High
       
   657 //! @SYMTestActions				TestWriteViaPlugin() opens a file for write access.
       
   658 //!								Following this, it sends a write request via a plugin to the fileserver.
       
   659 //!
       
   660 //!								1.	Set up test file name and path.
       
   661 //!								2.  Open file for write access.
       
   662 //!								3.	Write to test file.
       
   663 //!								4.  Seek to the beginning of test file.
       
   664 //!								5.  Read data from test file .
       
   665 //!								6.	Verify that the correct data was read from the test file.
       
   666 //!								7.	Close test file.
       
   667 //!
       
   668 //! @SYMTestExpectedResults		1.	Test file created without any panic.
       
   669 //!								2.	File opened without any panic.
       
   670 //!								3.	Read request completes by bypassing plug-in without any panic.
       
   671 //!								4.	Seek to beginning of test file completes without any panic.
       
   672 //!								5.	Read request completes by bypassing plug-in without any panic.
       
   673 //!								6.	Correct data read by from test file.
       
   674 //!								7.	File close without any panic.
       
   675 //!
       
   676 //! @SYMTestPriority			High
       
   677 //! @SYMTestStatus				Implemented
       
   678 //-------------------------------------------------------------------------------------------------
       
   679 void TestWriteFileViaPlugin()
       
   680 	{
       
   681 	RFile file;
       
   682 	TBuf8<64> buffer;
       
   683 	buffer.FillZ(64);
       
   684     TBuf8<64> wbuffer;
       
   685 	wbuffer.FillZ(64);
       
   686     wbuffer.Copy(_L8("TestTestTest"));
       
   687 
       
   688 
       
   689 	TBuf<256> filename;
       
   690 	TBuf8<10> content;
       
   691 
       
   692 	//setting up test files
       
   693 	filename.Append(gDriveToTest);
       
   694 	filename.Append(_L(":\\data\\test.tst"));
       
   695 	content.Copy(_L8("1234567890"));
       
   696 	ReplaceFiles(filename, content,__LINE__);
       
   697 
       
   698     test.Next(_L("TestWriteFileViaPlugin(): Opening file test.tst"));
       
   699     // we assume that file test.tst still exists
       
   700     TInt r = file.Open(TheFs, filename, EFileWrite);
       
   701 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   702 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   703 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   704 
       
   705 	test.Next(_L("Writing to file test.tst"));
       
   706     r = file.Write(0,wbuffer);
       
   707 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   708 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   709 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   710 
       
   711 	test.Next(_L("Seeking to beginning of file test.tst"));
       
   712 	TInt pos = 0;
       
   713 	r = file.Seek(ESeekStart, pos);
       
   714 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   715 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   716 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   717 
       
   718 	test.Next(_L("Reading file test.tst"));
       
   719 	TInt length = wbuffer.Length();
       
   720 	r = file.Read(buffer, length);
       
   721 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   722 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   723 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   724 
       
   725 	test.Next(_L("Comparing buffers"));
       
   726 	r = wbuffer.Compare(buffer);
       
   727 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   728 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   729 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   730 
       
   731 	test.Next(_L("Closing file test.tst"));
       
   732     file.Close();
       
   733 	}
       
   734 //-------------------------------------------------------------------------------------------------
       
   735 //! @SYMTestCaseID				KBASE-t_plugin_v2-1350
       
   736 //! @SYMTestType				CT
       
   737 //! @SYMTestCaseDesc			Client request to rename a file
       
   738 //! @SYMPREQ					REQ7901
       
   739 //! @SYMTestPriority			High
       
   740 //! @SYMTestActions				TestRename() opens a file for write access.
       
   741 //!								Following this, it sends a rename request via a plugin to the fileserver.
       
   742 //!
       
   743 //!								1.	Set up test file name and path.
       
   744 //!								2.  Open file for write access.
       
   745 //!								3.	Rename test file.
       
   746 //!								4.  Write to file.
       
   747 //!								5.  Rename test file again
       
   748 //!								6.	Close test file.
       
   749 //!
       
   750 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
   751 //!								2.	File opened without any panic.
       
   752 //!								3.	Rename request intercepted by plugin and completes without any panic.
       
   753 //!								4.	Write request comletes without any panic.
       
   754 //!								5.	Rename request intercepted by plugin and completes without any panic.
       
   755 //!								6.	File close without any panic.
       
   756 //!
       
   757 //! @SYMTestPriority			High
       
   758 //! @SYMTestStatus				Implemented
       
   759 //-------------------------------------------------------------------------------------------------
       
   760 void TestRename()
       
   761 	{
       
   762 	RFile file;
       
   763 
       
   764 	TBuf<256> filename1;
       
   765 	TBuf<256> filename2;
       
   766 
       
   767 	//setting up test files
       
   768 	filename1.Append(gDriveToTest);
       
   769 	filename1.Append(_L(":\\data\\renametest.tst"));
       
   770 
       
   771 	filename2.Append(gDriveToTest);
       
   772 	filename2.Append(_L(":\\Data\\test.tst\n"));
       
   773 
       
   774 	TInt r = TheFs.Delete(filename1);
       
   775 	if(r == KErrNotFound || r == KErrPathNotFound)
       
   776 		r = KErrNone;
       
   777 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   778 
       
   779 	test.Next(_L("TestRename(): Opening file test.tst"));
       
   780 	// we assume that file test.tst exists
       
   781 	r = file.Open(TheFs, filename2, EFileWrite);
       
   782 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   783 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   784 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   785 
       
   786 	filename1.Append(_L("\n"));
       
   787 	test.Next(_L("Renaming file test.tst to renametest.tst"));
       
   788 	r = file.Rename(filename1);
       
   789 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   790 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   791 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   792 
       
   793 	test.Next(_L("Write to file"));
       
   794 	r=file.Write(_L8("Hello World"),11);
       
   795 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   796 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   797 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   798 
       
   799 	file.Close();
       
   800 
       
   801 	test.Next(_L("Renaming file renametest.tst to test.tst"));
       
   802 	r = TheFs.Rename(filename1,filename2);
       
   803 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   804 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   805 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   806 
       
   807 	test.Next(_L("Closing renamed file renametest.tst"));
       
   808 	file.Close();
       
   809 	}
       
   810 //-------------------------------------------------------------------------------------------------
       
   811 //! @SYMTestCaseID				KBASE-t_plugin_v2-1343
       
   812 //! @SYMTestType				CT
       
   813 //! @SYMTestCaseDesc			Client request to open directory and read entries
       
   814 //! @SYMPREQ					REQ7901
       
   815 //! @SYMTestPriority			High
       
   816 //! @SYMTestActions				TestDir() opens a directory.
       
   817 //!								Following this, it sends a reads the directory entry and closes directory
       
   818 //!
       
   819 //!								1.	Set up path for directory and test files
       
   820 //!								2.  Open a directory
       
   821 //!								3.	Read directory entry via plugin.
       
   822 //!								4.  Close directory.
       
   823 //!								5.  Open another directory.
       
   824 //!								6.  Read directory entry directly
       
   825 //!								7.  Close directory.
       
   826 //!								8.  Compare entry read via plugin with entry read directly.
       
   827 //!								9.  Open another directory.
       
   828 //!								10. Read one entry via plugin
       
   829 //!								11. Compare Read One entry with Read Packed.
       
   830 //!								12. Close directory.
       
   831 //!
       
   832 //! @SYMTestExpectedResults		1.	Test path creat ed without any panic.
       
   833 //!								2.	Directory open request intercepted by plugin and directory opened without any panic.
       
   834 //!								3.	Directory read request intercepted by plugin and read entry completes without any panic.
       
   835 //!								4.	Directory close request comletes without any panic.
       
   836 //!								5.	Directory open request intercepted by plugin and directory opened without any panic.
       
   837 //!								6.	Directory read request bypasses plugin and read entry completes without any panic.
       
   838 //!								7.	Directory close request comletes without any panic.
       
   839 //!								8.	Enrties read are identical.
       
   840 //!								9.	Open another directory.
       
   841 //!								10. Read directory entry intercepted by plugin and read entry completes without any panic.
       
   842 //!								11. Enrties read are identical.
       
   843 //!								12. Directory close request comletes without any panic
       
   844 //!
       
   845 //! @SYMTestPriority			High
       
   846 //! @SYMTestStatus				Implemented
       
   847 //-------------------------------------------------------------------------------------------------
       
   848 void TestDir()
       
   849 	{
       
   850 	test.Next(_L("TestDir()"));
       
   851 
       
   852 	//READ MANY
       
   853 
       
   854 	// "Via PLugin"
       
   855 	RDir dir;
       
   856 
       
   857 	TBuf<256> filename1;
       
   858 	TBuf<256> filename2;
       
   859 
       
   860 	filename1.Append(gDriveToTest);
       
   861 	filename1.Append(_L(":\\"));
       
   862 
       
   863 	filename2.Append(gDriveToTest);
       
   864 	filename2.Append(_L(":\\Data\\"));
       
   865 
       
   866 	test.Next(_L("Opening directory "));
       
   867 
       
   868 	//Need to send which filename we want to read to the plugin
       
   869 	//This is a hack until there's a proper way of getting the directory filename.
       
   870 	test.Next(_L("Open RPlugin connection for KModifierPos"));
       
   871 	MyRPlugin rplugin;
       
   872 	TInt r = rplugin.Open(TheFs,KModifierPos);
       
   873 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   874 	test.Next(_L("Send dir name down to plugin"));
       
   875 	typedef TBuf<256> TDirName;
       
   876 	TPckg<TDirName> dirname1Pckg(filename1);
       
   877 	r = rplugin.DoControl(KPluginSetDirFullName,dirname1Pckg);
       
   878 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   879 	rplugin.Close();
       
   880 
       
   881 	 r = dir.Open(TheFs,filename1,KEntryAttMatchMask);
       
   882 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   883 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   884 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   885 
       
   886 	TEntryArray eA;
       
   887 	r = dir.Read(eA);
       
   888 	if(r==KErrEof) r = KErrNone;
       
   889 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   890 
       
   891 	TEntry a = eA[0];
       
   892 	RDebug::Print(_L("Filename : %S"),&a.iName);
       
   893 
       
   894 	test.Next(_L("Closing directory \\Data\\"));
       
   895 	dir.Close();
       
   896 
       
   897 
       
   898 
       
   899 
       
   900 	//Need to send which filename we want to read to the plugin
       
   901 	//This is a hack until there's a proper way of getting the directory filename.
       
   902 	test.Next(_L("Open RPlugin connection for KModifierPos"));
       
   903 	r = rplugin.Open(TheFs,KModifierPos);
       
   904 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   905 	test.Next(_L("Send dir name down to plugin"));
       
   906 	TPckg<TDirName> dirname2Pckg(filename2);
       
   907 	r = rplugin.DoControl(KPluginSetDirFullName,dirname2Pckg);
       
   908 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   909 	rplugin.Close();
       
   910 
       
   911 	test.Next(_L("Opening directory \\Data\\"));
       
   912 	r = dir.Open(TheFs,filename2,KEntryAttMatchMask);
       
   913 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   914 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   915 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   916 
       
   917 	// "Direct"
       
   918 	TEntryArray eA2;
       
   919 	r = dir.Read(eA2);
       
   920 	if(r==KErrEof) r = KErrNone;
       
   921 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   922 
       
   923 	TEntry a2 = eA2[0];
       
   924 	RDebug::Print(_L("Filename : %S"),&a2.iName);
       
   925 
       
   926 	test.Next(_L("Compare plugin and direct read on \\Data\\"));
       
   927 	test(a.iName.Compare(a2.iName));
       
   928 
       
   929 	test.Next(_L("Closing directory \\Data\\"));
       
   930 	dir.Close();
       
   931 
       
   932 
       
   933 
       
   934 
       
   935 
       
   936 	// READ ONE
       
   937 
       
   938 
       
   939 	//Need to send which filename we want to read to the plugin
       
   940 	//This is a hack until there's a proper way of getting the directory filename.
       
   941 	test.Next(_L("Open RPlugin connection for KModifierPos"));
       
   942 	r = rplugin.Open(TheFs,KModifierPos);
       
   943 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   944 	test.Next(_L("Send dir name down to plugin"));
       
   945 	r = rplugin.DoControl(KPluginSetDirFullName,dirname1Pckg);
       
   946 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   947 	rplugin.Close();
       
   948 
       
   949 
       
   950 	test.Next(_L("Opening directory "));
       
   951 	r = dir.Open(TheFs,filename1,KEntryAttMatchMask);
       
   952 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
   953 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
   954 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   955 
       
   956 	test.Next(_L("Read One entry via plugin - \\"));
       
   957 	TEntry oneEntry;
       
   958 	r= dir.Read(oneEntry);
       
   959 
       
   960 	test.Next(_L("Compare Read One entry with Read Packed 1st TEntry"));
       
   961 	RDebug::Print(_L("ReadOne Filename : %S"),&oneEntry.iName);
       
   962 
       
   963 	safe_test(oneEntry.iName.Compare(a.iName),__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
   964 
       
   965 	dir.Close();
       
   966 	}
       
   967 //-------------------------------------------------------------------------------------------------
       
   968 //! @SYMTestCaseID				KBASE-t_plugin_v2-1344
       
   969 //! @SYMTestType				CT
       
   970 //! @SYMTestCaseDesc			Client request to create and open a new file.
       
   971 //! @SYMPREQ					REQ8113
       
   972 //! @SYMTestPriority			High
       
   973 //! @SYMTestActions				TestCreate() creates and opens a new file.
       
   974 //!								Following this, it sends a write request to the file.
       
   975 //!
       
   976 //!								1.	Set up test file name and path.
       
   977 //!								2.  Delete any existing test file.
       
   978 //!								3.  Send create request to create and open a new file.
       
   979 //!								4.	Write to file.
       
   980 //!								5.	Delete file.
       
   981 //!								6.  Close test file.
       
   982 //!
       
   983 //! @SYMTestExpectedResults		1.	Test file created without any panic.
       
   984 //!								2.  Any existing test file deleted without any panic.
       
   985 //!								2.	Create request intercepted by plugin and completes without any panic.
       
   986 //!								3.  Write request comletes without any panic.
       
   987 //!								4.	Test file deleted without any panic.
       
   988 //!								6.  Test file close without any panic.
       
   989 //!
       
   990 //! @SYMTestPriority			High
       
   991 //! @SYMTestStatus				Implemented
       
   992 //-------------------------------------------------------------------------------------------------
       
   993 void TestCreate()
       
   994 	{
       
   995 	RFile file;
       
   996 
       
   997 	test.Next(_L("Creating file createtest.tst"));
       
   998 
       
   999 	TBuf<256> filename1;
       
  1000 
       
  1001 	//setting up test files
       
  1002 	filename1.Append(gDriveToTest);
       
  1003 	filename1.Append(_L(":\\data\\createtest.tst"));
       
  1004 
       
  1005 	TInt r = TheFs.Delete(filename1);
       
  1006 	if(r == KErrNotFound || r == KErrPathNotFound)
       
  1007 		r = KErrNone;
       
  1008 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1009 
       
  1010 	r = file.Create(TheFs, filename1, EFileWrite);
       
  1011 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1012 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1013 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1014 
       
  1015 	test.Next(_L("Write to file"));
       
  1016 	r=file.Write(_L8("Hello World"),11);
       
  1017 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1018 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1019 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1020 
       
  1021 	test.Next(_L("Closing created file createtest.tst"));
       
  1022 	file.Close();
       
  1023 
       
  1024 	r = TheFs.Delete(filename1);
       
  1025 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1026 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1027 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1028 	}
       
  1029 //-------------------------------------------------------------------------------------------------
       
  1030 //! @SYMTestCaseID				KBASE-t_plugin_v2-1345
       
  1031 //! @SYMTestType				CT
       
  1032 //! @SYMTestCaseDesc			Client request to open a file
       
  1033 //! @SYMPREQ					REQ8113
       
  1034 //! @SYMTestPriority			High
       
  1035 //! @SYMTestActions				TestOpen() opens a file for write access.
       
  1036 //!								Following this, it sends a write request via a plugin to the fileserver
       
  1037 //!
       
  1038 //!								1.	Set up test file name and path.
       
  1039 //!								2.  Open file for write access.
       
  1040 //!								3.	Write to file.
       
  1041 //!								4.  Close test file.
       
  1042 //!
       
  1043 //!
       
  1044 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
  1045 //!								2.	Open request intercepted by plugin and completes without any panic.
       
  1046 //!								3.  Write request comletes without any panic.
       
  1047 //!								4.	File close without any panic.
       
  1048 //!
       
  1049 //! @SYMTestPriority			High
       
  1050 //! @SYMTestStatus				Implemented
       
  1051 //-------------------------------------------------------------------------------------------------
       
  1052 void TestOpen()
       
  1053 	{
       
  1054 	RFile file;
       
  1055 
       
  1056 	TBuf<256> filename;
       
  1057 	TBuf8<10> content;
       
  1058 
       
  1059 	//setting up test files
       
  1060 	filename.Append(gDriveToTest);
       
  1061 	filename.Append(_L(":\\data\\test.tst"));
       
  1062 	content.Copy(_L8("1234567890"));
       
  1063 	ReplaceFiles(filename, content,__LINE__);
       
  1064 
       
  1065 	test.Next(_L("Opening file test.tst"));
       
  1066 	// we assume that file test.tst does not exists
       
  1067 	TInt r = file.Open(TheFs, filename, EFileWrite);
       
  1068 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1069 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1070 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1071 
       
  1072 	test.Next(_L("Write to file test.tst"));
       
  1073 	r=file.Write(_L8("Hello World"),11);
       
  1074 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1075 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1076 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1077 
       
  1078 	test.Next(_L("Closing created file test.tst"));
       
  1079 	file.Close();
       
  1080 	}
       
  1081 //-------------------------------------------------------------------------------------------------
       
  1082 //! @SYMTestCaseID				KBASE-t_plugin_v2-1348
       
  1083 //! @SYMTestType				CT
       
  1084 //! @SYMTestCaseDesc			Client request to create and open a temporary file.
       
  1085 //! @SYMPREQ					REQ8113
       
  1086 //! @SYMTestPriority			High
       
  1087 //! @SYMTestActions				TestTemp() sends a temp request via a plugin to the fileserver
       
  1088 //!								Following this, it writes to the file.
       
  1089 //!
       
  1090 //!								1.	Set up test path.
       
  1091 //!								2.  Send temp request to create and open a temporary file.
       
  1092 //!								3.	Write to file.
       
  1093 //!								4.  Close test file.
       
  1094 //!
       
  1095 //! @SYMTestExpectedResults		1.	Test path created without any panic.
       
  1096 //!								2.	Temp request intercepted by plugin and completes without any panic.
       
  1097 //!								3.  Write request comletes without any panic.
       
  1098 //!								4.	File close without any panic.
       
  1099 //!
       
  1100 //! @SYMTestPriority			High
       
  1101 //! @SYMTestStatus				Implemented
       
  1102 //-------------------------------------------------------------------------------------------------
       
  1103 void TestTemp()
       
  1104 	{
       
  1105 	RFile file;
       
  1106 	TFileName fileName;
       
  1107 
       
  1108 	TBuf<256> filename1;
       
  1109 	filename1.Append(gDriveToTest);
       
  1110 	filename1.Append(_L(":\\data\\"));
       
  1111 
       
  1112 	TInt r = file.Temp(TheFs, filename1,fileName, EFileWrite);
       
  1113 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1114 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1115 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1116 
       
  1117 	r=file.Write(_L8("Temp File"),9);
       
  1118 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1119 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1120 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1121 
       
  1122 	file.Close();
       
  1123 	}
       
  1124 //-------------------------------------------------------------------------------------------------
       
  1125 //! @SYMTestCaseID				KBASE-t_plugin_v2-1346
       
  1126 //! @SYMTestType				CT
       
  1127 //! @SYMTestCaseDesc			Client request to replace a file
       
  1128 //! @SYMPREQ					REQ8113
       
  1129 //! @SYMTestPriority			High
       
  1130 //! @SYMTestActions				TestReplace() opens a file for writing by creating a new file
       
  1131 //!								Following this, it sends a write request via a plugin to the fileserver.
       
  1132 //!                             It also replaces an existing file with another.
       
  1133 //!
       
  1134 //!								1.	Set up test file name and path.
       
  1135 //!								2.  Delete any existing test file.
       
  1136 //!								3.  Send replace request to create and open a new file for write.
       
  1137 //!								4.  Write to file.
       
  1138 //!								5.	Close test file.
       
  1139 //!								6.	Send replace request to create and open a new file for write.
       
  1140 //!								7.	Delete test files.
       
  1141 //!
       
  1142 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
  1143 //!								2.	Any existing file deleted without any panic.
       
  1144 //!								3.	Replace request intercepted by plugin and completes without any panic.
       
  1145 //!								4.  Write request comletes without any panic.
       
  1146 //!								5.	Test file close without any panic.
       
  1147 //!								5.	Test file deleted without any panic.
       
  1148 //!
       
  1149 //! @SYMTestPriority			High
       
  1150 //! @SYMTestStatus				Implemented
       
  1151 //-------------------------------------------------------------------------------------------------
       
  1152 void TestReplace()
       
  1153 	{
       
  1154 	RFile file;
       
  1155 
       
  1156 	test.Next(_L("Creating file replacetest.tst"));
       
  1157 
       
  1158 	TBuf<256> filename1;
       
  1159 	filename1.Append(gDriveToTest);
       
  1160 	filename1.Append(_L(":\\data\\replacetest.tst"));
       
  1161 
       
  1162 
       
  1163 	TBuf<256> filename2;
       
  1164 	filename2.Append(gDriveToTest);
       
  1165 	filename2.Append(_L(":\\data\\replacetest2.tst"));
       
  1166 
       
  1167 
       
  1168 	TInt r = TheFs.Delete(filename1);
       
  1169 	if(r == KErrNotFound || r == KErrPathNotFound)
       
  1170 		r = KErrNone;
       
  1171 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1172 
       
  1173 	r = file.Replace(TheFs, filename1, EFileWrite);
       
  1174 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1175 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1176 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1177 
       
  1178 	test.Next(_L("Write to file"));
       
  1179 	r=file.Write(_L8("Hello World"),11);
       
  1180 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1181 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1182 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1183 
       
  1184 	test.Next(_L("Closing replaced file replacetest.tst"));
       
  1185 	file.Close();
       
  1186 
       
  1187 	r = TheFs.Replace(filename1,filename2);
       
  1188 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1189 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1190 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1191 
       
  1192 	r = TheFs.Delete(filename1);
       
  1193 	if(r==KErrNotFound) r = KErrNone;
       
  1194 	else r = KErrGeneral;
       
  1195 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1196 
       
  1197 	r = TheFs.Delete(filename2);
       
  1198 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1199 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1200 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1201 	}
       
  1202 //-------------------------------------------------------------------------------------------------
       
  1203 //! @SYMTestCaseID				KBASE-t_plugin_v2-1347
       
  1204 //! @SYMTestType				CT
       
  1205 //! @SYMTestCaseDesc			Client request to read a section of a file
       
  1206 //! @SYMPREQ					REQ7902
       
  1207 //! @SYMTestPriority			High
       
  1208 //! @SYMTestActions				TestReadFileSection() creates and opens a file for writing.
       
  1209 //!								Following this, it reads a section of the file by sending a ReadFileSection
       
  1210 //!								request via a plugin to the fileserver.
       
  1211 //!
       
  1212 //!								1.	Set up test file name and path.
       
  1213 //!								2.  Delete any existing test file.
       
  1214 //!								3.  Send create request to create and open a test file for write.
       
  1215 //!								4.  Write to test file.
       
  1216 //!								5.	Close test file.
       
  1217 //!								6.	Send Readfilesection request to read a section of the testfile.
       
  1218 //!								7.	Verify that the correct section was read.
       
  1219 //!								8.	Delete test files.
       
  1220 //!
       
  1221 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
  1222 //!								2.	Any existing file deleted without any panic.
       
  1223 //!								3.	Create request completes without any panic.
       
  1224 //!								4.  Write request comletes without any panic.
       
  1225 //!								5.  close request comletes without any panic.
       
  1226 //!								6.  Readfilesection request intercepted by plugin and completes without any panic.
       
  1227 //!								7.	Correct file section read.
       
  1228 //!								8.	Test file deleted without any panic.
       
  1229 //!
       
  1230 //! @SYMTestPriority			High
       
  1231 //! @SYMTestStatus				Implemented
       
  1232 //-------------------------------------------------------------------------------------------------
       
  1233 void TestReadFileSection()
       
  1234 {
       
  1235 
       
  1236 	test.Next(_L("Reading a file section enter"));
       
  1237 
       
  1238 	RFile file;
       
  1239 
       
  1240 	TBuf<256> filename1;
       
  1241 	filename1.Append(gDriveToTest);
       
  1242 	filename1.Append(_L(":\\data\\testReadFileSection.tst"));
       
  1243 
       
  1244 
       
  1245 	TInt r = TheFs.Delete(filename1);
       
  1246 	if(r == KErrNotFound || r == KErrPathNotFound)
       
  1247 		r = KErrNone;
       
  1248 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1249 
       
  1250 	r = file.Create(TheFs, filename1, EFileWrite);
       
  1251 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1252 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1253 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1254 
       
  1255 	test.Next(_L("Write to file"));
       
  1256 	r=file.Write(0, _L8("Read File Section"));
       
  1257 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1258 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1259 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1260 
       
  1261 	file.Close();
       
  1262 
       
  1263 	TBuf8<64> temp1;
       
  1264 	temp1.FillZ(64);
       
  1265 
       
  1266 	test.Next(_L("ReadFileSection:Enter"));
       
  1267 	r=TheFs.ReadFileSection(filename1,0,temp1,9);
       
  1268 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1269 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1270 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1271 
       
  1272 	test.Printf(_L("ReadFileSection - read: %s\n"),&temp1);
       
  1273 	test.Printf(_L("ReadFileSection - temp1.Length()=%d\n"),temp1.Length());
       
  1274 
       
  1275 
       
  1276 	test.Next(_L("ReadFileSection:Exit"));
       
  1277 	test.Printf(_L("ReadFileSection - read: %s"),temp1.Ptr());
       
  1278 	TInt compare = (temp1.Length()==9);
       
  1279 	if(compare) compare = KErrNone;
       
  1280 	safe_test(compare,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1281 
       
  1282 	compare = (temp1==_L8("Read File")); // This should be .Compare()?
       
  1283 	if(compare) compare = KErrNone;
       
  1284 	safe_test(compare,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1285 
       
  1286 	test.Next(_L("Reading a file section complete"));
       
  1287 
       
  1288 	test.Next(_L("ReadFileSection:Delete"));
       
  1289 	r = TheFs.Delete(filename1);
       
  1290 	if(r == KErrNotFound || r == KErrPathNotFound)
       
  1291 		r = KErrNone;
       
  1292 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1293 
       
  1294 }
       
  1295 //-------------------------------------------------------------------------------------------------
       
  1296 //! @SYMTestCaseID				KBASE-t_plugin_v2-1342
       
  1297 //! @SYMTestType				CT
       
  1298 //! @SYMTestCaseDesc			Client request to change and get the size of a file
       
  1299 //! @SYMPREQ					REQ7901
       
  1300 //! @SYMTestPriority			High
       
  1301 //! @SYMTestActions				TestFileSize() creates and opens a file for read.
       
  1302 //!								Following this, it performs operations on the test file to set and change its size
       
  1303 //!								request via a plugin to the fileserver.
       
  1304 //!
       
  1305 //!								1.	Set up test file name and path.
       
  1306 //!								2.	Open first test file for read
       
  1307 //!								3	Retrieve size of test file.
       
  1308 //!								4	Close first test file
       
  1309 //!								5	Open second test file for read
       
  1310 //!								6	Retrieve size of test file
       
  1311 //!								7   Verify that size of both first and second files are the same
       
  1312 //!								8	Close second test file
       
  1313 //!								9.	Open third test file for write
       
  1314 //!								10	Retrieve size of test file.
       
  1315 //!								11	Change the size of test file by reducing the size.
       
  1316 //!								12.	Retrieve new size of test file.
       
  1317 //!								13.	Verify that new size of file is the same as the size to which the file was changed to.
       
  1318 //!								14.	Change the size of test file by increasing it.
       
  1319 //!								16.	Retrieve new size of test file.
       
  1320 //!								17.	Close third test file
       
  1321 //!								18.	Verify that new size of file is the same as the size to which the file was changed to.
       
  1322 
       
  1323 //!
       
  1324 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
  1325 //!								2.	Test files created without any panic.
       
  1326 //!								3.	First test file opened for read without any panic
       
  1327 //!								4.	KErrNone returned and current file size returned directly without any panic
       
  1328 //!								5.	First file closed with no panic
       
  1329 //!								6.	Second test file opened for read without any panic
       
  1330 //!								7.	KErrNone returned and current size of first file returned via  a plug in directly without any panic
       
  1331 //!								8.	Size of both files are the same.
       
  1332 //!								9.	Second file closed with no panic
       
  1333 //!								10.	Third test file opened for read without any panic
       
  1334 //!								11.	KErrNone returned  and current file size returned directly without any panic
       
  1335 //!								12.	KErrNone returned and file size changed directly without any panic
       
  1336 //!								13.	KErrNone returned and current file size returned directly without any panic
       
  1337 //!								14.	Size of both files are the same.
       
  1338 //!								15.	KErrNone and current file size changed directly without any panic
       
  1339 //!								16.	Current file size returned directly without any panic
       
  1340 //!								17.	Third file closed with no panic
       
  1341 //!								18.	Size of both files are the same.
       
  1342 //!
       
  1343 //! @SYMTestPriority			High
       
  1344 //! @SYMTestStatus				Implemented
       
  1345 //-------------------------------------------------------------------------------------------------
       
  1346 void TestFileSize()
       
  1347 	{
       
  1348 	RFile file;
       
  1349 
       
  1350 	// Drive thread Direct
       
  1351 	TBuf<256> filename1;
       
  1352 	TBuf<256> filename2;
       
  1353 	TBuf<256> filename3;
       
  1354 	TBuf8<10> content;
       
  1355 
       
  1356 	//setting up test files
       
  1357 	filename1.Append(gDriveToTest);
       
  1358 	filename1.Append(_L(":\\data\\test.size.2"));
       
  1359 	content.Copy(_L8("0987654321"));
       
  1360 	ReplaceFiles(filename1, content,__LINE__);
       
  1361 
       
  1362 	filename2.Append(gDriveToTest);
       
  1363 	filename2.Append(_L(":\\data\\test.size"));
       
  1364 	ReplaceFiles(filename2, content,__LINE__);
       
  1365 
       
  1366 	filename3.Append(gDriveToTest);
       
  1367 	filename3.Append(_L(":\\data\\test.setsize"));
       
  1368 	ReplaceFiles(filename3, content,__LINE__);
       
  1369 
       
  1370 	TInt r = file.Open(TheFs, filename1, EFileRead);
       
  1371     TInt size=0;
       
  1372     r = file.Size(size);
       
  1373 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1374 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1375 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1376     file.Close();
       
  1377 
       
  1378     //Via Plugin
       
  1379 	r = file.Open(TheFs, filename2, EFileRead);
       
  1380     TInt psize=0;
       
  1381     r = file.Size(psize);
       
  1382 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1383 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1384 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1385     file.Close();
       
  1386 
       
  1387     r = psize==size;
       
  1388     if(r) r = KErrNone;
       
  1389     safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.exe"));
       
  1390 
       
  1391     //Via Plugin
       
  1392 	r = file.Open(TheFs, filename3, EFileWrite);
       
  1393     size=0;
       
  1394     r = file.Size(size);
       
  1395 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1396 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1397 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1398 
       
  1399     r = file.SetSize(size-1);
       
  1400 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1401 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1402 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1403 
       
  1404     TInt endSize=0;
       
  1405     r = file.Size(endSize);
       
  1406 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1407 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1408 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1409 
       
  1410 	r = (endSize==size-1);
       
  1411 	if(r) r = KErrNone;
       
  1412 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1413 
       
  1414     r = file.SetSize(endSize+1);
       
  1415 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1416 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1417 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1418 
       
  1419     r = file.Size(endSize);
       
  1420 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1421 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1422 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1423 
       
  1424     file.Close();
       
  1425 
       
  1426     r = endSize==size;
       
  1427     if(r) r=KErrNone;
       
  1428 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1429 	}
       
  1430 //-------------------------------------------------------------------------------------------------
       
  1431 //! @SYMTestCaseID				KBASE-t_plugin_v2-1340
       
  1432 //! @SYMTestType				CT
       
  1433 //! @SYMTestCaseDesc			Client request to lock a section of a file
       
  1434 //! @SYMPREQ					REQ7902
       
  1435 //! @SYMTestPriority			High
       
  1436 //! @SYMTestActions				TestFileLock() creates and opens a file
       
  1437 //!								Following this, it performs operations on the test file to lock and unlock the file
       
  1438 //!								by sending request via a plugin to the fileserver.
       
  1439 //!
       
  1440 //!								1.	Set up test file name and path.
       
  1441 //!								2.	Open first test file for write
       
  1442 //!								3.	Open same test file read
       
  1443 //!								4.	Lock test file open for write.
       
  1444 //!								5.	Read data from test file open for read
       
  1445 //!								6.	Unlock test file opened for write.
       
  1446 //!								7.	Close opened files
       
  1447 //!								8.	Open second test file for write
       
  1448 //!								9.	Open same test file read
       
  1449 //!								10.	Lock test file open for write.
       
  1450 //!								11.	Read data from test file open for read
       
  1451 //!								12.	Unlock test file opened for write.
       
  1452 //!								13.	Close opened files
       
  1453 //!
       
  1454 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
  1455 //!								2   First test file opened for write without any panic
       
  1456 //!								3.	First test file opened for read without any panic
       
  1457 //!								4.	First test file is locked via plug-In without any panic
       
  1458 //!								5.	KErrLocked is returned from read request
       
  1459 //!								6.	Test file opened for write is unlocked without any panic
       
  1460 //!								7.	Second test file opened for write without any panic
       
  1461 //!								8.	Files closed with no panic
       
  1462 //!								9.	Second test file opened for read without any panic
       
  1463 //!								10.	Secondt test files is locked directly without any panic
       
  1464 //!								11.	KErrLocked is returned from read request
       
  1465 //!								12.	Test file opened for write is unlocked without any panic
       
  1466 //!								13.	Files closed with no panic
       
  1467 //!
       
  1468 //!
       
  1469 //! @SYMTestPriority			High
       
  1470 //! @SYMTestStatus				Implemented
       
  1471 //-------------------------------------------------------------------------------------------------
       
  1472 void TestFileLock()
       
  1473 	{
       
  1474 
       
  1475 	//Lock Via Plugin
       
  1476 	RFile file;
       
  1477     TBuf8<64> wbuffer;
       
  1478     wbuffer.Copy(_L8("TestTestTest"));
       
  1479 
       
  1480 	// Drive thread Direct
       
  1481 	TBuf<256> filename1;
       
  1482 	TBuf<256> filename2;
       
  1483 	TBuf8<10> content;
       
  1484 
       
  1485 	//setting up test files
       
  1486 	filename1.Append(gDriveToTest);
       
  1487 	filename1.Append(_L(":\\data\\test.lock"));
       
  1488 	content.Copy(_L8("0987654321"));
       
  1489 	ReplaceFiles(filename1, content,__LINE__);
       
  1490 
       
  1491 
       
  1492 	filename2.Append(gDriveToTest);
       
  1493 	filename2.Append(_L(":\\data\\test.tst"));
       
  1494 	content.Copy(_L8("1234567890"));
       
  1495 	ReplaceFiles(filename2, content,__LINE__);
       
  1496 
       
  1497 
       
  1498     test.Next(_L("Opening file test.lock"));
       
  1499 
       
  1500     TInt r = file.Open(TheFs, filename1, EFileShareReadersOrWriters | EFileWrite);
       
  1501 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1502 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1503 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1504 
       
  1505 	RFile file2;
       
  1506 	r = file2.Open(TheFs, filename1, EFileShareReadersOrWriters | EFileRead );
       
  1507 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1508 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1509 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1510 
       
  1511 	TBuf8<64> lockbuffer;
       
  1512 	r = file.Lock(0,2); // This will lock via plugin call to RFilePlugin::Lock
       
  1513 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1514 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1515 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1516 
       
  1517 	r = file2.Read(lockbuffer);
       
  1518 	// Test & Ensure KErrLocked returned.
       
  1519 	if(r==KErrLocked) r = KErrNone;
       
  1520 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1521 
       
  1522 	file2.Close();
       
  1523 
       
  1524 	//Unlock file (was locked in plugin)
       
  1525 	r = file.UnLock(0,2);
       
  1526 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1527 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1528 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1529 	
       
  1530 	file.Close();
       
  1531 
       
  1532 	//Lock via RFile
       
  1533     wbuffer.Copy(_L8("TestTestTest"));
       
  1534     test.Next(_L("TestFileLock(): Opening file test.tst"));
       
  1535     // we assume that file test.tst still exists
       
  1536     r = file.Open(TheFs, filename2, EFileShareReadersOrWriters | EFileWrite);
       
  1537 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1538 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1539 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1540 
       
  1541 	r = file2.Open(TheFs, filename2, EFileShareReadersOrWriters | EFileRead );
       
  1542 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1543 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1544 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1545 
       
  1546 	r = file.Lock(0,2); // This will lock via drive thread directly; RFile::Lock
       
  1547 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1548 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1549 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1550 
       
  1551 	r = file2.Read(lockbuffer);
       
  1552 
       
  1553 	r = (r==KErrLocked);
       
  1554 	if(r) r = KErrNone;
       
  1555 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1556 	file2.Close();
       
  1557 
       
  1558 	//Unlock file (was locked in plugin)
       
  1559 	r = file.UnLock(0,2);
       
  1560 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1561 	file.Close();
       
  1562 
       
  1563 	}
       
  1564 //-------------------------------------------------------------------------------------------------
       
  1565 //! @SYMTestCaseID				KBASE-t_plugin_v2-1341
       
  1566 //! @SYMTestType				CT
       
  1567 //! @SYMTestCaseDesc			Client request to get current file position
       
  1568 //! @SYMPREQ					REQ7901
       
  1569 //! @SYMTestPriority			High
       
  1570 //! @SYMTestActions				TestFileSeek() creates and opens a file for writing.
       
  1571 //!								Following this, it sends a request to get the current file position
       
  1572 //!
       
  1573 //!
       
  1574 //!								1.	Set up test file name and path.
       
  1575 //!								2.  Open first test file for read.
       
  1576 //!								3.  Send seek request to retrieve current file position of using a zero offset.
       
  1577 //!								4.  Close test file.
       
  1578 //!								5.	Open second test file for read
       
  1579 //!								6.	Send seek request to retrieve current file position of using a zero offset.
       
  1580 //!								7.  Close test file.
       
  1581 //!							    8.  Verify that current file position for both files are the same.
       
  1582 //!
       
  1583 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
  1584 //!								2.	Test file opened for read without any panic.
       
  1585 //!								3.	Seek request intercepted by plugin and completes without any panic.
       
  1586 //!								4.  Close request completes without any panic.
       
  1587 //!								5.  Test file opened for read without any panic.
       
  1588 //!								6.  Seek request intercepted by plugin and completes without any panic.
       
  1589 //!								7.	Close request completes without any panic.
       
  1590 //!								8.	Current file position for both files are the same.
       
  1591 //!
       
  1592 //! @SYMTestPriority			High
       
  1593 //! @SYMTestStatus				Implemented
       
  1594 //-------------------------------------------------------------------------------------------------
       
  1595 void TestFileSeek()
       
  1596 	{
       
  1597 	RFile file;
       
  1598 
       
  1599 	// Drive thread Direct
       
  1600 	TBuf<256> filename1;
       
  1601 	TBuf<256> filename2;
       
  1602 	TBuf8<10> content;
       
  1603 
       
  1604 	//setting up test files
       
  1605 	filename1.Append(gDriveToTest);
       
  1606 	filename1.Append(_L(":\\Data\\test.seek"));
       
  1607 	content.Copy(_L8("0987654321"));
       
  1608 	ReplaceFiles(filename1, content,__LINE__);
       
  1609 
       
  1610 
       
  1611 	filename2.Append(gDriveToTest);
       
  1612 	filename2.Append(_L(":\\data\\test.tst"));
       
  1613 	content.Copy(_L8("1234567890"));
       
  1614 	ReplaceFiles(filename2, content,__LINE__);
       
  1615 
       
  1616 	// Drive thread
       
  1617 	TInt r = file.Open(TheFs,filename2, EFileRead);
       
  1618     TInt pos=0;
       
  1619     TSeek mode = ESeekCurrent;
       
  1620     r = file.Seek(mode,pos);
       
  1621 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1622 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1623 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1624     file.Close();
       
  1625 
       
  1626     //Via Plugin
       
  1627 	r = file.Open(TheFs, filename1, EFileRead);
       
  1628     TInt pos2=0;
       
  1629     mode = ESeekCurrent;
       
  1630     r = file.Seek(mode,pos2);
       
  1631 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1632 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1633 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1634     file.Close();
       
  1635 
       
  1636     r = (pos == pos2);
       
  1637     if(r) r = KErrNone;
       
  1638     safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1639 	}
       
  1640 
       
  1641 //-------------------------------------------------------------------------------------------------
       
  1642 //! @SYMTestCaseID				KBASE-t_plugin_v2-1349
       
  1643 //! @SYMTestType				CT
       
  1644 //! @SYMTestCaseDesc			Client request to get and set both the attributes for a file or directory
       
  1645 //! @SYMPREQ					REQ7901
       
  1646 //! @SYMTestPriority			High
       
  1647 //! @SYMTestActions				TestFileEntry() sets up a test file
       
  1648 //!								Following this, it perfoms operations on the file and direct to get and set attributes
       
  1649 //!
       
  1650 //!
       
  1651 //!								1.	Set up test file name and path.
       
  1652 //!								2.	Send get entry request for test file
       
  1653 //!								3.	Set new date and time
       
  1654 //!								4.	Send set entry request to test file using new data and time
       
  1655 //!								5.	Send get entry request for test file
       
  1656 //!
       
  1657 //!
       
  1658 //! @SYMTestExpectedResults		1.	Test files created without any panic.
       
  1659 //!								2.	KErrNone returned and get entry request completes via plug in without any panic
       
  1660 //!								3.	Date and time set without any panic
       
  1661 //!								4.	KErrNone returned and set entry request completes via plug in without any panic
       
  1662 //!								5	KErrNone returned and get entry request completes via plug in without any panic
       
  1663 //!
       
  1664 //! @SYMTestPriority			High
       
  1665 //! @SYMTestStatus				Implemented
       
  1666 //-------------------------------------------------------------------------------------------------
       
  1667 void TestEntry()
       
  1668 	{
       
  1669 	TEntry entry;
       
  1670 
       
  1671 	//Drive thread Direct
       
  1672 	TBuf<256> filename1;
       
  1673 	TBuf8<10> content;
       
  1674 
       
  1675 	//setting up test files
       
  1676 	filename1.Append(gDriveToTest);
       
  1677 	filename1.Append(_L(":\\data\\test.size"));
       
  1678 	content.Copy(_L8("0987654321"));
       
  1679 	ReplaceFiles(filename1, content,__LINE__);
       
  1680 
       
  1681 	TInt r = TheFs.Entry(filename1, entry);
       
  1682 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1683 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1684 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1685 
       
  1686     test.Next(_L("Test SetEntry - Set to Read Only"));
       
  1687 	TDateTime dateTime(2008,EMay,27,15,35,0,0);
       
  1688 	TTime time(dateTime);
       
  1689 	r=TheFs.SetEntry(filename1,time,KEntryAttReadOnly,KEntryAttArchive);
       
  1690 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1691 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1692 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1693 
       
  1694 	TEntry entry1;
       
  1695 	r = TheFs.Entry(filename1, entry1);
       
  1696 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1697 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1698 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1699 
       
  1700 	r = entry1.iModified == dateTime;
       
  1701 	if(r) r = KErrNone;
       
  1702 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1703 
       
  1704 	r = (entry1.iAtt == ((entry.iAtt &~ KEntryAttArchive) | KEntryAttReadOnly));
       
  1705 	if(r) r = KErrNone;
       
  1706 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1707 
       
  1708     test.Next(_L("Test SetEntry - Remove Read Only attribute and compare"));
       
  1709 	r=TheFs.SetEntry(filename1,time,0,KEntryAttReadOnly);
       
  1710 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1711 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1712 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1713 
       
  1714 	r = TheFs.Entry(filename1, entry1);
       
  1715 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1716 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1717 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1718 
       
  1719 	r = entry1.iModified == dateTime;
       
  1720 	if(r) r = KErrNone;
       
  1721 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1722 
       
  1723 	r = (entry1.iAtt == (entry.iAtt &~ KEntryAttArchive));
       
  1724 	if(r) r = KErrNone;
       
  1725 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1726 	}
       
  1727 
       
  1728 //-------------------------------------------------------------------------------------------------
       
  1729 //! @SYMTestCaseID				KBASE-t_plugin_v2-1352
       
  1730 //! @SYMTestType				CT
       
  1731 //! @SYMTestCaseDesc			Testing various negative scenarios using lock ,read and close
       
  1732 //! @SYMPREQ					REQ8114
       
  1733 //! @SYMTestPriority			High
       
  1734 //! @SYMTestActions				TestComLock() sets up test files
       
  1735 //!								Following this, it perfoms lock, read and close operations the file via
       
  1736 //!								a  plugin
       
  1737 //!
       
  1738 //!
       
  1739 //! @SYMTestExpectedResults		Operations complete without any panic
       
  1740 //!
       
  1741 //! @SYMTestPriority			High
       
  1742 //! @SYMTestStatus				Implemented
       
  1743 //-------------------------------------------------------------------------------------------------
       
  1744 void TestComLock()
       
  1745 	{
       
  1746 	//Lock Via Plugin
       
  1747 	RFile file;
       
  1748 	RFile file2;
       
  1749     TBuf8<64> wbuffer;
       
  1750 	TBuf<256> filename1;
       
  1751 	TBuf<256> filename2;
       
  1752 	TBuf8<10> content;
       
  1753 
       
  1754     wbuffer.Copy(_L8("TestLockRead"));
       
  1755 
       
  1756 	//setting up test files
       
  1757 	filename1.Append(gDriveToTest);
       
  1758 	filename1.Append(_L(":\\data\\test.lockread"));
       
  1759 	content.Copy(_L8("0987654321"));
       
  1760 	ReplaceFiles(filename1, content,__LINE__);
       
  1761 
       
  1762 	filename2.Append(gDriveToTest);
       
  1763 	filename2.Append(_L(":\\data\\test.lockclose"));
       
  1764 	content.Copy(_L8("1234567890"));
       
  1765 	ReplaceFiles(filename2, content,__LINE__);
       
  1766 
       
  1767    	// Lock and post intercept read
       
  1768 	test.Next(_L("Opening file test.lockread"));
       
  1769 
       
  1770 	TInt r = file2.Open(TheFs, filename1, EFileShareReadersOrWriters | EFileWrite );
       
  1771 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1772 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1773 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1774 
       
  1775 	r = file.Open(TheFs, filename1, EFileShareReadersOrWriters | EFileRead );
       
  1776 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1777 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1778 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1779 
       
  1780 	//This will lock via plugin call to RFilePlugin::Lock and request a Read from post-interception
       
  1781 	r = file.Lock(0,2);
       
  1782 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1783 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1784 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1785 
       
  1786 	file2.Close();
       
  1787 
       
  1788 	//Unlock file (was locked in plugin)
       
  1789 	r = file.UnLock(0,2);
       
  1790 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1791 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1792 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1793 
       
  1794 	file.Close();
       
  1795 
       
  1796 	// Lock and post intercept close
       
  1797 	test.Next(_L("Opening file test.lockclose"));
       
  1798 
       
  1799 	r = file2.Open(TheFs, filename2, EFileShareReadersOrWriters | EFileWrite );
       
  1800 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1801 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1802 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1803 
       
  1804 	 r = file.Open(TheFs, filename2, EFileShareReadersOrWriters | EFileRead );
       
  1805 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1806 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1807 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1808 
       
  1809 	//This will lock via plugin call to RFilePlugin::Lock and request a close from post-interception
       
  1810 	r = file.Lock(0,2);
       
  1811 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1812 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1813 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1814 
       
  1815 	file2.Close();
       
  1816 	//Unlock file (was locked in plugin)
       
  1817 	r= file.UnLock(0,2);
       
  1818 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1819 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1820 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1821 
       
  1822 	file.Close();
       
  1823 	}
       
  1824 
       
  1825 //-------------------------------------------------------------------------------------------------
       
  1826 //! @SYMTestCaseID				KBASE-t_plugin_v2-1351
       
  1827 //! @SYMTestType				CT
       
  1828 //! @SYMTestCaseDesc			Testing various negative scenarios using read, readfilesection and size
       
  1829 //! @SYMPREQ					REQ7902
       
  1830 //! @SYMTestPriority			High
       
  1831 //! @SYMTestActions				TestComReadFileSection() sets up a test file
       
  1832 //!								Following this, it perfoms read request which is intercepted by a plugin
       
  1833 //!			                    and replaced by a readfilesection request
       
  1834 //!
       
  1835 //! @SYMTestExpectedResults	    Operations complete without any panic
       
  1836 //!
       
  1837 //! @SYMTestPriority			High
       
  1838 //! @SYMTestStatus				Implemented
       
  1839 //-------------------------------------------------------------------------------------------------
       
  1840 void TestComReadFileSection()
       
  1841 	{
       
  1842 	RFile file;
       
  1843 	TBuf8<4> narrow_buffer;
       
  1844 	narrow_buffer.FillZ(4);
       
  1845 	TBuf16<4> wide_buffer;
       
  1846 	wide_buffer.FillZ(4);
       
  1847 	TBuf<256> filename;
       
  1848 	TBuf8<10> content;
       
  1849 
       
  1850 	//setting up test files
       
  1851 	filename.Append(gDriveToTest);
       
  1852 	filename.Append(_L(":\\data\\test.readfile"));
       
  1853 	content.Copy(_L8("1234567890"));
       
  1854 	ReplaceFiles(filename, content,__LINE__);
       
  1855 
       
  1856 
       
  1857 	//opening test file
       
  1858 	TInt r = file.Open(TheFs,filename, EFileRead);
       
  1859 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1860 
       
  1861 	test.Next(_L("Reading from a file via a plugin using CFsPlugin::FileRead but issuing a ReadFileSection request"));
       
  1862 	r = file.Read(narrow_buffer); // -> returns data from pos 0 to 3
       
  1863 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1864 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1865 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1866 
       
  1867 	wide_buffer.Copy(narrow_buffer);
       
  1868 	RDebug::Print(_L("read: %S\n"), &wide_buffer);
       
  1869 	TInt size=0;
       
  1870 	r = file.Size(size);
       
  1871 	plugin_test(test,KModifierPos,__LINE__,(TText*)Expand("modifier_plugin.cpp"));
       
  1872 	plugin_test(test,KPreModifierPos,__LINE__,(TText*)Expand("premodifier_plugin.cpp"));
       
  1873 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1874 
       
  1875 	RDebug::Print(_L("RFile::size = %d"),size);
       
  1876 
       
  1877 	test.Next(_L("Reading from a file via a plugin using CFsPlugin::FileRead but issuing a ReadFileSection request complete"));
       
  1878 	file.Close();
       
  1879 	}
       
  1880 
       
  1881 
       
  1882 
       
  1883 void DismountAndUnloadPlugins()
       
  1884 	{
       
  1885 	test.Next(_L("Un-Loading Observer plugin"));
       
  1886 	TInt r = TheFs.DismountPlugin(KObserverPluginName);
       
  1887 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1888 
       
  1889 	r = TheFs.RemovePlugin(KObserverPluginName);
       
  1890 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1891 
       
  1892 	test.Next(_L("Un-Loading Modifier plugin"));
       
  1893 	r = TheFs.DismountPlugin(KModifierPluginName);
       
  1894 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1895 
       
  1896 	r = TheFs.RemovePlugin(KModifierPluginName);
       
  1897 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1898 
       
  1899 	test.Next(_L("Un-Loading Pre-Modifier plugin"));
       
  1900 	r = TheFs.DismountPlugin(KPreModifierPluginName);
       
  1901 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1902 
       
  1903 	r = TheFs.RemovePlugin(KPreModifierPluginName);
       
  1904 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1905 	}
       
  1906 //-------------------------------------------------------------------------------------------------
       
  1907 //! @SYMTestCaseID				KBASE-t_plugin_v2-1357
       
  1908 //! @SYMTestType				CT
       
  1909 //! @SYMTestCaseDesc			Testing plugin interception on certain drives
       
  1910 //! @SYMPREQ					REQ8109
       
  1911 //! @SYMTestPriority			High
       
  1912 //! @SYMTestActions				LoadPluginsForSpecificDriveTests() mounts three plugins and send request down the plugins
       
  1913 //!
       
  1914 //!								1.	Add and mount plugins.
       
  1915 //!								2.	Send replace and  open request.
       
  1916 //!								3.	close test files
       
  1917 //!								4.	Dismount plugins.
       
  1918 //!
       
  1919 //! @SYMTestExpectedResults	    1.  Plugin added and mounted without any panic.
       
  1920 //!								2.  Requests intercepted by plugins.
       
  1921 //!								3.	Test file closed with no panic.
       
  1922 //!								4.	Plugin dismount without any panic.
       
  1923 //!
       
  1924 //! @SYMTestPriority			High
       
  1925 //! @SYMTestStatus				Implemented
       
  1926 //-------------------------------------------------------------------------------------------------
       
  1927 void LoadPluginsForSpecificDriveTests()
       
  1928 	{
       
  1929 	TInt r = KErrNone;
       
  1930 
       
  1931 	//Add Plugins for specific drive.
       
  1932 	test.Next(_L("Loading DriveC plugin"));
       
  1933 	r = TheFs.AddPlugin(KDriveCPluginFileName);
       
  1934 	if (r == KErrAlreadyExists) r = KErrNone;
       
  1935 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1936 
       
  1937 	test.Next(_L("Mounting DriveC plugin on a different drive 25 (Z) : should return -5 KErrNotSupported"));
       
  1938 	r = TheFs.MountPlugin(KDriveCPluginName,25);
       
  1939 	test(r==KErrNotSupported);
       
  1940 
       
  1941 	test.Next(_L("Mounting DriveC plugin on drive 2 (C)"));
       
  1942 	r = TheFs.MountPlugin(KDriveCPluginName,2);
       
  1943 	if (r == KErrInUse) r = KErrNone;
       
  1944 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1945 
       
  1946 
       
  1947 	test.Next(_L("Loading DriveZ plugin"));
       
  1948 	r = TheFs.AddPlugin(KDriveZPluginFileName);
       
  1949 	if (r == KErrAlreadyExists) r = KErrNone;
       
  1950 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1951 
       
  1952 
       
  1953 	test.Next(_L("Mounting DriveZ plugin on drive (Z)"));
       
  1954 	r = TheFs.MountPlugin(KDriveZPluginName,KPluginMountDriveZ);
       
  1955 	if (r == KErrInUse) r = KErrNone;
       
  1956 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1957 
       
  1958 	test.Next(_L("Loading AllSupportedDrives plugin"));
       
  1959 	r = TheFs.AddPlugin(KAllSupportedDrivesPluginFileName);
       
  1960 	if (r == KErrAlreadyExists) r = KErrNone;
       
  1961 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1962 
       
  1963 
       
  1964 	test.Next(_L("Mounting AllSupportedDrives plugin on all supported drives"));
       
  1965 	r = TheFs.MountPlugin(KAllSupportedDrivesPluginName);
       
  1966 	if (r == KErrInUse) r = KErrNone;
       
  1967 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1968 
       
  1969 
       
  1970 	#ifdef __WINS__
       
  1971 		RFile file;
       
  1972 		r = file.Replace(TheFs,_L("x:\\drivexplugin.txt"),EFileWrite);
       
  1973 		safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1974 		file.Close();
       
  1975 
       
  1976 		r = file.Open(TheFs,_L("z:\\TEST\\clean.txt"),EFileRead);
       
  1977 		//if this fails, did you forget to do a \f32test\group\wintest ?
       
  1978 		plugin_test(test,KDriveZPos,__LINE__,(TText*)Expand("drivez_plugin.cpp"));
       
  1979 		safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp")); //if this fails, did you forget to do a \f32test\group\wintest ?
       
  1980 		file.Close(); 
       
  1981 
       
  1982 		r = file.Replace(TheFs,_L("c:\\drivecplugin.txt"),EFileWrite);
       
  1983 		plugin_test(test,KDriveCPos,__LINE__,(TText*)Expand("drivec_plugin.cpp"));
       
  1984 		safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1985 
       
  1986 		file.Close();
       
  1987 
       
  1988 	#endif
       
  1989 
       
  1990 	r = TheFs.DismountPlugin(KAllSupportedDrivesPluginName);
       
  1991 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1992 
       
  1993 	r = TheFs.RemovePlugin(KAllSupportedDrivesPluginName);
       
  1994 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1995 
       
  1996 	r = TheFs.DismountPlugin(KDriveZPluginName,25);
       
  1997 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  1998 
       
  1999 	r = TheFs.RemovePlugin(KDriveZPluginName);
       
  2000 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2001 
       
  2002 	r = TheFs.DismountPlugin(KDriveCPluginName,2);
       
  2003 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2004 
       
  2005 	r = TheFs.RemovePlugin(KDriveCPluginName);
       
  2006 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2007 	}
       
  2008 
       
  2009 //-------------------------------------------------------------------------------------------------
       
  2010 //! @SYMTestCaseID				KBASE-t_plugin_v2-1357
       
  2011 //! @SYMTestType				CT
       
  2012 //! @SYMTestCaseDesc			Testing unremovable plugins
       
  2013 //! @SYMPREQ					REQ8794
       
  2014 //! @SYMTestPriority			High
       
  2015 //! @SYMTestActions				LoadUnremovablePluginAndTest() mounts a unremovable plugin and attempts to
       
  2016 //!                             dismounts it
       
  2017 //!
       
  2018 //!								1.	Add and mount an unremovale plugin.
       
  2019 //!								2.	Attempt to dismount plugin.
       
  2020 //!								3.	Make plugin removable.
       
  2021 //!								4.	Attempt to dismount plugin.
       
  2022 //!
       
  2023 //! @SYMTestExpectedResults	    1.  Unremovale plugin added and mounted without any panic.
       
  2024 //!								2.  KErrAccessDenied returned and plugin does not dismount.
       
  2025 //!								3.	KErrNone returned
       
  2026 //!								4.	Plugin dismount without any panic.
       
  2027 
       
  2028 //! @SYMTestPriority			High
       
  2029 //! @SYMTestStatus				Implemented
       
  2030 //-------------------------------------------------------------------------------------------------
       
  2031 void LoadUnremovablePluginAndTest()
       
  2032 	{
       
  2033 	TInt r = KErrNone;
       
  2034 
       
  2035 	//Add Unremovable Plugin.
       
  2036 	test.Next(_L("Loading Unremovable plugin"));
       
  2037 	r = TheFs.AddPlugin(KUnremovablePluginFileName);
       
  2038 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2039 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2040 
       
  2041 	//Mount
       
  2042 	test.Next(_L("Mounting Unremovable Plugin"));
       
  2043 	r = TheFs.MountPlugin(KUnremovablePluginName);
       
  2044 	if (r == KErrInUse) r = KErrNone;
       
  2045 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2046 
       
  2047 	//Attempt to dismount this plugin
       
  2048 	//It's setup such that it is intercepting EFsDismountPlugin
       
  2049 	//and returns KErrAccessDenied.
       
  2050 	//Mount
       
  2051 	test.Next(_L("Attempting to dismount Unremovable Plugin"));
       
  2052 	r = TheFs.DismountPlugin(KUnremovablePluginName);
       
  2053 	r = (r==KErrPermissionDenied);
       
  2054 	if(r)
       
  2055 		{
       
  2056 		r = KErrNone;
       
  2057 		}
       
  2058 	else
       
  2059 		{
       
  2060 		r = KErrGeneral;
       
  2061 		}
       
  2062 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2063 
       
  2064 	MyRPlugin rplugin;
       
  2065 	TPckg<TBool> removablePckg(ETrue);
       
  2066 	test.Next(_L("Open RPlugin connection for UnremovablePlugin"));
       
  2067 	r = rplugin.Open(TheFs,KUnremovablePos);
       
  2068 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2069 	test.Next(_L("Set removable to true"));
       
  2070 	r = rplugin.DoControl(KPluginSetRemovable,removablePckg);
       
  2071 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2072 	rplugin.Close();
       
  2073 
       
  2074 	//Attempt to dismount this plugin
       
  2075 	//Should now work.
       
  2076 	test.Next(_L("Dismounting Unremovable Plugin"));
       
  2077 	r = TheFs.DismountPlugin(KUnremovablePluginName);
       
  2078 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2079 
       
  2080 	test.Next(_L("Removing Unremovable Plugin"));
       
  2081 	r = TheFs.RemovePlugin(KUnremovablePluginName);
       
  2082 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2083 	}
       
  2084 
       
  2085 //-------------------------------------------------------------------------------------------------
       
  2086 //! @SYMTestCaseID				KBASE-t_plugin_v2-1353
       
  2087 //! @SYMTestType				CT
       
  2088 //! @SYMTestCaseDesc			Testing that plug-ins can perform file reads and writes regardless of the permissions a file is open with.
       
  2089 //!
       
  2090 //! @SYMPREQ					REQ8114
       
  2091 //! @SYMTestPriority			High
       
  2092 //! @SYMTestActions				LoadExclusiveAccessPluginAndTest() mounts a plugin and performs operations on files
       
  2093 //!								open in exclusive access mode.
       
  2094 //!
       
  2095 //!								1.	Add and mount plugin.
       
  2096 //!								2.	Replace a file and open it in exclusive access mode.
       
  2097 //!								3.	Send a read request down.
       
  2098 //!								4.	Send a write request down.
       
  2099 //!								5.	Verify data sent down.
       
  2100 //!								6.	Close test file.
       
  2101 //!								7.	Dismount plugin.
       
  2102 //!
       
  2103 //! @SYMTestExpectedResults	    1.  Plugin added and mounted without any panic.
       
  2104 //!								2.  Request intercepted by plugin test file opened in exclisive access mode
       
  2105 //!								3.	Read request completes and KErrNone returned.
       
  2106 //!								4.	Write request completes and KErrNone returned.
       
  2107 //!								5.  Correct data returned.
       
  2108 //!								6.	Test file closed without any panic.
       
  2109 //!								7.	Plugin dismount without any panic.
       
  2110 //!
       
  2111 //!
       
  2112 //! @SYMTestPriority			High
       
  2113 //! @SYMTestStatus				Implemented
       
  2114 //-------------------------------------------------------------------------------------------------
       
  2115 void LoadExclusiveAccessPluginAndTest()
       
  2116 	{
       
  2117 	TInt r = KErrNone;
       
  2118 
       
  2119 	//Add Plugins for specific drive.
       
  2120 	test.Next(_L("Loading Exclusive Access plugin"));
       
  2121 	r = TheFs.AddPlugin(KExclusiveAccessPluginFileName);
       
  2122 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2123 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2124 
       
  2125 	//Mount
       
  2126 	test.Next(_L("Mounting Exclusive Access Plugin"));
       
  2127 	r = TheFs.MountPlugin(KExclusiveAccessPluginName);
       
  2128 	if (r == KErrInUse) r = KErrNone;
       
  2129 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2130 
       
  2131 	TBuf<256> filename;
       
  2132 	filename.Append(gDriveToTest);
       
  2133 	filename.Append(_L(":\\exclusiveaccess.file"));
       
  2134 
       
  2135 	test.Next(_L("Replacing file and opening it in ReadOnly mode"));
       
  2136 	test.Printf(_L("Filename : %s\n"), &filename);
       
  2137 
       
  2138 	//Replace a file and open it in exclusive access mode.
       
  2139 	RFile file;
       
  2140 	r = file.Replace(TheFs,filename, EFsFileRead | EFsFileWrite | EFileShareExclusive);
       
  2141 	plugin_test(test,KExclusiveAccessPos,__LINE__,(TText*)Expand("exclusiveaccess_plugin.cpp"));
       
  2142 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2143 
       
  2144 	//Try to send a read request down.
       
  2145 	TBuf8<256> rdata;
       
  2146 	r = file.Read(rdata);
       
  2147 	plugin_test(test,KExclusiveAccessPos,__LINE__,(TText*)Expand("exclusiveaccess_plugin.cpp"));
       
  2148 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2149 
       
  2150 	_LIT8(KData,"0123456789");
       
  2151 	TPtrC8 wdata(KData());
       
  2152 
       
  2153 	//Try to send a write request down.
       
  2154 	r = file.Write(wdata);
       
  2155 	plugin_test(test,KExclusiveAccessPos,__LINE__,(TText*)Expand("exclusiveaccess_plugin.cpp"));
       
  2156 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2157 
       
  2158 	//We need a way to determine whether the plugin did actually write anything.
       
  2159 	//Just read the data back and compare?
       
  2160 	r = file.Read(rdata);
       
  2161 	plugin_test(test,KExclusiveAccessPos,__LINE__,(TText*)Expand("exclusiveaccess_plugin.cpp"));
       
  2162 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp")); //read should be ok
       
  2163 	safe_test(rdata.Compare(wdata),__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2164 
       
  2165 	file.Close();
       
  2166 
       
  2167 	test.Next(_L("Un-Mounting ExclusiveAccess plugin"));
       
  2168 	r = TheFs.DismountPlugin(KExclusiveAccessPluginName);
       
  2169 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2170 
       
  2171 	test.Next(_L("Removing ExclusiveAccess plugin"));
       
  2172 	r = TheFs.RemovePlugin(KExclusiveAccessPluginName);
       
  2173 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2174 	}
       
  2175 //-------------------------------------------------------------------------------------------------
       
  2176 //! @SYMTestCaseID				KBASE-t_plugin_v2-1355
       
  2177 //! @SYMTestType				CT
       
  2178 //! @SYMTestCaseDesc			Testing various scenarios using write, replace, read, Entry and Dir
       
  2179 //!
       
  2180 //! @SYMPREQ					REQ8110
       
  2181 //! @SYMTestPriority			High
       
  2182 //! @SYMTestActions				LoadCombinationPluginAndTest() mounts two plugins and performs operations on files and directories
       
  2183 //!
       
  2184 //!
       
  2185 //!
       
  2186 //! @SYMTestExpectedResults	    Operations complete without any panic
       
  2187 //!
       
  2188 //!
       
  2189 //! @SYMTestPriority			High
       
  2190 //! @SYMTestStatus				Implemented
       
  2191 //-------------------------------------------------------------------------------------------------
       
  2192 void LoadCombinationPluginAndTest()
       
  2193 	{
       
  2194 	TInt r = KErrNone;
       
  2195 	RFile file;
       
  2196 	TBuf<256> filename1;
       
  2197 	TBuf<256> filename2;
       
  2198 	TBuf<256> filename3;
       
  2199 	TBuf<256> filename4;
       
  2200 	TBuf<256> filename6;
       
  2201 	TBuf<256> filename7;
       
  2202 	TBuf<256> filename8;
       
  2203 	TBuf<256> dirname1;
       
  2204 	TBuf<256> dirname2;
       
  2205 	TBuf<256> dirname3;
       
  2206 	TBuf8<10> content;
       
  2207 	TBuf8<64> wbuffer;
       
  2208 
       
  2209 	test.Next(_L("Loading Combinational2 plugin"));
       
  2210 	r = TheFs.AddPlugin(KCombinational2PluginFileName);
       
  2211 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2212 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2213 
       
  2214 	test.Next(_L("Mounting Combinational2 plugin"));
       
  2215 	r = TheFs.MountPlugin(KCombinational2PluginName);
       
  2216 	if (r == KErrInUse) r = KErrNone;
       
  2217 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2218 
       
  2219 	// Load Plugins
       
  2220 	test.Next(_L("Loading Combinational plugin"));
       
  2221 
       
  2222 	r = TheFs.AddPlugin(KCombinationalPluginFileName);
       
  2223 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2224 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2225 
       
  2226 	test.Next(_L("Mounting Combinational plugin"));
       
  2227 	r = TheFs.MountPlugin(KCombinationalPluginName);
       
  2228 	if (r == KErrInUse) r = KErrNone;
       
  2229 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2230 
       
  2231 	//Use RPlugin to communicate to the plugins which drive they should be
       
  2232 	//testing on.
       
  2233 	//This is needed because sometimes a plugin may open a different file etc and will need
       
  2234 	//to know which drive it should be testing on.
       
  2235 
       
  2236 	test.Next(_L("Open RPlugin connection for CombinationalPlugin"));
       
  2237 	MyRPlugin rplugin;
       
  2238 	r = rplugin.Open(TheFs,KCombinationalPos);
       
  2239 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2240 	TPckg<TChar> drivePckg(gDriveToTest);
       
  2241 
       
  2242 	test.Next(_L("Send drive letter to test down to plugin"));
       
  2243 	r = rplugin.DoControl(KPluginSetDrive,drivePckg);
       
  2244 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2245 	rplugin.Close();
       
  2246 
       
  2247 
       
  2248 
       
  2249 	//setting up test files
       
  2250 	filename1.Append(gDriveToTest);
       
  2251 	filename1.Append(_L(":\\combi.txt"));
       
  2252 	content.Copy(_L8("combi0"));
       
  2253 	ReplaceFiles(filename1, content,__LINE__);
       
  2254 
       
  2255 	filename2.Append(gDriveToTest);
       
  2256 	filename2.Append(_L(":\\combi1.txt"));
       
  2257 	content.Copy(_L8("combi1"));
       
  2258 	ReplaceFiles(filename2, content,__LINE__);
       
  2259 
       
  2260 	filename3.Append(gDriveToTest);
       
  2261 	filename3.Append(_L(":\\combi2.txt"));
       
  2262 	content.Copy(_L8("combi2"));
       
  2263 	ReplaceFiles(filename3, content,__LINE__);
       
  2264 
       
  2265 	filename4.Append(gDriveToTest);
       
  2266 	filename4.Append(_L(":\\combiReplace.txt"));
       
  2267 
       
  2268 	//File Tests
       
  2269 
       
  2270 	r = file.Open(TheFs, filename1, EFileWrite);
       
  2271 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2272 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2273 
       
  2274 	wbuffer.FillZ(64);
       
  2275 	wbuffer.Copy(_L8("CombiCombiCombi"));
       
  2276 	r = file.Write(2,wbuffer);
       
  2277 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2278 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2279 
       
  2280 	file.Close();
       
  2281 
       
  2282 	RFile file2;
       
  2283 
       
  2284 	r = file2.Replace(TheFs,filename4,EFileWrite);
       
  2285 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2286 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2287 	file2.Close(); //combiReplace
       
  2288 
       
  2289 	TEntry entry;
       
  2290 	r = TheFs.Entry(filename1,entry);
       
  2291 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2292 	plugin_test(test,KCombinational2Pos,__LINE__,(TText*)Expand("combinational2_plugin.cpp"));
       
  2293 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2294 
       
  2295 	TEntry entry2;
       
  2296 	r = TheFs.Entry(filename4,entry2);
       
  2297 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2298 	plugin_test(test,KCombinational2Pos,__LINE__,(TText*)Expand("combinational2_plugin.cpp"));
       
  2299 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2300 
       
  2301 	//DIRECTORY TESTS
       
  2302 
       
  2303 	//Lets make some directories (allow KErrAlreadyExists)
       
  2304 	//Then open 1 via RDir and then open the 2 from the plugin then open 3
       
  2305 	//Return the contents of 3, and then read 3's contents from
       
  2306 	// RDir and compare that it's the same.
       
  2307 
       
  2308 	dirname1.Append(gDriveToTest);
       
  2309 	dirname1.Append(_L(":\\dir1\\"));
       
  2310 
       
  2311 	dirname2.Append(gDriveToTest);
       
  2312 	dirname2.Append(_L(":\\dir2\\"));
       
  2313 
       
  2314 	dirname3.Append(gDriveToTest);
       
  2315 	dirname3.Append(_L(":\\dir3\\"));
       
  2316 
       
  2317 
       
  2318 	r = TheFs.MkDir(dirname1);
       
  2319 	if(r == KErrAlreadyExists) r = KErrNone;
       
  2320 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2321 
       
  2322 	r = TheFs.MkDir(dirname2);
       
  2323 	if(r == KErrAlreadyExists) r = KErrNone;
       
  2324 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2325 
       
  2326 	r = TheFs.MkDir(dirname3);
       
  2327 	if(r == KErrAlreadyExists) r = KErrNone;
       
  2328 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2329 
       
  2330 
       
  2331 	filename6.Append(gDriveToTest);
       
  2332 	filename7.Append(gDriveToTest);
       
  2333 	filename8.Append(gDriveToTest);
       
  2334 
       
  2335 	filename6.Append(_L(":\\dir1\\dir1.file"));
       
  2336 	filename7.Append(_L(":\\dir2\\dir2.file"));
       
  2337 	filename8.Append(_L(":\\dir3\\dir3.file"));
       
  2338 
       
  2339 	r = file.Replace(TheFs,filename6,EFileWrite);
       
  2340 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2341 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2342 	file.Close();
       
  2343 
       
  2344 	r = file.Replace(TheFs,filename7,EFileWrite);
       
  2345 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2346 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2347 	file.Close();
       
  2348 
       
  2349 	r = file.Replace(TheFs,filename8,EFileWrite);
       
  2350 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2351 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2352 	file.Close();
       
  2353 
       
  2354 	RDir dir;
       
  2355 	r = dir.Open(TheFs,dirname1,KEntryAttNormal);
       
  2356 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2357 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2358 
       
  2359 
       
  2360 	//Need to send which filename we want to read to the plugin
       
  2361 	//This is a hack until there's a proper way of getting the directory filename.
       
  2362 
       
  2363 	test.Next(_L("Open RPlugin connection for CombinationalPlugin"));
       
  2364 	r = rplugin.Open(TheFs,KCombinationalPos);
       
  2365 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2366 	test.Next(_L("Send dir name down to plugin"));
       
  2367 
       
  2368 	typedef TBuf<256> TDirName;
       
  2369 	TPckg<TDirName> dirname1Pckg(dirname1);
       
  2370 
       
  2371 	r = rplugin.DoControl(KPluginSetDirFullName,dirname1Pckg);
       
  2372 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2373 	rplugin.Close();
       
  2374 
       
  2375 	TEntryArray entryarray1;
       
  2376 	r = dir.Read(entryarray1); //returns read results for directory3
       
  2377 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2378 	if(r == KErrEof) r = KErrNone;
       
  2379 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2380 
       
  2381 	RDir dir2;
       
  2382 	r = dir2.Open(TheFs,dirname3,KEntryAttNormal);
       
  2383 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2384 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2385 
       
  2386 	test.Next(_L("Open RPlugin connection for CombinationalPlugin"));
       
  2387 	r = rplugin.Open(TheFs,KCombinationalPos);
       
  2388 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2389 	test.Next(_L("Send dir name down to plugin"));
       
  2390 	TPckg<TDirName> dirname3Pckg(dirname3);
       
  2391 	r = rplugin.DoControl(KPluginSetDirFullName,dirname3Pckg);
       
  2392 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2393 	rplugin.Close();
       
  2394 
       
  2395 	TEntryArray entryarray2;
       
  2396 	r = dir2.Read(entryarray2);
       
  2397 	plugin_test(test,KCombinationalPos,__LINE__,(TText*)Expand("combinational_plugin.cpp"));
       
  2398 	if(r == KErrEof) r = KErrNone;
       
  2399 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2400 
       
  2401 	//compare results
       
  2402 	safe_test(entryarray1[0].iName.Compare(entryarray2[0].iName),__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2403 
       
  2404 	//cleanup
       
  2405 	dir.Close();
       
  2406 	dir2.Close();
       
  2407 
       
  2408 	TheFs.DismountPlugin(KCombinational2PluginName);
       
  2409 	TheFs.DismountPlugin(KCombinationalPluginName);
       
  2410 	TheFs.RemovePlugin(KCombinational2PluginName);
       
  2411 	TheFs.RemovePlugin(KCombinationalPluginName);
       
  2412 	}
       
  2413 
       
  2414 //-------------------------------------------------------------------------------------------------
       
  2415 //! @SYMTestCaseID				KBASE-t_plugin_v2-1356
       
  2416 //! @SYMTestType				CT
       
  2417 //! @SYMTestCaseDesc			Testing various scenarios using write, replace, read, Entry and Dir
       
  2418 //!
       
  2419 //! @SYMPREQ					REQ8110
       
  2420 //! @SYMTestPriority			High
       
  2421 //! @SYMTestActions				LoadStackedPluginAndTest() mounts three plugins and performs read and write
       
  2422 //!								operations on a test file by sending the request down the stack of plugins
       
  2423 //!
       
  2424 //!
       
  2425 //!
       
  2426 //! @SYMTestExpectedResults	    Operations complete without any panic
       
  2427 //!
       
  2428 //!
       
  2429 //! @SYMTestPriority			High
       
  2430 //! @SYMTestStatus				Implemented
       
  2431 //-------------------------------------------------------------------------------------------------
       
  2432 void LoadStackedPluginAndTest()
       
  2433 	{
       
  2434 	RFile file;
       
  2435 	TBuf<256> filename;
       
  2436 
       
  2437 	//Setting up test files
       
  2438     filename.Append(gDriveToTest);
       
  2439 	filename.Append(_L(":\\test.stack"));
       
  2440 
       
  2441 	TBuf8<20> content;
       
  2442 	content.Copy(_L8("HELLO SYMBIAN WORLD1"));
       
  2443 	ReplaceFiles(filename, content,__LINE__);
       
  2444 
       
  2445 
       
  2446 	//Load Plugins
       
  2447 	test.Next(_L("Loading Stacked plugin"));
       
  2448 	TInt r = TheFs.AddPlugin(KStackedPluginFileName);
       
  2449 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2450 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2451 	test.Next(_L("Mounting Stacked plugin"));
       
  2452 	r = TheFs.MountPlugin(KStackedPluginName);
       
  2453 	if (r == KErrInUse) r = KErrNone;
       
  2454 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2455 
       
  2456 	//Using RPlugin to communicate to the plugins which drive they should be testing on.
       
  2457 	test.Next(_L("Open RPlugin connection for StackedPlugin"));
       
  2458 	MyRPlugin rplugin;
       
  2459 	r = rplugin.Open(TheFs,KStackedPos);
       
  2460 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2461 	TPckg<TChar> drivePckg(gDriveToTest);
       
  2462 	test.Next(_L("Send drive letter to test down to plugin"));
       
  2463 	r = rplugin.DoControl(KPluginSetDrive,drivePckg);
       
  2464 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2465 	rplugin.Close();
       
  2466 
       
  2467 	test.Next(_L("Loading Stacked2 plugin"));
       
  2468 	r = TheFs.AddPlugin(KStacked2PluginFileName);
       
  2469 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2470 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2471 	test.Next(_L("Mounting Stacked2 plugin"));
       
  2472 	r = TheFs.MountPlugin(KStacked2PluginName);
       
  2473 	if (r == KErrInUse) r = KErrNone;
       
  2474 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2475 
       
  2476 	test.Next(_L("Loading Stacked3 plugin"));
       
  2477 	r = TheFs.AddPlugin(KStacked3PluginFileName);
       
  2478 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2479 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2480 	test.Next(_L("Mounting Stacked3 plugin"));
       
  2481 	r = TheFs.MountPlugin(KStacked3PluginName);
       
  2482 	if (r == KErrInUse) r = KErrNone;
       
  2483 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2484 
       
  2485 
       
  2486 
       
  2487 
       
  2488 	//Setting up test data
       
  2489     TBuf8<20> wbuffer;
       
  2490 	wbuffer.FillZ(20);
       
  2491 	wbuffer.Copy(_L8("HELLO WORLD  SYMBIAN"));
       
  2492 
       
  2493     TBuf8<20> rbuffer;
       
  2494 	rbuffer.FillZ(20);
       
  2495 
       
  2496 	//Open  test file and send a write request
       
  2497 	r = file.Open(TheFs, filename, EFileWrite);
       
  2498 	plugin_test(test,KStackedPos,__LINE__,(TText*)Expand("stacked_plugin.cpp"));
       
  2499 	plugin_test(test,KStacked2Pos,__LINE__,(TText*)Expand("stacked2_plugin.cpp"));
       
  2500 	plugin_test(test,KStacked3Pos,__LINE__,(TText*)Expand("stacked3_plugin.cpp"));
       
  2501 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2502 
       
  2503 	//Writing to test file via plugins
       
  2504 	test.Next(_L("Writing to file test.stack"));
       
  2505     r = file.Write(wbuffer);
       
  2506     plugin_test(test,KStackedPos,__LINE__,(TText*)Expand("stacked_plugin.cpp"));
       
  2507     plugin_test(test,KStacked2Pos,__LINE__,(TText*)Expand("stacked2_plugin.cpp"));
       
  2508     plugin_test(test,KStacked3Pos,__LINE__,(TText*)Expand("stacked3_plugin.cpp"));
       
  2509 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2510 
       
  2511 	//Reading from test files
       
  2512 	test.Next(_L("Reading file test.stack"));
       
  2513 	plugin_test(test,KStackedPos,__LINE__,(TText*)Expand("stacked_plugin.cpp"));
       
  2514 	plugin_test(test,KStacked2Pos,__LINE__,(TText*)Expand("stacked2_plugin.cpp"));
       
  2515 	plugin_test(test,KStacked3Pos,__LINE__,(TText*)Expand("stacked3_plugin.cpp"));
       
  2516     r = file.Read(rbuffer);
       
  2517 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2518 
       
  2519 	// Check data returned
       
  2520 	test.Next(_L("Comparing buffers"));
       
  2521 	r = wbuffer.Compare(rbuffer);
       
  2522 	plugin_test(test,KStackedPos,__LINE__,(TText*)Expand("stacked_plugin.cpp"));
       
  2523 	plugin_test(test,KStacked2Pos,__LINE__,(TText*)Expand("stacked2_plugin.cpp"));
       
  2524 	plugin_test(test,KStacked3Pos,__LINE__,(TText*)Expand("stacked3_plugin.cpp"));
       
  2525 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2526 
       
  2527 	file.Close();
       
  2528 
       
  2529 	// Dismounting Plugins
       
  2530 	r = TheFs.DismountPlugin(KStacked3PluginName);
       
  2531 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2532 	r = TheFs.DismountPlugin(KStacked2PluginName);
       
  2533 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2534 	r = TheFs.DismountPlugin(KStackedPluginName);
       
  2535 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2536 
       
  2537 	// Removing Plugins
       
  2538 	r = TheFs.RemovePlugin(KStacked3PluginName);
       
  2539 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2540 	r = TheFs.RemovePlugin(KStacked2PluginName);
       
  2541 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2542 	r = TheFs.RemovePlugin(KStackedPluginName);
       
  2543 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2544 	}
       
  2545 
       
  2546 
       
  2547 GLDEF_C void CallTestsL()
       
  2548 	{
       
  2549 	__UHEAP_MARK;
       
  2550 	TInt theDrive;
       
  2551 	TInt r = TheFs.CharToDrive(gDriveToTest,theDrive);
       
  2552 	test(r == KErrNone);
       
  2553 
       
  2554 	TVolumeInfo volInfo;
       
  2555 	r = TheFs.Volume(volInfo, theDrive);
       
  2556 	test (r == KErrNone);
       
  2557 
       
  2558 	TDriveInfo drvInfo;
       
  2559 	r = TheFs.Drive(drvInfo,theDrive);
       
  2560 	test (r == KErrNone);
       
  2561 
       
  2562 	if(drvInfo.iType == EMediaRam || drvInfo.iType == EMediaRom || drvInfo.iMediaAtt == KMediaAttWriteProtected || drvInfo.iMediaAtt == KMediaAttLocked)
       
  2563 		{
       
  2564 		test.Printf(_L("Local Buffers are not supported on RAM or ROM drives\n"));
       
  2565 		if(drvInfo.iMediaAtt == KMediaAttLocked)
       
  2566 			{
       
  2567 			test.Printf(_L("This media is locked. Drive %d\n"),theDrive);
       
  2568 			}
       
  2569 		test.Printf(_L("Skipping Test\n"));
       
  2570 		return;
       
  2571 		}
       
  2572 	
       
  2573 	test.Next(_L("Loading Observer plugin"));
       
  2574 	r = TheFs.AddPlugin(KObserverPluginFileName);
       
  2575 	if (r == KErrAlreadyExists) r = KErrNone;
       
  2576 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2577 
       
  2578 	r = TheFs.MountPlugin(KObserverPluginName, (TUint)gDriveToTest.GetUpperCase() - 65);
       
  2579 	if (r == KErrNotSupported)
       
  2580 		{
       
  2581 		test.Printf(_L("Plugins are not supported on pagable drives.\nSkipping test.\n"));
       
  2582 
       
  2583 		r = TheFs.RemovePlugin(KObserverPluginName);
       
  2584 		safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2585 		
       
  2586 		return;
       
  2587 		}
       
  2588 	
       
  2589 	test.Next(_L("Un-Loading Observer plugin"));
       
  2590 	r = TheFs.DismountPlugin(KObserverPluginName);
       
  2591 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2592 
       
  2593 	r = TheFs.RemovePlugin(KObserverPluginName);
       
  2594 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2595 
       
  2596 	TBuf<256> theFSName;
       
  2597 
       
  2598 	r = TheFs.FileSystemName(theFSName, theDrive);
       
  2599 
       
  2600 	TBool Win32Filesystem = (theFSName.CompareF(_L("Win32")) == 0);
       
  2601 
       
  2602     if(!Win32Filesystem)
       
  2603         {
       
  2604 		// Drive is not mapped to local pc filesystem so can be formatted
       
  2605 		test.Next(_L("Formating Drive......... "));
       
  2606 		Format(theDrive);
       
  2607 		}
       
  2608 
       
  2609 	// This should be changed to an actual mechanism of determining if the drives filesystem and extensions has local buffer support
       
  2610 	TBool LocalBufferSupported = ETrue;
       
  2611 
       
  2612 	if (!LocalBufferSupported)
       
  2613 		{
       
  2614 		if((volInfo.iDrive.iType == EMediaRam) && !Win32Filesystem)
       
  2615 			{
       
  2616 			test.Printf(_L("Local Buffers are not supported on RAM drive\n"));
       
  2617 			test.Printf(_L("Skipping Test\n"));
       
  2618 			return;
       
  2619 			}
       
  2620 		else if(IsFileSystemLFFS(TheFs, theDrive))
       
  2621 			{
       
  2622 			test.Printf(_L("Local Buffers are not supported on LFFS drives\n"));
       
  2623 			test.Printf(_L("Skipping Test\n"));
       
  2624 			return;
       
  2625 			}
       
  2626 		else
       
  2627 			{
       
  2628 			test.Printf(_L("Error: Local Buffers are not supported on the selected drive\n"));
       
  2629 			test(EFalse);
       
  2630 			}
       
  2631 		}
       
  2632 
       
  2633 	TBuf<10> extensionName;
       
  2634 	for(TInt i = 0; i < 2; i++)
       
  2635 		{
       
  2636 		r = TheFs.ExtensionName(extensionName,CurrentDrive(),i);
       
  2637 		if(r==KErrNone && extensionName.Compare(_L("Nandftl")) == 0)
       
  2638 			{
       
  2639 			test.Printf(_L("Local Buffers are not supported on the nandftl extension\n"));
       
  2640 			test.Printf(_L("Skipping Test\n"));
       
  2641 			return;
       
  2642 			}
       
  2643 		}
       
  2644 
       
  2645 	SetupTestFiles();
       
  2646 
       
  2647 
       
  2648 
       
  2649 
       
  2650 	test.Next(_L("////////////////////////////"));
       
  2651 	test.Next(_L("////////////////////////////"));
       
  2652 	test.Next(_L("////////////////////////////"));
       
  2653 	test.Next(_L("////////////////////////////"));
       
  2654 
       
  2655 	test.Next(_L("Reading a file section enter"));
       
  2656 
       
  2657 	RFile file;
       
  2658 	TBuf<256> filename1;
       
  2659 	filename1.Append(gDriveToTest);
       
  2660 	filename1.Append(_L(":\\data\\testReadFileSection.tst"));
       
  2661 
       
  2662 
       
  2663 	r = TheFs.Delete(filename1);
       
  2664 	if(r == KErrNotFound || r == KErrPathNotFound)
       
  2665 		r = KErrNone;
       
  2666 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2667 
       
  2668 	r = file.Create(TheFs, filename1, EFileWrite);
       
  2669 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2670 
       
  2671 	test.Next(_L("Write to file"));
       
  2672 	r=file.Write(0, _L8("Read File Section"));
       
  2673 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2674 
       
  2675 	file.Close();
       
  2676 
       
  2677 	TBuf8<64> temp1;
       
  2678 	temp1.FillZ(64);
       
  2679 
       
  2680 	test.Next(_L("ReadFileSection:Enter"));
       
  2681 	r=TheFs.ReadFileSection(filename1,0,temp1,9);
       
  2682 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2683 
       
  2684 	TBuf16<64> temp1_wide;
       
  2685 	temp1_wide.Copy(temp1);
       
  2686 	test.Printf(_L("\nReadFileSection - read: %s\n"),&temp1_wide);
       
  2687 	test.Printf(_L("ReadFileSection - temp1.Length()=%d\n\n"),temp1.Length());
       
  2688 
       
  2689 
       
  2690 	test.Next(_L("ReadFileSection:Exit"));
       
  2691 	test.Printf(_L("ReadFileSection - read: %S"),&temp1);
       
  2692 	TInt compare = temp1.Length()==9;
       
  2693 	if(compare) compare = KErrNone;
       
  2694 	safe_test(compare,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2695 	compare = temp1.Compare(_L8("Read File"));
       
  2696 	compare = (temp1==_L8("Read File")); // This should be .Compare()?
       
  2697 	if(compare) compare = KErrNone;
       
  2698 	safe_test(compare,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2699 	test.Next(_L("Reading a file section complete"));
       
  2700 
       
  2701 	test.Next(_L("ReadFileSection:Delete"));
       
  2702 	r = TheFs.Delete(filename1);
       
  2703 	if(r == KErrNotFound || r==KErrPathNotFound)
       
  2704 		r = KErrNone;
       
  2705 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2706 
       
  2707 
       
  2708 	test.Next(_L("////////////////////////////"));
       
  2709 	test.Next(_L("////////////////////////////"));
       
  2710 	test.Next(_L("////////////////////////////"));
       
  2711 	test.Next(_L("////////////////////////////"));
       
  2712 
       
  2713 
       
  2714 	LoadAndMountPlugins();
       
  2715 
       
  2716 	#if defined __WINS__ && defined __DEBUG__
       
  2717 	// Turn on request tracing (for debug purposes)
       
  2718 	r = TheFs.SetDebugRegister(KPLUGIN | KCACHE);
       
  2719 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2720 	#endif
       
  2721 
       
  2722 	TInt drive = EDriveX;
       
  2723 	TBuf<25> path;
       
  2724 	r = TheFs.Subst(path,drive);
       
  2725 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2726 
       
  2727 
       
  2728 	TestReadFileDirect();
       
  2729 	TestReadFileViaPlugin();
       
  2730 	TestWriteFileDirect();
       
  2731 	TestWriteFileViaPlugin();
       
  2732 	//TestFileLock();
       
  2733 	TestFileSeek();
       
  2734 	TestFileSize();
       
  2735 	TestDir();
       
  2736 	TestCreate();
       
  2737 	TestOpen();
       
  2738 	TestReplace();
       
  2739 	TestReadFileSection();
       
  2740 	TestTemp();
       
  2741 	TestEntry();
       
  2742 	TestRename();
       
  2743 	TestComReadFileSection();
       
  2744 	//TestComLock();
       
  2745 
       
  2746 	DismountAndUnloadPlugins();
       
  2747 
       
  2748 	LoadExclusiveAccessPluginAndTest();
       
  2749 	LoadPluginsForSpecificDriveTests();
       
  2750 	LoadCombinationPluginAndTest();
       
  2751 	LoadStackedPluginAndTest();
       
  2752 
       
  2753 	//Unremovable plugin is removed by setting a flag via RPlugin
       
  2754 	LoadUnremovablePluginAndTest();
       
  2755 
       
  2756 	__UHEAP_MARKEND;
       
  2757 
       
  2758 	#if defined __WINS__ && defined __DEBUG__
       
  2759 	// Turn off request tracing
       
  2760 	r = TheFs.SetDebugRegister(0);
       
  2761 	safe_test(r,__LINE__,(TText*)Expand("t_plugin_v2.cpp"));
       
  2762 	#endif
       
  2763 
       
  2764 }