New conformance test for user32.dll

Ferenc Wagner wferi at
Tue Mar 4 16:40:54 CST 2003

Tony Lambregts <tony_lambregts at> writes:

> Patches should be in diff -u format. Please refer to the
> following link about submitting patches.

Er... I didn't mean it to be submitted right now, only
getting some comments on it (thanks!).  But below is the
patch nevertheless (the new listbox.c file is attached).
Reading the devel list it also became obvious that there is
wine-patches, where I should send the final patches, should
I?  So: is this kind of hackery acceptable for eventual
inclusion?  If nobody objects, I will go on improving it (I
already did so) and occasionally send it to wine-patches.
Hmm.  What is that "patch Patch police"? :)


Ps: If anybody wants to try, (s)he will probably need to
apply this patch to Makefile instead (or run configure).
That's why I included a note instead of a patch previously.

RCS file: /home/wine/wine/dlls/user/tests/,v
retrieving revision 1.3
diff -u -r1.3
--- 2 Oct 2002 19:58:28 -0000       1.3
+++ 4 Mar 2003 22:36:41 -0000
@@ -8,6 +8,7 @@
        class.c \
        generated.c \
+       listbox.c \
        sysparams.c \
        win.c \

-------------- next part --------------
#include "wine/test.h"
#include "windows.h"
#include "assert.h"
#include "unistd.h"

create_listbox (DWORD add_style, BOOL visible)
  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"));

  if (visible) {
    assert (!ShowWindow (handle, SW_SHOW));
    assert (RedrawWindow (handle, NULL, 0, RDW_UPDATENOW));
  return handle;

struct listbox_prop {
  int selected;
  int anchor;
  int caret;

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(style, ex, got) \
  ok (ex.selected==got.selected && \
      ex.anchor==got.anchor && \
      ex.caret==got.caret, \
      "style %#x: expected {s=%d,a=%d,c=%d}, got {s=%d,a=%d,c=%d}", \
      (unsigned int)style, \
      ex.selected, ex.anchor, ex.caret, \
      got.selected, got.anchor, got.caret)

buttonpress (HWND handle, WORD x, WORD y, BOOL visible)
  LPARAM lp=x+(y<<16);

  if (visible)
    sleep (1);
  assert (!SendMessage (handle, WM_LBUTTONDOWN, (WPARAM) MK_LBUTTON, lp));
  assert (!SendMessage (handle, WM_LBUTTONUP  , (WPARAM) 0         , lp));
  if (visible)
    assert (RedrawWindow (handle, NULL, 0, RDW_UPDATENOW));

keypress (HWND handle, WPARAM keycode, BYTE scancode,
          BOOL extended, BOOL visible)
  LPARAM lp=1+(scancode<<16)+(extended?KEYEVENTF_EXTENDEDKEY:0);

  if (visible)
    sleep (1);
  assert (!SendMessage (handle, WM_KEYDOWN, keycode, lp));
  assert (!SendMessage (handle, WM_KEYUP  , keycode, lp | 0xc000000));
  if (visible)
    assert (RedrawWindow (handle, NULL, 0, RDW_UPDATENOW));

check (DWORD add_style, BOOL visible)
  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 (add_style, visible);
  RECT second_item;

  listbox_query (hLB, &answer);
  listbox_ok (add_style, init, answer);

  assert (SendMessage (hLB, LB_GETITEMRECT, (WPARAM) 1,
                       (LPARAM) &second_item));
  buttonpress(hLB, second_item.left,, visible);

  listbox_query (hLB, &answer);
  listbox_ok (add_style, click, answer);

  keypress (hLB, VK_DOWN, 0x50, TRUE, visible);

  listbox_query (hLB, &answer);
  listbox_ok (add_style, down, answer);

  if (visible)
    sleep (1);
  assert (DestroyWindow (hLB));

  check (0, FALSE);
  check (LBS_NOSEL, FALSE);

More information about the wine-devel mailing list