LbsApi/src/requestorclassesstep.cpp
author Maciej Seroka <maciejs@symbian.org>
Wed, 28 Jul 2010 13:24:28 +0100
branchSymbian3
changeset 54 a4835904093b
permissions -rw-r--r--
Added new LbsApi smoke test
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     7
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    10
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    11
// Contributors:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    12
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    13
// Description:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    14
// Example CTestStep derived implementation
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    15
// 
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    16
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    17
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    18
/**
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    19
 @file RequestorClassesStep.cpp
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    20
 @internalTechnology
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    21
*/
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    22
#include "requestorclassesstep.h"
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    23
#include "te_lbsapisuitedefs.h"
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    24
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    25
#include "lcfsbucommondefinitions.h"
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    26
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    27
#include <lbs.h>
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    28
#include <lbssatellite.h>
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    29
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    30
#include <s32mem.h>
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    31
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    32
CRequestorClassesStep::~CRequestorClassesStep()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    33
/**
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    34
 * Destructor
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    35
 */
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    36
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    37
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    38
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    39
CRequestorClassesStep::CRequestorClassesStep()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    40
/**
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    41
 * Constructor
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    42
 */
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    43
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    44
	// **MUST** call SetTestStepName in the constructor as the controlling
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    45
	// framework uses the test step name immediately following construction to set
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    46
	// up the step's unique logging ID.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    47
	SetTestStepName(KRequestorClassesStep);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    48
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    49
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    50
TVerdict CRequestorClassesStep::doTestStepPreambleL()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    51
/**
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    52
 * @return - TVerdict code
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    53
 * Override of base class virtual
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    54
 */
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    55
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    56
	 CTe_LbsApiSuiteStepBase::doTestStepPreambleL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    57
	 if (TestStepResult()!=EPass)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    58
	    return   TestStepResult();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    59
	// process some pre setting to this test step then set SetTestStepResult to EFail or Epass.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    60
	SetTestStepResult(EPass);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    61
	return TestStepResult();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    62
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    63
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    64
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    65
TVerdict CRequestorClassesStep::doTestStepL()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    66
/**
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    67
 * @return - TVerdict code
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    68
 * Override of base class pure virtual
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    69
 * Our implementation only gets called if the base class doTestStepPreambleL() did
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    70
 * not leave. That being the case, the current test result value will be EPass.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    71
 */
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    72
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    73
	if (TestStepResult()==EPass)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    74
		{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    75
		TInt test;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    76
		if(!GetIntFromConfig(ConfigSection(),KTe_LbsApiSuiteInt,test)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    77
			)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    78
			{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    79
			// Leave if there's any error.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    80
			User::Leave(KErrNotFound);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    81
			}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    82
		SetTestStepResult(EPass);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    83
		StartL(test);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    84
		}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    85
	return TestStepResult();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    86
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    87
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    88
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    89
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    90
TVerdict CRequestorClassesStep::doTestStepPostambleL()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    91
/**
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    92
 * @return - TVerdict code
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    93
 * Override of base class virtual
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    94
 */
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    95
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    96
	// process something post setting to the test step
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    97
	// uncomment the following line if you have common post setting to all the test steps in there
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    98
	// CTe_LbsApiSuiteStepBase::doTestStepPostambleL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    99
	// uncomment the following line if you have post process or remove the following line if no post process
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   100
	// SetTestStepResult(EPass);		// or EFail
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   101
	return TestStepResult();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   102
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   103
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   104
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   105
void CRequestorClassesStep::StartL (TInt aIndex)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   106
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   107
	switch (aIndex)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   108
		{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   109
	case 0:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   110
		RRequestorStack_StreamingL ();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   111
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   112
	case 1:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   113
		RRequestorStack_Streaming2L ();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   114
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   115
	case 2:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   116
		CRequestor_ConstructionL ();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   117
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   118
	case 3:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   119
		CRequestor_SetL ();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   120
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   121
	case 4:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   122
		CRequestor_Construction2L ();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   123
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   124
	case 5:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   125
		CRequestor_StreamingL ();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   126
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   127
	case 6:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   128
		CRequestor_Streaming2L ();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   129
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   130
	default:
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   131
		break;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   132
		}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   133
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   134
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   135
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   136
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   137
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   138
// RRequestorStack
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   139
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   140
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   141
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   142
void ResetAndDestroyRequestorStack(TAny* aArray)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   143
    {
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   144
    RRequestorStack* stack = static_cast<RRequestorStack*>(aArray);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   145
    stack->ResetAndDestroy();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   146
    }
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   147
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   148
// 8.1.1. Streaming
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   149
void CRequestorClassesStep::RRequestorStack_StreamingL()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   150
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   151
    DECLARE_ERROR_LOGGING;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   152
    StandardPrepareL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   153
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   154
    RRequestorStack requestorStack;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   155
    CleanupStack::PushL(TCleanupItem(ResetAndDestroyRequestorStack, &requestorStack));
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   156
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   157
    _LIT(KDummyLit1, "Hello");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   158
    const CRequestor::TRequestorType KDummyRequestorType1(CRequestor::ERequestorService);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   159
    const CRequestor::TRequestorFormat KDummyRequestorFormat1(CRequestor::EFormatTelephone);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   160
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   161
    CRequestor* requestor = CRequestor::NewLC(KDummyRequestorType1, KDummyRequestorFormat1, KDummyLit1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   162
    User::LeaveIfError(requestorStack.Append(requestor));        //take ownership of requestor
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   163
    CleanupStack::Pop(requestor);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   164
    requestor = NULL;        //Just to make it clear we don't one requestor.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   165
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   166
    _LIT(KDummyLit2, "Goodbye");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   167
    const CRequestor::TRequestorType KDummyRequestorType2(CRequestor::ERequestorContact);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   168
    const CRequestor::TRequestorFormat KDummyRequestorFormat2(CRequestor::EFormatUrl);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   169
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   170
    requestor = CRequestor::NewLC(KDummyRequestorType2, KDummyRequestorFormat2, KDummyLit2);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   171
    User::LeaveIfError(requestorStack.Append(requestor));        //take ownership of requestor
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   172
    CleanupStack::Pop(requestor);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   173
    requestor = NULL;        //Just to make it clear we don't one requestor.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   174
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   175
    //All info in requestorStack. Now stream out and back into a new requestor stack.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   176
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   177
    CBufFlat* buffer = CBufFlat::NewL(512);        //Abritrary size chosen
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   178
    CleanupStack::PushL(buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   179
    RBufWriteStream writeStream;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   180
    writeStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   181
    writeStream.PushL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   182
    // externalize
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   183
    requestorStack.ExternalizeL(writeStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   184
    writeStream.CommitL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   185
    writeStream.Pop();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   186
    //requestorStack now piped into buffer.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   187
    //get rid of requestorStack.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   188
    CleanupStack::Pop(buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   189
    CleanupStack::PopAndDestroy(&requestorStack);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   190
    CleanupStack::PushL(buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   191
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   192
    RBufReadStream readStream;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   193
    readStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   194
    readStream.PushL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   195
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   196
    RRequestorStack requestorStack2;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   197
    CleanupStack::PushL(TCleanupItem(ResetAndDestroyRequestorStack, &requestorStack2));
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   198
    // internalize
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   199
    requestorStack2.InternalizeL(readStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   200
    //requestorStack2 should now be initialised.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   201
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   202
    CHECK_EQUAL_(2, requestorStack2.Count());
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   203
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   204
    requestor = requestorStack2[0];
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   205
    CHECK(!TPtrC(KDummyLit1).Compare(requestor->RequestorData()));
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   206
    CHECK_EQUAL_(requestor->RequestorType(), KDummyRequestorType1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   207
    CHECK_EQUAL_(requestor->RequestorFormat(), KDummyRequestorFormat1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   208
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   209
    requestor = requestorStack2[1];
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   210
    CHECK(!TPtrC(KDummyLit2).Compare(requestor->RequestorData()));
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   211
    CHECK_EQUAL_(requestor->RequestorType(), KDummyRequestorType2);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   212
    CHECK_EQUAL_(requestor->RequestorFormat(), KDummyRequestorFormat2);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   213
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   214
    CleanupStack::PopAndDestroy(3, buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   215
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   216
    StandardCleanup();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   217
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   218
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   219
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   220
// 8.1.2. Streaming with invalid stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   221
TInt RRequestorStack_Streaming_Invalid(TAny* /*aPtr*/)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   222
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   223
    RBufReadStream readStream;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   224
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   225
    // buffer
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   226
        CBufFlat* buffer = CBufFlat::NewL(512);        //Arbitrary size chosen
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   227
    RBufWriteStream writeStream; // make sure it is empty
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   228
    writeStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   229
    writeStream.WriteUint16L(12345); // put dummy value there (different from KRequestorStackVersion)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   230
    writeStream.Close();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   231
    writeStream.Release();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   232
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   233
    // read-stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   234
    readStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   235
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   236
    TInt err;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   237
    TRAP(err,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   238
        // internalize it
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   239
        RRequestorStack requestorStack2;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   240
        CleanupStack::PushL(TCleanupItem(ResetAndDestroyRequestorStack, &requestorStack2));
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   241
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   242
        requestorStack2.InternalizeL(readStream);   //This should panic
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   243
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   244
        CleanupStack::Pop();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   245
    	);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   246
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   247
    readStream.Release();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   248
    delete buffer;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   249
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   250
    return KErrGeneral;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   251
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   252
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   253
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   254
void CRequestorClassesStep::RRequestorStack_Streaming2L()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   255
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   256
    DECLARE_ERROR_LOGGING;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   257
    StandardPrepareL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   258
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   259
    // attempt to internalize from invalid stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   260
    DO_PANIC_TEST_L(
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   261
        RRequestorStack_Streaming_Invalid,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   262
        KPosClientFault,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   263
        EPositionInvalidClassType,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   264
        KDefaultTestTimeout);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   265
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   266
    StandardCleanup();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   267
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   268
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   269
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   270
// 8.1.3. Streaming with No Memory
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   271
// See NoMemoryTests.cpp
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   272
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   273
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   274
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   275
// CRequestor
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   276
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   277
//
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   278
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   279
// 8.2.1. Construction
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   280
void CRequestorClassesStep::CRequestor_ConstructionL()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   281
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   282
    DECLARE_ERROR_LOGGING;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   283
    StandardPrepareL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   284
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   285
    _LIT(KDummyLit, "Hello");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   286
    const CRequestor::TRequestorType KDummyRequestorType(CRequestor::ERequestorService);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   287
    const CRequestor::TRequestorFormat KDummyRequestorFormat(CRequestor::EFormatTelephone);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   288
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   289
    CRequestor* requestor = NULL;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   290
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   291
    requestor = CRequestor::NewL(KDummyRequestorType, KDummyRequestorFormat, KDummyLit);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   292
    CHECK(requestor->RequestorData().Compare(KDummyLit) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   293
    CHECK(requestor->RequestorType()   == KDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   294
    CHECK(requestor->RequestorFormat() == KDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   295
    delete requestor;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   296
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   297
    requestor = CRequestor::NewLC(KDummyRequestorType, KDummyRequestorFormat, KDummyLit);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   298
    CHECK(requestor->RequestorData().Compare(KDummyLit) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   299
    CHECK(requestor->RequestorType()   == KDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   300
    CHECK(requestor->RequestorFormat() == KDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   301
    CleanupStack::PopAndDestroy(requestor);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   302
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   303
    requestor = static_cast<CRequestor*>( User::LeaveIfNull(CRequestor::New(KDummyRequestorType, KDummyRequestorFormat, KDummyLit)));
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   304
    CHECK(requestor->RequestorData().Compare(KDummyLit) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   305
    CHECK(requestor->RequestorType()   == KDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   306
    CHECK(requestor->RequestorFormat() == KDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   307
    delete requestor;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   308
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   309
    StandardCleanup();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   310
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   311
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   312
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   313
// 8.2.2. Setters and Getters
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   314
void CRequestorClassesStep::CRequestor_SetL()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   315
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   316
    DECLARE_ERROR_LOGGING;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   317
    StandardPrepareL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   318
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   319
    // Get
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   320
    _LIT(KDummyLit, "Hello");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   321
    const CRequestor::TRequestorType KDummyRequestorType(CRequestor::ERequestorService);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   322
    const CRequestor::TRequestorFormat KDummyRequestorFormat(CRequestor::EFormatTelephone);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   323
    CRequestor* requestor = CRequestor::NewL(KDummyRequestorType, KDummyRequestorFormat, KDummyLit);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   324
    CleanupStack::PushL(requestor);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   325
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   326
    TPtrC ptr;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   327
    CRequestor::TRequestorType requestorType;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   328
    CRequestor::TRequestorFormat requestorFormat;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   329
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   330
    requestor->GetRequestor(requestorType, requestorFormat, ptr);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   331
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   332
    CHECK(ptr.Compare(KDummyLit)    == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   333
    CHECK(requestorType             == KDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   334
    CHECK(requestorFormat           == KDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   335
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   336
    // Set
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   337
    _LIT(KNewDummyLit, "Goodbye");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   338
    const CRequestor::TRequestorType KNewDummyRequestorType(CRequestor::ERequestorContact);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   339
    const CRequestor::TRequestorFormat KNewDummyRequestorFormat(CRequestor::EFormatUrl);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   340
    requestor->SetRequestorL(KNewDummyRequestorType, KNewDummyRequestorFormat, KNewDummyLit);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   341
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   342
    // check as properties
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   343
    CHECK(requestor->RequestorData().Compare(KNewDummyLit) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   344
    CHECK(requestor->RequestorType()   == KNewDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   345
    CHECK(requestor->RequestorFormat() == KNewDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   346
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   347
    // check by GetRequestor
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   348
    requestor->GetRequestor(requestorType, requestorFormat, ptr);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   349
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   350
    CHECK(ptr.Compare(KNewDummyLit) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   351
    CHECK(requestorType             == KNewDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   352
    CHECK(requestorFormat           == KNewDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   353
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   354
    CleanupStack::PopAndDestroy();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   355
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   356
    // Now set much longer requestor data, to check if
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   357
    // doesn't matter :-)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   358
    TBuf<1> shortData;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   359
    shortData.Append('$');
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   360
    requestor = CRequestor::NewLC(KDummyRequestorType, KDummyRequestorFormat, shortData);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   361
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   362
    TBuf<512> longData;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   363
    longData.Fill('@', longData.MaxLength());
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   364
    requestor->SetRequestorL(KNewDummyRequestorType, KNewDummyRequestorFormat, longData);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   365
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   366
    // check it
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   367
    CHECK(requestor->RequestorData().Compare(longData) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   368
    CHECK(requestor->RequestorType()   == KNewDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   369
    CHECK(requestor->RequestorFormat() == KNewDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   370
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   371
    // set smaller one again
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   372
    requestor->SetRequestorL(KDummyRequestorType, KDummyRequestorFormat, shortData);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   373
    CHECK(requestor->RequestorData().Compare(shortData) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   374
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   375
    CleanupStack::PopAndDestroy();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   376
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   377
    StandardCleanup();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   378
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   379
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   380
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   381
/*
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   382
// 8.2.3. Constructors with invalid parameters
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   383
void CRequestorClassesStep::CRequestor_Construction3L()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   384
{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   385
    // there are no relevant parameters to pass invalid values.
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   386
    // the only one is wrong stream, see 8.3.4 CRequestor_Streaming_Invalid
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   387
}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   388
*/
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   389
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   390
// 8.2.4. Constructors with No Memory
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   391
// See NoMemoryTests.cpp
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   392
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   393
// 8.2.5. SetRequestor with No Memory
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   394
// See NoMemoryTests.cpp
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   395
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   396
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   397
// 8.3.1. Construction from stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   398
void CRequestorClassesStep::CRequestor_Construction2L()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   399
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   400
    DECLARE_ERROR_LOGGING;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   401
    StandardPrepareL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   402
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   403
    _LIT(KDummyLit, "Hello");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   404
    const CRequestor::TRequestorType KDummyRequestorType(CRequestor::ERequestorService);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   405
    const CRequestor::TRequestorFormat KDummyRequestorFormat(CRequestor::EFormatTelephone);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   406
    CRequestor* requestor1 = CRequestor::NewLC(KDummyRequestorType, KDummyRequestorFormat, KDummyLit);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   407
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   408
    //Make a write stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   409
    HBufC8* buffer = HBufC8::NewLC(0x100);        //Should be plenty big enough
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   410
    TPtr8 ptr = buffer->Des();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   411
    RDesWriteStream writeStream(ptr);        //Opens the write stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   412
    CleanupClosePushL(writeStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   413
    requestor1->ExternalizeL(writeStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   414
    writeStream.CommitL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   415
    CleanupStack::PopAndDestroy(&writeStream);        //Close the write stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   416
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   417
    //Make a read stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   418
    RDesReadStream readStream(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   419
    CleanupClosePushL(readStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   420
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   421
    // construct
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   422
    CRequestor* requestor2 = CRequestor::NewL(readStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   423
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   424
    CHECK(!TPtrC(KDummyLit).Compare(requestor2->RequestorData()));
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   425
    CHECK_EQUAL_(requestor2->RequestorType(), KDummyRequestorType);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   426
    CHECK_EQUAL_(requestor2->RequestorFormat(), KDummyRequestorFormat);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   427
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   428
    delete requestor2;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   429
    CleanupStack::PopAndDestroy(3, requestor1);        //readStream, buffer, requestor1
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   430
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   431
    StandardCleanup();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   432
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   433
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   434
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   435
// 8.3.2. Externalize/Internalize
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   436
void CRequestorClassesStep::CRequestor_StreamingL()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   437
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   438
    DECLARE_ERROR_LOGGING;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   439
    StandardPrepareL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   440
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   441
    _LIT(KDummyLit1, "Hello");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   442
    const CRequestor::TRequestorType KDummyRequestorType1(CRequestor::ERequestorService);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   443
    const CRequestor::TRequestorFormat KDummyRequestorFormat1(CRequestor::EFormatTelephone);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   444
    CRequestor* requestor1 = CRequestor::NewLC(KDummyRequestorType1, KDummyRequestorFormat1, KDummyLit1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   445
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   446
    // set r2 with other values
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   447
    _LIT(KDummyLit2, "Goodbye");
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   448
    const CRequestor::TRequestorType KDummyRequestorType2(CRequestor::ERequestorContact);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   449
    const CRequestor::TRequestorFormat KDummyRequestorFormat2(CRequestor::EFormatUrl);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   450
    CRequestor* requestor2 = CRequestor::NewLC(KDummyRequestorType2, KDummyRequestorFormat2, KDummyLit2);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   451
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   452
    // Make a write stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   453
    HBufC8* buffer = HBufC8::NewLC(0x100);        //Should be plenty big enough
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   454
    TPtr8 ptr = buffer->Des();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   455
    RDesWriteStream writeStream(ptr);        //Opens the write stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   456
    CleanupClosePushL(writeStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   457
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   458
    // externalize r1
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   459
    writeStream << *requestor1;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   460
    writeStream.CommitL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   461
    CleanupStack::PopAndDestroy(&writeStream);        //Close the write stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   462
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   463
    RDesReadStream readStream(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   464
    CleanupClosePushL(readStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   465
    // internalize r2
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   466
    requestor2->InternalizeL(readStream);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   467
    CleanupStack::PopAndDestroy(&readStream);        //Close the readStream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   468
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   469
    // check r2
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   470
    CHECK(requestor2->RequestorData().Compare(KDummyLit1) == 0);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   471
    CHECK(requestor2->RequestorType()   == KDummyRequestorType1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   472
    CHECK(requestor2->RequestorFormat() == KDummyRequestorFormat1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   473
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   474
    CleanupStack::PopAndDestroy(3, requestor1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   475
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   476
    StandardCleanup();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   477
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   478
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   479
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   480
// 8.3.3. Streaming with NoMemory
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   481
// See NoMemoryTests.cpp
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   482
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   483
// 8.3.4. Invalid stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   484
TInt CRequestor_Internalize_Invalid_Stream(TAny* /*aPtr*/)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   485
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   486
    CRequestor* requestor = NULL;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   487
    RBufReadStream readStream;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   488
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   489
    // buffer
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   490
    CBufFlat* buffer = CBufFlat::NewL(512);        //Abritrary size chosen
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   491
    RBufWriteStream writeStream; // make sure it is empty
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   492
    writeStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   493
    writeStream.WriteUint16L(12345); // put dummy value there (different from KRequestorVersion)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   494
    writeStream.Close();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   495
    writeStream.Release();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   496
    readStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   497
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   498
    TInt err;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   499
    TRAP(err,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   500
                // internalize it
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   501
            requestor = CRequestor::New(DUMMY_REQUESTOR_TYPE_ACCEPTED1, DUMMY_REQUESTOR_FORMAT_ACCEPTED1, DUMMY_REQUESTOR_NAME_ACCEPTED1);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   502
                CleanupStack::PushL(requestor);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   503
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   504
            requestor->InternalizeL(readStream);   //This should panic
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   505
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   506
            CleanupStack::PopAndDestroy();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   507
    	);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   508
    User::LeaveIfError(err);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   509
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   510
    readStream.Release();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   511
    delete buffer;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   512
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   513
    return KErrGeneral;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   514
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   515
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   516
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   517
TInt CRequestor_Construct_Invalid_Stream(TAny* /*aPtr*/)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   518
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   519
    CRequestor* requestor = NULL;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   520
    RBufReadStream readStream;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   521
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   522
    // buffer
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   523
    CBufFlat* buffer = CBufFlat::NewL(512);        //Arbitrary size chosen
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   524
    RBufWriteStream writeStream; // make sure it is empty
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   525
    writeStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   526
    writeStream.WriteUint16L(12345); // put dummy value there (different from KRequestorVersion)
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   527
    writeStream.Close();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   528
    writeStream.Release();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   529
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   530
    // read-stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   531
    readStream.Open(*buffer);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   532
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   533
    TInt err;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   534
    TRAP(err,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   535
        // internalize it
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   536
        requestor = CRequestor::NewL(readStream);   //This should panic
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   537
    	);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   538
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   539
    delete requestor;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   540
    readStream.Release();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   541
    delete buffer;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   542
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   543
    return KErrGeneral;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   544
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   545
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   546
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   547
void CRequestorClassesStep::CRequestor_Streaming2L()
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   548
	{
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   549
    DECLARE_ERROR_LOGGING;
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   550
    StandardPrepareL();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   551
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   552
    // attempt to internalize from invalid stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   553
    DO_PANIC_TEST_L(
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   554
        CRequestor_Internalize_Invalid_Stream,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   555
        KPosClientFault,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   556
        EPositionInvalidClassType,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   557
        KDefaultTestTimeout);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   558
    // attempt to construct from invalid stream
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   559
    DO_PANIC_TEST_L(
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   560
        CRequestor_Construct_Invalid_Stream,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   561
        KPosClientFault,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   562
        EPositionInvalidClassType,
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   563
        KDefaultTestTimeout);
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   564
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   565
    StandardCleanup();
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   566
	}
a4835904093b Added new LbsApi smoke test
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   567