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 1534 matching lines...) Loading... |
1545 | 1545 |
1546 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); | 1546 EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); |
1547 WebContents* web_contents_incognito = | 1547 WebContents* web_contents_incognito = |
1548 browser_incognito->tab_strip_model()->GetActiveWebContents(); | 1548 browser_incognito->tab_strip_model()->GetActiveWebContents(); |
1549 ui_test_utils::FindInPageNotificationObserver observer( | 1549 ui_test_utils::FindInPageNotificationObserver observer( |
1550 web_contents_incognito); | 1550 web_contents_incognito); |
1551 observer.Wait(); | 1551 observer.Wait(); |
1552 EXPECT_EQ(ASCIIToUTF16("bar"), | 1552 EXPECT_EQ(ASCIIToUTF16("bar"), |
1553 GetFindBarTextForBrowser(browser_incognito)); | 1553 GetFindBarTextForBrowser(browser_incognito)); |
1554 } | 1554 } |
| 1555 |
| 1556 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 1557 FindboxDisappearAfterReloadBackFromNewTab) { |
| 1558 FindBar* find_bar = browser()->GetFindBarController()->find_bar(); |
| 1559 if (find_bar->HasGlobalFindPasteboard()) |
| 1560 return; |
| 1561 |
| 1562 // First we navigate to any page. |
| 1563 GURL url = GetURL(kSimple); |
| 1564 gfx::Point position; |
| 1565 bool fully_visible = false; |
| 1566 ui_test_utils::NavigateToURL(browser(), url); |
| 1567 |
| 1568 // Search for the word "page". |
| 1569 int ordinal = 0; |
| 1570 WebContents* web_contents_1 = |
| 1571 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1572 EXPECT_EQ( |
| 1573 1, FindInPageWchar(web_contents_1, L"page", kFwd, kIgnoreCase, &ordinal)); |
| 1574 |
| 1575 // Open the Find box. |
| 1576 EnsureFindBoxOpen(); |
| 1577 |
| 1578 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); |
| 1579 EXPECT_EQ(ASCIIToUTF16("1 of 1"), |
| 1580 GetFindBarMatchCountTextForBrowser(browser())); |
| 1581 |
| 1582 content::WindowedNotificationObserver observer( |
| 1583 content::NOTIFICATION_LOAD_STOP, |
| 1584 content::Source<NavigationController>(&browser() |
| 1585 ->tab_strip_model() |
| 1586 ->GetActiveWebContents() |
| 1587 ->GetController())); |
| 1588 |
| 1589 chrome::Reload(browser(), CURRENT_TAB); |
| 1590 |
| 1591 // Now create a second tab and load new page. |
| 1592 chrome::AddTabAt(browser(), GURL(), -1, true); |
| 1593 GURL url2 = GetURL(kFramePage); |
| 1594 ui_test_utils::NavigateToURL(browser(), url2); |
| 1595 WebContents* web_contents_2 = |
| 1596 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1597 EXPECT_NE(web_contents_1, web_contents_2); |
| 1598 |
| 1599 observer.Wait(); |
| 1600 // Go back to the first tab |
| 1601 browser()->tab_strip_model()->ActivateTabAt(0, false); |
| 1602 |
| 1603 // Make sure Find box is closed. |
| 1604 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
| 1605 EXPECT_FALSE(fully_visible); |
| 1606 } |
OLD | NEW |