| Index: components/web_view/web_view_apptest.cc
|
| diff --git a/components/web_view/web_view_apptest.cc b/components/web_view/web_view_apptest.cc
|
| index 130ef0a22e1baa079be89cd19a3fa43e1875af47..edcca51b8c7113d5c4ab3e1d8b9636cca226d5bb 100644
|
| --- a/components/web_view/web_view_apptest.cc
|
| +++ b/components/web_view/web_view_apptest.cc
|
| @@ -26,6 +26,7 @@ const char kTestTwoFile[] = "test_two.html";
|
| const char kTestTwoTitle[] = "Test Title Two";
|
| const char kTestThreeFile[] = "test_three.html";
|
| const char kTestThreeTitle[] = "Test Title Three";
|
| +const char kTheWordGreenFiveTimes[] = "the_word_green_five_times.html";
|
|
|
| GURL GetTestFileURL(const std::string& file) {
|
| base::FilePath data_file;
|
| @@ -36,12 +37,13 @@ GURL GetTestFileURL(const std::string& file) {
|
| CHECK(base::PathExists(data_file));
|
| return mojo::util::FilePathToFileURL(data_file);
|
| }
|
| +
|
| }
|
|
|
| class WebViewTest : public mus::ViewManagerTestBase,
|
| public mojom::WebViewClient {
|
| public:
|
| - WebViewTest() : web_view_(this) {}
|
| + WebViewTest() : web_view_(this), active_find_match_(0), find_count_(0) {}
|
| ~WebViewTest() override {}
|
|
|
| mojom::WebView* web_view() { return web_view_.web_view(); }
|
| @@ -55,6 +57,9 @@ class WebViewTest : public mus::ViewManagerTestBase,
|
| return last_forward_button_state_;
|
| }
|
|
|
| + int32_t active_find_match() const { return active_find_match_; }
|
| + int32_t find_count() const { return find_count_; }
|
| +
|
| void StartNestedRunLoopUntilLoadingDone() {
|
| run_loop_.reset(new base::RunLoop);
|
| run_loop_->Run();
|
| @@ -83,6 +88,7 @@ class WebViewTest : public mus::ViewManagerTestBase,
|
| // Overridden from ViewTreeDelegate:
|
| void OnEmbed(mus::View* root) override {
|
| content_ = root->connection()->CreateView();
|
| + content_->SetBounds(root->bounds());
|
| root->AddChild(content_);
|
| content_->SetVisible(true);
|
|
|
| @@ -113,6 +119,17 @@ class WebViewTest : public mus::ViewManagerTestBase,
|
| void TitleChanged(const mojo::String& title) override {
|
| last_title_ = title.get();
|
| }
|
| + void ReportFindInPageMatchCount(int32_t request_id,
|
| + int32_t count,
|
| + bool final_update) override {
|
| + find_count_ = count;
|
| + if (final_update)
|
| + QuitNestedRunLoop();
|
| + }
|
| + void ReportFindInPageSelection(int32_t request_id,
|
| + int32_t active_match_ordinal) override {
|
| + active_find_match_ = active_match_ordinal;
|
| + }
|
|
|
| mojo::ApplicationImpl* app_;
|
|
|
| @@ -127,6 +144,9 @@ class WebViewTest : public mus::ViewManagerTestBase,
|
| mojom::ButtonState last_back_button_state_;
|
| mojom::ButtonState last_forward_button_state_;
|
|
|
| + int32_t active_find_match_;
|
| + int32_t find_count_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(WebViewTest);
|
| };
|
|
|
| @@ -201,4 +221,13 @@ TEST_F(WebViewTest, NavigationClearsForward) {
|
| last_forward_button_state());
|
| }
|
|
|
| +TEST_F(WebViewTest, Find) {
|
| + ASSERT_NO_FATAL_FAILURE(NavigateTo(kTheWordGreenFiveTimes));
|
| +
|
| + web_view()->Find(1, "Green");
|
| + StartNestedRunLoopUntilLoadingDone();
|
| + EXPECT_EQ(1, active_find_match());
|
| + EXPECT_EQ(5, find_count());
|
| +}
|
| +
|
| } // namespace web_view
|
|
|