#include "chrome/browser/ui/views/toolbar/app_menu.h"
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include "base/auto_reset.h"
#include "base/containers/contains.h"
#include "base/containers/fixed_flat_map.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/time/time_override.h"
#include "base/timer/elapsed_timer.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_test_util.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service_load_waiter.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h"
#include "chrome/browser/ui/hats/trust_safety_sentiment_service_factory.h"
#include "chrome/browser/ui/safety_hub/safety_hub_hats_service.h"
#include "chrome/browser/ui/safety_hub/safety_hub_hats_service_factory.h"
#include "chrome/browser/ui/safety_hub/safety_hub_test_util.h"
#include "chrome/browser/ui/test/test_browser_ui.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/frame/app_menu_button_observer.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/browser_app_menu_button.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/upgrade_detector/upgrade_detector.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/menu/menu_scroll_view_container.h"
#include "ui/views/controls/menu/submenu_view.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "ui/display/screen.h"
#include "ui/display/tablet_state.h"
#endif
namespace {
class AppMenuBrowserTest : public UiBrowserTest { … };
void AppMenuBrowserTest::ShowUi(const std::string& name) { … }
bool AppMenuBrowserTest::VerifyUi() { … }
void AppMenuBrowserTest::WaitForUserDismissal() { … }
class AppMenuBrowserTestRefreshOnly : public AppMenuBrowserTest { … };
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, ShowWithRecentlyClosedWindow) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, InvokeUi_main) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly, InvokeUi_main) { … }
#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_X86_64)
#define MAYBE_InvokeUi_main_upgrade_available …
#else
#define MAYBE_InvokeUi_main_upgrade_available …
#endif
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly,
MAYBE_InvokeUi_main_upgrade_available) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, InvokeUi_main_tablet_mode) {
display::Screen::GetScreen()->OverrideTabletStateForTesting(
display::TabletState::kInTabletMode);
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly,
InvokeUi_main_tablet_mode) {
display::Screen::GetScreen()->OverrideTabletStateForTesting(
display::TabletState::kInTabletMode);
ShowAndVerifyUi();
}
#endif
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly, InvokeUi_main_guest) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly, InvokeUi_main_incognito) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, InvokeUi_history) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, InvokeUi_bookmarks) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, InvokeUi_more_tools) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, AppMenuViewAccessibleProperties) { … }
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTest, InvokeUi_help) {
ShowAndVerifyUi();
}
#endif
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly,
InvokeUi_passwords_and_autofill) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly, InvokeUi_reading_list) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly, InvokeUi_extensions) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly, InvokeUi_find_and_edit) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly, InvokeUi_save_and_share) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly,
InvokeUi_main_profile_signed_in) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly,
InvokeUi_profile_menu_in_app_menu_signed_out) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly,
InvokeUi_profile_menu_in_app_menu_signed_in) { … }
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestRefreshOnly,
InvokeUi_profile_menu_in_app_menu_signin_not_allowed) { … }
#endif
class AppMenuBrowserTestSafetyHub : public AppMenuBrowserTest { … };
IN_PROC_BROWSER_TEST_F(AppMenuBrowserTestSafetyHub,
Safety_Hub_shown_notification) { … }
}