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

import("//build/config/features.gni")
import("//build/config/ui.gni")
if (is_android) {
  import("//build/config/android/config.gni")
}

component("test_runner") {
  testonly = true

  defines = [ "TEST_RUNNER_IMPLEMENTATION" ]

  sources = [
    "accessibility_controller.cc",
    "accessibility_controller.h",
    "app_banner_service.cc",
    "app_banner_service.h",
    "event_sender.cc",
    "event_sender.h",
    "gamepad_controller.cc",
    "gamepad_controller.h",
    "gc_controller.cc",
    "gc_controller.h",
    "layout_and_paint_async_then.cc",
    "layout_and_paint_async_then.h",
    "layout_dump.cc",
    "layout_dump.h",
    "layout_test_runtime_flags.cc",
    "layout_test_runtime_flags.h",
    "mock_color_chooser.cc",
    "mock_color_chooser.h",
    "mock_content_settings_client.cc",
    "mock_content_settings_client.h",
    "mock_credential_manager_client.cc",
    "mock_credential_manager_client.h",
    "mock_grammar_check.cc",
    "mock_grammar_check.h",
    "mock_screen_orientation_client.cc",
    "mock_screen_orientation_client.h",
    "mock_spell_check.cc",
    "mock_spell_check.h",
    "mock_web_audio_device.cc",
    "mock_web_audio_device.h",
    "mock_web_document_subresource_filter.cc",
    "mock_web_document_subresource_filter.h",
    "mock_web_media_stream_center.cc",
    "mock_web_media_stream_center.h",
    "mock_web_midi_accessor.cc",
    "mock_web_midi_accessor.h",
    "mock_web_speech_recognizer.cc",
    "mock_web_speech_recognizer.h",
    "mock_web_theme_engine.cc",
    "mock_web_theme_engine.h",
    "mock_web_user_media_client.cc",
    "mock_web_user_media_client.h",
    "mock_webrtc_data_channel_handler.cc",
    "mock_webrtc_data_channel_handler.h",
    "mock_webrtc_dtmf_sender_handler.cc",
    "mock_webrtc_dtmf_sender_handler.h",
    "mock_webrtc_peer_connection_handler.cc",
    "mock_webrtc_peer_connection_handler.h",
    "pixel_dump.cc",
    "pixel_dump.h",
    "spell_check_client.cc",
    "spell_check_client.h",
    "test_common.cc",
    "test_common.h",
    "test_interfaces.cc",
    "test_interfaces.h",
    "test_plugin.cc",
    "test_plugin.h",
    "test_preferences.cc",
    "test_preferences.h",
    "test_runner.cc",
    "test_runner.h",
    "test_runner_export.h",
    "test_runner_for_specific_view.cc",
    "test_runner_for_specific_view.h",
    "text_input_controller.cc",
    "text_input_controller.h",
    "tracked_dictionary.cc",
    "tracked_dictionary.h",
    "web_ax_object_proxy.cc",
    "web_ax_object_proxy.h",
    "web_frame_test_client.cc",
    "web_frame_test_client.h",
    "web_frame_test_proxy.cc",
    "web_frame_test_proxy.h",
    "web_test_delegate.h",
    "web_test_interfaces.cc",
    "web_test_interfaces.h",
    "web_test_runner.h",
    "web_view_test_client.cc",
    "web_view_test_client.h",
    "web_view_test_proxy.cc",
    "web_view_test_proxy.h",
    "web_widget_test_client.cc",
    "web_widget_test_client.h",
    "web_widget_test_proxy.cc",
    "web_widget_test_proxy.h",
  ]

  # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
  configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]

  deps = [
    "//base:base",
    "//base:i18n",
    "//cc",
    "//cc/blink",
    "//content/public/common",
    "//gin",
    "//gpu",
    "//gpu/command_buffer/client:gles2_interface",
    "//media/midi:mojo_cpp_sources",
    "//net",
    "//skia",
    "//third_party/WebKit/public:blink",
    "//ui/display",
    "//ui/events:dom_keycode_converter",
    "//ui/events:events_base",
    "//ui/events/blink",
    "//ui/gfx",
    "//ui/gfx:test_support",
    "//ui/gfx/geometry",
    "//url",
    "//v8",
  ]

  data_deps = [
    ":resources",
  ]

  if (is_mac) {
    libs = [ "AppKit.framework" ]
  }
}

# Font copies.
if (!is_mac) {
  copy("copy_ahem") {
    visibility = [ ":*" ]
    sources = [
      "resources/fonts/AHEM____.TTF",
    ]
    outputs = [
      "$root_out_dir/AHEM____.TTF",
    ]
  }
}
if (use_x11) {
  copy("copy_x11_fonts") {
    visibility = [ ":*" ]
    sources = [
      "//third_party/gardiner_mod/GardinerModBug.ttf",
      "//third_party/gardiner_mod/GardinerModCat.ttf",
      "resources/fonts/fonts.conf",
    ]
    outputs = [
      "$root_out_dir/{{source_file_part}}",
    ]
  }
}
if (is_android) {
  copy("copy_android_fonts") {
    visibility = [ ":*" ]
    sources = [
      "resources/fonts/android_fallback_fonts.xml",
      "resources/fonts/android_main_fonts.xml",
    ]
    outputs = [
      "$root_out_dir/{{source_file_part}}",
    ]
  }
}
if (is_mac) {
  bundle_data("test_runner_bundle_data") {
    sources = [
      "resources/fonts/AHEM____.TTF",
      "resources/fonts/ChromiumAATTest.ttf",
    ]

    outputs = [
      "{{bundle_resources_dir}}/{{source_file_part}}",
    ]
  }
}

group("resources") {
  data_deps = []

  if (is_mac) {
    data_deps += [ ":test_runner_bundle_data" ]
  } else {
    data_deps += [ ":copy_ahem" ]
  }

  if (use_x11) {
    data_deps += [ ":copy_x11_fonts" ]
  }
  if (is_android) {
    data_deps += [ ":copy_android_fonts" ]
  }
}
