Update contrib.
1 // Copyright (c) 1994-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\prime\t_kern.cpp
20 LOCAL_D RTest test(_L("T_KERN"));
21 LOCAL_D TFindProcess fProc;
22 LOCAL_D TFindThread fThread;
23 LOCAL_D TFindSemaphore fSem;
24 LOCAL_D TFindMutex fMutex;
25 LOCAL_D TFindChunk fChunk;
26 LOCAL_D TFindLogicalDevice fLdd;
27 LOCAL_D TFindPhysicalDevice fPdd;
28 LOCAL_D TFindServer fServ;
29 LOCAL_D TFindLibrary fLib;
31 LOCAL_C void testFindHandles()
33 // Test the various find handles.
37 test.Start(_L("Processes"));
39 while (fProc.Next(n)==KErrNone)
40 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fProc.Handle());
41 test.Next(_L("Threads"));
42 while (fThread.Next(n)==KErrNone)
43 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fThread.Handle());
44 test.Next(_L("Semaphores"));
45 while (fSem.Next(n)==KErrNone)
46 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fSem.Handle());
47 test.Next(_L("Mutexes"));
48 while (fMutex.Next(n)==KErrNone)
49 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fMutex.Handle());
50 test.Next(_L("Chunks"));
51 while (fChunk.Next(n)==KErrNone)
52 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fChunk.Handle());
53 test.Next(_L("LogicalDevice"));
54 while (fLdd.Next(n)==KErrNone)
55 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fLdd.Handle());
56 test.Next(_L("PhysicalDevice"));
57 while (fPdd.Next(n)==KErrNone)
58 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fPdd.Handle());
59 test.Next(_L("Server"));
60 while (fServ.Next(n)==KErrNone)
61 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fServ.Handle());
62 test.Next(_L("Library"));
63 while (fLib.Next(n)==KErrNone)
64 test.Printf(_L(" %- 50s %d\n"),n.PtrZ(),fLib.Handle());
68 LOCAL_C void testCurrentProcessAndThread()
70 // Test the handles for the current process and thread.
74 test.Start(_L("Process"));
76 TFullName pFullName = p.FullName();
77 test.Printf(_L(" %S\n"),&pFullName);
78 TName pName = p.Name();
79 test.Printf(_L(" %S\n"),&pName);
81 test.Next(_L("Thread"));
83 TFullName tFullName = t.FullName();
84 test.Printf(_L(" %S\n"),&tFullName);
85 TName tName = t.Name();
86 test.Printf(_L(" %S\n"),&tName);
91 LOCAL_C TInt ThreadBeepFunction(TAny*)
93 // Thread which beeps and stops before the beep completes
97 User::Beep(440,1000000);
101 LOCAL_C void testBeep()
103 // Test the beep function.
107 test.Start(_L("220Hz dur=10"));
108 User::Beep(220,1000000);
109 User::After(2000000);
110 test.Next(_L("330Hz dur=10"));
111 User::Beep(330,1000000);
112 User::After(2000000);
113 test.Next(_L("440Hz dur=10"));
114 User::Beep(440,1000000);
115 User::After(2000000);
116 test.Next(_L("880Hz dur=10"));
117 User::Beep(880,1000000);
118 User::After(2000000);
119 test.Next(_L("1760Hz dur=10"));
120 User::Beep(1760,1000000);
121 User::After(2000000);
123 test.Next(_L("Listen to check that the first beep is interrupted after 2 secs"));
124 User::Beep(330,10000000);
125 User::After(2000000);
126 User::Beep(660,1000000);
127 User::After(1000000);
129 test.Next(_L("Listen to check that a negative value does not interrupt"));
130 User::Beep(330,5000000);
131 User::After(2000000);
132 TInt r=User::Beep(660,-1000000);
133 test.Next(_L("Check the 2nd beep returned KErrGeneral"));
134 test(r==KErrGeneral);
135 User::After(3000000);
137 test.Next(_L("Beep survives when thread terminates"));
139 thread.Create(_L("Beep Test Thread"),ThreadBeepFunction,0x1000,0x1000,0x1000,NULL);
143 User::WaitForRequest(stat);
147 timer.After(stat,TTimeIntervalMicroSeconds32(2000000)); //2secs
148 User::WaitForRequest(stat);
149 CLOSE_AND_WAIT(thread);
153 GLDEF_C TInt E32Main()
155 // Test the various kernel types.
161 test.Start(_L("TFindHandles"));
164 test.Next(_L("Current process and thread"));
165 testCurrentProcessAndThread();
167 test.Next(_L("Test beeper"));