Generate mouse events in order to test components



I have been attempting to write unit tests that will automatically check the UI of a project I’m working on. I’m trying to test whether the multipleSelectionsEnabled feature of the Listbox class works properly. In order to do this I need to somehow simulate a MouseEvent to simulate a click on a row of the ListBox. However after some research I see that there’s no constructor for a MouseEvent, so I cannot call the function below.

void ToggleableSet::cellClicked(int row, int column, const MouseEvent &me)
for (int i = 0; i < listeners.size(); i++) {

I inherited the code so I cannot change it, so I am looking for a way to generate a MouseEvent somehow that I can pass in as an argument. NULL and nullptr do not work.

Does anyone have any suggestions or experience with unit testing this kind of thing?


Was actually thinking about this earlier today. Have you seen this post? Testing, FontAwesome and some code