Add baseline test for license with sdk

This change adds a test that includes license modules that are used by
modules which are part of an sdk but which does not yet copy the
license module into the snapshot. It includes the refactoring changes
needed to allow license modules to be used in an sdk test and provides
a baseline against which future changes can be compared.

Bug: 181569894
Test: m nothing
Change-Id: I60722f43cc9cc8375d97f46eb4c281e6c38987cd
diff --git a/android/license_test.go b/android/license_test.go
index 2b09a4f..26b33c3 100644
--- a/android/license_test.go
+++ b/android/license_test.go
@@ -8,7 +8,7 @@
 var prepareForLicenseTest = GroupFixturePreparers(
 	// General preparers in alphabetical order.
 	PrepareForTestWithDefaults,
-	prepareForTestWithLicenses,
+	PrepareForTestWithLicenses,
 	PrepareForTestWithOverrides,
 	PrepareForTestWithPackageModule,
 	PrepareForTestWithPrebuilts,
diff --git a/android/licenses_test.go b/android/licenses_test.go
index 913dc88..9b2e06c 100644
--- a/android/licenses_test.go
+++ b/android/licenses_test.go
@@ -6,18 +6,6 @@
 	"github.com/google/blueprint"
 )
 
-var prepareForTestWithLicenses = GroupFixturePreparers(
-	FixtureRegisterWithContext(RegisterLicenseKindBuildComponents),
-	FixtureRegisterWithContext(RegisterLicenseBuildComponents),
-	FixtureRegisterWithContext(registerLicenseMutators),
-)
-
-func registerLicenseMutators(ctx RegistrationContext) {
-	ctx.PreArchMutators(RegisterLicensesPackageMapper)
-	ctx.PreArchMutators(RegisterLicensesPropertyGatherer)
-	ctx.PostDepsMutators(RegisterLicensesDependencyChecker)
-}
-
 var licensesTests = []struct {
 	name                       string
 	fs                         MockFS
diff --git a/android/testing.go b/android/testing.go
index ce27fca..191cb8d 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -74,6 +74,42 @@
 	ctx.PostDepsMutators(RegisterOverridePostDepsMutators)
 })
 
+var PrepareForTestWithLicenses = GroupFixturePreparers(
+	FixtureRegisterWithContext(RegisterLicenseKindBuildComponents),
+	FixtureRegisterWithContext(RegisterLicenseBuildComponents),
+	FixtureRegisterWithContext(registerLicenseMutators),
+)
+
+func registerLicenseMutators(ctx RegistrationContext) {
+	ctx.PreArchMutators(RegisterLicensesPackageMapper)
+	ctx.PreArchMutators(RegisterLicensesPropertyGatherer)
+	ctx.PostDepsMutators(RegisterLicensesDependencyChecker)
+}
+
+var PrepareForTestWithLicenseDefaultModules = GroupFixturePreparers(
+	FixtureAddTextFile("build/soong/licenses/Android.bp", `
+		license {
+				name: "Android-Apache-2.0",
+				package_name: "Android",
+				license_kinds: ["SPDX-license-identifier-Apache-2.0"],
+				copyright_notice: "Copyright (C) The Android Open Source Project",
+				license_text: ["LICENSE"],
+		}
+
+		license_kind {
+				name: "SPDX-license-identifier-Apache-2.0",
+				conditions: ["notice"],
+				url: "https://spdx.org/licenses/Apache-2.0.html",
+		}
+
+		license_kind {
+				name: "legacy_unencumbered",
+				conditions: ["unencumbered"],
+		}
+	`),
+	FixtureAddFile("build/soong/licenses/LICENSE", nil),
+)
+
 // Test fixture preparer that will register most java build components.
 //
 // Singletons and mutators should only be added here if they are needed for a majority of java