#include <memory>
#include <optional>
#include "base/base_paths.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/system/sys_info.h"
#include "base/test/bind.h"
#include "base/test/test_proto_loader.h"
#include "base/time/time.h"
#include "base/trace_event/named_trigger.h"
#include "base/values.h"
#include "build/build_config.h"
#include "content/browser/tracing/background_tracing_config_impl.h"
#include "content/browser/tracing/background_tracing_rule.h"
#include "content/public/browser/background_tracing_manager.h"
#include "content/public/test/browser_task_environment.h"
#include "net/base/network_change_notifier.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/perfetto/protos/perfetto/config/chrome/scenario_config.gen.h"
namespace content {
namespace {
class MockNetworkChangeNotifier : public net::NetworkChangeNotifier { … };
base::FilePath GetTestDataRoot() { … }
void CreateRuleConfig(const std::string& proto_text,
perfetto::protos::gen::TriggerRule& destination) { … }
}
class BackgroundTracingConfigTest : public testing::Test { … };
std::unique_ptr<BackgroundTracingConfigImpl> ReadFromJSONString(
const std::string& json_text) { … }
std::string ConfigToString(BackgroundTracingConfig* config) { … }
std::string RuleToString(const std::unique_ptr<BackgroundTracingRule>& rule) { … }
TEST_F(BackgroundTracingConfigTest, ConfigFromInvalidString) { … }
TEST_F(BackgroundTracingConfigTest, PreemptiveConfigFromInvalidString) { … }
TEST_F(BackgroundTracingConfigTest, ReactiveConfigFromInvalidString) { … }
TEST_F(BackgroundTracingConfigTest, PreemptiveConfigFromValidString) { … }
TEST_F(BackgroundTracingConfigTest, ValidPreemptiveCategoryToString) { … }
TEST_F(BackgroundTracingConfigTest, ReactiveConfigFromValidString) { … }
TEST_F(BackgroundTracingConfigTest, ValidPreemptiveConfigToString) { … }
TEST_F(BackgroundTracingConfigTest, InvalidPreemptiveConfigToString) { … }
TEST_F(BackgroundTracingConfigTest, ValidReactiveConfigToString) { … }
TEST_F(BackgroundTracingConfigTest, BufferLimitConfig) { … }
TEST_F(BackgroundTracingConfigTest, HistogramRuleFromValidProto) { … }
TEST_F(BackgroundTracingConfigTest, NamedRuleFromValidProto) { … }
TEST_F(BackgroundTracingConfigTest, RuleFromEmptyProto) { … }
TEST_F(BackgroundTracingConfigTest, TimerRuleFromValidProto) { … }
TEST_F(BackgroundTracingConfigTest, TimerRuleTriggersAfterDelay) { … }
TEST_F(BackgroundTracingConfigTest, RuleActivatesAfterDelay) { … }
TEST_F(BackgroundTracingConfigTest, RepeatingIntervalRuleFromValidProto) { … }
TEST_F(BackgroundTracingConfigTest, RepeatingIntervalRuleTriggersAfterDelay) { … }
TEST_F(BackgroundTracingConfigTest, RepeatingIntervalRuleTriggersRandomized) { … }
}