comdlg32/tests: Add a test for GetOpenFileName with a dialog template.

This commit is contained in:
Aric Stewart 2008-10-21 13:10:59 -05:00 committed by Alexandre Julliard
parent 37bbe9d4bc
commit faa956f537
3 changed files with 66 additions and 0 deletions

View File

@ -9,6 +9,8 @@ CTESTS = \
filedlg.c \
printdlg.c
RC_SRCS = rsrc.rc
@MAKE_TEST_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend

View File

@ -205,6 +205,16 @@ cleanup:
return 0;
}
static LONG_PTR WINAPI template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_NOTIFY)
{
if (((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE)
PostMessage(GetParent(dlg), WM_COMMAND, IDCANCEL, 0);
}
return 0;
}
static void test_create_view_window2(void)
{
OPENFILENAMEA ofn = {0};
@ -222,8 +232,28 @@ static void test_create_view_window2(void)
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
static void test_create_view_template(void)
{
OPENFILENAMEA ofn = {0};
char filename[1024] = {0};
DWORD ret;
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = filename;
ofn.nMaxFile = 1042;
ofn.lpfnHook = (LPOFNHOOKPROC)template_hook;
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE;
ofn.hInstance = GetModuleHandleW(NULL);
ofn.lpTemplateName = "template1";
ret = GetOpenFileNameA(&ofn);
ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
ret = CommDlgExtendedError();
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
}
START_TEST(filedlg)
{
test_DialogCancel();
test_create_view_window2();
test_create_view_template();
}

View File

@ -0,0 +1,34 @@
/* Resources for the common dialog unit test suite.
*
* Copyright 2008 CodeWeavers, Aric Stewart
*
* 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 "windef.h"
#include "winuser.h"
TEMPLATE1 DIALOG LOADONCALL MOVEABLE DISCARDABLE 5, 43, 227, 215
STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
FONT 8, "MS Shell Dlg"
{
LTEXT "Path:",-1,28,4,36,8
LTEXT "Text1",-1,4,16,20,40
LTEXT "Selected:",-1,32,49,40,8
EDITTEXT 55,74,47,200,12,ES_AUTOHSCROLL
LTEXT "Text2",-1,232,20,65,8
LTEXT "",-1,28,16,204,31
EDITTEXT 56,65,2,200,12,ES_AUTOHSCROLL
}