assertj-swing icon indicating copy to clipboard operation
assertj-swing copied to clipboard

JComboBoxFixture.selectItem() does not set focus on ComboBox

Open p10n opened this issue 2 years ago • 3 comments

I get failing tests even though my code is fine; the test is failing because JComboBoxFixture.selectItem() does not set focus on the ComboBox (as a user action would do).

(Background info: I am relying on the focus of ComboBoxes (or any of their subcomponents) as a trick to detect whether ActionPerformed or ItemStateChanged events are "real" ones (resulting from user actions) or "superfluous" ones (that ComboBoxes tend to throw on other inappropriate occasions.)

I verified this by debug output, but also when (visually) watching the test runnning, I notice that other UI elements (e.g. buttons) get a painted focus, while the combobox does not. My colleague @Gleethos had a look at JComboBoxDriver and JComboBoxSetSelectedIndexTask, and we think that there should be some code setting focus (like an analogon to JButton.doClick(), which does set the focus for buttons).

P.S. If this is welcome, we could try to add/fix it and create a pull-request...?

p10n avatar Sep 14 '22 11:09 p10n

Any update on this?

stodge avatar Feb 08 '24 15:02 stodge

We are still using a workaround...

p10n avatar Feb 15 '24 07:02 p10n

Hi @p10n and @stodge, apologies for the lack of feedback, we're a bit short on capacity especially for assertj-swing.

I'll reserve some time in the upcoming weeks to bring this project back to life and follow up on topics like #264.

scordio avatar Feb 15 '24 07:02 scordio