Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.4
diff -u -p -r1.4 common.test
--- modules/simpletest/tests/common.test	29 Aug 2008 14:45:19 -0000	1.4
+++ modules/simpletest/tests/common.test	31 Aug 2008 13:54:56 -0000
@@ -144,3 +144,53 @@ class DrupalHTTPRequestTestCase extends 
     $this->assertTitle(variable_get('site_name', 'Drupal'), t('Site title matches.'));
   }
 }
+
+/**
+ * Test drupal_add_css().
+ */
+class CSSTestCase extends DrupalWebTestCase {
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('Drupal add CSS'),
+      'description' => t('Text drupal_add_css($somefile). Verify css is added by checking the output of drupal_add_css(NULL) and checking the output of  drupal_get_css() at the theme layer.'),
+      'group' => t('System'),
+    );
+  }
+
+  function testDrupalAddCSS() {
+    global $language;
+
+    // Setup language variables for testing RTL support.
+    define('LANGUAGE_RTL', 42);
+    $language->direction = LANGUAGE_RTL;
+
+    // Add a module CSS to the default location.
+    drupal_add_css(drupal_get_path('module', 'block') .'/block.css');
+
+    // Add a module CSS to mobile media with preprocess.
+    drupal_add_css(drupal_get_path('module', 'node') .'/node.css', 'module', 'mobile');
+
+    // Add a module CSS to print media without preprocess.
+    drupal_add_css(drupal_get_path('module', 'block') .'/block.css', 'module', 'print', FALSE);
+
+    // Add a theme CSS to print media.
+    drupal_add_css(drupal_get_path('theme', 'bluemarine') .'/style.css', 'theme', 'print');
+
+    // Pass no parameters and store the entire CSS array.
+    $css = drupal_add_css();
+
+    $this->assertTrue($css['all']['module'][drupal_get_path('module', 'block') .'/block.css'], t('Stylesheet added using default parameters; media = all, type = module, preprocess = TRUE.'), t('System'));
+    $this->assertTrue($css['mobile']['module'][drupal_get_path('module', 'node') .'/node.css'], t('Stylesheet added to mobile media with preprocess.'), t('System'));
+    $this->assertTrue(!$css['print']['module'][drupal_get_path('module', 'block') .'/block.css'], t('Stylesheet added to print media without preprocess.'), t('System'));
+    $this->assertTrue($css['print']['theme'][drupal_get_path('theme', 'bluemarine') .'/style.css'], t('Stylesheet added to print media without preprocess.'), t('System'));
+    $this->assertTrue($css['print']['theme'][drupal_get_path('theme', 'bluemarine') .'/style-rtl.css'], t('Right-to-left stylesheet added to print media without preprocess.'), t('System'));
+
+    // Get the actual css output and check a non-preprocessed stylesheet reaches the theming layer.
+    $scripts = drupal_get_css();
+    $this->assertTrue(strpos($scripts, drupal_get_path('module', 'block') .'/block.css'), t('Stylesheet added without preprocessing is found in the output of drupal_get_css()'), t('System'));
+  }
+}
+
