Commit 3ef08159 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

shell32/tests: Add DBCS file name tests for DragQueryFile.

parent 9cd5bc0d
...@@ -746,7 +746,6 @@ static void test_SHCreateQueryCancelAutoPlayMoniker(void) ...@@ -746,7 +746,6 @@ static void test_SHCreateQueryCancelAutoPlayMoniker(void)
} }
#define WM_EXPECTED_VALUE WM_APP #define WM_EXPECTED_VALUE WM_APP
#define DROPTEST_FILENAME "c:\\wintest.bin"
struct DragParam { struct DragParam {
HWND hwnd; HWND hwnd;
HANDLE ready; HANDLE ready;
...@@ -755,10 +754,12 @@ struct DragParam { ...@@ -755,10 +754,12 @@ struct DragParam {
static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{ {
static BOOL expected; static BOOL expected;
static char expected_filename[MAX_PATH];
switch (msg) { switch (msg) {
case WM_EXPECTED_VALUE: case WM_EXPECTED_VALUE:
{ {
lstrcpynA(expected_filename, (const char*)wparam, sizeof(expected_filename));
expected = lparam; expected = lparam;
break; break;
} }
...@@ -768,19 +769,44 @@ static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA ...@@ -768,19 +769,44 @@ static LRESULT WINAPI drop_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
char filename[MAX_PATH] = "dummy"; char filename[MAX_PATH] = "dummy";
POINT pt; POINT pt;
BOOL r; BOOL r;
UINT num; UINT num, len;
winetest_push_context("%s", wine_dbgstr_a(expected_filename));
num = DragQueryFileA(hDrop, 0xffffffff, NULL, 0); num = DragQueryFileA(hDrop, 0xffffffff, NULL, 0);
ok(num == 1, "expected 1, got %u\n", num); ok(num == 1, "expected 1, got %u\n", num);
num = DragQueryFileA(hDrop, 0xffffffff, (char*)0xdeadbeef, 0xffffffff); num = DragQueryFileA(hDrop, 0xffffffff, (char*)0xdeadbeef, 0xffffffff);
ok(num == 1, "expected 1, got %u\n", num); ok(num == 1, "expected 1, got %u\n", num);
len = strlen(expected_filename);
num = DragQueryFileA(hDrop, 0, NULL, 0);
todo_wine_if(expected_filename[0] == 'd')
ok(num == len, "expected %u, got %u\n", len, num);
num = DragQueryFileA(hDrop, 0, filename, 0);
todo_wine_if(expected_filename[0] == 'd')
ok(num == len, "expected %u, got %u\n", len, num);
ok(!strcmp(filename, "dummy"), "got %s\n", filename);
num = DragQueryFileA(hDrop, 0, filename, sizeof(filename)); num = DragQueryFileA(hDrop, 0, filename, sizeof(filename));
ok(num == strlen(DROPTEST_FILENAME), "got %u\n", num); todo_wine_if(expected_filename[0] == 'd')
ok(!strcmp(filename, DROPTEST_FILENAME), "got %s\n", filename); ok(num == len, "expected %u, got %u\n", len, num);
ok(!strcmp(filename, expected_filename), "expected %s, got %s\n",
expected_filename, filename);
memset(filename, 0xaa, sizeof(filename));
num = DragQueryFileA(hDrop, 0, filename, 2);
todo_wine ok(num == 1, "expected 1, got %u\n", num);
ok(filename[0] == expected_filename[0], "expected '%c', got '%c'\n",
expected_filename[0], filename[0]);
ok(filename[1] == '\0', "expected nul, got %#x\n", (BYTE)filename[1]);
r = DragQueryPoint(hDrop, &pt); r = DragQueryPoint(hDrop, &pt);
ok(r == expected, "expected %d, got %d\n", expected, r); ok(r == expected, "expected %d, got %d\n", expected, r);
ok(pt.x == 10, "expected 10, got %ld\n", pt.x); ok(pt.x == 10, "expected 10, got %ld\n", pt.x);
ok(pt.y == 20, "expected 20, got %ld\n", pt.y); ok(pt.y == 20, "expected 20, got %ld\n", pt.y);
DragFinish(hDrop); DragFinish(hDrop);
winetest_pop_context();
return 0; return 0;
} }
} }
...@@ -841,8 +867,15 @@ static void test_DragQueryFile(BOOL non_client_flag) ...@@ -841,8 +867,15 @@ static void test_DragQueryFile(BOOL non_client_flag)
DWORD rc; DWORD rc;
HGLOBAL hDrop; HGLOBAL hDrop;
DROPFILES *pDrop; DROPFILES *pDrop;
int ret; int ret, i;
BOOL r; BOOL r;
static const struct {
UINT codepage;
const char* filename;
} testcase[] = {
{ 0, "c:\\wintest.bin" },
{ 932, "d:\\\x89\xb9\x8a\x79_02.CHY" },
};
param.ready = CreateEventA(NULL, FALSE, FALSE, NULL); param.ready = CreateEventA(NULL, FALSE, FALSE, NULL);
ok(param.ready != NULL, "can't create event\n"); ok(param.ready != NULL, "can't create event\n");
...@@ -851,23 +884,39 @@ static void test_DragQueryFile(BOOL non_client_flag) ...@@ -851,23 +884,39 @@ static void test_DragQueryFile(BOOL non_client_flag)
rc = WaitForSingleObject(param.ready, 5000); rc = WaitForSingleObject(param.ready, 5000);
ok(rc == WAIT_OBJECT_0, "got %lu\n", rc); ok(rc == WAIT_OBJECT_0, "got %lu\n", rc);
hDrop = GlobalAlloc(GHND, sizeof(DROPFILES) + (strlen(DROPTEST_FILENAME) + 2) * sizeof(WCHAR)); for (i = 0; i < ARRAY_SIZE(testcase); i++)
pDrop = GlobalLock(hDrop); {
pDrop->pt.x = 10; winetest_push_context("%d", i);
pDrop->pt.y = 20; if (testcase[i].codepage && testcase[i].codepage != GetACP())
pDrop->fNC = non_client_flag; {
pDrop->pFiles = sizeof(DROPFILES); skip("need codepage %u for this test\n", testcase[i].codepage);
ret = MultiByteToWideChar(CP_ACP, 0, DROPTEST_FILENAME, -1, winetest_pop_context();
(LPWSTR)(pDrop + 1), strlen(DROPTEST_FILENAME) + 1); continue;
ok(ret > 0, "got %d\n", ret); }
pDrop->fWide = TRUE;
GlobalUnlock(hDrop);
r = PostMessageA(param.hwnd, WM_EXPECTED_VALUE, 0, !non_client_flag);
ok(r, "got %d\n", r);
r = PostMessageA(param.hwnd, WM_DROPFILES, (WPARAM)hDrop, 0); ret = MultiByteToWideChar(CP_ACP, 0, testcase[i].filename, -1, NULL, 0);
ok(r, "got %d\n", r); ok(ret > 0, "got %d\n", ret);
hDrop = GlobalAlloc(GHND, sizeof(DROPFILES) + (ret + 1) * sizeof(WCHAR));
pDrop = GlobalLock(hDrop);
pDrop->pt.x = 10;
pDrop->pt.y = 20;
pDrop->fNC = non_client_flag;
pDrop->pFiles = sizeof(DROPFILES);
ret = MultiByteToWideChar(CP_ACP, 0, testcase[i].filename, -1,
(LPWSTR)(pDrop + 1), ret);
ok(ret > 0, "got %d\n", ret);
pDrop->fWide = TRUE;
GlobalUnlock(hDrop);
r = PostMessageA(param.hwnd, WM_EXPECTED_VALUE,
(WPARAM)testcase[i].filename, !non_client_flag);
ok(r, "got %d\n", r);
r = PostMessageA(param.hwnd, WM_DROPFILES, (WPARAM)hDrop, 0);
ok(r, "got %d\n", r);
winetest_pop_context();
}
r = PostMessageA(param.hwnd, WM_QUIT, 0, 0); r = PostMessageA(param.hwnd, WM_QUIT, 0, 0);
ok(r, "got %d\n", r); ok(r, "got %d\n", r);
...@@ -879,7 +928,6 @@ static void test_DragQueryFile(BOOL non_client_flag) ...@@ -879,7 +928,6 @@ static void test_DragQueryFile(BOOL non_client_flag)
CloseHandle(hThread); CloseHandle(hThread);
} }
#undef WM_EXPECTED_VALUE #undef WM_EXPECTED_VALUE
#undef DROPTEST_FILENAME
static void test_SHCreateSessionKey(void) static void test_SHCreateSessionKey(void)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment