[WINESYNC] setupapi/tests: Add test for IDF_CHECKFIRST and SetupPromptForDiskA/W.

With modifications from Hermes Belusca-Maito.

Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 14d782d18ac61baac2fc479c2bb19fb45cc98883 by Michael Müller <michael@fds-team.de>
This commit is contained in:
winesync 2023-09-14 20:57:28 +02:00 committed by Hermès Bélusca-Maïto
parent d651c6290b
commit 708bccf4d1
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 111 additions and 1 deletions

View file

@ -13,6 +13,7 @@ add_importlibs(coinst msvcrt kernel32)
list(APPEND SOURCE
devinst.c
dialog.c
diskspace.c
install.c
misc.c

View file

@ -0,0 +1,107 @@
/*
* Unit tests for SetupPromptForDisk
*
* Copyright 2014 Michael Müller
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "guiddef.h"
#include "setupapi.h"
#include "wine/test.h"
static void test_SetupPromptForDiskA(void)
{
char path[MAX_PATH];
char buffer[MAX_PATH];
UINT ret;
DWORD length;
GetSystemDirectoryA(path, MAX_PATH);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, "kernel32.dll", NULL, IDF_CHECKFIRST, buffer, sizeof(buffer) - 1, &length);
ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
ok(length == strlen(path) + 1, "Expect length %u, got %u\n", lstrlenA(path) + 1, length);
ok(!strcmp(path, buffer), "Expected path %s, got %s\n", debugstr_a(path), debugstr_a(buffer));
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, "kernel32.dll", NULL, IDF_CHECKFIRST, NULL, 0, &length);
ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %d\n", ret);
ok(length == strlen(path) + 1, "Expect length %u, got %u\n", lstrlenA(path) + 1, length);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, "kernel32.dll", NULL, IDF_CHECKFIRST, buffer, 1, &length);
ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, "kernel32.dll", NULL, IDF_CHECKFIRST, buffer, strlen(path), &length);
ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, "kernel32.dll", NULL, IDF_CHECKFIRST, buffer, strlen(path) + 1, &length);
ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
ok(length == strlen(path) + 1, "Expect length %u, got %u\n", lstrlenA(path) + 1, length);
ok(!strcmp(path, buffer), "Expected path %s, got %s\n", debugstr_a(path), debugstr_a(buffer));
}
static void test_SetupPromptForDiskW(void)
{
WCHAR path[MAX_PATH];
WCHAR buffer[MAX_PATH];
UINT ret;
DWORD length;
GetSystemDirectoryW(path, MAX_PATH);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskW(0, L"Test", L"Testdisk", path, L"kernel32.dll", NULL, IDF_CHECKFIRST, buffer, ARRAY_SIZE(buffer) - 1, &length);
ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
ok(length == lstrlenW(path) + 1, "Expect length %u, got %u\n", lstrlenW(path) + 1, length);
ok(!lstrcmpW(path, buffer), "Expected path %s, got %s\n", debugstr_w(path), debugstr_w(buffer));
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskW(0, L"Test", L"Testdisk", path, L"kernel32.dll", NULL, IDF_CHECKFIRST, NULL, 0, &length);
ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %d\n", ret);
ok(length == lstrlenW(path) + 1, "Expect length %u, got %u\n", lstrlenW(path) + 1, length);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskW(0, L"Test", L"Testdisk", path, L"kernel32.dll", NULL, IDF_CHECKFIRST, buffer, 1, &length);
ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskW(0, L"Test", L"Testdisk", path, L"kernel32.dll", NULL, IDF_CHECKFIRST, buffer, lstrlenW(path), &length);
ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
memset(buffer, 0, sizeof(buffer));
ret = SetupPromptForDiskW(0, L"Test", L"Testdisk", path, L"kernel32.dll", NULL, IDF_CHECKFIRST, buffer, lstrlenW(path) + 1, &length);
ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
ok(length == lstrlenW(path) + 1, "Expect length %u, got %u\n", lstrlenW(path) + 1, length);
ok(!lstrcmpW(path, buffer), "Expected path %s, got %s\n", debugstr_w(path), debugstr_w(buffer));
}
START_TEST(dialog)
{
test_SetupPromptForDiskA();
test_SetupPromptForDiskW();
}

View file

@ -4,6 +4,7 @@
#include <wine/test.h>
extern void func_devinst(void);
extern void func_dialog(void);
extern void func_diskspace(void);
extern void func_install(void);
extern void func_misc(void);
@ -15,6 +16,7 @@ extern void func_stringtable(void);
const struct test winetest_testlist[] =
{
{ "devinst", func_devinst },
{ "dialog", func_dialog },
{ "diskspace", func_diskspace },
{ "install", func_install },
{ "misc", func_misc },

View file

@ -10,4 +10,4 @@ files:
dlls/setupapi/setupcab.c: dll/win32/setupapi/setupcab.c
dlls/setupapi/stringtable.c: dll/win32/setupapi/stringtable_wine.c
tags:
wine: 0422c6c4d0224c4e619771a0d22f4a5a1575f3f3
wine: 14d782d18ac61baac2fc479c2bb19fb45cc98883