JComboBoxFixture.selectItem() does not set focus on ComboBox

Open
#271 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
desktop, testing

Research direction

Start with JComboBoxFixture.selectItem(), then trace the related JComboBoxDriver and JComboBoxSetSelectedIndexTask mentioned in the issue. Compare their behavior with the JButton.doClick() focus behavior. Done means selecting an item gives the ComboBox the focus expected from a user action and the relevant tests pass.

Written by the indexing model from the issue text.

Description

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...?

Dominant language
Java
Stars
121
Forks
52
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from assertj/assertj-swing

All issues in assertj/assertj-swing

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.