Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: chrome/browser/ui/find_bar/find_bar_host_browsertest.cc

Issue 532143002: Close the find bar on reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per reviewser comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
Finnur 2014/09/04 12:45:10 Should probably be named FindDisappearOnNavigateAn
Deepak 2014/09/04 13:18:15 Done.
843 // First we navigate to our special focus tracking page. 843 // First we navigate to our special focus tracking page.
844 GURL url = GetURL(kSimple); 844 GURL url = GetURL(kSimple);
845 GURL url2 = GetURL(kFramePage); 845 GURL url2 = GetURL(kFramePage);
846 ui_test_utils::NavigateToURL(browser(), url); 846 ui_test_utils::NavigateToURL(browser(), url);
847 847
848 chrome::ShowFindBar(browser()); 848 chrome::ShowFindBar(browser());
849 849
850 gfx::Point position; 850 gfx::Point position;
851 bool fully_visible = false; 851 bool fully_visible = false;
852 852
853 // Make sure it is open. 853 // Make sure it is open.
854 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 854 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
855 EXPECT_TRUE(fully_visible); 855 EXPECT_TRUE(fully_visible);
856 856
857 // Reload the tab and make sure Find window doesn't go away. 857 // Reload and make sure the Find window goes away.
858 content::WindowedNotificationObserver observer( 858 content::WindowedNotificationObserver observer(
859 content::NOTIFICATION_LOAD_STOP, 859 content::NOTIFICATION_LOAD_STOP,
860 content::Source<NavigationController>( 860 content::Source<NavigationController>(
861 &browser()->tab_strip_model()->GetActiveWebContents()-> 861 &browser()->tab_strip_model()->GetActiveWebContents()->
862 GetController())); 862 GetController()));
863 chrome::Reload(browser(), CURRENT_TAB); 863 chrome::Reload(browser(), CURRENT_TAB);
864 observer.Wait(); 864 observer.Wait();
865 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
866 EXPECT_FALSE(fully_visible);
Finnur 2014/09/04 12:45:10 With this change, I'm not sure the added test (at
Deepak 2014/09/04 13:18:15 Acknowledged.
865 867
868 // Opening Findbar again.
869 chrome::ShowFindBar(browser());
870
871 // Make sure it is open.
866 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 872 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
867 EXPECT_TRUE(fully_visible); 873 EXPECT_TRUE(fully_visible);
868 874
869 // Navigate and make sure the Find window goes away. 875 // Navigate and make sure the Find window goes away.
870 ui_test_utils::NavigateToURL(browser(), url2); 876 ui_test_utils::NavigateToURL(browser(), url2);
871 877
872 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 878 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
873 EXPECT_FALSE(fully_visible); 879 EXPECT_FALSE(fully_visible);
874 } 880 }
875 881
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 1551
1546 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); 1552 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT));
1547 WebContents* web_contents_incognito = 1553 WebContents* web_contents_incognito =
1548 browser_incognito->tab_strip_model()->GetActiveWebContents(); 1554 browser_incognito->tab_strip_model()->GetActiveWebContents();
1549 ui_test_utils::FindInPageNotificationObserver observer( 1555 ui_test_utils::FindInPageNotificationObserver observer(
1550 web_contents_incognito); 1556 web_contents_incognito);
1551 observer.Wait(); 1557 observer.Wait();
1552 EXPECT_EQ(ASCIIToUTF16("bar"), 1558 EXPECT_EQ(ASCIIToUTF16("bar"),
1553 GetFindBarTextForBrowser(browser_incognito)); 1559 GetFindBarTextForBrowser(browser_incognito));
1554 } 1560 }
1561
1562 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnReload) {
1563 FindBar* find_bar = browser()->GetFindBarController()->find_bar();
1564 if (find_bar->HasGlobalFindPasteboard())
1565 return;
Finnur 2014/09/04 12:45:10 Why is this needed if it is not needed in FindDisa
Deepak 2014/09/04 13:18:15 Acknowledged.
1566
1567 // First we navigate to any page.
1568 GURL url = GetURL(kSimple);
1569 ui_test_utils::NavigateToURL(browser(), url);
1570
1571 // Search for the word "page".
1572 int ordinal = 0;
1573 gfx::Point position;
1574 bool fully_visible = false;
1575
1576 WebContents* web_contents_1 =
1577 browser()->tab_strip_model()->GetActiveWebContents();
1578 EXPECT_EQ(
1579 1, FindInPageWchar(web_contents_1, L"page", kFwd, kIgnoreCase, &ordinal));
1580
1581 // Open the Find box.
1582 EnsureFindBoxOpen();
1583
1584 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText());
1585 EXPECT_EQ(ASCIIToUTF16("1 of 1"),
1586 GetFindBarMatchCountTextForBrowser(browser()));
1587
1588 content::WindowedNotificationObserver observer(
1589 content::NOTIFICATION_LOAD_STOP,
1590 content::Source<NavigationController>(&browser()
1591 ->tab_strip_model()
1592 ->GetActiveWebContents()
1593 ->GetController()));
1594 // Reloading the tab.
1595 chrome::Reload(browser(), CURRENT_TAB);
1596 observer.Wait();
1597 // Make sure Find box is closed.
1598 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
1599 EXPECT_FALSE(fully_visible);
1600 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698