#include <memory>
#include <utility>
#include "base/cfi_buildflags.h"
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/scoped_observation.h"
#include "base/test/bind.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/types/expected.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/apps/app_service/app_registry_cache_waiter.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/link_capturing/link_capturing_feature_test_support.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/intent_picker_tab_helper.h"
#include "chrome/browser/ui/test/test_browser_ui.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/browser/ui/views/location_bar/intent_chip_button.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/browser/ui/web_applications/test/web_app_navigation_browsertest.h"
#include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/interaction/interaction_test_util.h"
#include "ui/base/ui_base_features.h"
#include "ui/events/event_utils.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/widget/any_widget_observer.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/apps/intent_helper/preferred_apps_test_util.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#else
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#endif
class IntentChipButtonBrowserTest : public web_app::WebAppNavigationBrowserTest,
public testing::WithParamInterface<bool> { … };
IN_PROC_BROWSER_TEST_P(IntentChipButtonBrowserTest,
NavigationToInScopeLinkShowsIntentChip) { … }
IN_PROC_BROWSER_TEST_P(IntentChipButtonBrowserTest,
NavigationToOutOfScopeLinkDoesNotShowsIntentChip) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_IconVisibilityAfterTabSwitching …
#else
#define MAYBE_IconVisibilityAfterTabSwitching …
#endif
IN_PROC_BROWSER_TEST_P(IntentChipButtonBrowserTest,
MAYBE_IconVisibilityAfterTabSwitching) { … }
IN_PROC_BROWSER_TEST_P(IntentChipButtonBrowserTest,
ShowsIntentChipExpandedForPreferredApp) { … }
#if BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_P(IntentChipButtonBrowserTest, OpensAppForPreferredApp) {
apps_util::SetSupportedLinksPreferenceAndWait(profile(), test_web_app_id());
const GURL in_scope_url =
https_server().GetURL(GetAppUrlHost(), GetInScopeUrlPath());
DoAndWaitForIntentPickerIconUpdate([this, in_scope_url] {
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), in_scope_url));
});
Browser* app_browser = ClickIntentChip(true);
EXPECT_TRUE(web_app::AppBrowserController::IsForWebApp(app_browser,
test_web_app_id()));
}
#endif
INSTANTIATE_TEST_SUITE_P(…);
class IntentChipButtonBrowserUiTest : public UiBrowserTest { … };
#if BUILDFLAG(IS_WIN)
#define MAYBE_InvokeUi_default …
#else
#define MAYBE_InvokeUi_default …
#endif
IN_PROC_BROWSER_TEST_F(IntentChipButtonBrowserUiTest, MAYBE_InvokeUi_default) { … }