소스 검색

Move the test website and domain up into TestHarness.pm

This will make it easier to change our test fixture website, if we ever
need to, like for the saucelabs branch.
Daniel Gempesaw 11 년 전
부모
커밋
feb250fbe4
4개의 변경된 파일24개의 추가작업 그리고 5개의 파일을 삭제
  1. 3 2
      t/01-driver.t
  2. 3 1
      t/02-webelement.t
  3. 3 2
      t/Firefox-Profile.t
  4. 15 0
      t/lib/TestHarness.pm

+ 3 - 2
t/01-driver.t

@@ -21,7 +21,8 @@ my $harness = TestHarness->new(
 my %selenium_args = %{ $harness->base_caps };
 
 my $driver = Selenium::Remote::Driver->new(%selenium_args);
-my $website = 'http://localhost:63636';
+my $domain = $harness->domain;
+my $website = $harness->website;
 my $ret;
 
 my $chrome;
@@ -217,7 +218,7 @@ COOKIES: {
     pass('Deleting cookies...');
     $ret = $driver->get_all_cookies();
     is(@{$ret}, 0, 'Deleted all cookies.');
-    $ret = $driver->add_cookie('foo', 'bar', '/', 'localhost', 0);
+    $ret = $driver->add_cookie('foo', 'bar', '/', $domain, 0);
     pass('Adding cookie foo...');
     $ret = $driver->get_all_cookies();
     is(@{$ret}, 1, 'foo cookie added.');

+ 3 - 1
t/02-webelement.t

@@ -15,7 +15,9 @@ my $harness = TestHarness->new(
 my %selenium_args = %{ $harness->base_caps };
 
 my $driver = Selenium::Remote::Driver->new(%selenium_args);
-my $website = 'http://localhost:63636';
+my $domain = $harness->domain;
+my $website = $harness->website;
+
 $driver->get("$website/formPage.html");
 my $ret;
 my $elem;

+ 3 - 2
t/Firefox-Profile.t

@@ -26,7 +26,8 @@ my $fixture_dir = $FindBin::Bin . '/www/';
 
 CUSTOM_EXTENSION_LOADED: {
     my $profile = Selenium::Remote::Driver::Firefox::Profile->new;
-    my $website = 'http://localhost:63636';
+    my $domain = $harness->domain;
+    my $website = $harness->website;
     my $mock_encoded_profile = $fixture_dir . 'encoded_profile.b64';
     my $encoded;
 
@@ -74,7 +75,7 @@ CUSTOM_EXTENSION_LOADED: {
     # elements)
     $driver->set_implicit_wait_timeout(30000);
     $driver->find_element("h1", "tag_name");
-    cmp_ok($driver->get_current_url, '=~', qr/localhost/i,
+    cmp_ok($driver->get_current_url, '=~', qr/$domain/i,
            "profile loaded and preference respected!");
 
     $driver->get($website . '/index.html');

+ 15 - 0
t/lib/TestHarness.pm

@@ -129,6 +129,21 @@ has mock_file => (
     }
 );
 
+has website => (
+    is => 'ro',
+    default => sub {
+        my ($self) = @_;
+        my $port = 63636;
+
+        return 'http://' . $self->domain . ':' . $port;
+    }
+);
+
+has domain => (
+    is => 'ro',
+    default => sub { 'localhost' }
+);
+
 sub DEMOLISH {
     my ($self) = @_;
     if ($self->record) {