
user: extend conformance test for menu access from a remote process
The following series of patches move menu and menu item data into the server.
Conformance tests pass between each patch, and the major bottleneck in
tested applications was addressed so that application menus feel just as
responsive.
[rediffed - dank]

Thomas Kho

---

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

diff --git a/dlls/user/tests/menu.c b/dlls/user/tests/menu.c
index 01b113b..10a29a8 100644
--- a/dlls/user/tests/menu.c
+++ b/dlls/user/tests/menu.c
@@ -1840,6 +1840,89 @@ void test_menu_hilitemenuitem( void )
     DestroyMenu(hMenu);
 }
 
+static void test_menu_remote_process()
+{
+    char wndTitle[30];
+    int nMenu;
+    DWORD oldMenuData;
+    HMENU hMenu;
+    HWND hNotepad;
+    MENUITEMINFO mii;
+    MENUINFO mi;
+    PROCESS_INFORMATION pi;
+    STARTUPINFO si;
+
+    memset(&si, 0, sizeof(si));
+    si.cb = sizeof(si);
+    ok (CreateProcess(NULL, "notepad.exe", NULL, NULL, FALSE, 0, NULL, NULL,
+                      &si, &pi),
+        "CreateProcess error=%ld\n", GetLastError());
+
+    ok (!WaitForInputIdle(pi.hProcess, 10000), "error=%ld\n", GetLastError());
+    hNotepad = GetForegroundWindow();
+    ok ((int) hNotepad, "can't get foreground window\n");
+    ok (GetWindowText(hNotepad, wndTitle, 30), "error=%ld\n", GetLastError());
+    ok ((int) strstr(wndTitle, "Notepad"), "can't find notepad window\n");
+
+    hMenu = GetMenu(hNotepad);
+    ok ((int) hMenu, "GetMenu failed\n");
+    nMenu = GetMenuItemCount(hMenu);
+    /* notepad.exe menus slightly differ in Wine and Windows */
+    todo_wine ok(nMenu == 4 || nMenu == 5, "nMenu = %d, error=%ld\n", nMenu,
+       GetLastError());
+
+    memset(&mii, 0, sizeof(mii));
+    mii.cbSize = sizeof(MENUITEMINFO);
+    mii.fMask = MIIM_STRING;
+    mii.dwTypeData = NULL;
+    todo_wine ok (GetMenuItemInfo(hMenu, 0, TRUE, &mii),
+        "error=%ld\n", GetLastError());
+    mii.dwTypeData = malloc(++mii.cch);
+    todo_wine ok (GetMenuItemInfo(hMenu, 0, TRUE, &mii),
+        "error=%ld, dwTypeData='%s'\n", GetLastError(), mii.dwTypeData);
+    todo_wine ok (mii.dwTypeData && !strcmp(mii.dwTypeData, "&File"),
+        "error=%ld, dwTypeData='%s'\n", GetLastError(), mii.dwTypeData);
+    free(mii.dwTypeData);
+
+    mii.cbSize = sizeof(MENUITEMINFO);
+    mii.fMask = MIIM_STRING;
+    mii.dwTypeData = "&New File Menu";
+    todo_wine ok (SetMenuItemInfo(hMenu, 0, TRUE, &mii), "error=%ld\n",
+         GetLastError());
+    DrawMenuBar(hNotepad);
+
+    memset(&mii, 0, sizeof(mii));
+    mii.cbSize = sizeof(MENUITEMINFO);
+    mii.fMask = MIIM_STRING;
+    mii.dwTypeData = NULL;
+    todo_wine ok (GetMenuItemInfo(hMenu, 0, TRUE, &mii),
+        "error=%ld\n", GetLastError());
+    mii.dwTypeData = malloc(++mii.cch);
+    todo_wine ok (GetMenuItemInfo(hMenu, 0, TRUE, &mii),
+        "error=%ld, dwTypeData='%s'\n", GetLastError(), mii.dwTypeData);
+    todo_wine ok (mii.dwTypeData && !strcmp(mii.dwTypeData, "&New File Menu"),
+        "error=%ld, dwTypeData='%s'\n", GetLastError(), mii.dwTypeData);
+    free(mii.dwTypeData);
+
+    mi.cbSize = sizeof(MENUINFO);
+    mi.fMask = MIM_MENUDATA;
+    todo_wine ok (GetMenuInfo(hMenu, &mi), "error=%ld\n", GetLastError());
+    oldMenuData = mi.dwMenuData;
+    mi.dwMenuData = !mi.dwMenuData;
+    todo_wine ok (SetMenuInfo(hMenu, &mi), "error=%ld\n", GetLastError());
+    todo_wine ok (GetMenuInfo(hMenu, &mi), "error=%ld\n", GetLastError());
+    ok (oldMenuData != mi.dwMenuData, "oldMenuData=%ld, dwMenuData=%ld\n",
+        oldMenuData, mi.dwMenuData);
+
+    ok (SetMenu(hNotepad, NULL), "error=%ld\n", GetLastError());
+    hMenu = GetMenu(hNotepad);
+    ok (hMenu == NULL, "GetMenu failed\n");
+
+    TerminateProcess(pi.hProcess, 0);
+    CloseHandle(pi.hProcess);
+    CloseHandle(pi.hThread);
+}
+
 START_TEST(menu)
 {
     pSetMenuInfo =
@@ -1858,4 +1941,5 @@ START_TEST(menu)
     test_menu_input();
     test_menu_flags();
     test_menu_hilitemenuitem();
+    test_menu_remote_process();
 }
