New conformance test for user32.dll
Ferenc Wagner
wferi at tba.elte.hu
Mon Mar 3 12:07:46 CST 2003
Hello,
I put together a new test file for dlls/user/tests (find
attached). It tests undocumented behaviour (at least I
couldn't find a word), but one of my apps depend on it.
It's a first try, please have a look at it (I tried to
follow the Developers' Guide) and tell me what I should do.
I compiled a previous version (some code rearrangement
happened since then) with MSVC, it ran fine on XP, ME and
Win95, ie. all tests passed.
In short: a LISTBOX window can have the LBS_NOSEL style
option. For me it seems it's only about appearance and
nothing more. But Wine implements it in a more meaningful
way, unfortunately...
I'd like to be sure about what's correct before patching the
implementation. Looking forward to your comments:
Feri.
Insert listbox.c into CTESTS in Makefile{,.in} to run:
-------------- next part --------------
#include "wine/test.h"
#include "windows.h"
#include "assert.h"
HWND
create_listbox (DWORD add_style)
{
HWND handle=CreateWindow ("LISTBOX", "TestList",
(LBS_STANDARD & ~LBS_SORT) | add_style,
0, 0, 100, 100,
NULL, NULL, NULL, 0);
assert (handle);
assert (0==SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "First added"));
assert (1==SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "Second added"));
assert (2==SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "Third added"));
return handle;
}
struct listbox_prop {
int selected;
int anchor;
int caret;
};
void
listbox_query (HWND handle, struct listbox_prop *results)
{
results->selected = SendMessage (handle, LB_GETCURSEL, 0, 0);
results->anchor = SendMessage (handle, LB_GETANCHORINDEX, 0, 0);
results->caret = SendMessage (handle, LB_GETCARETINDEX, 0, 0);
}
#define listbox_ok(ex, got) ok (ex.selected==got.selected && \
ex.anchor==got.anchor && \
ex.caret==got.caret, \
"expected {s=%d,a=%d,c=%d}, got {s=%d,a=%d,c=%d}", \
ex.selected, ex.anchor, ex.caret, \
got.selected, got.anchor, got.caret)
void
buttonpress (HWND handle, WORD x, WORD y)
{
LPARAM lp=x+(y<<16);
assert (0==SendMessage (handle, WM_LBUTTONDOWN, (WPARAM) MK_LBUTTON, lp));
assert (0==SendMessage (handle, WM_LBUTTONUP, (WPARAM) 0, lp));
}
void
keypress (HWND handle, WPARAM keycode, BYTE scancode, BOOL extended)
{
LPARAM lp=1+(scancode<<16)+(extended?KEYEVENTF_EXTENDEDKEY:0);
assert (0==SendMessage (handle, WM_KEYDOWN, keycode, lp));
assert (0==SendMessage (handle, WM_KEYUP , keycode, lp | 0xc000000));
}
void
check_buttonpress ()
{
struct listbox_prop answer;
const struct listbox_prop init={LB_ERR,LB_ERR,0}, click={1,1,1}, down={2,2,2};
HWND hLB=create_listbox (0);
listbox_query (hLB, &answer);
listbox_ok (init, answer);
buttonpress(hLB, 8, 16);
listbox_query (hLB, &answer);
listbox_ok (click, answer);
keypress (hLB, VK_DOWN, 0x50, 1);
listbox_query (hLB, &answer);
listbox_ok (down, answer);
assert (DestroyWindow (hLB));
}
void
check_buttonpress_NOSEL ()
{
struct listbox_prop answer;
const struct listbox_prop init={LB_ERR,LB_ERR,0}, click={1,1,1}, down={2,2,2};
HWND hLB=create_listbox (LBS_NOSEL);
listbox_query (hLB, &answer);
listbox_ok (init, answer);
buttonpress(hLB, 8, 16);
listbox_query (hLB, &answer);
listbox_ok (click, answer);
keypress (hLB, VK_DOWN, 0x50, 1);
listbox_query (hLB, &answer);
listbox_ok (down, answer);
assert (DestroyWindow (hLB));
}
START_TEST(listbox)
{
check_buttonpress ();
check_buttonpress_NOSEL ();
}
More information about the wine-devel
mailing list