# Copyright 2015 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/chromeos/ui_mode.gni")
action("field_trial_testing_config_action") {
visibility = [ ":field_trial_config" ]
script = "//tools/variations/fieldtrial_to_struct.py"
source = "//testing/variations/fieldtrial_testing_config.json"
inputs = [
"//tools/json_to_struct/element_generator.py",
"//tools/json_to_struct/java_element_generator.py",
"//tools/json_to_struct/json_to_struct.py",
"//tools/json_to_struct/class_generator.py",
"//tools/json_to_struct/struct_generator.py",
source,
]
out_name = "fieldtrial_testing_config"
outputs = [
"$target_gen_dir/$out_name.cc",
"$target_gen_dir/$out_name.h",
]
if (current_os == "win") {
platform = "windows"
} else if (is_chromeos_lacros) {
platform = "chromeos_lacros"
} else {
platform = current_os
}
args = [
rebase_path(source, root_build_dir),
"--destbase=" + rebase_path(target_gen_dir, root_build_dir),
"--namespace=variations",
"--schema=" +
rebase_path("field_trial_testing_config_schema.json", root_build_dir),
"--platform=" + platform,
"--output=$out_name",
]
# At build-time, Android Chrome and WebView/WebLayer use the platform
# "android", but at run-time, variations has separate platforms "android",
# "android_webview" and "android_weblayer". So if building "android", also
# include WebView/WebLayer.
if (platform == "android") {
args += [
# TODO(peilinwang) investigate impact on test runtime, then enable the
# generation of the java fieldtrial testing config to be used when native
# isn't loaded.
# "--java",
"--platform=android_weblayer",
"--platform=android_webview",
]
}
}
static_library("field_trial_config") {
sources = [
"field_trial_util.cc",
"field_trial_util.h",
]
sources += get_target_outputs(":field_trial_testing_config_action")
deps = [
":field_trial_testing_config_action",
"//base",
"//components/variations",
"//components/variations/proto",
"//net",
]
public_deps = [ "//third_party/protobuf:protobuf_lite" ]
}
source_set("unit_tests") {
testonly = true
sources = [ "field_trial_util_unittest.cc" ]
deps = [
":field_trial_config",
"//base",
"//base/test:test_support",
"//components/variations",
"//components/variations/service",
"//components/version_info",
"//services/network/public/cpp",
"//testing/gtest",
]
}