chromium/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto_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 "services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto.h"

#include <map>
#include <memory>
#include <set>
#include <utility>
#include <vector>

#include "base/files/file_path.h"
#include "base/format_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/test/trace_test_utils.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/traced_value.h"
#include "base/tracing/trace_time.h"
#include "build/build_config.h"
#include "services/tracing/public/cpp/perfetto/perfetto_producer.h"
#include "services/tracing/public/cpp/perfetto/perfetto_traced_process.h"
#include "services/tracing/public/cpp/perfetto/producer_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/perfetto/protos/perfetto/trace/memory_graph.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/profiling/smaps.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/ps/process_stats.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/trace_packet.pbzero.h"

TrackEvent;
using MemoryTrackerSnapshot = perfetto::protos::MemoryTrackerSnapshot;

namespace tracing {

namespace {

class TracingObserverProtoTest : public testing::Test {};

const base::ProcessId kTestPid =;
const int kRegionsCount =;

const uint32_t kResidentSetKb =;
const uint32_t kPrivateFootprintKb =;
const uint32_t kSharedFootprintKb =;

const base::TimeTicks kTimestamp =;
const uint64_t kTimestampProto =;

uint64_t GetFakeAddrForVmRegion(int pid, int region_index) {}

uint64_t GetFakeSizeForVmRegion(int pid, int region_index) {}

std::vector<memory_instrumentation::mojom::VmRegionPtr> FillMemoryMap(int pid) {}

memory_instrumentation::mojom::OSMemDump GetFakeOSMemDump(
    uint32_t resident_set_kb,
    uint32_t private_footprint_kb,
    uint32_t shared_footprint_kb) {}

// crbug.com/1242040: flaky on linux, chromeos
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_AddChromeDumpToTraceIfEnabled_When_TraceLog_Disabled
#else
#define MAYBE_AddChromeDumpToTraceIfEnabled_When_TraceLog_Disabled
#endif
TEST_F(TracingObserverProtoTest,
       MAYBE_AddChromeDumpToTraceIfEnabled_When_TraceLog_Disabled) {}

TEST_F(TracingObserverProtoTest,
       AddOsDumpToTraceIfEnabled_When_TraceLog_Disabled) {}

TEST_F(TracingObserverProtoTest, AddChromeDumpToTraceIfEnabled) {}

TEST_F(TracingObserverProtoTest, AddOsDumpToTraceIfEnabled) {}

TEST_F(TracingObserverProtoTest, AsProtoInto) {}

}  // namespace

}  // namespace tracing