X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fselenium%2FAllTests.t;h=c5ebf1d19e600b793e48c8d13ce05a2ff30c4527;hb=ab875da135e7c44abb05eae5a136f6df4e09078c;hp=f309231e291d6fad28ac3ca5b306da7741a6eee0;hpb=0205f9f4755b0604fff7af2187b90e95d675fa98;p=kivitendo-erp.git diff --git a/t/selenium/AllTests.t b/t/selenium/AllTests.t index f309231e2..c5ebf1d19 100644 --- a/t/selenium/AllTests.t +++ b/t/selenium/AllTests.t @@ -1,12 +1,12 @@ #===================================================================== # LX-Office ERP -# Copyright (C) 2006 +# Copyright (C) 2006/2007 # Web http://www.lx-office.org # #===================================================================== # -# Author: Udo Spallek -# Email: udono@gmx.net +# Author: Udo Spallek, Thomas Kasulke +# Email: udono@gmx.net, tkasulke@linet-services.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,87 +30,124 @@ # ####################################################################### no strict; - push @INC, ['/t/selenium']; + push @INC, ['/t/selenium', \&init_server]; use vars qw( $lxdebug $lxtest $sel ); use strict; use Carp; use Test::WWW::Selenium; - use Test::More; + use Test::More qw(no_plan); use IO::Socket; - eval { require('t/lxtest.conf'); }; + if(-f "/tmp/lxtest-temp.conf") { + eval { require('/tmp/lxtest-temp.conf'); }; + } + else { + eval { require('t/lxtest.conf'); }; + } if ($@) { diag("No test configuration found in t/lxtest.conf.\n Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n"); exit 0; - }; + } sub server_is_running { return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost}, PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport}, ); } - if (server_is_running) { - plan tests => 204; # Need to be cutomized - } - else { - plan skip_all => "No selenium server found! " - ."Maybe you forgot to start it or " - ."the preferences in t/lxtest.conf doesen't fit to your system"; - exit 0; + +# if (server_is_running) { +# plan tests => 200; # Need to be cutomized +# } + sub init_server { + my $singlefileonly = 0; + if ($_[0] eq "singlefileonly") { + $singlefileonly = 1; + shift; + } + if(!server_is_running) { + print "No selenium server found! " + ."Maybe you forgot to start it or " + ."the preferences in t/lxtest.conf doesen't fit to your system"; + exit 0; + } + + diag('Pretests and initialisation'); + + + + $lxtest->{test_id} = time; # create individual ids by unixtime + $lxtest->{testuserlogin} = $lxtest->{testlogin} . $lxtest->{test_id} if(!$lxtest->{testuserlogin}); + $lxtest->{testuserpasswd} = $lxtest->{test_id} if(!$lxtest->{testuserpasswd}); + $lxtest->{db} = $lxtest->{db} . $lxtest->{test_id} if(!($lxtest->{db} =~ /^seleniumtestdatabase[0-9]{10}$/)); + + ok(defined $lxtest->{rpw}, "Get root password"); + + ok(defined $lxtest->{dbhost}, "found dbhost in config"); + ok(defined $lxtest->{dbport}, "found dbport in config"); + ok(defined $lxtest->{dbuser}, "found dbuser in config"); + ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config"); + + $lxtest->{lxadmin_url} = $lxtest->{lxbaseurl} . "admin.pl"; + $lxtest->{lxadmin_with_get} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; + $lxtest->{lxadmin} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; + + + + + eval { $sel = Test::WWW::Selenium->new( + host => $lxtest->{seleniumhost}, + port => $lxtest->{seleniumport}, + browser => $lxtest->{seleniumbrowser}, + browser_url => $lxtest->{lxadmin}, + auto_stop => '0', + ); + }; + if ($@) { + diag("No Selenium Server running, or wrong preferences\n\n"); + exit 0; + } + + ok(defined $sel, 'Creating Selenium Object'); + + diag('Starting Selenium tests...'); + + if(!$singlefileonly) { + foreach my $scriptdir (@_) { + opendir(SCRIPTS, 't/selenium/testscripts/' . $scriptdir) or die "Can't open directory!" . $!; + foreach (sort readdir(SCRIPTS)) { + if ( $_ =~ /^\w\d\d\d.*\.t$|^\d\d\d.*\.t$/ && !$sel->{ran_tests}{"t/selenium/testscripts/". $scriptdir . "/" . $_}) { + require_ok("t/selenium/testscripts/". $scriptdir . "/" . $_); + $sel->{ran_tests}{"t/selenium/testscripts/". $scriptdir . "/" . $_} = 1; + } + } + closedir(SCRIPTS); + } + } + else { + foreach (@_) { + if ( $_ =~ /^.*\/\w\d\d\d.*\.t$|^.*\/\d\d\d.*\.t$/ && !$sel->{ran_tests}{$_}) { + require_ok($_); + $sel->{ran_tests}{$_} = 1; + } + } + } + if($!) { + @! = ("Test fehlgeschlagen!"); + } + $sel->stop(); } - - diag('Pretests and initialisation'); - - - - $lxtest->{test_id} = time; # create individual ids by unixtime - $lxtest->{testuserlogin} = $lxtest->{testlogin} . $lxtest->{test_id}; - $lxtest->{testuserpasswd} = $lxtest->{test_id}; - $lxtest->{db} = $lxtest->{db} . $lxtest->{test_id}; - - ok(defined $lxtest->{rpw}, "Get root password"); - ok(defined $lxtest->{dbhost}, "found dbhost in config"); - ok(defined $lxtest->{dbport}, "found dbport in config"); - ok(defined $lxtest->{dbuser}, "found dbuser in config"); - ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config"); - - $lxtest->{lxadmin_url} = $lxtest->{lxbaseurl} . "admin.pl"; - $lxtest->{lxadmin_with_get} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; - $lxtest->{lxadmin} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; - + sub start_login() { + require "t/selenium/testscripts/base/000Login.t" if(!$sel->{_page_opened}); + skip("Failed page to load pages!",) if(!$sel->{_page_opened}); + if($sel->get_title() ne "Lx-Office Version 2.4.3 - Selenium - " . $lxtest->{db}){ + require "t/selenium/testscripts/base/000Login.t"; + } - - eval { $sel = Test::WWW::Selenium->new( - host => $lxtest->{seleniumhost}, - port => $lxtest->{seleniumport}, - browser => $lxtest->{seleniumbrowser}, - browser_url => $lxtest->{lxadmin}, - auto_stop => '0', - ); - }; - if ($@) { - diag("No Selenium Server running, or wrong preferences\n\n"); - exit 0; + $sel->select_frame_ok("relative=up"); } - - ok(defined $sel, 'Creating Selenium Object'); - - diag('Starting Selenium tests...'); - - opendir(SCRIPTS, 't/selenium/testscripts'); - my @testscripts = sort readdir(SCRIPTS); - foreach my $script (@testscripts){ - my $file = "t/selenium/testscripts/" . $script; - require_ok($file) if ( $script =~ /^\d\d\d.*\.t$/ ); - } - exit 1; - - $sel=''; # Destroy selenium object - - exit 1; - +1;