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

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

Issue 157713002: Switch DomAutomationController to be a RenderFrameObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nasko@ CR feedback Created 6 years, 10 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/interactive_test_utils.h" 18 #include "chrome/test/base/interactive_test_utils.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/dom_operation_notification_details.h" 20 #include "content/public/browser/dom_operation_notification_details.h"
21 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_frame_host.h"
Charlie Reis 2014/02/15 01:47:33 This doesn't look needed, right?
mkosiba (inactive) 2014/02/17 17:42:31 Done.
24 #include "content/public/browser/render_widget_host_view.h" 24 #include "content/public/browser/render_widget_host_view.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_view.h" 26 #include "content/public/browser/web_contents_view.h"
27 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
28 #include "net/test/embedded_test_server/embedded_test_server.h" 28 #include "net/test/embedded_test_server/embedded_test_server.h"
29 #include "ui/events/keycodes/keyboard_codes.h" 29 #include "ui/events/keycodes/keyboard_codes.h"
30 30
31 // TODO(kbr): remove: http://crbug.com/222296 31 // TODO(kbr): remove: http://crbug.com/222296
32 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
33 #import "base/mac/mac_util.h" 33 #import "base/mac/mac_util.h"
34 #endif 34 #endif
35 35
36 using content::DomOperationNotificationDetails; 36 using content::DomOperationNotificationDetails;
37 using content::NavigationController; 37 using content::NavigationController;
38 using content::RenderViewHost; 38 using content::RenderFrameHost;
Charlie Reis 2014/02/15 01:47:33 Unneeded?
mkosiba (inactive) 2014/02/17 17:42:31 Done.
39 39
40 namespace { 40 namespace {
41 41
42 const char kTestingPage[] = "/keyevents_test.html"; 42 const char kTestingPage[] = "/keyevents_test.html";
43 const char kSuppressEventJS[] = 43 const char kSuppressEventJS[] =
44 "window.domAutomationController.send(setDefaultAction('%ls', %ls));"; 44 "window.domAutomationController.send(setDefaultAction('%ls', %ls));";
45 const char kGetResultJS[] = 45 const char kGetResultJS[] =
46 "window.domAutomationController.send(keyEventResult[%d]);"; 46 "window.domAutomationController.send(keyEventResult[%d]);";
47 const char kGetResultLengthJS[] = 47 const char kGetResultLengthJS[] =
48 "window.domAutomationController.send(keyEventResult.length);"; 48 "window.domAutomationController.send(keyEventResult.length);";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const char* const result[kMaxResultLength]; 89 const char* const result[kMaxResultLength];
90 }; 90 };
91 91
92 const wchar_t* GetBoolString(bool value) { 92 const wchar_t* GetBoolString(bool value) {
93 return value ? L"true" : L"false"; 93 return value ? L"true" : L"false";
94 } 94 }
95 95
96 // A class to help wait for the finish of a key event test. 96 // A class to help wait for the finish of a key event test.
97 class TestFinishObserver : public content::NotificationObserver { 97 class TestFinishObserver : public content::NotificationObserver {
98 public: 98 public:
99 explicit TestFinishObserver(RenderViewHost* render_view_host) 99 explicit TestFinishObserver(content::WebContents* web_contents)
100 : finished_(false), waiting_(false) { 100 : finished_(false), waiting_(false) {
101 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, 101 registrar_.Add(this,
102 content::Source<RenderViewHost>(render_view_host)); 102 content::NOTIFICATION_DOM_OPERATION_RESPONSE,
103 content::Source<content::WebContents>(web_contents));
103 } 104 }
104 105
105 bool WaitForFinish() { 106 bool WaitForFinish() {
106 if (!finished_) { 107 if (!finished_) {
107 waiting_ = true; 108 waiting_ = true;
108 content::RunMessageLoop(); 109 content::RunMessageLoop();
109 waiting_ = false; 110 waiting_ = false;
110 } 111 }
111 return finished_; 112 return finished_;
112 } 113 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // event. 264 // event.
264 ASSERT_NO_FATAL_FAILURE(StartTest(tab_index, test.result_length)); 265 ASSERT_NO_FATAL_FAILURE(StartTest(tab_index, test.result_length));
265 ASSERT_NO_FATAL_FAILURE(SuppressEvents( 266 ASSERT_NO_FATAL_FAILURE(SuppressEvents(
266 tab_index, test.suppress_keydown, test.suppress_keypress, 267 tab_index, test.suppress_keydown, test.suppress_keypress,
267 test.suppress_keyup, test.suppress_textinput)); 268 test.suppress_keyup, test.suppress_textinput));
268 269
269 // We need to create a finish observer before sending the key event, 270 // We need to create a finish observer before sending the key event,
270 // because the test finished message might be arrived before returning 271 // because the test finished message might be arrived before returning
271 // from the SendKeyPressSync() method. 272 // from the SendKeyPressSync() method.
272 TestFinishObserver finish_observer( 273 TestFinishObserver finish_observer(
273 browser()->tab_strip_model()->GetWebContentsAt(tab_index)-> 274 browser()->tab_strip_model()->GetWebContentsAt(tab_index));
274 GetRenderViewHost());
275 275
276 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 276 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
277 browser(), test.key, test.ctrl, test.shift, test.alt, test.command)); 277 browser(), test.key, test.ctrl, test.shift, test.alt, test.command));
278 ASSERT_TRUE(finish_observer.WaitForFinish()); 278 ASSERT_TRUE(finish_observer.WaitForFinish());
279 ASSERT_NO_FATAL_FAILURE(CheckResult( 279 ASSERT_NO_FATAL_FAILURE(CheckResult(
280 tab_index, test.result_length, test.result)); 280 tab_index, test.result_length, test.result));
281 } 281 }
282 282
283 std::string GetTestDataDescription(const KeyEventTestData& data) { 283 std::string GetTestDataDescription(const KeyEventTestData& data) {
284 std::string desc = base::StringPrintf( 284 std::string desc = base::StringPrintf(
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress)); 873 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestAltKeySuppress));
874 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 874 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
875 875
876 // Ctrl+Alt should have no effect. 876 // Ctrl+Alt should have no effect.
877 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey)); 877 EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlAltKey));
878 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 878 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
879 } 879 }
880 #endif 880 #endif
881 881
882 } // namespace 882 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/base/javascript_test_observer.h » ('j') | content/browser/frame_host/render_frame_host_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698