common/tools/ats/smoketest/lbs/lbsclient/src/ctlbsclientpostp11.cpp
author Maciej Seroka <maciejs@symbian.org>
Tue, 10 Nov 2009 13:50:58 +0000
changeset 748 e13acd883fbe
child 872 17498133d9ad
permissions -rw-r--r--
Added new smoketest
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
748
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     4
// under the terms of the License "Symbian Foundation License v1.0"
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     7
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    10
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    11
// Contributors:
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    12
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    13
// Description:
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    14
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    15
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    16
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    17
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    18
//  INCLUDES
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    19
#include "ctlbsclientpostp11.h"
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    20
#include "ctlbsclientobserver.h"
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    21
#include <eikenv.h>
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    22
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    23
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    24
// ================= MEMBER FUNCTIONS =======================
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    25
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    26
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    27
// Constructor.
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    28
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    29
CT_LbsClientPosTp11::CT_LbsClientPosTp11(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    30
	{  
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    31
	_LIT(KTestName, "TP11 - EPos start and termination");
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    32
	SetTestStepName(KTestName); 
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    33
	}
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    34
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    35
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    36
// Destructor.
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    37
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    38
CT_LbsClientPosTp11::~CT_LbsClientPosTp11()
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    39
	{
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    40
	}
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    41
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    42
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    43
// CT_LbsClientPosTp11::CheckEPosActivityL
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    44
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    45
// (other items were commented in a header).
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    46
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    47
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    48
void CT_LbsClientPosTp11::CheckEPosActivityL(TBool aExpectEPosLiveness)
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    49
    {
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    50
    if (aExpectEPosLiveness && !CT_LbsClientObserver::EPosAliveL())
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    51
        {
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    52
        _LIT(KError, "Expected EPos server to be alive but it wasn't");
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    53
        LogErrorAndLeaveL(KError);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    54
        }
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    55
    if (!aExpectEPosLiveness && CT_LbsClientObserver::EPosAliveL())
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    56
        {
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    57
        _LIT(KError, "Expected EPos server to be dead but it wasn't");
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    58
        LogErrorAndLeaveL(KError);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    59
        }
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    60
    }
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    61
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    62
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    63
// CT_LbsClientPosTp11::ServerAliveL
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    64
// 
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    65
// (other items were commented in a header).
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    66
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    67
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    68
TBool CT_LbsClientPosTp11::ServerAliveL(const TDesC& aServerName)
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    69
    {
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    70
	TFindServer find(aServerName);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    71
    TFullName   name;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    72
    if (find.Next(name) == KErrNone) // server found
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    73
		{
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    74
		TBuf<100> buf;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    75
		_LIT(KFoundServer, "Found server: ");
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    76
		buf.Append(KFoundServer);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    77
		buf.Append(name);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    78
		INFO_PRINTF1(buf);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    79
		return ETrue;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    80
		}
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    81
	else 
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    82
		{
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    83
		return EFalse;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    84
		}
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    85
    }
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    86
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    87
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    88
// CT_LbsClientPosTp11::StartL
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    89
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    90
// (other items were commented in a header).
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    91
// ---------------------------------------------------------
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    92
//
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    93
void CT_LbsClientPosTp11::StartL()
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    94
    {
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    95
    const TInt KTimeEPosIsStillActive = 1000000;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    96
    const TInt KTimeEPosHasShutDown = 4000000;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    97
    
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    98
    User::After(2000000);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    99
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   100
    CT_LbsClientObserver::WaitForEPosShutdown();
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   101
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   102
    RPositionServer client1;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   103
    RPositionServer client2;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   104
    RPositionServer client3;
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   105
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   106
    CheckEPosActivityL(EFalse);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   107
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   108
    User::LeaveIfError(client1.Connect());
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   109
    CleanupClosePushL(client1);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   110
    CheckEPosActivityL(ETrue);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   111
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   112
    User::LeaveIfError(client2.Connect());
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   113
    CleanupClosePushL(client2);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   114
    CheckEPosActivityL(ETrue);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   115
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   116
    User::LeaveIfError(client3.Connect());
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   117
    CleanupClosePushL(client3);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   118
    CheckEPosActivityL(ETrue);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   119
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   120
    client1.Close();
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   121
    CheckEPosActivityL(ETrue);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   122
    client2.Close();
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   123
    CheckEPosActivityL(ETrue);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   124
    client3.Close();
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   125
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   126
    User::After(TTimeIntervalMicroSeconds32(KTimeEPosIsStillActive));
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   127
    CheckEPosActivityL(ETrue);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   128
    User::After(TTimeIntervalMicroSeconds32(
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   129
        KTimeEPosHasShutDown - KTimeEPosIsStillActive));
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   130
    CheckEPosActivityL(EFalse);
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   131
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   132
    CleanupStack::Pop(3); // client1-3 
e13acd883fbe Added new smoketest
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   133
    }