//
// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

java_library {
    name: "modules-utils-native-coverage-listener",
    srcs: ["NativeCoverageHackInstrumentationListener.java"],
    static_libs: [
        "androidx.test.rules",
    ],
    sdk_version: "test_current",
    min_sdk_version: "29",
    visibility: ["//visibility:public"],
}

// Utility for mocking DeviceConfig and other device state.
//
// NOTE: clients should depend on modules-utils-testable-device-config-defaults
// instead of using this library directly (so it sets the proper JNI dependencies)
java_library {
    name: "modules-utils-testable-device-config",
    srcs: [
        "TestableDeviceConfig.java",
    ],
    static_libs: [
        "modules-utils-build",
        "modules-utils-extended-mockito-rule",
    ],
    libs: [
        "framework-configinfrastructure",
    ],
    visibility: ["//visibility:public"],
}

// Utility for mocking DeviceConfig and other device state.
//
// NOTE: if you're only using ExtendedMockitoRule (without TestableDevicConfig), you should use
// modules-utils-extended-mockito-rule-defaults instead
//
// In order to use these utils successfully, both Java code and native libraries will be required.
// If your code is in a library, you will have to depend on these defaults both in the library as
// well as in the android_test that it gets linked into.
// You will also need to specify android:debuggable="true" in the test's manifest.
java_defaults {
    name: "modules-utils-testable-device-config-defaults",
    static_libs: ["modules-utils-testable-device-config"],
    compile_multilib: "both",
    defaults: ["modules-utils-extended-mockito-rule-defaults"],
    defaults_visibility: ["//visibility:public"],
}

// Utility for using ExtendedMockitoRule.
//
// NOTE: most clients should depend on modules-utils-extended-mockito-rule-defaults
// instead of using this library directly (so it sets the proper JNI dependencies)
java_library {
    name: "modules-utils-extended-mockito-rule",
    srcs: [
        "AbstractExtendedMockitoRule.java",
        "StaticMockFixture.java",
        "ExtendedMockitoRule.java",
    ],
    static_libs: [
        "junit",
        "mockito-target-extended-minus-junit4",
    ],
    libs: [
        "framework-annotations-lib", // @VisibleForTesting
    ],
    sdk_version: "module_current",
    min_sdk_version: "29",
    visibility: ["//visibility:public"],
    lint: {
        baseline_filename: "lint-baseline.xml",
    },
}

// Utility for using ExtendedMockitoRule.
//
// In order to use these utils successfully, both Java code and native libraries will be required.
// If your code is in a library, you will have to depend on these defaults both in the library as
// well as in the android_test that it gets linked into.
// You will also need to specify android:debuggable="true" in the test's manifest.
java_defaults {
    name: "modules-utils-extended-mockito-rule-defaults",
    static_libs: ["modules-utils-extended-mockito-rule"],
    compile_multilib: "both",
    jni_libs: [
        "libdexmakerjvmtiagent",
        "libstaticjvmtiagent",
    ],
    defaults_visibility: ["//visibility:public"],
}