OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/test/scoped_feature_list.h" | |
15 #include "build/build_config.h" | 14 #include "build/build_config.h" |
16 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
17 #include "chrome/browser/history/history_service_factory.h" | 16 #include "chrome/browser/history/history_service_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
23 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
24 #include "chrome/browser/ui/chrome_pages.h" | 23 #include "chrome/browser/ui/chrome_pages.h" |
25 #include "chrome/browser/ui/find_bar/find_bar.h" | 24 #include "chrome/browser/ui/find_bar/find_bar.h" |
26 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 25 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
27 #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" | 26 #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" |
28 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 27 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
29 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 28 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 29 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/browser/ui/webui/md_history_ui.h" | 30 #include "chrome/browser/ui/webui/md_history_ui.h" |
32 #include "chrome/common/chrome_features.h" | |
33 #include "chrome/common/chrome_switches.h" | |
34 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
35 #include "chrome/test/base/find_in_page_observer.h" | 32 #include "chrome/test/base/find_in_page_observer.h" |
36 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
37 #include "chrome/test/base/ui_test_utils.h" | 34 #include "chrome/test/base/ui_test_utils.h" |
38 #include "components/history/core/browser/history_service.h" | 35 #include "components/history/core/browser/history_service.h" |
39 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
40 #include "content/public/browser/download_manager.h" | 37 #include "content/public/browser/download_manager.h" |
41 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/notification_types.h" | 39 #include "content/public/browser/notification_types.h" |
43 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 | 291 |
295 for (size_t i = 0; i < urls.size(); ++i) { | 292 for (size_t i = 0; i < urls.size(); ++i) { |
296 ui_test_utils::NavigateToURL(browser(), urls[i]); | 293 ui_test_utils::NavigateToURL(browser(), urls[i]); |
297 EXPECT_EQ(1, FindInPageASCII(web_contents, "cat", | 294 EXPECT_EQ(1, FindInPageASCII(web_contents, "cat", |
298 kFwd, kIgnoreCase, NULL)); | 295 kFwd, kIgnoreCase, NULL)); |
299 EXPECT_EQ(0, FindInPageASCII(web_contents, "bat", | 296 EXPECT_EQ(0, FindInPageASCII(web_contents, "bat", |
300 kFwd, kIgnoreCase, NULL)); | 297 kFwd, kIgnoreCase, NULL)); |
301 } | 298 } |
302 } | 299 } |
303 | 300 |
304 // Verify search for text within special URLs such as chrome:history, | |
305 // chrome://downloads, data directory | |
306 #if defined(OS_MACOSX) || defined(OS_WIN) | |
307 // Disabled on Mac due to http://crbug.com/419987 | |
308 // Disabled on Win due to http://crbug.com/661013 | |
309 #define MAYBE_SearchWithinSpecialURL \ | |
310 DISABLED_SearchWithinSpecialURL | |
311 #else | |
312 #define MAYBE_SearchWithinSpecialURL \ | |
313 SearchWithinSpecialURL | |
314 #endif | |
315 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_SearchWithinSpecialURL) { | |
316 // TODO(tsergeant): Get this test working on MD History, which loads very | |
sky
2017/04/27 22:41:04
Is it not useful to try to update this test for md
Dan Beam
2017/04/28 03:17:45
i just think it's a very unclear test and isn't bu
sky
2017/04/28 17:43:54
Fair enough. Nuke it.
| |
317 // asynchronously and causes this test to fail. | |
318 base::test::ScopedFeatureList scoped_feature_list; | |
319 scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignHistory); | |
320 | |
321 WebContents* web_contents = | |
322 browser()->tab_strip_model()->GetActiveWebContents(); | |
323 | |
324 base::FilePath data_dir = | |
325 ui_test_utils::GetTestFilePath(base::FilePath(), base::FilePath()); | |
326 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(data_dir)); | |
327 EXPECT_EQ(1, FindInPageASCII(web_contents, "downloads", | |
328 kFwd, kIgnoreCase, NULL)); | |
329 | |
330 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); | |
331 | |
332 // The history page does an async request to the history service and then | |
333 // updates the renderer. So we make a query as well, and by the time it comes | |
334 // back we know the data is on its way to the renderer. | |
335 FlushHistoryService(); | |
336 | |
337 base::string16 query(data_dir.LossyDisplayName()); | |
338 EXPECT_EQ(1, | |
339 ui_test_utils::FindInPage(web_contents, query, | |
340 kFwd, kIgnoreCase, NULL, NULL)); | |
341 | |
342 GURL download_url = ui_test_utils::GetTestUrl( | |
343 base::FilePath().AppendASCII("downloads"), | |
344 base::FilePath().AppendASCII("a_zip_file.zip")); | |
345 ui_test_utils::DownloadURL(browser(), download_url); | |
346 | |
347 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); | |
348 FlushHistoryService(); | |
349 ASSERT_TRUE(content::ExecuteScript(web_contents, "Polymer.dom.flush();")); | |
350 EXPECT_EQ(1, FindInPageASCII(web_contents, download_url.spec(), | |
351 kFwd, kIgnoreCase, NULL)); | |
352 } | |
353 | |
354 // Verify search selection coordinates. The data file used is set-up such that | 301 // Verify search selection coordinates. The data file used is set-up such that |
355 // the text occurs on the same line, and we verify their positions by verifying | 302 // the text occurs on the same line, and we verify their positions by verifying |
356 // their relative positions. | 303 // their relative positions. |
357 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) { | 304 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) { |
358 const std::wstring search_string(L"\u5728\u897f\u660c\u536b\u661f\u53d1"); | 305 const std::wstring search_string(L"\u5728\u897f\u660c\u536b\u661f\u53d1"); |
359 gfx::Rect first, second, first_reverse; | 306 gfx::Rect first, second, first_reverse; |
360 WebContents* web_contents = | 307 WebContents* web_contents = |
361 browser()->tab_strip_model()->GetActiveWebContents(); | 308 browser()->tab_strip_model()->GetActiveWebContents(); |
362 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); | 309 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); |
363 ui_test_utils::FindInPage(web_contents, WideToUTF16(search_string), | 310 ui_test_utils::FindInPage(web_contents, WideToUTF16(search_string), |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1562 | 1509 |
1563 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); | 1510 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); |
1564 WebContents* web_contents_incognito = | 1511 WebContents* web_contents_incognito = |
1565 browser_incognito->tab_strip_model()->GetActiveWebContents(); | 1512 browser_incognito->tab_strip_model()->GetActiveWebContents(); |
1566 ui_test_utils::FindInPageNotificationObserver observer( | 1513 ui_test_utils::FindInPageNotificationObserver observer( |
1567 web_contents_incognito); | 1514 web_contents_incognito); |
1568 observer.Wait(); | 1515 observer.Wait(); |
1569 EXPECT_EQ(ASCIIToUTF16("bar"), | 1516 EXPECT_EQ(ASCIIToUTF16("bar"), |
1570 GetFindBarTextForBrowser(browser_incognito)); | 1517 GetFindBarTextForBrowser(browser_incognito)); |
1571 } | 1518 } |
OLD | NEW |