| 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 browser()->tab_strip_model()->GetActiveWebContents()); | 78 browser()->tab_strip_model()->GetActiveWebContents()); |
| 79 ui_test_utils::WindowedNotificationObserverWithDetails | 79 ui_test_utils::WindowedNotificationObserverWithDetails |
| 80 <FindNotificationDetails> observer( | 80 <FindNotificationDetails> observer( |
| 81 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, source); | 81 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, source); |
| 82 observer.Wait(); | 82 observer.Wait(); |
| 83 FindNotificationDetails details; | 83 FindNotificationDetails details; |
| 84 EXPECT_TRUE(observer.GetDetailsFor(source.map_key(), &details)); | 84 EXPECT_TRUE(observer.GetDetailsFor(source.map_key(), &details)); |
| 85 return details; | 85 return details; |
| 86 } | 86 } |
| 87 | 87 |
| 88 FindNotificationDetails WaitForFinalFindResult() { |
| 89 while (true) { |
| 90 auto details = WaitForFindResult(); |
| 91 if (details.final_update()) |
| 92 return details; |
| 93 } |
| 94 } |
| 95 |
| 88 private: | 96 private: |
| 89 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); | 97 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); |
| 90 }; | 98 }; |
| 91 | 99 |
| 92 // Flaky because the test server fails to start? See: http://crbug.com/96594. | 100 // Flaky because the test server fails to start? See: http://crbug.com/96594. |
| 93 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { | 101 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { |
| 94 ASSERT_TRUE(embedded_test_server()->Start()); | 102 ASSERT_TRUE(embedded_test_server()->Start()); |
| 95 | 103 |
| 96 // First we navigate to our test page (tab A). | 104 // First we navigate to our test page (tab A). |
| 97 GURL url = embedded_test_server()->GetURL(kSimplePage); | 105 GURL url = embedded_test_server()->GetURL(kSimplePage); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 ASSERT_GE(match_count, 3); | 184 ASSERT_GE(match_count, 3); |
| 177 // Avoid GetViewByID on BrowserView; the find bar is outside its hierarchy. | 185 // Avoid GetViewByID on BrowserView; the find bar is outside its hierarchy. |
| 178 FindBarView* find_bar_view = GetFindBarView(); | 186 FindBarView* find_bar_view = GetFindBarView(); |
| 179 views::View* next_button = | 187 views::View* next_button = |
| 180 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON); | 188 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON); |
| 181 views::View* previous_button = | 189 views::View* previous_button = |
| 182 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON); | 190 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON); |
| 183 | 191 |
| 184 // Clicking the next and previous buttons should not alter the focused view. | 192 // Clicking the next and previous buttons should not alter the focused view. |
| 185 ClickOnView(next_button); | 193 ClickOnView(next_button); |
| 186 EXPECT_EQ(2, WaitForFindResult().active_match_ordinal()); | 194 EXPECT_EQ(2, WaitForFinalFindResult().active_match_ordinal()); |
| 187 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 195 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 188 ClickOnView(previous_button); | 196 ClickOnView(previous_button); |
| 189 EXPECT_EQ(1, WaitForFindResult().active_match_ordinal()); | 197 EXPECT_EQ(1, WaitForFinalFindResult().active_match_ordinal()); |
| 190 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 198 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 191 | 199 |
| 192 // Tapping the next and previous buttons should not alter the focused view. | 200 // Tapping the next and previous buttons should not alter the focused view. |
| 193 TapOnView(next_button); | 201 TapOnView(next_button); |
| 194 EXPECT_EQ(2, WaitForFindResult().active_match_ordinal()); | 202 EXPECT_EQ(2, WaitForFinalFindResult().active_match_ordinal()); |
| 195 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 203 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 196 TapOnView(previous_button); | 204 TapOnView(previous_button); |
| 197 EXPECT_EQ(1, WaitForFindResult().active_match_ordinal()); | 205 EXPECT_EQ(1, WaitForFinalFindResult().active_match_ordinal()); |
| 198 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 206 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 199 | 207 |
| 200 // The same should be true even when the previous button is focused. | 208 // The same should be true even when the previous button is focused. |
| 201 previous_button->RequestFocus(); | 209 previous_button->RequestFocus(); |
| 202 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); | 210 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); |
| 203 ClickOnView(next_button); | 211 ClickOnView(next_button); |
| 204 EXPECT_EQ(2, WaitForFindResult().active_match_ordinal()); | 212 EXPECT_EQ(2, WaitForFinalFindResult().active_match_ordinal()); |
| 205 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); | 213 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); |
| 206 TapOnView(next_button); | 214 TapOnView(next_button); |
| 207 EXPECT_EQ(3, WaitForFindResult().active_match_ordinal()); | 215 EXPECT_EQ(3, WaitForFinalFindResult().active_match_ordinal()); |
| 208 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); | 216 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON)); |
| 209 } | 217 } |
| 210 | 218 |
| 211 IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) { | 219 IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) { |
| 212 ASSERT_TRUE(embedded_test_server()->Start()); | 220 ASSERT_TRUE(embedded_test_server()->Start()); |
| 213 // Make sure Chrome is in the foreground, otherwise sending input | 221 // Make sure Chrome is in the foreground, otherwise sending input |
| 214 // won't do anything and the test will hang. | 222 // won't do anything and the test will hang. |
| 215 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 223 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 216 // First we navigate to any page. | 224 // First we navigate to any page. |
| 217 ui_test_utils::NavigateToURL(browser(), | 225 ui_test_utils::NavigateToURL(browser(), |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 539 |
| 532 ui_test_utils::UrlLoadObserver observer( | 540 ui_test_utils::UrlLoadObserver observer( |
| 533 GURL("about:blank"), content::NotificationService::AllSources()); | 541 GURL("about:blank"), content::NotificationService::AllSources()); |
| 534 | 542 |
| 535 // Send Ctrl-Enter, should cause navigation to about:blank. | 543 // Send Ctrl-Enter, should cause navigation to about:blank. |
| 536 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 544 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 537 browser(), ui::VKEY_RETURN, true, false, false, false)); | 545 browser(), ui::VKEY_RETURN, true, false, false, false)); |
| 538 | 546 |
| 539 observer.Wait(); | 547 observer.Wait(); |
| 540 } | 548 } |
| OLD | NEW |