installationservices/swi/test/swicaptests/swiscaptest.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2005-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 "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 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #include "swiscaptest.h"
       
    24 
       
    25 #include "installclientserver.h"
       
    26 
       
    27 #include <e32def.h>
       
    28 
       
    29 #include "launcher.h"
       
    30 #include "writestream.h"
       
    31 
       
    32 _LIT(KSwisCapTestName, "Install Server capability test");
       
    33 
       
    34 
       
    35 CSwisCapTest* CSwisCapTest::NewL()
       
    36 	{
       
    37 	CSwisCapTest* self=new(ELeave) CSwisCapTest();
       
    38 	CleanupStack::PushL(self);
       
    39 	self->ConstructL();
       
    40 	CleanupStack::Pop(self);
       
    41 	return self;
       
    42 	}
       
    43 
       
    44 CSwisCapTest::CSwisCapTest()
       
    45 	{
       
    46 	SetCapabilityRequired(ECapabilityTrustedUI);
       
    47 //	SetCapabilityRequired(ECapabilityProtServ);
       
    48 	}
       
    49 	
       
    50 void CSwisCapTest::ConstructL()
       
    51 	{
       
    52 	SetNameL(KSwisCapTestName);
       
    53 	}
       
    54 
       
    55 void CSwisCapTest::RunTestL()
       
    56 	{
       
    57 	Swi::RInstallServerSession session;
       
    58 	CleanupClosePushL(session);
       
    59 		
       
    60 	if (KErrNone != CheckFailL(session.Connect(), _L("Connect")))
       
    61 		{
       
    62 		// if we get here we didn't connect and expected not to, but cannot carry on with tests
       
    63 		CleanupStack::PopAndDestroy(&session);
       
    64 		return;
       
    65 		}
       
    66 
       
    67 	TInt err;
       
    68 	TRequestStatus s;
       
    69 	TRequestStatus& rs=s;
       
    70 	
       
    71 	Swi::CInstallPrefs* installPrefs=Swi::CInstallPrefs::NewLC();
       
    72 	
       
    73 	Swi::CWriteStream* writeStream=Swi::CWriteStream::NewL();
       
    74 	*writeStream << *installPrefs; // This can leave.
       
    75 
       
    76 	TBuf8<4> arg;
       
    77 	TPtr8 ptr(0, 0);
       
    78 	ptr.Set(writeStream->Ptr());
       
    79 	TIpcArgs argsInstall(&ptr);
       
    80 
       
    81 	TRAP(err, session.InstallL(argsInstall, rs));
       
    82 	User::WaitForRequest(rs);
       
    83 	err+=rs.Int();
       
    84 	CheckFailL(err, _L("InstallL"));
       
    85 
       
    86 	// fake package argument
       
    87 	TIpcArgs argsUninstall(&arg);
       
    88 	TRAP(err, session.Uninstall(argsUninstall, rs));
       
    89 	User::WaitForRequest(rs);
       
    90 	err+=rs.Int();
       
    91 	CheckFailL(err, _L("UninstallL"));
       
    92 	
       
    93 	TRAP(err, session.Cancel());
       
    94 	CheckFailL(err, _L("Cancel"));
       
    95 
       
    96 	// fake restore arguments
       
    97 	TIpcArgs restoreArgs(&arg, &arg);;
       
    98 	TRAP(err, session.Restore(restoreArgs));
       
    99 	CheckFailL(err, _L("Restore"));
       
   100 /*
       
   101 	RFs fs;
       
   102 	User::LeaveIfError(fs.Connect());
       
   103 	CleanupClosePushL(fs);
       
   104 	fs.ShareProtected();
       
   105 	
       
   106 	RFile file;
       
   107 	User::LeaveIfError(file.Open(fs, _L("z:\\system\\data\\swipolicy.ini"), EFileRead));
       
   108 	CleanupClosePushL(file);
       
   109 	
       
   110 	arg.SetLength(1);
       
   111 	arg[0] = 'b';
       
   112 	TIpcArgs restoreFileArgs;
       
   113 	User::LeaveIfError(file.TransferToServer(restoreFileArgs, 0, 1));
       
   114 	restoreFileArgs.Set(2, &arg);
       
   115 	TRAP(err, session.RestoreFile(restoreFileArgs));
       
   116 	CheckFailL(err, _L("RestoreFile"));
       
   117 
       
   118 	CleanupStack::PopAndDestroy(2, &fs); // file
       
   119 
       
   120 	TRAP(err, session.RestoreCommit());
       
   121 	CheckFailL(err, _L("RestoreCommit"));
       
   122 */
       
   123 	CleanupStack::PopAndDestroy(2, &session);
       
   124 	}
       
   125