chromium/components/performance_manager/freezing/freezing_policy_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 "components/performance_manager/freezing/freezing_policy.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "components/performance_manager/freezing/freezer.h"
#include "components/performance_manager/graph/graph_impl.h"
#include "components/performance_manager/graph/process_node_impl.h"
#include "components/performance_manager/public/decorators/page_live_state_decorator.h"
#include "components/performance_manager/public/features.h"
#include "components/performance_manager/public/freezing/freezing.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "components/performance_manager/public/resource_attribution/origin_in_browsing_instance_context.h"
#include "components/performance_manager/public/resource_attribution/queries.h"
#include "components/performance_manager/public/resource_attribution/query_results.h"
#include "components/performance_manager/public/resource_attribution/resource_contexts.h"
#include "components/performance_manager/test_support/graph_test_harness.h"
#include "content/public/browser/browsing_instance_id.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"

namespace performance_manager {

namespace {

Mock;

// Mock version of a Freezer.
class LenientMockFreezer : public Freezer {};
MockFreezer;

}  // namespace

class FreezingPolicyTest : public GraphTestHarness {};

// A page with no `CannotFreezeReason` that is alone in its browsing instance is
// frozen when it has a freezing vote.
TEST_F(FreezingPolicyTest, Basic) {}

// Multiple connected pages in the same browsing instance with no
// `CannotFreezeReason` are frozen when they all have a freezing vote.
TEST_F(FreezingPolicyTest, ManyPagesSameBrowsingInstance) {}

// Similar to ManyPagesSameBrowsingInstance, except that the 1st and 3rd pages
// don't have frames in the same browsing instance (they're indirectly connected
// via the 2nd page).
TEST_F(FreezingPolicyTest, ConnectedPages) {}

// A browsing instance with many pages that each have a freeze vote is unfrozen
// when one of the pages gets a `CannotFreezeReason`.
TEST_F(FreezingPolicyTest,
       AddCannotFreezeReasonToBrowsingInstanceWithManyPages) {}

// Similar to AddCannotFreezeReasonToBrowsingInstanceWithManyPages, except that
// the 1st and 3rd pages don't have frames in the same browsing instance
// (they're indirectly connected via the 2nd page).
TEST_F(FreezingPolicyTest, AddCannotFreezeReasonToConnectedPages) {}

// A browsing instance with one page that has a `CannotFreezeReason` is not
// frozen when all its pages get a freeze vote.
TEST_F(FreezingPolicyTest,
       AddFreezeVotesToBrowsingInstanceWithManyPagesAndCannotFreezeReason) {}

// Similar to
// AddFreezeVotesToBrowsingInstanceWithManyPagesAndCannotFreezeReason, except
// that the 1st and 3rd pages don't have frames in the same browsing instance
// (they're indirectly connected via the 2nd page).
TEST_F(FreezingPolicyTest,
       AddFreezeVotesToConnectedPagesWithCannotFreezeReason) {}

// Verify that frozen state is correctly updated when a set of connected pages
// is broken in two by the deletion of a frame.
TEST_F(FreezingPolicyTest, BreakConnectedSet) {}

// Similar to BreakConnectedSet, but the connected set left by the page from
// which a page is deleted can be frozen.
TEST_F(FreezingPolicyTest, BreakConnectedSet_LeftSetIsFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenVisible) {}

TEST_F(FreezingPolicyTest, BecomesVisibleWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenAudible) {}

TEST_F(FreezingPolicyTest, BecomesAudibleWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenRecentlyAudible) {}

TEST_F(FreezingPolicyTest, BecomesRecentlyAudibleWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenHoldingWebLock) {}

TEST_F(FreezingPolicyTest, AcquiresWebLockWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenHoldingIndexedDBLock) {}

TEST_F(FreezingPolicyTest, AcquiresIndexedDBLockWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenConnectedToUSBDevice) {}

TEST_F(FreezingPolicyTest, ConnectedToUSBDeviceWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenConnectedToBluetoothDevice) {}

TEST_F(FreezingPolicyTest, ConnectedToBluetoothDeviceWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenCapturingVideo) {}

TEST_F(FreezingPolicyTest, StartsCapturingVideoWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenCapturingAudio) {}

TEST_F(FreezingPolicyTest, StartsCapturingAudioWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenMirrored) {}

TEST_F(FreezingPolicyTest, StartsBeingMirroredWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenCapturingWindow) {}

TEST_F(FreezingPolicyTest, StartsCapturingWindowWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenCapturingDisplay) {}

TEST_F(FreezingPolicyTest, StartsCapturingDisplayWhenFrozen) {}

TEST_F(FreezingPolicyTest, FreezeVoteWhenLoading) {}

TEST_F(FreezingPolicyTest, StartsLoadingWhenFrozen) {}

namespace {

class FreezingPolicyBatterySaverTest : public FreezingPolicyTest {};

}  // namespace

TEST_F(FreezingPolicyBatterySaverTest, Basic) {}

TEST_F(FreezingPolicyBatterySaverTest, ConnectedPages) {}

TEST_F(FreezingPolicyBatterySaverTest, CannotFreeze) {}

TEST_F(FreezingPolicyBatterySaverTest, CannotFreezeTransient) {}

TEST_F(FreezingPolicyBatterySaverTest, BatterySaverInactive) {}

TEST_F(FreezingPolicyBatterySaverTest, ForegroundCPU) {}

TEST_F(FreezingPolicyBatterySaverTest, DeactivateBatterySaver) {}

TEST_F(FreezingPolicyBatterySaverTest, ActivateBatterySaverAfterHighCPU) {}

}  // namespace performance_manager