0
votes

How can I automate Delphi Firemonkey UI testing without access to source code?

I currently have a suite of tests running against my application in both DUnit and TestComplete tests. I am looking at moving the UI from VCL based to FireMonkey based. I realize my tests will need to be rewritten, however I noticed that the UI testing software we use cannot "look-into" the application and see the controls and their properties. Instead of seeing an editbox or a label, all the tools can see is the form. I believe this is the case because of the slight of hand that Firemonkey uses to render the controls. The UI tests can be implemented using DUnit, but this requires our testers to have access to the source code, which is frowned upon where I work. Is anyone aware of a solution?

Thanks.

1
There's an add-on to fmx that adds UI Automation support - David Heffernan
I guess David is referring to this one: docwiki.embarcadero.com/RADStudio/XE8/en/… - Stefan Glienke
@Stefan Yes that's it. I can never remember what it's called, having no experience of fmx at all. - David Heffernan
Thanks! This is exactly what I was hoping for. Now I just need to test it and see if it works as advertised. - user1627960
Could not get it to work. The issue might be occurring on the testing software side. Trying to devise a way to test which side the issue is on. - user1627960

1 Answers

0
votes

Build a test harness.

function TForm1.FindControlAtPoint(aParent: TControl; aPos: TPointF): TControl;
var
  I: Integer;
  Control, ChildControl: TControl;
  S: String;
begin
  Result := nil;

  // Check all the child controls and find the one at the coordinates
  for I := aParent.Controls.Count – 1 downto 0 do
  begin
    Control := aParent.Controls[I];
    S := Control.ClassName;
    if Control.PointInObject(aPos.X, aPos.Y) then
    begin
      ChildControl := FindControlAtPoint(Control, aPos);
      if Assigned(ChildControl) and ChildControl.HitTest then
        Exit(ChildControl)
      else if Control.HitTest then
        Exit(Control);
    end;
  end;
end;