Akihiro Sagawa : shell32/tests: Add tests for DragQueryFile.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jun 2 07:50:06 CDT 2015
Module: wine
Branch: master
Commit: 37d7d6f81c45f14e56b5a4ae81fcd3cf5c4ab1c8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=37d7d6f81c45f14e56b5a4ae81fcd3cf5c4ab1c8
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Tue Jun 2 01:22:06 2015 +0900
shell32/tests: Add tests for DragQueryFile.
---
dlls/shell32/tests/shellole.c | 117 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 117 insertions(+)
diff --git a/dlls/shell32/tests/shellole.c b/dlls/shell32/tests/shellole.c
index 3f0b490..308134a 100644
--- a/dlls/shell32/tests/shellole.c
+++ b/dlls/shell32/tests/shellole.c
@@ -25,6 +25,7 @@
#include "winbase.h"
#include "shlobj.h"
+#include "shellapi.h"
#include "initguid.h"
DEFINE_GUID(FMTID_Test,0x12345678,0x1234,0x1234,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12);
@@ -742,10 +743,126 @@ static void test_SHCreateQueryCancelAutoPlayMoniker(void)
IMoniker_Release(mon);
}
+#define DROPTEST_FILENAME "c:\\wintest.bin"
+struct DragParam {
+ HWND hwnd;
+ HANDLE ready;
+};
+
+static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ switch (msg) {
+ case WM_DROPFILES:
+ {
+ HDROP hDrop = (HDROP)wparam;
+ char filename[MAX_PATH] = "dummy";
+ UINT num;
+ num = DragQueryFileA(hDrop, 0xffffffff, NULL, 0);
+ ok(num == 1, "expected 1, got %u\n", num);
+ num = DragQueryFileA(hDrop, 0xffffffff, (char*)0xdeadbeef, 0xffffffff);
+ todo_wine ok(num == 1, "expected 1, got %u\n", num);
+ num = DragQueryFileA(hDrop, 0, filename, sizeof(filename));
+ ok(num == strlen(DROPTEST_FILENAME), "got %u\n", num);
+ ok(!strcmp(filename, DROPTEST_FILENAME), "got %s\n", filename);
+ DragFinish(hDrop);
+ return 0;
+ }
+ }
+ return DefWindowProcA(hwnd, msg, wparam, lparam);
+}
+
+static DWORD WINAPI drop_window_therad(void *arg)
+{
+ struct DragParam *param = arg;
+ WNDCLASSA cls;
+ WINDOWINFO info;
+ BOOL r;
+ MSG msg;
+
+ memset(&cls, 0, sizeof(cls));
+ cls.lpfnWndProc = drop_window_proc;
+ cls.hInstance = GetModuleHandleA(NULL);
+ cls.lpszClassName = "drop test";
+ RegisterClassA(&cls);
+
+ param->hwnd = CreateWindowA("drop test", NULL, 0, 0, 0, 0, 0,
+ NULL, 0, NULL, 0);
+ ok(param->hwnd != NULL, "CreateWindow failed: %d\n", GetLastError());
+
+ memset(&info, 0, sizeof(info));
+ info.cbSize = sizeof(info);
+ r = GetWindowInfo(param->hwnd, &info);
+ ok(r, "got %d\n", r);
+ ok(!(info.dwExStyle & WS_EX_ACCEPTFILES), "got %08x\n", info.dwExStyle);
+
+ DragAcceptFiles(param->hwnd, TRUE);
+
+ memset(&info, 0, sizeof(info));
+ info.cbSize = sizeof(info);
+ r = GetWindowInfo(param->hwnd, &info);
+ ok(r, "got %d\n", r);
+ ok((info.dwExStyle & WS_EX_ACCEPTFILES), "got %08x\n", info.dwExStyle);
+
+ SetEvent(param->ready);
+
+ while ((r = GetMessageA(&msg, NULL, 0, 0)) != 0) {
+ if (r == (BOOL)-1) {
+ ok(0, "unexpected return value, got %d\n", r);
+ break;
+ }
+ DispatchMessageA(&msg);
+ }
+
+ DestroyWindow(param->hwnd);
+ UnregisterClassA("drop test", GetModuleHandleA(NULL));
+ return 0;
+}
+
+static void test_DragQueryFile(void)
+{
+ struct DragParam param;
+ HANDLE hThread;
+ DWORD rc;
+ HGLOBAL hDrop;
+ DROPFILES *pDrop;
+ int ret;
+ BOOL r;
+
+ param.ready = CreateEventA(NULL, FALSE, FALSE, NULL);
+ ok(param.ready != NULL, "can't create event\n");
+ hThread = CreateThread(NULL, 0, drop_window_therad, ¶m, 0, NULL);
+
+ rc = WaitForSingleObject(param.ready, 5000);
+ ok(rc == WAIT_OBJECT_0, "got %u\n", rc);
+
+ hDrop = GlobalAlloc(GHND, sizeof(DROPFILES) + (strlen(DROPTEST_FILENAME) + 2) * sizeof(WCHAR));
+ pDrop = GlobalLock(hDrop);
+ pDrop->pFiles = sizeof(DROPFILES);
+ ret = MultiByteToWideChar(CP_ACP, 0, DROPTEST_FILENAME, -1,
+ (LPWSTR)(pDrop + 1), strlen(DROPTEST_FILENAME) + 1);
+ ok(ret > 0, "got %d\n", ret);
+ pDrop->fWide = TRUE;
+ GlobalUnlock(hDrop);
+
+ r = PostMessageA(param.hwnd, WM_DROPFILES, (WPARAM)hDrop, 0);
+ ok(r, "got %d\n", r);
+
+ r = PostMessageA(param.hwnd, WM_QUIT, 0, 0);
+ ok(r, "got %d\n", r);
+
+ rc = WaitForSingleObject(hThread, 5000);
+ ok(rc == WAIT_OBJECT_0, "got %d\n", rc);
+
+ CloseHandle(param.ready);
+ CloseHandle(hThread);
+}
+#undef DROPTEST_FILENAME
+
START_TEST(shellole)
{
init();
test_SHPropStg_functions();
test_SHCreateQueryCancelAutoPlayMoniker();
+ test_DragQueryFile();
}
More information about the wine-cvs
mailing list