lbs/lbsclient/src/ctlbsclientpostp179.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 //  INCLUDES
       
    19 #include "ctlbsclientpostp179.h"
       
    20 #include "ctlbsposclientholder.h"
       
    21 #include <e32keys.h>
       
    22 
       
    23 // CONSTANTS
       
    24 _LIT(KPosPhoneTimeLocaleFormat,
       
    25      "         phone time: %F%H:%F%T:%F%S:%F%C");
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 // ---------------------------------------------------------
       
    30 // Constructor.
       
    31 // ---------------------------------------------------------
       
    32 CT_LbsClientPosTp179::CT_LbsClientPosTp179(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
       
    33 	{ 
       
    34 	_LIT(KTestName, "Tp179 - One Client, same PSY");
       
    35 	SetTestStepName(KTestName); 
       
    36 	}
       
    37 
       
    38 // ---------------------------------------------------------
       
    39 // Destructor.
       
    40 // ---------------------------------------------------------
       
    41 CT_LbsClientPosTp179::~CT_LbsClientPosTp179()
       
    42 	{
       
    43 	}
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // CT_LbsClientPosTp179::CloseTest
       
    47 // Always called after the test, even if the test leaves
       
    48 // (other items were commented in a header).
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 void CT_LbsClientPosTp179::CloseTest()
       
    52     {
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------
       
    56 // CT_LbsClientPosTp179::StartL
       
    57 //
       
    58 // (other items were commented in a header).
       
    59 // ---------------------------------------------------------
       
    60 //
       
    61 void CT_LbsClientPosTp179::StartL()
       
    62     {  
       
    63     const TInt NumClients = 3;
       
    64 	SetupPsyL(iUidTestPsy12);
       
    65 
       
    66     //Make one request, the performance requirement are not valid for
       
    67     //the first request.
       
    68     TTime startTime, stopTime;
       
    69     TTime serverStartTime, serverStopTime;
       
    70     TTimeIntervalMicroSeconds requestTime, connectionTime;
       
    71     TBuf<150> buf;
       
    72 
       
    73     serverStartTime.UniversalTime();
       
    74     ConnectL();
       
    75     serverStopTime.UniversalTime();
       
    76 
       
    77     User::LeaveIfError(OpenPositioner());
       
    78 
       
    79     TPositionInfo posInfo = TPositionInfo();
       
    80     _LIT(KService, "service");
       
    81     // Request data from default psy should be test psy 2
       
    82     startTime.UniversalTime();
       
    83     TInt err = PerformSyncRequest(KService, &posInfo);
       
    84     stopTime.UniversalTime();
       
    85 
       
    86     if (err != KErrNone)
       
    87         {
       
    88         _LIT(KErrorRequest, "The request was not completed with KErrorNone");
       
    89         LogErrorAndLeaveL(KErrorRequest);
       
    90         }
       
    91 
       
    92     requestTime = stopTime.MicroSecondsFrom(startTime);
       
    93     connectionTime = serverStopTime.MicroSecondsFrom(serverStartTime);
       
    94 
       
    95     // Added some extra timing here
       
    96     _LIT(KDebug, "Connecting to Epos took: %d us");
       
    97     buf.Format(KDebug, connectionTime.Int64());
       
    98     INFO_PRINTF1(buf);
       
    99     _LIT(KSeparator, "********");
       
   100     INFO_PRINTF1(KSeparator);
       
   101     buf.Zero();
       
   102     _LIT(KFirstRequest, "The first request took: %d us");
       
   103     buf.Format(KFirstRequest, requestTime.Int64());
       
   104     INFO_PRINTF1(buf);
       
   105     INFO_PRINTF1(KSeparator);
       
   106 
       
   107     CT_LbsPosClientHolder* clients = CT_LbsPosClientHolder::NewLC(NumClients, iUidTestPsy12, ETrue);
       
   108     
       
   109     TTime starttime,stoptime;
       
   110     
       
   111     starttime.UniversalTime();
       
   112     
       
   113     clients->MakeRequests();
       
   114     
       
   115     stoptime.UniversalTime();
       
   116     
       
   117      // Substract total delay incurred due to TestPsy2...i.e 2sec
       
   118     TInt duration=stoptime.Int64()-starttime.Int64()-2000000;
       
   119     
       
   120     _LIT(KMessage,"3 simultaneous requests from 3 different sub-sessions with a psy completed in %d microsec");
       
   121     TBuf<256> message;
       
   122     message.Format(KMessage,duration);
       
   123     INFO_PRINTF1(message);
       
   124     
       
   125     if(duration>3000000)
       
   126     {
       
   127      _LIT(KTime, "Time taken>3 sec");
       
   128      INFO_PRINTF1(KTime);
       
   129     }
       
   130     
       
   131     TPositionInfo position[NumClients];
       
   132 
       
   133     TTimeIntervalMicroSeconds
       
   134         reqTime[NumClients],
       
   135         reqTimeLimit(5000000),
       
   136         timeDifferenceLimit(500000);
       
   137     TInt status;
       
   138     TBool error = EFalse;
       
   139 
       
   140 	//some printing mostly used for information purpose.
       
   141     for (TInt i = 0; i < NumClients; i++)
       
   142         {
       
   143         clients->GetResult(status, position[i], reqTime[i], i);
       
   144 		TPosition tmp;
       
   145 		position[i].GetPosition(tmp);
       
   146         if (status != 0)
       
   147             {
       
   148             _LIT(KError, "The position requested could not be retrieved, status = %d");
       
   149             buf.Format(KError, status);
       
   150             ERR_PRINTF1(buf);
       
   151             error = ETrue;
       
   152             }
       
   153         if (reqTime[i].Int64() > reqTimeLimit.Int64())
       
   154             {
       
   155             _LIT(KErrorMsg, "The request time of client %d took more than 5 seconds, req. time = %d microsecs.");
       
   156             buf.Format(KErrorMsg, i, reqTime[i].Int64());
       
   157             ERR_PRINTF1(buf);
       
   158             error = ETrue;
       
   159             }
       
   160         for (TInt j = 0; j < i; j++)
       
   161             {
       
   162             _LIT(KReqMsg, "client %d request time: %d");
       
   163 
       
   164             buf.Format(KReqMsg, j, reqTime[j].Int64());
       
   165             INFO_PRINTF1(buf);
       
   166 			TPosition posi;
       
   167 			TPosition posj;
       
   168 			position[i].GetPosition(posi);
       
   169 			position[j].GetPosition(posj);
       
   170             posj.Time().FormatL(buf, KPosPhoneTimeLocaleFormat);
       
   171             INFO_PRINTF1(buf);
       
   172 
       
   173             buf.Format(KReqMsg, i, reqTime[i].Int64());
       
   174             INFO_PRINTF1(buf);
       
   175             posi.Time().FormatL(buf, KPosPhoneTimeLocaleFormat);
       
   176             INFO_PRINTF1(buf);
       
   177 
       
   178             _LIT(KSeparator, "********");
       
   179             INFO_PRINTF1(KSeparator);
       
   180 
       
   181             if (Abs(reqTime[i].Int64() - reqTime[j].Int64()) > timeDifferenceLimit.Int64())
       
   182                 {
       
   183                 _LIT(KMsg1, "Requests by client %d and %d wasn't served simultaniously: %d microsecs difference between reqTime.");
       
   184                 TBuf<150> buf;
       
   185                 buf.Format(KMsg1, i, j, Abs(reqTime[i].Int64() - reqTime[j].Int64()));
       
   186                 ERR_PRINTF1(buf);
       
   187                 error = ETrue;
       
   188                 }
       
   189             if (Abs(posi.Time().Int64() - posj.Time().Int64()) > timeDifferenceLimit.Int64())
       
   190                 {
       
   191                 _LIT(KMsg2, "Requests by client %d and %d wasn't served simultaniously: %d microsecs difference between phoneTime.");
       
   192                 TBuf<150> buf;
       
   193                 buf.Format(KMsg2, i, j, Abs(posi.Time().Int64() - posj.Time().Int64()));
       
   194                 ERR_PRINTF1(buf);
       
   195                 error = ETrue;
       
   196                 }
       
   197             }
       
   198         }
       
   199 
       
   200     CleanupStack::PopAndDestroy(); //clients
       
   201     ClosePositioner();
       
   202 
       
   203 	Disconnect();
       
   204 
       
   205     if (error)
       
   206         User::Leave(KErrGeneral);
       
   207     }