blob: 15b695ca0d36725da195858cf19126b7afc03fec [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"
22)
23
24func runCombinedApisTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2build.Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
25 t.Helper()
26 (&tc).ModuleTypeUnderTest = "combined_apis"
27 (&tc).ModuleTypeUnderTestFactory = combinedApisModuleFactory
28 bp2build.RunBp2BuildTestCase(t, registrationCtxFunc, tc)
29}
30
31func runCombinedApisTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) {
32 t.Helper()
33 runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
34}
35
36func TestCombinedApisGeneral(t *testing.T) {
37 runCombinedApisTestCase(t, bp2build.Bp2buildTestCase{
38 Description: "combined_apis, general case",
39 Blueprint: `combined_apis {
40 name: "foo",
41 bootclasspath: ["bcp"],
42 system_server_classpath: ["ssc"],
43}
44`,
45 ExpectedBazelTargets: []string{
46 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-current.txt", bp2build.AttrNameToString{
47 "scope": `"public"`,
48 "base": `":non-updatable-current.txt__BP2BUILD__MISSING__DEP"`,
49 "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
50 }),
51 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-current.txt", bp2build.AttrNameToString{
52 "scope": `"system"`,
53 "base": `":non-updatable-system-current.txt__BP2BUILD__MISSING__DEP"`,
54 "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
55 }),
56 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-module-lib-current.txt", bp2build.AttrNameToString{
57 "scope": `"module-lib"`,
58 "base": `":non-updatable-module-lib-current.txt__BP2BUILD__MISSING__DEP"`,
59 "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
60 }),
61 bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-server-current.txt", bp2build.AttrNameToString{
62 "scope": `"system-server"`,
63 "base": `":non-updatable-system-server-current.txt__BP2BUILD__MISSING__DEP"`,
64 "deps": `[":ssc__BP2BUILD__MISSING__DEP"]`,
65 }),
66 },
67 })
68}