OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 9 #include "base/message_loop.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 const wchar_t* GetBoolString(bool value) { | 79 const wchar_t* GetBoolString(bool value) { |
80 return value ? L"true" : L"false"; | 80 return value ? L"true" : L"false"; |
81 } | 81 } |
82 | 82 |
83 // A class to help wait for the finish of a key event test. | 83 // A class to help wait for the finish of a key event test. |
84 class TestFinishObserver : public NotificationObserver { | 84 class TestFinishObserver : public NotificationObserver { |
85 public: | 85 public: |
86 explicit TestFinishObserver(RenderViewHost* render_view_host) | 86 explicit TestFinishObserver(RenderViewHost* render_view_host) |
87 : finished_(false), waiting_(false) { | 87 : finished_(false), waiting_(false) { |
88 registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE, | 88 registrar_.Add(this, chrome::DOM_OPERATION_RESPONSE, |
89 Source<RenderViewHost>(render_view_host)); | 89 Source<RenderViewHost>(render_view_host)); |
90 } | 90 } |
91 | 91 |
92 bool WaitForFinish() { | 92 bool WaitForFinish() { |
93 if (!finished_) { | 93 if (!finished_) { |
94 waiting_ = true; | 94 waiting_ = true; |
95 ui_test_utils::RunMessageLoop(); | 95 ui_test_utils::RunMessageLoop(); |
96 waiting_ = false; | 96 waiting_ = false; |
97 } | 97 } |
98 return finished_; | 98 return finished_; |
99 } | 99 } |
100 | 100 |
101 virtual void Observe(NotificationType type, | 101 virtual void Observe(int type, |
102 const NotificationSource& source, | 102 const NotificationSource& source, |
103 const NotificationDetails& details) { | 103 const NotificationDetails& details) { |
104 DCHECK(type == NotificationType::DOM_OPERATION_RESPONSE); | 104 DCHECK(type == chrome::DOM_OPERATION_RESPONSE); |
105 Details<DomOperationNotificationDetails> dom_op_details(details); | 105 Details<DomOperationNotificationDetails> dom_op_details(details); |
106 // We might receive responses for other script execution, but we only | 106 // We might receive responses for other script execution, but we only |
107 // care about the test finished message. | 107 // care about the test finished message. |
108 if (dom_op_details->json() == "\"FINISHED\"") { | 108 if (dom_op_details->json() == "\"FINISHED\"") { |
109 finished_ = true; | 109 finished_ = true; |
110 if (waiting_) | 110 if (waiting_) |
111 MessageLoopForUI::current()->Quit(); | 111 MessageLoopForUI::current()->Quit(); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 true, false, false, false, 1, | 667 true, false, false, false, 1, |
668 { "D 91 0 false false false true" } | 668 { "D 91 0 false false false true" } |
669 #else | 669 #else |
670 ui::VKEY_T, true, false, false, false, | 670 ui::VKEY_T, true, false, false, false, |
671 true, false, false, false, 1, | 671 true, false, false, false, 1, |
672 { "D 17 0 true false false false" } | 672 { "D 17 0 true false false false" } |
673 #endif | 673 #endif |
674 }; | 674 }; |
675 | 675 |
676 ui_test_utils::WindowedNotificationObserver wait_for_new_tab( | 676 ui_test_utils::WindowedNotificationObserver wait_for_new_tab( |
677 NotificationType::TAB_PARENTED, | 677 chrome::TAB_PARENTED, |
678 NotificationService::AllSources()); | 678 NotificationService::AllSources()); |
679 | 679 |
680 // Press Ctrl/Cmd+T, which will open a new tab. It cannot be suppressed. | 680 // Press Ctrl/Cmd+T, which will open a new tab. It cannot be suppressed. |
681 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCtrlOrCmdT)); | 681 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(0, kTestCtrlOrCmdT)); |
682 | 682 |
683 ASSERT_NO_FATAL_FAILURE( | 683 ASSERT_NO_FATAL_FAILURE( |
684 wait_for_new_tab.WaitFor(Source<TabContentsWrapper>( | 684 wait_for_new_tab.WaitFor(Source<TabContentsWrapper>( |
685 browser()->GetTabContentsWrapperAt(1)))); | 685 browser()->GetTabContentsWrapperAt(1)))); |
686 | 686 |
687 int result_length; | 687 int result_length; |
688 ASSERT_NO_FATAL_FAILURE(GetResultLength(0, &result_length)); | 688 ASSERT_NO_FATAL_FAILURE(GetResultLength(0, &result_length)); |
689 EXPECT_EQ(1, result_length); | 689 EXPECT_EQ(1, result_length); |
690 | 690 |
691 EXPECT_EQ(2, browser()->tab_count()); | 691 EXPECT_EQ(2, browser()->tab_count()); |
692 ASSERT_EQ(1, browser()->active_index()); | 692 ASSERT_EQ(1, browser()->active_index()); |
693 | 693 |
694 // Because of issue http://crbug.com/65375, switching back to the first tab | 694 // Because of issue http://crbug.com/65375, switching back to the first tab |
695 // may cause the focus to be grabbed by omnibox. So instead, we load our | 695 // may cause the focus to be grabbed by omnibox. So instead, we load our |
696 // testing page in the newly created tab and try Cmd-W here. | 696 // testing page in the newly created tab and try Cmd-W here. |
697 ui_test_utils::NavigateToURL(browser(), url); | 697 ui_test_utils::NavigateToURL(browser(), url); |
698 | 698 |
699 // Make sure the focus is in the testing page. | 699 // Make sure the focus is in the testing page. |
700 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER)); | 700 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_TAB_CONTAINER)); |
701 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 701 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
702 | 702 |
703 // Reserved accelerators can't be suppressed. | 703 // Reserved accelerators can't be suppressed. |
704 ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true)); | 704 ASSERT_NO_FATAL_FAILURE(SuppressAllEvents(1, true)); |
705 | 705 |
706 ui_test_utils::WindowedNotificationObserver wait_for_tab_closed( | 706 ui_test_utils::WindowedNotificationObserver wait_for_tab_closed( |
707 NotificationType::TAB_CLOSED, Source<NavigationController>( | 707 chrome::TAB_CLOSED, Source<NavigationController>( |
708 &browser()->GetTabContentsAt(1)->controller())); | 708 &browser()->GetTabContentsAt(1)->controller())); |
709 | 709 |
710 // Press Ctrl/Cmd+W, which will close the tab. | 710 // Press Ctrl/Cmd+W, which will close the tab. |
711 #if defined(OS_MACOSX) | 711 #if defined(OS_MACOSX) |
712 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 712 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
713 browser(), ui::VKEY_W, false, false, false, true)); | 713 browser(), ui::VKEY_W, false, false, false, true)); |
714 #else | 714 #else |
715 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 715 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
716 browser(), ui::VKEY_W, true, false, false, false)); | 716 browser(), ui::VKEY_W, true, false, false, false)); |
717 #endif | 717 #endif |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); | 849 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); |
850 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 850 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
851 | 851 |
852 // Ctrl+Alt should have no effect. | 852 // Ctrl+Alt should have no effect. |
853 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); | 853 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); |
854 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 854 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
855 } | 855 } |
856 #endif | 856 #endif |
857 | 857 |
858 } // namespace | 858 } // namespace |
OLD | NEW |