chromium/chrome/browser/ui/toolbar/app_menu_model_interactive_uitest.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 <optional>
#include <string>

#include "base/feature_list.h"
#include "base/logging.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/ui/accelerator_utils.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/toolbar/app_menu_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test_utils.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "chrome/test/interaction/tracked_element_webcontents.h"
#include "chrome/test/interaction/webcontents_interaction_test_util.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/performance_manager/public/features.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/supervised_user/core/common/features.h"
#include "components/supervised_user/test_support/supervised_user_signin_test_utils.h"
#include "components/webapps/browser/banners/app_banner_manager.h"
#include "components/webapps/browser/banners/installable_web_app_check_result.h"
#include "components/webapps/browser/banners/web_app_banner_data.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "content/public/test/browser_test.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_urls.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/accelerators/menu_label_accelerator_util.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/expect_call_in_scope.h"
#include "ui/base/interaction/interaction_sequence.h"
#include "ui/base/interaction/state_observer.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "url/gurl.h"

namespace {
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
}  // namespace

class AppMenuModelInteractiveTest : public InteractiveBrowserTest {};

IN_PROC_BROWSER_TEST_F(AppMenuModelInteractiveTest, PerformanceNavigation) {}

IN_PROC_BROWSER_TEST_F(AppMenuModelInteractiveTest, IncognitoMenuItem) {}

IN_PROC_BROWSER_TEST_F(AppMenuModelInteractiveTest, IncognitoAccelerator) {}

// Test to confirm that the manage extensions menu item navigates when selected
// and emite histograms that it did so.
IN_PROC_BROWSER_TEST_F(AppMenuModelInteractiveTest, ManageExtensions) {}

IN_PROC_BROWSER_TEST_F(AppMenuModelInteractiveTest,
                       CastSaveShareSubMenuItemText) {}

// TODO(crbug.com/40073814): Remove this test in favor of a unit test
// extension_urls::GetWebstoreLaunchURL().
class ExtensionsMenuVisitChromeWebstoreModelInteractiveTest
    : public AppMenuModelInteractiveTest,
      public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

// Test to confirm that the visit Chrome Web Store menu item navigates to the
// correct chrome webstore URL when selected and emits histograms that it did
// so.
IN_PROC_BROWSER_TEST_P(ExtensionsMenuVisitChromeWebstoreModelInteractiveTest,
                       VisitChromeWebStore) {}

class PasswordManagerMenuItemInteractiveTest
    : public AppMenuModelInteractiveTest,
      public testing::WithParamInterface<bool> {};

IN_PROC_BROWSER_TEST_F(PasswordManagerMenuItemInteractiveTest,
                       PasswordManagerMenuItem) {}

IN_PROC_BROWSER_TEST_F(PasswordManagerMenuItemInteractiveTest,
                       NoMenuItemOnPasswordManagerPage) {}

ObservationStateObserver;
AppBannerManager;
InstallableWebAppCheckResult;
WebAppBannerData;

class AppBannerManagerInstallStateObserver
    : public ObservationStateObserver<InstallableWebAppCheckResult,
                                      AppBannerManager,
                                      AppBannerManager::Observer> {};

namespace {
DEFINE_LOCAL_STATE_IDENTIFIER_VALUE();
}  // namespace

class UniversalInstallAppMenuModelInteractiveTest
    : public AppMenuModelInteractiveTest,
      public testing::WithParamInterface<bool> {};

IN_PROC_BROWSER_TEST_P(UniversalInstallAppMenuModelInteractiveTest,
                       DIYAppMenuWorksCorrectly) {}

IN_PROC_BROWSER_TEST_P(UniversalInstallAppMenuModelInteractiveTest,
                       DIYAppMenuWorksCorrectlyInvalidManifestParsingSites) {}

IN_PROC_BROWSER_TEST_P(UniversalInstallAppMenuModelInteractiveTest,
                       InstallAppMenuWorksCorrectly) {}

IN_PROC_BROWSER_TEST_P(UniversalInstallAppMenuModelInteractiveTest,
                       InstallAppMenuShowsForNonLocallyInstalledApps) {}

INSTANTIATE_TEST_SUITE_P();

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
class SupervisedUserAppMenuModelInteractiveTest
    : public AppMenuModelInteractiveTest,
      public testing::WithParamInterface<bool> {};

IN_PROC_BROWSER_TEST_P(SupervisedUserAppMenuModelInteractiveTest,
                       OpenGuestSessionForSignedOutUser) {}

IN_PROC_BROWSER_TEST_P(SupervisedUserAppMenuModelInteractiveTest,
                       OpenGuestSessionForSignedInRegularUser) {}

IN_PROC_BROWSER_TEST_P(SupervisedUserAppMenuModelInteractiveTest,
                       OpenGuestSessionForSignedInSupervisedUser) {}

INSTANTIATE_TEST_SUITE_P();
#endif  // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)