common/tools/ats/smoketest/appinstall/src/AppInstallSmokeTestModuleBlocks.cpp
changeset 739 552776214487
child 872 17498133d9ad
equal deleted inserted replaced
738:53abda826a9f 739:552776214487
       
     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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This file contains testclass implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // [INCLUDE FILES] - do not remove
       
    19 #include <e32svr.h>
       
    20 #include <StifParser.h>
       
    21 #include <Stiftestinterface.h>
       
    22 #include <ImplementationInformation.h>
       
    23 #include <SwInstApi.h>
       
    24 #include "AppInstallSmokeTestModule.h"
       
    25 
       
    26 // EXTERNAL DATA STRUCTURES
       
    27 //extern  ?external_data;
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES  
       
    30 //extern ?external_function( ?arg_type,?arg_type );
       
    31 
       
    32 // CONSTANTS
       
    33 //const ?type ?constant_var = ?constant;
       
    34 
       
    35 // MACROS
       
    36 //#define ?macro ?macro_def
       
    37 
       
    38 // LOCAL CONSTANTS AND MACROS
       
    39 //const ?type ?constant_var = ?constant;
       
    40 //#define ?macro_name ?macro_def
       
    41 
       
    42 // MODULE DATA STRUCTURES
       
    43 //enum ?declaration
       
    44 //typedef ?declaration
       
    45 
       
    46 // LOCAL FUNCTION PROTOTYPES
       
    47 //?type ?function_name( ?arg_type, ?arg_type );
       
    48 
       
    49 // FORWARD DECLARATIONS
       
    50 //class ?FORWARD_CLASSNAME;
       
    51 using namespace SwiUI;
       
    52 
       
    53 // ============================= LOCAL FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ?function_name ?description.
       
    57 // ?description
       
    58 // Returns: ?value_1: ?description
       
    59 //          ?value_n: ?description_line1
       
    60 //                    ?description_line2
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 /*
       
    64 ?type ?function_name(
       
    65     ?arg_type arg,  // ?description
       
    66     ?arg_type arg)  // ?description
       
    67     {
       
    68 
       
    69     ?code  // ?comment
       
    70 
       
    71     // ?comment
       
    72     ?code
       
    73     }
       
    74 */
       
    75 
       
    76 // ============================ MEMBER FUNCTIONS ===============================
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CAppInstallSmokeTestModule::Delete
       
    80 // Delete here all resources allocated and opened from test methods. 
       
    81 // Called from destructor. 
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CAppInstallSmokeTestModule::Delete() 
       
    85     {
       
    86 
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CAppInstallSmokeTestModule::RunMethodL
       
    91 // Run specified method. Contains also table of test mothods and their names.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 TInt CAppInstallSmokeTestModule::RunMethodL( 
       
    95     CStifItemParser& aItem ) 
       
    96     {
       
    97 
       
    98     static TStifFunctionInfo const KFunctions[] =
       
    99         {  
       
   100         // Copy this line for every implemented function.
       
   101         // First string is the function name used in TestScripter script file.
       
   102         // Second is the actual implementation member function.
       
   103         ENTRY( "InstallApp", CAppInstallSmokeTestModule::InstallAppL ),
       
   104         ENTRY( "UninstallApp", CAppInstallSmokeTestModule::UninstallAppL ),
       
   105         //ADD NEW ENTRY HERE
       
   106         // [test cases entries] - Do not remove
       
   107 
       
   108         };
       
   109 
       
   110     const TInt count = sizeof( KFunctions ) / 
       
   111                         sizeof( TStifFunctionInfo );
       
   112 
       
   113     return RunInternalL( KFunctions, count, aItem );
       
   114 
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CAppInstallSmokeTestModule::ExampleL
       
   119 // Example test method function.
       
   120 // (other items were commented in a header).
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 TInt CAppInstallSmokeTestModule::InstallAppL( CStifItemParser& aItem )
       
   124     {
       
   125     // Print to UI
       
   126     _LIT( KAppInstallSmokeTestModule, "AppInstallSmokeTestModule" );
       
   127     _LIT( KInstallApp, "In InstallApp" );
       
   128     TestModuleIf().Printf( 0, KAppInstallSmokeTestModule, KInstallApp );
       
   129     // Print to log file
       
   130     iLog->Log( KInstallApp );
       
   131 
       
   132     TInt i = 0;
       
   133     TPtrC sisPath;
       
   134     if ( aItem.GetNextString ( sisPath ) == KErrNone )
       
   135         {
       
   136         RSWInstSilentLauncher installer;
       
   137         CleanupClosePushL(installer);
       
   138         User::LeaveIfError(installer.Connect());
       
   139         
       
   140         TInstallOptionsPckg options;
       
   141         options().iUpgrade = SwiUI::EPolicyAllowed;
       
   142         options().iPackageInfo = SwiUI::EPolicyAllowed;
       
   143         options().iOverwrite = SwiUI::EPolicyAllowed;
       
   144         options().iKillApp = SwiUI::EPolicyAllowed;
       
   145 
       
   146         
       
   147         User::LeaveIfError(installer.SilentInstall(sisPath, options));
       
   148         
       
   149         CleanupStack::PopAndDestroy(&installer);
       
   150         }
       
   151 
       
   152     return KErrNone;
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CAppInstallSmokeTestModule::ExampleL
       
   157 // Example test method function.
       
   158 // (other items were commented in a header).
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 TInt CAppInstallSmokeTestModule::UninstallAppL( CStifItemParser& aItem )
       
   162     {
       
   163 
       
   164     // Print to UI
       
   165     _LIT( KAppInstallSmokeTestModule, "AppInstallSmokeTestModule" );
       
   166     _LIT( KUninstallApp, "In UninstallApp" );
       
   167     TestModuleIf().Printf( 0, KAppInstallSmokeTestModule, KUninstallApp );
       
   168     // Print to log file
       
   169     iLog->Log( KUninstallApp );
       
   170 
       
   171     TUint pkgUid;
       
   172     if ( aItem.GetNextInt(pkgUid, EHex) == KErrNone )
       
   173         {
       
   174         RSWInstSilentLauncher uninstaller;
       
   175         CleanupClosePushL(uninstaller);
       
   176         User::LeaveIfError(uninstaller.Connect());
       
   177         
       
   178         TInstallOptionsPckg options;
       
   179         options().iUpgrade = SwiUI::EPolicyAllowed;
       
   180         options().iPackageInfo = SwiUI::EPolicyAllowed;
       
   181         options().iOverwrite = SwiUI::EPolicyAllowed;
       
   182         options().iKillApp = SwiUI::EPolicyAllowed;
       
   183         
       
   184         User::LeaveIfError(uninstaller.SilentUninstall( TUid::Uid(pkgUid), options, SwiUI::KSisxMimeType ));
       
   185         
       
   186         CleanupStack::PopAndDestroy(&uninstaller);
       
   187         }
       
   188 
       
   189     return KErrNone;
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // CAppInstallSmokeTestModule::?member_function
       
   194 // ?implementation_description
       
   195 // (other items were commented in a header).
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 /*
       
   199 TInt CAppInstallSmokeTestModule::?member_function(
       
   200    CItemParser& aItem )
       
   201    {
       
   202 
       
   203    ?code
       
   204 
       
   205    }
       
   206 */
       
   207 
       
   208 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   209 // None
       
   210 
       
   211 //  [End of File] - Do not remove