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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 browser()->tab_strip_model()->GetActiveWebContents(); | 832 browser()->tab_strip_model()->GetActiveWebContents(); |
833 ASSERT_TRUE(NULL != web_contents); | 833 ASSERT_TRUE(NULL != web_contents); |
834 | 834 |
835 // Search for a text that exists within a link on the page. | 835 // Search for a text that exists within a link on the page. |
836 int ordinal = 0; | 836 int ordinal = 0; |
837 EXPECT_EQ(2, FindInPageWchar(web_contents, L"html ", | 837 EXPECT_EQ(2, FindInPageWchar(web_contents, L"html ", |
838 kFwd, kIgnoreCase, &ordinal)); | 838 kFwd, kIgnoreCase, &ordinal)); |
839 EXPECT_EQ(1, ordinal); | 839 EXPECT_EQ(1, ordinal); |
840 } | 840 } |
841 | 841 |
842 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) { | 842 // Verify that the find bar is hidden on reload and navigation. |
| 843 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 844 HideFindBarOnNavigateAndReload) { |
843 // First we navigate to our special focus tracking page. | 845 // First we navigate to our special focus tracking page. |
844 GURL url = GetURL(kSimple); | 846 GURL url = GetURL(kSimple); |
845 GURL url2 = GetURL(kFramePage); | 847 GURL url2 = GetURL(kFramePage); |
846 ui_test_utils::NavigateToURL(browser(), url); | 848 ui_test_utils::NavigateToURL(browser(), url); |
847 | 849 |
848 chrome::ShowFindBar(browser()); | 850 chrome::ShowFindBar(browser()); |
849 | 851 |
850 gfx::Point position; | 852 gfx::Point position; |
851 bool fully_visible = false; | 853 bool fully_visible = false; |
852 | 854 |
853 // Make sure it is open. | 855 // Make sure it is open. |
854 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 856 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
855 EXPECT_TRUE(fully_visible); | 857 EXPECT_TRUE(fully_visible); |
856 | 858 |
857 // Reload the tab and make sure Find window doesn't go away. | 859 // Reload and make sure the find window goes away. |
858 content::WindowedNotificationObserver observer( | 860 content::WindowedNotificationObserver observer( |
859 content::NOTIFICATION_LOAD_STOP, | 861 content::NOTIFICATION_LOAD_STOP, |
860 content::Source<NavigationController>( | 862 content::Source<NavigationController>( |
861 &browser()->tab_strip_model()->GetActiveWebContents()-> | 863 &browser()->tab_strip_model()->GetActiveWebContents()-> |
862 GetController())); | 864 GetController())); |
863 chrome::Reload(browser(), CURRENT_TAB); | 865 chrome::Reload(browser(), CURRENT_TAB); |
864 observer.Wait(); | 866 observer.Wait(); |
| 867 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 868 EXPECT_FALSE(fully_visible); |
865 | 869 |
| 870 // Open the find bar again. |
| 871 chrome::ShowFindBar(browser()); |
| 872 |
| 873 // Make sure it is open. |
866 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 874 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
867 EXPECT_TRUE(fully_visible); | 875 EXPECT_TRUE(fully_visible); |
868 | 876 |
869 // Navigate and make sure the Find window goes away. | 877 // Navigate and make sure the find window goes away. |
870 ui_test_utils::NavigateToURL(browser(), url2); | 878 ui_test_utils::NavigateToURL(browser(), url2); |
871 | 879 |
872 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 880 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
873 EXPECT_FALSE(fully_visible); | 881 EXPECT_FALSE(fully_visible); |
874 } | 882 } |
875 | 883 |
876 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindStayVisibleOnAnchorLoad) { | 884 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindStayVisibleOnAnchorLoad) { |
877 // First we navigate to our special focus tracking page. | 885 // First we navigate to our special focus tracking page. |
878 GURL url = GetURL(kAnchorPage); | 886 GURL url = GetURL(kAnchorPage); |
879 ui_test_utils::NavigateToURL(browser(), url); | 887 ui_test_utils::NavigateToURL(browser(), url); |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 | 1553 |
1546 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); | 1554 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); |
1547 WebContents* web_contents_incognito = | 1555 WebContents* web_contents_incognito = |
1548 browser_incognito->tab_strip_model()->GetActiveWebContents(); | 1556 browser_incognito->tab_strip_model()->GetActiveWebContents(); |
1549 ui_test_utils::FindInPageNotificationObserver observer( | 1557 ui_test_utils::FindInPageNotificationObserver observer( |
1550 web_contents_incognito); | 1558 web_contents_incognito); |
1551 observer.Wait(); | 1559 observer.Wait(); |
1552 EXPECT_EQ(ASCIIToUTF16("bar"), | 1560 EXPECT_EQ(ASCIIToUTF16("bar"), |
1553 GetFindBarTextForBrowser(browser_incognito)); | 1561 GetFindBarTextForBrowser(browser_incognito)); |
1554 } | 1562 } |
OLD | NEW |