Fix some tests to work in prebuilt ART module mode.

test_for registers dependencies on the APEX modules, so don't use it
when they are disabled.

Test: m nothing SOONG_CONFIG_art_module_source_build=false
Test: mmm art
Test: art/tools/buildbot-build.sh
Bug: 172480615
Change-Id: I67e25e80926054390ebd8ad4cf54da44afc71315
diff --git a/build/SoongConfig.bp b/build/SoongConfig.bp
index c466324..38c0d97 100644
--- a/build/SoongConfig.bp
+++ b/build/SoongConfig.bp
@@ -23,7 +23,10 @@
     module_type: "cc_defaults",
     config_namespace: "art_module",
     bool_variables: ["source_build"],
-    properties: ["enabled"],
+    properties: [
+        "enabled",
+        "target.android.test_for",
+    ],
 }
 
 soong_config_module_type {
diff --git a/test/Android.bp b/test/Android.bp
index d71bd06..1a14eff 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -25,16 +25,29 @@
     default_applicable_licenses: ["art_license"],
 }
 
-art_cc_defaults {
+soong_config_module_type_import {
+    from: "art/build/SoongConfig.bp",
+    module_types: [
+        "art_module_cc_defaults",
+    ],
+}
+
+art_module_cc_defaults {
     name: "art_test_defaults",
     host_supported: true,
-    target: {
-        android: {
-            test_for: [
-                "com.android.art",
-                "com.android.art.debug",
-            ],
+    soong_config_variables: {
+        source_build: {
+            target: {
+                android: {
+                    test_for: [
+                        "com.android.art",
+                        "com.android.art.debug",
+                    ],
+                },
+            },
         },
+    },
+    target: {
         // The following set of relative_install_paths installs the library in a
         // location that will be available as java.library.path in run tests.
         android_arm: {