aboutsummaryrefslogtreecommitdiff
path: root/java/generated_java_library_test.go
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2023-06-01 14:42:59 -0700
committerJoe Onorato <joeo@google.com>2023-06-09 06:16:06 -0700
commit175073c472baadcf6ccd7bf94f013a28edf0713a (patch)
tree445ad40f4b620cdb0ab83ef38aff29b1d0b3f0eb /java/generated_java_library_test.go
parentf1d37b351147ba74be40f5f313e61e9956e44d7f (diff)
Make aconfig flags generate a library instead of a srcjar.
Also add unit tests for the rest of device_config Bug: 283475679 Test: m nothing (soong unit tests) Change-Id: Iee18a1f2f2cbb23e8c8d84c54e903b32be29a693
Diffstat (limited to 'java/generated_java_library_test.go')
-rw-r--r--java/generated_java_library_test.go65
1 files changed, 65 insertions, 0 deletions
diff --git a/java/generated_java_library_test.go b/java/generated_java_library_test.go
new file mode 100644
index 000000000..68f1f7edd
--- /dev/null
+++ b/java/generated_java_library_test.go
@@ -0,0 +1,65 @@
+// Copyright 2018 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package java
+
+import (
+ "testing"
+
+ "android/soong/android"
+)
+
+func JavaGenLibTestFactory() android.Module {
+ callbacks := &JavaGenLibTestCallbacks{}
+ return GeneratedJavaLibraryModuleFactory("test_java_gen_lib", callbacks, &callbacks.properties)
+}
+
+type JavaGenLibTestProperties struct {
+ Foo string
+}
+
+type JavaGenLibTestCallbacks struct {
+ properties JavaGenLibTestProperties
+}
+
+func (callbacks *JavaGenLibTestCallbacks) DepsMutator(module *GeneratedJavaLibraryModule, ctx android.BottomUpMutatorContext) {
+}
+
+func (callbacks *JavaGenLibTestCallbacks) GenerateSourceJarBuildActions(ctx android.ModuleContext) android.Path {
+ return android.PathForOutput(ctx, "blah.srcjar")
+}
+
+func testGenLib(t *testing.T, errorHandler android.FixtureErrorHandler, bp string) *android.TestResult {
+ return android.GroupFixturePreparers(
+ PrepareForIntegrationTestWithJava,
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("test_java_gen_lib", JavaGenLibTestFactory)
+ }),
+ ).
+ ExtendWithErrorHandler(errorHandler).
+ RunTestWithBp(t, bp)
+}
+
+func TestGenLib(t *testing.T) {
+ bp := `
+ test_java_gen_lib {
+ name: "javagenlibtest",
+ foo: "bar", // Note: This won't parse if the property didn't get added
+ }
+ `
+ result := testGenLib(t, android.FixtureExpectsNoErrors, bp)
+
+ javagenlibtest := result.ModuleForTests("javagenlibtest", "android_common").Module().(*GeneratedJavaLibraryModule)
+ android.AssertPathsEndWith(t, "Generated_srcjars", []string{"/blah.srcjar"}, javagenlibtest.Library.properties.Generated_srcjars)
+}