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++) {
listeners[i]->selectionChanged(this);
}
}
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?
