Re: user32: understanding the HiliteMenuItem failures (all platforms)... call for help

2008-01-29 Thread Reece Dunn
On 26/01/2008, Reece Dunn <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am currently looking at the user32: menu (HiliteMenuItem) test failures:
>
> menu.c:1884: Test failed: HiliteMenuItem: Item 1 is not hilited
> menu.c:1891: Test failed: HiliteMenuItem: Item 3 is not hilited
>
> 1.  These are failing consistently on all platforms (see
> http://test.winehq.org/data/200801161000 - you may need to search for
> HiliteMenuItem to find the failures!).
>
> 2.  It appears (backed up with tests in the attached patch) that the
> API fails when the HWND parameter is NULL.
>
> 3.  The tests are not comprehensive enough.
>
> The patch I have attached here is still a work in progress:

see previous e-mail for the patch.

> 1.  I have not tested it on Wine - it is likely that this will require
> todo_wine markers to make it run successfully.
>
> 2.  The tests are still failing on Windows (both XP and Vista).
>
> Here is where I get stuck. According to the MDSN documentation (which
> is likely to be wrong) this appears to be correct.
>
> Does anyone know how to get HiliteMenuItem to work?!

Any ideas?

- Reece




user32: understanding the HiliteMenuItem failures (all platforms)... call for help

2008-01-26 Thread Reece Dunn
Hi,

I am currently looking at the user32: menu (HiliteMenuItem) test failures:

menu.c:1884: Test failed: HiliteMenuItem: Item 1 is not hilited
menu.c:1891: Test failed: HiliteMenuItem: Item 3 is not hilited

1.  These are failing consistently on all platforms (see
http://test.winehq.org/data/200801161000 - you may need to search for
HiliteMenuItem to find the failures!).

2.  It appears (backed up with tests in the attached patch) that the
API fails when the HWND parameter is NULL.

3.  The tests are not comprehensive enough.

The patch I have attached here is still a work in progress:

1.  I have not tested it on Wine - it is likely that this will require
todo_wine markers to make it run successfully.

2.  The tests are still failing on Windows (both XP and Vista).

Here is where I get stuck. According to the MDSN documentation (which
is likely to be wrong) this appears to be correct.

Does anyone know how to get HiliteMenuItem to work?!

- Reece
From e607b6e4580099dd7bb244b55d7bad725a6bda5a Mon Sep 17 00:00:00 2001
From: Reece H. Dunn <[EMAIL PROTECTED]>
Date: Sat, 26 Jan 2008 15:29:22 +
Subject: [PATCH] user32: menu improve the HiliteMenuItem tests.

---
 dlls/user32/tests/menu.c |   63 ++---
 1 files changed, 53 insertions(+), 10 deletions(-)

diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c
index cb37ac0..e27b95c 100644
--- a/dlls/user32/tests/menu.c
+++ b/dlls/user32/tests/menu.c
@@ -1864,6 +1864,7 @@ static void test_menu_flags( void )
 static void test_menu_hilitemenuitem( void )
 {
 HMENU hMenu, hPopupMenu;
+HWND hwnd;
 
 hMenu = CreateMenu();
 hPopupMenu = CreatePopupMenu();
@@ -1874,25 +1875,67 @@ static void test_menu_hilitemenuitem( void )
 AppendMenu(hPopupMenu, MF_STRING, 102, "Item 2");
 AppendMenu(hPopupMenu, MF_STRING, 103, "Item 3");
 
-HiliteMenuItem(NULL, hPopupMenu, 0, MF_HILITE);
-HiliteMenuItem(NULL, hPopupMenu, 1, MF_HILITE);
-HiliteMenuItem(NULL, hPopupMenu, 2, MF_HILITE);
-HiliteMenuItem(NULL, hPopupMenu, 1, MF_UNHILITE);
+hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL,
+  WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200,
+  NULL, hMenu, NULL, NULL);
+ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
+
+/* no window */
+
+SetLastError(0xdeadbeef);
+ok(!HiliteMenuItem(NULL, hPopupMenu, 0, MF_HILITE),
+  "HiliteMenuItem: hilite state set\n");
+ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE,
+  "HiliteMenuItem: expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", 
GetLastError());
+
+/* initial state -- not hilited */
+
+ok(!(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_HILITE),
+  "HiliteMenuItem: Item 1 is hilited\n");
+
+/* not hilited -- don't change the hilited state */
+
+SetLastError(0xdeadbeef);
+ok(!HiliteMenuItem(hwnd, hPopupMenu, 0, MF_UNHILITE),
+  "HiliteMenuItem: unhilite state set, got error %d\n", GetLastError());
+
+ok(!(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_HILITE),
+  "HiliteMenuItem: Item 1 is hilited, got error %d\n", GetLastError());
+
+/* hilited */
+
+SetLastError(0xdeadbeef);
+ok(HiliteMenuItem(hwnd, hPopupMenu, 0, MF_HILITE),
+  "HiliteMenuItem: hilite state not set, got error %d\n", GetLastError());
 
 todo_wine
 {
 ok(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_HILITE,
-  "HiliteMenuItem: Item 1 is not hilited\n");
+  "HiliteMenuItem: Item 1 is not hilited, got error %d\n", GetLastError());
 }
-ok(!(GetMenuState(hPopupMenu, 1, MF_BYPOSITION) & MF_HILITE),
-  "HiliteMenuItem: Item 2 is hilited\n");
+
+/* hilited -- don't change the hilited state */
+
+SetLastError(0xdeadbeef);
+ok(!HiliteMenuItem(hwnd, hPopupMenu, 0, MF_HILITE),
+  "HiliteMenuItem: hilite state set, got error %d\n", GetLastError());
+
 todo_wine
 {
-ok(GetMenuState(hPopupMenu, 2, MF_BYPOSITION) & MF_HILITE,
-  "HiliteMenuItem: Item 3 is not hilited\n");
+ok(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_HILITE,
+  "HiliteMenuItem: Item 1 is not hilited, got error %d\n", GetLastError());
 }
 
-DestroyMenu(hMenu);
+/* not hilited */
+
+SetLastError(0xdeadbeef);
+ok(HiliteMenuItem(hwnd, hPopupMenu, 0, MF_UNHILITE),
+  "HiliteMenuItem: unhilite state not set, got error %d\n", 
GetLastError());
+
+ok(!(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_HILITE),
+  "HiliteMenuItem: Item 1 is hilited, got error %d\n", GetLastError());
+
+DestroyWindow(hwnd);
 }
 
 static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type,
-- 
1.5.3.5