Module: wine Branch: master Commit: 4bbde8fdd760c8345511942e099ad6aa8a049b42 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4bbde8fdd760c8345511942e09...
Author: Eryk Wieliczko ewdevel@gmail.com Date: Mon Nov 1 16:57:07 2010 +0100
comdlg32/tests: Add GetSaveFileName .* extension test.
---
dlls/comdlg32/tests/filedlg.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c index 977e91d..24c663e 100644 --- a/dlls/comdlg32/tests/filedlg.c +++ b/dlls/comdlg32/tests/filedlg.c @@ -1034,6 +1034,53 @@ static void test_mru(void) 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, 100, 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 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"; + DWORD ret; + + ok(GetCurrentDirectoryA(sizeof(curdir), curdir) != 0, "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; + ofn.lpstrFilter = "All Files (*.*)\0*.*\0"; + strcpy(filename, test_file_name); + + ret = GetSaveFileNameA(&ofn); + filename_ptr = ofn.lpstrFile + strlen( ofn.lpstrFile ) - strlen( test_file_name ); + ok(1 == ret, "expected 1, got %d\n", ret); + 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 ); +} + START_TEST(filedlg) { test_DialogCancel(); @@ -1045,4 +1092,5 @@ START_TEST(filedlg) test_getfolderpath(); test_mru(); if( resizesupported) test_resizable2(); + test_extension(); }