#include <string>
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "chrome/browser/apps/link_capturing/link_capturing_feature_test_support.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/user_education/browser_feature_promo_controller.h"
#include "chrome/browser/ui/views/web_apps/web_app_link_capturing_test_utils.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/browser/ui/web_applications/test/web_app_navigation_browsertest.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/web_app_pref_guardrails.h"
#include "chrome/browser/web_applications/web_app_ui_manager.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/user_education/interactive_feature_promo_test.h"
#include "components/user_education/views/help_bubble_factory_views.h"
#include "components/user_education/views/help_bubble_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event.h"
#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/point.h"
#include "ui/views/interaction/interaction_test_util_views.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/widget/any_widget_observer.h"
#if BUILDFLAG(IS_MAC)
#include "chrome/browser/apps/link_capturing/mac_intent_picker_helpers.h"
#endif
class DefaultLinkCapturingInteractiveUiTest
: public web_app::WebAppNavigationBrowserTest { … };
IN_PROC_BROWSER_TEST_F(DefaultLinkCapturingInteractiveUiTest,
IntentPickerBubbleAcceptCorrectActions) { … }
IN_PROC_BROWSER_TEST_F(DefaultLinkCapturingInteractiveUiTest,
IntentPickerBubbleCancel) { … }
IN_PROC_BROWSER_TEST_F(DefaultLinkCapturingInteractiveUiTest,
IntentPickerBubbleIgnored) { … }
#if BUILDFLAG(IS_MAC)
using IntentPickerInteractiveUiTest = DefaultLinkCapturingInteractiveUiTest;
IN_PROC_BROWSER_TEST_F(IntentPickerInteractiveUiTest,
ShowUniversalLinkAppInIntentChip) {
const GURL url1(embedded_test_server()->GetURL("/title1.html"));
const GURL url2(embedded_test_server()->GetURL("/title2.html"));
const char* kFinderAppPath = "/System/Library/CoreServices/Finder.app";
apps::OverrideMacAppForUrlForTesting(true, "");
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url1));
EXPECT_TRUE(web_app::AwaitIntentPickerTabHelperIconUpdateComplete(
browser()->tab_strip_model()->GetActiveWebContents()));
ASSERT_FALSE(web_app::GetIntentPickerIcon(browser())->GetVisible());
apps::OverrideMacAppForUrlForTesting(true, kFinderAppPath);
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url2));
EXPECT_TRUE(web_app::AwaitIntentPickerTabHelperIconUpdateComplete(
browser()->tab_strip_model()->GetActiveWebContents()));
IntentChipButton* intent_picker_icon =
web_app::GetIntentPickerIcon(browser());
ASSERT_NE(intent_picker_icon, nullptr);
ui::ImageModel app_icon = intent_picker_icon->GetAppIconForTesting();
SkColor final_color = app_icon.GetImage().AsBitmap().getColor(8, 8);
EXPECT_TRUE(
web_app::AreColorsEqual(SK_ColorRED, final_color, 50));
}
#endif
#if (BUILDFLAG(IS_LINUX) && \
(defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER))) || \
BUILDFLAG(IS_MAC)
#define MAYBE_AcceptingBubbleMeasuresUserAccept …
#define MAYBE_BubbleDismissMeasuresUserDismiss …
#define MAYBE_ClosingAppWindowMeasuresDismiss …
#define MAYBE_IPHShownOnLinkClick …
#else
#define MAYBE_AcceptingBubbleMeasuresUserAccept …
#define MAYBE_BubbleDismissMeasuresUserDismiss …
#define MAYBE_ClosingAppWindowMeasuresDismiss …
#define MAYBE_IPHShownOnLinkClick …
#endif
class WebAppLinkCapturingIPHPromoTest
: public InteractiveFeaturePromoTestT<
DefaultLinkCapturingInteractiveUiTest>,
public testing::WithParamInterface<bool> { … };
IN_PROC_BROWSER_TEST_P(WebAppLinkCapturingIPHPromoTest,
AppLaunchFromIntentChipShowsIPH) { … }
IN_PROC_BROWSER_TEST_P(WebAppLinkCapturingIPHPromoTest,
MAYBE_IPHShownOnLinkClick) { … }
IN_PROC_BROWSER_TEST_P(WebAppLinkCapturingIPHPromoTest,
MAYBE_ClosingAppWindowMeasuresDismiss) { … }
IN_PROC_BROWSER_TEST_P(WebAppLinkCapturingIPHPromoTest,
MAYBE_AcceptingBubbleMeasuresUserAccept) { … }
IN_PROC_BROWSER_TEST_P(WebAppLinkCapturingIPHPromoTest,
MAYBE_BubbleDismissMeasuresUserDismiss) { … }
INSTANTIATE_TEST_SUITE_P(…);