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

Side by Side Diff: chrome/browser/browser_keyevents_browsertest.cc

Issue 26277010: Create content::WebContentsDestroyedWatcher, use it in many tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 2 months 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 | Annotate | Revision Log
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // testing page in the newly created tab and try Cmd-W here. 716 // testing page in the newly created tab and try Cmd-W here.
717 ui_test_utils::NavigateToURL(browser(), url); 717 ui_test_utils::NavigateToURL(browser(), url);
718 718
719 // Make sure the focus is in the testing page. 719 // Make sure the focus is in the testing page.
720 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER)); 720 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER));
721 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 721 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
722 722
723 // Reserved accelerators can't be suppressed. 723 // Reserved accelerators can't be suppressed.
724 ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true)); 724 ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true));
725 725
726 content::WindowedNotificationObserver wait_for_tab_closed( 726 content::WebContentsDestroyedWatcher destroyed_watcher(
727 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 727 browser()->tab_strip_model()->GetWebContentsAt(1));
728 content::Source<content::WebContents>(
729 browser()->tab_strip_model()->GetWebContentsAt(1)));
730 728
731 // Press Ctrl/Cmd+W, which will close the tab. 729 // Press Ctrl/Cmd+W, which will close the tab.
732 #if defined(OS_MACOSX) 730 #if defined(OS_MACOSX)
733 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 731 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
734 browser(), ui::VKEY_W, false, false, false, true)); 732 browser(), ui::VKEY_W, false, false, false, true));
735 #else 733 #else
736 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 734 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
737 browser(), ui::VKEY_W, true, false, false, false)); 735 browser(), ui::VKEY_W, true, false, false, false));
738 #endif 736 #endif
739 737
740 ASSERT_NO_FATAL_FAILURE(wait_for_tab_closed.Wait()); 738 ASSERT_NO_FATAL_FAILURE(destroyed_watcher.Wait());
741 739
742 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 740 EXPECT_EQ(1, browser()->tab_strip_model()->count());
743 } 741 }
744 742
745 #if defined(OS_MACOSX) 743 #if defined(OS_MACOSX)
746 IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, EditorKeyBindings) { 744 IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, EditorKeyBindings) {
747 // TODO(kbr): re-enable: http://crbug.com/222296 745 // TODO(kbr): re-enable: http://crbug.com/222296
748 if (base::mac::IsOSMountainLionOrLater()) 746 if (base::mac::IsOSMountainLionOrLater())
749 return; 747 return;
750 748
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); 874 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress));
877 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 875 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
878 876
879 // Ctrl+Alt should have no effect. 877 // Ctrl+Alt should have no effect.
880 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); 878 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey));
881 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 879 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
882 } 880 }
883 #endif 881 #endif
884 882
885 } // namespace 883 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698