>From 1859647d4ad13e29186521605c09ad5d3a490e99 Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Wed, 16 Sep 2009 11:52:04 +0200 Subject: [PATCH 3/3] Test the correct path length for CDM_GETFOLDERPATH --- dlls/comdlg32/tests/filedlg.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c index be3cf8c..900dc72 100644 --- a/dlls/comdlg32/tests/filedlg.c +++ b/dlls/comdlg32/tests/filedlg.c @@ -868,6 +868,67 @@ static void test_arrange(void) } } +static CHAR WINDIR[MAX_PATH]; + +static UINT_PTR CALLBACK path_hook_proc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + LPNMHDR nmh; + + if( msg == WM_NOTIFY) + { + nmh = (LPNMHDR) lParam; + if( nmh->code == CDN_INITDONE) + { + PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE); + } + else if ( nmh->code == CDN_FOLDERCHANGE) + { + char buf[1024]; + int ret; + + memset(buf, 0x66, sizeof(buf)); + ret = SendMessageA( GetParent(hDlg), CDM_GETFOLDERPATH, sizeof(buf), (LPARAM)buf); + ok(!lstrcmpA(WINDIR, buf), "Expected '%s', got '%s'\n", WINDIR, buf); + ok(lstrlenA(WINDIR) + 1 == ret, "Expected %d, got %d\n", lstrlenA(WINDIR) + 1, ret); + } + } + + return 0; +} + +static void test_getfolderpath(void) +{ + OPENFILENAMEA ofn; + BOOL result; + char szFileName[MAX_PATH] = ""; + char szInitialDir[MAX_PATH]; + + GetWindowsDirectory(szInitialDir, MAX_PATH); + lstrcpyA(WINDIR, szInitialDir); + + ZeroMemory(&ofn, sizeof(ofn)); + + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = NULL; + ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK; + ofn.lpstrDefExt = "txt"; + ofn.lpfnHook = path_hook_proc; + ofn.lpstrInitialDir = szInitialDir; + + result = GetOpenFileNameA(&ofn); + ok(0 == result, "expected 0, got %d\n", result); + ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", + CommDlgExtendedError()); + + result = GetSaveFileNameA(&ofn); + ok(0 == result, "expected 0, got %d\n", result); + ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", + CommDlgExtendedError()); +} + START_TEST(filedlg) { test_DialogCancel(); @@ -876,4 +937,5 @@ START_TEST(filedlg) test_arrange(); test_resize(); test_ok(); + test_getfolderpath(); } -- 1.6.2.5