Fix the handling of MsiDoAction args (with test case).

This commit is contained in:
Mike McCormack 2005-09-13 10:37:46 +00:00 committed by Alexandre Julliard
parent 79ca56cd6a
commit e17ef695a2
2 changed files with 42 additions and 21 deletions

View File

@ -41,24 +41,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi);
UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction )
{
LPWSTR szwAction;
UINT rc;
UINT ret;
TRACE(" exteral attempt at action %s\n",szAction);
if (!szAction)
return ERROR_FUNCTION_FAILED;
if (hInstall == 0)
return ERROR_FUNCTION_FAILED;
TRACE("%s\n", debugstr_a(szAction));
szwAction = strdupAtoW(szAction);
if (!szwAction)
if (szAction && !szwAction)
return ERROR_FUNCTION_FAILED;
rc = MsiDoActionW(hInstall, szwAction);
HeapFree(GetProcessHeap(),0,szwAction);
return rc;
ret = MsiDoActionW( hInstall, szwAction );
HeapFree( GetProcessHeap(), 0, szwAction );
return ret;
}
/***********************************************************************
@ -67,16 +60,20 @@ UINT WINAPI MsiDoActionA( MSIHANDLE hInstall, LPCSTR szAction )
UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
{
MSIPACKAGE *package;
UINT ret = ERROR_INVALID_HANDLE;
UINT ret;
TRACE(" external attempt at action %s \n",debugstr_w(szAction));
TRACE("%s\n",debugstr_w(szAction));
if (!szAction)
return ERROR_INVALID_PARAMETER;
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
if (!package)
return ERROR_INVALID_HANDLE;
ret = ACTION_PerformUIAction( package, szAction );
msiobj_release( &package->hdr );
package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
if( package )
{
ret = ACTION_PerformUIAction(package,szAction);
msiobj_release( &package->hdr );
}
return ret;
}

View File

@ -272,9 +272,33 @@ static void test_getsourcepath( void )
MsiCloseHandle( hpkg );
}
void test_doaction( void )
{
MSIHANDLE hpkg;
UINT r;
r = MsiDoAction( -1, NULL );
ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
hpkg = package_from_db(create_package_db());
ok( hpkg, "failed to create package\n");
r = MsiDoAction(hpkg, NULL);
ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
r = MsiDoAction(0, "boo");
ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
r = MsiDoAction(hpkg, "boo");
ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
MsiCloseHandle( hpkg );
}
START_TEST(package)
{
test_createpackage();
test_getsourcepath_bad();
test_getsourcepath();
test_doaction();
}