1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/services/heap_profiling/public/cpp/switches.h"
#include "base/command_line.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "components/services/heap_profiling/public/cpp/settings.h"
#include "partition_alloc/buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace heap_profiling {
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
TEST(HeapProfilingSwitches, GetModeForStartup_Default) {
EXPECT_EQ(Mode::kNone, GetModeForStartup());
}
TEST(HeapProfilingSwitches, GetModeForStartup_Commandline) {
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(kMemlogMode, "");
EXPECT_EQ(Mode::kNone, GetModeForStartup());
}
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(kMemlogMode,
"invalid");
EXPECT_EQ(Mode::kNone, GetModeForStartup());
}
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(kMemlogMode,
kMemlogModeAll);
EXPECT_EQ(Mode::kAll, GetModeForStartup());
}
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
kMemlogMode, kMemlogModeBrowser);
EXPECT_EQ(Mode::kBrowser, GetModeForStartup());
}
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
kMemlogMode, kMemlogModeMinimal);
EXPECT_EQ(Mode::kMinimal, GetModeForStartup());
}
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(kMemlogMode,
kMemlogModeGpu);
EXPECT_EQ(Mode::kGpu, GetModeForStartup());
}
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
kMemlogMode, kMemlogModeRendererSampling);
EXPECT_EQ(Mode::kRendererSampling, GetModeForStartup());
}
}
#else
TEST(HeapProfilingSwitches, GetModeForStartup_NoModeWithoutShim) {
{
base::test::ScopedCommandLine scoped_command_line;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(kMemlogMode,
kMemlogModeAll);
EXPECT_EQ(Mode::kNone, GetModeForStartup());
}
}
#endif
} // namespace heap_profiling
|