classicui_plat/application_switching_api/tsrc/src/testdomapplicationswitchingblocks.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  test EIKSRVUI.H
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES]
       
    21 #include <e32svr.h>
       
    22 #include <stifparser.h>
       
    23 #include <stiftestinterface.h>
       
    24 #include <uikon/eiksrvui.h>
       
    25 #include <coemain.h>
       
    26 #include <documenthandler.h>
       
    27 #include <eikdialg.h>
       
    28 
       
    29 #include "testdomapplicationswitching.h"
       
    30 #include "testdomserappuiderive.h"
       
    31 
       
    32 const TInt KLength = 50;
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CTestDOMApplicationSwitching::RunMethodL
       
    38 // Run specified method. Contains also table of test mothods and their names.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 TInt CTestDOMApplicationSwitching::RunMethodL( CStifItemParser& aItem ) 
       
    42     {
       
    43 
       
    44     static TStifFunctionInfo const KFunctions[] =
       
    45         {
       
    46         ENTRY( "TestSAUBNewLC", CTestDOMApplicationSwitching::TestSAUBNewLC ),
       
    47         ENTRY( "TestSAUBDeconstructor", CTestDOMApplicationSwitching::TestSAUBDeconstructor ),
       
    48         ENTRY( "TestSAUBNotifyAlarmServerOfTaskChangeL", CTestDOMApplicationSwitching::TestSAUBNotifyAlarmServerOfTaskChangeL ),
       
    49         ENTRY( "TestSAUBEnableTaskListL", CTestDOMApplicationSwitching::TestSAUBEnableTaskListL ),
       
    50         ENTRY( "TestSAUBLaunchTaskListL", CTestDOMApplicationSwitching::TestSAUBLaunchTaskListL ),
       
    51         ENTRY( "TestSAUBCycleTasksL", CTestDOMApplicationSwitching::TestSAUBCycleTasksL ),
       
    52         ENTRY( "TestSAUBSetStatusPaneFlags", CTestDOMApplicationSwitching::TestSAUBSetStatusPaneFlags ),
       
    53         ENTRY( "TestSAUBSetStatusPaneLayoutL", CTestDOMApplicationSwitching::TestSAUBSetStatusPaneLayoutL ),
       
    54         ENTRY( "TestSAUBBlankScreen", CTestDOMApplicationSwitching::TestSAUBBlankScreen ),
       
    55         ENTRY( "TestSAUBUnblankScreen", CTestDOMApplicationSwitching::TestSAUBUnblankScreen ),
       
    56         ENTRY( "TestSAUBShutdownAppsL", CTestDOMApplicationSwitching::TestSAUBShutdownAppsL ),
       
    57         ENTRY( "TestSAUBHandleForegroundEventL", CTestDOMApplicationSwitching::TestSAUBHandleForegroundEventL ),
       
    58         ENTRY( "TestSAUBAlertGroupWin", CTestDOMApplicationSwitching::TestSAUBAlertGroupWin ),
       
    59         ENTRY( "TestSAUBBringAlertGroupWinForwards", CTestDOMApplicationSwitching::TestSAUBBringAlertGroupWinForwards ),
       
    60         ENTRY( "TestSAUBConstruct", CTestDOMApplicationSwitching::TestSAUBConstruct ),
       
    61         ENTRY( "TestSAUBInitialize", CTestDOMApplicationSwitching::TestSAUBInitialize ),
       
    62         ENTRY( "TestSAUBCEikServAppUiBase", CTestDOMApplicationSwitching::TestSAUBCEikServAppUiBase ),
       
    63         ENTRY( "TestSAUBHandleWsEventL", CTestDOMApplicationSwitching::TestSAUBHandleWsEventL ),
       
    64         ENTRY( "TestSAUBHandleThreadExit", CTestDOMApplicationSwitching::TestSAUBHandleThreadExit ),
       
    65         ENTRY( "TestSAUBHandleResourceChangeL", CTestDOMApplicationSwitching::TestSAUBHandleResourceChangeL ),
       
    66         ENTRY( "TestSAUSuppressAppSwitching", CTestDOMApplicationSwitching::TestSAUSuppressAppSwitching ),
       
    67         ENTRY( "TestSAUActivateDisplayIfNeeded", CTestDOMApplicationSwitching::TestSAUActivateDisplayIfNeeded ),
       
    68         ENTRY( "TestSAUCreateSessionL", CTestDOMApplicationSwitching::TestSAUCreateSessionL ),
       
    69         ENTRY( "TestSAUHideApplicationFromFswL", CTestDOMApplicationSwitching::TestSAUHideApplicationFromFswL ),
       
    70         ENTRY( "TestSAUStartNewServerApplication", CTestDOMApplicationSwitching::TestSAUStartNewServerApplication ),
       
    71         };
       
    72 
       
    73     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
       
    74 
       
    75     return RunInternalL( KFunctions, count, aItem );
       
    76 
       
    77     }
       
    78 
       
    79 // ============================ MEMBER FUNCTIONS ===============================
       
    80 // -----------------------------------------------------------------------------
       
    81 // CTestDOMApplicationSwitching::TestSAUBNewLC
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TInt CTestDOMApplicationSwitching::TestSAUBNewLC( CStifItemParser& /*aItem*/ )
       
    85     {
       
    86     CEikServAppUiBase* appuiBase = CEikServAppUiBase::NewLC();
       
    87     STIF_ASSERT_NULL( appuiBase );
       
    88     
       
    89     return KErrNone;
       
    90     
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CTestDOMApplicationSwitching::TestSAUBDeconstructor
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 TInt CTestDOMApplicationSwitching::TestSAUBDeconstructor( CStifItemParser& /*aItem*/ )
       
    98     {
       
    99 // when the mobile turn off,will it be invoked?
       
   100     return KErrNone;
       
   101     
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CTestDOMApplicationSwitching::TestSAUBNotifyAlarmServerOfTaskChangeL
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TInt CTestDOMApplicationSwitching::TestSAUBNotifyAlarmServerOfTaskChangeL( CStifItemParser& /*aItem*/ )
       
   109     {
       
   110     MEikServAppUiSessionHandler* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   111     appui->NotifyAlarmServerOfTaskChangeL();
       
   112     
       
   113     return KErrNone;
       
   114     
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CTestDOMApplicationSwitching::TestSAUBEnableTaskListL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TInt CTestDOMApplicationSwitching::TestSAUBEnableTaskListL( CStifItemParser& /*aItem*/ )
       
   122     {
       
   123     //the function will leave directly
       
   124     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   125     TRAPD( err, appui->CEikServAppUiBase::EnableTaskListL() );
       
   126     STIF_ASSERT_TRUE( err == KErrNotSupported );
       
   127     
       
   128     return KErrNone;
       
   129     
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CTestDOMApplicationSwitching::TestSAUBLaunchTaskListL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TInt CTestDOMApplicationSwitching::TestSAUBLaunchTaskListL( CStifItemParser& /*aItem*/ )
       
   137     {
       
   138     //the function will leave directly
       
   139     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   140     TRAPD( err, appui->CEikServAppUiBase::LaunchTaskListL() );
       
   141     STIF_ASSERT_TRUE( err == KErrNotSupported );
       
   142     
       
   143     return KErrNone;
       
   144     
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CTestDOMApplicationSwitching::TestSAUBCycleTasksL
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 TInt CTestDOMApplicationSwitching::TestSAUBCycleTasksL( CStifItemParser& /*aItem*/ )
       
   152     {
       
   153     MEikServAppUiSessionHandler* hand = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   154     hand->CycleTasksL( EBackwards );
       
   155     
       
   156     return KErrNone;
       
   157     
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CTestDOMApplicationSwitching::TestSAUBSetStatusPaneFlags
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TInt CTestDOMApplicationSwitching::TestSAUBSetStatusPaneFlags( CStifItemParser& /*aItem*/ )
       
   165     {
       
   166     //the function will leave directly
       
   167     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   168     TRAPD( err, appui->CEikServAppUiBase::SetStatusPaneFlags( 0 ) );
       
   169     STIF_ASSERT_TRUE( err == KErrNotSupported );
       
   170     
       
   171     return KErrNone;
       
   172     
       
   173     }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CTestDOMApplicationSwitching::TestSAUBSetStatusPaneLayoutL
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 TInt CTestDOMApplicationSwitching::TestSAUBSetStatusPaneLayoutL( CStifItemParser& /*aItem*/ )
       
   180     {
       
   181     //the function will leave directly
       
   182     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   183     TRAPD( err, appui->CEikServAppUiBase::SetStatusPaneLayoutL( 0 ) );
       
   184     STIF_ASSERT_TRUE( err == KErrNotSupported );
       
   185     
       
   186     return KErrNone;
       
   187     
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CTestDOMApplicationSwitching::TestSAUBBlankScreen
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 TInt CTestDOMApplicationSwitching::TestSAUBBlankScreen( CStifItemParser& /*aItem*/ )
       
   195     {
       
   196     //the function will leave directly
       
   197     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   198     TRAPD( err, appui->CEikServAppUiBase::BlankScreenL() );
       
   199     STIF_ASSERT_TRUE( err == KErrNotSupported );
       
   200     
       
   201     return KErrNone;
       
   202     
       
   203     }
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CTestDOMApplicationSwitching::TestSAUBUnblankScreen
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 TInt CTestDOMApplicationSwitching::TestSAUBUnblankScreen( CStifItemParser& /*aItem*/ )
       
   210     {
       
   211     //the function will leave directly
       
   212     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   213     TRAPD( err, appui->CEikServAppUiBase::UnblankScreen() );
       
   214     STIF_ASSERT_TRUE( err == KErrNotSupported );
       
   215     
       
   216     return KErrNone;
       
   217     
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CTestDOMApplicationSwitching::TestSAUBShutdownAppsL
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 TInt CTestDOMApplicationSwitching::TestSAUBShutdownAppsL( CStifItemParser& /*aItem*/ )
       
   225     {
       
   226     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   227     
       
   228     CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEnv->Process() );
       
   229     STIF_ASSERT_NOT_NULL( documentHandler );
       
   230     
       
   231     _LIT( KFile, "\\system\\apps\\testapplicationswitching.txt" );
       
   232     _LIT8( KContext, "Content Text" );
       
   233     TBuf8<KLength> context( KContext );
       
   234     
       
   235     RFs& fs = iEnv->FsSession();
       
   236     
       
   237     RFile file;
       
   238     CleanupClosePushL( file );
       
   239     STIF_ASSERT_NOT_NULL( &file );
       
   240     
       
   241     TDataType dataType;
       
   242     if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone )
       
   243         {
       
   244         file.Create( fs, KFile, EFileWrite | EFileShareAny );
       
   245         }
       
   246     
       
   247     file.Write( context );
       
   248     TInt flag = documentHandler->OpenFileL( file, dataType );
       
   249     STIF_ASSERT_TRUE( flag == KErrNone );
       
   250     
       
   251     CleanupStack::PopAndDestroy( &file );
       
   252     CleanupStack::PopAndDestroy( documentHandler );
       
   253     
       
   254     const TInt KTextUid = 0x1000599d;
       
   255     TUid textUid( TUid::Uid( KTextUid ) );
       
   256     RMessage2 message;
       
   257     const TInt timeoutInMicroseconds = 10000000;
       
   258     appui->CEikServAppUiBase::ShutdownAppsL( textUid, message, timeoutInMicroseconds );
       
   259     
       
   260     //the simulator will switch off( standby )
       
   261     return KErrNone;
       
   262     
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CTestDOMApplicationSwitching::TestSAUBHandleForegroundEventL
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 TInt CTestDOMApplicationSwitching::TestSAUBHandleForegroundEventL( CStifItemParser& /*aItem*/ )
       
   270     {
       
   271     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   272     appui->CEikServAppUiBase::HandleForegroundEventL( EFalse );
       
   273     
       
   274     return KErrNone;
       
   275     
       
   276     }
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 // CTestDOMApplicationSwitching::TestSAUBAlertGroupWin
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 TInt CTestDOMApplicationSwitching::TestSAUBAlertGroupWin( CStifItemParser& /*aItem*/ )
       
   283     {
       
   284     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   285     RWindowGroup windwoGroup = appui->CEikServAppUiBase::AlertGroupWin();
       
   286     
       
   287     return KErrNone;
       
   288     
       
   289     }
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CTestDOMApplicationSwitching::TestSAUBBringAlertGroupWinForwards
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 TInt CTestDOMApplicationSwitching::TestSAUBBringAlertGroupWinForwards( CStifItemParser& /*aItem*/ )
       
   296     {
       
   297     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   298     
       
   299     appui->CEikServAppUiBase::BringAlertGroupWinForwards( ETrue );
       
   300     
       
   301     return KErrNone;
       
   302     
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // CTestDOMApplicationSwitching::TestSAUBConstruct
       
   307 // -----------------------------------------------------------------------------
       
   308 //
       
   309 TInt CTestDOMApplicationSwitching::TestSAUBConstruct( CStifItemParser& /*aItem*/ )
       
   310     {
       
   311     //when the simulator launched the function will be invoked
       
   312     return KErrNone;
       
   313     
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CTestDOMApplicationSwitching::TestSAUBInitialize
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 TInt CTestDOMApplicationSwitching::TestSAUBInitialize( CStifItemParser& /*aItem*/ )
       
   321     {
       
   322     //when the simulator launched the function will be invoked
       
   323     return KErrNone;
       
   324     
       
   325     }
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CTestDOMApplicationSwitching::TestSAUBCEikServAppUiBase
       
   329 // -----------------------------------------------------------------------------
       
   330 //
       
   331 TInt CTestDOMApplicationSwitching::TestSAUBCEikServAppUiBase( CStifItemParser& /*aItem*/ )
       
   332     {
       
   333     //when the simulator launched the function will be invoked
       
   334     return KErrNone;
       
   335     
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CTestDOMApplicationSwitching::TestSAUBHandleWsEventL
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 TInt CTestDOMApplicationSwitching::TestSAUBHandleWsEventL( CStifItemParser& /*aItem*/ )
       
   343     {
       
   344     CTestDOMSerAppuiDerive* appui = static_cast<CTestDOMSerAppuiDerive*>( iEnv->AppUi() );
       
   345     CEikDialog* dialog = new (ELeave) CEikDialog;
       
   346     CleanupStack::PushL( dialog );
       
   347     TWsEvent wsEvent;
       
   348     appui->HandleWsEventL( wsEvent, dialog );
       
   349     
       
   350     CleanupStack::PopAndDestroy( dialog );
       
   351     return KErrNone;
       
   352     
       
   353     }
       
   354 
       
   355 // -----------------------------------------------------------------------------
       
   356 // CTestDOMApplicationSwitching::TestSAUBHandleThreadExit
       
   357 // -----------------------------------------------------------------------------
       
   358 //
       
   359 TInt CTestDOMApplicationSwitching::TestSAUBHandleThreadExit( CStifItemParser& /*aItem*/ )
       
   360     {
       
   361     //when the simulator launched the function will be invoked
       
   362     return KErrNone;
       
   363     
       
   364     }
       
   365 
       
   366 // -----------------------------------------------------------------------------
       
   367 // CTestDOMApplicationSwitching::TestSAUBHandleResourceChangeL
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 TInt CTestDOMApplicationSwitching::TestSAUBHandleResourceChangeL( CStifItemParser& /*aItem*/ )
       
   371     {
       
   372     CTestDOMSerAppuiDerive* appui = static_cast<CTestDOMSerAppuiDerive*>( iEnv->AppUi() );
       
   373     appui->HandleResourceChangeL( 0 );
       
   374     
       
   375     return KErrNone;
       
   376     
       
   377     }
       
   378 
       
   379 // -----------------------------------------------------------------------------
       
   380 // CTestDOMApplicationSwitching::TestSAUSuppressAppSwitching
       
   381 // -----------------------------------------------------------------------------
       
   382 //
       
   383 TInt CTestDOMApplicationSwitching::TestSAUSuppressAppSwitching( CStifItemParser& /*aItem*/ )
       
   384     {
       
   385     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   386     appui->SuppressAppSwitching( ETrue );
       
   387     
       
   388     return KErrNone;
       
   389     
       
   390     }
       
   391 
       
   392 // -----------------------------------------------------------------------------
       
   393 // CTestDOMApplicationSwitching::TestSAUActivateDisplayIfNeeded
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 TInt CTestDOMApplicationSwitching::TestSAUActivateDisplayIfNeeded( CStifItemParser& /*aItem*/ )
       
   397     {
       
   398     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   399     appui->ActivateDisplayIfNeeded();
       
   400     
       
   401     return KErrNone;
       
   402     
       
   403     }
       
   404 
       
   405 // -----------------------------------------------------------------------------
       
   406 // CTestDOMApplicationSwitching::TestSAUCreateSessionL
       
   407 // -----------------------------------------------------------------------------
       
   408 //
       
   409 TInt CTestDOMApplicationSwitching::TestSAUCreateSessionL( CStifItemParser& /*aItem*/ )
       
   410     {
       
   411     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   412     CEikServAppUiSession* session = appui->CreateSessionL();
       
   413     
       
   414     return KErrNone;
       
   415     
       
   416     }
       
   417 
       
   418 // -----------------------------------------------------------------------------
       
   419 // CTestDOMApplicationSwitching::TestSAUHideApplicationFromFswL
       
   420 // -----------------------------------------------------------------------------
       
   421 //
       
   422 TInt CTestDOMApplicationSwitching::TestSAUHideApplicationFromFswL( CStifItemParser& /*aItem*/ )
       
   423     {
       
   424     CEikServAppUi* appui = static_cast<CEikServAppUi*>( iEnv->AppUi() );
       
   425     appui->HideApplicationFromFswL( 0x2001CB80, EFalse );
       
   426     
       
   427     return KErrNone;
       
   428     
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // CTestDOMApplicationSwitching::TestSAUStartNewServerApplication
       
   433 // -----------------------------------------------------------------------------
       
   434 //
       
   435 TInt CTestDOMApplicationSwitching::TestSAUStartNewServerApplication( CStifItemParser& /*aItem*/ )
       
   436     {
       
   437     //when the simulator launched the function will be invoked
       
   438     return KErrNone;
       
   439     
       
   440     }
       
   441 
       
   442 
       
   443 
       
   444 //  [End of File]
       
   445