#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/lens/lens_overlay_controller.h"
#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/find_bar_host.h"
#include "chrome/browser/ui/views/find_bar_view.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/contents_web_view.h"
#include "chrome/test/base/find_result_waiter.h"
#include "chrome/test/base/in_process_browser_test.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 "components/find_in_page/find_notification_details.h"
#include "components/find_in_page/find_tab_helper.h"
#include "components/find_in_page/find_types.h"
#include "components/lens/lens_features.h"
#include "components/omnibox/common/omnibox_features.h"
#include "content/public/browser/render_widget_host_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 "content/public/test/focus_changed_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/switches.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_modifiers.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/interaction/view_focus_observer.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
ASCIIToUTF16;
WebContents;
IsViewFocused;
namespace {
const char kSimplePage[] = …;
std::unique_ptr<net::test_server::HttpResponse> HandleHttpRequest(
const net::test_server::HttpRequest& request) { … }
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(…);
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(…);
}
struct FindResultState { … };
class FindResulStateObserver : public ui::test::ObservationStateObserver<
FindResultState,
find_in_page::FindTabHelper,
find_in_page::FindResultObserver> { … };
DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(…);
class LegacyFindInPageTest : public InProcessBrowserTest { … };
class FindBarViewsUiTest : public InteractiveBrowserTest { … };
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, CrashEscHandlers) { … }
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, NavigationByKeyEvent) { … }
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest, ButtonsDoNotAlterFocus) { … }
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, ButtonsDisabledWithoutText) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusRestore …
#else
#define MAYBE_FocusRestore …
#endif
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, MAYBE_FocusRestore) { … }
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, SelectionRestoreOnTabSwitch) { … }
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, FocusRestoreOnTabSwitch) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusRestoreOnTabSwitchDismiss …
#else
#define MAYBE_FocusRestoreOnTabSwitchDismiss …
#endif
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest,
MAYBE_FocusRestoreOnTabSwitchDismiss) { … }
#if !BUILDFLAG(IS_MAC) && !defined(USE_AURA)
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest, PrepopulateRespectBlank) {
ASSERT_TRUE(embedded_test_server()->Start());
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
GURL url = embedded_test_server()->GetURL(kSimplePage);
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
browser()->GetFindBarController()->Show();
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_A, false, false, false, false));
EXPECT_EQ(u"a", GetFindBarText());
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_BACK, false, false, false, false));
EXPECT_EQ(std::u16string(), GetFindBarText());
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_ESCAPE, false, false, false, false));
browser()->GetFindBarController()->Show();
EXPECT_EQ(std::u16string(), GetFindBarText());
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_ESCAPE, false, false, false, false));
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
browser(), ui::VKEY_F3, false, false, false, false));
EXPECT_EQ(std::u16string(), GetFindBarText());
}
#endif
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest, DISABLED_PasteWithoutTextChange) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_CtrlEnter …
#else
#define MAYBE_CtrlEnter …
#endif
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest, MAYBE_CtrlEnter) { … }
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest, ActiveMatchAfterNoResults) { … }
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest, DISABLED_SelectionDuringFind) { … }
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest, GlobalEscapeClosesFind) { … }
IN_PROC_BROWSER_TEST_F(LegacyFindInPageTest,
ConsumedGlobalEscapeDoesNotCloseFind) { … }
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, MatchOrdinalStableWhileTyping) { … }
IN_PROC_BROWSER_TEST_F(FindBarViewsUiTest, LensButton) { … }