chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler_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/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h"

#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/gmock_move_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/search/background/ntp_background_data.h"
#include "chrome/browser/search/background/ntp_background_service_factory.h"
#include "chrome/browser/search/background/ntp_custom_background_service.h"
#include "chrome/browser/search/background/ntp_custom_background_service_observer.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory_test_util.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/webui/new_tab_page/ntp_pref_names.h"
#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome.mojom.h"
#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_section.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_profile.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/search/ntp_features.h"
#include "components/search_engines/template_url_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/scoped_web_ui_controller_factory_registration.h"
#include "content/public/test/test_web_contents_factory.h"
#include "content/public/test/web_ui_browsertest_util.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension_builder.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_features.h"
#include "ui/color/color_provider.h"
#include "ui/native_theme/native_theme.h"
#include "ui/shell_dialogs/select_file_dialog_factory.h"
#include "ui/shell_dialogs/selected_file_info.h"

namespace content {
class BrowserContext;
}  // namespace content

namespace {

_;
An;
DoAll;
Invoke;
Return;
ReturnRef;
SaveArg;

// A test SelectFileDialog to go straight to calling the listener.
class TestSelectFileDialog : public ui::SelectFileDialog {};

// A test SelectFileDialogFactory so that the TestSelectFileDialog is used.
class TestSelectFileDialogFactory : public ui::SelectFileDialogFactory {};

class MockPage : public side_panel::mojom::CustomizeChromePage {};

class MockNtpCustomBackgroundService : public NtpCustomBackgroundService {};

class MockNtpBackgroundService : public NtpBackgroundService {};

class MockThemeService : public ThemeService {};

std::unique_ptr<TestingProfile> MakeTestingProfile(
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {}

}  // namespace

class CustomizeChromePageHandlerTest : public testing::Test {};

TEST_F(CustomizeChromePageHandlerTest, SetMostVisitedSettings) {}

enum class ThemeUpdateSource {};

class CustomizeChromePageHandlerSetThemeTest
    : public CustomizeChromePageHandlerTest,
      public ::testing::WithParamInterface<ThemeUpdateSource> {};

TEST_P(CustomizeChromePageHandlerSetThemeTest, SetTheme) {}

TEST_P(CustomizeChromePageHandlerSetThemeTest, SetThemeWithDailyRefresh) {}

TEST_P(CustomizeChromePageHandlerSetThemeTest, SetUploadedImage) {}

TEST_P(CustomizeChromePageHandlerSetThemeTest, SetWallpaperSearchImage) {}

TEST_P(CustomizeChromePageHandlerSetThemeTest, SetThirdPartyTheme) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(CustomizeChromePageHandlerTest, GetBackgroundCollections) {}

TEST_F(CustomizeChromePageHandlerTest, GetBackgroundImages) {}

TEST_F(CustomizeChromePageHandlerTest, SetDefaultColor) {}

TEST_F(CustomizeChromePageHandlerTest, RemoveBackgroundImage) {}

TEST_F(CustomizeChromePageHandlerTest, ChooseLocalCustomBackgroundSuccess) {}

TEST_F(CustomizeChromePageHandlerTest, ChooseLocalCustomBackgroundCancel) {}

TEST_F(CustomizeChromePageHandlerTest, SetBackgroundImage) {}

TEST_F(CustomizeChromePageHandlerTest, OpenChromeWebStore) {}

TEST_F(CustomizeChromePageHandlerTest, OpenThirdPartyThemePage) {}

TEST_F(CustomizeChromePageHandlerTest, OpenChromeWebStoreCategoryPage) {}

TEST_F(CustomizeChromePageHandlerTest, OpenChromeWebStoreCollectionPage) {}

TEST_F(CustomizeChromePageHandlerTest, OpenNtpManagedByPage) {}

TEST_F(CustomizeChromePageHandlerTest, OpenChromeWebStoreHomePage) {}

TEST_F(CustomizeChromePageHandlerTest, SetDailyRefreshCollectionId) {}

TEST_F(CustomizeChromePageHandlerTest, SetFollowDeviceTheme_On) {}

TEST_F(CustomizeChromePageHandlerTest, SetUseDeviceTheme_Off) {}

TEST_F(CustomizeChromePageHandlerTest, ScrollToSection) {}

TEST_F(CustomizeChromePageHandlerTest, AttachedTabStateUpdated) {}

TEST_F(CustomizeChromePageHandlerTest, ScrollToUnspecifiedSection) {}

TEST_F(CustomizeChromePageHandlerTest, UpdateScrollToSection) {}

class CustomizeChromePageHandlerWithModulesTest
    : public CustomizeChromePageHandlerTest {};

TEST_F(CustomizeChromePageHandlerWithModulesTest, SetModulesSettings) {}

TEST_F(CustomizeChromePageHandlerWithModulesTest, SetModulesVisible) {}

TEST_F(CustomizeChromePageHandlerWithModulesTest, SetModuleDisabled) {}

class CustomizeChromePageHandlerWithTemplateURLServiceTest
    : public CustomizeChromePageHandlerTest {};

TEST_F(CustomizeChromePageHandlerWithTemplateURLServiceTest,
       NtpManagedByNameUpdated) {}