Index: simpletest.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.js,v retrieving revision 1.2 diff -u -p -r1.2 simpletest.js --- simpletest.js 18 Sep 2007 15:30:06 -0000 1.2 +++ simpletest.js 6 Apr 2008 02:50:09 -0000 @@ -1,34 +1,59 @@ // $Id: simpletest.js,v 1.2 2007/09/18 15:30:06 rokZlender Exp $ -/** - * Creates a select all checkbox before in every test group fieldset - */ + $(document).ready(function() { - $('.select_all').each(function() { - var legend = $('> legend', this); - var cbs = $('fieldset :checkbox', this); - var collapsed = 1; - var selectAllChecked = 1; - var cbInitialValue = ""; + // Adds expand-collapse functionality. + $('img.simpletest-menu-collapse').click(function(){ + if($(this).data('collapsed') == 1){ + $(this).data('collapsed', 0); + this.src = '/misc/menu-expanded.png'; + }else{ + $(this).data('collapsed',1); + this.src = '/misc/menu-collapsed.png'; + } + // Toggle all of the trs. + $("tr."+this.id.replace(/\-menu\-collapse/,'')+"-test").toggle(); + }); - for (i=0; i < cbs.length; i++) { - if (!cbs[i].checked) { + $('.select-all').each(function() { + var checkbox = $(''); + $('#'+ this.id).html(checkbox); + + var checkboxes = $('.'+ this.id +'-test'); + var selectAllChecked = 1; + var collapsed = 1; + for (var i = 0; i < checkboxes.length; i++) { + if (!checkboxes[i].checked) { selectAllChecked = 0; } else { collapsed = 0; } } - if (!collapsed && !selectAllChecked) - $('fieldset', this).removeClass('collapsed'); - - var item = $('
').html(''+'
Select all tests in group '+ legend.html() +'
'); - // finds all checkboxes in group fieldset and selects them or deselects - item.find(':checkbox').attr('checked', selectAllChecked).click(function() { - $(this).parents('fieldset:first').find('fieldset :checkbox').attr('checked', this.checked); + // Finds all checkboxes for particular test group and sets them to the "check all" state. + checkbox.attr('checked', selectAllChecked).click(function() { + var rows = $('.'+ this.id +'-test'); + for (var i = 0; i < rows.length; i++) { + $(rows[i]).find(':checkbox').attr('checked', this.checked); + } }).end(); - - // add select all checkbox - legend.after(item); }); -}); \ No newline at end of file + + // Set the initial state of the expand-collapse. + $('img.simpletest-menu-collapse').each(function(){ + //only set the state if it has not been set previously + if($(this).data('collapsed') == undefined){ + $(this).data('collapsed',1); + // See if any of the child checkboxes are checked and expand the menu if they are. + var doCheck = false; + $("tr."+this.id.replace(/\-menu\-collapse/,'')+"-test").find("input").each(function(){ + if(this.checked){ + doCheck = true; + } + }) + if(doCheck){ + $(this).click() + } + } + }); +}); Index: simpletest.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.css,v retrieving revision 1.2 diff -u -p -r1.2 simpletest.css --- simpletest.css 23 Mar 2008 03:35:38 -0000 1.2 +++ simpletest.css 6 Apr 2008 02:50:09 -0000 @@ -3,6 +3,29 @@ /* Addon for the simpletest module */ #simpletest { } +/* Test Table */ +table#simpletest-form-table td +{ + width:33.3% +} + table#simpletest-form-table td div.form-item, + td.select-all + { + text-align:center; + } + table#simpletest-form-table tr td + { + background-color:white !important; + } + table#simpletest-form-table tr.simpletest-group td + { + background-color:#EDF5FA !important; + } +img.simpletest-menu-collapse +{ + cursor:pointer; +} + div.simpletest-pass { background: #b6ffb6; } Index: simpletest.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v retrieving revision 1.43 diff -u -p -r1.43 simpletest.module --- simpletest.module 6 Apr 2008 00:23:10 -0000 1.43 +++ simpletest.module 6 Apr 2008 02:50:09 -0000 @@ -44,6 +44,17 @@ function simpletest_perm() { } /** + * Implemenation of hook_theme(). + */ +function simpletest_theme() { + return array( + 'simpletest_overview_form' => array( + 'arguments' => array('form' => NULL) + ), + ); +} + +/** * Try to load the simepletest * @return boolean TRUE if the load succeeded */ @@ -98,6 +109,7 @@ if (preg_match("/^(simpletest\d+),(\d+)/ }

'; return $output; } + drupal_add_css(drupal_get_path('module', 'simpletest') .'/simpletest.css', 'module'); drupal_add_js(drupal_get_path('module', 'simpletest') .'/simpletest.js', 'module'); $output = drupal_get_form('simpletest_overview_form'); @@ -121,7 +133,9 @@ function simpletest_running_output($outp * Form callback; make the form to run tests */ function simpletest_overview_form() { - $output = array(); + $output = array( + "#theme" => 'simpletest_overview_form' + ); $total_test = &simpletest_get_total_test(); @@ -242,6 +256,62 @@ function simpletest_clean_database() { } /** + * Theme the SimpleTest form that provides test selection. + * + * @ingroup themeable + */ +function theme_simpletest_overview_form($form) { + $header = array( + t('Test'), + t('Description'), + array('data' => t('Run'), 'class' => 'checkbox') + ); + + // Go through each test group and create a row. + $rows = array(); + foreach (element_children($form) as $gid) { + if (isset($form[$gid]['tests'])) { + $element = &$form[$gid]; + $test_class = strtolower(trim(preg_replace("/[^\w\d]/","-",$element["#title"]))); + + $row = array(); + $row[] = array( + 'data' => theme('image', 'misc/menu-collapsed.png', 'Menu Collapse', 'Menu Collapse', array('id' => $test_class .'-menu-collapse', 'class' => 'simpletest-menu-collapse')) . + ' ', + 'style' => 'font-weight: bold;' + ); + $row[] = $element['#description']; + $row[] = array('id' => $test_class, 'class' => 'select-all'); + $rows[] = array('data' => $row, 'class' => 'simpletest-group'); + + // Go through each test in the group and create table rows setting them to invisible. + foreach (element_children($element['tests']) as $test_name) { + $test = $element['tests'][$test_name]; + $row = array(); + $row[] = theme('indentation', 1) .''; + $row[] = $test['#description']; + + unset($test['#title']); + unset($test['#description']); + $test['#name'] = $test_name; + $row[] = drupal_render($test); + $row = array('data' => $row, 'style' => 'display:none;', 'class' => $test_class .'-test'); + $rows[] = $row; + } + unset($form[$gid]); // Remove test group from form. + } + } + // Output test groups. + $output = ''; + $output .= theme('table', $header, $rows, array('id' => 'simpletest-form-table')); + + // Output the rest of the form, excluded test groups which have been removed. + $output .= drupal_render($form); + + return $output; +} + +/** * Actually runs tests * @param array $testlist list of tests to run or DEFAULT NULL run all tests * @param boolean $html_reporter true if you want results in simple html, FALSE for full drupal page