Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Automation testing of Mindfusion Controls (Read 7448 times)
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Automation testing of Mindfusion Controls
Jul 1st, 2010 at 12:14pm
Print Post  
Hi,

I am testing an application that uses Mindfusion.Diagramming.DiagramView Class. In the application there is form of diagramView class which has a diagram and then nodes on the diagram. I have make my automation tool select the diagram nodes by text. e.g. if the node has text displayed 'If', it should select it.

I have added references of Mindfusion dlls that my application is using in my automation tool in order to use the exposed functions in my script.

Below function will fullfill my purpose:-
Public Shared Sub SelectRuleNode(ByVal diagram As Diagram, ByVal ruleLabel As String)


For Each node As DiagramNode In diagram.Nodes



'If node Is ShapeNode Then



If CType(node, ShapeNode).Text.ToLower.Equals(ruleLabel) Then


diagram.Selection.Clear()


diagram.Selection.AddItem(node)


Exit For


End If



'End If

Next
End Sub


To get the Diagram object I have to get the DiagramView object first.

My problem is that I am unable to get the diagramView object from the displayed form in the application. I can fetch the window handle of diagramView, when I pass this handle to

Dim dv As DiagramView = DiagramView.FromChildHandle(handle) , it returns Nothing (I am working in VB.Net)..........Can anyone help me in getting this right please.....Thanks, Divya
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automation testing of Mindfusion Controls
Reply #1 - Jul 1st, 2010 at 12:27pm
Print Post  
Hi,

Try using the Control.FromHandle() method instead of FromChildHandle().

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #2 - Jul 2nd, 2010 at 5:56am
Print Post  
Thanks for your reply Stoyan...

But I tried with DiagramView.FromHandle initially...but it returns nothing as well...then I switched to FromChildHandle.... Sad

Any help is appreciated....
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automation testing of Mindfusion Controls
Reply #3 - Jul 2nd, 2010 at 8:12am
Print Post  
The following works in my test, so I guess you don't have the correct window handle.

Code
Select All
Private Sub diagView_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles diagView.MouseDown
	Dim handle As IntPtr = diagView.Handle
	Dim view As DiagramView = Control.FromHandle(handle)
	Debug.Assert(diagView Is view)
End Sub
 



If you have a reference to the form object, another way to get the view is to loop over the form's Controls until you find a DiagramView instance.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #4 - Jul 5th, 2010 at 4:57am
Print Post  
Thanks for your reply Stoyan..

I reffered to SPY++ for the window handle of diagramView...It returns me value in hex which I converted to Dec and passed hardcoded to the FromHandle function just to check the return value.
Below is the code which I used...

Dim handle As IntPtr = 328896     '''Decimal of 504C0, as displayed in Spy++

Dim dv As DiagramView = DiagramView.FromHandle(handle)

I am getting the same window handle programmatically as well(through Process id, I have used UIAUtomationClient.dll's AutomationElement class as well...).

May be I am using the wrong one...but I have no way of finding the right window handle.... could you please give me a sample code to do that...

I am unable to attach the screenshot of SPY++ here to illustrate my problem better...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automation testing of Mindfusion Controls
Reply #5 - Jul 5th, 2010 at 8:47am
Print Post  
The handle returned by Spy++ is valid only during the execution of the current process. If you call FromHandle with the value given by Spy++ while the process runs, it works fine:

Code
Select All
Private Sub btnHandle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHandle.Click
	Dim handle As IntPtr = Integer.Parse(tbHandle.Text, Globalization.NumberStyles.HexNumber)
	Dim view As DiagramView = Control.FromHandle(handle)
	view.Diagram.BackBrush = New MindFusion.Drawing.SolidBrush(Color.Crimson)
End Sub 



If you have a reference to the form, you can loop over its controls and find the view by its type or Control.Name value. Or perhaps you could ask your developers to expose the view object as a property of the form.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #6 - Jul 7th, 2010 at 9:47am
Print Post  
Stoyan,

Even if I call FromHandle with the value given by Spy++ while the process is running, I am getting 'Nothing'....

Does this mean that the window handle I am using does not have any diagramView control associated with it? 

I have tried another way of getting the handle....

I used AutomationElement class of UIAutomationClient.dll to get the handle of diargamView...It goes as below...

Dim ae As AutomationElement = InfragisticsObjectHelper.GetElementByName(RootElement, "diagramView")

Dim handle As IntPtr = CType(ae.Current.NativeWindowHandle, IntPtr)

This also returns the same window handle which I am getting through SPY....

Could you please help me in identifying "what" is actually missing...why is the appropriate handle not exposed by the application...so that I can ask the developers to expose the required properties.

Thanks a lot for all your help...
  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #7 - Jul 15th, 2010 at 9:07am
Print Post  
Hi Stoyan,

Could you please help me in this further....
Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automation testing of Mindfusion Controls
Reply #8 - Jul 15th, 2010 at 12:06pm
Print Post  
If you know the name assigned to the control, such as "diagramView", you can use the method below to find it, e.g. starting from the form:

Code
Select All
Function FindChildControl(ByVal control As Control, ByVal name As String) As Control
	If control.Name = name Then Return control
	For Each child As Control In control.Controls
		Dim found As Control = FindChildControl(child, name)
		If found IsNot Nothing Then Return found
	Next
	Return Nothing
End Function

Dim v As DiagramView = CType(FindChildControl(mainForm, "diagView"), DiagramView)  



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #9 - Jul 20th, 2010 at 12:11pm
Print Post  
How do I retrieve the  "mainForm" control, to pass in below function call ?
Dim v As DiagramView = CType(FindChildControl(mainForm, "diagView"), DiagramView)

I can only retrieve the handle, donot have any way to get the control itself....I can get it through AutomationElement class but then conversion from AutomationElement to Windows.Forms.Control is not possible......
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automation testing of Mindfusion Controls
Reply #10 - Jul 20th, 2010 at 12:41pm
Print Post  
You can get the main form through Application.OpenForms. Does your test code run in the same process at all? That won't work if it's in a different process, neither Control.FromHandle.
  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #11 - Jul 21st, 2010 at 8:40am
Print Post  
I use an automation tool in which I am writing this code to test my application containing MindFusion Controls. Both the automation tool and application runs as different processes, so 'Application.openforms' is not fetching me the required form.

So, either there is a way to retrieve the mainform or I have to retrieve the required form only through AutomationElement class....
But the automationelement is not convertable to windows.forms.control....

What could be another way to acheive my goal....

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automation testing of Mindfusion Controls
Reply #12 - Jul 21st, 2010 at 8:56am
Print Post  
I don't have any idea. What is this automation tool you are using, and are you able to call methods on other controls from it - apart from sending UI events such as clicks and keystrokes?
  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #13 - Jul 21st, 2010 at 10:34am
Print Post  
I am using IBM's Rational Functional Tester(RFT) which does not support MindFusion controls. My application under test uses MindFusion controls which I need to automate.
For that matter, I have added references of Mindfusion API's(which my application under test is using) to RFT. I would use functions exposed from APIs to get the diagram and nodes's properties. But to be able to do that I need to retrieve the diagramView control and create its object.

  
Back to top
 
IP Logged
 
dmadaan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Jul 1st, 2010
Re: Automation testing of Mindfusion Controls
Reply #14 - Jul 23rd, 2010 at 6:59am
Print Post  
Hi Stoyan,

Is there any input from your side please?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint