localisation/apparchitecture/tef/t_abstractnonnativeappsstep.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2005-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent - Internal Symbian test code  
       
    21 */
       
    22 
       
    23 #include "t_abstractnonnativeappsstep.h"
       
    24 
       
    25 #include <apgicnfl.h>
       
    26 
       
    27 CT_AbstractNonNativeAppsTestStep::CT_AbstractNonNativeAppsTestStep()
       
    28 	{
       
    29 	}
       
    30 
       
    31 CT_AbstractNonNativeAppsTestStep::~CT_AbstractNonNativeAppsTestStep()
       
    32 	{
       
    33 	}
       
    34 
       
    35 void CT_AbstractNonNativeAppsTestStep::doAbstractNonNativeAppsTestStepPreambleL()
       
    36 	{
       
    37 	TInt error = iSession.Connect();
       
    38 	TEST(error==KErrNone);
       
    39 	error = iUtils.Connect();
       
    40 	TEST(error==KErrNone);
       
    41 	}
       
    42 
       
    43 void CT_AbstractNonNativeAppsTestStep::CleanupAndReset(RTestableApaLsSession& aSession, const TTestAppDetails& aApp)
       
    44 	{
       
    45 	// make sure we're starting from a clean sheet
       
    46 	CompleteDeregisterL(aSession, aApp);
       
    47 	aSession.DeregisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType));
       
    48 	aSession.RegisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType), KLitNativeExecutable);
       
    49 	}
       
    50 
       
    51 void CT_AbstractNonNativeAppsTestStep::CallRegisterL(RTestableApaLsSession& aSession, const TTestAppDetails& aApp)
       
    52 	{
       
    53 	CApaRegistrationResourceFileWriter* const registrationResourceFileWriter =
       
    54 		CApaRegistrationResourceFileWriter::NewL(TUid::Uid(aApp.iAppUid), aApp.iLogicalExecutable, TApaAppCapability::ENonNative);
       
    55 	CleanupStack::PushL(registrationResourceFileWriter);
       
    56 	aSession.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *registrationResourceFileWriter, NULL, NULL);
       
    57 	CleanupStack::PopAndDestroy();
       
    58 	}
       
    59 
       
    60 void CT_AbstractNonNativeAppsTestStep::CompleteRegisterL(RTestableApaLsSession& aSession, const TTestAppDetails& aApp)
       
    61 	{
       
    62 	aSession.PrepareNonNativeApplicationsUpdatesL();
       
    63 	CallRegisterL(aSession, aApp);
       
    64 	aSession.CommitNonNativeApplicationsUpdatesL();
       
    65 	}
       
    66 
       
    67 void CT_AbstractNonNativeAppsTestStep::CallDeregisterL(RTestableApaLsSession& aSession, const TTestAppDetails& aApp)
       
    68 	{
       
    69 	aSession.DeregisterNonNativeApplicationL(TUid::Uid(aApp.iAppUid));
       
    70 	}
       
    71 
       
    72 void CT_AbstractNonNativeAppsTestStep::CompleteDeregisterL(RTestableApaLsSession& aSession, const TTestAppDetails& aApp)
       
    73 	{
       
    74 	aSession.PrepareNonNativeApplicationsUpdatesL();
       
    75 	CallDeregisterL(aSession, aApp);
       
    76 	aSession.CommitNonNativeApplicationsUpdatesL();
       
    77 	}
       
    78 
       
    79 TBool CT_AbstractNonNativeAppsTestStep::FilePresent(const TDesC& aFile)
       
    80 	{
       
    81 	TBool present = EFalse;
       
    82 	TInt err = iUtils.IsFilePresent(aFile, present);
       
    83 	TEST(err == KErrNone);
       
    84 	return present;
       
    85 	}
       
    86 
       
    87 TBool CT_AbstractNonNativeAppsTestStep::FileAbsent(const TDesC& aFile)
       
    88 	{
       
    89 	TBool present = ETrue;
       
    90 	TInt err = iUtils.IsFilePresent(aFile, present);
       
    91 	TEST(err == KErrNone);
       
    92 	return !present;
       
    93 	}
       
    94 
       
    95 TBool CT_AbstractNonNativeAppsTestStep::AppPresent(RTestableApaLsSession& aSession, const TTestAppDetails& aApp)
       
    96 	{
       
    97 	TApaAppInfo info;
       
    98 	TInt err = aSession.GetAppInfo(info,TUid::Uid(aApp.iAppUid));
       
    99 	TEST(err == KErrNone);
       
   100 	TUid typeUid;
       
   101 	err = aSession.GetAppType(typeUid, TUid::Uid(aApp.iAppUid));
       
   102 	TEST(err == KErrNone);
       
   103 	
       
   104 	TBool test1 = (info.iUid.iUid == aApp.iAppUid) && (typeUid == TUid::Uid(KApplicationType));
       
   105 	TBool test2 = FilePresent(aApp.iRegistrationFile);
       
   106 	TBool test3 = FileAbsent(KLitUpdatedAppsList);
       
   107 	return test1 && test2 && test3;
       
   108 	}
       
   109 
       
   110 TBool CT_AbstractNonNativeAppsTestStep::AppAbsent(RTestableApaLsSession& aSession, const TTestAppDetails& aApp)
       
   111 	{
       
   112 	TApaAppInfo info;
       
   113 	TInt err = aSession.GetAppInfo(info,TUid::Uid(aApp.iAppUid));
       
   114 	TBool test1 = (err == KErrNotFound);
       
   115 	TBool test2 = FileAbsent(aApp.iRegistrationFile);
       
   116 	TBool test3 = FileAbsent(KLitUpdatedAppsList);
       
   117 	return test1 && test2 && test3;
       
   118 	}