[v5 PATCH 2/4] comctl32/tests: Add some tests for LBS_NODATA.
Nikolay Sivov
nsivov at codeweavers.com
Sun Nov 11 01:04:12 CST 2018
From: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/comctl32/tests/listbox.c | 154 +++++++++++++++++++++++++---------
1 file changed, 116 insertions(+), 38 deletions(-)
diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c
index c118047b4f..387660d160 100644
--- a/dlls/comctl32/tests/listbox.c
+++ b/dlls/comctl32/tests/listbox.c
@@ -122,7 +122,6 @@ struct listbox_stat
struct listbox_test
{
- struct listbox_prop prop;
struct listbox_stat init, init_todo;
struct listbox_stat click, click_todo;
struct listbox_stat step, step_todo;
@@ -155,8 +154,7 @@ static void keypress(HWND handle, WPARAM keycode, BYTE scancode, BOOL extended)
#define listbox_field_ok(t, s, f, got) \
ok (t.s.f==got.f, "style %#x, step " #s ", field " #f \
- ": expected %d, got %d\n", (unsigned int)t.prop.add_style, \
- t.s.f, got.f)
+ ": expected %d, got %d\n", style, t.s.f, got.f)
#define listbox_todo_field_ok(t, s, f, got) \
todo_wine_if (t.s##_todo.f) { listbox_field_ok(t, s, f, got); }
@@ -167,12 +165,14 @@ static void keypress(HWND handle, WPARAM keycode, BYTE scancode, BOOL extended)
listbox_todo_field_ok(t, s, caret, got); \
listbox_todo_field_ok(t, s, selcount, got)
-static void run_test(const struct listbox_test test)
+static void run_test(DWORD style, const struct listbox_test test)
{
struct listbox_stat answer;
- HWND hLB=create_listbox (test.prop.add_style, 0);
RECT second_item;
int i, res;
+ HWND hLB;
+
+ hLB = create_listbox (style, 0);
listbox_query (hLB, &answer);
listbox_ok (test, init, answer);
@@ -190,13 +190,13 @@ static void run_test(const struct listbox_test test)
DestroyWindow(hLB);
- hLB = create_listbox(test.prop.add_style, 0);
+ hLB = create_listbox(style, 0);
SendMessageA(hLB, LB_SELITEMRANGE, TRUE, MAKELPARAM(1, 2));
listbox_query(hLB, &answer);
listbox_ok(test, sel, answer);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4 && !(style & LBS_NODATA); i++)
{
DWORD size = SendMessageA(hLB, LB_GETTEXTLEN, i, 0);
int resA, resW;
@@ -209,13 +209,9 @@ static void run_test(const struct listbox_test test)
txtw = heap_alloc_zero((size + 1) * sizeof(*txtw));
resW = SendMessageW(hLB, LB_GETTEXT, i, (LPARAM)txtw);
- if (resA != resW)
- trace("SendMessageW(LB_GETTEXT) not supported on this platform (resA=%d resW=%d), skipping...\n", resA, resW);
- else
- {
- WideCharToMultiByte(CP_ACP, 0, txtw, -1, txt, size, NULL, NULL);
- ok(!strcmp (txt, strings[i]), "returned string for item %d does not match %s vs %s\n", i, txt, strings[i]);
- }
+ ok(resA == resW, "Unexpected text length.\n");
+ WideCharToMultiByte(CP_ACP, 0, txtw, -1, txt, size, NULL, NULL);
+ ok(!strcmp (txt, strings[i]), "Unexpected string for item %d, %s vs %s.\n", i, txt, strings[i]);
heap_free(txtw);
heap_free(txt);
@@ -2059,70 +2055,71 @@ static void test_listbox(void)
{
static const struct listbox_test SS =
/* {add_style} */
- {{0},
- {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
+ {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
{ 1, 1, 1, LB_ERR}, {0,0,0,0},
{ 2, 2, 2, LB_ERR}, {0,0,0,0},
{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
/* {selected, anchor, caret, selcount}{TODO fields} */
static const struct listbox_test SS_NS =
- {{LBS_NOSEL},
- {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
+ {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
{ 1, 1, 1, LB_ERR}, {0,0,0,0},
{ 2, 2, 2, LB_ERR}, {0,0,0,0},
{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
static const struct listbox_test MS =
- {{LBS_MULTIPLESEL},
- { 0, LB_ERR, 0, 0}, {0,0,0,0},
+ {{ 0, LB_ERR, 0, 0}, {0,0,0,0},
{ 1, 1, 1, 1}, {0,0,0,0},
{ 2, 1, 2, 1}, {0,0,0,0},
{ 0, LB_ERR, 0, 2}, {0,0,0,0}};
static const struct listbox_test MS_NS =
- {{LBS_MULTIPLESEL | LBS_NOSEL},
- {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
+ {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
{ 1, 1, 1, LB_ERR}, {0,0,0,0},
{ 2, 2, 2, LB_ERR}, {0,0,0,0},
{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
static const struct listbox_test ES =
- {{LBS_EXTENDEDSEL},
- { 0, LB_ERR, 0, 0}, {0,0,0,0},
+ {{ 0, LB_ERR, 0, 0}, {0,0,0,0},
{ 1, 1, 1, 1}, {0,0,0,0},
{ 2, 2, 2, 1}, {0,0,0,0},
{ 0, LB_ERR, 0, 2}, {0,0,0,0}};
static const struct listbox_test ES_NS =
- {{LBS_EXTENDEDSEL | LBS_NOSEL},
- {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
+ {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
{ 1, 1, 1, LB_ERR}, {0,0,0,0},
{ 2, 2, 2, LB_ERR}, {0,0,0,0},
{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
static const struct listbox_test EMS =
- {{LBS_EXTENDEDSEL | LBS_MULTIPLESEL},
- { 0, LB_ERR, 0, 0}, {0,0,0,0},
+ {{ 0, LB_ERR, 0, 0}, {0,0,0,0},
{ 1, 1, 1, 1}, {0,0,0,0},
{ 2, 2, 2, 1}, {0,0,0,0},
{ 0, LB_ERR, 0, 2}, {0,0,0,0}};
static const struct listbox_test EMS_NS =
- {{LBS_EXTENDEDSEL | LBS_MULTIPLESEL | LBS_NOSEL},
- {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
+ {{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
{ 1, 1, 1, LB_ERR}, {0,0,0,0},
{ 2, 2, 2, LB_ERR}, {0,0,0,0},
{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}};
- run_test(SS);
- run_test(SS_NS);
- run_test(MS);
- run_test(MS_NS);
- run_test(ES);
- run_test(ES_NS);
- run_test(EMS);
- run_test(EMS_NS);
+ run_test(0, SS);
+ run_test(LBS_NOSEL, SS_NS);
+ run_test(LBS_MULTIPLESEL, MS);
+ run_test(LBS_MULTIPLESEL | LBS_NOSEL, MS_NS);
+ run_test(LBS_EXTENDEDSEL, ES);
+ run_test(LBS_EXTENDEDSEL | LBS_NOSEL, ES_NS);
+ run_test(LBS_EXTENDEDSEL | LBS_MULTIPLESEL, EMS);
+ run_test(LBS_EXTENDEDSEL | LBS_MULTIPLESEL | LBS_NOSEL, EMS_NS);
+
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED, SS);
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_NOSEL, SS_NS);
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_MULTIPLESEL, MS);
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_MULTIPLESEL | LBS_NOSEL, MS_NS);
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL, ES);
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL | LBS_NOSEL, ES_NS);
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL | LBS_MULTIPLESEL, EMS);
+ run_test(LBS_NODATA | LBS_OWNERDRAWFIXED | LBS_EXTENDEDSEL | LBS_MULTIPLESEL | LBS_NOSEL, EMS_NS);
}
static const struct message lb_addstring_ownerdraw_parent_seq[] =
@@ -2240,6 +2237,86 @@ static void test_WM_MEASUREITEM(void)
DestroyWindow(parent);
}
+static void test_LBS_NODATA(void)
+{
+ static const UINT invalid_idx[] = { -2, 2 };
+ static const UINT valid_idx[] = { 0, 1 };
+ static const ULONG_PTR zero_data;
+ INT ret, text_len;
+ unsigned int i;
+ ULONG_PTR data;
+ BOOL is_wow64;
+ HWND listbox;
+
+ listbox = CreateWindowA(WC_LISTBOXA, "TestList", LBS_NODATA | LBS_OWNERDRAWFIXED | WS_VISIBLE,
+ 0, 0, 100, 100, NULL, NULL, NULL, 0);
+ ok(listbox != NULL, "Failed to create ListBox window.\n");
+
+ ret = SendMessageA(listbox, LB_INSERTSTRING, -1, 0);
+ ok(ret == 0, "Unexpected return value %d.\n", ret);
+ ret = SendMessageA(listbox, LB_INSERTSTRING, -1, 0);
+ ok(ret == 1, "Unexpected return value %d.\n", ret);
+ ret = SendMessageA(listbox, LB_GETCOUNT, 0, 0);
+ ok(ret == 2, "Unexpected return value %d.\n", ret);
+
+ /* Invalid indices. */
+ for (i = 0; i < ARRAY_SIZE(invalid_idx); ++i)
+ {
+ ret = SendMessageA(listbox, LB_SETITEMDATA, invalid_idx[i], 42);
+ ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
+ ret = SendMessageA(listbox, LB_GETTEXTLEN, invalid_idx[i], 0);
+ ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
+ if (ret == LB_ERR)
+ {
+ ret = SendMessageA(listbox, LB_GETTEXT, invalid_idx[i], (LPARAM)&data);
+ ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
+ }
+ ret = SendMessageA(listbox, LB_GETITEMDATA, invalid_idx[i], 0);
+ ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
+ }
+
+ IsWow64Process(GetCurrentProcess(), &is_wow64);
+#ifdef _WIN64
+ text_len = 8;
+#else
+ text_len = is_wow64 ? 8 : 4;
+#endif
+
+ /* Valid indices. */
+ for (i = 0; i < ARRAY_SIZE(valid_idx); ++i)
+ {
+ ret = SendMessageA(listbox, LB_SETITEMDATA, valid_idx[i], 42);
+ ok(ret == TRUE, "Unexpected return value %d.\n", ret);
+ ret = SendMessageA(listbox, LB_GETTEXTLEN, valid_idx[i], 0);
+ todo_wine_if(text_len == 8)
+ ok(ret == text_len, "Unexpected return value %d.\n", ret);
+
+ memset(&data, 0xee, sizeof(data));
+ ret = SendMessageA(listbox, LB_GETTEXT, valid_idx[i], (LPARAM)&data);
+ todo_wine_if(sizeof(void *) == 8)
+ ok(ret == sizeof(data), "Unexpected return value %d.\n", ret);
+ todo_wine
+ ok(!memcmp(&data, &zero_data, sizeof(data)), "Unexpected item data.\n");
+
+ ret = SendMessageA(listbox, LB_GETITEMDATA, valid_idx[i], 0);
+ todo_wine
+ ok(ret == 0, "Unexpected return value %d.\n", ret);
+ }
+
+ /* More messages that don't work with LBS_NODATA. */
+ ret = SendMessageA(listbox, LB_FINDSTRING, 1, 42);
+todo_wine
+ ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
+ ret = SendMessageA(listbox, LB_FINDSTRINGEXACT, 1, 42);
+todo_wine
+ ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
+ ret = SendMessageA(listbox, LB_SELECTSTRING, 1, 42);
+todo_wine
+ ok(ret == LB_ERR, "Unexpected return value %d.\n", ret);
+
+ DestroyWindow(listbox);
+}
+
START_TEST(listbox)
{
ULONG_PTR ctx_cookie;
@@ -2266,6 +2343,7 @@ START_TEST(listbox)
test_extents();
test_WM_MEASUREITEM();
test_LB_SETSEL();
+ test_LBS_NODATA();
unload_v6_module(ctx_cookie, hCtx);
}
--
2.19.1
More information about the wine-devel
mailing list