chromium/chrome/browser/search/background/wallpaper_search/wallpaper_search_background_manager_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 "chrome/browser/search/background/wallpaper_search/wallpaper_search_background_manager.h"

#include <vector>

#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/token.h"
#include "build/build_config.h"
#include "chrome/browser/search/background/ntp_custom_background_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"

namespace {

const char kWallpaperSearchHistoryId[] =;
const char kWallpaperSearchHistoryMood[] =;
const char kWallpaperSearchHistoryStyle[] =;
const char kWallpaperSearchHistorySubject[] =;

DoAll;
Return;
SaveArg;

class MockNtpCustomBackgroundService : public NtpCustomBackgroundService {};

class MockWallpaperSearchBackgroundManagerObserver
    : public WallpaperSearchBackgroundManagerObserver {};

std::unique_ptr<TestingProfile> MakeTestingProfile() {}

}  // namespace

class WallpaperSearchBackgroundManagerTest : public testing::Test {};

TEST_F(WallpaperSearchBackgroundManagerTest, GetHistory) {}

TEST_F(WallpaperSearchBackgroundManagerTest, SetHistoryImage) {}

TEST_F(WallpaperSearchBackgroundManagerTest, SetLocalBackgroundImage) {}

TEST_F(WallpaperSearchBackgroundManagerTest,
       SetLocalBackgroundImage_Inspiration) {}

// If the currently set wallpaper search image is set again, do not pass it
// through to SetBackgroundToLocalResourceWithId(). Otherwise, its image file
// could be deleted.
TEST_F(WallpaperSearchBackgroundManagerTest,
       SetLocalBackgroundImage_DoNotReSetSameImage) {}

TEST_F(WallpaperSearchBackgroundManagerTest, IsCurrentBackground) {}

TEST_F(WallpaperSearchBackgroundManagerTest, SaveCurrentBackgroundToHistory) {}

// Test that the last history entry is deleted when a new entry is added,
// if the list is full.
TEST_F(WallpaperSearchBackgroundManagerTest,
       SaveCurrentBackgroundToHistory_FullHistory) {}

// Test when the new history entry is already in history. Nothing should be
// deleted and the matching history entry should move to the front.
TEST_F(WallpaperSearchBackgroundManagerTest,
       SaveCurrentBackgroundToHistory_AlreadyInHistory) {}

// Test when the new history entry is the last entry in history. Nothing should
// be deleted and the matching history entry should move to the front.
TEST_F(WallpaperSearchBackgroundManagerTest,
       SaveCurrentBackgroundToHistory_LastInHistory) {}

// Check that std::nullopt is returned if the history entry passed in is
// not the current theme, and history is not changed.
TEST_F(WallpaperSearchBackgroundManagerTest,
       SaveCurrentBackgroundToHistory_NotCurrentBackground) {}

// Test that a wallpaper search background is removed if it is not in history
TEST_F(WallpaperSearchBackgroundManagerTest,
       RemoveWallpaperSearchBackground_NotHistory) {}

// Test that a wallpaper search background is not removed if it is in history
TEST_F(WallpaperSearchBackgroundManagerTest,
       RemoveWallpaperSearchBackground_History) {}

// Test that looping through history doesn't crash if the value is the wrong.
// shape.
// Example: The pref used to be a list of token strings and is now a list of
//          |base::Value::Dict|. If we run into the old form, we do not want
//          to crash.
TEST_F(WallpaperSearchBackgroundManagerTest,
       NoCrashIfHistoryContainsIllformedData) {}

TEST_F(WallpaperSearchBackgroundManagerTest, NotifyAboutHistory) {}