748
|
1 |
// Copyright (c) 2001-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"
|
748
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
748
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDES
|
|
20 |
#include "ctlbsclientpostp25.h"
|
|
21 |
#include "ctlbsrequester.h"
|
|
22 |
#include <EPos_CPosModules.h>
|
|
23 |
#include <EPos_CPosModuleUpdate.h>
|
|
24 |
|
|
25 |
// CONSTANTS
|
|
26 |
|
|
27 |
// ==================== LOCAL FUNCTIONS ====================
|
|
28 |
|
|
29 |
// ---------------------------------------------------------
|
|
30 |
// EnablePsyL. Enables a specific psy
|
|
31 |
// ---------------------------------------------------------
|
|
32 |
//
|
|
33 |
void EnablePsyL(
|
|
34 |
CPosModules& aDb,
|
|
35 |
TUid aPsy)
|
|
36 |
{
|
|
37 |
CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
|
|
38 |
// Enable Psy
|
|
39 |
moduleUpdate->SetUpdateAvailability(ETrue);
|
|
40 |
aDb.UpdateModuleL(aPsy, *moduleUpdate);
|
|
41 |
CleanupStack::PopAndDestroy(moduleUpdate);
|
|
42 |
|
|
43 |
}
|
|
44 |
|
|
45 |
// ================= MEMBER FUNCTIONS =======================
|
|
46 |
|
|
47 |
// ---------------------------------------------------------
|
|
48 |
// Constructor.
|
|
49 |
// ---------------------------------------------------------
|
|
50 |
CT_LbsClientPosTp25::CT_LbsClientPosTp25(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
|
|
51 |
{
|
|
52 |
_LIT(KTestName, "TP25 - Request location from multiple PSYs");
|
|
53 |
SetTestStepName(KTestName);
|
|
54 |
}
|
|
55 |
|
|
56 |
// Destructor
|
|
57 |
CT_LbsClientPosTp25::~CT_LbsClientPosTp25()
|
|
58 |
{
|
|
59 |
delete iFastPsy;
|
|
60 |
delete iMediumPsy;
|
|
61 |
delete iSlowPsy;
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
// CT_LbsClientPosTp25::StartL
|
|
66 |
//
|
|
67 |
// (other items were commented in a header).
|
|
68 |
// ---------------------------------------------------------
|
|
69 |
//
|
|
70 |
void CT_LbsClientPosTp25::StartL()
|
|
71 |
{
|
|
72 |
|
|
73 |
CPosModules* db = CPosModules::OpenL();
|
|
74 |
CleanupStack::PushL(db);
|
|
75 |
|
|
76 |
EnablePsyL(*db, iUidTestPsy12);// 0 sec
|
|
77 |
EnablePsyL(*db, iUidTestPsy4);// 3 sec
|
|
78 |
EnablePsyL(*db, iUidTestPsy9);// 6 sec
|
|
79 |
|
|
80 |
CleanupStack::PopAndDestroy(); // db
|
|
81 |
|
|
82 |
iFastPsy = CT_LbsRequester::NewL(iUidTestPsy12, this, Logger());
|
|
83 |
iMediumPsy = CT_LbsRequester::NewL(iUidTestPsy4, this, Logger());
|
|
84 |
iSlowPsy = CT_LbsRequester::NewL(iUidTestPsy9, this, Logger());
|
|
85 |
iCompletedRequests = 0;
|
|
86 |
|
|
87 |
TTime starttime,stoptime;
|
|
88 |
starttime.UniversalTime();
|
|
89 |
|
|
90 |
// Make request to slow psy first
|
|
91 |
iSlowPsy->StartRequest();
|
|
92 |
iFastPsy->StartRequest();
|
|
93 |
iMediumPsy->StartRequest();
|
|
94 |
|
|
95 |
// Wait for completion
|
|
96 |
CActiveScheduler::Start();
|
|
97 |
|
|
98 |
stoptime.UniversalTime();
|
|
99 |
|
|
100 |
// Substract total delay incurred due to PSY's...i.e 6sec
|
|
101 |
TInt duration=stoptime.Int64()-starttime.Int64()-6000000;
|
|
102 |
|
|
103 |
|
|
104 |
_LIT(KMessage,"3 simultaneous requests from 3 different sessions completed in %d microsec");
|
|
105 |
TBuf<256> error;
|
|
106 |
error.Format(KMessage,duration);
|
|
107 |
INFO_PRINTF1(error);
|
|
108 |
|
|
109 |
if(duration>3000000)
|
|
110 |
{
|
|
111 |
_LIT(KTime, "Time taken>3 sec");
|
|
112 |
INFO_PRINTF1(KTime);
|
|
113 |
}
|
|
114 |
|
|
115 |
// Evaluate result
|
|
116 |
_LIT(KPsyFast, "testpsy12");
|
|
117 |
_LIT(KPsyMedium, "testpsy4");
|
|
118 |
_LIT(KPsySlow, "testpsy9");
|
|
119 |
|
|
120 |
_LIT(KReturnedErrorCode, "Positioner %S returned error code %d");
|
|
121 |
TBuf<256> output;
|
|
122 |
output.Format(KReturnedErrorCode, &KPsyFast, iFastPsy->CompletionCode());
|
|
123 |
AssertTrueL(iFastPsy->CompletionCode() == KErrNone, output);
|
|
124 |
|
|
125 |
output.Format(KReturnedErrorCode, &KPsyMedium, iMediumPsy->CompletionCode());
|
|
126 |
AssertTrueL(iMediumPsy->CompletionCode() == KErrNone, output);
|
|
127 |
|
|
128 |
output.Format(KReturnedErrorCode, &KPsySlow, iSlowPsy->CompletionCode());
|
|
129 |
AssertTrueL(iSlowPsy->CompletionCode() == KErrNone, output);
|
|
130 |
_LIT(KWrongComplOrder, "Positioners completed out of order");
|
|
131 |
|
|
132 |
AssertTrueL(
|
|
133 |
iFastPsy->CompletionTimeUTC() < iMediumPsy->CompletionTimeUTC() &&
|
|
134 |
iMediumPsy->CompletionTimeUTC() < iSlowPsy->CompletionTimeUTC(),
|
|
135 |
KWrongComplOrder);
|
|
136 |
|
|
137 |
delete iFastPsy;
|
|
138 |
delete iMediumPsy;
|
|
139 |
delete iSlowPsy;
|
|
140 |
iFastPsy = NULL;
|
|
141 |
iMediumPsy = NULL;
|
|
142 |
iSlowPsy = NULL;
|
|
143 |
|
|
144 |
_LIT(KTEXT, "TP25 Passed! :)");
|
|
145 |
INFO_PRINTF1(KTEXT);
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------
|
|
149 |
// CT_LbsClientPosTp25::RequestCompleteL
|
|
150 |
//
|
|
151 |
// (other items were commented in a header).
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CT_LbsClientPosTp25::RequestCompleteL()
|
|
155 |
{
|
|
156 |
const TInt KNofRequesters = 3;
|
|
157 |
if (++iCompletedRequests == KNofRequesters)
|
|
158 |
{
|
|
159 |
CActiveScheduler::Stop();
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
// ---------------------------------------------------------
|
|
164 |
// CT_LbsClientPosTp25::AssertTrueL
|
|
165 |
//
|
|
166 |
// (other items were commented in a header).
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
//
|
|
169 |
void CT_LbsClientPosTp25::AssertTrueL(TBool aCondition, const TDesC& aErrorMsg)
|
|
170 |
{
|
|
171 |
if (!aCondition)
|
|
172 |
{
|
|
173 |
LogErrorAndLeaveL(aErrorMsg);
|
|
174 |
}
|
|
175 |
}
|