lbstest/lbstestproduct/lbshybridmolr/src/ctlbsmolrtracking.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 17 Sep 2010 08:37:32 +0300
changeset 60 9a7e3d5f461a
parent 36 b47902b73a93
permissions -rw-r--r--
Revision: 201037 Kit: 201037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
// Contributors:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
// Description:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
// This is the class implementation for the Module Information Tests
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
// EPOC includes.sue
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
// 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
//
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
// LBS includes. 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <lbssatellite.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include <lbs/lbsnetprotocolbase.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include <lbs/lbsassistancedatabuilderset.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include <lbs/lbsloccommon.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include <lbs/lbsx3p.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include <lbs/lbsnetprotocolbase.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include <lbs/lbslocdatasourceclasstypes.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include <lbs/lbslocdatasourcegpsbase.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
#include <lbs/epos_cposmodules.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
#include <lbs/epos_cposmoduleupdate.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
#include <lbs/epos_cposmoduleidlist.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
#include <e32math.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
#include <e32property.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
#include "lbsnetinternalapi.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
#include "LbsInternalInterface.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
#include "LbsExtendModuleInfo.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
#include "lbsdevloggermacros.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
// LBS test includes.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
#include "ctlbsmolrtracking.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
#include <lbs/test/tlbsutils.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
#include "argutils.h"
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
#include <lbs/test/activeyield.h>
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
60
9a7e3d5f461a Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    45
const TInt KSmallDelta = 800 * 1000; // 800 ms
36
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
Static Constructor
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
*/
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
CT_LbsMolrTracking* CT_LbsMolrTracking::New(CT_LbsHybridMOLRServer& aParent)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
	// Note the lack of ELeave.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
	// This means that having insufficient memory will return NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
	CT_LbsMolrTracking* testStep = new CT_LbsMolrTracking(aParent);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
	if (testStep)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
		TInt err = KErrNone;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
		TRAP(err, testStep->ConstructL());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
		if (err)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
			delete testStep;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
			testStep = NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
	return testStep;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
 * Constructor
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
CT_LbsMolrTracking::CT_LbsMolrTracking(CT_LbsHybridMOLRServer& aParent) 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
	: CT_LbsHybridMOLRStep(aParent),  
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
		iAdminGpsMode(CLbsAdmin::EGpsModeUnknown),  
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
		iGPSModeNotSupported(EFalse),
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
		iSpecialTestMode(0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
	SetTestStepName(KLbsMolrTracking);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
void CT_LbsMolrTracking::ConstructL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
	// Create the base class objects.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
	CT_LbsHybridMOLRStep::ConstructL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
 * Destructor
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
CT_LbsMolrTracking::~CT_LbsMolrTracking()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
	TRAP_IGNORE(doTestStepPostambleL());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
/**
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
 Things read from the ini file:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
 - Network Method (1 - TB, 2 - TBTA, 3 - TA, 4 - TATB)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
 - Planned Positions Originator (used in hybrid to decide where the position should 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
 			come from. Same for all positions returned, 1 - Module, 2 - Network)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
 - Could have checks for the module modes if wanted (optional, doesn't affect the test) 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
 			-first argument one of: 1 - PTB, 2 - ATB, 3 - Autonomous, 4 - PTA, 5 - ATA
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
 			-second and third argument can be 1 - Positions, 2 - Measurments
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
 - For each client the following information can be provided:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
 	- the starting delay, represented by two numbers:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
 	 	* the first one specifies after which network session to start - default is 0
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
 	 	* The second one specifies after which step in the network to start - default is 0;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
 	 		For a list of the network steps see ctlbsnetprotocol.h
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
 	- the number of NPUDs, default is one NPUD. One NPUD means not tracking, more than 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
 	 	that means the client is tracking
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
 	- the positioner options: interval, max fix time, max age, partial accepted.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
 			Default all zero and partial not accepted
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
 	- whether the client's NPUD request should be cancelled and at what stage
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
 			Default to not cancelled
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
 The number of clients is determined from how many entries are that contain 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
 client details. If there are no entries one default client is used. The information 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
 missing from an entry will be assumed to be default. If either the tracking interval 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
 or the number of NPUDs is set to indicate no tracking then this client will not 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
 do any tracking.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
 NOTE: The only way a client can do more NPUDs is if it's doing tracking
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
 NOTE: The Planned Position Originator has to be provided for all tests. Logic to 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
 		work it out when not running in hybrid hasn't been provided in the test yet
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
 TODO: Add some position checking and make the network position change
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
 TODO: Add logic to deal with the max fix time bigger than the interval and positions coming in 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
 			overlapping windows
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
 TODO: Sort out the PM returning a reference position in the right modes
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
 TODO: Checking of status changes for PM none <-> tracking 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
 Example of ini file entry:
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
 	[TEST]
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
	agps_module_update_file = c:\testdata\configs\test.ini
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
	$update,3,0,NAN,NAN,NAN,NAN,NAN*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
	$update,1,0,49.2,3.5,50,20,20*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
	$update,1,0,NAN,NAN,NAN,NAN,NAN*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
	$update,1,0,49.3,3.5,50,20,20*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
	$update,1,0,NAN,NAN,NAN,NAN,NAN*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
	$update,1,0,49.4,3.5,50,20,20*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
	$update,1,0,NAN,NAN,NAN,NAN,NAN*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
	$update,1,0,49.4,3.4,50,20,20*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
	$update,1,0,NAN,NAN,NAN,NAN,NAN*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
	$update,1,0,49.4,3.3,50,20,20*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
	$update,1,0,NAN,NAN,NAN,NAN,NAN*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
	$update,1,0,49.5,3.3,50,20,20*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
	// The network will request TB
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
	NetworkMethod = 1
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
	// It is expected that the module will return the position
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
	PositionOriginator = 1
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
	// The module should be set to PTB and then not set again (this is optional - for additional checking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
	// PTB
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
	$modulemodes,1*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
	// The client information
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
	// first client: session ID delay = 0, session step delay = 0, NPUDs = 4, interval = 10s, time out = 5s, max age = 0s, accept partial = false
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
	$clientdetails,0,0,4,10000000,5000000,0,false*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
	// second client: session ID delay = 1, session step delay = 4, NPUDs = 3, interval = 8s, time out = 3s, max age = 0s, accept partial = false
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
	$clientdetails,1,4,3,8000000,3000000,0,false*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
	// third client: session ID delay = 1, session step delay = 0, NPUDs = 1, interval = 0s, time out = 5s, max age = 0s, accept partial = false
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
	$clientdetails,1,0,1,0,5000000,0,false*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
	// fourth client: session ID delay = 4, session step delay = 3, NPUDs = 1 (so no tracking)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
	$clientdetails,4,3,1*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
	// fifth client: session ID delay = 4, session step delay = 3, no tracking
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
	$clientdetails,4,3*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
	// sixth client: no delay, no tracking (default client)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
	$clientdetails*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
	// seventh client: session ID delay = 0, session step delay = 0, NPUDs = 2, interval = 5s, time out = 5s, max age = 0s, accept partial = false, cancel = true, cancel session ID = 1, cancel session step = 3
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
	$clientdetails,0,0,2,5000000,5000000,0,false,cancel,1,3*
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
 */
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
TVerdict CT_LbsMolrTracking::doTestStepPreambleL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
	INFO_PRINTF1(_L("&gt;&gt;CT_LbsMolrTracking::doTestStepPreambleL()"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
	CT_LbsHybridMOLRStep::doTestStepPreambleL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
	// Get the GPS mode set in the Admin
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
	CLbsAdmin* admin = CLbsAdmin::NewL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
	CleanupStack::PushL(admin);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
	TESTL(KErrNone == admin->Get(KLbsSettingRoamingGpsMode, iAdminGpsMode));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
	CleanupStack::PopAndDestroy(admin);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
	// Set the test up so it expects that the GPS mode won't be supported if there is an incompatibility
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
	TPositionModuleInfoExtended::TDeviceGpsModeCapabilities deviceCapabilities;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
	TInt err = LbsModuleInfo::GetDeviceCapabilities(KLbsGpsLocManagerUid, deviceCapabilities);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
	if(!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB) && !(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
		if(iAdminGpsMode == CLbsAdmin::EGpsPreferTerminalAssisted || 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
				iAdminGpsMode == CLbsAdmin::EGpsAlwaysTerminalAssisted)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
			iGPSModeNotSupported = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
			}	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
	if(!(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB) && !(deviceCapabilities & TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
		if(iAdminGpsMode == CLbsAdmin::EGpsPreferTerminalBased || 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
				iAdminGpsMode == CLbsAdmin::EGpsAlwaysTerminalBased ||
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
				iAdminGpsMode == CLbsAdmin::EGpsAutonomous)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
			iGPSModeNotSupported = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
			}	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
		}	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
	SetTestStepResult(EPass);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
	T_LbsUtils utils;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
	iNetworkProtocol = CT_LbsNetProtocol::NewL(*this, *this);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
	// Get the Network Method
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
	_LIT(KNetworkMethod, "NetworkMethod");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
	TInt networkMethodInt;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
	if(GetIntFromConfig(ConfigSection(), KNetworkMethod, networkMethodInt))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
		iNetworkProtocol->SetNetworkMethod(networkMethodInt);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
	else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
		INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepPreambleL() - FAILED: no network method configured"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
		TEST(EFalse);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
	// Get the position originator
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
	_LIT(KPositionOriginator, "PositionOriginator");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
	TInt positionOriginatorInt;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
	if(GetIntFromConfig(ConfigSection(), KPositionOriginator, positionOriginatorInt))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
		iNetworkProtocol->SetPlannedPositionOriginator(positionOriginatorInt);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
	else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
		INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepPreambleL() - FAILED: no position originator configured"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
		TEST(EFalse);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
	// Get the SpecialTestModemode setting ... 0 means not in a LastKnownPosition mode
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
	_LIT(KLastKnownPosition, "SpecialTestMode");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
	TInt specialTestModeInt;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
	if(GetIntFromConfig(ConfigSection(), KLastKnownPosition, specialTestModeInt))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
		iSpecialTestMode = specialTestModeInt;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
	else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
		INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepPreambleL() - no SpecialTestMode in .ini section - setting mode to disabled"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
		iSpecialTestMode =0;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
	TPtrC configFileName;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
	_LIT(KUpdateOptionsFile, "agps_module_update_file");
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
	TEST(GetStringFromConfig(ConfigSection(), KUpdateOptionsFile, configFileName));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
	RArray<TCTClientDetails> clientDetailsArray;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
	CleanupClosePushL(clientDetailsArray);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
	utils.GetConfigured_ClientDetailsL(configFileName, ConfigSection(), clientDetailsArray);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
	for(TInt index = 1; index <= clientDetailsArray.Count(); ++index)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
		CT_LbsTestActiveManager* clientTestManager = CT_LbsTestActiveManager::NewL(index, *this, CActive::EPriorityStandard, *this);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
		iClientTestManagers.AppendL(clientTestManager);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
	for(TInt index = 0; index < clientDetailsArray.Count(); ++index)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
		CT_ClientData* client = new(ELeave) CT_ClientData(clientDetailsArray[index].iSessionIdDelay, clientDetailsArray[index].iSessionStepDelay, clientDetailsArray[index].iCancelRequest, clientDetailsArray[index].iSessionIdCancel, clientDetailsArray[index].iSessionStepCancel, clientDetailsArray[index].iNumberOfNPUDs, 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
							clientDetailsArray[index].iUpdateOptions, clientDetailsArray[index].iPsyId, clientDetailsArray[index].iExpectedError);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
		iClients.AppendL(client);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
	CleanupStack::PopAndDestroy(&clientDetailsArray);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
	return TestStepResult();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
TVerdict CT_LbsMolrTracking::doTestStepPostambleL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
	INFO_PRINTF1(_L("&gt;&gt;CT_LbsMolrTracking::doTestStepPostambleL()"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
	iClients.ResetAndDestroy();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
	iClientTestManagers.ResetAndDestroy();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
	if(iNetworkProtocol)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
		delete iNetworkProtocol;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
		iNetworkProtocol = NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
	iAdminGpsMode = CLbsAdmin::EGpsModeUnknown;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
	CT_LbsHybridMOLRStep::doTestStepPostambleL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
	return TestStepResult();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
TVerdict CT_LbsMolrTracking::doTestStepL()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
	INFO_PRINTF1(_L("CT_LbsMolrTracking::doTestStepL()"));	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
	// Stop the test if the preamble failed
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
	TESTL(TestStepResult() == EPass);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
	iNetworkProtocol->StartNetworkL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
	CActiveScheduler::Start();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
	return TestStepResult();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
void CT_LbsMolrTracking::OnReadyL(TInt aObjectId)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
	if(aObjectId > 0 && aObjectId <= iClients.Count())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
		DoClientStepL(aObjectId - 1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
		return;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
	User::Leave(KErrCorrupt);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
void CT_LbsMolrTracking::OnTimedOutL(TInt aObjectId)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
	INFO_PRINTF2(_L("Client number %d timed out waiting for a position"), aObjectId);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
	User::Leave(KErrTimedOut);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
void CT_LbsMolrTracking::OnGetLastKnownPositionL(TInt aObjectId, TInt32 aErr, const TPositionInfoBase&  /*aPosInfo*/)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
	INFO_PRINTF2(_L("CT_LbsMolrTracking::OnGetLastKnownPositionL()	>> LKNP() complete with %d"), aErr);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
	CT_ClientData& client = *(iClients[aObjectId-1]);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
	TInt numberOfNPUDs = client.iNumberOfNPUDs;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
	TInt positionsReceived = client.iPositionsReceived;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
	if (iSpecialTestMode==1)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
		INFO_PRINTF1(_L("CT_LbsMolrTracking::OnGetLastKnownPosition() - Special Test for FNP delivery"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
		INFO_PRINTF2(_L("Client number %d received a last known position"), aObjectId);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
		INFO_PRINTF3(_L("Client now has %d of %d positions"), positionsReceived+1, numberOfNPUDs);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
		INFO_PRINTF1(_L("CT_LbsMolrTracking::OnGetLastKnownPosition() - a network calculated FNP was correctly delivered"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
	else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
	INFO_PRINTF1(_L("CT_LbsMolrTracking::OnGetLastKnownPosition() - FAILED: not expecting this call"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
	TESTL(EFalse); // Shouldn't see this...
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
	++client.iPositionsReceived;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
	if(client.iPositionsReceived == client.iNumberOfNPUDs)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
		{ // stop this client tracking and close connection to the server also check that all the other clients have received positions as expected
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
		iClientTestManagers[aObjectId-1]->Deactivate();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
		delete client.iWatcher;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
		client.iWatcher = NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
		client.iPositioner.Close();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
		client.iServer.Close();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
		else // re-issue the request
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
		iClientTestManagers[aObjectId-1]->StartL(0);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
void CT_LbsMolrTracking::OnNotifyPositionUpdateL(TInt aObjectId, TInt32 aErr, const TPositionInfoBase& aPosInfo)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
	RDebug::Printf("LBSLog: LocSrv -> Client%d: Deliver Position, error = %d", aObjectId, aErr);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
	INFO_PRINTF2(_L("CT_LbsMolrTracking::OnNotifyPositionUpdate() >> NPUD() complete with %d"), aErr);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
	if(iGPSModeNotSupported)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
		TESTL(aErr == KErrNotSupported);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
	else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
		CT_ClientData& client = *(iClients[aObjectId-1]);		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
		TTime now;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
		now.HomeTime();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
		if(client.iRequestCancelled)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
			TESTL(aErr == KErrCancel);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
		else if(client.iExpectedError)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
			TESTL(aErr == client.iExpectedError);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
		else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
			TInt numberOfNPUDs = client.iNumberOfNPUDs;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
			TInt positionsReceived = client.iPositionsReceived;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
			INFO_PRINTF2(_L("Client number %d received a position"), aObjectId);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
			INFO_PRINTF3(_L("Client now has %d of %d positions"), positionsReceived+1, numberOfNPUDs);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
			if (iSpecialTestMode == 2)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   394
				
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
				INFO_PRINTF1(_L("testing MaxAge feature"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   396
				const TPositionInfo* lastPosReturned = static_cast<const TPositionInfo*>(&aPosInfo);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
				TPosition pos;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
				lastPosReturned->GetPosition(pos);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
	 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
				if (client.iPositionsReceived == 0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   401
					{ // if its the first one 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
					client.iTimeOfLastPosition = pos.Time();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
				else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
					if (client.iTimeOfLastPosition != pos.Time())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
						{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
						INFO_PRINTF1(_L("testing MaxAge feature - FAIL! position time was not same as previous"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
						TESTL(EFalse);	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
						}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   411
					else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
						{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
						INFO_PRINTF1(_L("testing MaxAge feature - PASS! position time was same as previous"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   414
						}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   415
					client.iTimeOfLastPosition = pos.Time();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   417
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   418
			else if (iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   419
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   420
					if ( (aErr == KPositionEarlyComplete) || (aErr == KErrNone))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   421
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   422
					INFO_PRINTF2(_L("testing early complete behaviour got correct error%d"), aErr);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   423
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
					else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   426
					INFO_PRINTF2(_L("testing early complete behaviour got error %d"), aErr);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
					TESTL(EFalse);	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
			else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   432
				// Normally it should be KErrNone
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   433
				TESTL(aErr == KErrNone);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   434
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   435
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   436
			// Verify position.
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
			//CT_ClientData& client = *(iClients[aObjectId-1]);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
			TESTL(aPosInfo.PositionClassType() == EPositionInfoClass);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
			if(iNetworkProtocol->PlannedPositionOriginator() == CT_LbsNetProtocol::EPositionOriginatorModule)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
				if(client.iAutonomousPsy)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
					INFO_PRINTF2(_L("Autonomous GPS client got position with techtype = %d"), aPosInfo.PositionMode());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   445
					TESTL( (aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal)) || (aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted)));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   446
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   447
				else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   448
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   449
					TESTL(aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   450
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   451
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   452
			if(iNetworkProtocol->PlannedPositionOriginator() == CT_LbsNetProtocol::EPositionOriginatorNetwork)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   453
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
				if (iSpecialTestMode==3)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   455
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   456
					INFO_PRINTF1(_L("testing early complete behaviour - don't check tech type"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   457
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   458
				else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   459
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   460
					TESTL(aPosInfo.PositionMode() == (TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   461
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   462
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   463
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   464
			if(iExpectedApiBehaviour == EApiVariant1)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   465
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   466
				if(client.iPositionsReceived == 0)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   467
					{ // record the time when a first position is received by the client
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
					client.iTimeOfInitialPosition.HomeTime();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
				else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
					{ // make sure that the position was received in the right window
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
					TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(client.iTimeOfInitialPosition);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
					
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
					if (iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
						{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
						INFO_PRINTF1(_L("testing early complete behaviour - don't check arrival time"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   477
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   478
						}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   479
					else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
						{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
						if (client.iUpdateOptions.UpdateInterval().Int64())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
							{ // if tracking
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
							if(interval.Int64() < client.iUpdateOptions.UpdateInterval().Int64() * client.iPositionsReceived && 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
									interval.Int64()+KSmallDelta >= client.iUpdateOptions.UpdateInterval().Int64() * client.iPositionsReceived)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
								{ // if the time is slightly before the window then allow for possible delays in the test framework
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
								interval = interval.Int64() + KSmallDelta;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
								}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   488
							if(interval.Int64() % client.iUpdateOptions.UpdateInterval().Int64() > client.iUpdateOptions.UpdateTimeOut().Int64() && 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   489
									(interval.Int64()-KSmallDelta) % client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   490
								{ // if the time is slightly after the window then allow for possible delays in the test framework
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   491
								interval = interval.Int64() - KSmallDelta;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
								}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   493
							TESTL(interval.Int64() / client.iUpdateOptions.UpdateInterval().Int64() == client.iPositionsReceived);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
							TESTL(interval.Int64() % client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
							}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
						}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   497
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
			else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
				{ // variant2 api behaviour
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
				if(client.iPositionsReceived > 0) // make sure that the position was received in the right window
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
					{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   503
					TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(client.iTimeOfPreviousPosition);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   504
					if (iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   505
						{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   506
						INFO_PRINTF1(_L("testing early complete behaviour - don't check arrival time"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   507
						}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   508
					else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   509
						{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   510
						if (client.iUpdateOptions.UpdateInterval().Int64())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   511
							{ // if tracking
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   512
							if(interval.Int64() < client.iUpdateOptions.UpdateInterval().Int64() && 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   513
									interval.Int64()+KSmallDelta >= client.iUpdateOptions.UpdateInterval().Int64())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   514
								{ // if the time is slightly before the window then allow for possible delays in the test framework
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
								interval = interval.Int64() + KSmallDelta;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
								}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
							if(interval.Int64() - client.iUpdateOptions.UpdateInterval().Int64() > client.iUpdateOptions.UpdateTimeOut().Int64() && 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
									(interval.Int64()-KSmallDelta) - client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   519
								{ // if the time is slightly after the window then allow for possible delays in the test framework
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   520
								interval = interval.Int64() - KSmallDelta;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
								}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
							TESTL(interval.Int64() >= client.iUpdateOptions.UpdateInterval().Int64());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
							TESTL(interval.Int64() - client.iUpdateOptions.UpdateInterval().Int64() <= client.iUpdateOptions.UpdateTimeOut().Int64());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
							}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
						}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
				client.iTimeOfPreviousPosition.HomeTime();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
		++client.iPositionsReceived;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   532
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
		if(client.iPositionsReceived == client.iNumberOfNPUDs)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   534
			{ // stop this client tracking and close connection to the server also check that all the other clients have received positions as expected
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   535
			iClientTestManagers[aObjectId-1]->Deactivate();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   536
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   537
			delete client.iWatcher;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   538
			client.iWatcher = NULL;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
			client.iPositioner.Close();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
			client.iServer.Close();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
			TBool moreActiveClients(EFalse);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
			if(iSpecialTestMode==3) // testing early complete behaviour when have multiple client requests 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
				INFO_PRINTF1(_L("testing early complete behaviour - don't check arrival times are in tracking windows"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   548
			else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
				for(TUint index = 0; index < iClients.Count(); ++index)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   551
					{ // for each client check that the positions were received in the right window until now
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
					if(!iClientTestManagers[index]->IsDeactivated())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
						{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
						moreActiveClients = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
						CT_ClientData& clientToCheck = *(iClients[index]);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
						if((!(clientToCheck.iRequestCancelled)) && (clientToCheck.iPositionsReceived > 0) &&  !(clientToCheck.iExpectedError))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
							{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
							if(iExpectedApiBehaviour == EApiVariant1)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
								{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
								TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(clientToCheck.iTimeOfInitialPosition);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
								if (client.iUpdateOptions.UpdateInterval().Int64())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
									{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
						
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   564
									TESTL(interval.Int64() / clientToCheck.iUpdateOptions.UpdateInterval().Int64() == clientToCheck.iPositionsReceived-1 || // either the client received all the positions already 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   565
									(interval.Int64() / clientToCheck.iUpdateOptions.UpdateInterval().Int64() == clientToCheck.iPositionsReceived &&  // or the window to receive a position is now and it's RunL didn't get called yet
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   566
									 interval.Int64() % clientToCheck.iUpdateOptions.UpdateInterval().Int64() <= clientToCheck.iUpdateOptions.UpdateTimeOut().Int64()));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   567
									}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
								}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
							else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
								{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
								TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(clientToCheck.iTimeOfPreviousPosition);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
								if (client.iUpdateOptions.UpdateInterval().Int64())
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
									{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
									TESTL(interval.Int64() - clientToCheck.iUpdateOptions.UpdateInterval().Int64() - KSmallDelta <= 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
												clientToCheck.iUpdateOptions.UpdateTimeOut().Int64());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
									}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
								}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
							}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
						}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
					}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   583
			if(!moreActiveClients)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
				{ // if all the clients finished then tell the network to close the session
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   585
				iNetworkProtocol->SignalClientsFinished();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   586
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   587
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   588
		else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   589
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   590
			// re-issue the request
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   591
			iClientTestManagers[aObjectId-1]->StartL(0);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   592
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   593
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   594
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   595
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   596
void CT_LbsMolrTracking::StopTest()
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   597
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   598
	CActiveScheduler::Stop();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   599
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   600
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   601
void CT_LbsMolrTracking::OnSignalNetworkStep(TInt aSessionId, TInt aSessionStep)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   602
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   603
	for(TInt index = 0; index < iClientTestManagers.Count(); ++index)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   604
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   605
		CT_ClientData& client = *iClients[index];
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   606
		if(client.iInitialStep)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   607
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   608
			if(aSessionId > client.iSessionIdDelay || 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   609
					(aSessionId == client.iSessionIdDelay && aSessionStep >= client.iSessionStepDelay))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   610
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   611
				iClientTestManagers[index]->StartL(0);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   612
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   613
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   614
		if(client.iCancelRequest && !(client.iRequestCancelled))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   615
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   616
			INFO_PRINTF3(_L("Waiting to cancel. At network session %d, step %d"), aSessionId, aSessionStep);			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   617
			if(aSessionId > client.iSessionIdCancel || 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   618
					(aSessionId == client.iSessionIdCancel && aSessionStep >= client.iSessionStepCancel))
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   619
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   620
				// cancel oustanding NPUD
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   621
				INFO_PRINTF3(_L("Cancelling Request for Client %d's NPUD %d"),index+1, client.iPositionsReceived+1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   622
				__ASSERT_DEBUG((client.iNumberOfNPUDs == client.iPositionsReceived + 1), User::Invariant());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   623
				RDebug::Printf("LBSLog: Client%d -> LocSrv : CancelRequest", index+1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   624
				client.iWatcher->CancelRequest();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   625
				client.iRequestCancelled = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   626
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   627
			}		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   628
		}	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   629
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   630
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   631
void CT_LbsMolrTracking::DoClientStepL(TInt aIndex)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   632
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   633
	CT_ClientData& client = *(iClients[aIndex]);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   634
	const TInt KPosTimeOutDelay = 6 * 1000 * 1000; // this is so it leaves some space for delays due to other things in the test running
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   635
	TInt posTimeOut(KPosTimeOutDelay);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   636
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   637
	TInt positionsReceived = client.iPositionsReceived;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   638
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   639
	if(client.iInitialStep)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   640
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   641
		TESTL(KErrNone == client.iServer.Connect());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   642
		TRequestStatus dbclear;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   643
		client.iServer.EmptyLastKnownPositionStore(dbclear);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   644
		User::WaitForRequest(dbclear);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   645
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   646
		if(client.iPsyUid)	// client wants a particular psy
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   647
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   648
			EnablePsy(client.iPsyUid);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   649
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   650
			TPositionModuleInfo moduleInfo;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   651
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   652
			client.iServer.GetModuleInfoById(TUid::Uid(client.iPsyUid), moduleInfo);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   653
			
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   654
			if(moduleInfo.TechnologyType() == TPositionModuleInfo::ETechnologyTerminal)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   655
				{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   656
				client.iAutonomousPsy = ETrue;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   657
				}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   658
			TESTL(KErrNone == client.iPositioner.Open(client.iServer, TUid::Uid(client.iPsyUid)));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   659
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   660
		else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   661
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   662
			TESTL(KErrNone == client.iPositioner.Open(client.iServer));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   663
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   664
		TPositionUpdateOptions updateOptions(client.iUpdateOptions);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   665
		if(iExpectedApiBehaviour == EApiVariant2)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   666
			{ // for variant 2 of the API behaviour the timeout is considered from the time of the NPUD, rather than from the target time
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   667
			updateOptions.SetUpdateTimeOut(updateOptions.UpdateTimeOut().Int64() + updateOptions.UpdateInterval().Int64());
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   668
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   669
		client.iPositioner.SetUpdateOptions(updateOptions);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   670
		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   671
		client.iWatcher = CPosServerWatcher::NewLC(client.iPositioner, *(iClientTestManagers[aIndex]));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   672
		CleanupStack::Pop(client.iWatcher);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   673
		client.iInitialStep = EFalse;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   674
		posTimeOut += client.iUpdateOptions.UpdateTimeOut().Int64();; 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   675
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   676
	else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   677
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   678
		posTimeOut += client.iUpdateOptions.UpdateInterval().Int64() + client.iUpdateOptions.UpdateTimeOut().Int64(); 		
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   679
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   680
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   681
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   682
	if ((iSpecialTestMode == 1) && (aIndex == 0) && (positionsReceived == 1)) 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   683
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   684
		INFO_PRINTF2(_L("Client number %d issuing LKNP request"), aIndex+1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   685
		client.iWatcher->IssueGetLastKnownPosition();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   686
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   687
	else
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   688
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   689
		INFO_PRINTF2(_L("Client number %d issuing NPUD request"), aIndex+1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   690
		RDebug::Printf("LBSLog: Client%d -> LocSrv : NotifyPositionUpdate", aIndex+1);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   691
		client.iWatcher->IssueNotifyPositionUpdate();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   692
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   693
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   694
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   695
	if (iSpecialTestMode==3)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   696
		{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   697
		if ((aIndex == 0) && (positionsReceived == 0)) 	// in this mode client 1 will immediately  CompleteRequest the 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   698
														// NPUD. The  test has contrived to have an ongoing MoLr
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   699
														// because client 2 has an outstanding NPUD that should not 
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   700
														// be interfered with 	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   701
			{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   702
			INFO_PRINTF1(_L("CompleteRequest!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"));
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   703
			client.iWatcher->CompleteRequest() ;
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   704
			}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   705
		}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   706
	iClientTestManagers[aIndex]->WaitForPosition(posTimeOut);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   707
	}
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   708
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   709
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   710
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   711
void CT_LbsMolrTracking::EnablePsy(TInt aPsyUid)
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   712
	{
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   713
	CPosModules* db = CPosModules::OpenL();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   714
	CleanupStack::PushL(db);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   715
	CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   716
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   717
	CPosModuleIdList* prioList = db->ModuleIdListLC();
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   718
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   719
	// Enable the PSY that came as an in parameter
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   720
	moduleUpdate->SetUpdateAvailability(ETrue);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   721
	db->UpdateModuleL(TUid::Uid(aPsyUid), *moduleUpdate);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   722
	
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   723
	CleanupStack::PopAndDestroy(prioList);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   724
	CleanupStack::PopAndDestroy(moduleUpdate);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   725
	CleanupStack::PopAndDestroy(db);
b47902b73a93 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   726
}