Bug 494917

Summary: Menu item can be shown without its parent menu showing
Product: [Mono] UI Automation Reporter: Brian Merrell <bgmerrell>
Component: Winforms - GeneralAssignee: Sanford Armstrong <saarmstrong>
Status: VERIFIED FIXED QA Contact: E-mail List <mono-a11y-qa>
Severity: Normal    
Priority: P3 - Medium    
Version: Release 1.0   
Target Milestone: Release 1.1   
Hardware: x86   
OS: openSUSE 11.1   
Whiteboard:
Found By: Integration Test Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Screenshot referenced in PROBLEM STATEMENT and RESULTS.

Description Brian Merrell 2009-04-14 21:45:19 UTC
PROBLEM STATEMENT

Assume there is a "File" menu on a MenuStrip for an application.  This "File" menu has a menu child named "New" that contains a menu item named "Document".  
This is the case with uia2atk/test/samples/menustrip.py.

The problem is that the the "Document" menu item can be shown without its parent menu being shown.  Simply put, the "Document" menu item will appears in the GUI where it would be if the user navigating to it manually using the mouse or keyboard.  The attached screenshot illustrates this.

REPRO

1.  Run Accerciser and open the "IPython Console" tab
2.  Run uia2atk/test/samples/menustrip.py
3.  If Bug 494586 is open, click on the "File" menu twice to open and close it.  This will prevent the application from crashing in step 5
4.  In Accerciser, browse to and select the "File" menu accessible.
5.  In Accerciser's IPython console, run the following:

acc.querySelection().selectChild(0)

This will select the first child of the "File" menu accessible, which is the "Document" menu item.

RESULTS

The "Document" menu item appears in the GUI where it would be if the user navigating to it manually using the mouse or keyboard.

See attached screenshot.  

EXPECTED RESULTS

Gtk does some weird things too when using selectChild to select menus and menu items.  But it appears to simply ignore attempts to select a menu item unless its parent menu showing.  I like that idea.

COMMENTS

This is related to Bug 494586, which is about the application crashing if REPRO step 3 is not followed.
Comment 1 Brian Merrell 2009-04-14 21:47:07 UTC
Created attachment 285700 [details]
Screenshot referenced in PROBLEM STATEMENT and RESULTS.
Comment 2 Brian Merrell 2009-04-16 16:58:29 UTC
Hmm.. I just noticed something interested about the Gtk behavior.  I said in the original EXPECTED RESULTS that "[Gtk] appears to simply ignore attempts to select a menu item unless its parent menu showing."  This may not be true, however.  It looks like the menu accessible being selected does at least handle the query, and doesn't ignore it altogether.  To illustrate this you can do the following:

1.  Open Accerciser and click on the "IPython Console" tab
2.  Run uia2atk/test/samples/gtkmenubar.py
3.  Browse the gtkmenubar.py application's hierarchy in Accerciser and notice that the "File" menu's 2nd child is an "Open Recent" menu
4.  Select the "File" menu in Accerciser
5.  Run the following in the IPython Console:

acc.querySelection().selectChild()

6.  Notice that the label at the bottom of the menubar.py application changes to "You selected: Open Recent"

For reference, here is the event handler in the menubar.py app:

open_recent_item.connect("activate", self.on_activate)
Comment 3 Ray Wang 2009-04-17 03:05:26 UTC
Hey Brad, from your instructions, I got:

"TypeError: wrong number of arguments: expected 2, got 1"

after I run 
"acc.querySelection().selectChild()"

I guess you miss a parameter, so I add it as:

acc.querySelection().selectChild(1)

it returns true, but label is not changed.
Comment 4 Sanford Armstrong 2009-04-29 08:09:41 UTC
This is fixed by the same pending patch as in bug #494586:

http://reviews.mono-a11y.org/r/168/
Comment 5 Sanford Armstrong 2009-04-29 17:03:31 UTC
Fixed in UIAutomationWinforms (trunk r133036, 1.0 r133037).
Comment 6 Brian Merrell 2009-05-05 17:11:51 UTC
I think this bug report is invalid:

10:37 <@bgmerrell> sandy: i think 494917 is invalid
10:37 <@bgmerrell> sandy: :( i can do the same thing in Gtk
10:37 <@bgmerrell> i'm a dolt
10:38 <@sandy> well, for some of these, we may have to show all parent items in 
               order to perform the action correctly
10:38 <@sandy> (not 100% sure)
10:40 <@bgmerrell> sandy: well, if you take gtkmenubar.py and use accerciser to 
                   perform a 'click' action on the "Open Recent" menu, that 
                   menu's children will appear and be floating without the 
                   parent menu

We should probably roll it back, especially if it means fixing Bug 501074.
Comment 7 Feng Xia Mu 2009-06-08 03:19:20 UTC
hi, the bug is deal with as:
Menu item won't be shown if its parent menu isn't showing.

do as following:
1.  Run Accerciser and open the "IPython Console" tab
2.  Run uia2atk/test/samples/menustrip.py
3.  In Accerciser, browse to and select the "File" menu accessible.
4.  In Accerciser's IPython console, run the following:
    acc.querySelection().selectChild(0)

result:
   
    the "New" menu and "Document" menu item both won't show. 

I hope when we do "acc.querySelection().selectChild(0)", the "New" menu and its menu item both will show, but in GTK sample if we do the same action, the query menu and menu item will not showing too, so I think the "result" is acceptable, so close this bug.
Comment 8 Feng Xia Mu 2009-06-08 06:02:50 UTC
close in:
mono-core-135601-1177.src.rpm
mono-uia-132785-276.src.rpm
uiaatkbridge-134036-662.src.rpm
uiautomationwinforms-134512-668.src.rpm
Revision: 135624