user32: Add a test for the menu resource loader, make it pass under Wine.
This commit is contained in:
parent
7f189eccb9
commit
34015b93a4
|
@ -2032,6 +2032,8 @@ static BOOL MENU_SetItemData( MENUITEM *item, UINT flags, UINT_PTR id,
|
|||
item->text = NULL;
|
||||
}
|
||||
|
||||
if (flags & MF_SEPARATOR) flags |= MF_GRAYED | MF_DISABLED;
|
||||
|
||||
if (flags & MF_OWNERDRAW)
|
||||
item->dwItemData = (DWORD_PTR)str;
|
||||
else
|
||||
|
|
|
@ -1914,9 +1914,7 @@ static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type,
|
|||
|
||||
if (mii.fType == MFT_SEPARATOR)
|
||||
{
|
||||
todo_wine {
|
||||
ok(mii.fState == MFS_GRAYED, "id %u: expected fState MFS_GRAYED, got %04x\n", checked_cmd, mii.fState);
|
||||
}
|
||||
ok(mii.wID == 0, "id %u: expected wID 0, got %u\n", checked_cmd, mii.wID);
|
||||
}
|
||||
else
|
||||
|
@ -1988,6 +1986,89 @@ static void test_CheckMenuRadioItem(void)
|
|||
check_menu_items(hmenu, -1, 0, 0);
|
||||
}
|
||||
|
||||
static void test_menu_resource_layout(void)
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
MENUITEMTEMPLATEHEADER mith;
|
||||
WORD data[];
|
||||
} menu_template =
|
||||
{
|
||||
{ 0, 0 }, /* versionNumber, offset */
|
||||
{
|
||||
/* mtOption, mtID, mtString[] '\0' terminated */
|
||||
MF_STRING, 1, 'F', 0,
|
||||
MF_STRING, 2, 0,
|
||||
MF_SEPARATOR, 3, 0,
|
||||
/* MF_SEPARATOR, 4, 'S', 0, FIXME: Wine ignores 'S' */
|
||||
MF_STRING|MF_GRAYED|MF_END, 5, 'E', 0
|
||||
}
|
||||
};
|
||||
static const struct
|
||||
{
|
||||
UINT type, state, id;
|
||||
const char *str;
|
||||
} menu_data[] =
|
||||
{
|
||||
{ MF_STRING, MF_ENABLED, 1, "F" },
|
||||
{ MF_SEPARATOR, MF_GRAYED|MF_DISABLED, 2, "" },
|
||||
{ MF_SEPARATOR, MF_GRAYED|MF_DISABLED, 3, "" },
|
||||
/*{ MF_SEPARATOR, MF_GRAYED|MF_DISABLED, 4, "S" }, FIXME: Wine ignores 'S'*/
|
||||
{ MF_STRING, MF_GRAYED, 5, "E" },
|
||||
{ MF_SEPARATOR, MF_GRAYED|MF_DISABLED, 6, "" },
|
||||
{ MF_STRING, MF_ENABLED, 7, "" },
|
||||
{ MF_SEPARATOR, MF_GRAYED|MF_DISABLED, 8, "" }
|
||||
};
|
||||
HMENU hmenu;
|
||||
UINT count, i;
|
||||
BOOL ret;
|
||||
|
||||
hmenu = LoadMenuIndirect(&menu_template);
|
||||
ok(hmenu != 0, "LoadMenuIndirect error %u\n", GetLastError());
|
||||
|
||||
ret = AppendMenu(hmenu, MF_STRING, 6, NULL);
|
||||
ok(ret, "AppendMenu failed\n");
|
||||
ret = AppendMenu(hmenu, MF_STRING, 7, "\0");
|
||||
ok(ret, "AppendMenu failed\n");
|
||||
ret = AppendMenu(hmenu, MF_SEPARATOR, 8, "separator");
|
||||
ok(ret, "AppendMenu failed\n");
|
||||
|
||||
count = GetMenuItemCount(hmenu);
|
||||
ok(count == sizeof(menu_data)/sizeof(menu_data[0]),
|
||||
"expected %u menu items, got %u\n",
|
||||
(UINT)sizeof(menu_data)/sizeof(menu_data[0]), count);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
char buf[20];
|
||||
MENUITEMINFO mii;
|
||||
|
||||
memset(&mii, 0, sizeof(mii));
|
||||
mii.cbSize = sizeof(mii);
|
||||
mii.dwTypeData = buf;
|
||||
mii.cch = sizeof(buf);
|
||||
mii.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_ID | MIIM_STRING;
|
||||
ret = GetMenuItemInfo(hmenu, i, TRUE, &mii);
|
||||
ok(ret, "GetMenuItemInfo(%u) failed\n", i);
|
||||
#if 0
|
||||
trace("item #%u: fType %04x, fState %04x, wID %u, dwTypeData %s\n",
|
||||
i, mii.fType, mii.fState, mii.wID, (LPCSTR)mii.dwTypeData);
|
||||
#endif
|
||||
ok(mii.fType == menu_data[i].type,
|
||||
"%u: expected fType %04x, got %04x\n", i, menu_data[i].type, mii.fType);
|
||||
ok(mii.fState == menu_data[i].state,
|
||||
"%u: expected fState %04x, got %04x\n", i, menu_data[i].state, mii.fState);
|
||||
ok(mii.wID == menu_data[i].id,
|
||||
"%u: expected wID %04x, got %04x\n", i, menu_data[i].id, mii.wID);
|
||||
ok(mii.cch == strlen(menu_data[i].str),
|
||||
"%u: expected cch %u, got %u\n", i, (UINT)strlen(menu_data[i].str), mii.cch);
|
||||
ok(!strcmp((LPCSTR)mii.dwTypeData, menu_data[i].str),
|
||||
"%u: expected dwTypeData %s, got %s\n", i, menu_data[i].str, (LPCSTR)mii.dwTypeData);
|
||||
}
|
||||
|
||||
DestroyMenu(hmenu);
|
||||
}
|
||||
|
||||
START_TEST(menu)
|
||||
{
|
||||
pSetMenuInfo =
|
||||
|
@ -2007,4 +2088,5 @@ START_TEST(menu)
|
|||
test_menu_flags();
|
||||
test_menu_hilitemenuitem();
|
||||
test_CheckMenuRadioItem();
|
||||
test_menu_resource_layout();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue