[COMDLG32]

- Sync to Wine 1.3.37

svn path=/trunk/; revision=55612
This commit is contained in:
Rafal Harabien 2012-02-15 17:35:24 +00:00
parent b9f8ea2889
commit d4cc49dd21
8 changed files with 2223 additions and 48 deletions

View file

@ -3,18 +3,16 @@ add_definitions(-D__ROS_LONG64__)
list(APPEND SOURCE list(APPEND SOURCE
filedlg.c filedlg.c
finddlg.c
fontdlg.c fontdlg.c
itemdlg.c
printdlg.c printdlg.c
testlist.c testlist.c
rsrc.rc) rsrc.rc)
add_executable(comdlg32_winetest ${SOURCE}) add_executable(comdlg32_winetest ${SOURCE})
target_link_libraries(comdlg32_winetest wine) target_link_libraries(comdlg32_winetest wine uuid)
if(MSVC)
target_link_libraries(comdlg32_winetest uuid)
endif()
set_module_type(comdlg32_winetest win32cui) set_module_type(comdlg32_winetest win32cui)
add_importlibs(comdlg32_winetest comdlg32 winspool user32 gdi32 msvcrt kernel32 ntdll) add_importlibs(comdlg32_winetest comdlg32 winspool user32 gdi32 msvcrt kernel32 ntdll ole32 shell32)
add_cd_file(TARGET comdlg32_winetest DESTINATION reactos/bin FOR all) add_cd_file(TARGET comdlg32_winetest DESTINATION reactos/bin FOR all)

View file

@ -5,7 +5,9 @@
<include base="comdlg32_winetest">.</include> <include base="comdlg32_winetest">.</include>
<define name="__ROS_LONG64__" /> <define name="__ROS_LONG64__" />
<file>filedlg.c</file> <file>filedlg.c</file>
<file>finddlg.c</file>
<file>fontdlg.c</file> <file>fontdlg.c</file>
<file>itemdlg.c</file>
<file>printdlg.c</file> <file>printdlg.c</file>
<file>testlist.c</file> <file>testlist.c</file>
<file>rsrc.rc</file> <file>rsrc.rc</file>
@ -15,5 +17,8 @@
<library>user32</library> <library>user32</library>
<library>gdi32</library> <library>gdi32</library>
<library>ntdll</library> <library>ntdll</library>
<library>ole32</library>
<library>uuid</library>
<library>shell32</library>
</module> </module>
</group> </group>

View file

@ -22,7 +22,6 @@
#include <windows.h> #include <windows.h>
#include <wine/test.h> #include <wine/test.h>
#include "initguid.h"
#include "shlguid.h" #include "shlguid.h"
#define COBJMACROS #define COBJMACROS
#include "shobjidl.h" #include "shobjidl.h"
@ -142,9 +141,7 @@ static void test_DialogCancel(void)
else else
{ {
ok(0 == result, "expected 0, got %d\n", result); ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError() || ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", CommDlgExtendedError());
broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
"expected 0, got %d\n", CommDlgExtendedError());
} }
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -154,9 +151,7 @@ static void test_DialogCancel(void)
else else
{ {
ok(0 == result, "expected 0, got %d\n", result); ok(0 == result, "expected 0, got %d\n", result);
ok(0 == CommDlgExtendedError() || ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", CommDlgExtendedError());
broken(CDERR_INITIALIZATION == CommDlgExtendedError()), /* win9x */
"expected 0, got %d\n", CommDlgExtendedError());
} }
} }
@ -219,7 +214,7 @@ static UINT_PTR CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wPa
hr = IShellView2_DestroyViewWindow(shell_view2); hr = IShellView2_DestroyViewWindow(shell_view2);
ok(SUCCEEDED(hr), "DestroyViewWindow returned %#x\n", hr); ok(SUCCEEDED(hr), "DestroyViewWindow returned %#x\n", hr);
/* XP and W2K3 need this. On Win9x and W2K the call to DestroyWindow() fails and has /* XP and W2K3 need this. On W2K the call to DestroyWindow() fails and has
* no side effects. NT4 doesn't get here. (FIXME: Vista doesn't get here yet). * no side effects. NT4 doesn't get here. (FIXME: Vista doesn't get here yet).
*/ */
DestroyWindow(view_params.hwndView); DestroyWindow(view_params.hwndView);
@ -231,8 +226,7 @@ static UINT_PTR CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wPa
hr = IShellView2_GetCurrentInfo(shell_view2, &folder_settings); hr = IShellView2_GetCurrentInfo(shell_view2, &folder_settings);
ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr); ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr);
ok(folder_settings.ViewMode == FVM_DETAILS || ok(folder_settings.ViewMode == FVM_DETAILS || broken(folder_settings.ViewMode == FVM_LIST), /* nt4 */
broken(folder_settings.ViewMode == FVM_LIST), /* Win9x */
"view mode is %d, expected FVM_DETAILS\n", "view mode is %d, expected FVM_DETAILS\n",
folder_settings.ViewMode); folder_settings.ViewMode);
@ -304,7 +298,7 @@ static void test_create_view_template(void)
} }
/* test cases for resizing of the file dialog */ /* test cases for resizing of the file dialog */
struct { static const struct {
DWORD flags; DWORD flags;
int resize_folderchange;/* change in CDN_FOLDERCHANGE handler */ int resize_folderchange;/* change in CDN_FOLDERCHANGE handler */
int resize_timer1; /* change in first WM_TIMER handler */ int resize_timer1; /* change in first WM_TIMER handler */
@ -433,8 +427,7 @@ static LONG_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, L
/* sized horizontal and moved vertical */ /* sized horizontal and moved vertical */
case cmb1: case cmb1:
case edt1: case edt1:
ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 10, 0) || ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 10, 0),
broken(TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0)),/*win98*/
"control id %03x should have sized horizontally and moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n", "control id %03x should have sized horizontally and moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top, ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom, ctrlrcs[i].right, ctrlrcs[i].bottom,
@ -451,8 +444,7 @@ static LONG_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, L
/* moved horizontal and vertical */ /* moved horizontal and vertical */
case IDCANCEL: case IDCANCEL:
case pshHelp: case pshHelp:
ok( TESTRECTS( ctrlrcs[i], rc, 10, 10, 0, 0) || ok( TESTRECTS( ctrlrcs[i], rc, 10, 10, 0, 0),
broken(TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0)),/*win98*/
"control id %03x should have moved horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n", "control id %03x should have moved horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top, ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
ctrlrcs[i].right, ctrlrcs[i].bottom, ctrlrcs[i].right, ctrlrcs[i].bottom,
@ -562,14 +554,16 @@ static void test_resize(void)
/* test cases for control message IDOK */ /* test cases for control message IDOK */
/* Show case for bug #19079 */ /* Show case for bug #19079 */
static struct { typedef struct {
int retval; /* return code of the message handler */ int retval; /* return code of the message handler */
BOOL setmsgresult; /* set the result in the DWLP_MSGRESULT */ BOOL setmsgresult; /* set the result in the DWLP_MSGRESULT */
BOOL usemsgokstr; /* use the FILEOKSTRING message instead of WM_NOTIFY:CDN_FILEOK */ BOOL usemsgokstr; /* use the FILEOKSTRING message instead of WM_NOTIFY:CDN_FILEOK */
BOOL do_subclass; /* subclass the dialog hook procedure */ BOOL do_subclass; /* subclass the dialog hook procedure */
BOOL expclose; /* is the dialog expected to close ? */ BOOL expclose; /* is the dialog expected to close ? */
BOOL actclose; /* has the dialog actually closed ? */ BOOL actclose; /* has the dialog actually closed ? */
} ok_testcases[] = { } ok_wndproc_testcase;
static ok_wndproc_testcase ok_testcases[] = {
{ 0, FALSE, FALSE, FALSE, TRUE}, { 0, FALSE, FALSE, FALSE, TRUE},
{ 0, TRUE, FALSE, FALSE, TRUE}, { 0, TRUE, FALSE, FALSE, TRUE},
{ 0, FALSE, FALSE, TRUE, TRUE}, { 0, FALSE, FALSE, TRUE, TRUE},
@ -590,12 +584,12 @@ static struct {
static LONG_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) static LONG_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
HWND parent = GetParent( dlg); HWND parent = GetParent( dlg);
static int index; static ok_wndproc_testcase *testcase = NULL;
static UINT msgFILEOKSTRING; static UINT msgFILEOKSTRING;
if (msg == WM_INITDIALOG) if (msg == WM_INITDIALOG)
{ {
index = ((OPENFILENAME*)lParam)->lCustData; testcase = (ok_wndproc_testcase*)((OPENFILENAME*)lParam)->lCustData;
ok_testcases[index].actclose = TRUE; testcase->actclose = TRUE;
msgFILEOKSTRING = RegisterWindowMessageA( FILEOKSTRING); msgFILEOKSTRING = RegisterWindowMessageA( FILEOKSTRING);
} }
if( msg == WM_NOTIFY) { if( msg == WM_NOTIFY) {
@ -604,28 +598,28 @@ static LONG_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM
PostMessage( parent, WM_COMMAND, IDOK, 0); PostMessage( parent, WM_COMMAND, IDOK, 0);
return FALSE; return FALSE;
} else if(((LPNMHDR)lParam)->code == CDN_FILEOK) { } else if(((LPNMHDR)lParam)->code == CDN_FILEOK) {
if( ok_testcases[index].usemsgokstr) if( testcase->usemsgokstr)
return FALSE; return FALSE;
if( ok_testcases[index].setmsgresult) if( testcase->setmsgresult)
SetWindowLongPtrA( dlg, DWLP_MSGRESULT, ok_testcases[index].retval); SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
return ok_testcases[index].retval; return testcase->retval;
} }
} }
if( msg == msgFILEOKSTRING) { if( msg == msgFILEOKSTRING) {
if( !ok_testcases[index].usemsgokstr) if( !testcase->usemsgokstr)
return FALSE; return FALSE;
if( ok_testcases[index].setmsgresult) if( testcase->setmsgresult)
SetWindowLongPtrA( dlg, DWLP_MSGRESULT, ok_testcases[index].retval); SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
return ok_testcases[index].retval; return testcase->retval;
} }
if( msg == WM_TIMER) { if( msg == WM_TIMER) {
/* the dialog did not close automatically */ /* the dialog did not close automatically */
ok_testcases[index].actclose = FALSE; testcase->actclose = FALSE;
KillTimer( dlg, 0); KillTimer( dlg, 0);
PostMessage( parent, WM_COMMAND, IDCANCEL, 0); PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
return FALSE; return FALSE;
} }
if( ok_testcases[index].do_subclass) if( testcase && testcase->do_subclass)
return DefWindowProc( dlg, msg, wParam, lParam); return DefWindowProc( dlg, msg, wParam, lParam);
return FALSE; return FALSE;
} }
@ -645,8 +639,10 @@ static void test_ok(void)
char curdir[MAX_PATH]; char curdir[MAX_PATH];
int i; int i;
DWORD ret; DWORD ret;
BOOL cdret;
ok(GetCurrentDirectoryA(sizeof(curdir), curdir) != 0, "Failed to get current dir err %d\n", GetLastError()); cdret = GetCurrentDirectoryA(sizeof(curdir), curdir);
ok(cdret, "Failed to get current dir err %d\n", GetLastError());
if (!GetTempFileNameA(".", "txt", 0, tmpfilename)) { if (!GetTempFileNameA(".", "txt", 0, tmpfilename)) {
skip("Failed to create a temporary file name\n"); skip("Failed to create a temporary file name\n");
return; return;
@ -658,7 +654,7 @@ static void test_ok(void)
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE ; ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE ;
for( i = 0; ok_testcases[i].retval != -1; i++) { for( i = 0; ok_testcases[i].retval != -1; i++) {
strcpy( filename, tmpfilename); strcpy( filename, tmpfilename);
ofn.lCustData = i; ofn.lCustData = (LPARAM)(ok_testcases + i);
ofn.lpfnHook = ok_testcases[i].do_subclass ofn.lpfnHook = ok_testcases[i].do_subclass
? (LPOFNHOOKPROC) ok_template_hook ? (LPOFNHOOKPROC) ok_template_hook
: (LPOFNHOOKPROC) test_ok_wndproc; : (LPOFNHOOKPROC) test_ok_wndproc;
@ -669,7 +665,8 @@ static void test_ok(void)
ok(ret == ok_testcases[i].expclose, "testid %d: GetOpenFileName returned %#x\n", i, ret); ok(ret == ok_testcases[i].expclose, "testid %d: GetOpenFileName returned %#x\n", i, ret);
ret = CommDlgExtendedError(); ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret); ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
ok(SetCurrentDirectoryA(curdir), "Failed to restore current dir err %d\n", GetLastError()); cdret = SetCurrentDirectoryA(curdir);
ok(cdret, "Failed to restore current dir err %d\n", GetLastError());
} }
ret = DeleteFileA( tmpfilename); ret = DeleteFileA( tmpfilename);
ok( ret, "Failed to delete temporary file %s err %d\n", tmpfilename, GetLastError()); ok( ret, "Failed to delete temporary file %s err %d\n", tmpfilename, GetLastError());
@ -760,7 +757,7 @@ static LONG_PTR WINAPI template_hook_arrange(HWND dlgChild, UINT msg, WPARAM wPa
/* special case: there is a control with id stc32 */ /* special case: there is a control with id stc32 */
/* expected height */ /* expected height */
expecty = posz0[withhelp].cy; expecty = posz0[withhelp].cy;
if( rcStc32.bottom - rcStc32.top > clrcParent.bottom) { if( rcStc32.bottom - rcStc32.top + (withhelp ? 0 : fixhelp) > clrcParent.bottom) {
expecty += clrcChild.bottom - clrcParent.bottom; expecty += clrcChild.bottom - clrcParent.bottom;
if( !withhelp) expecty += fixhelp; if( !withhelp) expecty += fixhelp;
} }
@ -983,6 +980,120 @@ static void test_resizable2(void)
#undef ISSIZABLE #undef ISSIZABLE
} }
static void test_mru(void)
{
ok_wndproc_testcase testcase = {0};
OPENFILENAME ofn = {sizeof(OPENFILENAME)};
const char *test_dir_name = "C:\\mru_test";
const char *test_file_name = "test.txt";
const char *test_full_path = "C:\\mru_test\\test.txt";
char filename_buf[MAX_PATH];
DWORD ret;
ofn.lpstrFile = filename_buf;
ofn.nMaxFile = sizeof(filename_buf);
ofn.lpTemplateName = "template1";
ofn.hInstance = GetModuleHandle(NULL);
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER | OFN_ENABLETEMPLATE | OFN_NOCHANGEDIR;
ofn.lCustData = (LPARAM)&testcase;
ofn.lpfnHook = (LPOFNHOOKPROC)test_ok_wndproc;
SetLastError(0xdeadbeef);
ret = CreateDirectoryA(test_dir_name, NULL);
ok(ret == TRUE, "CreateDirectoryA should have succeeded: %d\n", GetLastError());
/* "teach" comdlg32 about this directory */
strcpy(filename_buf, test_full_path);
SetLastError(0xdeadbeef);
ret = GetOpenFileNameA(&ofn);
ok(ret, "GetOpenFileNameA should have succeeded: %d\n", GetLastError());
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %x\n", ret);
ok(testcase.actclose, "Open File dialog should have closed.\n");
ok(!strcmp(ofn.lpstrFile, test_full_path), "Expected to get %s, got %s\n", test_full_path, ofn.lpstrFile);
/* get a filename without a full path. it should return the file in
* test_dir_name, not in the CWD */
strcpy(filename_buf, test_file_name);
SetLastError(0xdeadbeef);
ret = GetOpenFileNameA(&ofn);
ok(ret, "GetOpenFileNameA should have succeeded: %d\n", GetLastError());
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %x\n", ret);
ok(testcase.actclose, "Open File dialog should have closed.\n");
if(strcmp(ofn.lpstrFile, test_full_path) != 0)
win_skip("Platform doesn't save MRU data\n");
SetLastError(0xdeadbeef);
ret = RemoveDirectoryA(test_dir_name);
ok(ret == TRUE, "RemoveDirectoryA should have succeeded: %d\n", GetLastError());
}
static UINT_PTR WINAPI test_extension_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND parent = GetParent( dlg);
if( msg == WM_NOTIFY) {
SetTimer( dlg, 0, 1000, 0);
PostMessage( parent, WM_COMMAND, IDOK, 0);
}
if( msg == WM_TIMER) {
/* the dialog did not close automatically */
KillTimer( dlg, 0);
PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
}
return FALSE;
}
static const char *defext_filters[] = {
"TestFilter (*.pt*)\0*.pt*\0",
"TestFilter (*.ab?)\0*.ab?\0",
"TestFilter (*.*)\0*.*\0",
NULL /* is a test, not an endmark! */
};
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
static void test_extension(void)
{
OPENFILENAME ofn = { sizeof(OPENFILENAME)};
char filename[1024] = {0};
char curdir[MAX_PATH];
char *filename_ptr;
const char *test_file_name = "deadbeef";
unsigned int i;
DWORD ret;
BOOL boolret;
boolret = GetCurrentDirectoryA(sizeof(curdir), curdir);
ok(boolret, "Failed to get current dir err %d\n", GetLastError());
/* Ignore .* extension */
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile = filename;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK;
ofn.lpstrDefExt = NULL;
ofn.lpstrInitialDir = curdir;
ofn.lpfnHook = test_extension_wndproc;
ofn.nFileExtension = 0;
for (i = 0; i < ARRAY_SIZE(defext_filters); i++) {
ofn.lpstrFilter = defext_filters[i];
strcpy(filename, test_file_name);
boolret = GetSaveFileNameA(&ofn);
ok(boolret, "%u: expected true\n", i);
ret = CommDlgExtendedError();
ok(!ret, "%u: CommDlgExtendedError returned %#x\n", i, ret);
filename_ptr = ofn.lpstrFile + strlen( ofn.lpstrFile ) - strlen( test_file_name );
ok( strlen(ofn.lpstrFile) >= strlen(test_file_name), "Filename %s is too short\n", ofn.lpstrFile );
ok( strcmp(filename_ptr, test_file_name) == 0,
"Filename is %s, expected %s\n", filename_ptr, test_file_name );
}
}
#undef ARRAY_SIZE
START_TEST(filedlg) START_TEST(filedlg)
{ {
test_DialogCancel(); test_DialogCancel();
@ -992,5 +1103,7 @@ START_TEST(filedlg)
test_resize(); test_resize();
test_ok(); test_ok();
test_getfolderpath(); test_getfolderpath();
test_mru();
if( resizesupported) test_resizable2(); if( resizesupported) test_resizable2();
test_extension();
} }

View file

@ -0,0 +1,147 @@
/*
* Unit test suite for comdlg32 API functions: find/replace dialogs
*
* Copyright 2010 by Dylan Smith
*
* 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 "windows.h"
#include "commdlg.h"
#include "wine/test.h"
static UINT ID_FINDMSGSTRING;
static LRESULT handle_findmsg(FINDREPLACEA *fr)
{
return 0;
}
static LRESULT CALLBACK OwnerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg == ID_FINDMSGSTRING) {
return handle_findmsg((FINDREPLACEA*)lParam);
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
static void test_param_check(void)
{
char findbuffer[64];
char replacebuffer[64];
FINDREPLACEA fr, *pFr;
WNDCLASSA wc;
ZeroMemory(&wc, sizeof(wc));
wc.lpfnWndProc = OwnerWndProc;
wc.lpszClassName = "test_param_check";
RegisterClassA(&wc);
#define CHECK_FIND_OR_REPLACE(FUNC, FAIL, ERR_CODE) \
do { \
HWND hwnd = FUNC(pFr); \
BOOL is_ok = !!hwnd == !FAIL; \
ok(is_ok, "%s should%s fail\n", #FUNC, FAIL ? "" : "n't"); \
if (FAIL && is_ok) { \
DWORD ext_err = CommDlgExtendedError(); \
ok(ext_err == ERR_CODE, "expected err %x got %x\n", \
ERR_CODE, ext_err); \
} else { \
DestroyWindow(hwnd); \
} \
} while (0)
#define CHECK_FIND_FAIL(ERR_CODE) \
CHECK_FIND_OR_REPLACE(FindTextA, TRUE, ERR_CODE)
#define CHECK_FIND_SUCCEED() \
CHECK_FIND_OR_REPLACE(FindTextA, FALSE, 0)
#define CHECK_REPLACE_FAIL(ERR_CODE) \
CHECK_FIND_OR_REPLACE(ReplaceTextA, TRUE, ERR_CODE)
#define CHECK_REPLACE_SUCCEED() \
CHECK_FIND_OR_REPLACE(ReplaceTextA, FALSE, 0)
#define CHECK_FINDREPLACE_FAIL(ERR_CODE) \
do { \
CHECK_FIND_FAIL(ERR_CODE); \
CHECK_REPLACE_FAIL(ERR_CODE); \
} while (0)
pFr = NULL;
CHECK_FINDREPLACE_FAIL(CDERR_INITIALIZATION);
pFr = &fr;
ZeroMemory(&fr, sizeof(fr));
/* invalid lStructSize (0) */
CHECK_FINDREPLACE_FAIL(CDERR_STRUCTSIZE);
fr.lStructSize = sizeof(fr);
/* invalid hwndOwner (NULL) */
CHECK_FINDREPLACE_FAIL(CDERR_DIALOGFAILURE);
fr.hwndOwner = CreateWindowA(wc.lpszClassName, NULL, WS_VISIBLE, 0, 0, 200, 100,
NULL, NULL, GetModuleHandleA(NULL), NULL);
/* invalid wFindWhatLen (0) */
CHECK_FINDREPLACE_FAIL(FRERR_BUFFERLENGTHZERO);
fr.wFindWhatLen = sizeof(findbuffer);
/* invalid lpstrFindWhat (NULL) */
CHECK_FINDREPLACE_FAIL(FRERR_BUFFERLENGTHZERO);
fr.lpstrFindWhat = findbuffer;
strcpy(findbuffer, "abc");
/* invalid lpstrReplaceWith (NULL) for ReplaceText */
CHECK_FIND_SUCCEED();
CHECK_REPLACE_FAIL(FRERR_BUFFERLENGTHZERO);
fr.lpstrReplaceWith = replacebuffer;
strcpy(replacebuffer, "def");
/* wReplaceWithLen may be 0, even for ReplaceText */
CHECK_FIND_SUCCEED();
CHECK_REPLACE_SUCCEED();
fr.wReplaceWithLen = sizeof(replacebuffer);
/* invalid lpfnHook (NULL) when Flags has FR_ENABLEHOOK */
fr.Flags = FR_ENABLEHOOK;
CHECK_FINDREPLACE_FAIL(CDERR_NOHOOK);
/* invalid hInstance (NULL)
* when Flags has FR_ENABLETEMPLATE or FR_ENABLETEMPLATEHANDLE */
fr.Flags = FR_ENABLETEMPLATE;
CHECK_FINDREPLACE_FAIL(CDERR_FINDRESFAILURE);
fr.Flags = FR_ENABLETEMPLATEHANDLE;
CHECK_FINDREPLACE_FAIL(CDERR_NOHINSTANCE);
fr.hInstance = GetModuleHandle(NULL);
/* invalid lpTemplateName (NULL) when Flags has FR_ENABLETEMPLATE */
fr.Flags = FR_ENABLETEMPLATE;
CHECK_FINDREPLACE_FAIL(CDERR_FINDRESFAILURE);
fr.Flags = 0;
CHECK_FIND_SUCCEED();
CHECK_REPLACE_SUCCEED();
DestroyWindow(fr.hwndOwner);
}
START_TEST(finddlg)
{
ID_FINDMSGSTRING = RegisterWindowMessageA(FINDMSGSTRINGA);
test_param_check();
}

View file

@ -138,7 +138,8 @@ static void test_ChooseFontA(void)
ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize); ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize);
ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight); ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight);
ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight); ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName); ok((strcmp(lfa.lfFaceName, "Symbol") == 0) ||
broken(*lfa.lfFaceName == 0), "Expected Symbol, got %s\n", lfa.lfFaceName);
DeleteDC(printer_ic); DeleteDC(printer_ic);
} }

File diff suppressed because it is too large Load diff

View file

@ -320,18 +320,14 @@ static void test_abort_proc(void)
if (!PrintDlgA(&pd)) if (!PrintDlgA(&pd))
{ {
skip("No default printer available.\n"); skip("No default printer available.\n");
ok(DeleteFileA(filename), "Failed to delete temporary file\n"); goto end;
return;
} }
GlobalFree(pd.hDevMode); GlobalFree(pd.hDevMode);
GlobalFree(pd.hDevNames); GlobalFree(pd.hDevNames);
ok(pd.hDC != NULL, "PrintDlg didn't return a DC.\n"); ok(pd.hDC != NULL, "PrintDlg didn't return a DC.\n");
if (!(print_dc = pd.hDC)) if (!(print_dc = pd.hDC))
{ goto end;
ok(DeleteFileA(filename), "Failed to delete temporary file\n");
return;
}
ok(SetAbortProc(print_dc, abort_proc) > 0, "SetAbortProc failed\n"); ok(SetAbortProc(print_dc, abort_proc) > 0, "SetAbortProc failed\n");
ok(!abort_proc_called, "AbortProc got called unexpectedly by SetAbortProc.\n"); ok(!abort_proc_called, "AbortProc got called unexpectedly by SetAbortProc.\n");
@ -371,7 +367,9 @@ static void test_abort_proc(void)
abort_proc_called = FALSE; abort_proc_called = FALSE;
end: end:
ok(DeleteFileA(filename), "Failed to delete temporary file\n"); SetLastError(0xdeadbeef);
if(!DeleteFileA(filename))
trace("Failed to delete temporary file (err = %x)\n", GetLastError());
} }
/* ########################### */ /* ########################### */

View file

@ -7,11 +7,17 @@
#include "wine/test.h" #include "wine/test.h"
extern void func_filedlg(void); extern void func_filedlg(void);
extern void func_finddlg(void);
extern void func_fontdlg(void);
extern void func_itemdlg(void);
extern void func_printdlg(void); extern void func_printdlg(void);
const struct test winetest_testlist[] = const struct test winetest_testlist[] =
{ {
{ "filedlg", func_filedlg }, { "filedlg", func_filedlg },
{ "finddlg", func_finddlg },
{ "fontdlg", func_fontdlg },
//{ "itemdlg", func_itemdlg }, // Win 7
{ "printdlg", func_printdlg }, { "printdlg", func_printdlg },
{ 0, 0 } { 0, 0 }
}; };