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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/run_loop.h" | |
10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
17 #include "chrome/browser/ui/chrome_pages.h" | 18 #include "chrome/browser/ui/chrome_pages.h" |
18 #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" | 19 #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" |
19 #include "chrome/browser/ui/location_bar/location_bar.h" | 20 #include "chrome/browser/ui/location_bar/location_bar.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 231 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
231 | 232 |
232 chrome::FocusLocationBar(browser()); | 233 chrome::FocusLocationBar(browser()); |
233 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 234 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
234 // Hide the window, show it again, the focus should not have changed. | 235 // Hide the window, show it again, the focus should not have changed. |
235 ui_test_utils::HideNativeWindow(window); | 236 ui_test_utils::HideNativeWindow(window); |
236 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); | 237 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); |
237 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 238 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
238 } | 239 } |
239 | 240 |
241 // This test is only for Linux Desktop. | |
242 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | |
243 #define MAYBE_BrowserDialogModalTest BrowserDialogModalTest | |
244 #else | |
245 #define MAYBE_BrowserDialogModalTest DISABLE_BrowserDialogModalTest | |
246 #endif | |
247 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_BrowserDialogModalTest) { | |
248 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
249 const GURL url = embedded_test_server()->GetURL(kSimplePage); | |
250 ui_test_utils::NavigateToURL(browser(), url); | |
251 ASSERT_TRUE(browser()->window()->IsActive()); | |
252 | |
253 browser()->OpenFile(); | |
254 | |
255 base::RunLoop run_loop; | |
256 base::MessageLoop::current()->PostTask( | |
257 FROM_HERE, run_loop.QuitClosure()); | |
258 run_loop.Run(); | |
sadrul
2015/09/02 17:27:28
Add a comment explaining why this is necessary.
| |
259 | |
260 gfx::Rect rect = browser()->window()->GetBounds(); | |
261 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point(rect.x() + 1, | |
262 rect.y() + 1))); | |
263 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | |
264 ui_controls::LEFT, ui_controls::DOWN)); | |
sadrul
2015/09/02 17:27:28
Can this send both (DOWN | UP) for a click?
| |
265 // The window should not get focus due to modal dialog. | |
266 EXPECT_FALSE(browser()->window()->IsActive()); | |
267 } | |
268 | |
240 // Tabs remember focus. | 269 // Tabs remember focus. |
241 // Disabled, http://crbug.com/62542. | 270 // Disabled, http://crbug.com/62542. |
242 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) { | 271 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) { |
243 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 272 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
244 const GURL url = embedded_test_server()->GetURL(kSimplePage); | 273 const GURL url = embedded_test_server()->GetURL(kSimplePage); |
245 ui_test_utils::NavigateToURL(browser(), url); | 274 ui_test_utils::NavigateToURL(browser(), url); |
246 | 275 |
247 // Create several tabs. | 276 // Create several tabs. |
248 for (int i = 0; i < 4; ++i) { | 277 for (int i = 0; i < 4; ++i) { |
249 chrome::AddSelectedTabWithURL(browser(), url, | 278 chrome::AddSelectedTabWithURL(browser(), url, |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 730 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
702 content::NotificationService::AllSources()); | 731 content::NotificationService::AllSources()); |
703 chrome::GoForward(browser(), CURRENT_TAB); | 732 chrome::GoForward(browser(), CURRENT_TAB); |
704 forward_nav_observer.Wait(); | 733 forward_nav_observer.Wait(); |
705 } | 734 } |
706 | 735 |
707 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 736 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
708 } | 737 } |
709 | 738 |
710 } // namespace | 739 } // namespace |
OLD | NEW |