| 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" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // Find a very long string in a large page. | 428 // Find a very long string in a large page. |
| 429 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindLongString) { | 429 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindLongString) { |
| 430 WebContents* web_contents = | 430 WebContents* web_contents = |
| 431 browser()->tab_strip_model()->GetActiveWebContents(); | 431 browser()->tab_strip_model()->GetActiveWebContents(); |
| 432 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); | 432 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); |
| 433 | 433 |
| 434 base::FilePath path = ui_test_utils::GetTestFilePath( | 434 base::FilePath path = ui_test_utils::GetTestFilePath( |
| 435 base::FilePath().AppendASCII("find_in_page"), | 435 base::FilePath().AppendASCII("find_in_page"), |
| 436 base::FilePath().AppendASCII("LongFind.txt")); | 436 base::FilePath().AppendASCII("LongFind.txt")); |
| 437 std::string query; | 437 std::string query; |
| 438 base::ReadFileToString(path, &query); | 438 { |
| 439 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 440 base::ReadFileToString(path, &query); |
| 441 } |
| 439 EXPECT_EQ(1, FindInPage16(web_contents, base::UTF8ToUTF16(query), | 442 EXPECT_EQ(1, FindInPage16(web_contents, base::UTF8ToUTF16(query), |
| 440 kFwd, kIgnoreCase, NULL)); | 443 kFwd, kIgnoreCase, NULL)); |
| 441 } | 444 } |
| 442 | 445 |
| 443 // Find a big font string in a page. | 446 // Find a big font string in a page. |
| 444 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) { | 447 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) { |
| 445 WebContents* web_contents = | 448 WebContents* web_contents = |
| 446 browser()->tab_strip_model()->GetActiveWebContents(); | 449 browser()->tab_strip_model()->GetActiveWebContents(); |
| 447 ui_test_utils::NavigateToURL(browser(), GetURL("BigText.html")); | 450 ui_test_utils::NavigateToURL(browser(), GetURL("BigText.html")); |
| 448 EXPECT_EQ(1, FindInPageASCII(web_contents, "SomeLargeString", | 451 EXPECT_EQ(1, FindInPageASCII(web_contents, "SomeLargeString", |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindWholeFileContent) { | 497 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindWholeFileContent) { |
| 495 WebContents* web_contents = | 498 WebContents* web_contents = |
| 496 browser()->tab_strip_model()->GetActiveWebContents(); | 499 browser()->tab_strip_model()->GetActiveWebContents(); |
| 497 | 500 |
| 498 base::FilePath path = ui_test_utils::GetTestFilePath( | 501 base::FilePath path = ui_test_utils::GetTestFilePath( |
| 499 base::FilePath().AppendASCII("find_in_page"), | 502 base::FilePath().AppendASCII("find_in_page"), |
| 500 base::FilePath().AppendASCII("find_test.txt")); | 503 base::FilePath().AppendASCII("find_test.txt")); |
| 501 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(path)); | 504 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(path)); |
| 502 | 505 |
| 503 std::string query; | 506 std::string query; |
| 504 base::ReadFileToString(path, &query); | 507 { |
| 508 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 509 base::ReadFileToString(path, &query); |
| 510 } |
| 505 EXPECT_EQ(1, FindInPage16(web_contents, base::UTF8ToUTF16(query), | 511 EXPECT_EQ(1, FindInPage16(web_contents, base::UTF8ToUTF16(query), |
| 506 false, false, NULL)); | 512 false, false, NULL)); |
| 507 } | 513 } |
| 508 | 514 |
| 509 // This test loads a single-frame page and makes sure the ordinal returned makes | 515 // This test loads a single-frame page and makes sure the ordinal returned makes |
| 510 // sense as we FindNext over all the items. | 516 // sense as we FindNext over all the items. |
| 511 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { | 517 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { |
| 512 // First we navigate to our page. | 518 // First we navigate to our page. |
| 513 GURL url = GetURL(kFrameData); | 519 GURL url = GetURL(kFrameData); |
| 514 ui_test_utils::NavigateToURL(browser(), url); | 520 ui_test_utils::NavigateToURL(browser(), url); |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 | 1568 |
| 1563 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); | 1569 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); |
| 1564 WebContents* web_contents_incognito = | 1570 WebContents* web_contents_incognito = |
| 1565 browser_incognito->tab_strip_model()->GetActiveWebContents(); | 1571 browser_incognito->tab_strip_model()->GetActiveWebContents(); |
| 1566 ui_test_utils::FindInPageNotificationObserver observer( | 1572 ui_test_utils::FindInPageNotificationObserver observer( |
| 1567 web_contents_incognito); | 1573 web_contents_incognito); |
| 1568 observer.Wait(); | 1574 observer.Wait(); |
| 1569 EXPECT_EQ(ASCIIToUTF16("bar"), | 1575 EXPECT_EQ(ASCIIToUTF16("bar"), |
| 1570 GetFindBarTextForBrowser(browser_incognito)); | 1576 GetFindBarTextForBrowser(browser_incognito)); |
| 1571 } | 1577 } |
| OLD | NEW |