wxMaxima
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
test_MenuHelpString.cpp File Reference

Regression test for MenuHelpString() (the status-bar menu-help lookup). More...

#include <wx/app.h>
#include <wx/frame.h>
#include <wx/log.h>
#include <wx/menu.h>
#include "MenuHelpString.h"
#include <cstdlib>
#include <stdexcept>
#include <unistd.h>
#include <catch2/catch.hpp>
Include dependency graph for test_MenuHelpString.cpp:

Data Structures

class  TestApp
 

Functions

 SCENARIO ("MenuHelpString returns the help of a highlighted item")
 
 SCENARIO ("MenuHelpString never asserts on an id that is not in the menu")
 
 wxDECLARE_APP (TestApp)
 
int main (int argc, char **argv)
 

Detailed Description

Regression test for MenuHelpString() (the status-bar menu-help lookup).

wxMaxima shows a menu item's help string in the status bar while the item is highlighted. The old code called wxMenu::GetHelpString(), which in wxWidgets 3.3 asserts ("item" failed) when the highlighted id is not an item of that menu – a case the native menu code produces mostly on Windows (menu/submenu titles, ids belonging to another menu). That platform never reaches this test machine, so we reproduce the exact bad condition here deterministically: a throwing wxWidgets assert handler turns the assert into a catchable failure, and we look up an id that is not in the menu.

With the buggy GetHelpString() lookup this test fails on ANY platform whose wxWidgets has assertions enabled (both the Windows and the Linux CI); with the MenuHelpString() fix it passes.