Index: simpletest.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v
retrieving revision 1.21
diff -u -p -r1.21 simpletest.module
--- simpletest.module	25 Dec 2006 11:43:39 -0000	1.21
+++ simpletest.module	20 Mar 2007 16:41:06 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: simpletest.module,v 1.21 2006/12/25 11:43:39 rokZlender Exp $
+// $Id: simpletest.module,v 1.15.2.1 2007/02/25 12:20:34 rokZlender Exp $
 
 /**
  * Implementation of hook_help().
@@ -101,40 +101,64 @@ function simpletest_entrypoint() {
      */
     return '&nbsp;';  
   }  
-  $op = $_POST['op'];
-  $edit = $_POST;
-  if (empty($op)) {
-		$op = arg(2);
+	$output = drupal_get_form('simpletest_overview_form');
+	
+	if (simpletest_running_output()) {
+	  print theme('page',  simpletest_running_output() . $output);
+	} else {
+	  print theme('page', $output);	
 	}
-	switch ($op) {
-		case t('Run All Tests'):
+}
+
+function simpletest_running_output($output = NULL) {
+  static $o;
+  if ($output != NULL) {
+    $o = $output;
+  }
+  return $o;
+}
+
+/**
+ * FAPI form submit for simpletest_overview_form
+ *
+ * @param $form_id 
+ * @param $form_values
+ */
+function simpletest_overview_form_submit($form_id, $form_values) {
+  
+  switch ($form_values['running_options']){
+    
+    case 'all_tests':
       $output  = simpletest_run_tests();
-  		break;
-		
-		case t('Run Selected Tests'):
-		  $tests_list = array();
-			foreach($edit as $test => $checked) {
-				if ($checked && ($test != 'form_id') && ($test != 'op') && ($test != 'form_token')) {
-					$tests_list[] = $test;
-				}
-			}
-			if (count($tests_list) > 0 ) {
-				$output = simpletest_run_tests($tests_list);  	 	 
+    break;    
+    
+    case 'selected_tests':
+      $test_list = array();
+      foreach ($form_values as $test => $checked){
+        if ($checked && ($test != 'running_options' && $test != 'op' && $test != 'form_token' && $test != 'form_id')) {
+          $tests_list[] = $test;
+        }
+      }
+      if (count($tests_list) > 0 ) {
+				$output = simpletest_run_tests($tests_list);
 			}
 			else { 
 				// no test has been selected
 				drupal_set_message(t('No test has been selected.'), 'error');
-				/** @FIXME!!! */
-//				$output = form_submit(t('Back to Menu'));
-//				$output = form($output);
 			}
-			break;
-		default:
-			$output = drupal_get_form('simpletest_overview_form');
+    break;  
+    
+    default:
+      drupal_set_message(t('No test has been selected.'), 'error');
   }
-	print theme('page', $output);	
+  
+  simpletest_running_output($output);
+  return false;
 }
 
+/**
+ * Create simpletest_overview_form 
+ */
 function simpletest_overview_form() {
   $output = array();
   $total_test = &simpletest_get_total_test();
@@ -154,13 +178,16 @@ function simpletest_overview_form() {
                     array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => FALSE,
                           '#title' => $group_test->getLabel()));
   }
-  $submit[] = array('#type' => 'submit', '#value' => t('Run All Tests'));
-  $submit[] = array('#type' => 'submit', '#value' => t('Run Selected Tests'));
+  
+  $submit['running_options'] = array('#type' => 'radios', '#default_value' => 'all_tests', 
+                    '#options' => array('all_tests' => t('Run all tests'), 'selected_tests' => t('Run selected tests')));
+  $submit['op'] = array('#type' => 'submit', '#value' => t('Begin'));
   $output[] = array_merge($submit,
                   array('#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, '#title' => 'Run tests', '#description' => t('WARNING, this may take a long time.')));
   return $output;
 }
 
+
 /**
  * Actually runs tests
  * @param array $testlist list of tests to run or DEFAULT NULL run all tests
