• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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", "",
40		checkVersionedAndroidBpContents(`
41// This is auto-generated. DO NOT EDIT.
42
43prebuilt_platform_compat_config {
44    name: "mysdk_myconfig@current",
45    sdk_member_name: "myconfig",
46    visibility: ["//visibility:public"],
47    metadata: "compat_configs/myconfig/myconfig_meta.xml",
48}
49
50sdk_snapshot {
51    name: "mysdk@current",
52    visibility: ["//visibility:public"],
53    compat_configs: ["mysdk_myconfig@current"],
54}
55`),
56		checkUnversionedAndroidBpContents(`
57// This is auto-generated. DO NOT EDIT.
58
59prebuilt_platform_compat_config {
60    name: "myconfig",
61    prefer: false,
62    visibility: ["//visibility:public"],
63    metadata: "compat_configs/myconfig/myconfig_meta.xml",
64}
65`),
66		checkAllCopyRules(`
67.intermediates/myconfig/android_common/myconfig_meta.xml -> compat_configs/myconfig/myconfig_meta.xml
68`),
69		snapshotTestChecker(checkSnapshotWithoutSource,
70			func(t *testing.T, result *android.TestResult) {
71				// Make sure that the snapshot metadata is collated by the platform compat config singleton.
72				java.CheckMergedCompatConfigInputs(t, result, "snapshot module", "snapshot/compat_configs/myconfig/myconfig_meta.xml")
73			}),
74
75		snapshotTestChecker(checkSnapshotWithSourcePreferred,
76			func(t *testing.T, result *android.TestResult) {
77				// Make sure that the snapshot metadata is collated by the platform compat config singleton.
78				java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
79					"out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml",
80				)
81			}),
82
83		snapshotTestChecker(checkSnapshotPreferredWithSource,
84			func(t *testing.T, result *android.TestResult) {
85				// Make sure that the snapshot metadata is collated by the platform compat config singleton.
86				java.CheckMergedCompatConfigInputs(t, result, "snapshot module",
87					"snapshot/compat_configs/myconfig/myconfig_meta.xml",
88				)
89			}),
90	)
91}
92