sysstatemgmt/systemstateplugins/test/tintgsapolicy/src/tgsastatetranfromstartup.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:34:26 +0100
branchRCL_3
changeset 22 8cb079868133
parent 21 ccb4f6b3db21
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
//
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
//
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
// Contributors:
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
//
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
// Description:
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
//
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
/**
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
 @file
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
 @test
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
 @internalComponent - Internal Symbian test code
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
*/
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include "gsatestapps.h"
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <ssm/ssmstates.hrh>
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <ssm/ssmsubstates.hrh>
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <ssm/ssmstate.h>
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <ssm/ssmstatetransition.h>
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <ssm/ssmstatemanager.h>
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <ssm/ssmstateawaresession.h>
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <ssm/ssmdomaindefs.h>
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "tgsastatetran_base.h"
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
class CStateTranFromStartup : public CTGsaStateTransition
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
	{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
public:
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
	static CStateTranFromStartup* NewL();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
	~CStateTranFromStartup();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
private:
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
	void ConstructL();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
	CStateTranFromStartup();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
public:
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
	void DoTestStateTranFromStartupL();
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    46
	void DoTestStateTranFromStartuptoShutdownL();
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
	};
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    49
static TInt StopScheduler(TAny* aStateTranFromStartup)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    50
 	{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    51
 	CStateTranFromStartup* stateTran = reinterpret_cast<CStateTranFromStartup*>(aStateTranFromStartup);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    52
 	TRAPD(err,stateTran->CallStopSchedulerL());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    53
 	return err;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    54
 	}
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
CStateTranFromStartup* CStateTranFromStartup::NewL()
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
	{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
	CStateTranFromStartup* self = new(ELeave) CStateTranFromStartup();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
	self->ConstructL();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
	return self;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
	}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
void CStateTranFromStartup::ConstructL()
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
	{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
	CTGsaStateTransition::ConstructL(KGsaTestStateTranFromStartupResult);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
	}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
CStateTranFromStartup::~CStateTranFromStartup()
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
	{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
	}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
CStateTranFromStartup::CStateTranFromStartup()
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
	{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
	}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    76
// Tests the Fail state transitions from startup under different scenarios
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
void CStateTranFromStartup::DoTestStateTranFromStartupL()
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
	{
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    79
	CActiveScheduler* sched=new(ELeave) CActiveScheduler;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    80
	CleanupStack::PushL(sched);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    81
	CActiveScheduler::Install(sched);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    82
	
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    83
	// Notifier used to get the notification when system gets to fail state
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    84
	CSsmStateAwareSession* notif_for_failstate = CSsmStateAwareSession::NewLC(KSM2UiServicesDomain3);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    85
	notif_for_failstate->AddSubscriberL(*this);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
    86
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
	RSsmStateManager stateMan;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
	TInt err = stateMan.Connect();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
	CleanupClosePushL(stateMan);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
	if (err == KErrNone)
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
		RDebug::Print(_L("\nStateTran Test: RSsmStateManager sess Connect %d\n"), err);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
	else
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
		{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
		RDebug::Print(_L("\nStateTran Test: Unable to connect to RSsmStateManager sess\n"));	
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
		User::Leave(KTestAppFailure);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
		}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
	// Creates and open the result file for streaming
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
	err = iFileWriteStream.Replace(iFs, KGsaTestStateTranFromStartupResult, EFileWrite);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
	RDebug::Print(_L("\nStateTran Test: iFileWriteStream open with %d\n"), err);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
	CurrentSystemStateL();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
	//Scenario 1 - Request for state change from Startup to invalid state
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
	RDebug::Print(_L("\nStateTran Test: Scenario 1 \n"));
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
	TSsmState state(10, KSsmAnySubState);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
	TSsmStateTransition stateTrans_InvalidState(state, 1);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
	TRequestStatus status;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
	stateMan.RequestStateTransition(stateTrans_InvalidState, status);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
	RDebug::Print(_L("\nStateTran Test: Start RequestStateTransition from Startup to Invalid state with %d\n "), status.Int());
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
	
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
	User::WaitForRequest(status);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
	iFileWriteStream.WriteInt32L(status.Int());
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
	if (status.Int() == KErrNotSupported)
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
		{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
		CurrentSystemStateL();
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   117
		RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Normal to Invalid state completes with %d Expected -5\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   118
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   119
	else
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   120
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   121
		RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Normal to Invalid state Failed"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   122
		User::Leave(KTestAppFailure);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   123
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   124
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   125
	//Scenario 2 - Request for state change from Startup to fail state with invalid substate
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   126
	RDebug::Print(_L("\nStateTran Test: Scenario 2 \n"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   127
	const TInt KInvalidFailSubState = 20;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   128
	state.Set(ESsmFail, KInvalidFailSubState);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   129
	TSsmStateTransition stateTrans_InvalidSubState(state, 1);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   130
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   131
	stateMan.RequestStateTransition(stateTrans_InvalidSubState, status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   132
	RDebug::Print(_L("\nStateTran Test: Start RequestStateTransition from Startup to fail state with invalid substate %d\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   133
	
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   134
	User::WaitForRequest(status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   135
	iFileWriteStream.WriteInt32L(status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   136
	if (status.Int() == KErrNotSupported)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   137
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   138
		RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Startup to fail state with invalid substate completes with %d Expected -5\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   139
		CurrentSystemStateL();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   140
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   141
	else
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   142
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   143
		RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Startup to fail state with invalid substate Failed"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   144
		User::Leave(KTestAppFailure);		
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   145
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   146
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   147
	//Scenario 3 - Request for state change from Startup to shutdown invalid substate
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   148
	RDebug::Print(_L("\nStateTran Test: Scenario 3 \n"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   149
	TRequestStatus status1;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   150
	const TInt KInvalidShutdownSubState = 15;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   151
	TSsmState shutdownState_Invalid(ESsmShutdown, KInvalidShutdownSubState);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   152
	TSsmStateTransition stateTrans_ShutdownInvalid(shutdownState_Invalid, 1);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   153
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   154
	stateMan.RequestStateTransition(stateTrans_ShutdownInvalid, status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   155
	RDebug::Print(_L("\nStateTran Test: Start RequestStateTransition from Startup to Shutdown state with Invalid Substate %d\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   156
	
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   157
	User::WaitForRequest(status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   158
	iFileWriteStream.WriteInt32L(status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   159
	if (status.Int() == KErrNotSupported)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   160
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   161
		RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Startup to Shutdown state with invalid substate completes with %d Expected -5\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   162
		CurrentSystemStateL();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   163
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   164
	else
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   165
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   166
		RDebug::Print(_L("\nStateTran Test: RequestStateTransition from Startup to fail state with invalid substate Failed"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   167
		User::Leave(KTestAppFailure);		
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   168
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   169
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   170
	//Scenario 4 - Request for two state changes to fail state one after the other
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   171
	//The first request to the fail state will be completed with KErrCancel and the second request to transit to the fail state will be completed with KErrNone.
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   172
	RDebug::Print(_L("\nStateTran Test: Scenario 4 \n"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   173
	state.Set(ESsmFail, KSsmAnySubState);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   174
	TSsmStateTransition stateTrans_fail(state, 1);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   175
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   176
	stateMan.RequestStateTransition(stateTrans_fail, status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   177
	RDebug::Print(_L("\nStateTran Test: Start First RequestStateTransition from Startup to fail state %d\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   178
	
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   179
	stateMan.RequestStateTransition(stateTrans_fail, status1);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   180
	RDebug::Print(_L("\nStateTran Test: Start Second RequestStateTransition from Startup to fail state %d\n "), status1.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   181
	
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   182
	User::WaitForRequest(status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   183
	iFileWriteStream.WriteInt32L(status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   184
	if (status.Int() == KErrCancel)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   185
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   186
		RDebug::Print(_L("\nStateTran Test: First RequestStateTransition from Startup to fail state completes with %d Expected -3\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   187
		CurrentSystemStateL();
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
		}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
	else
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
		{
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   191
		RDebug::Print(_L("\nStateTran Test: First RequestStateTransition from Startup to fail state Failed"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   192
		User::Leave(KTestAppFailure);		
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   193
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   194
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   195
	User::WaitForRequest(status1);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   196
	iFileWriteStream.WriteInt32L(status1.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   197
	if (status1.Int() == KErrNone)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   198
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   199
		RDebug::Print(_L("\nStateTran Test: Second RequestStateTransition from Startup to fail state completes %d Expected 0\n "), status1.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   200
		CurrentSystemStateL();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   201
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   202
	else
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   203
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   204
		RDebug::Print(_L("\nStateTran Test: Second RequestStateTransition from Startup to fail state Failed"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   205
		User::Leave(KTestAppFailure);		
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   206
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   207
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   208
	// This async callback is used to stop the scheduler once the system goes into fail state.
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   209
	iAsyncCallbackForStopScheduler =  new(ELeave) CAsyncCallBack(CActive::EPriorityIdle);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   210
	TCallBack stopSchedulerCallback(StopScheduler, this);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   211
	iAsyncCallbackForStopScheduler->Set(stopSchedulerCallback);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   212
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   213
	iAsyncCallbackForStopScheduler->CallBack();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   214
	sched->Start();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   215
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   216
	CleanupStack::PopAndDestroy(3);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   217
	}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   218
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   219
// Tests the Shutdown state transitions from startup scenario
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   220
void CStateTranFromStartup::DoTestStateTranFromStartuptoShutdownL()
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   221
	{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   222
	RDebug::Printf("I am in CStateTranFromStartup::DoTestStateTranFromStartupShutdownL");
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   223
	CActiveScheduler* sched=new(ELeave) CActiveScheduler;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   224
	CleanupStack::PushL(sched);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   225
	CActiveScheduler::Install(sched);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   226
	
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   227
	// Notifier used to get the notification when system gets to Shutdown state
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   228
	CSsmStateAwareSession* notif_for_shutdownstate = CSsmStateAwareSession::NewLC(KSM2UiServicesDomain3);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   229
	notif_for_shutdownstate->AddSubscriberL(*this);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   230
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   231
	RSsmStateManager stateMan;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   232
	TRequestStatus status;
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   233
	TInt err = stateMan.Connect();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   234
	CleanupClosePushL(stateMan);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   235
	if (err == KErrNone)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   236
		RDebug::Print(_L("\nStateTran Shutdown Test: RSsmStateManager sess Connect %d\n"), err);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   237
	else
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   238
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   239
		RDebug::Print(_L("\nStateTran Shutdown Test: Unable to connect to RSsmStateManager sess\n"));	
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
		User::Leave(KTestAppFailure);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
		}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   243
		// Creates and open the result file for streaming
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   244
	err = iFileWriteStream.Replace(iFs, KGsaTestStateTranFromStartupResult, EFileWrite);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   245
	RDebug::Print(_L("\nStateTran Shutdown Test: iFileWriteStream open with %d\n"), err);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   246
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   247
	CurrentSystemStateL();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   248
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   249
	RDebug::Print(_L("\nStateTran Shutdown Test Scenario \n"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   250
	TSsmState shutdownState_Critical(ESsmShutdown, ESsmShutdownSubStateCritical);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   251
	TSsmStateTransition stateTrans_ShutdownCritical(shutdownState_Critical, 1);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   252
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   253
	stateMan.RequestStateTransition(stateTrans_ShutdownCritical, status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   254
	RDebug::Print(_L("\nStateTran Shutdown Test: Start RequestStateTransition from Startup to shutdown state %d\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   255
		
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   256
	User::WaitForRequest(status);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   257
	iFileWriteStream.WriteInt32L(status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   258
	RDebug::Printf("The value of status is %d",status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   259
	if (status.Int() == KErrNone)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   260
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   261
		RDebug::Print(_L("\nStateTran Shutdown Test: RequestStateTransition from Startup to Shutdown state completes with %d Expected 0\n "), status.Int());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   262
		CurrentSystemStateL();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   263
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   264
	else
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   265
		{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   266
		RDebug::Print(_L("\nStateTran Shutdown Test: RequestStateTransition from Startup to Shutdown state Failed"));
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   267
		User::Leave(KTestAppFailure);		
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   268
		}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   269
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   270
	// This async callback is used to stop the scheduler once the system goes into Shutdown state.
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   271
	iAsyncCallbackForStopScheduler =  new(ELeave) CAsyncCallBack(CActive::EPriorityIdle);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   272
	TCallBack stopSchedulerCallback(StopScheduler, this);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   273
	iAsyncCallbackForStopScheduler->Set(stopSchedulerCallback);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   274
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   275
	iAsyncCallbackForStopScheduler->CallBack();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   276
	sched->Start();
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   277
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   278
	CleanupStack::PopAndDestroy(3);
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   279
21
ccb4f6b3db21 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   280
	}
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
TInt E32Main()
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
	{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
	__UHEAP_MARK;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
	CTrapCleanup* cleanup=CTrapCleanup::New();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
	TInt r=KErrNoMemory;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
	TInt testCompletionReason = KErrNone;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
	TInt argc = User::CommandLineLength();
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
	if (cleanup)
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
		{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
		__UHEAP_MARK;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
		CStateTranFromStartup* stateTran = NULL;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
		TRAP(r, stateTran = CStateTranFromStartup::NewL());
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
		if (r == KErrNone)
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
			{
22
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   297
			if(argc>0)
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   298
				{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   299
				TRAP(testCompletionReason, stateTran->DoTestStateTranFromStartuptoShutdownL());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   300
				}
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   301
			else
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   302
				{
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   303
				TRAP(testCompletionReason, stateTran->DoTestStateTranFromStartupL());
8cb079868133 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 21
diff changeset
   304
				}
0
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
			// testCompletionReason is the reason with which the test case completes.
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
			TRAP(r, stateTran->CommitTestResultsL(testCompletionReason));
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
			
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
			// Rendezvous'ng the process as it started as WaitForSignal execution behaviour
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
			RProcess::Rendezvous(KErrNone);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
			delete stateTran;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
			}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
		delete cleanup;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
		__UHEAP_MARKEND;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
		if (r != KErrNone)
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
			{
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
			User::Panic(_L("tgsastatetranfromstartuppanic"), r);
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
			}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
		}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
	__UHEAP_MARKEND;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
	return r;
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
	}
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
4e1aa6a622a0 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326