summaryrefslogtreecommitdiff
path: root/java/testing.go
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-09-20 14:04:35 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-09-20 14:04:35 +0000
commit3769a27c5ea903db6362604d0d70c8e1cd0fa3cf (patch)
treed80b3c01d09a182087f462ad92d3bb63e04fc44e /java/testing.go
parent3536614eddd6acccd7457bb3a1406c0a6775dd42 (diff)
parent1ea7c9fa522c81da21989e0f1e5d1af67bb02b08 (diff)
Merge "Add test to TestJavaStableSdkVersion for legacy core platform"
Diffstat (limited to 'java/testing.go')
-rw-r--r--java/testing.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/java/testing.go b/java/testing.go
index d8a77cf37..a642753c4 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -229,6 +229,26 @@ func FixtureConfigureApexBootJars(bootJars ...string) android.FixturePreparer {
)
}
+// FixtureUseLegacyCorePlatformApi prepares the fixture by setting the exception list of those
+// modules that are allowed to use the legacy core platform API to be the ones supplied.
+func FixtureUseLegacyCorePlatformApi(moduleNames ...string) android.FixturePreparer {
+ lookup := make(map[string]struct{})
+ for _, moduleName := range moduleNames {
+ lookup[moduleName] = struct{}{}
+ }
+ return android.FixtureModifyConfig(func(config android.Config) {
+ // Try and set the legacyCorePlatformApiLookup in the config, the returned value will be the
+ // actual value that is set.
+ cached := config.Once(legacyCorePlatformApiLookupKey, func() interface{} {
+ return lookup
+ })
+ // Make sure that the cached value is the one we need.
+ if !reflect.DeepEqual(cached, lookup) {
+ panic(fmt.Errorf("attempting to set legacyCorePlatformApiLookupKey to %q but it has already been set to %q", lookup, cached))
+ }
+ })
+}
+
// registerRequiredBuildComponentsForTest registers the build components used by
// PrepareForTestWithJavaDefaultModules.
//