| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/browser_window.h" | 8 #include "chrome/browser/browser_window.h" |
| 9 #include "chrome/browser/find_bar.h" |
| 9 #include "chrome/browser/find_bar_controller.h" | 10 #include "chrome/browser/find_bar_controller.h" |
| 10 #include "chrome/browser/find_notification_details.h" | 11 #include "chrome/browser/find_notification_details.h" |
| 11 #include "chrome/browser/renderer_host/render_view_host.h" | 12 #include "chrome/browser/renderer_host/render_view_host.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents_view.h" | 14 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 14 #include "chrome/browser/views/find_bar_host.h" | |
| 15 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
| 16 #include "chrome/test/in_process_browser_test.h" | 16 #include "chrome/test/in_process_browser_test.h" |
| 17 #include "chrome/test/ui_test_utils.h" | 17 #include "chrome/test/ui_test_utils.h" |
| 18 | 18 |
| 19 #if defined(TOOLKIT_VIEWS) | 19 #if defined(TOOLKIT_VIEWS) |
| 20 #include "chrome/browser/views/find_bar_host.h" |
| 20 #include "views/focus/focus_manager.h" | 21 #include "views/focus/focus_manager.h" |
| 21 #elif defined(TOOLKIT_GTK) | 22 #elif defined(TOOLKIT_GTK) |
| 22 #include "chrome/browser/gtk/slide_animator_gtk.h" | 23 #include "chrome/browser/gtk/slide_animator_gtk.h" |
| 24 #elif defined(OS_MACOSX) |
| 25 #include "chrome/browser/cocoa/find_bar_bridge.h" |
| 23 #endif | 26 #endif |
| 24 | 27 |
| 25 const std::wstring kSimplePage = L"404_is_enough_for_us.html"; | 28 const std::wstring kSimplePage = L"404_is_enough_for_us.html"; |
| 26 const std::wstring kFramePage = L"files/find_in_page/frames.html"; | 29 const std::wstring kFramePage = L"files/find_in_page/frames.html"; |
| 27 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; | 30 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; |
| 28 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; | 31 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; |
| 29 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; | 32 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; |
| 30 const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; | 33 const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; |
| 31 const std::wstring kEndState = L"files/find_in_page/end_state.html"; | 34 const std::wstring kEndState = L"files/find_in_page/end_state.html"; |
| 32 const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; | 35 const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 47 | 50 |
| 48 class FindInPageControllerTest : public InProcessBrowserTest { | 51 class FindInPageControllerTest : public InProcessBrowserTest { |
| 49 public: | 52 public: |
| 50 FindInPageControllerTest() { | 53 FindInPageControllerTest() { |
| 51 EnableDOMAutomation(); | 54 EnableDOMAutomation(); |
| 52 | 55 |
| 53 #if defined(TOOLKIT_VIEWS) | 56 #if defined(TOOLKIT_VIEWS) |
| 54 DropdownBarHost::disable_animations_during_testing_ = true; | 57 DropdownBarHost::disable_animations_during_testing_ = true; |
| 55 #elif defined(TOOLKIT_GTK) | 58 #elif defined(TOOLKIT_GTK) |
| 56 SlideAnimatorGtk::SetAnimationsForTesting(false); | 59 SlideAnimatorGtk::SetAnimationsForTesting(false); |
| 60 #elif defined(OS_MACOSX) |
| 61 FindBarBridge::disable_animations_during_testing_ = true; |
| 57 #endif | 62 #endif |
| 58 | 63 |
| 59 } | 64 } |
| 60 | 65 |
| 61 protected: | 66 protected: |
| 62 bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) { | 67 bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) { |
| 63 FindBarTesting* find_bar = | 68 FindBarTesting* find_bar = |
| 64 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); | 69 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); |
| 65 return find_bar->GetFindBarWindowInfo(position, fully_visible); | 70 return find_bar->GetFindBarWindowInfo(position, fully_visible); |
| 66 } | 71 } |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) { | 493 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) { |
| 489 HTTPTestServer* server = StartHTTPServer(); | 494 HTTPTestServer* server = StartHTTPServer(); |
| 490 | 495 |
| 491 // First we navigate to our special focus tracking page. | 496 // First we navigate to our special focus tracking page. |
| 492 GURL url = server->TestServerPageW(kSimplePage); | 497 GURL url = server->TestServerPageW(kSimplePage); |
| 493 GURL url2 = server->TestServerPageW(kFramePage); | 498 GURL url2 = server->TestServerPageW(kFramePage); |
| 494 ui_test_utils::NavigateToURL(browser(), url); | 499 ui_test_utils::NavigateToURL(browser(), url); |
| 495 | 500 |
| 496 browser()->ShowFindBar(); | 501 browser()->ShowFindBar(); |
| 497 | 502 |
| 503 gfx::Point position; |
| 498 bool fully_visible = false; | 504 bool fully_visible = false; |
| 499 | 505 |
| 500 // Make sure it is open. | 506 // Make sure it is open. |
| 501 EXPECT_TRUE(GetFindBarWindowInfo(NULL, &fully_visible)); | 507 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 502 EXPECT_TRUE(fully_visible); | 508 EXPECT_TRUE(fully_visible); |
| 503 | 509 |
| 504 // Reload the tab and make sure Find window doesn't go away. | 510 // Reload the tab and make sure Find window doesn't go away. |
| 505 browser()->Reload(); | 511 browser()->Reload(); |
| 506 ui_test_utils::WaitForNavigationInCurrentTab(browser()); | 512 ui_test_utils::WaitForNavigationInCurrentTab(browser()); |
| 507 | 513 |
| 508 EXPECT_TRUE(GetFindBarWindowInfo(NULL, &fully_visible)); | 514 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 509 EXPECT_TRUE(fully_visible); | 515 EXPECT_TRUE(fully_visible); |
| 510 | 516 |
| 511 // Navigate and make sure the Find window goes away. | 517 // Navigate and make sure the Find window goes away. |
| 512 ui_test_utils::NavigateToURL(browser(), url2); | 518 ui_test_utils::NavigateToURL(browser(), url2); |
| 513 | 519 |
| 514 EXPECT_TRUE(GetFindBarWindowInfo(NULL, &fully_visible)); | 520 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 515 EXPECT_FALSE(fully_visible); | 521 EXPECT_FALSE(fully_visible); |
| 516 } | 522 } |
| 517 | 523 |
| 518 // Make sure Find box disappears when History/Downloads page is opened, and | 524 // Make sure Find box disappears when History/Downloads page is opened, and |
| 519 // when a New Tab is opened. | 525 // when a New Tab is opened. |
| 520 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 526 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 521 FindDisappearOnNewTabAndHistory) { | 527 FindDisappearOnNewTabAndHistory) { |
| 522 HTTPTestServer* server = StartHTTPServer(); | 528 HTTPTestServer* server = StartHTTPServer(); |
| 523 | 529 |
| 524 // First we navigate to our special focus tracking page. | 530 // First we navigate to our special focus tracking page. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 549 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 555 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 550 EXPECT_TRUE(fully_visible); | 556 EXPECT_TRUE(fully_visible); |
| 551 | 557 |
| 552 browser()->ShowHistoryTab(); | 558 browser()->ShowHistoryTab(); |
| 553 | 559 |
| 554 // Make sure Find box is closed. | 560 // Make sure Find box is closed. |
| 555 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 561 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 556 EXPECT_FALSE(fully_visible); | 562 EXPECT_FALSE(fully_visible); |
| 557 } | 563 } |
| 558 | 564 |
| 565 // TODO(rohitrao): The FindMovesWhenObscuring test does not pass on mac. |
| 566 // http://crbug.com/22036 |
| 567 #if defined(OS_MACOSX) |
| 568 #define MAYBE_FindMovesWhenObscuring DISABLED_FindMovesWhenObscuring |
| 569 #else |
| 570 #define MAYBE_FindMovesWhenObscuring FindMovesWhenObscuring |
| 571 #endif |
| 572 |
| 559 // Make sure Find box moves out of the way if it is obscuring the active match. | 573 // Make sure Find box moves out of the way if it is obscuring the active match. |
| 560 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) { | 574 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FindMovesWhenObscuring) { |
| 561 HTTPTestServer* server = StartHTTPServer(); | 575 HTTPTestServer* server = StartHTTPServer(); |
| 562 | 576 |
| 563 GURL url = server->TestServerPageW(kMoveIfOver); | 577 GURL url = server->TestServerPageW(kMoveIfOver); |
| 564 ui_test_utils::NavigateToURL(browser(), url); | 578 ui_test_utils::NavigateToURL(browser(), url); |
| 565 | 579 |
| 566 browser()->ShowFindBar(); | 580 browser()->ShowFindBar(); |
| 567 | 581 |
| 568 // This is needed on GTK because the reposition operation is asynchronous. | 582 // This is needed on GTK because the reposition operation is asynchronous. |
| 569 MessageLoop::current()->RunAllPending(); | 583 MessageLoop::current()->RunAllPending(); |
| 570 | 584 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 | 820 |
| 807 TabContents* tab = browser()->GetSelectedTabContents(); | 821 TabContents* tab = browser()->GetSelectedTabContents(); |
| 808 int ordinal = 0; | 822 int ordinal = 0; |
| 809 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); | 823 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); |
| 810 EXPECT_EQ(ordinal, 1); | 824 EXPECT_EQ(ordinal, 1); |
| 811 | 825 |
| 812 // End the find session, click on the link. | 826 // End the find session, click on the link. |
| 813 tab->StopFinding(FindBarController::kActivateSelection); | 827 tab->StopFinding(FindBarController::kActivateSelection); |
| 814 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 828 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
| 815 } | 829 } |
| OLD | NEW |