blob: ec7cea3833f672c26fe0331cd12c6f029f21f36b [file] [log] [blame]
Jihoon Kang2a43e562024-02-12 19:05:12 +00001// Copyright 2024 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package codegen
16
17import (
18 "android/soong/android"
19 "android/soong/java"
20 "testing"
21)
22
23func TestAconfigDeclarationsGroup(t *testing.T) {
24 result := android.GroupFixturePreparers(
25 PrepareForTestWithAconfigBuildComponents,
26 java.PrepareForTestWithJavaDefaultModules,
27 ).RunTestWithBp(t, `
28 aconfig_declarations {
29 name: "foo-aconfig",
30 package: "com.example.package",
31 srcs: ["foo.aconfig"],
32 }
33
34 java_aconfig_library {
35 name: "foo-java",
36 aconfig_declarations: "foo-aconfig",
37 }
38
39 aconfig_declarations {
40 name: "bar-aconfig",
41 package: "com.example.package",
42 srcs: ["foo.aconfig"],
43 }
44
45 java_aconfig_library {
46 name: "bar-java",
47 aconfig_declarations: "bar-aconfig",
48 }
49
50 aconfig_declarations_group {
51 name: "my_group",
52 java_aconfig_libraries: [
53 "foo-java",
54 "bar-java",
55 ],
56 }
57
58 java_library {
59 name: "baz",
60 srcs: [
61 ":my_group{.srcjars}",
62 ],
63 }
64 `)
65
66 // Check if aconfig_declarations_group module depends on the aconfig_library modules
67 java.CheckModuleDependencies(t, result.TestContext, "my_group", "", []string{
68 `bar-java`,
69 `foo-java`,
70 })
71
72 // Check if srcjar files are correctly passed to the reverse dependency of
73 // aconfig_declarations_group module
74 bazModule := result.ModuleForTests("baz", "android_common")
75 bazJavacSrcjars := bazModule.Rule("javac").Args["srcJars"]
76 errorMessage := "baz javac argument expected to contain srcjar provided by aconfig_declrations_group"
77 android.AssertStringDoesContain(t, errorMessage, bazJavacSrcjars, "foo-java.srcjar")
78 android.AssertStringDoesContain(t, errorMessage, bazJavacSrcjars, "bar-java.srcjar")
79}