procedure TGUITestCase.CheckFocused(Control: TControl);
var
F :TControl;
begin
Assert(Control <> nil, 'No control');
Check(Control is TWinControl,
Format('Expected a TWinControl, but %s is a %s',
[Control.Name, Control.ClassName])
);
Check(TWinControl(Control).CanFocus,
Format('Control %s cannot focus', [Control.ClassName])
);
if (Control.Owner <> nil) and (Control.Owner is TCustomForm) then
F := TCustomForm(Control.Owner).ActiveControl
else
F := GetFocused;
if F <> Control then
begin
if F <> nil then
Fail(Format('Expected control %s to have focus, but %s had it.', [Control.Name, F.Name]), CallerAddr)
else
Fail(Format('Expected control %s to have focus', [Control.Name]), CallerAddr);
end
End; |