1// 2// Copyright (C) 2017 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17package { 18 default_applicable_licenses: ["Android-Apache-2.0"], 19} 20 21java_genrule { 22 name: "lib-test-profile-text-protos", 23 host_supported: true, 24 tools: ["aprotoc"], 25 srcs: [ 26 ":profile-proto-def", 27 "assets/*.textpb", 28 ], 29 out: ["lib-test-profiles.jar"], 30 /* 31 * Loops over all *.textpb files under assets/ and serializes them into binary protos with 32 * ".pb" extension using aprotoc. The generated *.pb files are put under an assets/ 33 * directory, which gets packed into a .jar file and ends up under the assets/ 34 * directory in the package, which can then be read with asset manager. 35 * 36 * If a profile fails to parse, an error is thrown and the build will fail. 37 */ 38 cmd: "out_dir=$$(dirname $(out)) && assets_dir=\"assets\" " + 39 "&& mkdir -p $$out_dir/$$assets_dir && src_protos=($(locations assets/*.textpb)) " + 40 "&& for file in $${src_protos[@]} ; do fname=$$(basename $$file) " + 41 "&& if ! ($(location aprotoc) --encode=longevity.profile.Configuration " + 42 "$(location :profile-proto-def) < $$file > " + 43 "$$out_dir/$$assets_dir/$${fname//.textpb/.pb}) ; then " + 44 "echo \"\033[0;31mFailed to parse profile $$file. See above for errors.\033[0m\" " + 45 "&& exit 1 ; fi ; done && jar cf $(out) -C $$(dirname $(out)) $$assets_dir", 46} 47 48android_test { 49 name: "LongevityPlatformLibTests", 50 51 min_sdk_version: "26", 52 static_libs: [ 53 "androidx.test.runner", 54 "common-platform-scenarios", 55 "guava", 56 "lib-test-profile-text-protos", 57 "longevity-device-lib", 58 "mockito-target", 59 "platform-test-composers", 60 "truth-prebuilt", 61 "ub-uiautomator", 62 ], 63 srcs: ["src/**/*.java"], 64 test_suites: ["device-tests"], 65} 66