Paul Vriens : setupapi/tests: pSetupGetField returns A or W string depending on OS.
Alexandre Julliard
julliard at winehq.org
Mon Jun 8 09:44:50 CDT 2009
Module: wine
Branch: master
Commit: de945384a4c1f593820e91811c1c04ff0263ca48
URL: http://source.winehq.org/git/wine.git/?a=commit;h=de945384a4c1f593820e91811c1c04ff0263ca48
Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date: Mon Jun 8 16:09:51 2009 +0200
setupapi/tests: pSetupGetField returns A or W string depending on OS.
---
dlls/setupapi/tests/parser.c | 83 ++++++++++++++++++++++++++++++++----------
1 files changed, 64 insertions(+), 19 deletions(-)
diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c
index a67a5cd..f12d02d 100644
--- a/dlls/setupapi/tests/parser.c
+++ b/dlls/setupapi/tests/parser.c
@@ -32,14 +32,18 @@
/* function pointers */
static HMODULE hSetupAPI;
-static LPCWSTR (WINAPI *pSetupGetField)(PINFCONTEXT,DWORD);
+static LPCSTR (WINAPI *pSetupGetFieldA)(PINFCONTEXT,DWORD);
+static LPCWSTR (WINAPI *pSetupGetFieldW)(PINFCONTEXT,DWORD);
static BOOL (WINAPI *pSetupEnumInfSectionsA)( HINF hinf, UINT index, PSTR buffer, DWORD size, UINT *need );
static void init_function_pointers(void)
{
hSetupAPI = GetModuleHandleA("setupapi.dll");
- pSetupGetField = (void *)GetProcAddress(hSetupAPI, "pSetupGetField");
+ /* Nice, pSetupGetField is either A or W depending on the Windows version! The actual test
+ * takes care of this difference */
+ pSetupGetFieldA = (void *)GetProcAddress(hSetupAPI, "pSetupGetField");
+ pSetupGetFieldW = (void *)GetProcAddress(hSetupAPI, "pSetupGetField");
pSetupEnumInfSectionsA = (void *)GetProcAddress(hSetupAPI, "SetupEnumInfSectionsA" );
}
@@ -497,7 +501,14 @@ static const char *contents = "[Version]\n"
"[Strings]\n"
"RTMQFE_NAME = \"RTMQFE\"\n";
-static const WCHAR getfield_res[][20] =
+static const CHAR getfield_resA[][20] =
+{
+ "RTMQFE",
+ "%RTMGFE_NAME%",
+ "SP1RTM",
+};
+
+static const WCHAR getfield_resW[][20] =
{
{'R','T','M','Q','F','E',0},
{'%','R','T','M','G','F','E','_','N','A','M','E','%',0},
@@ -509,10 +520,20 @@ static void test_pSetupGetField(void)
UINT err;
BOOL ret;
HINF hinf;
- LPCWSTR field;
+ LPCSTR fieldA;
+ LPCWSTR fieldW;
INFCONTEXT context;
int i;
int len;
+ BOOL unicode = TRUE;
+
+ SetLastError(0xdeadbeef);
+ lstrcmpW(NULL, NULL);
+ if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+ {
+ win_skip("Using A-functions instead of W\n");
+ unicode = FALSE;
+ }
hinf = test_file_contents( contents, &err );
ok( hinf != NULL, "Expected valid INF file\n" );
@@ -524,23 +545,47 @@ static void test_pSetupGetField(void)
for ( i = 0; i < 3; i++ )
{
- field = pSetupGetField( &context, i );
- ok( field != NULL, "Failed to get field %i\n", i );
- ok( !lstrcmpW( getfield_res[i], field ), "Wrong string returned\n" );
+ if (unicode)
+ {
+ fieldW = pSetupGetFieldW( &context, i );
+ ok( fieldW != NULL, "Failed to get field %i\n", i );
+ ok( !lstrcmpW( getfield_resW[i], fieldW ), "Wrong string returned\n" );
+ }
+ else
+ {
+ fieldA = pSetupGetFieldA( &context, i );
+ ok( fieldA != NULL, "Failed to get field %i\n", i );
+ ok( !lstrcmpA( getfield_resA[i], fieldA ), "Wrong string returned\n" );
+ }
}
- field = pSetupGetField( &context, 3 );
- ok( field != NULL, "Failed to get field 3\n" );
- len = lstrlenW( field );
- ok( len == 511 /* NT4, W2K, XP and W2K3 */ ||
- len == 4096 /* Vista */ ||
- len == 256 /* Win9x and WinME */,
- "Unexpected length, got %d\n", len );
-
- field = pSetupGetField( &context, 4 );
- ok( field == NULL, "Expected NULL, got %p\n", field );
- ok( GetLastError() == ERROR_INVALID_PARAMETER,
- "Expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
+ if (unicode)
+ {
+ fieldW = pSetupGetFieldW( &context, 3 );
+ ok( fieldW != NULL, "Failed to get field 3\n" );
+ len = lstrlenW( fieldW );
+ ok( len == 511 || /* NT4, W2K, XP and W2K3 */
+ len == 4096, /* Vista */
+ "Unexpected length, got %d\n", len );
+
+ fieldW = pSetupGetFieldW( &context, 4 );
+ ok( fieldW == NULL, "Expected NULL, got %p\n", fieldW );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
+ }
+ else
+ {
+ fieldA = pSetupGetFieldA( &context, 3 );
+ ok( fieldA != NULL, "Failed to get field 3\n" );
+ len = lstrlenA( fieldA );
+ ok( len == 511, /* Win9x, WinME */
+ "Unexpected length, got %d\n", len );
+
+ fieldA = pSetupGetFieldA( &context, 4 );
+ ok( fieldA == NULL, "Expected NULL, got %p\n", fieldA );
+ ok( GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
+ }
SetupCloseInfFile( hinf );
}
More information about the wine-cvs
mailing list