1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-2009 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". |
1772 @SYMTestPriority High |
1771 @SYMTestPriority High |
1773 |
1772 |
1774 @SYMTestStatus Implemented |
1773 @SYMTestStatus Implemented |
1775 |
1774 |
1776 @SYMTestActions Start the surface update server in two different threads. |
1775 @SYMTestActions Start the surface update server in two different threads. |
1777 |
1776 |
1778 @SYMTestExpectedResults Thread 1: KErrNone |
1777 @SYMTestExpectedResults Thread 1: KErrNone |
1779 Thread 2: KErrNone |
1778 Thread 2: KErrAlreadyExists. |
1780 The "provider" returned to both threads should also be the same value! |
|
1781 */ |
1779 */ |
1782 void CTSurfaceUpdate::TestCase12L() |
1780 void CTSurfaceUpdate::TestCase12L() |
1783 { |
1781 { |
1784 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; |
1782 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; |
1785 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); |
1783 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); |
1786 TEST(res == KErrNone); |
1784 TEST(res == KErrNone); |
1787 User::LeaveIfError(res); |
1785 User::LeaveIfError(res); |
1788 |
1786 |
1789 _LIT(KThreadName, "TestServerStartupTwoThreads"); |
1787 _LIT(KThreadName, "TestServerStartupTwoThreads"); |
1790 TTime tm; |
1788 TTime tm; |
1791 TBuf<32> buf; |
1789 TBuf<32> buf; |
1792 tm.UniversalTime(); |
1790 tm.UniversalTime(); |
1793 TRAP(res, tm.FormatL(buf, _L("_%H%T%S%C"))); |
1791 TRAP(res, tm.FormatL(buf, _L("_%H%T%S%C"))); |
1794 TEST(res == KErrNone); |
1792 TEST(res == KErrNone); |
1795 User::LeaveIfError(res); |
1793 User::LeaveIfError(res); |
1796 TBuf<128> threadName(KThreadName); |
1794 TBuf<128> threadName(KThreadName); |
1797 threadName.Append(buf); //guarantee uniqueness of the thread name |
1795 threadName.Append(buf); //guarantee uniqueness of the thread name |
1798 RThread thread; |
1796 RThread thread; |
1799 MSurfaceUpdateServerProvider *surfaceUpdateProvider2 = NULL; |
1797 res = thread.Create(threadName, |
1800 res = thread.Create(threadName, |
1798 TestServerStartupTwoThreads, |
1801 TestServerStartupTwoThreads, |
1799 KDefaultStackSize, |
1802 KDefaultStackSize, |
1800 &User::Heap(), |
1803 &User::Heap(), |
1801 NULL); |
1804 &surfaceUpdateProvider2); |
1802 TEST(res == KErrNone); |
1805 TEST(res == KErrNone); |
1803 User::LeaveIfError(res); |
1806 User::LeaveIfError(res); |
1804 TRequestStatus rendezvousStatus; |
1807 TRequestStatus rendezvousStatus; |
1805 thread.Rendezvous(rendezvousStatus); |
1808 thread.Rendezvous(rendezvousStatus); |
1806 thread.Resume(); |
1809 thread.Resume(); |
1807 User::WaitForRequest(rendezvousStatus); |
1810 User::WaitForRequest(rendezvousStatus); |
1808 TEST(KErrAlreadyExists == rendezvousStatus.Int()); |
1811 TEST(KErrNone == rendezvousStatus.Int()); |
1809 } |
1812 // Check that we get the same provider for both threads! |
1810 |
1813 TEST(surfaceUpdateProvider2 == surfaceUpdateProvider); |
|
1814 } |
|
1815 |
|
1816 |
|
1817 /** |
1811 /** |
1818 Starting the update server in another thread - called from TestCase12 |
1812 Starting the update server in another thread - called from TestCase12 |
1819 */ |
1813 */ |
1820 TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny *aArgPtr) |
1814 TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny*) |
1821 { |
1815 { |
1822 MSurfaceUpdateServerProvider **surfaceUpdateProviderPtr = |
1816 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; |
1823 reinterpret_cast<MSurfaceUpdateServerProvider **>(aArgPtr); |
1817 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); |
1824 TInt res = StartSurfaceUpdateServer(*surfaceUpdateProviderPtr); |
|
1825 return res; |
1818 return res; |
1826 } |
1819 } |
1827 |
1820 |
1828 /** |
1821 /** |
1829 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0020 |
1822 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0020 |
2255 INFO_PRINTF1(_L("TestCase11")); |
2248 INFO_PRINTF1(_L("TestCase11")); |
2256 TRAPD(ret, TestCase11()); |
2249 TRAPD(ret, TestCase11()); |
2257 TEST(ret == KErrNone); |
2250 TEST(ret == KErrNone); |
2258 break; |
2251 break; |
2259 } |
2252 } |
2260 case 12: |
2253 case 12: |
2261 { |
2254 { |
2262 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0019")); |
2255 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0019")); |
2263 INFO_PRINTF1(_L("TestCase12L")); |
2256 INFO_PRINTF1(_L("TestCase12")); |
2264 TRAPD(ret, TestCase12L()); |
2257 TRAPD(ret, TestCase12L()); |
2265 TEST(ret == KErrNone); |
2258 TEST(ret == KErrNone); |
2266 break; |
2259 break; |
2267 } |
2260 } |
2268 case 13: |
2261 case 13: |
2269 { |
2262 { |
2270 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0020")); |
2263 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0020")); |
2271 INFO_PRINTF1(_L("TestCase13L")); |
2264 INFO_PRINTF1(_L("TestCase13L")); |
2272 TRAPD(ret, TestCase13L()); |
2265 TRAPD(ret, TestCase13L()); |