ReactOS  0.4.14-dev-384-g5b37caa
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 
33 static void test_SetupPromptForDiskA(void)
34 {
35  char file[] = "kernel32.dll";
36  char path[MAX_PATH];
37  char buffer[MAX_PATH];
38  UINT ret;
39  DWORD length;
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 
69 static 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;
77  DWORD length;
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 }
#define IDF_CHECKFIRST
Definition: setupapi.h:422
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
GLuint buffer
Definition: glext.h:5915
START_TEST(dialog)
Definition: dialog.c:107
#define lstrlenW
Definition: compat.h:415
static void test_SetupPromptForDiskW(void)
Definition: dialog.c:69
#define DPROMPT_SUCCESS
Definition: setupapi.h:269
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
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
int ret
static void test_SetupPromptForDiskA(void)
Definition: dialog.c:33
#define DPROMPT_BUFFERTOOSMALL
Definition: setupapi.h:272
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
unsigned int UINT
Definition: ndis.h:50
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
static HWND dialog
Definition: gui.c:33
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define memset(x, y, z)
Definition: compat.h:39
static char title[]
Definition: ps.c:92
Definition: fci.c:126