1//
2// Copyright (C) 2018 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_team: "trendy_team_fwk_core_networking",
19    default_applicable_licenses: ["Android-Apache-2.0"],
20}
21
22java_defaults {
23    name: "NetworkStackTestsDefaults",
24    srcs: [
25        "src/**/*.java",
26        "src/**/*.kt",
27    ],
28    resource_dirs: ["res"],
29    static_libs: [
30        "androidx.test.ext.junit",
31        "androidx.test.rules",
32        "kotlin-reflect",
33        "mockito-target-extended-minus-junit4",
34        "net-tests-utils",
35        //"net-utils-framework-common",
36        "testables",
37    ],
38    libs: [
39        "android.test.runner",
40        "android.test.base",
41        "android.test.mock",
42    ],
43    defaults: [
44        "framework-connectivity-test-defaults",
45        "libnetworkstackutilsjni_deps",
46    ],
47    jni_libs: [
48        // For mockito extended
49        "libdexmakerjvmtiagent",
50        "libstaticjvmtiagent",
51        "libnetworkstackutilsjni",
52    ],
53    jni_uses_sdk_apis: true,
54    exclude_kotlinc_generated_files: false,
55}
56
57// Tests for NetworkStackNext.
58android_test {
59    name: "NetworkStackNextTests",
60    platform_apis: true,
61    target_sdk_version: "current",
62    min_sdk_version: "30",
63    srcs: [], // TODO: tests that only apply to the current, non-stable API can be added here
64    test_suites: ["general-tests"],
65    defaults: [
66        "NetworkStackTestsDefaults",
67        "ConnectivityNextEnableDefaults",
68        "connectivity-mainline-presubmit-java-defaults",
69    ],
70    static_libs: ["NetworkStackApiCurrentLib"],
71    compile_multilib: "both", // Workaround for b/147785146 for mainline-presubmit
72    jarjar_rules: ":NetworkStackJarJarRules",
73}
74
75// Library containing the unit tests. This is used by the coverage test target to pull in the
76// unit test code. It is not currently used by the tests themselves because all the build
77// configuration needed by the tests is in the NetworkStackTestsDefaults rule.
78android_library {
79    name: "NetworkStackTestsLib",
80    min_sdk_version: "30",
81    defaults: ["NetworkStackTestsDefaults"],
82    static_libs: ["NetworkStackApiStableLib"],
83    lint: {
84        test: true,
85
86    },
87    visibility: [
88        "//packages/modules/NetworkStack/tests/integration",
89        "//packages/modules/Connectivity/tests:__subpackages__",
90        "//packages/modules/Connectivity/Tethering/tests:__subpackages__",
91    ],
92}
93
94android_test {
95    name: "NetworkStackTests",
96    platform_apis: true,
97    min_sdk_version: "30",
98    test_suites: [
99        "general-tests",
100        "mts",
101    ],
102    defaults: [
103        "NetworkStackTestsDefaults",
104        "connectivity-mainline-presubmit-java-defaults",
105    ],
106    static_libs: ["NetworkStackApiStableLib"],
107    compile_multilib: "both",
108    jarjar_rules: ":NetworkStackJarJarRules",
109}
110
111// Additional dependencies of libnetworkstackutilsjni that are not provided by the system when
112// running as a test application.
113// Using java_defaults as jni_libs does not support filegroups.
114java_defaults {
115    name: "libnetworkstackutilsjni_deps",
116    jni_libs: [
117        "libnativehelper_compat_libc++",
118        "libnetworkstacktestsjni",
119    ],
120}
121