# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")

source_set("native_test_support") {
  testonly = true
  sources = [
    "main_runner.cc",
    "main_runner.h",
    "native_test_launcher.cc",
    "native_test_launcher.h",
    "native_test_util.cc",
    "native_test_util.h",
  ]
  deps = [
    ":native_main_runner_jni",
    ":native_test_jni",
    "//base",
    "//base/test:test_support",
    "//testing/gtest",
  ]
}

source_set("native_browser_test_support") {
  testonly = true
  sources = [
    "native_browser_test_support.cc",
    "native_browser_test_support.h",
  ]
  deps = [ ":native_browser_test_jni" ]
  public_deps = [ "//base" ]
}

source_set("native_test_native_code") {
  testonly = true
  sources = [ "native_test_jni_onload.cc" ]
  libs = [ "log" ]
  deps = [
    ":native_test_support",
    "//base",
  ]
}

generate_jni("native_main_runner_jni") {
  testonly = true
  sources = [ "java/src/org/chromium/native_test/MainRunner.java" ]
}

android_library("native_main_runner_java") {
  testonly = true

  srcjar_deps = [ ":native_main_runner_jni" ]
  sources = [ "java/src/org/chromium/native_test/MainRunner.java" ]
  deps = [ "//third_party/jni_zero:jni_zero_java" ]
}

android_library("native_test_java") {
  testonly = true

  deps = [
    ":native_main_runner_java",
    "//base:base_java",
    "//base:base_java_test_support",
    "//build/android:build_java",
    "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
    "//testing/android/reporter:reporter_java",
    "//third_party/jni_zero:jni_zero_java",
  ]
  srcjar_deps = [ ":native_test_jni" ]
  sources = [
    "java/src/org/chromium/native_test/NativeTest.java",
    "java/src/org/chromium/native_test/NativeTestApplication.java",
    "java/src/org/chromium/native_test/NativeUnitTest.java",
    "java/src/org/chromium/native_test/NativeUnitTestActivity.java",
    "java/src/org/chromium/native_test/NativeUnitTestNativeActivity.java",
  ]
}

android_library("native_browser_test_java") {
  testonly = true

  sources = [
    "java/src/org/chromium/native_test/NativeBrowserTest.java",
    "java/src/org/chromium/native_test/NativeBrowserTestActivity.java",
    "java/src/org/chromium/native_test/NativeBrowserTestApplication.java",
  ]
  srcjar_deps = [ ":native_browser_test_jni" ]
  deps = [
    ":native_test_java",
    "//base:base_java",
    "//third_party/androidx:androidx_fragment_fragment_java",
    "//third_party/jni_zero:jni_zero_java",
  ]
}

android_resources("cleartext_traffic_resources") {
  sources = [ "java/res/xml/allow_cleartext_traffic.xml" ]
}

generate_jni("native_test_jni") {
  testonly = true
  sources = [ "java/src/org/chromium/native_test/NativeTest.java" ]
}

generate_jni("native_browser_test_jni") {
  testonly = true
  sources = [ "java/src/org/chromium/native_test/NativeBrowserTest.java" ]
}
