dd430c894416ef72ec9927a33a9f429675754fe4
[reactos.git] / rostests / winetests / setupapi / dialog.c
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 #ifdef __REACTOS__
36 char path[] = "C:\\ReactOS\\system32";
37 #else
38 #error "path must use GetSystemDirectoryA()! ROSTESTS_234"
39 char path[] = "C:\\windows\\system32";
40 #endif
41 char file[] = "kernel32.dll";
42 char buffer[MAX_PATH];
43 UINT ret;
44 DWORD length;
45
46 memset(buffer, 0, sizeof(buffer));
47 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, sizeof(buffer) - 1, &length);
48 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
49 ok(length == strlen(path)+1, "Expect length %u, got %u\n", (DWORD)strlen(path) + 1, length);
50 ok(strcmp(path, buffer) == 0, "Expected path %s, got %s\n", path, buffer);
51
52 memset(buffer, 0, sizeof(buffer));
53 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, 0, 0, &length);
54 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %d\n", ret);
55 ok(length == strlen(path)+1, "Expect length %u, got %u\n", (DWORD)strlen(path) + 1, length);
56
57 memset(buffer, 0, sizeof(buffer));
58 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, 1, &length);
59 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
60
61 memset(buffer, 0, sizeof(buffer));
62 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, strlen(path), &length);
63 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
64
65 memset(buffer, 0, sizeof(buffer));
66 ret = SetupPromptForDiskA(0, "Test", "Testdisk", path, file, 0, IDF_CHECKFIRST, buffer, strlen(path)+1, &length);
67 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
68 ok(length == strlen(path)+1, "Expect length %u, got %u\n", (DWORD)strlen(path) + 1, length);
69 ok(strcmp(path, buffer) == 0, "Expected path %s, got %s\n", path, buffer);
70 }
71
72 static void test_SetupPromptForDiskW(void)
73 {
74 #ifdef __REACTOS__
75 WCHAR path[] = {'C',':','\\','R','e','a','c','t','O','S','\\','s','y','s','t','e','m','3','2','\0'};
76 #else
77 #error "path must use GetSystemDirectoryW()! ROSTESTS_234"
78 WCHAR path[] = {'C',':','\\','w','i','n','d','o','w','s','\\','s','y','s','t','e','m','3','2','\0'};
79 #endif
80 WCHAR file[] = {'k','e','r','n','e','l','3','2','.','d','l','l','\0'};
81 WCHAR title[] = {'T','e','s','t','\0'};
82 WCHAR disk[] = {'T','e','s','t','d','i','s','k','\0'};
83 WCHAR buffer[MAX_PATH];
84 UINT ret;
85 DWORD length;
86
87 memset(buffer, 0, sizeof(buffer));
88 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, MAX_PATH-1, &length);
89 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
90 ok(length == lstrlenW(path)+1, "Expect length %u, got %u\n", lstrlenW(path)+1, length);
91 ok(lstrcmpW(path, buffer) == 0, "Expected path %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
92
93 memset(buffer, 0, sizeof(buffer));
94 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, 0, 0, &length);
95 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %d\n", ret);
96 ok(length == lstrlenW(path)+1, "Expect length %u, got %u\n", lstrlenW(path)+1, length);
97
98 memset(buffer, 0, sizeof(buffer));
99 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, 1, &length);
100 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
101
102 memset(buffer, 0, sizeof(buffer));
103 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, lstrlenW(path), &length);
104 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret);
105
106 memset(buffer, 0, sizeof(buffer));
107 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, lstrlenW(path)+1, &length);
108 ok(ret == DPROMPT_SUCCESS, "Expected DPROMPT_SUCCESS, got %u\n", ret);
109 ok(length == lstrlenW(path)+1, "Expect length %u, got %u\n", lstrlenW(path)+1, length);
110 ok(lstrcmpW(path, buffer) == 0, "Expected path %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
111 }
112
113 START_TEST(dialog)
114 {
115 test_SetupPromptForDiskA();
116 test_SetupPromptForDiskW();
117 }