graphicscomposition/surfaceupdate/tsrc/tsurfaceupdate.cpp
branchRCL_3
changeset 163 bbf46f59e123
parent 0 5d03bc08d59c
child 164 25ffed67c7ef
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
  1756 	TEST(KErrArgument == status.Int());
  1756 	TEST(KErrArgument == status.Int());
  1757 	
  1757 	
  1758 	session.Close();
  1758 	session.Close();
  1759 	}
  1759 	}
  1760 
  1760 
       
  1761 
  1761 /**
  1762 /**
  1762   @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0019
  1763   @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0019
  1763 
  1764 
  1764 
  1765 
  1765   @SYMPREQ 1007
  1766   @SYMPREQ 1007
  1771   @SYMTestPriority High
  1772   @SYMTestPriority High
  1772 
  1773 
  1773   @SYMTestStatus Implemented
  1774   @SYMTestStatus Implemented
  1774 
  1775 
  1775   @SYMTestActions Start the surface update server in two different threads.
  1776   @SYMTestActions Start the surface update server in two different threads.
  1776   	
  1777     
  1777   @SYMTestExpectedResults Thread 1: KErrNone
  1778   @SYMTestExpectedResults Thread 1: KErrNone
  1778      Thread 2: KErrAlreadyExists.
  1779      Thread 2: KErrNone
       
  1780      The "provider" returned to both threads should also be the same value!
  1779 */
  1781 */
  1780 void CTSurfaceUpdate::TestCase12L()
  1782 void CTSurfaceUpdate::TestCase12L()
  1781 	{
  1783     {
  1782 	MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL;
  1784     MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL;
  1783 	TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider);
  1785     TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider);
  1784 	TEST(res == KErrNone);
  1786     TEST(res == KErrNone);
  1785 	User::LeaveIfError(res);
  1787     User::LeaveIfError(res);
  1786 
  1788 
  1787 	_LIT(KThreadName, "TestServerStartupTwoThreads");
  1789     _LIT(KThreadName, "TestServerStartupTwoThreads");
  1788 	TTime tm;
  1790     TTime tm;
  1789 	TBuf<32> buf;
  1791     TBuf<32> buf;
  1790 	tm.UniversalTime();
  1792     tm.UniversalTime();
  1791 	TRAP(res, tm.FormatL(buf, _L("_%H%T%S%C")));
  1793     TRAP(res, tm.FormatL(buf, _L("_%H%T%S%C")));
  1792 	TEST(res == KErrNone);
  1794     TEST(res == KErrNone);
  1793 	User::LeaveIfError(res);
  1795     User::LeaveIfError(res);
  1794 	TBuf<128> threadName(KThreadName);
  1796     TBuf<128> threadName(KThreadName);
  1795 	threadName.Append(buf); //guarantee uniqueness  of the thread name
  1797     threadName.Append(buf); //guarantee uniqueness  of the thread name
  1796 	RThread thread;
  1798     RThread thread;
  1797 	res = thread.Create(threadName,
  1799     MSurfaceUpdateServerProvider *surfaceUpdateProvider2 = NULL;
  1798 			TestServerStartupTwoThreads,
  1800     res = thread.Create(threadName,
  1799 			KDefaultStackSize,
  1801             TestServerStartupTwoThreads,
  1800 			&User::Heap(),
  1802             KDefaultStackSize,
  1801 			NULL);
  1803             &User::Heap(),
  1802 	TEST(res == KErrNone);
  1804             &surfaceUpdateProvider2);
  1803 	User::LeaveIfError(res);
  1805     TEST(res == KErrNone);
  1804 	TRequestStatus rendezvousStatus;
  1806     User::LeaveIfError(res);
  1805 	thread.Rendezvous(rendezvousStatus);
  1807     TRequestStatus rendezvousStatus;
  1806 	thread.Resume();
  1808     thread.Rendezvous(rendezvousStatus);
  1807 	User::WaitForRequest(rendezvousStatus);
  1809     thread.Resume();
  1808 	TEST(KErrAlreadyExists == rendezvousStatus.Int());
  1810     User::WaitForRequest(rendezvousStatus);
  1809 	}
  1811     TEST(KErrNone == rendezvousStatus.Int());
  1810 	
  1812     // Check that we get the same provider for both threads!
       
  1813     TEST(surfaceUpdateProvider2 == surfaceUpdateProvider);
       
  1814     }
       
  1815 
       
  1816 
  1811 /**
  1817 /**
  1812 Starting the update server in another thread - called from TestCase12
  1818 Starting the update server in another thread - called from TestCase12
  1813 */
  1819 */
  1814 TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny*)
  1820 TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny *aArgPtr)
  1815 	{
  1821 	{
  1816 	MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL;
  1822 	MSurfaceUpdateServerProvider **surfaceUpdateProviderPtr = 
  1817 	TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider);
  1823 	        reinterpret_cast<MSurfaceUpdateServerProvider **>(aArgPtr);
       
  1824 	TInt res = StartSurfaceUpdateServer(*surfaceUpdateProviderPtr);
  1818 	return res;
  1825 	return res;
  1819 	}
  1826 	}
  1820 
  1827 
  1821 /**
  1828 /**
  1822   @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0020
  1829   @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0020
  2248  		INFO_PRINTF1(_L("TestCase11"));
  2255  		INFO_PRINTF1(_L("TestCase11"));
  2249  		TRAPD(ret, TestCase11());
  2256  		TRAPD(ret, TestCase11());
  2250  		TEST(ret == KErrNone);
  2257  		TEST(ret == KErrNone);
  2251  		break;
  2258  		break;
  2252 		}
  2259 		}
  2253 	case 12:
  2260     case 12:
  2254  		{
  2261         {
  2255  		((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0019"));
  2262         ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0019"));
  2256  		INFO_PRINTF1(_L("TestCase12"));
  2263         INFO_PRINTF1(_L("TestCase12L"));
  2257  		TRAPD(ret, TestCase12L());
  2264         TRAPD(ret, TestCase12L());
  2258  		TEST(ret == KErrNone);
  2265         TEST(ret == KErrNone);
  2259  		break;
  2266         break;
  2260 		}
  2267         }
  2261 	case 13:
  2268 	case 13:
  2262  		{
  2269  		{
  2263  		((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0020"));
  2270  		((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0020"));
  2264  		INFO_PRINTF1(_L("TestCase13L"));
  2271  		INFO_PRINTF1(_L("TestCase13L"));
  2265  		TRAPD(ret, TestCase13L());
  2272  		TRAPD(ret, TestCase13L());