1*333d2b36SAndroid Build Coastguard Worker// Copyright 2021 Google Inc. All rights reserved. 2*333d2b36SAndroid Build Coastguard Worker// 3*333d2b36SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*333d2b36SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*333d2b36SAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*333d2b36SAndroid Build Coastguard Worker// 7*333d2b36SAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*333d2b36SAndroid Build Coastguard Worker// 9*333d2b36SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*333d2b36SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*333d2b36SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*333d2b36SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*333d2b36SAndroid Build Coastguard Worker// limitations under the License. 14*333d2b36SAndroid Build Coastguard Worker 15*333d2b36SAndroid Build Coastguard Workerpackage sdk 16*333d2b36SAndroid Build Coastguard Worker 17*333d2b36SAndroid Build Coastguard Workerimport ( 18*333d2b36SAndroid Build Coastguard Worker "testing" 19*333d2b36SAndroid Build Coastguard Worker 20*333d2b36SAndroid Build Coastguard Worker "android/soong/android" 21*333d2b36SAndroid Build Coastguard Worker "android/soong/java" 22*333d2b36SAndroid Build Coastguard Worker) 23*333d2b36SAndroid Build Coastguard Worker 24*333d2b36SAndroid Build Coastguard Workerfunc testSnapshotWithCompatConfig(t *testing.T, sdk string) { 25*333d2b36SAndroid Build Coastguard Worker result := android.GroupFixturePreparers( 26*333d2b36SAndroid Build Coastguard Worker prepareForSdkTestWithJava, 27*333d2b36SAndroid Build Coastguard Worker java.PrepareForTestWithPlatformCompatConfig, 28*333d2b36SAndroid Build Coastguard Worker prepareForSdkTestWithApex, 29*333d2b36SAndroid Build Coastguard Worker ).RunTestWithBp(t, sdk+` 30*333d2b36SAndroid Build Coastguard Worker platform_compat_config { 31*333d2b36SAndroid Build Coastguard Worker name: "myconfig", 32*333d2b36SAndroid Build Coastguard Worker } 33*333d2b36SAndroid Build Coastguard Worker `) 34*333d2b36SAndroid Build Coastguard Worker 35*333d2b36SAndroid Build Coastguard Worker CheckSnapshot(t, result, "mysdk", "", 36*333d2b36SAndroid Build Coastguard Worker checkAndroidBpContents(` 37*333d2b36SAndroid Build Coastguard Worker// This is auto-generated. DO NOT EDIT. 38*333d2b36SAndroid Build Coastguard Worker 39*333d2b36SAndroid Build Coastguard Workerapex_contributions_defaults { 40*333d2b36SAndroid Build Coastguard Worker name: "mysdk.contributions", 41*333d2b36SAndroid Build Coastguard Worker contents: ["prebuilt_myconfig"], 42*333d2b36SAndroid Build Coastguard Worker} 43*333d2b36SAndroid Build Coastguard Worker 44*333d2b36SAndroid Build Coastguard Workerprebuilt_platform_compat_config { 45*333d2b36SAndroid Build Coastguard Worker name: "myconfig", 46*333d2b36SAndroid Build Coastguard Worker prefer: false, 47*333d2b36SAndroid Build Coastguard Worker visibility: ["//visibility:public"], 48*333d2b36SAndroid Build Coastguard Worker metadata: "compat_configs/myconfig/myconfig_meta.xml", 49*333d2b36SAndroid Build Coastguard Worker} 50*333d2b36SAndroid Build Coastguard Worker`), 51*333d2b36SAndroid Build Coastguard Worker checkAllCopyRules(` 52*333d2b36SAndroid Build Coastguard Worker.intermediates/myconfig/android_common/myconfig_meta.xml -> compat_configs/myconfig/myconfig_meta.xml 53*333d2b36SAndroid Build Coastguard Worker`), 54*333d2b36SAndroid Build Coastguard Worker snapshotTestChecker(checkSnapshotWithoutSource, 55*333d2b36SAndroid Build Coastguard Worker func(t *testing.T, result *android.TestResult) { 56*333d2b36SAndroid Build Coastguard Worker // Make sure that the snapshot metadata is collated by the platform compat config singleton. 57*333d2b36SAndroid Build Coastguard Worker java.CheckMergedCompatConfigInputs(t, result, "snapshot module", "snapshot/compat_configs/myconfig/myconfig_meta.xml") 58*333d2b36SAndroid Build Coastguard Worker }), 59*333d2b36SAndroid Build Coastguard Worker 60*333d2b36SAndroid Build Coastguard Worker snapshotTestChecker(checkSnapshotWithSourcePreferred, 61*333d2b36SAndroid Build Coastguard Worker func(t *testing.T, result *android.TestResult) { 62*333d2b36SAndroid Build Coastguard Worker // Make sure that the snapshot metadata is collated by the platform compat config singleton. 63*333d2b36SAndroid Build Coastguard Worker java.CheckMergedCompatConfigInputs(t, result, "snapshot module", 64*333d2b36SAndroid Build Coastguard Worker "out/soong/.intermediates/myconfig/android_common/myconfig_meta.xml", 65*333d2b36SAndroid Build Coastguard Worker ) 66*333d2b36SAndroid Build Coastguard Worker }), 67*333d2b36SAndroid Build Coastguard Worker 68*333d2b36SAndroid Build Coastguard Worker snapshotTestChecker(checkSnapshotPreferredWithSource, 69*333d2b36SAndroid Build Coastguard Worker func(t *testing.T, result *android.TestResult) { 70*333d2b36SAndroid Build Coastguard Worker // Make sure that the snapshot metadata is collated by the platform compat config singleton. 71*333d2b36SAndroid Build Coastguard Worker java.CheckMergedCompatConfigInputs(t, result, "snapshot module", 72*333d2b36SAndroid Build Coastguard Worker "snapshot/compat_configs/myconfig/myconfig_meta.xml", 73*333d2b36SAndroid Build Coastguard Worker ) 74*333d2b36SAndroid Build Coastguard Worker }), 75*333d2b36SAndroid Build Coastguard Worker ) 76*333d2b36SAndroid Build Coastguard Worker} 77*333d2b36SAndroid Build Coastguard Worker 78*333d2b36SAndroid Build Coastguard Workerfunc TestSnapshotWithCompatConfig(t *testing.T) { 79*333d2b36SAndroid Build Coastguard Worker testSnapshotWithCompatConfig(t, ` 80*333d2b36SAndroid Build Coastguard Worker sdk { 81*333d2b36SAndroid Build Coastguard Worker name: "mysdk", 82*333d2b36SAndroid Build Coastguard Worker compat_configs: ["myconfig"], 83*333d2b36SAndroid Build Coastguard Worker } 84*333d2b36SAndroid Build Coastguard Worker`) 85*333d2b36SAndroid Build Coastguard Worker} 86*333d2b36SAndroid Build Coastguard Worker 87*333d2b36SAndroid Build Coastguard Workerfunc TestSnapshotWithCompatConfig_Apex(t *testing.T) { 88*333d2b36SAndroid Build Coastguard Worker testSnapshotWithCompatConfig(t, ` 89*333d2b36SAndroid Build Coastguard Worker apex { 90*333d2b36SAndroid Build Coastguard Worker name: "myapex", 91*333d2b36SAndroid Build Coastguard Worker key: "myapex.key", 92*333d2b36SAndroid Build Coastguard Worker min_sdk_version: "2", 93*333d2b36SAndroid Build Coastguard Worker compat_configs: ["myconfig"], 94*333d2b36SAndroid Build Coastguard Worker } 95*333d2b36SAndroid Build Coastguard Worker 96*333d2b36SAndroid Build Coastguard Worker sdk { 97*333d2b36SAndroid Build Coastguard Worker name: "mysdk", 98*333d2b36SAndroid Build Coastguard Worker apexes: ["myapex"], 99*333d2b36SAndroid Build Coastguard Worker } 100*333d2b36SAndroid Build Coastguard Worker`) 101*333d2b36SAndroid Build Coastguard Worker} 102