#include "third_party/blink/renderer/core/frame/find_in_page.h"
#include "base/functional/bind.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom-blink.h"
#include "third_party/blink/renderer/core/editing/finder/text_finder.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
RunPendingTasks;
namespace blink {
class FindInPageTest : public testing::Test { … };
Document& FindInPageTest::GetDocument() const { … }
FindInPage& FindInPageTest::GetFindInPage() const { … }
TextFinder& FindInPageTest::GetTextFinder() const { … }
class FindInPageCallbackReceiver { … };
#if BUILDFLAG(IS_ANDROID)
TEST_F(FindInPageTest, FindMatchRectsReturnsCorrectRects) {
GetDocument().body()->setInnerHTML("aAaAbBaBbAaAaA");
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
int identifier = 0;
WebString search_text(String("aA"));
auto find_options =
mojom::blink::FindOptions::New();
find_options->run_synchronously_for_testing = true;
GetTextFinder().ResetMatchCount();
GetTextFinder().StartScopingStringMatches(identifier, search_text,
*find_options);
int rects_version = GetTextFinder().FindMatchMarkersVersion();
FindInPageCallbackReceiver callback_receiver;
GetFindInPage().FindMatchRects(
rects_version - 1,
WTF::BindOnce(&FindInPageCallbackReceiver::AssertFindMatchRects,
WTF::Unretained(&callback_receiver), rects_version,
GetTextFinder().FindMatchRects(),
GetTextFinder().ActiveFindMatchRect()));
EXPECT_TRUE(callback_receiver.IsCalled());
}
#endif
TEST_F(FindInPageTest, FindAllAs) { … }
}