#include "base/memory/discardable_memory.h"
#include "base/memory/discardable_memory_internal.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_POSIX)
#include "base/memory/madv_free_discardable_memory_posix.h"
#endif
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
namespace base {
class DiscardableMemoryBackingFieldTrialTest : public ::testing::Test { … };
TEST_F(DiscardableMemoryBackingFieldTrialTest, TrialActiveOnlyIfCapable) { … }
TEST_F(DiscardableMemoryBackingFieldTrialTest,
EmulatedSharedMemoryBackingMatchesTrialGroup) { … }
TEST_F(DiscardableMemoryBackingFieldTrialTest,
MadvFreeBackingMatchesTrialGroup) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(DiscardableMemoryBackingFieldTrialTest, AshmemBackingMatchesTrialGroup) {
std::unique_ptr<test::ScopedFeatureList> scoped_feature =
GetScopedFeatureListForDiscardableMemoryTrialGroup(
DiscardableMemoryTrialGroup::kAshmem);
if (!DiscardableMemoryBackingFieldTrialIsEnabled())
return;
DiscardableMemoryBacking backing = GetDiscardableMemoryBacking();
EXPECT_EQ(backing, DiscardableMemoryBacking::kSharedMemory);
}
#endif
}
#endif