Преглед изворни кода

Probe port in binary tests after construction

Daniel Gempesaw пре 10 година
родитељ
комит
eb271356ef
3 измењених фајлова са 16 додато и 11 уклоњено
  1. 2 2
      lib/Selenium/Firefox.pm
  2. 2 2
      lib/Selenium/Firefox/Binary.pm
  3. 12 7
      t/binary.t

+ 2 - 2
lib/Selenium/Firefox.pm

@@ -2,7 +2,7 @@ package Selenium::Firefox;
 
 # ABSTRACT: A convenience package for creating a Firefox instance
 use Selenium::Binary qw/_find_open_port_above _probe_port/;
-use Selenium::Firefox::Binary qw/path/;
+use Selenium::Firefox::Binary qw/firefox_path/;
 use Selenium::Firefox::Profile;
 use Selenium::Waiter qw/wait_until/;
 use Moo;
@@ -58,7 +58,7 @@ has 'binary_mode' => (
         $ENV{'MOZ_CRASHREPORTER_DISABLE'} = '1'; # disable breakpad
         $ENV{'NO_EM_RESTART'} = '1'; # prevent the binary from detaching from the console.log
 
-        my $binary = path();
+        my $binary = firefox_path();
         system( $binary . ' -no-remote > /dev/null 2>&1 & ');
 
         my $success = wait_until { _probe_port($port) } timeout => 10;

+ 2 - 2
lib/Selenium/Firefox/Binary.pm

@@ -5,7 +5,7 @@ use File::Which qw/which/;
 
 require Exporter;
 our @ISA = qw/Exporter/;
-our @EXPORT_OK = qw/path/;
+our @EXPORT_OK = qw/firefox_path/;
 
 sub _windows_path {
     # TODO: make this slightly less dumb
@@ -28,7 +28,7 @@ sub _unix_path {
     return which('firefox') || '/usr/bin/firefox';
 }
 
-sub path {
+sub firefox_path {
     my $path;
     if ($^O eq 'MSWin32') {
         $path =_windows_path();

+ 12 - 7
t/binary.t

@@ -2,12 +2,12 @@
 
 use strict;
 use warnings;
-use Test::More;
-use Selenium::Binary;
+use Selenium::Binary qw/_probe_port/;
 use Selenium::Firefox::Binary;
 use Selenium::Chrome;
 use Selenium::PhantomJS;
 use Selenium::Firefox;
+use Test::More;
 
 use FindBin;
 use lib $FindBin::Bin . '/lib';
@@ -20,9 +20,11 @@ my %caps = %{ $harness->base_caps };
 delete $caps{browser_name};
 
 PHANTOMJS: {
-    my $ghost = Selenium::PhantomJS->new( %caps );
-    is( $ghost->browser_name, 'phantomjs', 'binary phantomjs is okay');
-    isnt( $ghost->port, 4444, 'phantomjs can start up its own binary');
+    my $phantom = Selenium::PhantomJS->new( %caps );
+    is( $phantom->browser_name, 'phantomjs', 'binary phantomjs is okay');
+    isnt( $phantom->port, 4444, 'phantomjs can start up its own binary');
+
+    ok( _probe_port( $phantom->port ), 'the phantomjs binary is listening on its port');
 }
 
 CHROME: {
@@ -30,14 +32,17 @@ CHROME: {
     my $chrome = Selenium::Chrome->new( %caps );
     ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
     isnt( $chrome->port, 4444, 'chrome can start up its own binary');
-    $chrome->quit;
+
+    ok( _probe_port( $chrome->port ), 'the chrome binary is listening on its port');
 }
 
 FIREFOX: {
-    my $binary = Selenium::Firefox::Binary::path();
+    my $binary = Selenium::Firefox::Binary::firefox_path();
     ok(-x $binary, 'we can find some sort of firefox');
     my $firefox = Selenium::Firefox->new;
     isnt( $firefox->port, 4444, 'firefox can start up its own binary');
+
+    ok( _probe_port( $firefox->port ), 'the firefox binary is listening on its port');
 }
 
 done_testing;