OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/tabs/tab_strip_model.h" | 9 #include "chrome/browser/tabs/tab_strip_model.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 | 832 |
833 // Find "Default". | 833 // Find "Default". |
834 int ordinal = 0; | 834 int ordinal = 0; |
835 TabContentsWrapper* tab1 = browser()->GetSelectedTabContentsWrapper(); | 835 TabContentsWrapper* tab1 = browser()->GetSelectedTabContentsWrapper(); |
836 EXPECT_EQ(1, FindInPageWchar(tab1, L"Default", kFwd, kIgnoreCase, &ordinal)); | 836 EXPECT_EQ(1, FindInPageWchar(tab1, L"Default", kFwd, kIgnoreCase, &ordinal)); |
837 | 837 |
838 // Create a second tab. | 838 // Create a second tab. |
839 // For some reason we can't use AddSelectedTabWithURL here on ChromeOS. It | 839 // For some reason we can't use AddSelectedTabWithURL here on ChromeOS. It |
840 // could be some delicate assumption about the tab starting off unselected or | 840 // could be some delicate assumption about the tab starting off unselected or |
841 // something relating to user gesture. | 841 // something relating to user gesture. |
842 browser::NavigateParams params(browser(), url, PageTransition::TYPED); | 842 browser()->AddBlankTab(true); |
843 params.disposition = NEW_BACKGROUND_TAB; | 843 ui_test_utils::NavigateToURL(browser(), url); |
844 params.tabstrip_add_types = TabStripModel::ADD_NONE; | |
845 browser::Navigate(¶ms); | |
846 browser()->ActivateTabAt(1, false); | |
847 TabContentsWrapper* tab2 = browser()->GetSelectedTabContentsWrapper(); | 844 TabContentsWrapper* tab2 = browser()->GetSelectedTabContentsWrapper(); |
848 EXPECT_NE(tab1, tab2); | 845 EXPECT_NE(tab1, tab2); |
849 | 846 |
850 // Find "given". | 847 // Find "given". |
851 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal); | 848 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal); |
852 | 849 |
853 // Switch back to first tab. | 850 // Switch back to first tab. |
854 browser()->ActivateTabAt(0, false); | 851 browser()->ActivateTabAt(0, false); |
855 browser()->GetFindBarController()->EndFindSession( | 852 browser()->GetFindBarController()->EndFindSession( |
856 FindBarController::kKeepSelection); | 853 FindBarController::kKeepSelection); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 // Open the Find box. | 953 // Open the Find box. |
957 EnsureFindBoxOpen(); | 954 EnsureFindBoxOpen(); |
958 | 955 |
959 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); | 956 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarText()); |
960 | 957 |
961 // Close the Find box. | 958 // Close the Find box. |
962 browser()->GetFindBarController()->EndFindSession( | 959 browser()->GetFindBarController()->EndFindSession( |
963 FindBarController::kKeepSelection); | 960 FindBarController::kKeepSelection); |
964 | 961 |
965 // Now create a second tab and load the same page. | 962 // Now create a second tab and load the same page. |
966 browser::NavigateParams params(browser(), url, PageTransition::TYPED); | 963 browser()->AddBlankTab(true); |
967 params.disposition = NEW_BACKGROUND_TAB; | 964 ui_test_utils::NavigateToURL(browser(), url); |
968 params.tabstrip_add_types = TabStripModel::ADD_NONE; | |
969 browser::Navigate(¶ms); | |
970 browser()->ActivateTabAt(1, false); | |
971 TabContentsWrapper* tab2 = browser()->GetSelectedTabContentsWrapper(); | 965 TabContentsWrapper* tab2 = browser()->GetSelectedTabContentsWrapper(); |
972 EXPECT_NE(tab1, tab2); | 966 EXPECT_NE(tab1, tab2); |
973 | 967 |
974 // Search for the word "text". | 968 // Search for the word "text". |
975 FindInPageWchar(tab2, L"text", kFwd, kIgnoreCase, &ordinal); | 969 FindInPageWchar(tab2, L"text", kFwd, kIgnoreCase, &ordinal); |
976 | 970 |
977 // Go back to the first tab and make sure we have NOT switched the prepopulate | 971 // Go back to the first tab and make sure we have NOT switched the prepopulate |
978 // text to "text". | 972 // text to "text". |
979 browser()->ActivateTabAt(0, false); | 973 browser()->ActivateTabAt(0, false); |
980 | 974 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 | 1073 |
1080 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); | 1074 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); |
1081 int ordinal = 0; | 1075 int ordinal = 0; |
1082 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); | 1076 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); |
1083 EXPECT_EQ(ordinal, 1); | 1077 EXPECT_EQ(ordinal, 1); |
1084 | 1078 |
1085 // End the find session, click on the link. | 1079 // End the find session, click on the link. |
1086 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); | 1080 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); |
1087 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 1081 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
1088 } | 1082 } |
OLD | NEW |