ReactOS 0.4.16-dev-257-g6aa11ac
dialog.c
Go to the documentation of this file.
1/*
2 * Unit tests for SetupPromptForDisk
3 *
4 * Copyright 2014 Michael Müller
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdarg.h>
22
23#include "windef.h"
24#include "winbase.h"
25#include "wingdi.h"
26#include "winuser.h"
27#include "winreg.h"
28#include "guiddef.h"
29#include "setupapi.h"
30
31#include "wine/test.h"
32
33static void test_SetupPromptForDiskA(void)
34{
35 char file[] = "kernel32.dll";
36 char path[MAX_PATH];
37 char buffer[MAX_PATH];
38 UINT ret;
40
42
43 memset(buffer, 0, sizeof(buffer));
44 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, sizeof(buffer) - 1, &length);
45 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
46 ok(length == strlen(path)+1, "Expect length %u, got %u\n", (DWORD)strlen(path) + 1, length);
47 ok(strcmp(path, buffer) == 0, "Expected path %s, got %s\n", path, buffer);
48
49 memset(buffer, 0, sizeof(buffer));
50 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, 0, 0, &length);
51 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %d\n", ret);
52 ok(length == strlen(path)+1, "Expect length %u, got %u\n", (DWORD)strlen(path) + 1, length);
53
54 memset(buffer, 0, sizeof(buffer));
55 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, 1, &length);
56 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
57
58 memset(buffer, 0, sizeof(buffer));
59 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, strlen(path), &length);
60 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
61
62 memset(buffer, 0, sizeof(buffer));
63 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, strlen(path)+1, &length);
64 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
65 ok(length == strlen(path)+1, "Expect length %u, got %u\n", (DWORD)strlen(path) + 1, length);
66 ok(strcmp(path, buffer) == 0, "Expected path %s, got %s\n", path, buffer);
67}
68
69static void test_SetupPromptForDiskW(void)
70{
71 WCHAR file[] = {'k','e','r','n','e','l','3','2','.','d','l','l','\0'};
72 WCHAR title[] = {'T','e','s','t','\0'};
73 WCHAR disk[] = {'T','e','s','t','d','i','s','k','\0'};
76 UINT ret;
78
80
81 memset(buffer, 0, sizeof(buffer));
83 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
84 ok(length == lstrlenW(path)+1, "Expect length %u, got %u\n", lstrlenW(path)+1, length);
85 ok(lstrcmpW(path, buffer) == 0, "Expected path %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
86
87 memset(buffer, 0, sizeof(buffer));
88 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, 0, 0, &length);
89 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %d\n", ret);
90 ok(length == lstrlenW(path)+1, "Expect length %u, got %u\n", lstrlenW(path)+1, length);
91
92 memset(buffer, 0, sizeof(buffer));
94 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
95
96 memset(buffer, 0, sizeof(buffer));
98 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
99
100 memset(buffer, 0, sizeof(buffer));
102 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
103 ok(length == lstrlenW(path)+1, "Expect length %u, got %u\n", lstrlenW(path)+1, length);
104 ok(lstrcmpW(path, buffer) == 0, "Expected path %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
105}
106
108{
111}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define MAX_PATH
Definition: compat.h:34
#define lstrlenW
Definition: compat.h:750
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2283
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
UINT WINAPI SetupPromptForDiskW(HWND hwndParent, PCWSTR DialogTitle, PCWSTR DiskName, PCWSTR PathToSource, PCWSTR FileSought, PCWSTR TagFile, DWORD DiskPromptStyle, PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
Definition: dialog.c:219
UINT WINAPI SetupPromptForDiskA(HWND hwndParent, PCSTR DialogTitle, PCSTR DiskName, PCSTR PathToSource, PCSTR FileSought, PCSTR TagFile, DWORD DiskPromptStyle, PSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
Definition: dialog.c:174
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define wine_dbgstr_w
Definition: kernel32.h:34
static void test_SetupPromptForDiskW(void)
Definition: dialog.c:69
static void test_SetupPromptForDiskA(void)
Definition: dialog.c:33
static HWND dialog
Definition: gui.c:33
unsigned int UINT
Definition: ndis.h:50
static char title[]
Definition: ps.c:92
#define memset(x, y, z)
Definition: compat.h:39
#define DPROMPT_BUFFERTOOSMALL
Definition: setupapi.h:272
#define DPROMPT_SUCCESS
Definition: setupapi.h:269
#define IDF_CHECKFIRST
Definition: setupapi.h:427
Definition: fci.c:127
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180