gssettingsuis/Gs/tsrc/public/basic/MT_GSLauncher/MT_CGSLauncher.cpp
changeset 0 8c5d936e5675
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  CLASS HEADER
       
    20 #include "MT_CGSLauncher.h"
       
    21 
       
    22 //  EXTERNAL INCLUDES
       
    23 #include <EUnitMacros.h>
       
    24 #include <EUnitDecorators.h>
       
    25 #include <GSLauncher.h>
       
    26 #include <GSFWViewUIDs.h>
       
    27 
       
    28 //  INTERNAL INCLUDES
       
    29 
       
    30 
       
    31 // CONSTRUCTION
       
    32 MT_CGSLauncher* MT_CGSLauncher::NewL()
       
    33     {
       
    34     MT_CGSLauncher* self = MT_CGSLauncher::NewLC();
       
    35     CleanupStack::Pop();
       
    36 
       
    37     return self;
       
    38     }
       
    39 
       
    40 MT_CGSLauncher* MT_CGSLauncher::NewLC()
       
    41     {
       
    42     MT_CGSLauncher* self = new( ELeave ) MT_CGSLauncher();
       
    43     CleanupStack::PushL( self );
       
    44 
       
    45     self->ConstructL();
       
    46 
       
    47     return self;
       
    48     }
       
    49 
       
    50 // Destructor (virtual by CBase)
       
    51 MT_CGSLauncher::~MT_CGSLauncher()
       
    52     {
       
    53     }
       
    54 
       
    55 // Default constructor
       
    56 MT_CGSLauncher::MT_CGSLauncher()
       
    57     {
       
    58     }
       
    59 
       
    60 // Second phase construct
       
    61 void MT_CGSLauncher::ConstructL()
       
    62     {
       
    63     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    64     // It generates the test case table.
       
    65     CEUnitTestSuiteClass::ConstructL();
       
    66     }
       
    67 
       
    68 //  METHODS
       
    69 
       
    70 void MT_CGSLauncher::EmptySetupL(  )
       
    71     {
       
    72     }
       
    73     
       
    74 void MT_CGSLauncher::SetupL(  )
       
    75     {
       
    76     iCGSLauncher = CGSLauncher::NewL();;
       
    77     }
       
    78     
       
    79 
       
    80 void MT_CGSLauncher::Teardown(  )
       
    81     {
       
    82     if ( iCGSLauncher )
       
    83     	{
       
    84 	    delete iCGSLauncher; 
       
    85     	iCGSLauncher = NULL; 
       
    86     	}
       
    87     }
       
    88     
       
    89 
       
    90 void MT_CGSLauncher::T_CGSLauncher_NewLL(  )
       
    91     {
       
    92     CGSLauncher* Launcher = CGSLauncher::NewL();
       
    93     CleanupStack::PushL( Launcher );
       
    94     EUNIT_ASSERT_DESC( Launcher != NULL, "An instance of CGSLauncher is not created");
       
    95     CleanupStack::PopAndDestroy(); 
       
    96     }
       
    97     
       
    98 void MT_CGSLauncher::T_CGSLauncher_LaunchGSViewLL(  )
       
    99     {
       
   100     // iCGSLauncher->LaunchGSViewL( <add parameters here > );
       
   101      EUNIT_ASSERT_DESC( EFalse, "Generated assert, replace with real");
       
   102     }
       
   103     
       
   104 //----------------------------------------------------------------------------
       
   105 TBool MT_CGSLauncher::KillGSL()
       
   106 	{
       
   107 	RDebug::Print(_L("T_CGSLauncher::KillGSL()"));
       
   108 	TUid gsuid = TUid::Uid(0x100058EC);
       
   109 	TBool taskFoundAndEnded(EFalse);
       
   110 	RWsSession 		ws;
       
   111 	ws.Connect();
       
   112 	TApaTaskList 	l(ws);
       
   113 	TBool GSExist = l.FindApp(gsuid).Exists();
       
   114 	TInt i=5;
       
   115 	if ( GSExist )
       
   116 		{
       
   117 		while ( 1 )
       
   118 			{
       
   119 			RDebug::Print(_L("T_CGSLauncher::KillGSL()  trying to End GS"));
       
   120 			TApaTask 		gs = l.FindApp(gsuid);
       
   121 			if( !gs.Exists() || i-- < 0) 
       
   122 				{
       
   123 				taskFoundAndEnded = i>0 ? ETrue : EFalse;
       
   124 				break; 
       
   125 				}
       
   126 			gs.EndTask();
       
   127 			RDebug::Print(_L("T_CGSLauncher::KillGSL   Ended GS"));
       
   128 			User::After(TTimeIntervalMicroSeconds32 (100000));
       
   129 			}
       
   130 		}
       
   131 	ws.Close();
       
   132 	return taskFoundAndEnded;
       
   133 	}
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 //   Launches GS view, waits 8 sec and kills GS application (success criteria)
       
   137 void MT_CGSLauncher::LaunchGWView_gs_not_running(  )
       
   138     {
       
   139     	RDebug::Print(_L("T_CGSLauncher::T_CGSLauncher_LaunchGSViewL(  )"));
       
   140      iCGSLauncher->LaunchGSViewL( KGSTelPluginUid,TUid::Uid(0),_L8("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") ); // telephony
       
   141      User::After(TTimeIntervalMicroSeconds32 (8000000));
       
   142      TBool endedSuccesfully=KillGSL();
       
   143      EUNIT_ASSERT_DESC( endedSuccesfully, "test result");
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // Launches GS view, waits 8 sec and launches other GS view. 
       
   148 // Waits 2 sec and kills GS application (success criteria)
       
   149 void MT_CGSLauncher::LaunchGWView_gs_is_running()
       
   150 	{
       
   151  	RDebug::Print(_L("T_CGSLauncher::LaunchGWView_gs_is_running(  )"));
       
   152 
       
   153 	iCGSLauncher->LaunchGSViewL( KGSGenPluginUid,TUid::Uid(0),_L8("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") ); // security view
       
   154 	User::After(TTimeIntervalMicroSeconds32 (8000000));
       
   155 
       
   156 	iCGSLauncher->LaunchGSViewL( KGSConPluginUid,TUid::Uid(0),KNullDesC8  ); // connection view
       
   157 	User::After(TTimeIntervalMicroSeconds32 (3000000));
       
   158 
       
   159 	TBool endedSuccesfully=KillGSL();
       
   160 	EUNIT_ASSERT_DESC( endedSuccesfully, "test result");
       
   161 	}
       
   162 	
       
   163 //  TEST TABLE
       
   164 EUNIT_BEGIN_TEST_TABLE(
       
   165     MT_CGSLauncher,
       
   166     "Add test suite description here.",
       
   167     "MODULE" )
       
   168 
       
   169 EUNIT_TEST(
       
   170     "NewL and NewLC - test",
       
   171     "CGSLauncher",
       
   172     "NewL and NewLC",
       
   173     "FUNCTIONALITY",
       
   174     EmptySetupL, T_CGSLauncher_NewLL, Teardown)
       
   175     
       
   176 EUNIT_TEST(
       
   177     "Launch GS once",
       
   178     "CGSLauncher",
       
   179     "LaunchGSViewL",
       
   180     "FUNCTIONALITY",
       
   181     SetupL, LaunchGWView_gs_not_running, Teardown)
       
   182 
       
   183 EUNIT_TEST(
       
   184     "Launch GS twice",
       
   185     "CGSLauncher",
       
   186     "LaunchGSViewL",
       
   187     "FUNCTIONALITY",
       
   188     SetupL, LaunchGWView_gs_is_running, Teardown)
       
   189     
       
   190 
       
   191 EUNIT_END_TEST_TABLE
       
   192 
       
   193 //  END OF FILE