kerneltest/f32test/server/t_dspace.cpp
changeset 247 d8d70de2bd36
parent 109 b3a1d9898418
child 269 d57b86b1867a
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
  1695 	r=TheFs.Delete(KFileFiller);
  1695 	r=TheFs.Delete(KFileFiller);
  1696 	test_KErrNone(r);
  1696 	test_KErrNone(r);
  1697 
  1697 
  1698 	}
  1698 	}
  1699 
  1699 
       
  1700 //-------------------------------------------------------------------------------------------------
       
  1701 // Test the fix for:
       
  1702 // ou1cimx#410349 Not getting any Notification from RFs::NotifyDiskSpace() for E and F drive when when tested multiple
       
  1703 // 
       
  1704 // Action: Enable a plugin to intercept RFs::Delete, and test RFs::Delet can still trigger disk space
       
  1705 // notification
       
  1706 //-------------------------------------------------------------------------------------------------
       
  1707 
       
  1708 _LIT(KPreModifierPluginFileName,"premodifier_plugin");
       
  1709 _LIT(KPreModifierPluginName,"PreModifierPlugin");
       
  1710 const TUint KTestFileSize = KKilo * 100;
       
  1711 
       
  1712 #define SAFETEST_KErrNone(a)        if(a != KErrNone)\
       
  1713                                         {\
       
  1714                                         TheFs.DismountPlugin(KPreModifierPluginName);\
       
  1715                                         TheFs.RemovePlugin(KPreModifierPluginName);\
       
  1716                                         test_KErrNone(a);\
       
  1717                                         }
       
  1718 
       
  1719 TInt PluginTestThreadFunction(TAny*)
       
  1720     {
       
  1721     RTest test(_L("PluginTestThreadFunction"));
       
  1722     RFs fs;
       
  1723     fs.Connect();
       
  1724     
       
  1725     TInt r = fs.SetSessionPath(gSessionPath);
       
  1726     test_KErrNone(r);
       
  1727     
       
  1728     RFile file;
       
  1729     r = file.Create(fs, KTestFile1, EFileShareAny|EFileWrite);
       
  1730     test_KErrNone(r);
       
  1731     r = file.SetSize(KTestFileSize);
       
  1732     test_KErrNone(r);
       
  1733     file.Close();
       
  1734       
       
  1735     User::After(5000000); // wait for 5 seconds, to ensure first notification received.
       
  1736     
       
  1737     r = fs.Delete(KTestFile1);
       
  1738     test_KErrNone(r);
       
  1739     
       
  1740     fs.Close();
       
  1741     return KErrNone;
       
  1742     }
       
  1743 
       
  1744 void TestDiskSpaceNotifyWithPlugin()
       
  1745     {
       
  1746     test.Next(_L("Test Disk Space Notify With Plugin"));
       
  1747       
       
  1748     TInt drive;
       
  1749     TInt r = RFs::CharToDrive(gSessionPath[0],drive);
       
  1750     SAFETEST_KErrNone(r);
       
  1751     Format(drive);
       
  1752     
       
  1753     r = TheFs.MkDirAll(gSessionPath);
       
  1754     SAFETEST_KErrNone(r);
       
  1755      
       
  1756     r = TheFs.AddPlugin(KPreModifierPluginFileName);
       
  1757     SAFETEST_KErrNone(r);
       
  1758 
       
  1759     r = TheFs.MountPlugin(KPreModifierPluginName);
       
  1760     SAFETEST_KErrNone(r);
       
  1761     
       
  1762     TInt64 free = FreeDiskSpace(drive);
       
  1763     TInt64 threshold = free - KTestFileSize + 1;
       
  1764     
       
  1765     TRequestStatus status;
       
  1766     TRequestStatus statusDeath;
       
  1767     
       
  1768     TheFs.NotifyDiskSpace(threshold, drive, status);
       
  1769     
       
  1770     RThread thread;
       
  1771     r = thread.Create(_L("PluginTestThread"), PluginTestThreadFunction, KStackSize, KHeapSize, KHeapSize, NULL);
       
  1772     SAFETEST_KErrNone(r);
       
  1773     thread.Logon(statusDeath);
       
  1774     thread.Resume();
       
  1775     
       
  1776     User::WaitForRequest(status);
       
  1777     SAFETEST_KErrNone(status.Int());
       
  1778     
       
  1779     TheFs.NotifyDiskSpace(threshold, drive, status);
       
  1780     User::WaitForRequest(status);
       
  1781     SAFETEST_KErrNone(status.Int());
       
  1782     
       
  1783     User::WaitForRequest(statusDeath);
       
  1784     SAFETEST_KErrNone(statusDeath.Int());
       
  1785     thread.Close();
       
  1786     
       
  1787     r = TheFs.DismountPlugin(KPreModifierPluginName);
       
  1788     SAFETEST_KErrNone(r);
       
  1789 
       
  1790     r = TheFs.RemovePlugin(KPreModifierPluginName);
       
  1791     SAFETEST_KErrNone(r);
       
  1792 
       
  1793     Format(drive);
       
  1794     }
       
  1795 
  1700 GLDEF_C void CallTestsL()
  1796 GLDEF_C void CallTestsL()
  1701 //
  1797 //
  1702 // Do all tests
  1798 // Do all tests
  1703 //
  1799 //
  1704 	{
  1800 	{
  1751 		{
  1847 		{
  1752 		TestDiskNotify();
  1848 		TestDiskNotify();
  1753 		}
  1849 		}
  1754 
  1850 
  1755 	TestChangeNotification();
  1851 	TestChangeNotification();
       
  1852 	TestDiskSpaceNotifyWithPlugin();
  1756 
  1853 
  1757 	if( LffsDrive )
  1854 	if( LffsDrive )
  1758 		{
  1855 		{
  1759 
  1856 
  1760 		TestLffsFunctions();
  1857 		TestLffsFunctions();