1*333d2b36SAndroid Build Coastguard Worker// Copyright 2024 Google Inc. All rights reserved. 2*333d2b36SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 3*333d2b36SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 4*333d2b36SAndroid Build Coastguard Worker// You may obtain a copy of the License at 5*333d2b36SAndroid Build Coastguard Worker// 6*333d2b36SAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 7*333d2b36SAndroid Build Coastguard Worker// 8*333d2b36SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 9*333d2b36SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 10*333d2b36SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11*333d2b36SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 12*333d2b36SAndroid Build Coastguard Worker// limitations under the License. 13*333d2b36SAndroid Build Coastguard Worker 14*333d2b36SAndroid Build Coastguard Workerpackage systemfeatures 15*333d2b36SAndroid Build Coastguard Worker 16*333d2b36SAndroid Build Coastguard Workerimport ( 17*333d2b36SAndroid Build Coastguard Worker "android/soong/android" 18*333d2b36SAndroid Build Coastguard Worker 19*333d2b36SAndroid Build Coastguard Worker "testing" 20*333d2b36SAndroid Build Coastguard Worker) 21*333d2b36SAndroid Build Coastguard Worker 22*333d2b36SAndroid Build Coastguard Workerfunc TestJavaSystemFeaturesSrcs(t *testing.T) { 23*333d2b36SAndroid Build Coastguard Worker bp := ` 24*333d2b36SAndroid Build Coastguard Workerjava_system_features_srcs { 25*333d2b36SAndroid Build Coastguard Worker name: "system-features-srcs", 26*333d2b36SAndroid Build Coastguard Worker full_class_name: "com.android.test.RoSystemFeatures", 27*333d2b36SAndroid Build Coastguard Worker} 28*333d2b36SAndroid Build Coastguard Worker` 29*333d2b36SAndroid Build Coastguard Worker 30*333d2b36SAndroid Build Coastguard Worker res := android.GroupFixturePreparers( 31*333d2b36SAndroid Build Coastguard Worker android.FixtureRegisterWithContext(registerSystemFeaturesComponents), 32*333d2b36SAndroid Build Coastguard Worker android.PrepareForTestWithBuildFlag("RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS", "true"), 33*333d2b36SAndroid Build Coastguard Worker android.PrepareForTestWithBuildFlag("RELEASE_SYSTEM_FEATURE_AUTOMOTIVE", "0"), 34*333d2b36SAndroid Build Coastguard Worker android.PrepareForTestWithBuildFlag("RELEASE_SYSTEM_FEATURE_TELEVISION", "UNAVAILABLE"), 35*333d2b36SAndroid Build Coastguard Worker android.PrepareForTestWithBuildFlag("RELEASE_SYSTEM_FEATURE_WATCH", ""), 36*333d2b36SAndroid Build Coastguard Worker android.PrepareForTestWithBuildFlag("RELEASE_NOT_SYSTEM_FEATURE_FOO", "BAR"), 37*333d2b36SAndroid Build Coastguard Worker ).RunTestWithBp(t, bp) 38*333d2b36SAndroid Build Coastguard Worker 39*333d2b36SAndroid Build Coastguard Worker module := res.ModuleForTests("system-features-srcs", "") 40*333d2b36SAndroid Build Coastguard Worker cmd := module.Rule("system-features-srcs").RuleParams.Command 41*333d2b36SAndroid Build Coastguard Worker android.AssertStringDoesContain(t, "Expected fully class name", cmd, " com.android.test.RoSystemFeatures ") 42*333d2b36SAndroid Build Coastguard Worker android.AssertStringDoesContain(t, "Expected readonly flag", cmd, "--readonly=true") 43*333d2b36SAndroid Build Coastguard Worker android.AssertStringDoesContain(t, "Expected AUTOMOTIVE feature flag", cmd, "--feature=AUTOMOTIVE:0 ") 44*333d2b36SAndroid Build Coastguard Worker android.AssertStringDoesContain(t, "Expected TELEVISION feature flag", cmd, "--feature=TELEVISION:UNAVAILABLE ") 45*333d2b36SAndroid Build Coastguard Worker android.AssertStringDoesContain(t, "Expected WATCH feature flag", cmd, "--feature=WATCH: ") 46*333d2b36SAndroid Build Coastguard Worker android.AssertStringDoesNotContain(t, "Unexpected FOO arg from non-system feature flag", cmd, "FOO") 47*333d2b36SAndroid Build Coastguard Worker 48*333d2b36SAndroid Build Coastguard Worker systemFeaturesModule := module.Module().(*javaSystemFeaturesSrcs) 49*333d2b36SAndroid Build Coastguard Worker expectedOutputPath := "out/soong/.intermediates/system-features-srcs/gen/RoSystemFeatures.java" 50*333d2b36SAndroid Build Coastguard Worker android.AssertPathsRelativeToTopEquals(t, "Expected output file", []string{expectedOutputPath}, systemFeaturesModule.Srcs()) 51*333d2b36SAndroid Build Coastguard Worker} 52