Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: chrome/browser/ui/browser_focus_uitest.cc

Issue 2500093003: Re-enable tabs_interactive_uitest for linux_aura (Closed)
Patch Set: merge with BringBrowserWindowToFront Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 ASSERT_TRUE(IsViewFocused(vid)); 324 ASSERT_TRUE(IsViewFocused(vid));
325 325
326 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 326 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
327 browser(), ui::VKEY_TAB, true, true, false, false)); 327 browser(), ui::VKEY_TAB, true, true, false, false));
328 } 328 }
329 } 329 }
330 } 330 }
331 331
332 // Tabs remember focus with find-in-page box. 332 // Tabs remember focus with find-in-page box.
333 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocusFindInPage) { 333 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocusFindInPage) {
334 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 334 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
sky 2016/11/15 20:21:12 I don't think any of these calls to BringBrowserWi
335 ui_test_utils::BrowserActivationWaiter waiter(browser());
336 waiter.WaitForActivation();
337 const GURL url = embedded_test_server()->GetURL(kSimplePage); 335 const GURL url = embedded_test_server()->GetURL(kSimplePage);
338 ui_test_utils::NavigateToURL(browser(), url); 336 ui_test_utils::NavigateToURL(browser(), url);
339 337
340 chrome::Find(browser()); 338 chrome::Find(browser());
341 ui_test_utils::FindInPage( 339 ui_test_utils::FindInPage(
342 browser()->tab_strip_model()->GetActiveWebContents(), 340 browser()->tab_strip_model()->GetActiveWebContents(),
343 base::ASCIIToUTF16("a"), true, false, NULL, NULL); 341 base::ASCIIToUTF16("a"), true, false, NULL, NULL);
344 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 342 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
345 343
346 // Focus the location bar. 344 // Focus the location bar.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 unfocused_browser->tab_strip_model()->GetActiveWebContents(), 411 unfocused_browser->tab_strip_model()->GetActiveWebContents(),
414 "stealFocus();")); 412 "stealFocus();"));
415 413
416 // Make sure the first browser is still active. 414 // Make sure the first browser is still active.
417 EXPECT_TRUE(focused_browser->window()->IsActive()); 415 EXPECT_TRUE(focused_browser->window()->IsActive());
418 } 416 }
419 417
420 // Page cannot steal focus when focus is on location bar. 418 // Page cannot steal focus when focus is on location bar.
421 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) { 419 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) {
422 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 420 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
423 ui_test_utils::BrowserActivationWaiter waiter(browser());
424 waiter.WaitForActivation();
425 421
426 // Open the page that steals focus. 422 // Open the page that steals focus.
427 const GURL url = embedded_test_server()->GetURL(kStealFocusPage); 423 const GURL url = embedded_test_server()->GetURL(kStealFocusPage);
428 ui_test_utils::NavigateToURL(browser(), url); 424 ui_test_utils::NavigateToURL(browser(), url);
429 425
430 chrome::FocusLocationBar(browser()); 426 chrome::FocusLocationBar(browser());
431 427
432 ASSERT_TRUE(content::ExecuteScript( 428 ASSERT_TRUE(content::ExecuteScript(
433 browser()->tab_strip_model()->GetActiveWebContents(), 429 browser()->tab_strip_model()->GetActiveWebContents(),
434 "stealFocus();")); 430 "stealFocus();"));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 chrome::AddSelectedTabWithURL( 552 chrome::AddSelectedTabWithURL(
557 browser(), GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK); 553 browser(), GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK);
558 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( 554 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
559 browser()->tab_strip_model()->GetActiveWebContents())); 555 browser()->tab_strip_model()->GetActiveWebContents()));
560 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 556 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
561 } 557 }
562 558
563 // Tests that focus goes where expected when using reload. 559 // Tests that focus goes where expected when using reload.
564 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { 560 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
565 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 561 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
566 ui_test_utils::BrowserActivationWaiter waiter(browser());
567 waiter.WaitForActivation();
568 562
569 // Open the new tab, reload. 563 // Open the new tab, reload.
570 { 564 {
571 content::WindowedNotificationObserver observer( 565 content::WindowedNotificationObserver observer(
572 content::NOTIFICATION_LOAD_STOP, 566 content::NOTIFICATION_LOAD_STOP,
573 content::NotificationService::AllSources()); 567 content::NotificationService::AllSources());
574 chrome::NewTab(browser()); 568 chrome::NewTab(browser());
575 observer.Wait(); 569 observer.Wait();
576 } 570 }
577 content::RunAllPendingInMessageLoop(); 571 content::RunAllPendingInMessageLoop();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 673 }
680 674
681 // Flaky on Windows (http://crbug.com/665296). 675 // Flaky on Windows (http://crbug.com/665296).
682 #if defined(OS_WIN) 676 #if defined(OS_WIN)
683 #define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate 677 #define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate
684 #else 678 #else
685 #define MAYBE_FocusOnNavigate FocusOnNavigate 679 #define MAYBE_FocusOnNavigate FocusOnNavigate
686 #endif 680 #endif
687 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnNavigate) { 681 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnNavigate) {
688 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 682 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
689 ui_test_utils::BrowserActivationWaiter waiter(browser());
690 waiter.WaitForActivation();
691 683
692 // Load the NTP. 684 // Load the NTP.
693 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 685 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
694 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 686 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
695 687
696 // Navigate to another page. 688 // Navigate to another page.
697 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); 689 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html");
698 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath( 690 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath(
699 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile))); 691 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile)));
700 ui_test_utils::NavigateToURL(browser(), file_url); 692 ui_test_utils::NavigateToURL(browser(), file_url);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof)); 736 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof));
745 EXPECT_EQ(url1, web_contents->GetVisibleURL()); 737 EXPECT_EQ(url1, web_contents->GetVisibleURL());
746 // After running the spoof code, |GetActiveWebContents| returns the new tab, 738 // After running the spoof code, |GetActiveWebContents| returns the new tab,
747 // not the same as |web_contents|. 739 // not the same as |web_contents|.
748 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( 740 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
749 browser()->tab_strip_model()->GetActiveWebContents())); 741 browser()->tab_strip_model()->GetActiveWebContents()));
750 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); 742 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
751 } 743 }
752 744
753 } // namespace 745 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698