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 41 GetSystemDirectoryA(path, MAX_PATH); 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'}; 74 WCHAR path[MAX_PATH]; 75 WCHAR buffer[MAX_PATH]; 76 UINT ret; 77 DWORD length; 78 79 GetSystemDirectoryW(path, MAX_PATH); 80 81 memset(buffer, 0, sizeof(buffer)); 82 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, MAX_PATH-1, &length); 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)); 93 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, 1, &length); 94 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret); 95 96 memset(buffer, 0, sizeof(buffer)); 97 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, lstrlenW(path), &length); 98 ok(ret == DPROMPT_BUFFERTOOSMALL, "Expected DPROMPT_BUFFERTOOSMALL, got %u\n", ret); 99 100 memset(buffer, 0, sizeof(buffer)); 101 ret = SetupPromptForDiskW(0, title, disk, path, file, 0, IDF_CHECKFIRST, buffer, lstrlenW(path)+1, &length); 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 107 START_TEST(dialog) 108 { 109 test_SetupPromptForDiskA(); 110 test_SetupPromptForDiskW(); 111 } 112