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

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

Issue 2500093003: Re-enable tabs_interactive_uitest for linux_aura (Closed)
Patch Set: 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 ui_test_utils::ActivateBrowserWindow(browser());
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 ASSERT_TRUE(content::ExecuteScript( 410 ASSERT_TRUE(content::ExecuteScript(
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 ui_test_utils::ActivateBrowserWindow(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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 // Open about:blank, focus should be on the location bar. 551 // Open about:blank, focus should be on the location bar.
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 ui_test_utils::ActivateBrowserWindow(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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 // The tab contents should have the focus in the second tab. 666 // The tab contents should have the focus in the second tab.
673 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 667 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
674 668
675 // Go back to the first tab. The focus should not be in the omnibox. 669 // Go back to the first tab. The focus should not be in the omnibox.
676 chrome::SelectPreviousTab(browser()); 670 chrome::SelectPreviousTab(browser());
677 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 671 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
678 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); 672 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
679 } 673 }
680 674
681 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) { 675 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) {
682 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 676 ui_test_utils::ActivateBrowserWindow(browser());
683 ui_test_utils::BrowserActivationWaiter waiter(browser());
684 waiter.WaitForActivation();
685 677
686 // Load the NTP. 678 // Load the NTP.
687 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 679 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
688 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 680 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
689 681
690 // Navigate to another page. 682 // Navigate to another page.
691 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); 683 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html");
692 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath( 684 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath(
693 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile))); 685 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile)));
694 ui_test_utils::NavigateToURL(browser(), file_url); 686 ui_test_utils::NavigateToURL(browser(), file_url);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof)); 730 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof));
739 EXPECT_EQ(url1, web_contents->GetVisibleURL()); 731 EXPECT_EQ(url1, web_contents->GetVisibleURL());
740 // After running the spoof code, |GetActiveWebContents| returns the new tab, 732 // After running the spoof code, |GetActiveWebContents| returns the new tab,
741 // not the same as |web_contents|. 733 // not the same as |web_contents|.
742 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( 734 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
743 browser()->tab_strip_model()->GetActiveWebContents())); 735 browser()->tab_strip_model()->GetActiveWebContents()));
744 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); 736 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
745 } 737 }
746 738
747 } // namespace 739 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698