#include "base/dcheck_is_on.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "components/tracing/common/tracing_switches.h"
#include "content/browser/tracing/startup_tracing_controller.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "services/tracing/perfetto/privacy_filtering_check.h"
#include "services/tracing/public/cpp/perfetto/trace_event_data_source.h"
#include "services/tracing/public/cpp/trace_startup.h"
#include "services/tracing/public/cpp/trace_startup_config.h"
#include "services/tracing/public/cpp/tracing_features.h"
#include "third_party/perfetto/include/perfetto/tracing/tracing.h"
namespace content {
namespace {
void CheckForConditionAndWaitMoreIfNeeded(
base::RepeatingCallback<bool()> condition,
base::OnceClosure quit_closure) { … }
void WaitForCondition(base::RepeatingCallback<bool()> condition,
const std::string& description) { … }
}
class StartupTracingInProcessTest : public ContentBrowserTest { … };
class LargeTraceEventData : public base::trace_event::ConvertableToTraceFormat { … };
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_TestFilledStartupBuffer …
#else
#define MAYBE_TestFilledStartupBuffer …
#endif
IN_PROC_BROWSER_TEST_F(StartupTracingInProcessTest,
MAYBE_TestFilledStartupBuffer) { … }
namespace {
enum class FinishType { … };
std::ostream& operator<<(std::ostream& o, FinishType type) { … }
enum class OutputType { … };
std::ostream& operator<<(std::ostream& o, OutputType type) { … }
enum class OutputLocation { … };
std::ostream& operator<<(std::ostream& o, OutputLocation type) { … }
}
class StartupTracingTest
: public ContentBrowserTest,
public testing::WithParamInterface<
std::tuple<FinishType, OutputType, OutputLocation>> { … };
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_TestEnableTracing …
#else
#define MAYBE_TestEnableTracing …
#endif
IN_PROC_BROWSER_TEST_P(StartupTracingTest, MAYBE_TestEnableTracing) { … }
IN_PROC_BROWSER_TEST_P(StartupTracingTest, DISABLED_ContinueAtShutdown) { … }
class EmergencyStopTracingTest : public StartupTracingTest { … };
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_StopOnUIThread …
#else
#define MAYBE_StopOnUIThread …
#endif
IN_PROC_BROWSER_TEST_P(EmergencyStopTracingTest, MAYBE_StopOnUIThread) { … }
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_StopOnThreadPool …
#else
#define MAYBE_StopOnThreadPool …
#endif
IN_PROC_BROWSER_TEST_P(EmergencyStopTracingTest, MAYBE_StopOnThreadPool) { … }
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_StopOnThreadPoolTwice …
#else
#define MAYBE_StopOnThreadPoolTwice …
#endif
IN_PROC_BROWSER_TEST_P(EmergencyStopTracingTest, MAYBE_StopOnThreadPoolTwice) { … }
}