blob: 45e8e0ed6d733d150f1d54574fa26ed4d6293299 [file] [log] [blame]
Paul Duffin001b2342021-03-11 18:43:31 +00001// Copyright 2021 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 sdk
16
17import (
18 "testing"
19
20 "android/soong/android"
21 "android/soong/java"
22)
23
Paul Duffinfcf79852022-07-20 14:18:24 +000024func testSnapshotWithCompatConfig(t *testing.T, sdk string) {
Paul Duffin001b2342021-03-11 18:43:31 +000025 result := android.GroupFixturePreparers(
26 prepareForSdkTestWithJava,
27 java.PrepareForTestWithPlatformCompatConfig,
Paul Duffinfcf79852022-07-20 14:18:24 +000028 prepareForSdkTestWithApex,
29 ).RunTestWithBp(t, sdk+`
Paul Duffin001b2342021-03-11 18:43:31 +000030 platform_compat_config {
31 name: "myconfig",
32 }
33 `)
34
35 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinb01ac4b2022-05-24 20:10:05 +000036 checkAndroidBpContents(`
Paul Duffin001b2342021-03-11 18:43:31 +000037// This is auto-generated. DO NOT EDIT.
38
39prebuilt_platform_compat_config {
40 name: "myconfig",
41 prefer: false,
42 visibility: ["//visibility:public"],
43 metadata: "compat_configs/myconfig/myconfig_meta.xml",
44}
45`),
46 checkAllCopyRules(`
47.intermediates/myconfig/android_common/myconfig_meta.xml -> compat_configs/myconfig/myconfig_meta.xml
48`),
Paul Duffin1822a0a2021-03-21 12:56:33 +000049 snapshotTestChecker(checkSnapshotWithoutSource,
50 func(t *testing.T, result *android.TestResult) {
51 // Make sure that the snapshot metadata is collated by the platform compat config singleton.
52 java.CheckMergedCompatConfigInputs(t, result, "snapshot module", "snapshot/compat_configs/myconfig/myconfig_meta.xml")
53 }),
54
55 snapshotTestChecker(checkSnapshotWithSourcePreferred,
56 func(t *testing.T, result *android.TestResult) {
57 // Make sure that the snapshot metadata is collated by the platform compat config singleton.
58 java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
59 "out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml",
Paul Duffin1822a0a2021-03-21 12:56:33 +000060 )
61 }),
62
63 snapshotTestChecker(checkSnapshotPreferredWithSource,
64 func(t *testing.T, result *android.TestResult) {
65 // Make sure that the snapshot metadata is collated by the platform compat config singleton.
66 java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
Paul Duffin1822a0a2021-03-21 12:56:33 +000067 "snapshot/compat_configs/myconfig/myconfig_meta.xml",
68 )
69 }),
Paul Duffin001b2342021-03-11 18:43:31 +000070 )
71}
Paul Duffinfcf79852022-07-20 14:18:24 +000072
73func TestSnapshotWithCompatConfig(t *testing.T) {
74 testSnapshotWithCompatConfig(t, `
75 sdk {
76 name: "mysdk",
77 compat_configs: ["myconfig"],
78 }
79`)
80}
81
82func TestSnapshotWithCompatConfig_Apex(t *testing.T) {
83 testSnapshotWithCompatConfig(t, `
84 apex {
85 name: "myapex",
86 key: "myapex.key",
87 min_sdk_version: "2",
88 compat_configs: ["myconfig"],
89 }
90
91 sdk {
92 name: "mysdk",
93 apexes: ["myapex"],
94 }
95`)
96}