| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/browser.h" | 6 #include "chrome/browser/browser.h" |
| 7 #include "chrome/browser/browser_window.h" | 7 #include "chrome/browser/browser_window.h" |
| 8 #include "chrome/browser/find_bar_controller.h" | 8 #include "chrome/browser/find_bar_controller.h" |
| 9 #include "chrome/browser/find_notification_details.h" | 9 #include "chrome/browser/find_notification_details.h" |
| 10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
| 11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents_view.h" | 12 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 13 #include "chrome/browser/views/find_bar_win.h" | 13 #include "chrome/browser/views/find_bar_host.h" |
| 14 #include "chrome/common/notification_service.h" | 14 #include "chrome/common/notification_service.h" |
| 15 #include "chrome/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
| 16 #include "chrome/test/ui_test_utils.h" | 16 #include "chrome/test/ui_test_utils.h" |
| 17 #include "views/focus/focus_manager.h" | 17 #include "views/focus/focus_manager.h" |
| 18 | 18 |
| 19 const std::wstring kSimplePage = L"404_is_enough_for_us.html"; | 19 const std::wstring kSimplePage = L"404_is_enough_for_us.html"; |
| 20 const std::wstring kFramePage = L"files/find_in_page/frames.html"; | 20 const std::wstring kFramePage = L"files/find_in_page/frames.html"; |
| 21 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; | 21 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; |
| 22 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; | 22 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; |
| 23 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; | 23 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 429 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 430 DISABLED_FindDisappearOnNavigate) { | 430 DISABLED_FindDisappearOnNavigate) { |
| 431 HTTPTestServer* server = StartHTTPServer(); | 431 HTTPTestServer* server = StartHTTPServer(); |
| 432 | 432 |
| 433 // First we navigate to our special focus tracking page. | 433 // First we navigate to our special focus tracking page. |
| 434 GURL url = server->TestServerPageW(kSimplePage); | 434 GURL url = server->TestServerPageW(kSimplePage); |
| 435 GURL url2 = server->TestServerPageW(kFramePage); | 435 GURL url2 = server->TestServerPageW(kFramePage); |
| 436 ui_test_utils::NavigateToURL(browser(), url); | 436 ui_test_utils::NavigateToURL(browser(), url); |
| 437 | 437 |
| 438 // Open the Find window with animations disabled. | 438 // Open the Find window with animations disabled. |
| 439 FindBarWin::disable_animations_during_testing_ = true; | 439 FindBarHost::disable_animations_during_testing_ = true; |
| 440 browser()->ShowFindBar(); | 440 browser()->ShowFindBar(); |
| 441 | 441 |
| 442 gfx::Point position; | 442 gfx::Point position; |
| 443 bool fully_visible = false; | 443 bool fully_visible = false; |
| 444 | 444 |
| 445 // Make sure it is open. | 445 // Make sure it is open. |
| 446 GetFindBarWindowInfo(&position, &fully_visible); | 446 GetFindBarWindowInfo(&position, &fully_visible); |
| 447 EXPECT_TRUE(fully_visible); | 447 EXPECT_TRUE(fully_visible); |
| 448 | 448 |
| 449 // Reload the tab and make sure Find window doesn't go away. | 449 // Reload the tab and make sure Find window doesn't go away. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 463 // when a New Tab is opened. | 463 // when a New Tab is opened. |
| 464 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 464 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 465 FindDisappearOnNewTabAndHistory) { | 465 FindDisappearOnNewTabAndHistory) { |
| 466 HTTPTestServer* server = StartHTTPServer(); | 466 HTTPTestServer* server = StartHTTPServer(); |
| 467 | 467 |
| 468 // First we navigate to our special focus tracking page. | 468 // First we navigate to our special focus tracking page. |
| 469 GURL url = server->TestServerPageW(kSimplePage); | 469 GURL url = server->TestServerPageW(kSimplePage); |
| 470 ui_test_utils::NavigateToURL(browser(), url); | 470 ui_test_utils::NavigateToURL(browser(), url); |
| 471 | 471 |
| 472 // Open the Find window with animations disabled. | 472 // Open the Find window with animations disabled. |
| 473 FindBarWin::disable_animations_during_testing_ = true; | 473 FindBarHost::disable_animations_during_testing_ = true; |
| 474 browser()->ShowFindBar(); | 474 browser()->ShowFindBar(); |
| 475 | 475 |
| 476 gfx::Point position; | 476 gfx::Point position; |
| 477 bool fully_visible = false; | 477 bool fully_visible = false; |
| 478 | 478 |
| 479 // Make sure it is open. | 479 // Make sure it is open. |
| 480 GetFindBarWindowInfo(&position, &fully_visible); | 480 GetFindBarWindowInfo(&position, &fully_visible); |
| 481 EXPECT_TRUE(fully_visible); | 481 EXPECT_TRUE(fully_visible); |
| 482 | 482 |
| 483 // Open another tab (tab B). | 483 // Open another tab (tab B). |
| (...skipping 21 matching lines...) Expand all Loading... |
| 505 // Make sure Find box moves out of the way if it is obscuring the active match. | 505 // Make sure Find box moves out of the way if it is obscuring the active match. |
| 506 // Flaky, see http://crbug.com/16447. | 506 // Flaky, see http://crbug.com/16447. |
| 507 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 507 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 508 DISABLED_FindMovesWhenObscuring) { | 508 DISABLED_FindMovesWhenObscuring) { |
| 509 HTTPTestServer* server = StartHTTPServer(); | 509 HTTPTestServer* server = StartHTTPServer(); |
| 510 | 510 |
| 511 GURL url = server->TestServerPageW(kMoveIfOver); | 511 GURL url = server->TestServerPageW(kMoveIfOver); |
| 512 ui_test_utils::NavigateToURL(browser(), url); | 512 ui_test_utils::NavigateToURL(browser(), url); |
| 513 | 513 |
| 514 // Open the Find window with animations disabled. | 514 // Open the Find window with animations disabled. |
| 515 FindBarWin::disable_animations_during_testing_ = true; | 515 FindBarHost::disable_animations_during_testing_ = true; |
| 516 browser()->ShowFindBar(); | 516 browser()->ShowFindBar(); |
| 517 | 517 |
| 518 gfx::Point start_position; | 518 gfx::Point start_position; |
| 519 gfx::Point position; | 519 gfx::Point position; |
| 520 bool fully_visible = false; | 520 bool fully_visible = false; |
| 521 | 521 |
| 522 // Make sure it is open. | 522 // Make sure it is open. |
| 523 GetFindBarWindowInfo(&start_position, &fully_visible); | 523 GetFindBarWindowInfo(&start_position, &fully_visible); |
| 524 EXPECT_TRUE(fully_visible); | 524 EXPECT_TRUE(fully_visible); |
| 525 | 525 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 // Make sure Find box does not become UI-inactive when no text is in the box as | 615 // Make sure Find box does not become UI-inactive when no text is in the box as |
| 616 // we switch to a tab contents with an empty find string. See issue 13570. | 616 // we switch to a tab contents with an empty find string. See issue 13570. |
| 617 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) { | 617 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) { |
| 618 HTTPTestServer* server = StartHTTPServer(); | 618 HTTPTestServer* server = StartHTTPServer(); |
| 619 | 619 |
| 620 // First we navigate to any page. | 620 // First we navigate to any page. |
| 621 GURL url = server->TestServerPageW(kSimplePage); | 621 GURL url = server->TestServerPageW(kSimplePage); |
| 622 ui_test_utils::NavigateToURL(browser(), url); | 622 ui_test_utils::NavigateToURL(browser(), url); |
| 623 | 623 |
| 624 // Open the Find window with animations disabled. | 624 // Open the Find window with animations disabled. |
| 625 FindBarWin::disable_animations_during_testing_ = true; | 625 FindBarHost::disable_animations_during_testing_ = true; |
| 626 browser()->ShowFindBar(); | 626 browser()->ShowFindBar(); |
| 627 | 627 |
| 628 // Simulate a user clearing the search string. Ideally, we should be | 628 // Simulate a user clearing the search string. Ideally, we should be |
| 629 // simulating keypresses here for searching for something and pressing | 629 // simulating keypresses here for searching for something and pressing |
| 630 // backspace, but that's been proven flaky in the past, so we go straight to | 630 // backspace, but that's been proven flaky in the past, so we go straight to |
| 631 // tab_contents. | 631 // tab_contents. |
| 632 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 632 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 633 // Stop the (non-existing) find operation, and clear the selection (which | 633 // Stop the (non-existing) find operation, and clear the selection (which |
| 634 // signals the UI is still active). | 634 // signals the UI is still active). |
| 635 tab_contents->StopFinding(true); | 635 tab_contents->StopFinding(true); |
| 636 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI | 636 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI |
| 637 // still responds to browser window resizing. | 637 // still responds to browser window resizing. |
| 638 ASSERT_TRUE(tab_contents->find_ui_active()); | 638 ASSERT_TRUE(tab_contents->find_ui_active()); |
| 639 } | 639 } |
| OLD | NEW |