On 2/7/19 11:55 AM, Huw Davies wrote:
On Thu, Jan 31, 2019 at 05:23:22PM +0200, Gabriel Ivăncescu wrote:
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
dlls/comctl32/tests/listbox.c | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index e789483..68e4073 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -1906,6 +1906,69 @@ static void test_GetListBoxInfo(void) 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(WC_LISTBOXA, "TestList", styles[i] | WS_CHILD,
0, 0, 100, 100, parent, (HMENU)ID_LISTBOX, 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)"");
Don't you need to treat the NODATA case separately here just as you do above?
I don't think so, but perhaps I'm missing something.
I treat it specially above because I want to also test SETCOUNT's behavior for init storage (test if it reserves or not, etc) and it only works with NODATA so it has to be special cased. The init storage itself should be the same.