From e7425a5b7cbc0bf45e972f42e14ce1fd8d8398fd Mon Sep 17 00:00:00 2001 From: Stefan Leichter Date: Tue, 31 May 2005 09:33:59 +0000 Subject: [PATCH] Test GetFileVersionInfoSizeA with executables. --- dlls/version/tests/.cvsignore | 1 + dlls/version/tests/Makefile.in | 2 ++ dlls/version/tests/info.c | 41 +++++++++++++++++++++++++++++++++++++++++ dlls/version/tests/version.rc | 28 ++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 dlls/version/tests/version.rc diff --git a/dlls/version/tests/.cvsignore b/dlls/version/tests/.cvsignore index 2e1bc40c69d..a9bda4e3602 100644 --- a/dlls/version/tests/.cvsignore +++ b/dlls/version/tests/.cvsignore @@ -1,3 +1,4 @@ Makefile info.ok testlist.c +version.res diff --git a/dlls/version/tests/Makefile.in b/dlls/version/tests/Makefile.in index e232227d896..01ec220d59f 100644 --- a/dlls/version/tests/Makefile.in +++ b/dlls/version/tests/Makefile.in @@ -8,6 +8,8 @@ IMPORTS = version CTESTS = \ info.c +RC_SRCS = version.rc + @MAKE_TEST_RULES@ ### Dependencies: diff --git a/dlls/version/tests/info.c b/dlls/version/tests/info.c index 9f83e3befd2..a48b7749677 100644 --- a/dlls/version/tests/info.c +++ b/dlls/version/tests/info.c @@ -45,6 +45,7 @@ static void test_info_size(void) { DWORD hdl, retval; + char mypath[MAX_PATH] = ""; SetLastError(MY_LAST_ERROR); retval = GetFileVersionInfoSizeA( NULL, NULL); @@ -111,6 +112,46 @@ static void test_info_size(void) (MY_LAST_ERROR == GetLastError()), "Last error wrong! ERROR_FILE_NOT_FOUND/ERROR_RESOURCE_DATA_NOT_FOUND " "(XP)/0x%08lx (NT4) expected, got 0x%08lx\n", MY_LAST_ERROR, GetLastError()); + + /* test a currently loaded executable */ + if(GetModuleFileNameA(NULL, mypath, MAX_PATH)) { + hdl = 0x55555555; + SetLastError(MY_LAST_ERROR); + retval = GetFileVersionInfoSizeA( mypath, &hdl); + ok( retval, + "GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08lx\n", + retval); + ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()), + "Last error wrong! NO_ERROR/0x%08lx (NT4) expected, got 0x%08lx\n", + MY_LAST_ERROR, GetLastError()); + ok( hdl == 0L, + "Handle wrong! 0L expected, got 0x%08lx\n", hdl); + } + else + trace("skipping GetModuleFileNameA(NULL,..) failed\n"); + + /* test a not loaded executable */ + if(GetSystemDirectoryA(mypath, MAX_PATH)) { + lstrcatA(mypath, "\\regsvr32.exe"); + + if(INVALID_FILE_ATTRIBUTES == GetFileAttributesA(mypath)) + trace("GetFileAttributesA(%s) failed\n", mypath); + else { + hdl = 0x55555555; + SetLastError(MY_LAST_ERROR); + retval = GetFileVersionInfoSizeA( mypath, &hdl); + ok( retval, + "GetFileVersionInfoSizeA result wrong! <> 0L expected, got 0x%08lx\n", + retval); + ok((NO_ERROR == GetLastError()) || (MY_LAST_ERROR == GetLastError()), + "Last error wrong! NO_ERROR/0x%08lx (NT4) expected, got 0x%08lx\n", + MY_LAST_ERROR, GetLastError()); + ok( hdl == 0L, + "Handle wrong! 0L expected, got 0x%08lx\n", hdl); + } + } + else + trace("skipping GetModuleFileNameA(NULL,..) failed\n"); } static void VersionDwordLong2String(DWORDLONG Version, LPSTR lpszVerString) diff --git a/dlls/version/tests/version.rc b/dlls/version/tests/version.rc new file mode 100644 index 00000000000..cbc44dde89f --- /dev/null +++ b/dlls/version/tests/version.rc @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2005 Mike McCormack + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WINE_FILEDESCRIPTION_STR "Wine version test" +#define WINE_FILENAME_STR "version_test.exe" +#define WINE_FILETYPE VFT_APP +#define WINE_FILEVERSION 1,0,0,0 +#define WINE_FILEVERSION_STR "1.0.0.0" +#define WINE_PRODUCTVERSION 1,0,0,0 +#define WINE_PRODUCTVERSION_STR "1.0.0.0" +#define WINE_PRODUCTNAME_STR "Wine version test" + +#include "wine/wine_common_ver.rc" -- 2.11.4.GIT