? tests/example/example_info_file.libraries.info
Index: libraries.api.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.api.php,v
retrieving revision 1.4
diff -u -p -r1.4 libraries.api.php
--- libraries.api.php	9 Oct 2010 22:26:03 -0000	1.4
+++ libraries.api.php	3 Nov 2010 20:11:41 -0000
@@ -14,12 +14,17 @@
  *   values are describing each library. Each key is the directory name below
  *   the 'libraries' directory, in which the library may be found. Each value is
  *   an associative array containing:
- *   - title: The official, human-readable name of the library.
+ *   - name: The official, human-readable name of the library.
  *   - vendor url: The URL of the homepage of the library.
  *   - download url: The URL of a web page on which the library can be obtained.
  *   - path: (optional) A relative path from the directory of the library to the
  *     actual library. Only required if the extracted download package contains
  *     the actual library files in a sub-directory.
+ *   - library path: (optional) The absolute path to the library directory. This
+ *     should not be declared normally, as it is automatically detected, to
+ *     allow for multiple possible library locations. A valid use-case is an
+ *     external library, in which case the full URL to the library should be
+ *     specified here.
  *   - version callback: (optional) The name of a function that detects and
  *     returns the full version string of the library. The first argument is
  *     always $library, an array containing all library information as described
@@ -27,6 +32,13 @@
  *     arguments, either as a single $options parameter or as multiple
  *     parameters, which correspond to the two ways to specify the argument
  *     values (see 'version arguments'). Defaults to libraries_get_version().
+ *   - version: (optional) The version of the library. This should not be
+ *     declared normally, as it is automatically detected (see 'version
+ *     callback' below) to allow for version changes of libraries without code
+ *     changes of implementing modules and to support different versions of a
+ *     library simultaneously (though only one version can be installed per
+ *     site). A valid use-case is an external library whose version cannot be
+ *     determined programatically.
  *   - version arguments: A list of arguments to pass to the version callback.
  *     Version arguments can be declared either as an associative array whose
  *     keys are the argument names or as an indexed array without specifying
Index: libraries.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.module,v
retrieving revision 1.9
diff -u -p -r1.9 libraries.module
--- libraries.module	15 Oct 2010 15:15:53 -0000	1.9
+++ libraries.module	3 Nov 2010 20:11:42 -0000
@@ -179,14 +179,15 @@ function libraries_info($library = NULL)
 
   if (!isset($libraries)) {
     $libraries = array();
+    // Gather information from hook_libraries_info().
     foreach (module_implements('libraries_info') as $module) {
       foreach (module_invoke($module, 'libraries_info') as $name => $properties) {
         $properties['module'] = $module;
-        $properties['name'] = $name;
         $libraries[$name] = $properties;
       }
     }
     // Gather information from .info files.
+    // .info files override module definitions.
     foreach (libraries_info_files() as $name => $path) {
       $file = "$path/$name.info";
       $libraries[$name] = drupal_parse_info_file($file);
@@ -195,10 +196,11 @@ function libraries_info($library = NULL)
     // Provide defaults.
     foreach ($libraries as $name => &$properties) {
       $properties += array(
-        'title' => $name,
+        'name' => $name,
         'vendor url' => '',
         'download url' => '',
         'path' => '',
+        'library path' => FALSE,
         'version callback' => 'libraries_get_version',
         'version arguments' => array(),
         'files' => array(),
@@ -311,8 +313,10 @@ function libraries_detect_library(&$libr
     foreach ($library['variants'] as $name => &$variant) {
       // If no variant callback has been set, assume the variant to be
       // installed.
-      $variant['installed'] = TRUE;
-      if (!empty($variant['variant callback'])) {
+      if (!isset($variant['variant callback'])) {
+        $variant['installed'] = TRUE;
+      }
+      else {
         // We support both a single parameter, which is an associative array,
         // and an indexed array of multiple parameters.
         if (isset($variant['variant arguments'][0])) {
@@ -322,7 +326,7 @@ function libraries_detect_library(&$libr
         else {
           $variant['installed'] = $variant['variant callback']($library, $name, $variant['variant arguments']);
         }
-        if (empty($variant['installed'])) {
+        if (!$variant['installed']) {
           $variant['error'] = 'not found';
           $variant['error message'] = t('The %variant variant of %library could not be found.', array(
             '%variant' => $name,
@@ -341,38 +345,42 @@ function libraries_detect_library(&$libr
  * Loads a library.
  *
  * @param $library
- *   The name of the library to load.
+ *   An array of library information as returned from libraries_info().
  * @param $variant
  *   The name of the variant to load.
  */
 function libraries_load($library, $variant = NULL) {
   $library = libraries_info($library);
   libraries_detect_library($library);
-  if ($library['installed']) {
-    libraries_load_files($library, $variant);
-    return TRUE;
+
+  // If the library itself is not installed, do nothing;
+  if (!$library['installed']) {
+    return FALSE;
+  }
+
+  // If a variant was specified, override the top-level properties with the
+  // variant properties.
+  if (!empty($variant) && !empty($library['variants'][$variant])) {
+    // If the variant is not installed, do nothing.
+    if (!$library['variants'][$variant]['installed']) {
+      return FALSE;
+    }
+    $library = array_merge($library, $library['variants'][$variant]);
   }
-  return FALSE;
+
+  return libraries_load_files($library, $variant);
 }
 
 /**
  * Loads a library's files.
  *
  * @param $library
- *   The name of the library to load.
- * @param $variant
- *   The name of the variant to load.
+ *   An array of library information as returned by libraries_info().
+ *
+ * @return
+ *   The number of loaded files.
  */
-function libraries_load_files($library, $variant = NULL) {
-  // Construct the full path to the library for later use.
-  $path = (!empty($library['path']) ? $library['library path'] . '/' . $library['path'] : $library['library path']);
-
-  // If a variant was specified, override the top-level properties with the
-  // variant properties.
-  if (!empty($variant) && !empty($library['variants'][$variant]['installed'])) {
-    $library = array_merge($library, $library['variants'][$variant]);
-  }
-
+function libraries_load_files($library) {
   // Load integration files.
   if (!empty($library['integration files'])) {
     foreach ($library['integration files'] as $module => $files) {
@@ -383,6 +391,13 @@ function libraries_load_files($library, 
     }
   }
 
+  // Construct the full path to the library for later use.
+  $path = $library['library path'];
+  $path = ($library['path'] !== '' ? $path . '/' . $library['path'] : $path);
+
+  // Count the number of loaded files for the return value.
+  $count = 0;
+
   // Load both the JavaScript and the CSS files.
   // The parameters for drupal_add_js() and drupal_add_css() require special
   // handling.
@@ -409,6 +424,7 @@ function libraries_load_files($library, 
           $options['weight'] = ($type == 'js') ? JS_DEFAULT : CSS_DEFAULT;
         }
         call_user_func('drupal_add_' . $type, $data, $options);
+        $count++;
       }
     }
   }
@@ -419,9 +435,12 @@ function libraries_load_files($library, 
       $file_path = DRUPAL_ROOT . '/' . $path . '/' . $file;
       if (file_exists($file_path)) {
         require_once $file_path;
+        $count++;
       }
     }
   }
+
+  return $count;
 }
 
 /**
Index: tests/libraries.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries.test,v
retrieving revision 1.8
diff -u -p -r1.8 libraries.test
--- tests/libraries.test	15 Oct 2010 15:15:53 -0000	1.8
+++ tests/libraries.test	3 Nov 2010 20:11:42 -0000
@@ -30,26 +30,49 @@ class LibrariesTestCase extends DrupalWe
    * @todo Better method name(s); split into detection/loading/overloading/etc.
    */
   function testLibraries() {
-    // Test a library specified with an .info file gets detected.
-    $library = libraries_info('example');
+    // Test that library information is found correctly.
+    $library = libraries_info('example_simple');
     $expected = array(
-      'title' => 'example',
+      'name' => 'example_simple',
+      'title' => 'Example simple',
       'vendor url' => '',
       'download url' => '',
       'path' => '',
-      'version callback' => 'libraries_get_version',
-      'version arguments' => array(),
-      'files' => array(),
+      'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
+      'version callback' => '_libraries_test_return_version',
+      'version arguments' => array('1'),
+      'files' => array(
+        'js' => array('example_1.js'),
+        'css' => array('example_1.css'),
+        'php' => array('example_1.php'),
+      ),
       'variants' => array(),
       'versions' => array(),
       'integration files' => array(),
+      'module' => 'libraries_test',
     );
+    $this->verbose(var_export($expected, TRUE));
+    $this->verbose(var_export($library, TRUE));
+    $this->assertEqual($library, $expected, 'Library information is correctly gathered.');
+
+    // Test a library specified with an .info file gets detected.
+    $library = libraries_info('libraries_info_example');
+    $expected = array_merge(libraries_info('empty'), array(
+      'name' => 'libraries_info_example',
+      'title' => 'Example info file',
+      'info file' => DRUPAL_ROOT . '/' . drupal_get_path('module', 'libraries_test') . '/libraries_info_example/libraries_info_example.info',
+      'hidden' => TRUE,
+    ));
+    unset($expected['module']);
+    $this->verbose(var_export($expected, TRUE));
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library, $expected, 'Library specified with an .info file found');
 
     // Test missing library.
     $library = libraries_info('example_missing');
     libraries_detect_library($library);
-    $this->assertEqual($library['error'], 'not found', 'Non-existing library not found.');
+    $this->verbose(var_export($library, TRUE));
+    $this->assertEqual($library['error'], 'not found', 'Missing library not found.');
     $error_message = t('%library could not be found.', array(
       '%library' => $library['title'],
     ));
@@ -58,7 +81,8 @@ class LibrariesTestCase extends DrupalWe
     // Test unknown library version.
     $library = libraries_info('example_undetected_version');
     libraries_detect_library($library);
-    $this->assertEqual($library['error'], 'not detected', 'Library version not found.');
+    $this->verbose(var_export($library, TRUE));
+    $this->assertEqual($library['error'], 'not detected', 'Undetected version detected as such.');
     $error_message = t('The version of %library could not be detected.', array(
       '%library' => $library['title'],
     ));
@@ -67,7 +91,8 @@ class LibrariesTestCase extends DrupalWe
     // Test unsupported library version.
     $library = libraries_info('example_unsupported_version');
     libraries_detect_library($library);
-    $this->assertEqual($library['error'], 'not supported', 'Library version not supported.');
+    $this->verbose(var_export($library, TRUE));
+    $this->assertEqual($library['error'], 'not supported', 'Unsupported version detected as such.');
     $error_message = t('The installed version %version of %library is not supported.', array(
       '%version' => $library['version'],
       '%library' => $library['title'],
@@ -77,18 +102,21 @@ class LibrariesTestCase extends DrupalWe
     // Test supported library version.
     $library = libraries_info('example_supported_version');
     libraries_detect_library($library);
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['installed'], TRUE, 'Supported library version found.');
 
     // Test libraries_get_version().
     $library = libraries_info('example_default_version_callback');
     libraries_detect_library($library);
     $version = '2';
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['version'], $version, 'Expected version returned by default version callback.');
 
     // Test a multiple-parameter version callback.
     $library = libraries_info('example_multiple_parameter_version_callback');
     libraries_detect_library($library);
     $version = '2';
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['version'], $version, 'Expected version returned by multiple parameter version callback.');
 
     // Test a top-level files property.
@@ -99,6 +127,7 @@ class LibrariesTestCase extends DrupalWe
       'css' => array('example_1.css'),
       'php' => array('example_1.php'),
     );
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['files'], $files, 'Top-level files property works.');
 
     // Test version-specific library files.
@@ -109,12 +138,14 @@ class LibrariesTestCase extends DrupalWe
       'css' => array('example_2.css'),
       'php' => array('example_2.php'),
     );
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['files'], $files, 'Version-specific library files found.');
 
     // Test missing variant.
     $library = libraries_info('example_variant_missing');
     libraries_detect_library($library);
     $variants = array_keys($library['variants']);
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['variants']['example_variant']['error'], 'not found', 'Missing variant not found');
     $error_message = t('The %variant variant of %library could not be found.', array(
       '%variant' => $variants[0],
@@ -125,29 +156,30 @@ class LibrariesTestCase extends DrupalWe
     // Test existing variant.
     $library = libraries_info('example_variant');
     libraries_detect_library($library);
+    $this->verbose(var_export($library, TRUE));
     $this->assertEqual($library['variants']['example_variant']['installed'], TRUE, 'Existing variant found.');
 
     // Test loading of a simple library with a top-level files property.
     $this->drupalGet('libraries_test/simple');
-    $this->assertLibraryFiles('example_1');
+    $this->assertLibraryFiles('example_1', 'Simple library loading');
 
     // Test loading of integration files.
     $this->drupalGet('libraries_test/integration_files');
-    $this->assertRaw('libraries_test.js', 'The JavaScript integration file is loaded.');
-    $this->assertRaw('libraries_test.css', 'The CSS integration file is loaded.');
-    $this->assertText('libraries_test.inc', 'The PHP integration file is loaded.');
+    $this->assertRaw('libraries_test.js', 'Integration file loading: libraries_test.js found');
+    $this->assertRaw('libraries_test.css', 'Integration file loading: libraries_test.css found');
+    $this->assertRaw('libraries_test.inc', 'Integration file loading: libraries_test.inc found');
 
     // Test version overloading.
     $this->drupalGet('libraries_test/versions');
-    $this->assertLibraryFiles('example_2');
+    $this->assertLibraryFiles('example_2', 'Version overloading');
 
     // Test variant loading.
     $this->drupalGet('libraries_test/variant');
-    $this->assertLibraryFiles('example_3');
+    $this->assertLibraryFiles('example_3', 'Variant loading');
 
     // Test version overloading and variant loading.
     $this->drupalGet('libraries_test/versions_and_variants');
-    $this->assertLibraryFiles('example_4');
+    $this->assertLibraryFiles('example_4', 'Concurrent version and variant overloading');
   }
 
   /**
@@ -163,22 +195,31 @@ class LibrariesTestCase extends DrupalWe
    *   other files will be asserted to not be loaded. See
    *   tests/example/README.txt for more information on how the loading of the
    *   files is tested.
+   * @param $label
+   *   A label to prepend to the assertion messages, to make them less ambiguous.
+   * @param $extensions
+   *   (optional) The expected file extensions of $name. Defaults to
+   *   array('js', 'css', 'php').
    */
-  function assertLibraryFiles($name) {
+  function assertLibraryFiles($name, $label = '', $extensions = array('js', 'css', 'php')) {
     $names = drupal_map_assoc(array('example_1', 'example_2', 'example_3', 'example_4'));
     unset($names[$name]);
 
     // Test that the wrong files are not loaded.
     foreach ($names as $filename) {
-      $this->assertNoRaw("$filename.js", 'A wrong JavaScript file is not loaded.');
-      $this->assertNoRaw("$filename.css", 'A wrong CSS file is not loaded.');
-      $this->assertNoText("$filename.php", 'A wrong PHP file is not loaded.');
+      foreach ($extensions as $extension) {
+        $message = "$filename.$extension not found";
+        $message = ($label !== '' ? "$label: $message" : $message);
+        $this->assertNoRaw("$filename.$extension", $prefix . $message);
+      }
     }
 
     // Test that the correct files are loaded.
-    $this->assertRaw("$name.js", 'The correct JavaScript file is loaded.');
-    $this->assertRaw("$name.css", 'The correct CSS file is loaded.');
-    $this->assertText("$name.php", 'The correct PHP file is loaded.');
+    foreach ($extensions as $extension) {
+      $message = "$filename.$extension found";
+      $message = ($label !== '' ? "$label: $message" : $message);
+      $this->assertRaw("$name.$extension", $message);
+    }
   }
 
 }
Index: tests/libraries_test.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.css,v
retrieving revision 1.2
diff -u -p -r1.2 libraries_test.css
--- tests/libraries_test.css	23 Jul 2010 12:57:01 -0000	1.2
+++ tests/libraries_test.css	3 Nov 2010 20:11:42 -0000
@@ -4,12 +4,9 @@
  * @file
  * Test CSS file for Libraries loading.
  *
- * Because we cannot test CSS programatically with SimpleTest, the CSS below can
- * be useful for debugging with SimpleTest's verbose mode. Note that since the
- * DOM cannot be manipulated via CSS, JavaScript loading needs to be functional
- * for this to have any visible effect.
+ * Color the 'libraries-test-css' div blue. See README.txt for more information.
  */
 
-div#libraries-test {
+.libraries-test-css {
   color: purple;
 }
Index: tests/libraries_test.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.js,v
retrieving revision 1.3
diff -u -p -r1.3 libraries_test.js
--- tests/libraries_test.js	22 Sep 2010 17:00:56 -0000	1.3
+++ tests/libraries_test.js	3 Nov 2010 20:11:42 -0000
@@ -4,15 +4,15 @@
  * @file
  * Test JavaScript file for Libraries loading.
  *
- * Because we cannot test JavaScript programatically with SimpleTest, the
- * JavaScript below can be useful for debugging with SimpleTest's verbose mode.
+ * Replace the text in the 'libraries-test-javascript' div. See README.txt for
+ * more information.
  */
 
 (function ($) {
 
 Drupal.behaviors.librariesTest = {
   attach: function(context, settings) {
-    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is purple, the CSS file was loaded successfully.</div>')
+    $('.libraries-test-javascript').text('If this text shows up, libraries_test.js was loaded successfully')
   }
 };
 
Index: tests/libraries_test.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.module,v
retrieving revision 1.6
diff -u -p -r1.6 libraries_test.module
--- tests/libraries_test.module	15 Oct 2010 15:15:53 -0000	1.6
+++ tests/libraries_test.module	3 Nov 2010 20:11:43 -0000
@@ -13,21 +13,18 @@ function libraries_test_libraries_info()
   // Test library detection.
   $libraries['example_missing'] = array(
     'title' => 'Example missing',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/missing',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('1'),
   );
   $libraries['example_undetected_version'] = array(
     'title' => 'Example undetected version',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array(FALSE),
   );
   $libraries['example_unsupported_version'] = array(
     'title' => 'Example unsupported version',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('1'),
@@ -38,7 +35,6 @@ function libraries_test_libraries_info()
 
   $libraries['example_supported_version'] = array(
     'title' => 'Example supported version',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -50,7 +46,6 @@ function libraries_test_libraries_info()
   // Test the default version callback.
   $libraries['example_default_version_callback'] = array(
     'title' => 'Example default version callback',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version arguments' => array(
       'file' => 'README.txt',
@@ -63,7 +58,6 @@ function libraries_test_libraries_info()
   // Test a multiple-parameter version callback.
   $libraries['example_multiple_parameter_version_callback'] = array(
     'title' => 'Example_multiple_parameter_version_callback',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     // Version 2
     'version callback' => '_libraries_test_get_version',
@@ -73,7 +67,6 @@ function libraries_test_libraries_info()
   // Test a top-level files property.
   $libraries['example_simple'] = array(
     'title' => 'Example simple',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('1'),
@@ -95,7 +88,6 @@ function libraries_test_libraries_info()
   // these files should be automatically loaded when the library is loaded.
   $libraries['example_integration_files'] = array(
     'title' => 'Example integration files',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -111,7 +103,6 @@ function libraries_test_libraries_info()
   // Test version overloading.
   $libraries['example_versions'] = array(
     'title' => 'Example versions',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -136,7 +127,6 @@ function libraries_test_libraries_info()
   // Test variant detection.
   $libraries['example_variant_missing'] = array(
     'title' => 'Example variant missing',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -155,7 +145,6 @@ function libraries_test_libraries_info()
 
   $libraries['example_variant'] = array(
     'title' => 'Example variant',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -175,7 +164,6 @@ function libraries_test_libraries_info()
   // Test correct behaviour with multiple versions and multiple variants.
   $libraries['example_versions_and_variants'] = array(
     'title' => 'Example versions and variants',
-    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -226,6 +214,10 @@ function libraries_test_libraries_info()
       ),
     ),
   );
+ 
+  // This library is used together with libraries_info() to be populated with
+  // the defaults.
+  $libraries['empty'] = array();
 
   return $libraries;
 }
@@ -234,7 +226,7 @@ function libraries_test_libraries_info()
  * Implements hook_libraries_info_file_paths()
  */
 function libraries_test_libraries_info_file_paths() {
-  return array(drupal_get_path('module', 'libraries_test') . '/example');
+  return array(drupal_get_path('module', 'libraries_test') . '/libraries_info_example');
 }
 
 /**
@@ -346,27 +338,54 @@ function libraries_test_menu() {
 }
 
 /**
- * Loads the test library with multiple versions.
+ * Loads a specified library (variant) for testing.
+ *
+ * JavaScript and CSS files can be checked directly by SimpleTest, so we only
+ * need to manually check for PHP files. We provide information about the loaded
+ * JavaScript and CSS files for easier debugging. See example/README.txt for
+ * more information.
  */
 function _libraries_test_load($library, $variant = NULL) {
   libraries_load($library, $variant);
   // JavaScript and CSS files can be checked directly by SimpleTest, so we only
   // need to manually check for PHP files.
   $output = '';
-  if (function_exists('_libraries_test_example_1')) {
-    $output .= 'example_1.php';
-  }
-  if (function_exists('_libraries_test_example_2')) {
-    $output .= 'example_2.php';
-  }
-  if (function_exists('_libraries_test_example_3')) {
-    $output .= 'example_3.php';
-  }
-  if (function_exists('_libraries_test_example_4')) {
-    $output .= 'example_4.php';
-  }
-  if (function_exists('_libraries_test_integration_file')) {
-    $output .= 'libraries_test.inc';
+
+  // For easer debugging of JS loading, a text is shown that the JavaScript will
+  // replace.
+  $output .= '<h2>JavaScript</h2>';
+  $output .= '<div class="libraries-test-javascript">';
+  $output .= 'If this text shows up, no JavaScript test file was loaded.';
+  $output .= '</div>';
+
+  // For easier debugging of CSS loading, the loaded CSS files will color the
+  // following text.
+  $output .= '<h2>CSS</h2>';
+  $output .= '<div class="libraries-test-css">';
+  $output .= 'If one of the CSS test files has been loaded, this text will be colored:';
+  $output .= '<ul>';
+  // Do not reference the actual CSS files (i.e. including '.css'), because that
+  // breaks testing.
+  $output .= '<li>example_1: red</li>';
+  $output .= '<li>example_2: green</li>';
+  $output .= '<li>example_3: orange</li>';
+  $output .= '<li>example_4: blue</li>';
+  $output .= '<li>libraries_test: purple</li>';
+  $output .= '</ul>';
+  $output .= '</div>';
+
+  $output .= '<h2>PHP</h2>';
+  $output .= '<div class="libraries-test-php">';
+  $output .= 'The following is a list of all loaded test PHP files:';
+  $output .= '<ul>';
+  $files = get_included_files();
+  foreach ($files as $file) {
+    if (strpos($file, 'libraries/test') && !strpos($file, 'libraries_test.module')) {
+      $output .= '<li>' . strstr($file, 'libraries/test') . '</li>';
+    }
   }
+  $output .= '</ul>';
+  $output .= '</div>';
+
   return $output;
 }
Index: tests/example/example_1.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_1.css,v
retrieving revision 1.1
diff -u -p -r1.1 example_1.css
--- tests/example/example_1.css	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_1.css	3 Nov 2010 20:11:43 -0000
@@ -4,10 +4,9 @@
  * @file
  * Test CSS file for Libraries loading.
  *
- * Color the 'libraries-test' div red. See example_installed.txt for more
- * information.
+ * Color the 'libraries-test-css' div red. See README.txt for more information.
  */
 
-div#libraries-test {
+.libraries-test-css {
   color: red;
 }
Index: tests/example/example_1.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_1.js,v
retrieving revision 1.1
diff -u -p -r1.1 example_1.js
--- tests/example/example_1.js	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_1.js	3 Nov 2010 20:11:43 -0000
@@ -4,15 +4,15 @@
  * @file
  * Test JavaScript file for Libraries loading.
  *
- * Insert a 'libraries-test' div and some text below the page title. See
- * example_installed.txt for more information.
+ * Replace the text in the 'libraries-test-javascript' div. See README.txt for
+ * more information.
  */
 
 (function ($) {
 
 Drupal.behaviors.librariesTest = {
   attach: function(context, settings) {
-    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is red, the CSS file was loaded successfully.</div>')
+    $('.libraries-test-javascript').text('If this text shows up, example_1.js was loaded successfully')
   }
 };
 
Index: tests/example/example_2.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_2.css,v
retrieving revision 1.1
diff -u -p -r1.1 example_2.css
--- tests/example/example_2.css	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_2.css	3 Nov 2010 20:11:43 -0000
@@ -4,10 +4,9 @@
  * @file
  * Test CSS file for Libraries loading.
  *
- * Color the 'libraries-test' div green. See example_installed.txt for more
- * information.
+ * Color the 'libraries-test-css' div green. See README.txt for more information.
  */
 
-div#libraries-test {
+.libraries-test-css {
   color: green;
 }
Index: tests/example/example_2.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_2.js,v
retrieving revision 1.1
diff -u -p -r1.1 example_2.js
--- tests/example/example_2.js	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_2.js	3 Nov 2010 20:11:43 -0000
@@ -4,15 +4,15 @@
  * @file
  * Test JavaScript file for Libraries loading.
  *
- * Insert a 'libraries-test' div and some text below the page title. See
- * example_installed.txt for more information.
+ * Replace the text in the 'libraries-test-javascript' div. See README.txt for
+ * more information.
  */
 
 (function ($) {
 
 Drupal.behaviors.librariesTest = {
   attach: function(context, settings) {
-    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is green, the CSS file was loaded successfully.</div>')
+    $('.libraries-test-javascript').text('If this text shows up, example_2.js was loaded successfully')
   }
 };
 
Index: tests/example/example_3.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_3.css,v
retrieving revision 1.1
diff -u -p -r1.1 example_3.css
--- tests/example/example_3.css	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_3.css	3 Nov 2010 20:11:43 -0000
@@ -4,10 +4,9 @@
  * @file
  * Test CSS file for Libraries loading.
  *
- * Color the 'libraries-test' div orange. See example_installed.txt for more
- * information.
+ * Color the 'libraries-test-css' div orange. See README.txt for more information.
  */
 
-div#libraries-test {
+.libraries-test-css {
   color: orange;
 }
Index: tests/example/example_3.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_3.js,v
retrieving revision 1.1
diff -u -p -r1.1 example_3.js
--- tests/example/example_3.js	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_3.js	3 Nov 2010 20:11:43 -0000
@@ -4,15 +4,15 @@
  * @file
  * Test JavaScript file for Libraries loading.
  *
- * Insert a 'libraries-test' div and some text below the page title. See
- * example_installed.txt for more information.
+ * Replace the text in the 'libraries-test-javascript' div. See README.txt for
+ * more information.
  */
 
 (function ($) {
 
 Drupal.behaviors.librariesTest = {
   attach: function(context, settings) {
-    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is orange, the CSS file was loaded successfully.</div>')
+    $('.libraries-test-javascript').text('If this text shows up, example_3.js was loaded successfully')
   }
 };
 
Index: tests/example/example_4.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_4.css,v
retrieving revision 1.1
diff -u -p -r1.1 example_4.css
--- tests/example/example_4.css	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_4.css	3 Nov 2010 20:11:43 -0000
@@ -4,10 +4,9 @@
  * @file
  * Test CSS file for Libraries loading.
  *
- * Color the 'libraries-test' div blue. See example_installed.txt for more
- * information.
+ * Color the 'libraries-test-css' div blue. See README.txt for more information.
  */
 
-div#libraries-test {
+.libraries-test-css {
   color: blue;
 }
Index: tests/example/example_4.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_4.js,v
retrieving revision 1.1
diff -u -p -r1.1 example_4.js
--- tests/example/example_4.js	22 Sep 2010 17:30:38 -0000	1.1
+++ tests/example/example_4.js	3 Nov 2010 20:11:43 -0000
@@ -4,15 +4,15 @@
  * @file
  * Test JavaScript file for Libraries loading.
  *
- * Insert a 'libraries-test' div and some text below the page title. See
- * example_installed.txt for more information.
+ * Replace the text in the 'libraries-test-javascript' div. See README.txt for
+ * more information.
  */
 
 (function ($) {
 
 Drupal.behaviors.librariesTest = {
   attach: function(context, settings) {
-    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is blue, the CSS file was loaded successfully.</div>')
+    $('.libraries-test-javascript').text('If this text shows up, example_4.js was loaded successfully')
   }
 };
 
