Update contrib.
1 // Copyright (c) 1996-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_multin.cpp
16 // Test multiple inheritance with and without virtual bases.
20 // - Test multiple inheritance with virtual bases. Using a virtual
21 // base class, copy one or more strings from the "producer" object
22 // to the "consumer" object. Verify that results are as expected.
23 // - Test multiple inheritance without virtual bases. Using a non-
24 // virtual base class, copy one or more strings from the "producer"
25 // object to the "consumer" object. Verify that results are as expected.
26 // Platforms/Drives/Compatibility:
28 // Assumptions/Requirement/Pre-requisites:
29 // Failures and causes:
30 // Base Port information:
36 LOCAL_D RTest test(_L("T_MULTIN"));
38 void MConsumer::Consume(const TDesC& aStr1,const TDesC& aStr2)
40 #if defined(__TRACE__)
41 test.Printf(_L("MConsumer::Consume(s,s)\n"));
44 TBuf<0x100> b;b.Format(_L("%S%S"),&aStr1,&aStr2);Consume(b);
47 void MConsumer::Consume(const TDesC& aStr1,const TDesC& aStr2,const TDesC& aStr3)
49 #if defined(__TRACE__)
50 test.Printf(_L("MConsumer::Consume(s,s,s)\n"));
53 TBuf<0x100> b;b.Format(_L("%S%S%S"),&aStr1,&aStr2,&aStr3);Consume(b);
56 void MConsumer::Consume(const TDesC& aStr1,const TDesC& aStr2,const TDesC& aStr3,const TDesC& aStr4)
58 #if defined(__TRACE__)
59 test.Printf(_L("MConsumer::Consume(s,s,s,s)\n"));
62 TBuf<0x100> b;b.Format(_L("%S%S%S%S"),&aStr1,&aStr2,&aStr3,&aStr4);Consume(b);
65 TPtrC MPipe::Produce()
67 #if defined(__TRACE__)
68 test.Printf(_L("MPipe::Produce\n"));
74 void MPipe::Consume(const TDesC& aStr)
76 #if defined(__TRACE__)
77 test.Printf(_L("MPipe::Consume(s)\n"));
80 #if defined(__TRACE__)
85 test.Printf(_L("aStr type=%d,aStr length=%d\n"),t,l);
91 p=(TText*)((TInt*)&aStr+1);
94 p=*(TText**)((TInt*)&aStr+1);
97 p=*(TText**)((TInt*)&aStr+2);
100 p=(TText*)((TInt*)&aStr+2);
103 p=(TText*)(*(TInt**)((TInt*)&aStr+2)+1);
107 test.Printf(_L("aStr=\"%.3s...\"\n"),p);
111 #if defined(__TRACE__)
113 TInt l=*(TInt*)&iBuf;
116 TInt m=((TInt*)&iBuf)[1];
117 test.Printf(_L("iBuf type=%d,iBuf length=%d,iBuf max length=%d\n"),t,l,m);
123 p=(TText*)((TInt*)&iBuf+1);
126 p=*(TText**)((TInt*)&iBuf+1);
129 p=*(TText**)((TInt*)&iBuf+2);
132 p=(TText*)((TInt*)&iBuf+2);
135 p=(TText*)(*(TInt**)((TInt*)&iBuf+2)+1);
139 test.Printf(_L("iBuf=\"%.3s...\"\n"),p);
146 void MPipe::Consume(const TDesC& aStr1,const TDesC& aStr2)
148 #if defined(__TRACE__)
149 test.Printf(_L("MPipe::Consume(s,s)\n"));
152 iBuf.Format(_L("%S%S"),&aStr1,&aStr2);
155 void MPipe::Consume(const TDesC& aStr1,const TDesC& aStr2,const TDesC& aStr3)
157 #if defined(__TRACE__)
158 test.Printf(_L("MPipe::Consume(s,s,s)\n"));
161 iBuf.Format(_L("%S%S%S"),&aStr1,&aStr2,&aStr3);
164 void MPipe::Consume(const TDesC& aStr1,const TDesC& aStr2,const TDesC& aStr3,const TDesC& aStr4)
166 #if defined(__TRACE__)
167 test.Printf(_L("MPipe::Consume(s,s,s,s)\n"));
170 iBuf.Format(_L("%S%S%S%S"),&aStr1,&aStr2,&aStr3,&aStr4);
173 MProducer* TBase::Producer()
175 #if defined(__TRACE__)
176 test.Printf(_L("TBase::Producer\n"));
182 return((TProducer*)this);
184 return((TPipe*)this);
190 MConsumer* TBase::Consumer()
192 #if defined(__TRACE__)
193 test.Printf(_L("TBase::Consumer\n"));
199 return((TConsumer*)this);
201 return((TPipe*)this);
207 TPtrC TProducer::Produce()
209 #if defined(__TRACE__)
210 test.Printf(_L("TProducer::Produce\n"));
216 TSpecies TProducer::Species() const
218 #if defined(__TRACE__)
219 test.Printf(_L("TProducer::Species\n"));
225 TSpecies TConsumer::Species() const
227 #if defined(__TRACE__)
228 test.Printf(_L("TConsumer::Species\n"));
234 void TConsumer::Consume(const TDesC& aStr)
236 #if defined(__TRACE__)
237 test.Printf(_L("TConsumer::Consume\n"));
240 test.Printf(_L("Consumed: %S\n"),&aStr);
243 TSpecies TPipe::Species() const
245 #if defined(__TRACE__)
246 test.Printf(_L("TPipe::Species\n"));
252 TSpecies TVirProducer::Species() const
254 #if defined(__TRACE__)
255 test.Printf(_L("TVirProducer::Species\n"));
261 TPtrC TVirProducer::Produce()
263 #if defined(__TRACE__)
264 test.Printf(_L("TVirProducer::Produce\n"));
270 TSpecies TVirConsumer::Species() const
272 #if defined(__TRACE__)
273 test.Printf(_L("TVirConsumer::Species\n"));
279 MConsumer* TVirConsumer::Consumer()
281 #if defined(__TRACE__)
282 test.Printf(_L("TVirConsumer::Consumer\n"));
288 void TVirConsumer::Consume(const TDesC& aStr)
290 #if defined(__TRACE__)
291 test.Printf(_L("TVirConsumer::Consume\n"));
294 test.Printf(_L("Consumed: %S\n"),&aStr);
297 TSpecies TVirPipe::Species() const
299 #if defined(__TRACE__)
300 test.Printf(_L("TVirPipe::Species\n"));
306 MProducer* TVirPipe::Producer()
308 #if defined(__TRACE__)
309 test.Printf(_L("TVirPipe::Producer\n"));
315 MConsumer* TVirPipe::Consumer()
317 #if defined(__TRACE__)
318 test.Printf(_L("TVirPipe::Consumer\n"));
324 TPtrC TVirPipe::Produce()
326 #if defined(__TRACE__)
327 test.Printf(_L("TVirPipe::Produce\n"));
333 void TVirPipe::Consume(const TDesC& aStr)
335 #if defined(__TRACE__)
336 test.Printf(_L("TVirPipe::Consume(s)\n"));
342 void TVirPipe::Consume(const TDesC& aStr1,const TDesC& aStr2)
344 #if defined(__TRACE__)
345 test.Printf(_L("TVirPipe::Consume(s,s)\n"));
348 iBuf.Format(_L("%S%S"),&aStr1,&aStr2);
351 void TVirPipe::Consume(const TDesC& aStr1,const TDesC& aStr2,const TDesC& aStr3)
353 #if defined(__TRACE__)
354 test.Printf(_L("TVirPipe::Consume(s,s,s)\n"));
357 iBuf.Format(_L("%S%S%S"),&aStr1,&aStr2,&aStr3);
360 void TVirPipe::Consume(const TDesC& aStr1,const TDesC& aStr2,const TDesC& aStr3,const TDesC& aStr4)
362 #if defined(__TRACE__)
363 test.Printf(_L("TVirPipe::Consume(s,s,s,s)\n"));
366 iBuf.Format(_L("%S%S%S%S"),&aStr1,&aStr2,&aStr3,&aStr4);
369 LOCAL_C MProducer& Producer(TBase& aBase)
371 #if defined(__TRACE__)
372 test.Printf(_L("Producer(TBase&)\n"));
375 MProducer* prod=aBase.Producer();
380 LOCAL_C MConsumer& Consumer(TBase& aBase)
382 #if defined(__TRACE__)
383 test.Printf(_L("Consumer(TBase&)\n"));
386 MConsumer* cons=aBase.Consumer();
391 LOCAL_C void testCopy1(MConsumer& aConsumer,MProducer& aProducer)
393 // Copy a string from the producer to the consumer.
397 #if defined(__TRACE__)
398 test.Printf(_L("testCopy1()\n"));
401 aConsumer.Consume(aProducer.Produce());
404 LOCAL_C void testCopy2(MConsumer& aConsumer,MProducer& aProducer)
406 // Copy two strings from the producer to the consumer.
410 #if defined(__TRACE__)
411 test.Printf(_L("testCopy2()\n"));
414 TPtrC s1=aProducer.Produce();
415 TPtrC s2=aProducer.Produce();
416 aConsumer.Consume(s1,s2);
419 LOCAL_C void testCopy3(MConsumer& aConsumer,MProducer& aProducer)
421 // Copy three strings from the producer to the consumer.
425 #if defined(__TRACE__)
426 test.Printf(_L("testCopy3()\n"));
429 TPtrC s1=aProducer.Produce();
430 TPtrC s2=aProducer.Produce();
431 TPtrC s3=aProducer.Produce();
432 aConsumer.Consume(s1,s2,s3);
435 LOCAL_C void testCopy4(MConsumer& aConsumer,MProducer& aProducer)
437 // Copy four strings from the producer to the consumer.
441 #if defined(__TRACE__)
442 test.Printf(_L("testCopy4()\n"));
445 TPtrC s1=aProducer.Produce();
446 TPtrC s2=aProducer.Produce();
447 TPtrC s3=aProducer.Produce();
448 TPtrC s4=aProducer.Produce();
449 aConsumer.Consume(s1,s2,s3,s4);
452 LOCAL_C void testMulti()
454 // Test multiple inheritance without virtual bases.
458 #if defined(__TRACE__)
459 test.Printf(_L("testMulti()\n"));
462 test.Next(_L("without virtual base classes"));
467 testCopy1(Consumer(pipe),Producer(prod));
468 testCopy2(Consumer(cons),Producer(pipe));
470 testCopy3(Consumer(pipe),Producer(prod));
471 testCopy4(Consumer(cons),Producer(pipe));
473 testCopy4(Consumer(pipe),Producer(prod));
474 testCopy3(Consumer(cons),Producer(pipe));
476 testCopy2(Consumer(pipe),Producer(prod));
477 testCopy1(Consumer(cons),Producer(pipe));
480 LOCAL_C void testVirt()
482 // Test multiple inheritance with virtual bases.
486 #if defined(__TRACE__)
487 test.Printf(_L("testVirt()\n"));
490 test.Next(_L("with virtual base classes"));
495 testCopy1(Consumer(pipe),Producer(prod));
496 testCopy2(Consumer(cons),Producer(pipe));
498 testCopy3(Consumer(pipe),Producer(prod));
499 testCopy4(Consumer(cons),Producer(pipe));
501 testCopy4(Consumer(pipe),Producer(prod));
502 testCopy3(Consumer(cons),Producer(pipe));
504 testCopy2(Consumer(pipe),Producer(prod));
505 testCopy1(Consumer(cons),Producer(pipe));
508 GLDEF_C TInt E32Main()
510 // Test the multiple inheritance implementation.
513 #if defined(__TRACE__)
514 test.Printf(_L("E32Main()\n"));
519 test.Start(_L("Multiple Inheritance"));