Update contrib.
1 // Copyright (c) 2002-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\system\t_env.cpp
19 #include <e32std_private.h>
22 #include <e32msgqueue.h>
25 LOCAL_D RTest test(_L("T_ENV_CHILD"));
29 GLDEF_C TInt E32Main()
33 test.Start(_L("Environment"));
35 //parameter slot 1 contains a message queue of TInts which contain control messages
36 //parameter slot 2 contains a message queue of TInts
37 //parameter slot 3 is a mutex
38 //parameter slot 4 is a semaphore
39 //parameter slot 5 is a chunk
41 RMsgQueue<TInt> controlQueue;
42 TInt err = controlQueue.Open(1, EOwnerProcess);
46 controlQueue.ReceiveBlocking(t);
52 User::SetJustInTime(EFalse);
53 RMsgQueue<TInt> intQueue;
54 intQueue.Open(-1); //should panic
61 User::SetJustInTime(EFalse);
62 RMsgQueue<TInt> intQueue;
63 intQueue.Open(4545); //should panic
69 //attempt to read slot which is empty
70 RMsgQueue<TInt> intQueue;
71 TInt ret = intQueue.Open(15); //15 is empty
72 test(ret == KErrNotFound);
77 //attempt to open incorrect handle type
80 TInt ret = mutex.Open(2); //2 is a TInt queue
81 test(ret == KErrArgument);
87 //test passing a mutex (slot 3)
89 mutex.Open(3, EOwnerThread);
90 TFullName name = mutex.FullName();
91 TInt ret = name.CompareF(_L("testmutex"));
92 test (ret == KErrNone);
99 //test passing a semaphore (slot 4)
101 sem.Open(4, EOwnerThread);
102 TFullName name = sem.FullName();
103 TInt ret = name.CompareF(_L("testsemaphore"));
104 test (ret == KErrNone);
111 //test file handle (slots 7=session 8=file)
112 _LIT8(KTestData,"test data");
117 TInt len = User::ParameterLength(8);
119 TInt ret = User::GetTIntParameter(8, handle);
120 test(ret == KErrNone);
121 file.Adopt(session, handle);
123 ret = file.Read(0, rbuf);
124 test(ret == KErrNone);
126 ret = rbuf.CompareF(KTestData);
127 test(ret == KErrNone);
135 //test a chunk in slot 5
137 TInt ret = chunk.Open(5, EOwnerThread);
138 test (ret == KErrNone);
139 TFullName name = chunk.FullName();
140 ret = name.CompareF(_L("testchunk"));
141 test (ret == KErrNone);
148 //test passing a 16 bit descriptor // slot 15
151 TInt len = User::ParameterLength(15);
152 TInt ret = User::GetDesParameter(15, buf);
153 test (ret == KErrNone);
154 test(buf.Length() == len/2);
155 ret = buf.CompareF(_L("16 bit text"));
156 test (ret == KErrNone);
162 //test passing a 8 bit descriptor // slot 15
164 TInt len = User::ParameterLength(15);
165 TInt ret = User::GetDesParameter(15, buf);
166 test (ret == KErrNone);
167 test (len == buf.Length());
168 ret = buf.CompareF(_L8("8 bit text"));
169 test (ret == KErrNone);
175 User::SetJustInTime(EFalse);
176 TPtr8 bad((TUint8*)0xfeed, 20);
177 User::GetDesParameter(15, bad);
183 //test passing zero length data
185 TInt len = User::ParameterLength(15);
186 TInt ret = User::GetDesParameter(15, buf);
187 test (ret == KErrNone);
188 test (len == buf.Length());
195 //test getting command line, will be zero at the moment as just a reserved slot
197 TInt len = User::ParameterLength(0);
198 TInt ret = User::GetDesParameter(0, buf);
199 test (ret == KErrNone);
200 test (len == buf.Length());
210 controlQueue.Close();