common/tools/ats/smoketest/http/src/testhttpserver.cpp
author Maciej Seroka <maciejs@symbian.org>
Wed, 06 Jan 2010 13:41:51 +0000
changeset 836 675529c38614
child 872 17498133d9ad
permissions -rw-r--r--
Added smoke test for making a connection to a web server through ethernet
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     4
// under the terms of the License "Symbian Foundation License v1.0"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     7
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    10
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    11
// Contributors:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    12
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    13
// Description:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    14
// Contains implementation of CTestHttpServer class
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    15
// @internalAll
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    16
// 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    17
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    18
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    19
// User Includes
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    20
// Test Server
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    21
#include "testhttpserver.h"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    22
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    23
// Test steps
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    24
#include "testhttpbasestep.h"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    25
#include "testhttpeboclientstep.h"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    26
#include "testhttpeboclientconditionalstep.h"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    27
#include "testhttpbuffersizestep.h"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    28
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    29
#if (!defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    30
// The system-wide unique name for the test-server
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    31
_LIT(KServerName, "TestHttpServer");
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    32
#endif
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    33
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    34
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    35
Static factory constructor. Creates and returns instance of the test server
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    36
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    37
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    38
@return		A pointer to the newly created CTestHttpServer object
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    39
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    40
CTestHttpServer*  CTestHttpServer::NewL()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    41
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    42
	// Construct the server
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    43
	CTestHttpServer* server = new(ELeave) CTestHttpServer();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    44
	CleanupStack::PushL(server);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    45
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    46
	// CServer base class call
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    47
	// Name the server using the system-wide unique string
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    48
	// Clients use this to create server sessions.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    49
	server->StartL(server->ServerName());
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    50
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    51
	CleanupStack::Pop(server);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    52
	return server;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    53
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    54
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    55
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    56
#if (!defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    57
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    58
Creates the Active Scheduler, then creates the test-server, synchronises the
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    59
thread with the client and then enters the active scheduler.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    60
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    61
This is EKA1 version of MainL(). Uses sempahore to sync with client
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    62
as Rendezvous calls are not available
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    63
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    64
LOCAL_C void MainL()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    65
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    66
	// Create and install the active scheduler.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    67
	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    68
	CleanupStack::PushL(sched);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    69
	CActiveScheduler::Install(sched);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    70
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    71
	// Create the server inside trap harness
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    72
	CTestHttpServer *server = NULL;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    73
	TRAPD(err, server = CTestHttpServer::NewL());
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    74
	if (!err)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    75
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    76
		CleanupStack::PushL(server);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    77
		RSemaphore sem;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    78
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    79
		// The client API of TestExecute will already have created the
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    80
		// semaphore and will be waiting on it.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    81
		User::LeaveIfError(sem.OpenGlobal(KServerName));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    82
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    83
		CleanupStack::Pop(server);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    84
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    85
		// Signal the client
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    86
		sem.Signal();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    87
		sem.Close();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    88
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    89
		// Enter the active scheduler
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    90
		sched->Start();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    91
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    92
	CleanupStack::PopAndDestroy(); // sched
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    93
	delete server;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    94
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    95
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    96
#else
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    97
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    98
EKA2 version of MainL()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    99
Uses the new Rendezvous call isntead of the older semaphore.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   100
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   101
LOCAL_C void MainL()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   102
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   103
	// For platform security
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   104
#if (defined __DATA_CAGING__)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   105
	RProcess().DataCaging(RProcess::EDataCagingOn);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   106
	RProcess().SecureApi(RProcess::ESecureApiOn);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   107
#endif
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   108
	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   109
	CActiveScheduler::Install(sched);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   110
	CTestHttpServer* server = NULL;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   111
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   112
	// Create the test-server
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   113
	TRAPD(err, server = CTestHttpServer::NewL());
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   114
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   115
	if(!err)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   116
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   117
		// Sync with the client and enter the active scheduler
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   118
		RProcess::Rendezvous(KErrNone);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   119
		sched->Start();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   120
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   121
	delete server;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   122
	delete sched;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   123
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   124
#endif		// #if (!defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   125
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   126
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   127
#if (defined __WINS__ && !defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   128
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   129
DLL entry-point for EKA1 emulator builds.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   130
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   131
GLDEF_C TInt E32Dll(enum TDllReason /*aDllReason*/)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   132
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   133
	return KErrNone;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   134
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   135
#else
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   136
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   137
Exe entry point code, for EKA1 hardware and EKA2 builds.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   138
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   139
GLDEF_C TInt E32Main()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   140
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   141
	__UHEAP_MARK;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   142
	CTrapCleanup *cleanup = CTrapCleanup::New();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   143
	if (cleanup == NULL)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   144
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   145
		return KErrNoMemory;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   146
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   147
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   148
	TRAPD(err, MainL());
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   149
	__ASSERT_ALWAYS(!err,User::Panic(KTxt,err));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   150
	delete cleanup;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   151
	__UHEAP_MARKEND;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   152
	return KErrNone;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   153
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   154
#endif		// #if (defined __WINS__ && !defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   155
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   156
#if (defined __WINS__ && !defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   157
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   158
For EKA1 emulator builds. This function is called when the thread is first
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   159
resumed. Has the standard thread entry siganture.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   160
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   161
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   162
@return		KErrNone if everything is fine or system-wide error if any
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   163
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   164
TInt ThreadFunc (TAny* /*aParam*/)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   165
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   166
	__UHEAP_MARK;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   167
	CTrapCleanup* cleanup = CTrapCleanup::New();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   168
	if (cleanup == NULL)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   169
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   170
		return KErrNoMemory;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   171
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   172
	TRAPD(err, MainL());
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   173
	__ASSERT_ALWAYS(!err,User::Panic(KTxt,err));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   174
	delete cleanup;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   175
	__UHEAP_MARKEND;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   176
	return KErrNone;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   177
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   178
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   179
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   180
For EKA1 emulator builds. Creates and starts a thread for the server to run.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   181
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   182
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   183
@param		None
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   184
@return		Integer value indicating the error code.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   185
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   186
EXPORT_C TInt NewServer()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   187
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   188
	_LIT(KThread, "Thread");
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   189
	RThread thread;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   190
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   191
	// Name the thread as "<Server-Name>Thread" making it hopefully unique
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   192
	TBuf<KMaxTestExecuteNameLength> threadName(KServerName);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   193
	threadName.Append(KThread);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   194
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   195
	const TInt KMaxHeapSize = 0x1000000;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   196
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   197
	// Create the thread
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   198
	TInt err = thread.Create(threadName, ThreadFunc, KDefaultStackSize,
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   199
							 KMinHeapSize, KMaxHeapSize, NULL, EOwnerProcess
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   200
							);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   201
	if (err != KErrNone)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   202
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   203
		return err;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   204
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   205
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   206
	// Start the thread -> effectively calls ThreadFunc
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   207
	thread.Resume();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   208
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   209
	thread.Close();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   210
	return KErrNone;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   211
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   212
#endif 		// #if (defined __WINS__ && !defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   213
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   214
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   215
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   216
Base class pure virtual
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   217
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   218
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   219
@return 	Instance of the test step
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   220
@param		Descriptor containing the test-step name
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   221
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   222
CTestStep* CTestHttpServer::CreateTestStep(const TDesC& aStepName)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   223
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   224
	CTestStep *testStep = NULL;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   225
	TRAPD(err,testStep=CreateTestStepL(aStepName));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   226
	if(err == KErrNone)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   227
		return testStep;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   228
	else
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   229
		return NULL;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   230
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   231
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   232
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   233
CTestStep* CTestHttpServer::CreateTestStepL(const TDesC& aStepName)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   234
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   235
	CTestStep *testStep = NULL;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   236
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   237
	if (aStepName == KTestHttpEboClientStep)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   238
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   239
		testStep = new (ELeave) CHttpEboClientStep();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   240
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   241
	else if (aStepName == KTestHttpEboClientConditionalStep)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   242
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   243
		testStep = new (ELeave) CHttpEboClientConditionalStep();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   244
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   245
	else if ( aStepName == KTestHttpBufferSizeStep )
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   246
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   247
		testStep = new (ELeave) CTestHttpBufferSizeStep();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   248
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   249
		
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   250
	return testStep;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   251
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   252
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   253
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   254
Returns server name based on the EKA version
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   255
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   256
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   257
@return		Descriptor containing the servername
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   258
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   259
const TPtrC CTestHttpServer::ServerName()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   260
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   261
#if (!defined EKA2)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   262
	return KServerName();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   263
#else
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   264
	// The exe name can be either TestWListBListUriServer or
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   265
	// TestWListBListUriServer_Cap based on whether the normal
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   266
	// or the security tests are being run. So decide the server
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   267
	// name during runtime
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   268
	TParsePtrC serverName(RProcess().FileName());
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   269
	return serverName.Name();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   270
#endif
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   271
	}