Menu

#77 find JMenu index figured wrong

open
nobody
None
5
2005-12-12
2005-12-12
saaker
No

jfcunit version: 2.08

Overview:

There are two windows on the desktop, each with a menu
with the same text lable. The text label is "View". One
View Menu is the desired View Menu. Both the recorder
and player know the window the desired View Menu is in.
This will be referred to as the "known window". To
figure the index, the recorder ignores the known window
and does a search through all the windows present for
View Menus. Since there are two windows with a View
Menu and the desired View Menu is the 2nd one come
upon, the index is figured to be one.

On the other hand, the player assumes the index refers
to just occurances in the Known Window. Since there is
only one View Menu in the Known Window and it is the
desired View Menu, it expects an index of zero.

Detailed Explaination:

XML Element in Error:

XMLRecorder produced
<find container="JFrame5" finder="JMenuItemFinder"
id="MenuItem7" index="1" label="View" operation="equals"/>
The Player expected element would be:
<find container="JFrame5" finder="JMenuItemFinder"
id="MenuItem7" index="0" label="View" operation="equals"/>
The difference is the "index" of 1 in the case of the
XMLRecorder and 0 in the case of the player.

Programming impacted:

The playback method Finder.find(final Container[]
conts, final int index) has the container JFrame5. So
it expects the index to be limited to just the one
window. It is expecting an index of zero as the desired
View Menu is the only View Menu in JFrame5.

However XMLRecorder delivers an index of one, Method
XMLRecorder.generateMenuFind(final Component comp) has
the following line of code,
TestHelper.indexOf(finder, null, comp)
which calls the following method signature,
TestHelper.indexOf(final Finder finder, final Container
cont,
final Component comp).
Since Container cont is null, TestHelper.indexOf looks
through all the windows to figure the index.
containers = getAllWindows() is the code executed in
TestHelper.indexOf.

I hope this helps jfcunit be a better product. Thank
you for jfcunit.

Discussion


Log in to post a comment.