Paul Duffin | 001b234 | 2021-03-11 18:43:31 +0000 | [diff] [blame] | 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 | |
| 15 | package sdk |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | "android/soong/java" |
| 22 | ) |
| 23 | |
| 24 | func 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 Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame^] | 40 | checkAndroidBpContents(` |
Paul Duffin | 001b234 | 2021-03-11 18:43:31 +0000 | [diff] [blame] | 41 | // This is auto-generated. DO NOT EDIT. |
| 42 | |
| 43 | prebuilt_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 Duffin | 1822a0a | 2021-03-21 12:56:33 +0000 | [diff] [blame] | 53 | 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 Duffin | 1822a0a | 2021-03-21 12:56:33 +0000 | [diff] [blame] | 64 | ) |
| 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 Duffin | 1822a0a | 2021-03-21 12:56:33 +0000 | [diff] [blame] | 71 | "snapshot/compat_configs/myconfig/myconfig_meta.xml", |
| 72 | ) |
| 73 | }), |
Paul Duffin | 001b234 | 2021-03-11 18:43:31 +0000 | [diff] [blame] | 74 | ) |
| 75 | } |