• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17java_genrule {
18    name: "lib-test-profile-text-protos",
19    host_supported: true,
20    tools: ["aprotoc"],
21    srcs: [
22        ":profile-proto-def",
23        "assets/*.textpb",
24    ],
25    out: ["lib-test-profiles.jar"],
26    /*
27     * Loops over all *.textpb files under assets/ and serializes them into binary protos with
28     * ".pb" extension using aprotoc. The generated *.pb files are put under an assets/
29     * directory, which gets packed into a .jar file and ends up under the assets/
30     * directory in the package, which can then be read with asset manager.
31     *
32     * If a profile fails to parse, an error is thrown and the build will fail.
33     */
34    cmd: "out_dir=$$(dirname $(out)) && assets_dir=\"assets\" " +
35        "&& mkdir -p $$out_dir/$$assets_dir && src_protos=($(locations assets/*.textpb)) " +
36        "&& for file in $${src_protos[@]} ; do fname=$$(basename $$file) " +
37        "&& if ! ($(location aprotoc) --encode=longevity.profile.Configuration " +
38        "$(location :profile-proto-def) < $$file > " +
39        "$$out_dir/$$assets_dir/$${fname//.textpb/.pb}) ; then " +
40        "echo \"\033[0;31mFailed to parse profile $$file. See above for errors.\033[0m\" " +
41        "&& exit 1 ; fi ; done && jar cf $(out) -C $$(dirname $(out)) $$assets_dir",
42}
43
44android_test {
45    name: "LongevityPlatformLibTests",
46
47    sdk_version: "26",
48    static_libs: [
49        "androidx.test.runner",
50        "common-platform-scenarios",
51        "guava",
52        "lib-test-profile-text-protos",
53        "longevity-device-lib",
54        "mockito-target",
55        "platform-test-composers",
56        "truth-prebuilt",
57        "ub-uiautomator",
58    ],
59    srcs: ["src/**/*.java"],
60    test_suites: ["device-tests"],
61}
62