From ee3e0586550b073e68a31418cb39868679953588 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Thu, 6 Jul 2006 19:01:11 +0900 Subject: [PATCH] msi: Add a test for MsiGetComponentPath and make it pass. --- dlls/msi/msi.c | 6 ++++-- dlls/msi/tests/msi.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index d3c217927a..a628155fca 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -977,7 +977,7 @@ UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage ) INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent, awstring* lpPathBuf, DWORD* pcchBuf) { - WCHAR squished_pc[GUID_SIZE]; + WCHAR squished_pc[GUID_SIZE], squished_comp[GUID_SIZE]; UINT rc; INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN; HKEY hkey = 0; @@ -992,7 +992,9 @@ INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent, if( lpPathBuf && !pcchBuf ) return INSTALLSTATE_INVALIDARG; - squash_guid( szProduct, squished_pc ); + if (!squash_guid( szProduct, squished_pc ) || + !squash_guid( szComponent, squished_comp )) + return INSTALLSTATE_INVALIDARG; rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE); if( rc != ERROR_SUCCESS ) diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c index b79f45d32e..4334675b2d 100644 --- a/dlls/msi/tests/msi.c +++ b/dlls/msi/tests/msi.c @@ -31,6 +31,8 @@ typedef UINT (WINAPI *fnMsiOpenPackageExA)(LPCSTR, DWORD, MSIHANDLE*); fnMsiOpenPackageExA pMsiOpenPackageExA; typedef UINT (WINAPI *fnMsiOpenPackageExW)(LPCWSTR, DWORD, MSIHANDLE*); fnMsiOpenPackageExW pMsiOpenPackageExW; +typedef INSTALLSTATE (WINAPI *fnMsiGetComponentPathA)(LPCSTR, LPCSTR, LPSTR, DWORD*); +fnMsiGetComponentPathA pMsiGetComponentPathA; static void test_usefeature(void) { @@ -83,6 +85,46 @@ static void test_null(void) ok( r == ERROR_INVALID_PARAMETER,"wrong error\n"); } +static void test_getcomponentpath(void) +{ + INSTALLSTATE r; + char buffer[0x100]; + DWORD sz; + + if(!pMsiGetComponentPathA) + return; + + r = pMsiGetComponentPathA( NULL, NULL, NULL, NULL ); + ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n"); + + r = pMsiGetComponentPathA( "bogus", "bogus", NULL, NULL ); + ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n"); + + r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL, NULL ); + ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n"); + + sz = sizeof buffer; + buffer[0]=0; + r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer, &sz ); + ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n"); + + r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}", + "{00000000-0000-0000-0000-000000000000}", buffer, &sz ); + ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n"); + + r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}", + "{00000000-0000-0000-0000-00000000}", buffer, &sz ); + ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n"); + + r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}", + "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer, &sz ); + ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n"); + + r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}", + "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer, &sz ); + ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n"); +} + START_TEST(msi) { HMODULE hmod = GetModuleHandle("msi.dll"); @@ -92,7 +134,10 @@ START_TEST(msi) GetProcAddress(hmod, "MsiOpenPackageExA"); pMsiOpenPackageExW = (fnMsiOpenPackageExW) GetProcAddress(hmod, "MsiOpenPackageExW"); + pMsiGetComponentPathA = (fnMsiGetComponentPathA) + GetProcAddress(hmod, "MsiGetComponentPathA" ); test_usefeature(); test_null(); + test_getcomponentpath(); }