first trial of xvnc support
Chris Nehren [Fri, 14 Jan 2011 13:04:57 +0000 (08:04 -0500)]
lib/Test/Harness/Selenium.pm

index 3590be0..51d099f 100644 (file)
@@ -31,6 +31,19 @@ BEGIN {
 
 sub new {
   my ($class, $self) = @_;
+  if($self->{xvnc}) {
+    $ENV{DISPLAY} = $self->{xvnc};
+    my $xvnc_pid = fork();
+    if(!defined $xvnc_pid) {
+      die "couldn't fork xvnc: $!";
+    }
+    elsif($xvnc_pid) {
+      $self->{xvnc_pid} = $xvnc_pid;
+    }
+    else {
+      exec("Xvnc", $self->{xvnc});
+    }
+  }
   bless $self, $class;
 }
 
@@ -103,4 +116,11 @@ sub get_rows_for {
   return \@rows;
 }
 
+sub DESTROY {
+  my($self) = @_;
+  if(exists $self->{xvnc_pid}) {
+    kill("KILL", $self->{xvnc_pid});
+  }
+}
+
 1;