messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionGetNumberOfChildren.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // GetNumberOfChildren
       
    17 // [Action Parameters]
       
    18 // CMsvSession  Session       <input>: Reference to the session.
       
    19 // TMsvId       ParentId      <input>: Value of the parent id.
       
    20 // TInt         childrenCount <output-initiation>: Value of the Number of children.
       
    21 // [Action Description]
       
    22 // Returns the number of children of a given parent.
       
    23 // [APIs Used]
       
    24 // none.
       
    25 // __ACTION_INFO_END__
       
    26 // 
       
    27 //
       
    28 
       
    29 /**
       
    30  @file
       
    31 */
       
    32 
       
    33 #include <msvapi.h>
       
    34 
       
    35 #include "CmtfTestActionGetNumberOfChildren.h"
       
    36 #include "CMtfTestCase.h"
       
    37 #include "CMtfTestActionParameters.h"
       
    38 
       
    39 
       
    40 CMtfTestAction* CMtfTestActionGetNumberOfChildren::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    41 	{
       
    42 	CMtfTestActionGetNumberOfChildren* self = new (ELeave) CMtfTestActionGetNumberOfChildren(aTestCase);
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL(aActionParameters);
       
    45 	CleanupStack::Pop();
       
    46 	return self;
       
    47 	}
       
    48 	
       
    49 
       
    50 CMtfTestActionGetNumberOfChildren::CMtfTestActionGetNumberOfChildren(CMtfTestCase& aTestCase)
       
    51 	: CMtfSynchronousTestAction(aTestCase)
       
    52 	{
       
    53 	}
       
    54 
       
    55 
       
    56 CMtfTestActionGetNumberOfChildren::~CMtfTestActionGetNumberOfChildren()
       
    57 	{
       
    58 	}
       
    59 
       
    60 
       
    61 void CMtfTestActionGetNumberOfChildren::ExecuteActionL()
       
    62 	{
       
    63     TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionGetNumberOfChildren);
       
    64 	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
       
    65 	TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
       
    66 	
       
    67 	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId,TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
       
    68 	CleanupStack::PushL(entry);
       
    69 	entry->SetEntryL(paramParentId);
       
    70 
       
    71 	TMsvSelectionOrdering order;
       
    72 	order.SetShowInvisibleEntries(ETrue);
       
    73 	entry->SetSortTypeL(order);
       
    74  		
       
    75 	CMsvEntrySelection* selection = entry->ChildrenL();
       
    76 	CleanupStack::PushL(selection);
       
    77 
       
    78 	TInt childrenCount = selection->Count();
       
    79 		
       
    80 	StoreParameterL<TInt>(TestCase(),childrenCount,ActionParameters().Parameter(2));
       
    81 	CleanupStack::PopAndDestroy(selection);
       
    82 	CleanupStack::PopAndDestroy(entry);
       
    83 
       
    84 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionGetNumberOfChildren);
       
    85 	TestCase().ActionCompletedL(*this);
       
    86 	}