|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 #include "ctlbshybridx3pstep.h" |
|
17 #include <lbs/lbslocdatasourceclasstypes.h> |
|
18 |
|
19 |
|
20 CT_LbsHybridX3PStep::~CT_LbsHybridX3PStep() |
|
21 { |
|
22 iExpectedModuleGpsOptions.ResetAndDestroy(); |
|
23 iExpectedModuleGpsOptions.Close(); |
|
24 } |
|
25 |
|
26 |
|
27 CT_LbsHybridX3PStep::CT_LbsHybridX3PStep(CT_LbsHybridX3PServer& aParent) |
|
28 : iParent(aParent), iExpectedModuleGpsOptionsIndex(0), iAgpsModuleEventListener(NULL) |
|
29 { |
|
30 } |
|
31 |
|
32 void CT_LbsHybridX3PStep::ConstructL() |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 |
|
38 /** |
|
39 * @return - TVerdict |
|
40 * Implementation of CTestStep base class virtual |
|
41 * It is used for doing all initialisation common to derived classes in here. |
|
42 * Make it being able to leave if there are any errors here as there's no point in |
|
43 * trying to run a test step if anything fails. |
|
44 * The leave will be picked up by the framework. |
|
45 */ |
|
46 TVerdict CT_LbsHybridX3PStep::doTestStepPreambleL() |
|
47 { |
|
48 // Process some common pre setting to test steps then set SetTestStepResult to EFail or Epass. |
|
49 INFO_PRINTF1(_L("doTestStepPreabmleL()")); |
|
50 |
|
51 // The expected module GPS options |
|
52 T_LbsUtils utils; |
|
53 TPtrC configFileName; |
|
54 _LIT(KUpdateOptionsFile, "agps_module_update_file"); |
|
55 GetStringFromConfig(ConfigSection(), KUpdateOptionsFile, configFileName); |
|
56 utils.GetExpected_ModuleModes(configFileName, ConfigSection(), iExpectedModuleGpsOptions); |
|
57 if(iExpectedModuleGpsOptions.Count() > 0) |
|
58 { // if there are some options then start listening for events from the module |
|
59 iAgpsModuleEventListener = CT_AgpsModuleEventListener::NewL(*this); |
|
60 } |
|
61 |
|
62 SetTestStepResult(EPass); |
|
63 |
|
64 return TestStepResult(); |
|
65 } |
|
66 |
|
67 |
|
68 /** |
|
69 * @return - TVerdict |
|
70 * Implementation of CTestStep base class virtual |
|
71 * It is used for doing all after test treatment common to derived classes in here. |
|
72 * Make it being able to leave |
|
73 * The leave will be picked up by the framework. |
|
74 */ |
|
75 TVerdict CT_LbsHybridX3PStep::doTestStepPostambleL() |
|
76 { |
|
77 // Process some common post setting to test steps then set SetTestStepResult to EFail or Epass. |
|
78 INFO_PRINTF1(_L("doTestStepPostabmleL()")); |
|
79 TEST(iExpectedModuleGpsOptionsIndex == iExpectedModuleGpsOptions.Count()); |
|
80 iExpectedModuleGpsOptions.ResetAndDestroy(); |
|
81 iExpectedModuleGpsOptionsIndex = 0; |
|
82 delete iAgpsModuleEventListener; |
|
83 iAgpsModuleEventListener = NULL; |
|
84 |
|
85 //SetTestStepResult(EPass); // or EFail |
|
86 return TestStepResult(); |
|
87 } |
|
88 |
|
89 void CT_LbsHybridX3PStep::OnSetGpsOptions(const TLbsGpsOptions& aGpsOptions) |
|
90 /** |
|
91 * Compares the GPS options received by the AGPS module to the ones expected by the test |
|
92 */ |
|
93 { |
|
94 |
|
95 INFO_PRINTF1(_L("CT_LbsHybridX3PStep::OnSetGpsOptions()")); |
|
96 if(iExpectedModuleGpsOptionsIndex >= iExpectedModuleGpsOptions.Count()) |
|
97 { |
|
98 TEST(EFalse); |
|
99 return; |
|
100 } |
|
101 TLbsGpsOptions* expectedOptions = iExpectedModuleGpsOptions[iExpectedModuleGpsOptionsIndex]; |
|
102 ++iExpectedModuleGpsOptionsIndex; |
|
103 |
|
104 if(aGpsOptions.GpsMode() != expectedOptions->GpsMode()) |
|
105 { |
|
106 INFO_PRINTF3(_L("CT_LbsHybridX3PStep::OnSetGpsOptions - FAILED because got unexpected mode. Got 0x%x expected 0x%x()"), aGpsOptions.GpsMode(), expectedOptions->GpsMode()); |
|
107 TEST(EFalse); |
|
108 return; |
|
109 } |
|
110 if(aGpsOptions.ClassType() != expectedOptions->ClassType()) |
|
111 { |
|
112 INFO_PRINTF3(_L("CT_LbsHybridX3PStep::OnSetGpsOptions - FAILED because got unexpected class type. Got 0x%x expected 0x%x()"), aGpsOptions.ClassType(), expectedOptions->ClassType()); |
|
113 TEST(EFalse); |
|
114 return; |
|
115 } |
|
116 if(aGpsOptions.ClassType() & ELbsGpsOptionsArrayClass) |
|
117 { |
|
118 //INFO_PRINTF1(_L("CT_LbsHybridX3PStep::OnSetGpsOptions Got options array")); |
|
119 const TLbsGpsOptionsArray& optionsArr = reinterpret_cast<const TLbsGpsOptionsArray&>(aGpsOptions); |
|
120 const TLbsGpsOptionsArray& expectedOptionsArr = reinterpret_cast<const TLbsGpsOptionsArray&>(*expectedOptions); |
|
121 if(optionsArr.NumOptionItems() != expectedOptionsArr.NumOptionItems()) |
|
122 { |
|
123 INFO_PRINTF3(_L("CT_LbsHybridX3PStep::OnSetGpsOptions - FAILED because got unexpected number of options in array. Got %d expected %d)"), optionsArr.NumOptionItems(), expectedOptionsArr.NumOptionItems()); |
|
124 TEST(EFalse); |
|
125 return; |
|
126 } |
|
127 for(TInt index = 0; index < optionsArr.NumOptionItems(); ++index) |
|
128 { |
|
129 TLbsGpsOptionsItem item; |
|
130 TLbsGpsOptionsItem expectedItem; |
|
131 optionsArr.GetOptionItem(index, item); |
|
132 expectedOptionsArr.GetOptionItem(index, expectedItem); |
|
133 |
|
134 if(item.PosUpdateType() != expectedItem.PosUpdateType()) |
|
135 { |
|
136 INFO_PRINTF3(_L("CT_LbsHybridX3PStep::OnSetGpsOptions - FAILED because got unexpected position update type. Got %d expected %d)"), item.PosUpdateType(), expectedItem.PosUpdateType()); |
|
137 TEST(EFalse); |
|
138 return; |
|
139 } |
|
140 } |
|
141 } |
|
142 } |