| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/pdf/pdf_extension_test_util.h" | 7 #include "chrome/browser/pdf/pdf_extension_test_util.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
| 12 #include "content/public/browser/browser_context.h" | |
| 13 #include "content/public/browser/browser_plugin_guest_manager.h" | |
| 14 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 16 #include "content/public/test/find_test_utils.h" | 14 #include "content/public/test/find_test_utils.h" |
| 17 #include "content/public/test/test_navigation_observer.h" | 15 #include "content/public/test/test_navigation_observer.h" |
| 18 #include "net/dns/mock_host_resolver.h" | 16 #include "net/dns/mock_host_resolver.h" |
| 19 #include "third_party/WebKit/public/web/WebFindOptions.h" | 17 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 20 | 18 |
| 21 namespace content { | 19 namespace content { |
| 22 | 20 |
| 23 class ChromeFindRequestManagerTest : public InProcessBrowserTest { | 21 class ChromeFindRequestManagerTest : public InProcessBrowserTest { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // The ID of the last find request requested. | 76 // The ID of the last find request requested. |
| 79 int last_request_id_; | 77 int last_request_id_; |
| 80 | 78 |
| 81 DISALLOW_COPY_AND_ASSIGN(ChromeFindRequestManagerTest); | 79 DISALLOW_COPY_AND_ASSIGN(ChromeFindRequestManagerTest); |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 | 82 |
| 85 // Tests searching in a full-page PDF. | 83 // Tests searching in a full-page PDF. |
| 86 IN_PROC_BROWSER_TEST_F(ChromeFindRequestManagerTest, FindInPDF) { | 84 IN_PROC_BROWSER_TEST_F(ChromeFindRequestManagerTest, FindInPDF) { |
| 87 LoadAndWait("/find_in_pdf_page.pdf"); | 85 LoadAndWait("/find_in_pdf_page.pdf"); |
| 88 ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(contents())); | 86 pdf_extension_test_util::EnsurePDFHasLoaded(contents()); |
| 89 | 87 |
| 90 blink::WebFindOptions options; | 88 blink::WebFindOptions options; |
| 91 Find("result", options); | 89 Find("result", options); |
| 92 options.find_next = true; | 90 options.find_next = true; |
| 93 Find("result", options); | 91 Find("result", options); |
| 94 Find("result", options); | 92 Find("result", options); |
| 95 delegate()->WaitForFinalReply(); | 93 delegate()->WaitForFinalReply(); |
| 96 | 94 |
| 97 FindResults results = delegate()->GetFindResults(); | 95 FindResults results = delegate()->GetFindResults(); |
| 98 EXPECT_EQ(last_request_id(), results.request_id); | 96 EXPECT_EQ(last_request_id(), results.request_id); |
| 99 EXPECT_EQ(5, results.number_of_matches); | 97 EXPECT_EQ(5, results.number_of_matches); |
| 100 EXPECT_EQ(3, results.active_match_ordinal); | 98 EXPECT_EQ(3, results.active_match_ordinal); |
| 101 } | 99 } |
| 102 | 100 |
| 103 // Tests searching in a page with embedded PDFs. Note that this test, the | |
| 104 // FindInPDF test, and the find tests in web_view_browsertest.cc ensure that | |
| 105 // find-in-page works across GuestViews. | |
| 106 // | |
| 107 // TODO(paulmeyer): Note that this is left disabled for now since | |
| 108 // EnsurePDFHasLoaded() currently does not work for embedded PDFs. This will be | |
| 109 // fixed and enabled in a subsequent patch. | |
| 110 IN_PROC_BROWSER_TEST_F(ChromeFindRequestManagerTest, | |
| 111 DISABLED_FindInEmbeddedPDFs) { | |
| 112 LoadAndWait("/find_in_embedded_pdf_page.html"); | |
| 113 ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(contents())); | |
| 114 | |
| 115 blink::WebFindOptions options; | |
| 116 Find("result", options); | |
| 117 options.find_next = true; | |
| 118 options.forward = false; | |
| 119 Find("result", options); | |
| 120 Find("result", options); | |
| 121 Find("result", options); | |
| 122 delegate()->WaitForFinalReply(); | |
| 123 | |
| 124 FindResults results = delegate()->GetFindResults(); | |
| 125 EXPECT_EQ(last_request_id(), results.request_id); | |
| 126 EXPECT_EQ(13, results.number_of_matches); | |
| 127 EXPECT_EQ(11, results.active_match_ordinal); | |
| 128 } | |
| 129 | |
| 130 } // namespace content | 101 } // namespace content |
| OLD | NEW |