homescreensrv_plat/menu_content_service_api/tsrc/src/mcsapiutils.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #include <ecom/ecom.h>
       
    18 #include <Stiftestinterface.h>
       
    19 #include "mcsapitest.h"
       
    20 #include "waitactive.h"
       
    21 #include "mcsmenuopwatcher.h"
       
    22 
       
    23 #include <mcsmenu.h>
       
    24 #include <mcsmenuitem.h>
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CClientServiceTester::CClientServiceTester
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CClientServiceTester::NewL
       
    39 // Two-phased constructor.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CMCSAPITest::CMCSAPITest( 
       
    43     CTestModuleIf& aTestModuleIf ):
       
    44         CScriptBase( aTestModuleIf )
       
    45     {
       
    46     TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksMem );
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CClientServiceTester::ConstructL
       
    51 // Symbian 2nd phase constructor can leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CMCSAPITest::ConstructL()
       
    55     {   
       
    56     iTestUtils = CTestUtils::NewL();
       
    57     iSetupSuffix = 0;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CClientServiceTester::NewL
       
    62 // Two-phased constructor.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CMCSAPITest* CMCSAPITest::NewL( 
       
    66     CTestModuleIf& aTestModuleIf )
       
    67     {
       
    68     CMCSAPITest* self = new (ELeave) CMCSAPITest( aTestModuleIf );
       
    69     
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     CleanupStack::Pop();
       
    73 
       
    74     return self;
       
    75     }
       
    76     
       
    77 // Destructor
       
    78 CMCSAPITest::~CMCSAPITest()
       
    79     { 
       
    80     REComSession::FinalClose();
       
    81     delete iTestUtils;
       
    82     }
       
    83 
       
    84 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // LibEntryL is a polymorphic Dll entry point.
       
    88 // Returns: CScriptBase: New CScriptBase derived object
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C CScriptBase* LibEntryL( 
       
    92     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
    93     {
       
    94     
       
    95     return ( CScriptBase* ) CMCSAPITest::NewL( aTestModuleIf );
       
    96         
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // E32Dll is a DLL entry point function.
       
   101 // Returns: KErrNone
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 #ifndef EKA2 // Hide Dll entry point to EKA2
       
   105 GLDEF_C TInt E32Dll(
       
   106     TDllReason /*aReason*/) // Reason code
       
   107     {
       
   108     return(KErrNone);
       
   109     
       
   110     }
       
   111 #endif // EKA2
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // 
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 
       
   119 TInt CMCSAPITest::SetupMenuL(RMenu& aMenu)
       
   120 	{
       
   121 //	aMenu.OpenL(_L("sapitest_menudata"));
       
   122 //	return KErrNone;
       
   123 	_LIT(KFileName, "sapitest_menudata");
       
   124   	TBool deleteErr = iTestUtils->Delete(  );
       
   125   	TBool copyErr =  iTestUtils->Copy( KFileName , ++iSetupSuffix);
       
   126   	WaitL( 20000 );
       
   127   	TBuf<50> fileName(KFileName);
       
   128   	fileName.AppendNum(iSetupSuffix);
       
   129   	aMenu.OpenL(fileName);
       
   130   	return KErrNone;
       
   131 	
       
   132 	
       
   133 	}
       
   134 
       
   135 void CMCSAPITest::WaitL(TInt aMicroSec)
       
   136 	{
       
   137 	CWaitActive* wait = CWaitActive::NewL();
       
   138     wait->Wait(aMicroSec);
       
   139     delete wait;
       
   140 	}
       
   141 
       
   142 TInt CMCSAPITest::SaveL(CMenuItem *aItem)
       
   143 	{
       
   144     TInt result (KErrGeneral);
       
   145     CMCSMenuOpWatcher* watcher =  CMCSMenuOpWatcher::NewL(ETrue);
       
   146 	CleanupStack::PushL( watcher );
       
   147 	
       
   148     CMenuOperation* oper = aItem->SaveL(watcher->iStatus);
       
   149     watcher->Watch( *oper );
       
   150 	CActiveScheduler::Start();
       
   151 	WaitL( 1000000 );
       
   152 	result = watcher->GetStatus();
       
   153 	CleanupStack::PopAndDestroy( watcher );  
       
   154     return result;
       
   155 	}