chromium/chrome/browser/performance_manager/policies/memory_saver_mode_policy_unittest.cc

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

#include "chrome/browser/performance_manager/policies/memory_saver_mode_policy.h"

#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "chrome/browser/performance_manager/test_support/page_discarding_utils.h"
#include "components/performance_manager/public/decorators/tab_page_decorator.h"
#include "components/performance_manager/public/features.h"
#include "components/performance_manager/public/user_tuning/prefs.h"
#include "components/performance_manager/public/user_tuning/tab_revisit_tracker.h"
#include "components/prefs/testing_pref_service.h"

namespace performance_manager::policies {

namespace {
// These discard timeouts are based on the values in
// `MemorySaverModePolicy::GetTimeBeforeDiscardForCurrentMode`.
constexpr base::TimeDelta AGGRESSIVE_TIMEOUT =;
constexpr base::TimeDelta MEDIUM_TIMEOUT =;
constexpr base::TimeDelta CONSERVATIVE_TIMEOUT =;
}  // namespace

class TestTabRevisitTracker : public TabRevisitTracker {};

class MemorySaverModeTest : public testing::GraphTestHarnessWithMockDiscarder {};

TEST_F(MemorySaverModeTest, NoDiscardIfMemorySaverOff) {}

TEST_F(MemorySaverModeTest, DiscardAfterBackgrounded) {}

TEST_F(MemorySaverModeTest, DiscardAfterAggressiveTimeout) {}

TEST_F(MemorySaverModeTest, DiscardAfterConservativeTimeout) {}

TEST_F(MemorySaverModeTest, DontDiscardAfterBackgroundedIfSuspended) {}

TEST_F(MemorySaverModeTest, DontDiscardIfPageIsNotATab) {}

// The tab shouldn't be discarded if it's playing audio. There are many other
// conditions that prevent discarding, but they're implemented in
// `PageDiscardingHelper` and therefore tested there.
TEST_F(MemorySaverModeTest, DontDiscardIfPlayingAudio) {}

TEST_F(MemorySaverModeTest, DontDiscardIfAlreadyNotVisibleWhenModeEnabled) {}

TEST_F(MemorySaverModeTest, NoDiscardIfPageNodeRemoved) {}

TEST_F(MemorySaverModeTest, UnknownPageNodeNeverAddedToMap) {}

TEST_F(MemorySaverModeTest, PageNodeDiscardedIfTypeChanges) {}

TEST_F(MemorySaverModeTest,
       DiscardAfterTimeForCurrentModeIfNumRevisitsUnderMax) {}

TEST_F(MemorySaverModeTest, DontDiscardIfAboveMaxNumRevisits) {}

}  // namespace performance_manager::policies