//! @File
//! @SYMTestSuiteName	SF-LBS-X3P-CANCELREFPOS
//! @SYMScriptTestEnvironment TEF
//
//Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
//All rights reserved.
//This component and the accompanying materials are made available
//under the terms of "Eclipse Public License v1.0"
//which accompanies this distribution, and is available
//at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
//Initial Contributors:
//Nokia Corporation - initial contribution.
//
//Contributors:
//
//Description:

LOAD_SUITE SfLbsX3PTestServer -SharedData

PRINT Run SfLbsX3PTestServer
PRINT

// Before we start LBS, select the test A-GPS integration module to use.
PREFIX RUN_UTILS
MkDir c:\private\10282253\
MkDir c:\private\10282253\lbs\
MkDir c:\private\10282253\lbs\locmods\
CopyFile c:\testdata\configs\xtestmodule.ini c:\private\10282253\lbs\locmods\agpsintegmodule.ini
CopyFile c:\testdata\configs\lbstestconfig.txt c:\config.txt
REMOVE_PREFIX

PRINT Start LBS
RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_ResetDefaultAdmin
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_StartLbs



START_TESTCASE                SFLBS-X3P-CancelRefPos-0001
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0001
//! @SYMTestCaseDesc            Call RlbsTransmitPosition::CancelTransmitPosition() when no transmit is outstanding.
//! @SYMTestPriority            High
//! @SYMTestActions             1. Open sub-session
//!                             2. Do not request X3P
//!                             3. Attempt to cancel X3P
//! @SYMTestExpectedResults     CancelTransmitPosition() fails with KErrNotFound
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0001

END_TESTCASE SFLBS-X3P-CancelRefPos-0001


START_TESTCASE                SFLBS-X3P-CancelRefPos-0002
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0002
//! @SYMTestCaseDesc            Request X3P, then cancel request before MO-LR started ()
//! @SYMTestPriority            High
//! @SYMTestActions             1. Open a session with the transmit position server
//!                             2. Create a sub-session
//!                             3. Request current position be sent to a third party ? RlbsTransmitPosition::TransmitPosition()
//!                             giving a valid destination Id (email/phone number).
//!                             4. RLbsTransmitPosition::CancelTransmitPosition()
//!                             5. Wait for request to complete
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrCancel
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

//	May not be possible to implement. Need to get the cancel in after the NRH sends the request to the NG, 
//	but before the protocol module sends the MOLR to the network.

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0002

END_TESTCASE SFLBS-X3P-CancelRefPos-0002


START_TESTCASE                SFLBS-X3P-CancelRefPos-0003
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0003
//! @SYMTestCaseDesc            Request X3P, then cancel request before MO-LR started ()
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Tell NetSim that next request should have a time delay (needed)
//!                             2. Request current position be sent to a third party ? RlbsTransmitPosition::TransmitPosition()
//!                             3. Wait for notification from NetSim that MOLR has been sent
//!                             4. RLbsTransmitPosition::CancelTransmitPosition()
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel in CActive::Cancel()
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

//	ISSUE: Jarek mentioned using the timelag feature in NetSim for the MOLR, but not sure why that would be needed?

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0003

END_TESTCASE SFLBS-X3P-CancelRefPos-0003


START_TESTCASE                SFLBS-X3P-CancelRefPos-0004
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0004
//! @SYMTestCaseDesc            Request X3P, then cancel request after location request received
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Request current position be sent to a third party ? RlbsTransmitPosition::TransmitPosition()
//!                             2. Wait for notification of Location Request from network (sent in response to MOLR)
//!                             3. RLbsTransmitPosition::CancelTransmitPosition()
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel in CActive::Cancel()
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

//	ISSUE: Jarek mentioned using the timelag feature in NetSim for the MOLR, but not sure why that would be needed?

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0004

END_TESTCASE SFLBS-X3P-CancelRefPos-0004


START_TESTCASE                SFLBS-X3P-CancelRefPos-0005
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0005
//! @SYMTestCaseDesc            Request X3P, then cancel request after responding to location request
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Request current position be sent to a third party ? RlbsTransmitPosition::TransmitPosition()
//!                             2. Wait for notification of response to Location Request from network
//!                             3. RLbsTransmitPosition::CancelTransmitPosition()
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel in CActive::Cancel()
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0005

END_TESTCASE SFLBS-X3P-CancelRefPos-0005


START_TESTCASE                SFLBS-X3P-CancelRefPos-0006
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0006
//! @SYMTestCaseDesc            Request X3P, then cancel request after protocol module closed MOLR but before it sent X3P complete to NRH
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Request current position be sent to a third party ? RlbsTransmitPosition::TransmitPosition()
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel in CActive::Cancel()
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

//	ISSUES: Currently not possible to implement. Think it would require new functionality (to insert a time lag) in NetSim

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0006
RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_VerifyPosInfos

END_TESTCASE SFLBS-X3P-CancelRefPos-0006


START_TESTCASE                SFLBS-X3P-CancelRefPos-0007
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0007
//! @SYMTestCaseDesc            Description was missing
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Request current position be sent to a third party - RlbsTransmitPosition::TransmitPosition()
//!                             2. Try to cancel Active object using Cancel function and in the cancel function call CancelTransmitPostion()
//! @SYMTestExpectedResults     TransmitPosition should be canceled without any problem
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

//	ISSUES: Currently not possible to implement. Think it would require new functionality (to insert a time lag) in NetSim

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0007

END_TESTCASE SFLBS-X3P-CancelRefPos-0007


START_TESTCASE                SFLBS-X3P-CancelRefPos-0008
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0008
//! @SYMTestCaseDesc            Description was missing
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Create two transmit Positional objects
//!                             2. Call TransmitPosition from the first one
//!                             3. Try canceling on the second TransmitPosition object
//! @SYMTestExpectedResults     Transmit Postion should complete properly on first one. Cancel on second one should not have any effect
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

//	ISSUES: Currently not possible to implement. Think it would require new functionality (to insert a time lag) in NetSim

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0008
RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_VerifyPosInfos

END_TESTCASE SFLBS-X3P-CancelRefPos-0008


START_TESTCASE                SFLBS-X3P-CancelRefPos-0009
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0009
//! @SYMTestCaseDesc            Description was missing
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Create two transmit Positional objects
//!                             2. Call TransmitPosition from the first one
//!                             3. Try canceling on the second TransmitPosition object using Active Object->Cancel() function
//! @SYMTestExpectedResults     Transmit Postion should complete properly on first one. Cancel on second one should not have any effect
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

//	ISSUES: Currently not possible to implement. Think it would require new functionality (to insert a time lag) in NetSim

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0009
RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_VerifyPosInfos

END_TESTCASE SFLBS-X3P-CancelRefPos-0009


START_TESTCASE                SFLBS-X3P-CancelRefPos-0011
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0011
//! @SYMTestCaseDesc            Request X3P, then cancel after network has provided MoLrResult
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Request current position be sent to a third party ? RlbsTransmitPosition::TransmitPosition()
//!                             2. Wait for NetSim's notification that MOLR result has been sent to LBS
//!                             3. RLbsTransmitPosition::CancelTransmitPosition()
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel in CActive::Cancel()
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0011

END_TESTCASE SFLBS-X3P-CancelRefPos-0011


START_TESTCASE                SFLBS-X3P-CancelRefPos-0012
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0012
//! @SYMTestCaseDesc            Request X3P, then cancel X3P RefPos active object
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Request current position be sent to a third party - RlbsTransmitPosition::TransmitPosition()
//!                             2. Cancel X3P Refpos active object
//!                             3. wait for request to complete
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel in CActive::Cancel()
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0012

END_TESTCASE SFLBS-X3P-CancelRefPos-0012


START_TESTCASE                SFLBS-X3P-CancelRefPos-0013
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0013
//! @SYMTestCaseDesc            Request X3P, then cancel X3P when X3P RefPos active object completes
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Request current position be sent to a third party - RlbsTransmitPosition::TransmitPosition()
//!                             2. Cancel X3P when X3P Reference position is received
//!                             3. Wait for X3P to complete
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released

RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 060 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0013

END_TESTCASE SFLBS-X3P-CancelRefPos-0013
//This test added at end because it caused the next test fail. 
//Cancelling at More assistance data callback causes Network Gateway to ask for assistance data which affects next test


START_TESTCASE                SFLBS-X3P-CancelRefPos-0010
//! @SYMTestCaseID              SFLBS-X3P-CancelRefPos-0010
//! @SYMTestCaseDesc            Cancel X3P when we get NotifyMeasurementReportRequestMoreAssitanceData callback from NetSim
//! @SYMTestPriority            Critical
//! @SYMTestActions             1. Set modDataIn.iAssDataTestMode = TModuleDataIn::EModuleTestModeAssDataOn_SomeDataNotAvailable so that
//!                             Lbs system will ask for more assistance data to get position
//!                             2. Call TransmitPostion
//!                             3. Wait for NotifyMeasurementReportRequestMoreAssitanceData callback from NetSim
//!                             4. Call CancelTransmitPosition() to cancel X3P
//! @SYMTestExpectedResults     No panic. X3P request completes with KErrNone or KErrCancel in CActive::Cancel()
//! @SYMTestType                CIT
//! @SYMTestStatus              3. Released


RUN_TEST_STEP 010 SfLbsX3PTestServer LbsStep_InstallScheduler
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_CreateVerifyPosInfos 
RUN_TEST_STEP 120 SfLbsX3PTestServer LbsX3PStep_Cancel c:\testdata\configs\sflbsx3pcancelrefpos.ini LBS-X3P-Cancel-0010

END_TESTCASE SFLBS-X3P-CancelRefPos-0010
PRINT Stop LBS
RUN_TEST_STEP 020 SfLbsX3PTestServer LbsStep_StopLbs
// Re-select the real A-GPS integration module.
RUN_UTILS DeleteFile c:\private\10282253\lbs\locmods\agpsintegmodule.ini
// Delete network registration status text file
RUN_UTILS DeleteFile c:\config.txt


