#include "chrome/browser/ui/webui/browser_command/browser_command_handler.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/command_updater_impl.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/user_education/tutorial_identifiers.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/saved_tab_groups/features.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/user_education/common/help_bubble_factory_registry.h"
#include "components/user_education/common/tutorial_identifier.h"
#include "components/user_education/common/tutorial_registry.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/window_open_disposition.h"
#include "ui/base/window_open_disposition_utils.h"
#include "ui/webui/resources/js/browser_command/browser_command.mojom.h"
ClickInfo;
ClickInfoPtr;
Command;
CommandHandler;
namespace {
std::vector<Command> supported_commands = …;
const ui::ElementContext kTestContext1(1);
class TestCommandHandler : public BrowserCommandHandler { … };
class TestTutorialService : public user_education::TutorialService { … };
class MockTutorialService : public TestTutorialService { … };
class MockCommandHandler : public TestCommandHandler { … };
class MockCommandUpdater : public CommandUpdaterImpl { … };
void CanExecuteCommandCallback(base::OnceClosure quit_closure,
bool* expected_can_show,
bool can_show) { … }
void ExecuteCommandCallback(base::OnceClosure quit_closure,
bool* expected_command_executed,
bool command_executed) { … }
WindowOpenDisposition DispositionFromClick(const ClickInfo& info) { … }
class TestingChildProfile : public TestingProfile { … };
}
class BrowserCommandHandlerTest : public testing::Test { … };
TEST_F(BrowserCommandHandlerTest, SupportedCommands) { … }
TEST_F(BrowserCommandHandlerTest, CanExecuteCommand_OpenSafetyCheck) { … }
TEST_F(BrowserCommandHandlerTest, OpenSafetyCheckCommand) { … }
TEST_F(BrowserCommandHandlerTest, OpenSafetyCheckFromWhatsNewCommand) { … }
TEST_F(BrowserCommandHandlerTest,
CanShowSafeBrowsingEnhancedProtectionCommandPromo_NoPolicies) { … }
TEST_F(
BrowserCommandHandlerTest,
CanShowSafeBrowsingEnhancedProtectionCommandPromo_EnhancedProtectionEnabled) { … }
TEST_F(
BrowserCommandHandlerTest,
CanShowSafeBrowsingEnhancedProtectionCommandPromo_HasSafeBrowsingManaged_NoProtection) { … }
TEST_F(
BrowserCommandHandlerTest,
CanShowSafeBrowsingEnhancedProtectionCommandPromo_HasSafeBrowsingManaged_StandardProtection) { … }
TEST_F(
BrowserCommandHandlerTest,
CanShowSafeBrowsingEnhancedProtectionCommandPromo_HasSafeBrowsingManaged_EnhancedProtection) { … }
TEST_F(BrowserCommandHandlerTest, OpenSafeBrowsingEnhancedProtectionCommand) { … }
TEST_F(BrowserCommandHandlerTest, OpenFeedbackFormCommand) { … }
TEST_F(BrowserCommandHandlerTest, CanExecuteCommand_OpenPrivacyGuide) { … }
TEST_F(BrowserCommandHandlerTest, OpenPrivacyGuideCommand) { … }
TEST_F(BrowserCommandHandlerTest, StartTabGroupTutorialCommand) { … }
TEST_F(BrowserCommandHandlerTest, OpenPasswordManagerCommand) { … }
TEST_F(BrowserCommandHandlerTest, OpenPerformanceSettings) { … }
TEST_F(BrowserCommandHandlerTest,
OpenNTPAndStartCustomizeChromeTutorialCommand) { … }
TEST_F(BrowserCommandHandlerTest, StartPasswordManagerTutorialCommand) { … }
TEST_F(BrowserCommandHandlerTest, StartSavedTabGroupTutorialCommand) { … }
TEST_F(BrowserCommandHandlerTest, OpenAISettingsCommand) { … }
TEST_F(BrowserCommandHandlerTest, OpenPaymentsSettingsCommand) { … }