=?UTF-8?Q?Gabriel=20Iv=C4=83ncescu=20?=: user32/tests: Add tests for LB_INITSTORAGE.
Alexandre Julliard
julliard at winehq.org
Mon Feb 11 16:12:11 CST 2019
Module: wine
Branch: master
Commit: 0d19628ef5511d23e2d793af4ad5adca0aede884
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0d19628ef5511d23e2d793af4ad5adca0aede884
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Fri Feb 8 13:17:22 2019 +0200
user32/tests: Add tests for LB_INITSTORAGE.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/tests/listbox.c | 64 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index b87acd7..7f1e9cf 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -1824,6 +1824,69 @@ todo_wine
DestroyWindow(parent);
}
+static void test_init_storage( void )
+{
+ static const DWORD styles[] =
+ {
+ LBS_HASSTRINGS,
+ LBS_NODATA | LBS_OWNERDRAWFIXED,
+ };
+ HWND parent, listbox;
+ LONG ret, items_size;
+ int i, j;
+
+ parent = create_parent();
+ for (i = 0; i < ARRAY_SIZE(styles); i++)
+ {
+ listbox = CreateWindowA("listbox", "TestList", styles[i] | WS_CHILD,
+ 0, 0, 100, 100, parent, (HMENU)1, NULL, 0);
+
+ items_size = SendMessageA(listbox, LB_INITSTORAGE, 100, 0);
+ ok(items_size >= 100, "expected at least 100, got %d\n", items_size);
+
+ ret = SendMessageA(listbox, LB_INITSTORAGE, 0, 0);
+ ok(ret == items_size, "expected %d, got %d\n", items_size, ret);
+
+ /* it doesn't grow since the space was already reserved */
+ ret = SendMessageA(listbox, LB_INITSTORAGE, items_size, 0);
+ ok(ret == items_size, "expected %d, got %d\n", items_size, ret);
+
+ /* it doesn't shrink the reserved space */
+ ret = SendMessageA(listbox, LB_INITSTORAGE, 42, 0);
+ ok(ret == items_size, "expected %d, got %d\n", items_size, ret);
+
+ /* now populate almost all of it so it's not reserved anymore */
+ if (styles[i] & LBS_NODATA)
+ {
+ ret = SendMessageA(listbox, LB_SETCOUNT, items_size - 1, 0);
+ ok(ret == 0, "unexpected return value %d\n", ret);
+ }
+ else
+ {
+ for (j = 0; j < items_size - 1; j++)
+ {
+ ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)"");
+ ok(ret == j, "expected %d, got %d\n", j, ret);
+ }
+ }
+
+ /* we still have one more reserved slot, so it doesn't grow yet */
+ ret = SendMessageA(listbox, LB_INITSTORAGE, 1, 0);
+ ok(ret == items_size, "expected %d, got %d\n", items_size, ret);
+
+ /* fill the slot and check again, it should grow this time */
+ ret = SendMessageA(listbox, LB_INSERTSTRING, -1, (LPARAM)"");
+ ok(ret == items_size - 1, "expected %d, got %d\n", items_size - 1, ret);
+ ret = SendMessageA(listbox, LB_INITSTORAGE, 0, 0);
+ ok(ret == items_size, "expected %d, got %d\n", items_size, ret);
+ ret = SendMessageA(listbox, LB_INITSTORAGE, 1, 0);
+ ok(ret > items_size, "expected it to grow past %d, got %d\n", items_size, ret);
+
+ DestroyWindow(listbox);
+ }
+ DestroyWindow(parent);
+}
+
static void test_missing_lbuttonup( void )
{
HWND listbox, parent, capture;
@@ -2251,6 +2314,7 @@ START_TEST(listbox)
test_listbox_LB_DIR();
test_listbox_dlgdir();
test_set_count();
+ test_init_storage();
test_GetListBoxInfo();
test_missing_lbuttonup();
test_extents();
More information about the wine-cvs
mailing list