blob: 1f4c2af324933c2c0f777d4a88e14b98605b4b48 [file] [log] [blame]
Zi Wang0d6a5302023-02-16 14:54:01 -08001// Copyright (C) 2023 The Android Open Source Project
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 api
16
17import (
18 "testing"
19
20 "android/soong/android"
21 "android/soong/bp2build"
Jihoon Kang1453baa2023-05-27 05:32:30 +000022 "android/soong/java"
Zi Wang0d6a5302023-02-16 14:54:01 -080023)
24
25func runCombinedApisTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2build.Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
26 t.Helper()
27 (&tc).ModuleTypeUnderTest = "combined_apis"
28 (&tc).ModuleTypeUnderTestFactory = combinedApisModuleFactory
29 bp2build.RunBp2BuildTestCase(t, registrationCtxFunc, tc)
30}
31
32func runCombinedApisTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) {
33 t.Helper()
Jihoon Kang1453baa2023-05-27 05:32:30 +000034 runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {
35 ctx.RegisterModuleType("java_defaults", java.DefaultsFactory)
36 })
Zi Wang0d6a5302023-02-16 14:54:01 -080037}
38
39func TestCombinedApisGeneral(t *testing.T) {
40 runCombinedApisTestCase(t, bp2build.Bp2buildTestCase{
41 Description: "combined_apis, general case",
42 Blueprint: `combined_apis {
43 name: "foo",
44 bootclasspath: ["bcp"],
45 system_server_classpath: ["ssc"],
46}
47`,
Jihoon Kang1453baa2023-05-27 05:32:30 +000048 Filesystem: map[string]string{
49 "a/Android.bp": `
50 java_defaults {
51 name: "android.jar_defaults",
52 }
53 `,
54 },
Zi Wang0d6a5302023-02-16 14:54:01 -080055 ExpectedBazelTargets: []string{
56 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-current.txt", bp2build.AttrNameToString{
57 "scope": `"public"`,
58 "base": `":non-updatable-current.txt__BP2BUILD__MISSING__DEP"`,
59 "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
60 }),
61 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-current.txt", bp2build.AttrNameToString{
62 "scope": `"system"`,
63 "base": `":non-updatable-system-current.txt__BP2BUILD__MISSING__DEP"`,
64 "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
65 }),
66 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-module-lib-current.txt", bp2build.AttrNameToString{
67 "scope": `"module-lib"`,
68 "base": `":non-updatable-module-lib-current.txt__BP2BUILD__MISSING__DEP"`,
69 "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
70 }),
71 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-server-current.txt", bp2build.AttrNameToString{
72 "scope": `"system-server"`,
73 "base": `":non-updatable-system-server-current.txt__BP2BUILD__MISSING__DEP"`,
74 "deps": `[":ssc__BP2BUILD__MISSING__DEP"]`,
75 }),
76 },
77 })
78}