Index: openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl,v diff -u -N -r1.37 -r1.38 --- openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 10 Jan 2007 21:22:01 -0000 1.37 +++ openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 17 Sep 2009 15:57:01 -0000 1.38 @@ -27,6 +27,11 @@ nsv_set aa_test init_classes {} nsv_set aa_test categories { config db api web smoke stress security_risk populator production_safe } nsv_set aa_test exclusion_categories { stress security_risk } + if {[parameter::get_from_package_key -package_key "acs-automated-testing" -parameter "SeleniumRcServer"] ne ""} { + nsv_lappend aa_test categories "selenium" + } else { + nsv_lappend aa_test exclusion_categories "selenium" + } } ad_proc -public aa_stub { @@ -130,14 +135,21 @@ the descructor to unmount the package. @author Peter Harper @creation-date 04 November 2001 + + @param init_class_id Unique string to identify the init class + @param init_class_desc Longer description of the init class + @param constructor Tcl code block to run to setup the init class + @param destructor Tcl code block to tear down the init class } { # # Work out the package key # set package_root [file join [acs_root_dir] packages] set package_rel [string replace [info script] \ 0 [string length $package_root]] - set package_key [lindex [file split $package_rel] 0] + if {![info exists package_key]} { + set package_key [lindex [file split $package_rel] 0] + } # # First, search the current list of init_classes. If an old version already # exists, replace it with the new version. @@ -375,6 +387,9 @@ # set filtered_inits {} foreach init_class $init_classes { + if {[llength $init_class] == 2} { + set init_class [lindex $init_class 0] + } if {[string trim $init_class] ne ""} { set found 0 foreach init_class_info [nsv_get aa_test init_classes] { @@ -441,10 +456,16 @@ global aa_init_class_logs upvar 2 _aa_exports _aa_exports foreach init_class \[list $init_classes\] { - foreach v \$_aa_exports(\[list $package_key \$init_class\]) { + if {[llength $init_class] == 2} { + set init_package_key [lindex $init_class 1] + set init_class [lindex $init_class 0] + } else { + set init_package_key $package_key + } + foreach v \$_aa_exports(\[list \$init_package_key \$init_class\]) { upvar 2 \$v \$v } - foreach logpair \$aa_init_class_logs(\[list $package_key \$init_class\]) { + foreach logpair \$aa_init_class_logs(\[list \$init_package_key \$init_class\]) { aa_log_result \[lindex \$logpair 0\] \[lindex \$logpair 1\] } } @@ -1226,3 +1247,50 @@ aa_log_result "fail" $explanation } } + +ad_proc -public aa_selenium_init {} { + Setup a global Selenium RC server connection + + @return true is everything is ok, false if there was any error +} { + # check if the global selenium connection already exists + global _acs_automated_testing_selenium_init + if {[info exists _acs_automated_testing_selenium_init]} { + # if we already initialized Selenium RC this will be true if + # we already failed to initialize Selenium RC this will be + # false. We don't want to try to initialize Selenium RC more + # than once per request thread in any case so just return the + # previous status. This is a global and is reset on every + # request. + return $_acs_automated_testing_selenium_init + } + + set server_url [parameter::get_from_package_key \ + -package_key acs-automated-testing \ + -parameter "SeleniumRcServer" \ + -default ""] + if {$server_url eq ""} { + # no server configured so don't try to initialize + return 0 + } + set server_port [parameter::get_from_package_key \ + -package_key acs-automated-testing \ + -parameter "SeleniumRcPort" \ + -default "4444"] + set browsers [parameter::get_from_package_key \ + -package_key acs-automated-testing \ + -parameter "SeleniumRcBrowsers" \ + -default "*firefox"] + set success_p [expr {![catch {Se init $server_url $server_port ${browsers} [ad_url]} errmsg]}] + if {!$success_p} { + ns_log error [ad_log_stack_trace] + } + set _acs_automated_testing_selenium_init $success_p + return $success_p +} + +aa_register_init_class \ + "selenium" \ + "Init Class for Selenium Remote Control" \ + {aa_selenium_init} \ + {catch {Se stop} errmsg}