Rein Klazes : user32/tests: Show that Windows avoids creating loops in a menu tree, probably by limiting the depth of such tree.

Alexandre Julliard julliard at winehq.org
Fri Jul 17 09:03:42 CDT 2009


Module: wine
Branch: master
Commit: 5b4b1e6a67474317181e689aa0d6587758d5dcf2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5b4b1e6a67474317181e689aa0d6587758d5dcf2

Author: Rein Klazes <wijn at online.nl>
Date:   Thu Jul 16 12:30:29 2009 +0200

user32/tests: Show that Windows avoids creating loops in a menu tree, probably by limiting the depth of such tree.

---

 dlls/user32/tests/menu.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c
index 0948f69..868fd9a 100644
--- a/dlls/user32/tests/menu.c
+++ b/dlls/user32/tests/menu.c
@@ -2932,6 +2932,63 @@ static void test_menu_cancelmode(void)
     DestroyWindow( hwnd);
 }
 
+/* show menu trees have a maximum depth */
+static void test_menu_maxdepth(void)
+{
+#define NR_MENUS 100
+    HMENU hmenus[ NR_MENUS];
+    int i;
+    DWORD ret;
+
+    for( i = 0; i < NR_MENUS; i++) {
+        hmenus[i] = CreatePopupMenu();
+        if( !hmenus[i]) break;
+    }
+    ok( i == NR_MENUS, "could not create more then %d menu's\n", i);
+    for( i = 1; i < NR_MENUS; i++) {
+        ret = AppendMenuA( hmenus[i], MF_POPUP, (UINT_PTR)hmenus[i-1],"test");
+        if( !ret) break;
+    }
+    trace("Maximum depth is %d\n", i);
+todo_wine
+    ok( i < NR_MENUS ||
+           broken( i == NR_MENUS), /* win98, NT */
+           "no ( or very large) limit on menu depth!\n");
+
+    for( i = 0; i < NR_MENUS; i++)
+        DestroyMenu( hmenus[i]);
+}
+
+/* bug #12171 */
+static void test_menu_circref(void)
+{
+    HMENU menu1, menu2;
+    DWORD ret;
+
+    menu1 = CreatePopupMenu();
+    menu2 = CreatePopupMenu();
+    ok( menu1 && menu2, "error creating menus.\n");
+    ret = AppendMenuA( menu1, MF_POPUP, (UINT_PTR)menu2, "winetest");
+    ok( ret, "AppendMenu failed, error is %d\n", GetLastError());
+    ret = AppendMenuA( menu1, MF_STRING | MF_HILITE, 123, "winetest");
+    ok( ret, "AppendMenu failed, error is %d\n", GetLastError());
+    /* app chooses an id that happens to clash with its own hmenu */
+    ret = AppendMenuA( menu2, MF_STRING, (UINT_PTR)menu2, "winetest");
+    ok( ret, "AppendMenu failed, error is %d\n", GetLastError());
+    /* now attempt to change the string of the first item of menu1 */
+    ret = ModifyMenuA( menu1, (UINT_PTR)menu2, MF_POPUP, (UINT_PTR)menu2, "menu 2");
+todo_wine
+    ok( !ret ||
+            broken( 0), /* win98, NT */
+            "ModifyMenu should have failed.\n");
+    if( !ret) { /* will probably stack fault if the ModifyMenu succeeded */
+        ret = GetMenuState( menu1, 123, 0);
+        ok( ret == MF_HILITE, "GetMenuState returned %x\n",ret);
+    }
+    DestroyMenu( menu2);
+    DestroyMenu( menu1);
+}
+
 START_TEST(menu)
 {
     init_function_pointers();
@@ -2970,4 +3027,6 @@ START_TEST(menu)
     test_menu_hilitemenuitem();
     test_menu_trackpopupmenu();
     test_menu_cancelmode();
+    test_menu_maxdepth();
+    test_menu_circref();
 }




More information about the wine-cvs mailing list