--- a/common/build.test.xml Wed Jan 06 13:17:03 2010 +0000
+++ b/common/build.test.xml Wed Jan 06 13:41:51 2010 +0000
@@ -119,6 +119,7 @@
<arg value="--src=${sf.spec.test.package.location}/../bctest/${program}"/>
<arg value="--dest=${sf.spec.test.package.location}\${env.COMPUTERNAME}-bctest-${build.id}_${program}" />
<arg value="--publish=${publish.dir}\ats_reports\${program}"/>
+ <arg value="--bld-drive=${build.drive}"/>
</exec>
<!-- Now ready to send to ATS3 -->
<echo message="Sending Test drop : ${program} ............" />
--- a/common/tools/ats/ats_specialise_test_drop.pl Wed Jan 06 13:17:03 2010 +0000
+++ b/common/tools/ats/ats_specialise_test_drop.pl Wed Jan 06 13:41:51 2010 +0000
@@ -12,6 +12,7 @@
#
# Contributors:
# Brendan Donegan, brendand@symbian.org
+# Maciej Seroka, maciejs@symbian.org
#
# Description:
# This is a tool for setting the name of an ATS test drop, and/or the build id
@@ -38,6 +39,7 @@
my $xml_in; # Name of the input xml file. Always 'test.xml' if extracted from zipped test drop.
my $temp_dest_name; # Leafname of temporary output file, if $destfile undefined.
my $publish; # Publishing folder for ats reports.
+my $bld_drive; # Subst'd drive
sub usage($);
sub help();
@@ -50,7 +52,8 @@
'src' => \$srcfile,
'dest' => \$destfile,
'help' => \$help,
- 'publish' => \$publish);
+ 'publish' => \$publish,
+ 'bld-drive' => \$bld_drive);
GetOptions(\%optmap,
'test-drop-name=s',
@@ -59,12 +62,13 @@
'src=s',
'dest=s',
'help!',
- 'publish=s')
+ 'publish=s',
+ 'bld-drive=s')
or usage_error();
# Check if Tie::File module installed
eval("use Tie::File");
-if ($@) { $publish = '' };
+if ($@) { $publish = ''; $bld_drive = ''; };
if ($help) {
help();
@@ -171,6 +175,14 @@
}
untie @lines;
}
+ if ($bld_drive) { #Replace D:\ATS\winscw_smoketest path with subst'd drive
+ my @LINE;
+ tie @LINE, 'Tie::File', "test.xml" or die("Cannot tie file \"test.xml\". $!\n");
+ for (@LINE) {
+ s/D:\\ATS\\winscw_smoketest/$bld_drive/g;
+ }
+ untie @LINE;
+ }
if ( -f "$destfile.zip") {
unlink("$destfile.zip") or die("Could not delete \"$destfile.zip\": $!\n");
}
--- a/common/tools/ats/smoketest/Group/bld.inf Wed Jan 06 13:17:03 2010 +0000
+++ b/common/tools/ats/smoketest/Group/bld.inf Wed Jan 06 13:41:51 2010 +0000
@@ -33,3 +33,4 @@
#include "../localisation/uiftestfw/group/BLD.INF"
#include "../localisation/apparchitecture/group/BLD.INF"
#include "../graphics/wserv/group/bld.inf"
+#include "../http/group/bld.inf"
--- a/common/tools/ats/smoketest/Group/smoketest.pl Wed Jan 06 13:17:03 2010 +0000
+++ b/common/tools/ats/smoketest/Group/smoketest.pl Wed Jan 06 13:41:51 2010 +0000
@@ -17,6 +17,7 @@
mkpath "temp/smoketest/resource/general";
mkpath "temp/smoketest/localisation/general";
mkpath "temp/smoketest/bitmap/general";
+mkpath "temp/smoketest/ethernet/general";
my $epoc=$ENV{'EPOCROOT'} . "epoc32/";
copy("smoketest.xml", "temp/test.xml");
@@ -41,6 +42,8 @@
copy($epoc . "data/z/smoketest/smoketest_language.script", "temp/smoketest/general/smoketest_language.script");
copy($epoc . "data/z/smoketest/smoketest_bitmap.ini", "temp/smoketest/general/smoketest_bitmap.ini");
copy($epoc . "data/z/smoketest/smoketest_bitmap.script", "temp/smoketest/general/smoketest_bitmap.script");
+copy($epoc . "data/z/smoketest/smoketest_http.ini", "temp/smoketest/general/smoketest_http.ini");
+copy($epoc . "data/z/smoketest/smoketest_http.script", "temp/smoketest/general/smoketest_http.script");
copy($epoc . "data/z/smoketest/sms/message1.txt", "temp/smoketest/sms/general/message1.txt");
copy($epoc . "data/z/smoketest/MachineName.txt", "temp/smoketest/general/MachineName.txt");
copy($epoc . "data/z/smoketest/emailmessage/20KBody.txt", "temp/smoketest/emailmessage/general/20KBody.txt");
@@ -85,6 +88,7 @@
copy($epoc . "data/z/private/10003a3f/import/apps/tstapp_reg.rsc", "temp/smoketest/localisation/general/tstapp_reg.rsc");
copy($epoc . "data/z/resource/plugins/tstapp_embedded.rsc", "temp/smoketest/localisation/general/tstapp_embedded.rsc");
copy($epoc . "data/z/smoketest/bitmap/uibench_16bit.mbm", "temp/smoketest/bitmap/general/uibench_16bit.mbm");
+copy($epoc . "data/z/delproxy.pl", "temp/smoketest/ethernet/general/delproxy.pl");
copy($epoc . "release/winscw/udeb/SmokeTestSecureFSclient.dll", "temp/smoketest/winscw_udeb/SmokeTestSecureFSclient.dll");
copy($epoc . "release/winscw/udeb/SmokeTestSecureFSserver.exe", "temp/smoketest/winscw_udeb/SmokeTestSecureFSserver.exe");
copy($epoc . "release/winscw/udeb/Smoketest_Agenda_Server.exe", "temp/smoketest/winscw_udeb/Smoketest_Agenda_Server.exe");
@@ -113,6 +117,7 @@
copy($epoc . "release/winscw/udeb/t_graphicswservapi.exe", "temp/smoketest/winscw_udeb/t_graphicswservapi.exe");
copy($epoc . "release/winscw/udeb/twsgraphicshare.exe", "temp/smoketest/winscw_udeb/twsgraphicshare.exe");
copy($epoc . "release/winscw/udeb/twsgraphicunshare.exe", "temp/smoketest/winscw_udeb/twsgraphicunshare.exe");
+copy($epoc . "release/winscw/udeb/testhttpsuite.exe", "temp/smoketest/winscw_udeb/testhttpsuite.exe");
copy($epoc . "release/winscw/udeb/ProfileSmokeTestModule.dll", "temp/smoketest/winscw_udeb/ProfileSmokeTestModule.dll");
copy($epoc . "winscw/c/smoketest/ProfileSmokeTestModule.cfg", "temp/smoketest/general/ProfileSmokeTestModule.cfg");
--- a/common/tools/ats/smoketest/Group/smoketest.xml Wed Jan 06 13:17:03 2010 +0000
+++ b/common/tools/ats/smoketest/Group/smoketest.xml Wed Jan 06 13:41:51 2010 +0000
@@ -424,7 +424,16 @@
<param dst="c:/smoketest/bitmap/uibench_16bit.mbm"/>
<param component-path="smoketest\bitmap" />
</params>
- </step>
+ </step>
+ <step id="" name="Test Step 1 (install)" harness="GENERIC" enabled="true" passrate="100" significant="false">
+ <command>install</command>
+ <params>
+ <param type="data"/>
+ <param src="delproxy.pl"/>
+ <param dst="c:\delproxy.pl"/>
+ <param component-path="smoketest\ethernet" />
+ </params>
+ </step>
<step id="" name="Test Step 1 (install)" harness="GENERIC" enabled="true" passrate="100" significant="false">
<command>install</command>
<params>
@@ -676,7 +685,16 @@
<param dst="c:\sys\bin\twsgraphicunshare.exe"/>
<param component-path="smoketest" />
</params>
- </step>
+ </step>
+ <step id="" name="Test Step 1 (install)" harness="GENERIC" enabled="true" passrate="100" significant="false">
+ <command>install</command>
+ <params>
+ <param type="binary"/>
+ <param src="testhttpsuite.exe"/>
+ <param dst="c:\sys\bin\testhttpsuite.exe"/>
+ <param component-path="smoketest" />
+ </params>
+ </step>
<step id="" name="Test Step 2 (execute)" harness="GENERIC" enabled="true" passrate="100" significant="true">
<command>execute</command>
<params>
@@ -776,12 +794,59 @@
<param leave-old-result="true"/>
</params>
</step>
+ <step id="" name="Test Step 2 (execute)" harness="GENERIC" enabled="true" passrate="100" significant="true">
+ <command>execute</command>
+ <params>
+ <param local="true"/>
+ <param file="perl"/>
+ <param dir="D:\ATS\winscw_smoketest\epoc32\winscw\c"/>
+ <param parameters="delproxy.pl ethernetced.xml"/>
+ <param timeout="600"/>
+ <param async="false"/>
+ </params>
+ </step>
+ <step id="" name="Test Step 2 (execute)" harness="GENERIC" enabled="true" passrate="100" significant="true">
+ <command>execute</command>
+ <params>
+ <param local="true"/>
+ <param file="perl"/>
+ <param dir="D:\ATS\winscw_smoketest\epoc32\tools"/>
+ <param parameters="configchange.pl --config ethernetWithCommDB --kernel EKA2 --target winscw --variant UDEB"/>
+ <param timeout="1200"/>
+ <param async="false"/>
+ </params>
+ </step>
+ <step id="" name="Test Step 2 (execute)" harness="GENERIC" enabled="true" passrate="100" significant="true">
+ <command>execute</command>
+ <params>
+ <param file="dbcreator.exe"/>
+ <param parameters="-dtextshell -- f:c:\S60_32_default_snaps.xml"/>
+ <param timeout="600"/>
+ </params>
+ </step>
+ <step id="" name="Test Step 2 (execute)" harness="GENERIC" enabled="true" passrate="100" significant="true">
+ <command>execute</command>
+ <params>
+ <param file="testexecute.exe"/>
+ <param parameters="c:\smoketest\smoketest_http.script"/>
+ <param result-file="c:\logs\testexecute\smoketest_http.htm"/>
+ <param timeout="600"/>
+ <param parser="TEFTestResultParser"/>
+ <param leave-old-result="true"/>
+ </params>
+ </step>
<step id="" name="Test Step 3 (fetch-log)" harness="GENERIC" enabled="true" passrate="100">
<command>fetch-log</command>
<params>
<param path="c:\logs\testexecute\screen.mbm" />
</params>
</step>
+ <step id="" name="Test Step 3 (fetch-log)" harness="GENERIC" enabled="true" passrate="100">
+ <command>fetch-log</command>
+ <params>
+ <param path="c:\logs\testexecute\HttpGoogle.htm" />
+ </params>
+ </step>
</case>
</set>
<set id="" name="ATSINTERFACE smoke tests" harness="ATSINTERFACE" enabled="true" passrate="100">
@@ -1023,9 +1088,11 @@
<file>smoketest/general/smoketest_email.script</file>
<file>smoketest/general/smoketest_lbs.ini</file>
<file>smoketest/general/smoketest_lbs.script</file>
+ <file>smoketest/general/smoketest_language.script</file>
<file>smoketest/general/smoketest_bitmap.ini</file>
<file>smoketest/general/smoketest_bitmap.script</file>
- <file>smoketest/general/smoketest_language.script</file>
+ <file>smoketest/general/smoketest_http.ini</file>
+ <file>smoketest/general/smoketest_http.script</file>
<file>smoketest/sms/general/message1.txt</file>
<file>smoketest/general/MachineName.txt</file>
<file>smoketest/emailmessage/general/20KBody.txt</file>
@@ -1070,6 +1137,7 @@
<file>smoketest/localisation/general/tstapp_reg.rsc</file>
<file>smoketest/localisation/general/tstapp_embedded.rsc</file>
<file>smoketest/bitmap/general/uibench_16bit.mbm</file>
+ <file>smoketest/ethernet/general/delproxy.pl</file>
<file>smoketest/winscw_udeb/SmokeTestSecureFSclient.dll</file>
<file>smoketest/winscw_udeb/SmokeTestSecureFSserver.exe</file>
<file>smoketest/winscw_udeb/Smoketest_Agenda_Server.exe</file>
@@ -1098,6 +1166,7 @@
<file>smoketest/winscw_udeb/t_graphicswservapi.exe</file>
<file>smoketest/winscw_udeb/twsgraphicshare.exe</file>
<file>smoketest/winscw_udeb/twsgraphicunshare.exe</file>
+ <file>smoketest/winscw_udeb/testhttpsuite.exe</file>
<file>smoketest/winscw_udeb/ProfileSmokeTestModule.dll</file>
<file>smoketest/general/ProfileSmokeTestModule.cfg</file>
<file>smoketest/winscw_udeb/TestNpdApi.dll</file>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/group/bld.inf Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,34 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Component description file
+//
+//
+
+
+PRJ_TESTMMPFILES
+
+testhttpsuite.mmp
+
+PRJ_TESTEXPORTS
+
+..\script\setup_smoketest_http.script z:\smoketest\setup_smoketest_http.script
+
+// Script file for testing the functionality.
+..\script\smoketest_http.script z:\smoketest\smoketest_http.script
+
+// Ini file
+..\ini\smoketest_http.ini z:\smoketest\smoketest_http.ini
+
+// Perl script
+..\group\delproxy.pl z:\delproxy.pl
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/group/delproxy.pl Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "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:
+# Symbian Foundation Ltd - initial contribution.
+# Maciej Seroka, maciej@symbian.org
+#
+# Description:
+# This is a tool for removing proxy settings from ethernetced.xml.
+
+use Tie::File;
+
+my $filename;
+if ($ARGV[0]) {
+ $filename = $ARGV[0];
+ }
+else { die 'Missing parameter "filename"'; }
+
+my $LINE;
+print $filename;
+tie @LINE, 'Tie::File', $filename or die 'file not found';
+my $n = 0;
+my $proxy_begin = 0;
+my $proxy_end = 0;
+
+for (@LINE) {
+ if ($LINE[$n] =~ /<ProxyTable>/) {
+ $proxy_begin = $n;
+ }
+ if ($LINE[$n] =~ /<\/ProxyTable>/) {
+ $proxy_end = $n;
+ last;
+ }
+ $n += 1;
+ }
+
+if ($proxy_end > 0) {
+ splice @LINE, $proxy_begin, ($proxy_end - $proxy_begin + 1);
+ }
+
+untie @LINE;
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/group/testhttpsuite.mmp Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,34 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+//OPTION CW -w off
+TARGET testhttpsuite.exe
+TARGETTYPE EXE
+CAPABILITY ALL -TCB
+
+UID 0x1000007A 0x102729DF
+
+
+SYSTEMINCLUDE /epoc32/include /epoc32/include/test /epoc32/include/ecom
+USERINCLUDE ../inc
+
+SOURCEPATH ../src
+SOURCE testhttpserver.cpp testhttpbasestep.cpp testhttpeboclientstep.cpp testhttpbuffersizestep.cpp testhttpeboclientconditionalstep.cpp
+
+LIBRARY c32.lib euser.lib estor.lib efsrv.lib http.lib inetprotutil.lib bafl.lib ecom.lib crypto.lib
+LIBRARY commdb.lib esock.lib
+
+//For TEF
+LIBRARY testexecuteutils.lib testexecutelogclient.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/inc/testhttpbasestep.h Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,67 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains declaration of CTestHttpBaseStep class
+// @internalAll
+//
+//
+
+#ifndef __TEST_HTTP_BASE_STEP_H__
+#define __TEST_HTTP_BASE_STEP_H__
+
+// System Include
+#include <http.h>
+
+// User Include
+#include "testhttpserver.h"
+
+/**
+This is the base test step from which all other test steps are derived
+to test the EBO support provided by the http client framework.
+@internalTechnology
+@test
+*/
+class CTestHttpBaseStep : public CTestStep, public MHTTPTransactionCallback
+ {
+public:
+ static void InitCommsL();
+ CTestHttpBaseStep();
+ virtual ~CTestHttpBaseStep();
+ // TEF virtuals
+ virtual TVerdict doTestStepPreambleL();
+ // TEF pure virtual
+ virtual TVerdict doTestStepL();
+
+protected:
+ virtual void StartClientL() = 0;
+ virtual void InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod) = 0;
+
+ // methods from MHTTPTransactionCallback
+ virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) = 0;
+ virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent) = 0;
+
+ virtual void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue);
+
+protected:
+ RHTTPSession iSess;
+ RHTTPTransaction iTrans;
+ RFs iFileServ;
+ CActiveScheduler* iSched;
+ };
+
+/*@{*/
+/// Literal constant defined for identifying step name
+_LIT(KTestHttpBaseStep, "TestHttpBaseStep");
+/*@}*/
+
+#endif // __TEST_HTTPEBO_BASE_STEP_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/inc/testhttpbuffersizestep.h Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,54 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains declaration of CTestHttpBufferSizeStep class
+// @internalAll
+//
+//
+
+#ifndef __TEST_HTTP_BUFFER_SIZE_STEP_H__
+#define __TEST_HTTP_BUFFER_SIZE_STEP_H__
+
+// User Include
+#include "testhttpbasestep.h"
+
+/// Literal constant defined for identifying step name
+_LIT(KTestHttpBufferSizeStep, "TestHttpBufferSizeStep");
+
+/**
+This is the base test step from which all other test steps are derived
+to test the HTTP Library.
+@internalTechnology
+@test
+*/
+class CTestHttpBufferSizeStep : public CTestHttpBaseStep
+ {
+public:
+ CTestHttpBufferSizeStep();
+ virtual ~CTestHttpBufferSizeStep();
+
+private:
+ void StartClientL();
+ void InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod);
+ void ValidateTest();
+
+ // methods from MHTTPTransactionCallback
+ void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) ;
+ TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent) ;
+
+public:
+ MHTTPDataSupplier* iRespBody;
+ TInt iChunkSize;
+ };
+
+#endif // __TEST_HTTP_BUFFER_SIZE_STEP_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/inc/testhttpeboclientconditionalstep.h Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,62 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains declaration of CHttpEboClientStep class
+// @internalAll
+//
+//
+
+#ifndef TESTHTTPEBOCLIENTCONDITIONALSTEP_H_
+#define TESTHTTPEBOCLIENTCONDITIONALSTEP_H_
+//System Include
+#include "testhttpbasestep.h"
+#include <http/mhttpdataoptimiser.h>
+
+/**
+This is the eboclient to test the ebo functionality.
+This tests some conditions like the pipelining and non pipelining with the ebo feature.
+@internalTechnology
+@test
+*/
+
+class CHttpEboClientConditionalStep : public CTestHttpBaseStep, public MHttpDataOptimiser
+ {
+public:
+ virtual ~CHttpEboClientConditionalStep();
+ CHttpEboClientConditionalStep();
+
+ //These methods from MHttpDataOptimiser
+ void EncodeL (const TDesC8& aHttpData, HBufC8*& aEncodedData);
+ void DecodeL (const TDesC8& aData, HBufC8*& aHttpData, TBool& aTransFail);
+
+private:
+ void StartClientL();
+ void InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod);
+
+ // methods from MHTTPTransactionCallback
+ void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
+ TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
+
+private:
+ MHTTPDataSupplier* iRespBody;
+ TInt iChunkSize;
+ TBool iPipeliningEnabled;
+ TBool iDisableTransOpt;
+ };
+
+/*@{*/
+/// Literal constant defined for identifying step name
+_LIT(KTestHttpEboClientConditionalStep, "TestHttpEboClientConditionalStep");
+/*@}*/
+
+#endif /*TESTHTTPEBOCLIENTCONDITIONALSTEP_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/inc/testhttpeboclientstep.h Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,62 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains declaration of CHttpEboClientStep class
+// @internalAll
+//
+//
+
+#ifndef __TEST_HTTP_EBOCLIENT_STEP_H__
+#define __TEST_HTTP_EBOCLIENT_STEP_H__
+
+//System Include
+#include "testhttpbasestep.h"
+#include <http/mhttpdataoptimiser.h>
+
+/**
+This is the eboclient to test the ebo functionality.
+@internalTechnology
+@test
+*/
+
+class CHttpEboClientStep : public CTestHttpBaseStep, public MHttpDataOptimiser
+ {
+public:
+ virtual ~CHttpEboClientStep();
+ CHttpEboClientStep();
+
+ //These methods from MHttpDataOptimiser
+ void EncodeL (const TDesC8& aHttpData, HBufC8*& aEncodedData);
+ void DecodeL (const TDesC8& aData, HBufC8*& aHttpData, TBool& aTransFail);
+
+private:
+ void StartClientL();
+ void InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod);
+
+ // methods from MHTTPTransactionCallback
+ void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
+ TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
+
+private:
+ TBool iSavingResponseBody;
+ RFile iRespBodyFile;
+ MHTTPDataSupplier* iRespBody;
+ TPtrC iOutputFilename;
+ };
+
+/*@{*/
+/// Literal constant defined for identifying step name
+_LIT(KTestHttpEboClientStep, "TestHttpEboClientStep");
+/*@}*/
+
+#endif // __TEST_HTTP_EBOCLIENT_STEP_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/inc/testhttpserver.h Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,61 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains declaration of CTestHttpServer class
+// @internalAll
+//
+//
+
+#ifndef __TEST__HTTP_SERVER_H__
+#define __TEST__HTTP_SERVER_H__
+
+// System Include
+// For accessing TEF classes
+#include <testexecuteserverbase.h>
+
+/*@{*/
+/// Literal constants for INI file field-names
+_LIT(KIniSessProxy, "SessProxy");
+_LIT(KIniSessProxyUsage, "SessProxyUsage");
+_LIT(KIniTranProxy, "TranProxy");
+_LIT(KIniTranProxyUsage, "TranProxyUsage");
+_LIT(KIniUri, "Uri");
+_LIT(KIniRespBodyFileName, "RespBodyFileName");
+_LIT(KIniFileName, "OutputFileName");
+_LIT(KIniSessHttpOptUsage, "SessHttpOptUsage");
+_LIT(KIniTranHttpOptUsage, "TranHttpOptUsage");
+_LIT(KIniIsEncoded, "IsEncoded");
+_LIT(KIniIsDecoded, "IsDecoded");
+_LIT(KIniFailTransaction, "FailTransaction");
+_LIT(KDisableTransOpt, "DisableTransOpt");
+/*@}*/
+_LIT(KTxt, "ERROR");
+
+/**
+This is the test server to test the white/black-list uri service API.
+@internalTechnology
+*/
+class CTestHttpServer : public CTestServer
+ {
+public:
+ // Construction
+ static CTestHttpServer* NewL();
+ // Base class pure virtual
+ virtual CTestStep* CreateTestStep(const TDesC& aStepName);
+
+protected:
+ CTestStep* CreateTestStepL(const TDesC& aStepName);
+ const TPtrC ServerName();
+ };
+
+#endif // __TEST__HTTPEBO_SERVER_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/ini/smoketest_http.ini Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,10 @@
+[HttpEbo_1]
+Uri = http://www.google.co.uk/
+SessProxyUsage = EFalse
+TranProxyUsage = EFalse
+OutputFileName = C:\logs\testexecute\HttpGoogle.htm
+SessHttpOptUsage = EFalse
+TranHttpOptUsage = EFalse
+IsEncoded =
+IsDecoded =
+FailTransaction =
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/script/setup_smoketest_http.script Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,24 @@
+//
+// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+RUN_UTILS MkDir c:\smoketest\
+
+RUN_UTILS CopyFile z:\smoketest\smoketest_http.ini c:\smoketest\smoketest_http.ini
+RUN_UTILS MakeReadWrite c:\smoketest\smoketest_http.ini
+RUN_UTILS CopyFile z:\smoketest\smoketest_http.script c:\smoketest\smoketest_http.script
+RUN_UTILS MakeReadWrite c:\smoketest\smoketest_http.script
+RUN_UTILS CopyFile z:\delproxy.pl c:\delproxy.pl
+RUN_UTILS MakeReadWrite c:\delproxy.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/script/smoketest_http.script Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,30 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Script file for HTTP Smoke Test.
+// @internalAll
+//
+
+PRINT Run Http smoketest
+
+// Load the test
+LOAD_SUITE testhttpsuite
+DELAY 1000
+
+START_TESTCASE SMOKE_HTTP_0001
+//! @SYMTestCaseID SMOKE_EMAIL_0001
+//! @SYMTestCaseDesc Create the transaction with GET method and some requesting URL
+
+RUN_TEST_STEP 100 testhttpsuite TestHttpEboClientStep c:\smoketest\smoketest_http.ini HttpEbo_1
+
+END_TESTCASE SMOKE_HTTP_0001
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/src/testhttpbasestep.cpp Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,166 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains implementation of CTestHttpBaseStep class
+// @internalAll
+//
+//
+
+// System Include
+// for StartC32()
+#include <c32comm.h>
+#include <e32base.h>
+#include <http.h>
+// User Include
+#include "testhttpbasestep.h"
+
+// File system root
+_LIT(KFileSystemRoot,"C:\\");
+
+// PDD names for the physical device drivers that are loaded in wins or arm
+#if defined (__WINS__)
+#define PDD_NAME _L("ECDRV")
+#else
+#define PDD_NAME _L("EUART1")
+#define PDD2_NAME _L("EUART2")
+#define PDD3_NAME _L("EUART3")
+#define PDD4_NAME _L("EUART4")
+#endif
+
+#define LDD_NAME _L("ECOMM")
+
+
+// Loads the physical device drivers
+void CTestHttpBaseStep::InitCommsL()
+ {
+ TInt ret = User::LoadPhysicalDevice(PDD_NAME);
+ User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
+
+#ifndef __WINS__
+ ret = User::LoadPhysicalDevice(PDD2_NAME);
+ ret = User::LoadPhysicalDevice(PDD3_NAME);
+ ret = User::LoadPhysicalDevice(PDD4_NAME);
+#endif
+
+ ret = User::LoadLogicalDevice(LDD_NAME);
+ User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
+ ret = StartC32();
+ User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
+ }
+
+
+/**
+Constructor: Sets the test step name.
+@internalTechnology
+@test
+*/
+CTestHttpBaseStep::CTestHttpBaseStep()
+ {
+ //Call base class method to set human readable name for test step
+ SetTestStepName(KTestHttpBaseStep);
+ }
+
+
+/**
+Destructor: Closes the iFileServ.
+@internalTechnology
+@test
+*/
+CTestHttpBaseStep::~CTestHttpBaseStep()
+ {
+ iFileServ.Close();
+ delete iSched;
+ //CleanupStack::PopAndDestroy(); // iSched
+ iSched = NULL;
+ }
+
+
+/**
+Base class virtual doTestStepPreambleL():
+Create and install the active scheduler and connect to iFileServ (RFs).
+@internalTechnology
+@test
+@param None
+@return EPass or EFail.
+*/
+TVerdict CTestHttpBaseStep::doTestStepPreambleL()
+ {
+ iSched = new(ELeave) CActiveScheduler;
+ CActiveScheduler::Install(iSched);
+ User::LeaveIfError(iFileServ.Connect());
+ return TestStepResult();
+ } // doTestPreambleL
+
+
+/**
+Base class pure virtual doTestStepL():
+Tests the ebo support in http.
+@internalTechnology
+@test
+@param None
+@return EPass or EFail indicating the result of the test step.
+*/
+TVerdict CTestHttpBaseStep::doTestStepL()
+ {
+// __UHEAP_MARK;
+ INFO_PRINTF1(_L("\n"));
+ // Start C32 and initalize some device drivers. This is necessary when running a test console as these won't
+ // have been started
+ TRAPD(err,InitCommsL());
+ if (err != KErrNone)
+ {
+ ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBaseStep::InitCommsL: %D\n"
+ ),err
+ );
+ SetTestStepResult(EFail);
+ }
+ else
+ {
+ // Opening session
+ iSess.OpenL();
+ // start the client
+ TRAP(err,StartClientL());
+ if (err != KErrNone)
+ {
+ ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBaseStep::StartClientL: %D\n"
+ ),err
+ );
+ SetTestStepResult(EFail);
+ }
+ // Closing session
+ iSess.Close();
+ }
+// __UHEAP_MARKEND;
+
+ INFO_PRINTF1(_L("\n"));
+ return TestStepResult();
+ } // doTestStepL
+
+
+/**
+Sets the headers.
+@internalTechnology
+@test
+@param aHeaders Headers collection
+@param aHdrField Header field to be added
+@return aHdrValue Header value to be added
+*/
+void CTestHttpBaseStep::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
+ {
+ RStringF valStr = iSess.StringPool().OpenFStringL(aHdrValue);
+ THTTPHdrVal val(valStr);
+ aHeaders.SetFieldL(iSess.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
+ valStr.Close();
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/src/testhttpbuffersizestep.cpp Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,261 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains implementation of CTestHttpBufferSizeStep class
+// @internalAll
+//
+//
+
+// System Include
+// for StartC32()
+#include <c32comm.h>
+#include <e32base.h>
+#include <http.h>
+
+// User Include
+#include "testhttpbuffersizestep.h"
+
+// File system root
+_LIT(KFileSystemRoot,"C:\\");
+
+// Standard headers used by default
+_LIT8(KUserAgent, "TestHttpBufferSize");
+_LIT8(KAccept, "*/*");
+
+
+/**
+Constructor: Sets the test step name.
+@internalTechnology
+@test
+*/
+CTestHttpBufferSizeStep::CTestHttpBufferSizeStep()
+ {
+ //Call base class method to set human readable name for test step
+ SetTestStepName(KTestHttpBufferSizeStep);
+ //Set the iChunkSize to the default buffer size of 6144 Bytes
+ iChunkSize = 1024;
+ }
+
+
+/**
+Destructor: Closes the iFileServ.
+@internalTechnology
+@test
+*/
+CTestHttpBufferSizeStep::~CTestHttpBufferSizeStep()
+ {
+ }
+
+
+/**
+Sets the proxy and HttpDataOptimiser implemetation to session
+based on the patameter values in ini file and calls InvokeHttpMethodL()
+@internalTechnology
+@test
+@param None
+@return None
+*/
+void CTestHttpBufferSizeStep::StartClientL()
+ {
+ TPtrC uri;
+
+ if (!GetStringFromConfig(ConfigSection(), KIniUri, uri))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KIniUri);
+ SetTestStepResult(EFail);
+ return;
+ }
+
+ THTTPHdrVal hdrVal ( 1024 );
+ RHTTPConnectionInfo httpConnInfo = iSess.ConnectionInfo();
+ httpConnInfo.SetPropertyL ( iSess.StringPool().StringF(HTTP::ERecvBufferSize,RHTTPSession::GetTable()), hdrVal );
+ INFO_PRINTF1(_L("Receive buffer size has been set to 1024 bytes\n"));
+
+ RStringPool strP = iSess.StringPool();
+ RStringF method;
+
+ // method
+ method = strP.StringF(HTTP::EGET,RHTTPSession::GetTable());
+ TBuf8<256> url8;
+ url8.Copy(uri);
+ TRAPD(err,InvokeHttpMethodL(url8, method));
+ if (err != KErrNone)
+ {
+ ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBufferSizeStep::InvokeHttpMethodL: %D\n"
+ ),err
+ );
+ SetTestStepResult(EFail);
+ }
+ method.Close();
+ ValidateTest();
+ }
+
+
+/**
+Invoke the http method
+This actually creates the transaction, sets the headers and HttpDataOptimiser implemetation to transaction
+and then starts the transaction
+@internalTechnology
+@test
+@param aUri Requested uri
+@param aMethod Requested method
+@return None
+*/
+void CTestHttpBufferSizeStep::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod)
+ {
+
+ TUriParser8 uri;
+ uri.Parse( aUri );
+
+ // Opening a transaction
+ iTrans = iSess.OpenTransactionL(uri, *this, aMethod);
+ RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
+ // Add headers appropriate to all methods
+ SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
+ SetHeaderL(hdr, HTTP::EAccept, KAccept);
+
+ // submit the transaction
+ iTrans.SubmitL();
+ // Start the scheduler, once the transaction completes or is cancelled on an error the scheduler will be
+ // stopped in the event handler
+ CActiveScheduler::Start();
+ }
+
+
+/**
+This is the implementation of interface method CTestHttpBufferSizeStep::MHFRunL
+If there is a reponse body it will be copied to a file.
+Just printing the fired events to the log file.
+@internalTechnology
+@test
+@param aTransaction Transaction which is being processed currently
+@param THTTPEvent Event for which it is called
+@return None
+*/
+void CTestHttpBufferSizeStep::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
+ {
+ switch (aEvent.iStatus)
+ {
+ case THTTPEvent::EGotResponseHeaders:
+ {
+ // HTTP response headers have been received. We can determine now if there is
+ // going to be a response body to save.
+ RHTTPResponse resp = aTransaction.Response();
+ TInt status = resp.StatusCode();
+ RStringF statusStr = resp.StatusText();
+ TBuf<32> statusStr16;
+ statusStr16.Copy(statusStr.DesC());
+ INFO_PRINTF3(_L("Status: %D (%S)\n"),status, &statusStr16);
+
+ if (resp.HasBody() && (status >= 200) && (status < 300) && (status != 204))
+ {
+ TInt dataSize = resp.Body()->OverallDataSize();
+ if (dataSize >= 0)
+ INFO_PRINTF2(_L("Response body size is %d\n"), dataSize);
+ else
+ INFO_PRINTF1(_L("Response body size is unknown\n"));
+ }
+ } break;
+ case THTTPEvent::EGotResponseBodyData:
+ {
+ // Get the body data supplier
+ iRespBody = aTransaction.Response().Body();
+ INFO_PRINTF1(_L("Receiving response body...\n"));
+
+ TPtrC8 bodyData;
+ TBool lastChunk = iRespBody->GetNextDataPart(bodyData);
+ if(bodyData.Size() > iChunkSize)
+ {
+ iChunkSize = bodyData.Size();
+ }
+ iRespBody->ReleaseData();
+ } break;
+ case THTTPEvent::EResponseComplete:
+ {
+ // The transaction's response is complete
+ INFO_PRINTF1(_L("\nTransaction Complete\n"));
+ } break;
+ case THTTPEvent::ESucceeded:
+ {
+ INFO_PRINTF1(_L("Transaction Successful\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ case THTTPEvent::EFailed:
+ {
+ INFO_PRINTF1(_L("Transaction Failed\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ case THTTPEvent::ERedirectedPermanently:
+ {
+ INFO_PRINTF1(_L("Permanent Redirection\n"));
+ } break;
+ case THTTPEvent::ERedirectedTemporarily:
+ {
+ INFO_PRINTF1(_L("Temporary Redirection\n"));
+ } break;
+ case THTTPEvent::ERedirectRequiresConfirmation:
+ {
+ // 301(Moved Permanently), 302(Found) or 307(Temporary Redirect) status is received
+ // from a transaction and hence ERedirectRequiresConfirmation is sent by filter
+ // client has opted to close the transaction
+ INFO_PRINTF1(_L("Redirect requires confirmation\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ default:
+ {
+ INFO_PRINTF2(_L("<unrecognised event: %D>\n"), aEvent.iStatus);
+ // close off the transaction if it's an error
+ if (aEvent.iStatus < 0)
+ {
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ }
+ } break;
+ }
+ }
+
+
+/**
+This is the implementation of interface method CTestHttpBufferSizeStep::MHFRunError
+@internalTechnology
+@test
+@param aError Error which has been raised.
+@param aTransaction Transaction which is being processed currently
+@param THTTPEvent Event which it is being handled currently.
+@return None
+*/
+TInt CTestHttpBufferSizeStep::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
+ {
+ INFO_PRINTF2(_L("MHFRunError fired with error code %D\n"), aError);
+ return KErrNone;
+ }
+
+void CTestHttpBufferSizeStep::ValidateTest()
+ {
+ if(iChunkSize <= 1024)
+ {
+ ERR_PRINTF1(_L("Teststep Passed: Buffer Size Feature is working\n"));
+ }
+ else
+ {
+ ERR_PRINTF2(_L("Received a chunk of size: %D\n"), iChunkSize);
+ ERR_PRINTF1(_L("Received a chunk of size greater than the specified size of 1024 Bytes.\n"));
+ ERR_PRINTF1(_L("Teststep Failed: Buffer Size Feature is not working\n"));
+ SetTestStepResult(EFail);
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/src/testhttpeboclientconditionalstep.cpp Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,314 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains implementation of CHttpEboClientStep class
+// @internalAll
+//
+//
+
+// User Include
+#include "testhttpeboclientconditionalstep.h"
+
+// Standard headers used by default
+_LIT8(KUserAgent, "TestHttpEboClientConditional");
+_LIT8(KAccept, "*/*");
+_LIT8(KHttpUrl1, "http://www.google.co.in/");
+_LIT8(KHttpUrl2, "http://www.live.com/");
+_LIT8(KHttpUrl3, "http://www.search.com/");
+_LIT8(KHttpUrl4, "http://www.find.com/");
+
+/**
+Constructor: Sets the test step name.
+@internalTechnology
+@test
+*/
+CHttpEboClientConditionalStep::CHttpEboClientConditionalStep()
+ {
+
+ //Call base class method to set human readable name for test step
+ SetTestStepName(KTestHttpEboClientConditionalStep);
+ }
+
+
+/**
+Destructor
+@internalTechnology
+@test
+*/
+CHttpEboClientConditionalStep::~CHttpEboClientConditionalStep()
+ {
+ }
+
+
+/**
+Sets the proxy and HttpDataOptimiser implemetation to session
+based on the patameter values in ini file and calls InvokeHttpMethodL()
+@internalTechnology
+@test
+@param None
+@return None
+*/
+void CHttpEboClientConditionalStep::StartClientL()
+ {
+ if (!GetBoolFromConfig(ConfigSection(), KDisableTransOpt, iDisableTransOpt))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KDisableTransOpt);
+ SetTestStepResult(EFail);
+ return;
+ }
+
+ RStringPool strP = iSess.StringPool();
+ RStringF method;
+
+ // method
+ method = strP.StringF(HTTP::EGET,RHTTPSession::GetTable());
+ TBuf8<256> url8;
+ TRAPD(err,InvokeHttpMethodL(url8, method));
+ if (err != KErrNone)
+ {
+ ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBufferSizeStep::InvokeHttpMethodL: %D\n"
+ ),err
+ );
+ SetTestStepResult(EFail);
+ }
+ method.Close();
+ }
+
+/**
+Invoke the http method
+This actually creates the transaction, sets the headers and HttpDataOptimiser implemetation to transaction
+and then starts the transaction
+@internalTechnology
+@test
+@param aUri Requested uri
+@param aMethod Requested method
+@return None
+*/
+void CHttpEboClientConditionalStep::InvokeHttpMethodL(const TDesC8& /*aUri*/, RStringF aMethod)
+ {
+ TUriParser8 uri1;
+ uri1.Parse( KHttpUrl1 );
+
+ // Opening transactions
+ RHTTPTransaction trans1 = iSess.OpenTransactionL(uri1, *this, aMethod);
+ CleanupClosePushL(trans1);
+ RHTTPHeaders hdr1 = trans1.Request().GetHeaderCollection();
+ SetHeaderL(hdr1, HTTP::EUserAgent, KUserAgent);
+ SetHeaderL(hdr1, HTTP::EAccept, KAccept);
+
+ TUriParser8 uri2;
+ uri2.Parse( KHttpUrl2 );
+ RHTTPTransaction trans2 = iSess.OpenTransactionL(uri2, *this, aMethod);
+ CleanupClosePushL(trans2);
+ RHTTPHeaders hdr2 = trans2.Request().GetHeaderCollection();
+ SetHeaderL(hdr2, HTTP::EUserAgent, KUserAgent);
+ SetHeaderL(hdr2, HTTP::EAccept, KAccept);
+
+ TUriParser8 uri3;
+ uri3.Parse( KHttpUrl3 );
+ RHTTPTransaction trans3 = iSess.OpenTransactionL(uri3, *this, aMethod);
+ CleanupClosePushL(trans3);
+ RHTTPHeaders hdr3 = trans3.Request().GetHeaderCollection();
+ SetHeaderL(hdr3, HTTP::EUserAgent, KUserAgent);
+ SetHeaderL(hdr3, HTTP::EAccept, KAccept);
+
+ TUriParser8 uri4;
+ uri4.Parse( KHttpUrl4 );
+ RHTTPTransaction trans4 = iSess.OpenTransactionL(uri4, *this, aMethod);
+ CleanupClosePushL(trans4);
+ RHTTPHeaders hdr4 = trans4.Request().GetHeaderCollection();
+ SetHeaderL(hdr4, HTTP::EUserAgent, KUserAgent);
+ SetHeaderL(hdr4, HTTP::EAccept, KAccept);
+
+ if (iDisableTransOpt)
+ {
+ iSess.SetupHttpDataOptimiser(*this);
+ THTTPHdrVal disableOptimiser(iSess.StringPool().StringF(HTTP::EDisableHTTPTransOptimiser,RHTTPSession::GetTable()));
+ trans3.PropertySet().SetPropertyL(iSess.StringPool().StringF(HTTP::EHTTPTransOptimiser,RHTTPSession::GetTable()), disableOptimiser);
+ }
+ else
+ {
+ trans1.SetupHttpDataOptimiser(*this);
+ trans2.SetupHttpDataOptimiser(*this);
+ trans4.SetupHttpDataOptimiser(*this);
+ }
+
+ trans1.SubmitL();
+ CActiveScheduler::Start();
+
+ trans2.SubmitL();
+ CActiveScheduler::Start();
+
+ trans3.SubmitL();
+ CActiveScheduler::Start();
+
+ trans4.SubmitL();
+ CActiveScheduler::Start();
+
+ CleanupStack::Pop(&trans4);
+ CleanupStack::Pop(&trans3);
+ CleanupStack::Pop(&trans2);
+ CleanupStack::Pop(&trans1);
+ }
+
+/**
+This is the implementation of interface method MHttpDataOptimiser::MHFRunL
+If there is a reponse body it will be copied to a file.
+Just printing the fired events to the log file.
+@internalTechnology
+@test
+@param aTransaction Transaction which is being processed currently
+@param THTTPEvent Event for which it is called
+@return None
+*/
+void CHttpEboClientConditionalStep::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
+ {
+ switch (aEvent.iStatus)
+ {
+ case THTTPEvent::EGotResponseHeaders:
+ {
+ INFO_PRINTF2(_L("Processing Transaction %d\n"), aTransaction.Id());
+ RHTTPResponse resp = aTransaction.Response();
+ TInt status = resp.StatusCode();
+ RStringF statusStr = resp.StatusText();
+ TBuf<32> statusStr16;
+ statusStr16.Copy(statusStr.DesC());
+ INFO_PRINTF3(_L("Status: %D (%S)\n"),status, &statusStr16);
+
+ if (resp.HasBody() && (status >= 200) && (status < 300) && (status != 204))
+ {
+ TInt dataSize = resp.Body()->OverallDataSize();
+ if (dataSize >= 0)
+ INFO_PRINTF2(_L("Response body size is %d\n"), dataSize);
+ else
+ INFO_PRINTF1(_L("Response body size is unknown\n"));
+ }
+ } break;
+ case THTTPEvent::EGotResponseBodyData:
+ {
+ // Get the body data supplier
+ iRespBody = aTransaction.Response().Body();
+ INFO_PRINTF1(_L("Receiving response body...\n"));
+
+ TPtrC8 bodyData;
+ TBool lastChunk = iRespBody->GetNextDataPart(bodyData);
+ if(bodyData.Size() > iChunkSize)
+ {
+ iChunkSize = bodyData.Size();
+ }
+ iRespBody->ReleaseData();
+ } break;
+ case THTTPEvent::EResponseComplete:
+ {
+ // The transaction's response is complete
+ INFO_PRINTF1(_L("\nTransaction Complete\n"));
+ } break;
+ case KErrHttpOptimiserFailsTrans:
+ {
+ INFO_PRINTF1(_L("Cancelling/Failing Transaction\n"));
+ aTransaction.Fail(THTTPFilterHandle::EProtocolHandler);
+ //CActiveScheduler::Stop();
+ } break;
+ case THTTPEvent::ESucceeded:
+ {
+ INFO_PRINTF1(_L("Transaction Successful\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ case THTTPEvent::EFailed:
+ {
+ INFO_PRINTF1(_L("Transaction Failed\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ case THTTPEvent::ERedirectedPermanently:
+ {
+ INFO_PRINTF1(_L("Permanent Redirection\n"));
+ } break;
+ case THTTPEvent::ERedirectedTemporarily:
+ {
+ INFO_PRINTF1(_L("Temporary Redirection\n"));
+ } break;
+ case THTTPEvent::ERedirectRequiresConfirmation:
+ {
+ // 301(Moved Permanently), 302(Found) or 307(Temporary Redirect) status is received
+ // from a transaction and hence ERedirectRequiresConfirmation is sent by filter
+ // client has opted to close the transaction
+ INFO_PRINTF1(_L("Redirect requires confirmation\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ default:
+ {
+ INFO_PRINTF2(_L("<unrecognised event: %D>\n"), aEvent.iStatus);
+ // close off the transaction if it's an error
+ if (aEvent.iStatus < 0)
+ {
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ }
+ } break;
+ }
+ }
+
+
+/**
+This is the implementation of interface method MHttpDataOptimiser::MHFRunError
+@internalTechnology
+@test
+@param aError Error which has been raised.
+@param aTransaction Transaction which is being processed currently
+@param THTTPEvent Event which it is being handled currently.
+@return None
+*/
+TInt CHttpEboClientConditionalStep::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
+ {
+ INFO_PRINTF2(_L("MHFRunError fired with error code %D\n"), aError);
+ return KErrNone;
+ }
+
+
+/**
+It enocodes the request data.
+@internalTechnology
+@test
+@param aHttpData Actual request.
+@param aEncodedData Encoded request.
+@return None
+*/
+void CHttpEboClientConditionalStep::EncodeL (const TDesC8& aHttpData, HBufC8* &aEncodedData)
+ {
+ INFO_PRINTF1(_L("######## CHttpEboClientStep::EncodeL ########\n"));
+ aEncodedData = aHttpData.AllocLC();
+ CleanupStack::Pop();
+ INFO_PRINTF1(_L("Encoded/Changed the request\n"));
+ }
+
+
+/**
+It decodes the responsing data before parsing.
+@internalTechnology
+@test
+@param aHttpData Actual response.
+@param aEncodedData Decoded response.
+@return None
+*/
+void CHttpEboClientConditionalStep::DecodeL (const TDesC8& aData, HBufC8*& aHttpData, TBool& /*aTransFail*/)
+ {
+ INFO_PRINTF1(_L("######## CHttpEboClientStep::DecodeL ########\n"));
+ aHttpData = aData.AllocLC();
+ CleanupStack::Pop();
+ INFO_PRINTF1(_L("Sent the actual response as a decoded response\n"));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/src/testhttpeboclientstep.cpp Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,542 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains implementation of CHttpEboClientStep class
+// @internalAll
+//
+//
+
+// User Include
+#include "testhttpeboclientstep.h"
+// Additional headers
+#include "CommDbConnPref.h"
+#include "CommDb.h"
+#include "es_sock.h"
+
+// Standard headers used by default
+_LIT8(KUserAgent, "TestHttpEboClient");
+_LIT8(KAccept, "*/*");
+
+/**
+Constructor: Sets the test step name.
+@internalTechnology
+@test
+*/
+CHttpEboClientStep::CHttpEboClientStep()
+ {
+
+ //Call base class method to set human readable name for test step
+ SetTestStepName(KTestHttpEboClientStep);
+ }
+
+
+/**
+Destructor
+@internalTechnology
+@test
+*/
+CHttpEboClientStep::~CHttpEboClientStep()
+ {
+ }
+
+
+/**
+Sets the proxy and HttpDataOptimiser implemetation to session
+based on the patameter values in ini file and calls InvokeHttpMethodL()
+@internalTechnology
+@test
+@param None
+@return None
+*/
+void CHttpEboClientStep::StartClientL()
+ {
+ TPtrC uri;
+ TPtrC proxyPtr;
+ TBool proxyUsage;
+ TPtrC resbodyFilename;
+ TBool sessHttpOptUsage;
+ if (!GetStringFromConfig(ConfigSection(), KIniUri, uri) ||
+ !GetStringFromConfig(ConfigSection(), KIniFileName, resbodyFilename) ||
+ !GetBoolFromConfig(ConfigSection(), KIniSessProxyUsage, proxyUsage)
+ )
+ {
+ ERR_PRINTF4(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n%S\n%S\n"
+ ),&KIniUri, &KIniFileName, &KIniSessProxyUsage
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ iOutputFilename.Set(resbodyFilename);
+ if (proxyUsage)
+ if(!GetStringFromConfig(ConfigSection(), KIniSessProxy, proxyPtr)
+ )
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected field is: \n%S\n"
+ ),&KIniSessProxy
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ RStringPool strP = iSess.StringPool();
+ RStringF method;
+ //setting proxy to session
+ if(proxyUsage)
+ {
+ iSess.ConnectionInfo().SetPropertyL(iSess.StringPool().StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), iSess.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
+ TBuf8<256> prox8;
+ prox8.Copy(proxyPtr);
+ RStringF proxy = iSess.StringPool().OpenFStringL(prox8);
+ CleanupClosePushL(proxy);
+ iSess.ConnectionInfo().SetPropertyL(iSess.StringPool().StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), proxy);
+ CleanupStack::PopAndDestroy(&proxy);
+ }
+ // Setting HttpDataOptimiser to session
+ if (!GetBoolFromConfig(ConfigSection(), KIniSessHttpOptUsage, sessHttpOptUsage))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KIniSessHttpOptUsage
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ if (sessHttpOptUsage)
+ iSess.SetupHttpDataOptimiser(*this);
+
+ // method
+ method = strP.StringF(HTTP::EGET,RHTTPSession::GetTable());
+ TBuf8<256> url8;
+ url8.Copy(uri);
+ TRAPD(err,InvokeHttpMethodL(url8, method));
+ if (err != KErrNone)
+ {
+ ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBaseStep::InvokeHttpMethodL: %D\n"
+ ),err
+ );
+ SetTestStepResult(EFail);
+ }
+ method.Close();
+ }
+
+
+/**
+Invoke the http method
+This actually creates the transaction, sets the headers and HttpDataOptimiser implemetation to transaction
+and then starts the transaction
+@internalTechnology
+@test
+@param aUri Requested uri
+@param aMethod Requested method
+@return None
+*/
+void CHttpEboClientStep::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod)
+ {
+
+ TBool tranProxyUsage;
+ TBool tranHttpOptUsage;
+ TPtrC tranProxy;
+ TUriParser8 uri;
+ uri.Parse( aUri );
+
+ //This code has been added by Maciej Seroka to get rid of the access point selection dialog
+
+ // Initialise the socket server session.
+ RSocketServ socketServ;
+ User::LeaveIfError(socketServ.Connect());
+
+ // Initialise the RConnection.
+ RConnection connection;
+ User::LeaveIfError(connection.Open(socketServ));
+
+ // open the IAP communications database
+ CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
+ CleanupStack::PushL(commDB);
+
+ // initialize a view
+ CCommsDbConnectionPrefTableView* commDBView =
+ commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);
+
+ // go to the first record
+ User::LeaveIfError(commDBView->GotoFirstRecord());
+
+ // Declare a prefTableView Object.
+ CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
+
+ // read the connection preferences
+ commDBView->ReadConnectionPreferenceL(pref);
+ TUint32 iapID = pref.iBearer.iIapId;
+
+ // pop and destroy the IAP View
+ CleanupStack::PopAndDestroy(commDBView);
+
+ // pop and destroy the database object
+ CleanupStack::PopAndDestroy(commDB);
+
+ // Now we have the iap Id. Use it to connect for the connection.
+ // Create a connection preference variable.
+ TCommDbConnPref connectPref;
+
+ // setup preferences
+ connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
+ connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
+ connectPref.SetBearerSet(ECommDbBearerGPRS);
+ connectPref.SetIapId(iapID);
+
+ // start a synchronous connection
+ TInt errConnect = connection.Start(connectPref);
+
+ // Then, associate the current socket server session and rconnection object
+ //used above with the HttpSession which u will be using.
+
+ RStringPool strP = iSess.StringPool();
+ RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
+ connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
+ THTTPHdrVal (socketServ.Handle()));
+ TInt connPtr = REINTERPRET_CAST(TInt, &(connection));
+ connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection,
+ RHTTPSession::GetTable() ),
+ THTTPHdrVal (connPtr) );
+
+ //and it ends here.
+
+
+ // Opening a transaction
+ iTrans = iSess.OpenTransactionL(uri, *this, aMethod);
+ RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
+ // Add headers appropriate to all methods
+ SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
+ SetHeaderL(hdr, HTTP::EAccept, KAccept);
+
+ if (!GetBoolFromConfig(ConfigSection(), KIniTranProxyUsage, tranProxyUsage))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KIniTranProxyUsage
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ if (tranProxyUsage)
+ if (!GetStringFromConfig(ConfigSection(), KIniTranProxy, tranProxy))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected field is: \n%S\n"
+ ),&KIniTranProxy
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ //setting transaction proxy
+ RHTTPTransactionPropertySet transactionProperties = iTrans.PropertySet();
+// RStringPool strP = iSess.StringPool();
+ if (tranProxyUsage)
+ {
+ TBuf8<256> tranProx8;
+ tranProx8.Copy(tranProxy);
+ RStringF proxyAddr = strP.OpenFStringL(tranProx8);
+ CleanupClosePushL(proxyAddr);
+ THTTPHdrVal proxyUsage(strP.StringF(HTTP::EUseProxy, RHTTPSession::GetTable()));
+ transactionProperties.SetPropertyL(strP.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), proxyUsage);
+ transactionProperties.SetPropertyL(strP.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), proxyAddr);
+ CleanupStack::PopAndDestroy(1,&proxyAddr);
+ }
+
+ // Setting HttpDataOptimiser for transaction.
+ if (!GetBoolFromConfig(ConfigSection(), KIniTranHttpOptUsage, tranHttpOptUsage))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KIniTranHttpOptUsage
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ if (tranHttpOptUsage)
+ iTrans.SetupHttpDataOptimiser(*this);
+ // submit the transaction
+ iTrans.SubmitL();
+ // Start the scheduler, once the transaction completes or is cancelled on an error the scheduler will be
+ // stopped in the event handler
+ CActiveScheduler::Start();
+ }
+
+
+/**
+This is the implementation of interface method MHttpDataOptimiser::MHFRunL
+If there is a reponse body it will be copied to a file.
+Just printing the fired events to the log file.
+@internalTechnology
+@test
+@param aTransaction Transaction which is being processed currently
+@param THTTPEvent Event for which it is called
+@return None
+*/
+void CHttpEboClientStep::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
+ {
+ switch (aEvent.iStatus)
+ {
+ case THTTPEvent::EGotResponseHeaders:
+ {
+ // HTTP response headers have been received. We can determine now if there is
+ // going to be a response body to save.
+ RHTTPResponse resp = aTransaction.Response();
+ TInt status = resp.StatusCode();
+ RStringF statusStr = resp.StatusText();
+ TBuf<32> statusStr16;
+ statusStr16.Copy(statusStr.DesC());
+ INFO_PRINTF3(_L("Status: %D (%S)\n"),status, &statusStr16);
+ // Determine if the body will be saved to disk
+ iSavingResponseBody = EFalse;
+ if (resp.HasBody() && (status >= 200) && (status < 300) && (status != 204))
+ {
+ TInt dataSize = resp.Body()->OverallDataSize();
+ if (dataSize >= 0)
+ INFO_PRINTF2(_L("Response body size is %d\n"), dataSize);
+ else
+ INFO_PRINTF1(_L("Response body size is unknown\n"));
+
+ // Save response to file in disk.
+ iSavingResponseBody = ETrue;
+ }
+
+ if (iSavingResponseBody) // If we're saving, then open a file handle for the new file
+ {
+ // Check it exists and open a file handle
+ TInt valid = iFileServ.IsValidName(iOutputFilename);
+ if (!valid)
+ {
+ ERR_PRINTF1(_L("The specified filename is not valid!.\n"));
+ iSavingResponseBody = EFalse;
+ }
+ else
+ {
+ TInt err = iRespBodyFile.Replace(iFileServ,
+ iOutputFilename,
+ EFileWrite|EFileShareExclusive);
+ if (err)
+ {
+ iSavingResponseBody = EFalse;
+ User::Leave(err);
+ }
+ }
+ }
+
+ } break;
+ case THTTPEvent::EGotResponseBodyData:
+ {
+ // Get the body data supplier
+ iRespBody = aTransaction.Response().Body();
+
+ // Append to the output file if we're saving responses
+ if (iSavingResponseBody)
+ {
+ INFO_PRINTF1(_L("Saving response body...\n"));
+ TPtrC8 bodyData;
+ TBool lastChunk = iRespBody->GetNextDataPart(bodyData);
+ iRespBodyFile.Write(bodyData);
+ if (lastChunk)
+ iRespBodyFile.Close();
+ }
+
+ // Done with that bit of body data
+ iRespBody->ReleaseData();
+ } break;
+ case THTTPEvent::EResponseComplete:
+ {
+ // The transaction's response is complete
+ INFO_PRINTF1(_L("\nTransaction Complete\n"));
+ } break;
+ case KErrHttpOptimiserFailsTrans:
+ {
+ INFO_PRINTF1(_L("Cancelling/Failing Transaction\n"));
+ aTransaction.Fail(THTTPFilterHandle::EProtocolHandler);
+ //CActiveScheduler::Stop();
+ } break;
+ case THTTPEvent::ESucceeded:
+ {
+ INFO_PRINTF1(_L("Transaction Successful\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ case THTTPEvent::EFailed:
+ {
+ INFO_PRINTF1(_L("Transaction Failed\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ //Line added to fail the test if no connection to a web server
+ SetTestStepResult(EFail);
+ } break;
+ case THTTPEvent::ERedirectedPermanently:
+ {
+ INFO_PRINTF1(_L("Permanent Redirection\n"));
+ } break;
+ case THTTPEvent::ERedirectedTemporarily:
+ {
+ INFO_PRINTF1(_L("Temporary Redirection\n"));
+ } break;
+ case THTTPEvent::ERedirectRequiresConfirmation:
+ {
+ // 301(Moved Permanently), 302(Found) or 307(Temporary Redirect) status is received
+ // from a transaction and hence ERedirectRequiresConfirmation is sent by filter
+ // client has opted to close the transaction
+ INFO_PRINTF1(_L("Redirect requires confirmation\n"));
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ } break;
+ default:
+ {
+ INFO_PRINTF2(_L("<unrecognised event: %D>\n"), aEvent.iStatus);
+ // close off the transaction if it's an error
+ if (aEvent.iStatus < 0)
+ {
+ aTransaction.Close();
+ CActiveScheduler::Stop();
+ }
+ //Line added to fail the test if no connection to a web server
+ SetTestStepResult(EFail);
+ } break;
+ }
+ }
+
+
+/**
+This is the implementation of interface method MHttpDataOptimiser::MHFRunError
+@internalTechnology
+@test
+@param aError Error which has been raised.
+@param aTransaction Transaction which is being processed currently
+@param THTTPEvent Event which it is being handled currently.
+@return None
+*/
+TInt CHttpEboClientStep::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
+ {
+ INFO_PRINTF2(_L("MHFRunError fired with error code %D\n"), aError);
+ return KErrNone;
+ }
+
+
+/**
+It enocodes the request data.
+@internalTechnology
+@test
+@param aHttpData Actual request.
+@param aEncodedData Encoded request.
+@return None
+*/
+void CHttpEboClientStep::EncodeL (const TDesC8& /*aHttpData*/, HBufC8* &aEncodedData)
+ {
+
+ INFO_PRINTF1(_L("######## CHttpEboClientStep::EncodeL ########\n"));
+ TBool isEncoded;
+ if (!GetBoolFromConfig(ConfigSection(), KIniIsEncoded, isEncoded))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KIniIsEncoded
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ // Checking whether enocoding is needed.
+ if (isEncoded)
+ {
+ // Encoding: Changing the request data to http://www.google.co.uk/
+ _LIT8(KTestRequest, "GET http://www.google.co.uk/ HTTP/1.1\r\nHost: www.google.co.uk\r\nAccept: */*\r\nUser-Agent: TestHttpEboClient\r\n\r\n");
+ const TDesC8& encodedReq(KTestRequest);
+ TRAPD(err,
+ {
+ aEncodedData = encodedReq.AllocLC();
+ CleanupStack::Pop();
+ });
+ if (err != KErrNone)
+ {
+ ERR_PRINTF2(_L("Test step failed: Leave occured while encoding the request: %D\n"), err);
+ SetTestStepResult(EFail);
+ }
+ else
+ {
+ INFO_PRINTF1(_L("Encoded/Changed the request\n"));
+ }
+ }
+ else
+ INFO_PRINTF1(_L("Not encoding the request [passing NULL]\n"));
+ }
+
+
+/**
+It decodes the responsing data before parsing.
+@internalTechnology
+@test
+@param aHttpData Actual response.
+@param aEncodedData Decoded response.
+@return None
+*/
+void CHttpEboClientStep::DecodeL (const TDesC8& aData, HBufC8*& aHttpData, TBool& aTransFail)
+ {
+ INFO_PRINTF1(_L("######## CHttpEboClientStep::DecodeL ########\n"));
+ TBool isDecoded;
+ TBool failTransaction;
+ if (!GetBoolFromConfig(ConfigSection(), KIniIsDecoded, isDecoded))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KIniIsDecoded
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ // Checking whether decoding is needed.
+ if (isDecoded)
+ {
+ TRAPD(err,
+ {
+ // Copying same actual response to decoded response
+ aHttpData = aData.AllocLC();
+ CleanupStack::Pop();
+ });
+ if (err != KErrNone)
+ {
+ ERR_PRINTF2(_L("Test step failed: Leave occured while decoding the response: %D\n"), err);
+ SetTestStepResult(EFail);
+ }
+ else
+ {
+ INFO_PRINTF1(_L("Sent the actual response as a decoded response\n"));
+ }
+ }
+ else
+ INFO_PRINTF1(_L("Not decoding the response [passing NULL]\n"));
+
+ if(!GetBoolFromConfig(ConfigSection(), KIniFailTransaction, failTransaction))
+ {
+ ERR_PRINTF2(_L("Problem in reading values from ini. \
+ \nExpected fields are: \n%S\n"
+ ),&KIniFailTransaction
+ );
+ SetTestStepResult(EFail);
+ return;
+ }
+ // Checking to fail the transaction.
+ if (failTransaction)
+ {
+ aTransFail = ETrue;
+ INFO_PRINTF1(_L("CHttpEboClientStep::DecodeL returing ETrue(intend to fail the transaction)\n"));
+ }
+ else
+ {
+ aTransFail = EFalse;
+ INFO_PRINTF1(_L("CHttpEboClientStep::DecodeL returing EFalse(not failing the transaction)\n"));
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/ats/smoketest/http/src/testhttpserver.cpp Wed Jan 06 13:41:51 2010 +0000
@@ -0,0 +1,271 @@
+// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Symbian Foundation License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Contains implementation of CTestHttpServer class
+// @internalAll
+//
+//
+
+// User Includes
+// Test Server
+#include "testhttpserver.h"
+
+// Test steps
+#include "testhttpbasestep.h"
+#include "testhttpeboclientstep.h"
+#include "testhttpeboclientconditionalstep.h"
+#include "testhttpbuffersizestep.h"
+
+#if (!defined EKA2)
+// The system-wide unique name for the test-server
+_LIT(KServerName, "TestHttpServer");
+#endif
+
+/**
+Static factory constructor. Creates and returns instance of the test server
+@internalTechnology
+@test
+@return A pointer to the newly created CTestHttpServer object
+*/
+CTestHttpServer* CTestHttpServer::NewL()
+ {
+ // Construct the server
+ CTestHttpServer* server = new(ELeave) CTestHttpServer();
+ CleanupStack::PushL(server);
+
+ // CServer base class call
+ // Name the server using the system-wide unique string
+ // Clients use this to create server sessions.
+ server->StartL(server->ServerName());
+
+ CleanupStack::Pop(server);
+ return server;
+ }
+
+
+#if (!defined EKA2)
+/**
+Creates the Active Scheduler, then creates the test-server, synchronises the
+thread with the client and then enters the active scheduler.
+
+This is EKA1 version of MainL(). Uses sempahore to sync with client
+as Rendezvous calls are not available
+*/
+LOCAL_C void MainL()
+ {
+ // Create and install the active scheduler.
+ CActiveScheduler* sched = new(ELeave) CActiveScheduler;
+ CleanupStack::PushL(sched);
+ CActiveScheduler::Install(sched);
+
+ // Create the server inside trap harness
+ CTestHttpServer *server = NULL;
+ TRAPD(err, server = CTestHttpServer::NewL());
+ if (!err)
+ {
+ CleanupStack::PushL(server);
+ RSemaphore sem;
+
+ // The client API of TestExecute will already have created the
+ // semaphore and will be waiting on it.
+ User::LeaveIfError(sem.OpenGlobal(KServerName));
+
+ CleanupStack::Pop(server);
+
+ // Signal the client
+ sem.Signal();
+ sem.Close();
+
+ // Enter the active scheduler
+ sched->Start();
+ }
+ CleanupStack::PopAndDestroy(); // sched
+ delete server;
+
+ }
+#else
+/**
+EKA2 version of MainL()
+Uses the new Rendezvous call isntead of the older semaphore.
+*/
+LOCAL_C void MainL()
+ {
+ // For platform security
+#if (defined __DATA_CAGING__)
+ RProcess().DataCaging(RProcess::EDataCagingOn);
+ RProcess().SecureApi(RProcess::ESecureApiOn);
+#endif
+ CActiveScheduler* sched = new(ELeave) CActiveScheduler;
+ CActiveScheduler::Install(sched);
+ CTestHttpServer* server = NULL;
+
+ // Create the test-server
+ TRAPD(err, server = CTestHttpServer::NewL());
+
+ if(!err)
+ {
+ // Sync with the client and enter the active scheduler
+ RProcess::Rendezvous(KErrNone);
+ sched->Start();
+ }
+ delete server;
+ delete sched;
+ }
+#endif // #if (!defined EKA2)
+
+
+#if (defined __WINS__ && !defined EKA2)
+/**
+DLL entry-point for EKA1 emulator builds.
+*/
+GLDEF_C TInt E32Dll(enum TDllReason /*aDllReason*/)
+ {
+ return KErrNone;
+ }
+#else
+/**
+Exe entry point code, for EKA1 hardware and EKA2 builds.
+*/
+GLDEF_C TInt E32Main()
+ {
+ __UHEAP_MARK;
+ CTrapCleanup *cleanup = CTrapCleanup::New();
+ if (cleanup == NULL)
+ {
+ return KErrNoMemory;
+ }
+
+ TRAPD(err, MainL());
+ __ASSERT_ALWAYS(!err,User::Panic(KTxt,err));
+ delete cleanup;
+ __UHEAP_MARKEND;
+ return KErrNone;
+ }
+#endif // #if (defined __WINS__ && !defined EKA2)
+
+#if (defined __WINS__ && !defined EKA2)
+/**
+For EKA1 emulator builds. This function is called when the thread is first
+resumed. Has the standard thread entry siganture.
+@internalTechnology
+@test
+@return KErrNone if everything is fine or system-wide error if any
+*/
+TInt ThreadFunc (TAny* /*aParam*/)
+ {
+ __UHEAP_MARK;
+ CTrapCleanup* cleanup = CTrapCleanup::New();
+ if (cleanup == NULL)
+ {
+ return KErrNoMemory;
+ }
+ TRAPD(err, MainL());
+ __ASSERT_ALWAYS(!err,User::Panic(KTxt,err));
+ delete cleanup;
+ __UHEAP_MARKEND;
+ return KErrNone;
+ }
+
+/**
+For EKA1 emulator builds. Creates and starts a thread for the server to run.
+@internalTechnology
+@test
+@param None
+@return Integer value indicating the error code.
+*/
+EXPORT_C TInt NewServer()
+ {
+ _LIT(KThread, "Thread");
+ RThread thread;
+
+ // Name the thread as "<Server-Name>Thread" making it hopefully unique
+ TBuf<KMaxTestExecuteNameLength> threadName(KServerName);
+ threadName.Append(KThread);
+
+ const TInt KMaxHeapSize = 0x1000000;
+
+ // Create the thread
+ TInt err = thread.Create(threadName, ThreadFunc, KDefaultStackSize,
+ KMinHeapSize, KMaxHeapSize, NULL, EOwnerProcess
+ );
+ if (err != KErrNone)
+ {
+ return err;
+ }
+
+ // Start the thread -> effectively calls ThreadFunc
+ thread.Resume();
+
+ thread.Close();
+ return KErrNone;
+ }
+#endif // #if (defined __WINS__ && !defined EKA2)
+
+
+/**
+Base class pure virtual
+@internalTechnology
+@test
+@return Instance of the test step
+@param Descriptor containing the test-step name
+*/
+CTestStep* CTestHttpServer::CreateTestStep(const TDesC& aStepName)
+ {
+ CTestStep *testStep = NULL;
+ TRAPD(err,testStep=CreateTestStepL(aStepName));
+ if(err == KErrNone)
+ return testStep;
+ else
+ return NULL;
+ }
+
+
+CTestStep* CTestHttpServer::CreateTestStepL(const TDesC& aStepName)
+ {
+ CTestStep *testStep = NULL;
+
+ if (aStepName == KTestHttpEboClientStep)
+ {
+ testStep = new (ELeave) CHttpEboClientStep();
+ }
+ else if (aStepName == KTestHttpEboClientConditionalStep)
+ {
+ testStep = new (ELeave) CHttpEboClientConditionalStep();
+ }
+ else if ( aStepName == KTestHttpBufferSizeStep )
+ {
+ testStep = new (ELeave) CTestHttpBufferSizeStep();
+ }
+
+ return testStep;
+ }
+
+/**
+Returns server name based on the EKA version
+@internalTechnology
+@test
+@return Descriptor containing the servername
+*/
+const TPtrC CTestHttpServer::ServerName()
+ {
+#if (!defined EKA2)
+ return KServerName();
+#else
+ // The exe name can be either TestWListBListUriServer or
+ // TestWListBListUriServer_Cap based on whether the normal
+ // or the security tests are being run. So decide the server
+ // name during runtime
+ TParsePtrC serverName(RProcess().FileName());
+ return serverName.Name();
+#endif
+ }