applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp
branchRCL_3
changeset 9 2611c08ee28e
parent 7 337070b4fa18
child 18 f21293830889
equal deleted inserted replaced
8:fa2fd8b2d6cc 9:2611c08ee28e
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 #include "chttpservice.h"
    17 #include "chttpservice.h"
    18 #include "ctestclienthttpget.h"
    18 #include "ctestclienthttpget.h"
    19 #include "ctestclienthttppost.h"
    19 #include "ctestclienthttppost.h"
    20 #include <escapeutils.h>
    20 #include <escapeutils.h>
    21 #include <thttphdrval.h>
    21 #include <thttphdrval.h>
       
    22 #include <commdbconnpref.h>
    22 #include "httptestutils.h"
    23 #include "httptestutils.h"
    23 #include "clocaltestserver.h"
    24 #include "clocaltestserver.h"
    24 #include "chttpclienttestparams.h"
    25 #include "chttpclienttestparams.h"
    25 #include "ctesthttpserviceauthentication.h"
    26 #include "ctesthttpserviceauthentication.h"
       
    27 #include "chttpnetworkconnectioninfo.h"
    26 
    28 
    27 _LIT(KTestCaseName, "TestCaseName");
    29 _LIT(KTestCaseName, "TestCaseName");
    28 _LIT8(KUserAgent, "HTTP Client API Test");
    30 _LIT8(KUserAgent, "HTTP Client API Test");
    29 _LIT(KTestHttpClientAPITestTitle, "HTTP client API Unit Test Harness");
    31 _LIT(KTestHttpClientAPITestTitle, "HTTP client API Unit Test Harness");
    30 const TInt KMaxNoOfConnections = 6;
    32 const TInt KMaxNoOfConnections = 6;
    48     }
    50     }
    49 
    51 
    50 // TEF virtuals
    52 // TEF virtuals
    51 TVerdict CTestHttpClientStep::doTestStepPreambleL()
    53 TVerdict CTestHttpClientStep::doTestStepPreambleL()
    52     {
    54     {
       
    55     TInt status;
    53     iActiveScheduler = new (ELeave) CActiveScheduler();
    56     iActiveScheduler = new (ELeave) CActiveScheduler();
    54     CActiveScheduler::Install(iActiveScheduler);
    57     CActiveScheduler::Install(iActiveScheduler);
    55     iTestParamArray = new(ELeave) CHttpClientTestParamArray;
    58     iTestParamArray = new(ELeave) CHttpClientTestParamArray;
    56     iTestUtils = CHTTPTestUtils::NewL(KTestHttpClientAPITestTitle());
    59     iTestUtils = CHTTPTestUtils::NewL(KTestHttpClientAPITestTitle());
    57     iTestUtils->InitCommsL();
    60     
    58     
    61     
    59     iTestServer = CLocalTestServer::NewL(*iTestUtils, *this, *iTestParamArray);
    62     iTestServer = CLocalTestServer::NewL(*iTestUtils, *this, *iTestParamArray);
    60     iHttpClient = CHttpService::NewL();
    63     iHttpClient = CHttpService::NewL();
       
    64     TCommDbConnPref connPref;
       
    65     connPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
    66     connPref.SetIapId(1);
       
    67     connPref.SetNetId(0);
       
    68     iHttpConnInfo = iHttpClient->HttpNetworkConnection();
       
    69     status = iHttpConnInfo->Start();
    61     THttpHeaderValueVariant variant(KUserAgent());
    70     THttpHeaderValueVariant variant(KUserAgent());
    62     if(iHttpClient->AddRequestHeader(HTTP::EUserAgent, variant))
    71     if(iHttpClient->AddRequestHeader(HTTP::EUserAgent, variant))
    63         {
    72         {
    64         SetTestStepResult(EFail);
    73         SetTestStepResult(EFail);
    65         return TestStepResult();
    74         return TestStepResult();
   132    
   141    
   133     if(param->NoRetryOnDisconnect())
   142     if(param->NoRetryOnDisconnect())
   134         {
   143         {
   135         iHttpTrans->SetNoRetry();
   144         iHttpTrans->SetNoRetry();
   136         }
   145         }
   137     
       
   138     if(param->ResponseTimeoutEnable())
   146     if(param->ResponseTimeoutEnable())
   139         {
   147         {
   140         iHttpTrans->SetResponseTimeout(10);
   148         iHttpTrans->SetResponseTimeout(10);
   141         }
   149         }
   142     
       
   143     const RPointerArray<CHeaderInfo>& info = param->RequestHeaderInfos();
   150     const RPointerArray<CHeaderInfo>& info = param->RequestHeaderInfos();
   144     for(TInt i = 0; i < info.Count(); ++i)
   151     for(TInt i = 0; i < info.Count(); ++i)
   145         {
   152         {
   146         CHeaderInfo* headerInfo = info[i];
   153         CHeaderInfo* headerInfo = info[i];
   147         const TDesC8& headerName = *headerInfo->iFieldName;
   154         const TDesC8& headerName = *headerInfo->iFieldName;
   167                     TReal64 value = 0.;
   174                     TReal64 value = 0.;
   168                     lex.Val(value);             
   175                     lex.Val(value);             
   169                     THTTPHdrVal::TQConv q(value);
   176                     THTTPHdrVal::TQConv q(value);
   170                     TInt val2 = q;
   177                     TInt val2 = q;
   171                     THttpHeaderValueVariant variant2(val2);
   178                     THttpHeaderValueVariant variant2(val2);
   172                     // Set the header with the param
   179                     /// Set the header with the param
   173                     iHttpTrans->AddRequestHeader(headerName, variant, paramName, variant2);
   180                     iHttpTrans->AddRequestHeader(headerName, variant, paramName, variant2);
   174                     }
   181                     }
   175                 }
   182                 }
   176             }
   183             }
   177         }
   184         }