Given $form, how to programmatically generate its corresponding $form_state?
Here is what I did to fill $form_state['values'] with the default values from $form:

function mymodule_get_form_state($form){
  $values = array();
  _mymodule_form_get_values($form, &amp;$values);
  $form_state = array();
  $form_state['values'] = $values;
  return ($form_state);
}

function _mymodule_form_get_values($element, &amp;$values) {
  foreach (element_children($element) as $key) {
    if (isset($element[$key]) &amp;&amp; $element[$key]) {
      if (isset($element[$key]['#default_value']) &amp;&amp; $element[$key]['#default_value']) {
        $values[$key] = $element[$key]['#default_value'];
      } else {
        // Recurse through all children elements.
        _mymodule_form_get_values($element[$key], &amp;$values);
      }
    }
  }
}