Chromium Code Reviews| 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/auto_reset.h" | |
| 5 #include "base/macros.h" | 6 #include "base/macros.h" |
| 6 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
| 12 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
| 13 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 14 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 15 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" |
| 17 #include "chrome/browser/ui/views/find_bar_host.h" | 18 #include "chrome/browser/ui/views/find_bar_host.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/interactive_test_utils.h" | 21 #include "chrome/test/base/interactive_test_utils.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 24 #include "net/test/embedded_test_server/embedded_test_server.h" | 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 25 #include "ui/base/clipboard/clipboard.h" | 26 #include "ui/base/clipboard/clipboard.h" |
| 27 #include "ui/base/test/ui_controls.h" | |
| 26 #include "ui/events/keycodes/keyboard_codes.h" | 28 #include "ui/events/keycodes/keyboard_codes.h" |
| 27 #include "ui/views/focus/focus_manager.h" | 29 #include "ui/views/focus/focus_manager.h" |
| 28 #include "ui/views/view.h" | 30 #include "ui/views/view.h" |
| 29 | 31 |
| 30 using base::ASCIIToUTF16; | 32 using base::ASCIIToUTF16; |
| 31 using content::WebContents; | 33 using content::WebContents; |
| 32 using ui_test_utils::IsViewFocused; | 34 using ui_test_utils::IsViewFocused; |
| 33 | 35 |
| 34 namespace { | 36 namespace { |
| 35 static const char kSimplePage[] = "/find_in_page/simple.html"; | 37 static const char kSimplePage[] = "/find_in_page/simple.html"; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 FindNotificationDetails details; | 85 FindNotificationDetails details; |
| 84 EXPECT_TRUE(observer.GetDetailsFor(source.map_key(), &details)); | 86 EXPECT_TRUE(observer.GetDetailsFor(source.map_key(), &details)); |
| 85 return details; | 87 return details; |
| 86 } | 88 } |
| 87 | 89 |
| 88 private: | 90 private: |
| 89 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); | 91 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 // Flaky because the test server fails to start? See: http://crbug.com/96594. | 94 // Flaky because the test server fails to start? See: http://crbug.com/96594. |
| 95 // TODO(msw): Remove flaky test debug logging for http://crbug.com/639350. | |
| 93 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { | 96 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { |
| 97 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers A"; | |
| 94 ASSERT_TRUE(embedded_test_server()->Start()); | 98 ASSERT_TRUE(embedded_test_server()->Start()); |
| 99 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers B"; | |
| 95 | 100 |
| 96 // First we navigate to our test page (tab A). | 101 // First we navigate to our test page (tab A). |
| 97 GURL url = embedded_test_server()->GetURL(kSimplePage); | 102 GURL url = embedded_test_server()->GetURL(kSimplePage); |
| 98 ui_test_utils::NavigateToURL(browser(), url); | 103 ui_test_utils::NavigateToURL(browser(), url); |
| 104 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers C"; | |
| 99 | 105 |
| 100 chrome::Find(browser()); | 106 chrome::Find(browser()); |
| 107 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers D"; | |
| 101 | 108 |
| 102 // Open another tab (tab B). | 109 // Open another tab (tab B). |
| 103 chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); | 110 chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); |
| 111 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers E"; | |
| 104 | 112 |
| 105 chrome::Find(browser()); | 113 chrome::Find(browser()); |
| 106 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 114 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 115 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers F"; | |
| 107 | 116 |
| 108 // Select tab A. | 117 // Select tab A. |
| 109 browser()->tab_strip_model()->ActivateTabAt(0, true); | 118 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 119 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers G"; | |
| 110 | 120 |
| 111 // Close tab B. | 121 // Close tab B. |
| 112 browser()->tab_strip_model()->CloseWebContentsAt(1, | 122 browser()->tab_strip_model()->CloseWebContentsAt(1, |
| 113 TabStripModel::CLOSE_NONE); | 123 TabStripModel::CLOSE_NONE); |
| 124 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers H"; | |
| 114 | 125 |
| 115 // Click on the location bar so that Find box loses focus. | 126 // Click on the location bar so that Find box loses focus. |
| 116 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), | 127 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), |
|
msw
2016/08/26 22:06:10
It seems like we are hanging here from the logs:
h
| |
| 117 VIEW_ID_OMNIBOX)); | 128 VIEW_ID_OMNIBOX)); |
| 118 // Check the location bar is focused. | 129 // Check the location bar is focused. |
| 119 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 130 EXPECT_TRUE(IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 120 | 131 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers I: PRESS ESC"; |
| 132 base::AutoReset<bool> reset_a(&ui_test_utils::g_crbug_639350_logging, true); | |
| 133 base::AutoReset<bool> reset_b(&ui_controls::g_crbug_639350_logging, true); | |
| 121 // This used to crash until bug 1303709 was fixed. | 134 // This used to crash until bug 1303709 was fixed. |
| 122 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 135 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 123 browser(), ui::VKEY_ESCAPE, false, false, false, false)); | 136 browser(), ui::VKEY_ESCAPE, false, false, false, false)); |
| 137 LOG(ERROR) << "crbug.com/639350 FindInPageTest.CrashEscHandlers J: TEST DONE"; | |
| 124 } | 138 } |
| 125 | 139 |
| 126 IN_PROC_BROWSER_TEST_F(FindInPageTest, NavigationByKeyEvent) { | 140 IN_PROC_BROWSER_TEST_F(FindInPageTest, NavigationByKeyEvent) { |
| 127 ASSERT_TRUE(embedded_test_server()->Start()); | 141 ASSERT_TRUE(embedded_test_server()->Start()); |
| 128 // Make sure Chrome is in the foreground, otherwise sending input | 142 // Make sure Chrome is in the foreground, otherwise sending input |
| 129 // won't do anything and the test will hang. | 143 // won't do anything and the test will hang. |
| 130 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 144 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 131 // First we navigate to any page. | 145 // First we navigate to any page. |
| 132 ui_test_utils::NavigateToURL(browser(), | 146 ui_test_utils::NavigateToURL(browser(), |
| 133 embedded_test_server()->GetURL(kSimplePage)); | 147 embedded_test_server()->GetURL(kSimplePage)); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 ui_test_utils::UrlLoadObserver observer( | 566 ui_test_utils::UrlLoadObserver observer( |
| 553 GURL("about:blank"), content::NotificationService::AllSources()); | 567 GURL("about:blank"), content::NotificationService::AllSources()); |
| 554 | 568 |
| 555 // Send Ctrl-Enter, should cause navigation to about:blank. | 569 // Send Ctrl-Enter, should cause navigation to about:blank. |
| 556 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 570 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 557 browser(), ui::VKEY_RETURN, true, false, false, false)); | 571 browser(), ui::VKEY_RETURN, true, false, false, false)); |
| 558 | 572 |
| 559 observer.Wait(); | 573 observer.Wait(); |
| 560 } | 574 } |
| 561 #endif | 575 #endif |
| OLD | NEW |