chromium/base/trace_event/typed_macros_unittest.cc

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

#include "base/trace_event/typed_macros.h"

#include "base/location.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/trace_test_utils.h"
#include "base/trace_event/interned_args_helper.h"
#include "base/trace_event/trace_log.h"
#include "base/trace_event/typed_macros_embedder_support.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/perfetto/include/perfetto/protozero/scattered_heap_buffer.h"
#include "third_party/perfetto/include/perfetto/tracing/track_event_interned_data_index.h"
#include "third_party/perfetto/protos/perfetto/trace/interned_data/interned_data.pb.h"
#include "third_party/perfetto/protos/perfetto/trace/trace.pb.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_mojo_event_info.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/log_message.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/source_location.pb.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/source_location.pbzero.h"

#include "base/tracing/perfetto_platform.h"

namespace base {
namespace trace_event {

namespace {

std::unique_ptr<perfetto::TracingSession> g_tracing_session;

void EnableTrace(bool filter_debug_annotations = false) {}


void CancelTrace() {}

struct TestTrackEvent;
struct TestTracePacket;
TestTrackEvent* g_test_track_event;
TestTracePacket* g_test_trace_packet;

struct TestTrackEvent : public TrackEventHandle::CompletionListener {};

struct TestTracePacket : public TracePacketHandle::CompletionListener {};

TrackEventHandle PrepareTrackEvent(bool filter_debug_annotations) {}

TrackEventHandle PrepareTrackEventWithDebugAnnotations(TraceEvent*) {}

TrackEventHandle PrepareTrackEventFilterDebugAnnotations(TraceEvent*) {}

TracePacketHandle PrepareTracePacket() {}

void EmitEmptyPacket() {}

class TypedTraceEventTest : public testing::Test {};

}  // namespace

TEST_F(TypedTraceEventTest, CallbackExecutedWhenTracingEnabled) {}

TEST_F(TypedTraceEventTest, CallbackNotExecutedWhenTracingDisabled) {}

TEST_F(TypedTraceEventTest, DescriptorPacketWrittenForEventWithTrack) {}

TEST_F(TypedTraceEventTest, InternedData) {}

// TODO: crbug/334063999 - The test is disabled due to flakiness.
TEST_F(TypedTraceEventTest, DISABLED_InstantThreadEvent) {}

// TODO: crbug/334063999 - The test is disabled due to flakiness.
TEST_F(TypedTraceEventTest, DISABLED_InstantProcessEvent) {}

TEST_F(TypedTraceEventTest, InstantGlobalEvent) {}

TEST_F(TypedTraceEventTest, InstantGlobalDefaultEvent) {}

TEST_F(TypedTraceEventTest, BeginEventOnDefaultTrackDoesNotWriteTrackUuid) {}

TEST_F(TypedTraceEventTest, EndEventOnDefaultTrackDoesNotWriteTrackUuid) {}

// In the client library, EmitEmptyPacket() isn't called and the packet
// disappears from the trace. This functionality is instead tested in Perfetto's
// API integration tests. We just verify that the macro builds correctly here
// when building with the client library.
#define MAYBE_EmptyEvent
TEST_F(TypedTraceEventTest, MAYBE_EmptyEvent) {}

TEST_F(TypedTraceEventTest, ChromeMojoInterfaceTag) {}

class TypedTraceEventFilterDebugAnnotationsTest : public TypedTraceEventTest {};

TEST_F(TypedTraceEventFilterDebugAnnotationsTest, ChromeMojoInterfaceTag) {}

}  // namespace trace_event
}  // namespace base