Bug 489387

Summary: DbusCoreUiaSource: Implement AutomationElement.FromHandle
Product: [Mono] UI Automation Reporter: Brad Taylor <btaylor1>
Component: Client - UIAAssignee: E-mail List <mono-a11y-bugs>
Status: CONFIRMED --- QA Contact: E-mail List <mono-a11y-qa>
Severity: Enhancement    
Priority: P4 - Low    
Version: Unspecified   
Target Milestone: Release 2.1   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Untested patch

Description Brad Taylor 2009-03-26 15:53:38 UTC
Implement the AutomationElement class's FromHandle method.
Comment 1 Sanford Armstrong 2009-10-21 21:16:19 UTC
Created attachment 323543 [details]
Untested patch

I started implementing this because the old UIAutomationWinformsClientTests use it, and I thought they would be useful to run.  But I ran into some issues and then realized that they could be related to running the tests in the same process as the form, which I'm not ready to be testing.

But anyway, here's my work-in-progress, basically untested patch, which only implements it for UiaDbus.

Whoever picks up this bug may find this handy.
Comment 2 Sanford Armstrong 2009-11-24 02:20:59 UTC
Updating hours
Comment 3 Sanford Armstrong 2009-11-24 17:32:37 UTC
Committed, leaving open because I need to open some new bugs and don't want to forget (see review).
Comment 4 Rui Guo 2009-12-03 16:21:38 UTC
Currently we implement the FromHandle by reversely searching every AutomationElement's NativeWindowHandle property.
However, AutomationElements and native handles are not one-to-one mapped. It's possible for an AutomationElement to have several native window handles (including the one stored in NativeWindowHandle property).

E.g. with our SWF UIAutomationClientTests, the textBox1 control, which is 100 * 20 in pixel, actually consists of actally 2 windows (one for the body and the other one for the border):

0x7200030 (has no name): ()  100x20+102+56  +105+80
1 child:
    0x7200031 (has no name): ()  96x16+2+2  +107+82

textBox1's NativeWindowHandle is 0x7200031, however IMO, the result of FromHandle (new IntPtr(0x7200030)) shall not be null, but also be textBox1's AutomationElement.
Comment 5 Sanford Armstrong 2009-12-09 17:49:31 UTC
Adding some hours.