719
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
872
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
719
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
719
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file
|
|
15 |
// [Test Step] :
|
|
16 |
// AsyncStep
|
|
17 |
// Ownes a Active Object for async operations.
|
|
18 |
//
|
|
19 |
//
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
/* User includes */
|
|
24 |
#include "T_MsgAsyncStep.h"
|
|
25 |
|
|
26 |
|
|
27 |
/* Literals Used */
|
|
28 |
_LIT(KProgressTime, "ProgressTime");
|
|
29 |
_LIT(KCancelTime, "CancelTime");
|
|
30 |
|
|
31 |
|
|
32 |
/**
|
|
33 |
Function : CT_MsgAsyncStep
|
|
34 |
Description : Constructor
|
|
35 |
@return : N/A
|
|
36 |
*/
|
|
37 |
CT_MsgAsyncStep::CT_MsgAsyncStep()
|
|
38 |
: CT_MsgStep()
|
|
39 |
, iActive(NULL)
|
|
40 |
, iTimerCancel(NULL)
|
|
41 |
, iTimerProgress(NULL)
|
|
42 |
, iTimeProgress(0)
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
/**
|
|
49 |
Function : ConstructL
|
|
50 |
Description : Creates an object of the active object and timer
|
|
51 |
@return : N/A
|
|
52 |
*/
|
|
53 |
void CT_MsgAsyncStep::ConstructL()
|
|
54 |
{
|
|
55 |
iActive = CT_MsgActive::NewL(*this);
|
|
56 |
iTimerCancel = CT_MsgTimer::NewL(*this);
|
|
57 |
iTimerProgress= CT_MsgTimer::NewL(*this);
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
/**
|
|
63 |
Function : ~CT_MsgAsyncStep
|
|
64 |
Description : Destructor
|
|
65 |
@return : N/A
|
|
66 |
*/
|
|
67 |
CT_MsgAsyncStep::~CT_MsgAsyncStep()
|
|
68 |
{
|
|
69 |
delete iTimerProgress;
|
|
70 |
iTimerProgress=NULL;
|
|
71 |
|
|
72 |
delete iTimerCancel;
|
|
73 |
iTimerCancel=NULL;
|
|
74 |
|
|
75 |
delete iActive;
|
|
76 |
iActive=NULL;
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
/**
|
|
82 |
Function : Completed
|
|
83 |
Description : Cancels the wait for completion of an outstanding request
|
|
84 |
@return : N/A
|
|
85 |
*/
|
|
86 |
void CT_MsgAsyncStep::Completed()
|
|
87 |
{
|
|
88 |
iTimerProgress->Cancel();
|
|
89 |
iTimerCancel->Cancel();
|
|
90 |
ProgressL(ETrue);
|
|
91 |
CActiveScheduler::Stop();
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
/**
|
|
96 |
Function : TimerCompletedL
|
|
97 |
Description : Sets the progress information and cancel information accordingly
|
|
98 |
@return : none
|
|
99 |
*/
|
|
100 |
void CT_MsgAsyncStep::TimerCompletedL(CTimer* aTimer)
|
|
101 |
{
|
|
102 |
if ( aTimer==iTimerProgress )
|
|
103 |
{
|
|
104 |
INFO_PRINTF1(_L("Calling ProgressL(EFalse)"));
|
|
105 |
ProgressL(EFalse);
|
|
106 |
iTimerProgress->After(iTimeProgress);
|
|
107 |
}
|
|
108 |
else if ( aTimer==iTimerCancel )
|
|
109 |
{
|
|
110 |
INFO_PRINTF1(_L("Calling Cancel()"));
|
|
111 |
iTimerProgress->Cancel();
|
|
112 |
CancelStep();
|
|
113 |
CActiveScheduler::Stop();
|
|
114 |
}
|
|
115 |
}
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
/**
|
|
120 |
Function : doTestStepPreambleL
|
|
121 |
Description : Call the doTestStepPreambleL of the CTestStep class
|
|
122 |
Reads the porgress time and cancel time from the ini
|
|
123 |
@return : TVerdict result
|
|
124 |
*/
|
|
125 |
enum TVerdict CT_MsgAsyncStep::doTestStepPreambleL()
|
|
126 |
{
|
|
127 |
TVerdict ret=CTestStep::doTestStepPreambleL();
|
|
128 |
|
|
129 |
if( GetIntFromConfig( ConfigSection(), KProgressTime, iTimeProgress) )
|
|
130 |
{
|
|
131 |
iTimerProgress->After(iTimeProgress);
|
|
132 |
}
|
|
133 |
|
|
134 |
TInt time = 0;
|
|
135 |
if( GetIntFromConfig( ConfigSection(), KCancelTime, time) )
|
|
136 |
{
|
|
137 |
iTimerCancel->After(time);
|
|
138 |
}
|
|
139 |
return ret;
|
|
140 |
}
|