[tools 3/3] testbot/cgi: Take into account the form order in GetFirstErrField().

Francois Gouget fgouget at codeweavers.com
Mon Jul 11 11:46:17 CDT 2022


The base Page class does not know in which order the fields are so its
GetFirstErrField() method just returns the first invalid field in
alphabetical order. But for FormPage it makes more sense to return the
first invalid field in the form order.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/lib/ObjectModel/CGI/FormPage.pm | 29 +++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/testbot/lib/ObjectModel/CGI/FormPage.pm b/testbot/lib/ObjectModel/CGI/FormPage.pm
index 688ee13a97..c299d54b4a 100644
--- a/testbot/lib/ObjectModel/CGI/FormPage.pm
+++ b/testbot/lib/ObjectModel/CGI/FormPage.pm
@@ -211,6 +211,35 @@ sub DisplayProperty($$)
 =pod
 =over 12
 
+=item C<GetFirstErrField()>
+
+Returns the first invalid field in the form order.
+
+See Page::GetFirstErrField().
+
+=back
+=cut
+
+sub GetFirstErrField($)
+{
+  my ($self) = @_;
+
+  if (defined $self->GetErrMessage())
+  {
+    foreach my $PropertyDescriptor (@{$self->GetPropertyDescriptors()})
+    {
+      if ($self->IsErrField($PropertyDescriptor->GetName()))
+      {
+        return $PropertyDescriptor->GetName();
+      }
+    }
+  }
+  return undef;
+}
+
+=pod
+=over 12
+
 =item C<GetPropertyValue()>
 
 Returns the underlying property value.
-- 
2.30.2



More information about the wine-devel mailing list