chromium/services/tracing/public/cpp/perfetto/perfetto_config_unittest.cc

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

#include "services/tracing/public/cpp/perfetto/perfetto_config.h"

#include "base/base_paths.h"
#include "base/json/json_reader.h"
#include "base/path_service.h"
#include "base/test/test_proto_loader.h"
#include "base/trace_event/trace_config.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace tracing {

namespace {

base::FilePath GetTestDataRoot() {}

class AdaptPerfettoConfigForChromeTest : public ::testing::Test {};

base::trace_event::TraceConfig ParseTraceConfigFromJson(
    const std::string& json_config) {}

}  // namespace

TEST_F(AdaptPerfettoConfigForChromeTest, Simple) {}

TEST_F(AdaptPerfettoConfigForChromeTest, LegacyTraceEvent) {}

TEST_F(AdaptPerfettoConfigForChromeTest, UnsupportedTrackEvent) {}

TEST_F(AdaptPerfettoConfigForChromeTest, DisabledCategories) {}

TEST_F(AdaptPerfettoConfigForChromeTest, PrivacyFiltering) {}

TEST_F(AdaptPerfettoConfigForChromeTest, DiscardBuffer) {}

TEST_F(AdaptPerfettoConfigForChromeTest, MultipleBuffers) {}

TEST_F(AdaptPerfettoConfigForChromeTest, ProcessFilter) {}

#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CASTOS)
TEST_F(AdaptPerfettoConfigForChromeTest, Systrace) {
  auto perfetto_config = ParsePerfettoConfigFromText(R"pb(
    data_sources: { config: { name: "org.chromium.trace_system" } }
  )pb");
  auto trace_config =
      GetPerfettoConfigWithDataSources(ParseTraceConfigFromJson(R"json({
      "record_mode": "record-continuously",
      "enable_systrace": true
    })json"),
                                       {"org.chromium.trace_system"});
  EXPECT_TRUE(AdaptPerfettoConfigForChrome(&perfetto_config));
  EXPECT_EQ(PrintConfigToText(trace_config),
            PrintConfigToText(perfetto_config));
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CASTOS)

}  // namespace tracing