chromium/content/browser/renderer_host/navigation_transitions/navigation_entry_screenshot_cache_unittest.cc

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

#include "content/browser/renderer_host/navigation_transitions/navigation_entry_screenshot_cache.h"

#include "base/test/scoped_feature_list.h"
#include "cc/resources/ui_resource_bitmap.h"
#include "content/browser/browser_context_impl.h"
#include "content/browser/renderer_host/navigation_controller_impl.h"
#include "content/browser/renderer_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/navigation_transitions/navigation_entry_screenshot.h"
#include "content/browser/renderer_host/navigation_transitions/navigation_entry_screenshot_manager.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/restore_type.h"
#include "content/test/test_web_contents.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace content {

namespace {

static NavigationEntryScreenshotCache* GetCacheForTab(WebContents* tab) {}

NavigationEntry* GetEntryWithID(WebContents* tab, int nav_entry_id) {}

void AssertEntryHasNoScreenshot(WebContents* tab, int nav_entry_id) {}
}  // namespace

class NavigationEntryScreenshotCacheTest : public RenderViewHostTestHarness {};

// Test the basic functionalities of `SetScreenshot`, `RemoveScreenshot` of
// `NavigationEntryScreenshotCache`.
TEST_F(NavigationEntryScreenshotCacheTest, GetRemoveBasic) {}

// Test Get/Set when the `NavigationEntry` is deleted. When the navigation entry
// is deleted, we must clear the cached screenshot for the entry.
TEST_F(NavigationEntryScreenshotCacheTest, DeletedNavEntry) {}

// Test that screenshot eviction works in basic one-tab case.
TEST_F(NavigationEntryScreenshotCacheTest, CacheEvictionOneTab) {}

// Specifically testing the iterative implementation of
// `NavigationEntryScreenshotCache::EvictScreenshotsUntilInBudgetOrEmpty`:
// In previous tests, only one screenshot is evicted at a time; this test
// asserts the all but the nearest screenshots are evicted.
TEST_F(NavigationEntryScreenshotCacheTest, MultipleCacheEvictionsOneTab) {}

// Test that cached screenshot eviction works with multiple tabs: we always
// evict screenshots from the least recently used tabs. (Caching a screenshot
// affects which tab is LRU.)
TEST_F(NavigationEntryScreenshotCacheTest,
       AlwaysEvictFromLeastRecentlyUsedTabs) {}

// Test that when the WebContents is destroyed, all the screenshots for that tab
// are deleted.
TEST_F(NavigationEntryScreenshotCacheTest, OnWebContentsDestroyed) {}

// `base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL` signals the
// purge of all the cached screenshots within the global manager's Profile. This
// test asserts that.
TEST_F(NavigationEntryScreenshotCacheTest, OnMemoryPressureCritical) {}

}  // namespace content