chromium/media/gpu/test/BUILD.gn

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

if (is_chromeos || is_linux) {
  import("//build/config/chromeos/ui_mode.gni")
}
import("//build/config/ui.gni")
import("//media/gpu/args.gni")
import("//media/media_options.gni")

# TODO(crbug.com/1006266): consider using |use_chromeos_video_acceleration|.
if (enable_av1_decoder && (use_v4l2_codec || use_vaapi || is_win)) {
  test("video_decode_accelerator_tests") {
    testonly = true
    sources = [
      "video_decode_accelerator_test_suite.cc",
      "video_decode_accelerator_test_suite.h",
      "video_decode_accelerator_tests.cc",
    ]
    data = [ "//media/test/data/" ]
    deps = [
      ":frame_file_writer",
      ":frame_validator",
      ":helpers",
      ":test_helpers",
      ":video_player",
      ":video_player_test_environment",
      "//base/test:test_support",
      "//media:test_support",
      "//media/gpu:buildflags",
      "//testing/gmock",
      "//testing/gtest",
    ]

    if (is_chromeos || is_linux) {
      deps += [ "//media/gpu/chromeos:common" ]
    }

    if (use_vaapi) {
      data_deps = [ "//media/gpu/vaapi/test/fake_libva_driver:fake_drv_video" ]
    }
  }

  test("video_decode_accelerator_perf_tests") {
    testonly = true
    sources = [ "video_decode_accelerator_perf_tests.cc" ]
    data = [ "//media/test/data/" ]
    deps = [
      ":helpers",
      ":video_player",
      ":video_player_test_environment",
      "//media:test_support",
      "//media/gpu:buildflags",
      "//testing/gtest",
    ]

    if (use_v4l2_codec || use_vaapi) {
      deps += [ "//sandbox/linux:sandbox_services" ]
    }
  }

  test("video_encode_accelerator_tests") {
    testonly = true
    sources = [ "video_encode_accelerator_tests.cc" ]
    data = [ "//media/test/data/" ]
    deps = [
      ":frame_file_writer",
      ":frame_validator",
      ":helpers",
      ":test_helpers",
      ":video_encoder",
      ":video_encoder_test_environment",
      "//media:test_support",
      "//media/gpu:buildflags",
      "//testing/gtest",
    ]
  }

  test("video_encode_accelerator_perf_tests") {
    testonly = true
    sources = [ "video_encode_accelerator_perf_tests.cc" ]
    data = [ "//media/test/data/" ]
    deps = [
      ":frame_validator",
      ":helpers",
      ":test_helpers",
      ":video_encoder",
      ":video_encoder_test_environment",
      "//media:test_support",
      "//media/gpu:buildflags",
      "//testing/gtest",
    ]
  }
}

source_set("helpers") {
  testonly = true
  sources = [
    "image.cc",
    "image.h",
    "image_quality_metrics.cc",
    "image_quality_metrics.h",
    "raw_video.cc",
    "raw_video.h",
    "video_bitstream.cc",
    "video_bitstream.h",
    "video_frame_helpers.cc",
    "video_frame_helpers.h",
  ]
  deps = [
    "//base:base",
    "//base/test:test_config",
    "//base/test:test_support",
    "//gpu/ipc/common",
    "//media:test_support",
    "//media/gpu",
    "//third_party/ffmpeg",
    "//third_party/libyuv",
  ]
  public_deps = [ "//testing/gtest" ]

  if ((is_chromeos || is_linux) && (use_v4l2_codec || use_vaapi)) {
    deps += [ "//media/gpu/chromeos:common" ]
  }
}

source_set("frame_validator") {
  testonly = true
  sources = [
    "video_frame_validator.cc",
    "video_frame_validator.h",
  ]
  deps = [
    ":helpers",
    ":test_helpers",
    "//media/gpu",
  ]

  if (is_chromeos || is_linux) {
    deps += [ "//build:chromeos_buildflags" ]

    if (use_v4l2_codec || use_vaapi) {
      deps += [ "//media/gpu/chromeos:common" ]
    }
  }
}

source_set("frame_file_writer") {
  testonly = true
  sources = [
    "video_frame_file_writer.cc",
    "video_frame_file_writer.h",
  ]
  deps = [
    ":helpers",
    "//media/gpu",
    "//ui/gfx/codec:codec",
  ]

  if (is_chromeos || is_linux) {
    deps += [ "//build:chromeos_buildflags" ]

    if (use_v4l2_codec || use_vaapi) {
      deps += [ "//media/gpu/chromeos:common" ]
    }
  }
}

source_set("test_helpers") {
  testonly = true
  sources = [
    "video_test_helpers.cc",
    "video_test_helpers.h",
  ]
  public_deps = [
    ":helpers",
    "//media:test_support",
  ]
  deps = [
    "//media/gpu",
    "//mojo/public/cpp/system",
    "//testing/gtest",
    "//third_party/libyuv",
  ]
}

static_library("video_player") {
  testonly = true
  sources = [
    "video_player/decoder_listener.cc",
    "video_player/decoder_listener.h",
    "video_player/decoder_wrapper.cc",
    "video_player/decoder_wrapper.h",
    "video_player/frame_renderer_dummy.cc",
    "video_player/frame_renderer_dummy.h",
    "video_player/test_vda_video_decoder.cc",
    "video_player/test_vda_video_decoder.h",
  ]
  deps = [
    ":test_helpers",
    "//media/gpu",
    "//testing/gtest:gtest",
  ]
}

static_library("video_test_environment") {
  testonly = true
  sources = [
    "video_test_environment.cc",
    "video_test_environment.h",
  ]

  deps = [
    ":helpers",
    "//base:base",
    "//base/test:test_support",
    "//media:test_support",
    "//media/gpu",
    "//mojo/core/embedder:embedder",
  ]

  public_deps = [
    ":frame_file_writer",
    "//testing/gtest",
  ]
}

static_library("video_player_test_environment") {
  testonly = true
  sources = [
    "video_player/video_player_test_environment.cc",
    "video_player/video_player_test_environment.h",
  ]
  data = [ "//media/test/data/" ]
  deps = [
    ":frame_file_writer",
    ":helpers",
    ":video_player",
    ":video_test_environment",
    "//media/gpu",
  ]

  if (is_chromeos || is_linux) {
    deps += [ "//build:chromeos_buildflags" ]
  }
}

static_library("video_encoder") {
  testonly = true
  sources = [
    "bitstream_helpers.cc",
    "bitstream_helpers.h",
    "video_encoder/bitstream_file_writer.cc",
    "video_encoder/bitstream_file_writer.h",
    "video_encoder/bitstream_validator.cc",
    "video_encoder/bitstream_validator.h",
    "video_encoder/decoder_buffer_validator.cc",
    "video_encoder/decoder_buffer_validator.h",
    "video_encoder/video_encoder.cc",
    "video_encoder/video_encoder.h",
    "video_encoder/video_encoder_client.cc",
    "video_encoder/video_encoder_client.h",
  ]
  public_deps = [ "//third_party/libgav1:libgav1_parser" ]
  deps = [
    ":test_helpers",
    "//media/gpu",
    "//testing/gtest:gtest",
  ]
}

static_library("video_encoder_test_environment") {
  testonly = true
  sources = [
    "video_encoder/video_encoder_test_environment.cc",
    "video_encoder/video_encoder_test_environment.h",
  ]
  data = [ "//media/test/data/" ]
  public_deps = [
    ":helpers",
    ":video_test_environment",
    "//media/gpu",
  ]
  deps = [ "//base:base" ]

  if (is_chromeos || is_linux) {
    deps += [ "//build:chromeos_buildflags" ]
  }
}

if (use_vaapi || use_v4l2_codec) {
  static_library("image_processor") {
    testonly = true
    sources = [
      "image_processor/image_processor_client.cc",
      "image_processor/image_processor_client.h",
    ]
    deps = [
      ":helpers",
      "//media:test_support",
      "//media/gpu",
      "//media/gpu/chromeos",
      "//testing/gtest",
      "//third_party/libyuv",
    ]

    if (is_chromeos || is_linux) {
      deps += [ "//build:chromeos_buildflags" ]
    }

    data = [ "//media/test/data/" ]
  }
}

if (is_chromeos_ash) {
  static_library("local_gpu_memory_buffer_manager") {
    testonly = true
    sources = [
      "local_gpu_memory_buffer_manager.cc",
      "local_gpu_memory_buffer_manager.h",
    ]
    deps = [
      "//base",
      "//build/config/linux/libdrm",
      "//gpu/command_buffer/client",
      "//third_party/minigbm",
      "//ui/gfx:memory_buffer",
      "//ui/gfx/geometry",
      "//ui/gfx/linux:gbm",
    ]
  }
}