blob: d166add00d111551e5f3af1bb81c4eb63f7fe8d5 [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
24func TestSnapshotWithCompatConfig(t *testing.T) {
25 result := android.GroupFixturePreparers(
26 prepareForSdkTestWithJava,
27 java.PrepareForTestWithPlatformCompatConfig,
28 ).RunTestWithBp(t, `
29 sdk {
30 name: "mysdk",
31 compat_configs: ["myconfig"],
32 }
33
34 platform_compat_config {
35 name: "myconfig",
36 }
37 `)
38
39 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinb01ac4b2022-05-24 20:10:05 +000040 checkAndroidBpContents(`
Paul Duffin001b2342021-03-11 18:43:31 +000041// This is auto-generated. DO NOT EDIT.
42
43prebuilt_platform_compat_config {
44 name: "myconfig",
45 prefer: false,
46 visibility: ["//visibility:public"],
47 metadata: "compat_configs/myconfig/myconfig_meta.xml",
48}
49`),
50 checkAllCopyRules(`
51.intermediates/myconfig/android_common/myconfig_meta.xml -> compat_configs/myconfig/myconfig_meta.xml
52`),
Paul Duffin1822a0a2021-03-21 12:56:33 +000053 snapshotTestChecker(checkSnapshotWithoutSource,
54 func(t *testing.T, result *android.TestResult) {
55 // Make sure that the snapshot metadata is collated by the platform compat config singleton.
56 java.CheckMergedCompatConfigInputs(t, result, "snapshot module", "snapshot/compat_configs/myconfig/myconfig_meta.xml")
57 }),
58
59 snapshotTestChecker(checkSnapshotWithSourcePreferred,
60 func(t *testing.T, result *android.TestResult) {
61 // Make sure that the snapshot metadata is collated by the platform compat config singleton.
62 java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
63 "out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml",
Paul Duffin1822a0a2021-03-21 12:56:33 +000064 )
65 }),
66
67 snapshotTestChecker(checkSnapshotPreferredWithSource,
68 func(t *testing.T, result *android.TestResult) {
69 // Make sure that the snapshot metadata is collated by the platform compat config singleton.
70 java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
Paul Duffin1822a0a2021-03-21 12:56:33 +000071 "snapshot/compat_configs/myconfig/myconfig_meta.xml",
72 )
73 }),
Paul Duffin001b2342021-03-11 18:43:31 +000074 )
75}