## page was renamed from DesktopExperienceTeam/ApplicationMenuXDTests
== Goals ==
Ensuring cross-desktop (XD) compatibility of the application menu. The menubar of a GTK-based application should be correctly displayed in a KDE desktop and the menubar of a Qt-based application should be correctly displayed in a GNOME desktop.
== Comparing menubars presented by the applets ==
=== Compare menubars at startup ===
1. Add a "!DumpCurrentMenuBar() -> string" DBus method to both menubar applets to dump the menubar in JSON format. The dump code should implement its own traversal of the menubar hierarchy and should ''not'' rely on DBusMenu. This way we can ensure the dump is as close as possible to what is presented to the user.<
>To avoid adding a dependency on a JSON lib to the final product, this method should only be compiled in when applets are build with a specific flag.
1. Create a tool which can start an application with each applet, dump the menubars and report any difference. Expected usages:
{{{
# Start application with both applets, compare the menubars and output the diff
menubar-test compare /path/to/application [application [args]]
# Start application with KDE applet and dump the menubar to kde.log
menubar-test dump --kde=kde.log /path/to/application
# Start application with both applets and dump the menubars
menubar-test dump --kde=kde.log --gnome=gnome.log /path/to/application
}}}
=== Test dynamic menus or radio/checkbox items ===
1. Add a "!ActivateMenuBarItem(list)" DBus method so that it's possible to programatically open submenus or activate menu items.
1. Extend the test tool so that it can open menu bar items, dumping the menubars at each step. This makes it possible to test dynamic menus. Expected usage:
{{{
# Assuming a file hierarchy like this:
# File
# Open
# Close
# View
# (o) Detail
# ( ) Icon
# ( ) Preview
# Dynamic
# ...
#
# Start application and opens the "Dynamic" submenu:
menubar-test compare --activate 2 /path/to/application
# Start application and change the view mode to "Preview":
menubar-test compare --activate 1,2 /path/to/application
}}}
== Simulating menubars ==
It is already possible to dump the menubar of an application via dbusmenu-dumper. We should create a menubar-loader which loads the dump and recreates the menubar, making it quick to test specific situations. This application can also be run from menubar-test.
=== JSON format ===
We should standardize on the format generated by dbusmenu-dumper. Format should look like this:
{{{
[
{
"id": 1,
"label": "_File",
"submenu": [
{
"id": 10,
"label": "_Open",
"shortcut": [["Control", "O"]]
},
{
"id": 11,
"label": "_Close",
"enabled": false
}
]
},
{
"id": 2,
"label": "_Settings",
"submenu": [
{
"id": 20,
"label": "Show Toolbar",
"toggle-type": "checkmark",
"toggle-state": 1
}
]
}
]
}}}