Module: wine Branch: master Commit: 2e20bd496095ae8b146b4965d4b73081a7ebc818 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2e20bd496095ae8b146b4965d4...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Jan 5 20:27:06 2009 +0100
setupapi/tests: Added some tests for SetupEnumInfSectionsA/W.
---
dlls/setupapi/tests/parser.c | 51 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c index 8869ca1..ddfd0f2 100644 --- a/dlls/setupapi/tests/parser.c +++ b/dlls/setupapi/tests/parser.c @@ -33,12 +33,14 @@ /* function pointers */ static HMODULE hSetupAPI; static LPCWSTR (WINAPI *pSetupGetField)(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"); + pSetupGetField = (void *)GetProcAddress(hSetupAPI, "pSetupGetField"); + pSetupEnumInfSectionsA = (void *)GetProcAddress(hSetupAPI, "SetupEnumInfSectionsA" ); }
static const char tmpfilename[] = ".\tmp.inf"; @@ -246,6 +248,52 @@ static void test_section_names(void) } }
+static void test_enum_sections(void) +{ + static const char *contents = STD_HEADER "[s1]\nfoo=bar\n[s2]\nbar=foo\n[s3]\n[strings]\na=b\n"; + + BOOL ret; + DWORD len; + HINF hinf; + UINT err, index; + char buffer[256]; + + if (!pSetupEnumInfSectionsA) + { + win_skip( "SetupEnumInfSectionsA not available\n" ); + return; + } + + hinf = test_file_contents( contents, &err ); + ok( hinf != NULL, "Expected valid INF file\n" ); + + for (index = 0; ; index++) + { + SetLastError( 0xdeadbeef ); + ret = pSetupEnumInfSectionsA( hinf, index, NULL, 0, &len ); + err = GetLastError(); + if (!ret && GetLastError() == ERROR_NO_MORE_ITEMS) break; + ok( ret, "SetupEnumInfSectionsA failed\n" ); + ok( len == 3 || len == 8, "wrong len %u\n", len ); + + SetLastError( 0xdeadbeef ); + ret = pSetupEnumInfSectionsA( hinf, index, NULL, sizeof(buffer), &len ); + err = GetLastError(); + ok( !ret, "SetupEnumInfSectionsA succeeded\n" ); + ok( err == ERROR_INVALID_USER_BUFFER, "wrong error %u\n", err ); + ok( len == 3 || len == 8, "wrong len %u\n", len ); + + SetLastError( 0xdeadbeef ); + ret = pSetupEnumInfSectionsA( hinf, index, buffer, sizeof(buffer), &len ); + ok( ret, "SetupEnumInfSectionsA failed err %u\n", GetLastError() ); + ok( len == 3 || len == 8, "wrong len %u\n", len ); + ok( !lstrcmpi( buffer, "version" ) || !lstrcmpi( buffer, "s1" ) || + !lstrcmpi( buffer, "s2" ) || !lstrcmpi( buffer, "s3" ) || !lstrcmpi( buffer, "strings" ), + "bad section '%s'\n", buffer ); + } + SetupCloseInfFile( hinf ); +} +
/* Test various key and value names */
@@ -672,6 +720,7 @@ START_TEST(parser) init_function_pointers(); test_invalid_files(); test_section_names(); + test_enum_sections(); test_key_names(); test_close_inf_file(); test_pSetupGetField();