1 // Copyright (c) 2004-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 "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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Thread entry point functions for the test framework's thread used to run the active scheduler |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "InputRequestListener.h" |
|
24 #include <in_iface.h> |
|
25 #include "reteldriverinput.h" |
|
26 #include "ceteldriverfactory.h" |
|
27 #include "cpdpfsmfactory.h" |
|
28 |
|
29 /** |
|
30 Creates and starts the active scheduler, and initializes the units under test |
|
31 */ |
|
32 void ActiveSchedulerMainL(CInputRequestListener* aListener, TThreadId aParentThreadId) |
|
33 { |
|
34 CActiveScheduler *sched = new(ELeave) CActiveScheduler; |
|
35 CleanupStack::PushL(sched); |
|
36 CActiveScheduler::Install(sched); |
|
37 |
|
38 aListener->iParentThread.Open(aParentThreadId); |
|
39 |
|
40 __UHEAP_MARK; |
|
41 |
|
42 CActiveScheduler::Add(aListener); |
|
43 |
|
44 aListener->CreateUnitUnderTestL(); |
|
45 |
|
46 // listen for requests from the main test thread |
|
47 aListener->Activate(); |
|
48 |
|
49 // notify the test execute thread that we are initialized and ready to handle FSM or Etel driver Input requests |
|
50 TRequestStatus *readyStatus = &aListener->iReadyForInputRequest; |
|
51 aListener->iParentThread.RequestComplete(readyStatus, KErrNone); |
|
52 TRequestStatus *initStatus = &aListener->iThreadInitialized; |
|
53 aListener->iParentThread.RequestComplete(initStatus, KErrNone); |
|
54 |
|
55 CActiveScheduler::Start(); |
|
56 |
|
57 // this could be done in the destructor, but we do it here so that the UHEAP macros work out for this thread |
|
58 // (otherwise they would be deleted in the main test thread) |
|
59 aListener->DeleteUnitUnderTest(); |
|
60 |
|
61 __UHEAP_MARKEND; |
|
62 |
|
63 CleanupStack::PopAndDestroy(sched); |
|
64 |
|
65 // inform the main test thread that this thread is finished and that there are no memory leaks |
|
66 TRequestStatus *destuctedStatus = &aListener->iThreadDestructed; |
|
67 aListener->iParentThread.RequestComplete(destuctedStatus, KErrNone); |
|
68 aListener->iParentThread.Close(); |
|
69 } |
|
70 |
|
71 /** |
|
72 Create the trap cleanup and calls the main thread f'n |
|
73 */ |
|
74 TInt ActiveSchedulerThread(TAny* aActiveSchedulerParams) |
|
75 { |
|
76 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
77 if(!cleanup) |
|
78 { |
|
79 return KErrNoMemory; |
|
80 } |
|
81 |
|
82 TActiveSchedulerThreadParams *params = (TActiveSchedulerThreadParams*)aActiveSchedulerParams; |
|
83 TRAPD(err, ActiveSchedulerMainL(params->iListener, params->iThreadId)); |
|
84 |
|
85 delete cleanup; |
|
86 |
|
87 return err; |
|
88 } |
|