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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 232 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
232 | 233 |
233 chrome::FocusLocationBar(browser()); | 234 chrome::FocusLocationBar(browser()); |
234 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 235 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
235 // Hide the window, show it again, the focus should not have changed. | 236 // Hide the window, show it again, the focus should not have changed. |
236 ui_test_utils::HideNativeWindow(window); | 237 ui_test_utils::HideNativeWindow(window); |
237 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); | 238 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); |
238 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); | 239 ASSERT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); |
239 } | 240 } |
240 | 241 |
242 // This test is only for Linux Desktop. | |
243 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | |
msw
2015/09/04 22:25:16
Remove |&& defined(USE_AURA)| from here and simila
joone
2015/09/10 23:55:38
Done.
| |
244 #define MAYBE_BrowserDialogModalTest BrowserDialogModalTest | |
245 #else | |
246 #define MAYBE_BrowserDialogModalTest DISABLE_BrowserDialogModalTest | |
msw
2015/09/04 22:25:16
"DISABLED_"
joone
2015/09/10 23:55:38
Done.
| |
247 #endif | |
248 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_BrowserDialogModalTest) { | |
249 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
250 const GURL url = embedded_test_server()->GetURL(kSimplePage); | |
251 ui_test_utils::NavigateToURL(browser(), url); | |
252 ASSERT_TRUE(browser()->window()->IsActive()); | |
253 | |
254 browser()->OpenFile(); | |
255 | |
256 // Insert a delay to wait until the file-picker is opened and gets focus. | |
msw
2015/09/04 22:25:17
Is there a better way to do this? If the nested ru
joone
2015/09/10 23:55:38
I added a timeout(1 sec).
| |
257 base::RunLoop run_loop; | |
258 base::MessageLoop::current()->PostTask( | |
259 FROM_HERE, run_loop.QuitClosure()); | |
260 run_loop.Run(); | |
261 | |
262 gfx::Rect rect = browser()->window()->GetBounds(); | |
msw
2015/09/04 22:25:17
Right after the run loop, do EXPECT_FALSE(browser(
joone
2015/09/10 23:55:38
Done.
| |
263 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point(rect.x() + 1, | |
msw
2015/09/04 22:25:16
nit: maybe use ClickOnView instead?
joone
2015/09/10 23:55:38
Done.
| |
264 rect.y() + 1))); | |
265 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | |
msw
2015/09/04 22:25:16
I wonder if (1) Perhaps the dialog will actually c
joone
2015/09/10 23:55:38
Calling ClickOnView() may be able to fix this prob
| |
266 ui_controls::LEFT, ui_controls::DOWN)); | |
267 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | |
268 ui_controls::LEFT, ui_controls::UP)); | |
269 | |
270 // The window should not get focus due to modal dialog. | |
271 EXPECT_FALSE(browser()->window()->IsActive()); | |
272 } | |
273 | |
241 // Tabs remember focus. | 274 // Tabs remember focus. |
242 // Disabled, http://crbug.com/62542. | 275 // Disabled, http://crbug.com/62542. |
243 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) { | 276 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) { |
244 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 277 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
245 const GURL url = embedded_test_server()->GetURL(kSimplePage); | 278 const GURL url = embedded_test_server()->GetURL(kSimplePage); |
246 ui_test_utils::NavigateToURL(browser(), url); | 279 ui_test_utils::NavigateToURL(browser(), url); |
247 | 280 |
248 // Create several tabs. | 281 // Create several tabs. |
249 for (int i = 0; i < 4; ++i) { | 282 for (int i = 0; i < 4; ++i) { |
250 chrome::AddSelectedTabWithURL(browser(), url, | 283 chrome::AddSelectedTabWithURL(browser(), url, |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
702 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 735 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
703 content::NotificationService::AllSources()); | 736 content::NotificationService::AllSources()); |
704 chrome::GoForward(browser(), CURRENT_TAB); | 737 chrome::GoForward(browser(), CURRENT_TAB); |
705 forward_nav_observer.Wait(); | 738 forward_nav_observer.Wait(); |
706 } | 739 } |
707 | 740 |
708 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 741 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
709 } | 742 } |
710 | 743 |
711 } // namespace | 744 } // namespace |
OLD | NEW |