Author: akhaldi
Date: Sun Mar 19 17:23:26 2017
New Revision: 74205
URL:
http://svn.reactos.org/svn/reactos?rev=74205&view=rev
Log:
[VERSION_WINETEST] Sync with Wine Staging 2.2. CORE-12823
Modified:
trunk/rostests/winetests/version/info.c
Modified: trunk/rostests/winetests/version/info.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/version/info.c?…
==============================================================================
--- trunk/rostests/winetests/version/info.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/version/info.c [iso-8859-1] Sun Mar 19 17:23:26 2017
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2004 Stefan Leichter
+ * Copyright (C) 2017 Akihiro Sagawa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,7 +24,9 @@
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
+#include "winnls.h"
#include "winver.h"
+#include "verrsrc.h"
#include "wine/test.h"
#define MY_LAST_ERROR ((DWORD)-1)
@@ -750,6 +753,103 @@
HeapFree(GetProcessHeap(), 0, ver);
}
+static void test_GetFileVersionInfoEx(void)
+{
+ char *ver, *p;
+ BOOL ret;
+ UINT size, translation, i;
+ HMODULE mod;
+ BOOL (WINAPI *pGetFileVersionInfoExW)(DWORD, LPCWSTR, DWORD, DWORD, LPVOID);
+ DWORD (WINAPI *pGetFileVersionInfoSizeExW)(DWORD, LPCWSTR, LPDWORD);
+ const LANGID lang = GetUserDefaultUILanguage();
+ const LANGID english = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
+ const WORD unicode = 1200; /* = UNICODE */
+ const WCHAR kernel32W[] =
{'k','e','r','n','e','l','3','2','.','d','l','l',0};
+ const DWORD test_flags[] = {
+ 0, FILE_VER_GET_LOCALISED, FILE_VER_GET_NEUTRAL,
+ FILE_VER_GET_LOCALISED | FILE_VER_GET_NEUTRAL,
+ 0xdeadbeef, /* invalid value (ignored) */
+ };
+ char desc[MAX_PATH];
+
+ size = GetFileVersionInfoSizeW(kernel32W, NULL);
+ ok(size, "GetFileVersionInfoSize(kernel32) error %u\n", GetLastError());
+
+ ver = HeapAlloc(GetProcessHeap(), 0, size);
+ assert(ver);
+
+ ret = GetFileVersionInfoW(kernel32W, 0, size, ver);
+ ok(ret, "GetFileVersionInfo error %u\n", GetLastError());
+
+ ret = VerQueryValueA(ver, "\\VarFileInfo\\Translation", (void **)&p,
&size);
+ translation = *(UINT *)p;
+ ok(ret, "VerQueryValue error %u\n", GetLastError());
+ ok(size == 4, "VerQueryValue returned %u, expected 4\n", size);
+
+ /* test default version resource */
+ todo_wine_if(lang != english)
+ ok(LOWORD(translation) == lang, "got %u, expected lang is %u\n",
+ LOWORD(translation), lang);
+ todo_wine
+ ok(HIWORD(translation) == unicode, "got %u, expected codepage is %u\n",
+ HIWORD(translation), unicode);
+
+ HeapFree(GetProcessHeap(), 0, ver);
+
+ mod = GetModuleHandleA("version.dll");
+ assert(mod);
+
+ /* prefer W-version as A-version is not available on Windows 7 */
+ pGetFileVersionInfoExW = (void *)GetProcAddress(mod,
"GetFileVersionInfoExW");
+ pGetFileVersionInfoSizeExW = (void *)GetProcAddress(mod,
"GetFileVersionInfoSizeExW");
+ if (!pGetFileVersionInfoExW && !pGetFileVersionInfoSizeExW)
+ {
+ win_skip("GetFileVersionInfoEx family is not available\n");
+ return;
+ }
+
+ for (i = 0; i < sizeof(test_flags)/sizeof(test_flags[0]); i++)
+ {
+ size = pGetFileVersionInfoSizeExW(test_flags[i], kernel32W, NULL);
+ ok(size, "[%u] GetFileVersionInfoSizeEx(kernel32) error %u\n", i,
GetLastError());
+
+ ver = HeapAlloc(GetProcessHeap(), 0, size);
+ assert(ver);
+
+ ret = pGetFileVersionInfoExW(test_flags[i], kernel32W, 0, size, ver);
+ ok(ret, "[%u] GetFileVersionInfoEx error %u\n", i, GetLastError());
+
+ ret = VerQueryValueA(ver, "\\VarFileInfo\\Translation", (void
**)&p, &size);
+ ok(ret, "[%u] VerQueryValue error %u\n", i, GetLastError());
+ ok(size == 4, "[%u] VerQueryValue returned %u, expected 4\n", i,
size);
+ translation = *(UINT *)p;
+
+ /* test MUI version resource */
+ todo_wine_if((test_flags[i] & FILE_VER_GET_LOCALISED) && lang !=
english)
+ if (test_flags[i] & FILE_VER_GET_LOCALISED)
+ ok(LOWORD(translation) == lang, "[%u] got %u, expected lang is
%u\n",
+ i, LOWORD(translation), lang);
+ else
+ ok(LOWORD(translation) == english, "[%u] got %u, expected lang is
%u\n",
+ i, LOWORD(translation), english);
+ todo_wine
+ ok(HIWORD(translation) == unicode, "[%u] got %u, expected codepage is
%u\n",
+ i, HIWORD(translation), unicode);
+
+ /* test string info using translation info */
+ size = 0;
+ sprintf(desc, "\\StringFileInfo\\%04x%04x\\FileDescription",
+ LOWORD(translation), HIWORD(translation));
+ ret = VerQueryValueA(ver, desc, (void **)&p, &size);
+ ok(ret, "[%u] VerQueryValue error %u\n", i, GetLastError());
+ ok(size == strlen(p) + 1, "[%u] VerQueryValue returned %u\n", i,
size);
+
+ HeapFree(GetProcessHeap(), 0, ver);
+ }
+
+ return;
+}
+
START_TEST(info)
{
test_info_size();
@@ -758,4 +858,5 @@
test_VerQueryValueA();
test_VerQueryValue_InvalidLength();
test_extra_block();
-}
+ test_GetFileVersionInfoEx();
+}