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

Side by Side Diff: chrome/test/base/interactive_test_utils.cc

Issue 2286853002: Add temporary debug logging for crbug.com/639350. (Closed)
Patch Set: Add logging for mouse moves and events. Created 4 years, 3 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
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 "chrome/test/base/interactive_test_utils.h" 5 #include "chrome/test/base/interactive_test_utils.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 10
11 namespace ui_test_utils { 11 namespace ui_test_utils {
12 12
13 // TODO(msw): Remove flaky test debug logging for http://crbug.com/639350.
14 bool g_crbug_639350_logging = false;
15
13 namespace { 16 namespace {
14 17
15 bool GetNativeWindow(const Browser* browser, gfx::NativeWindow* native_window) { 18 bool GetNativeWindow(const Browser* browser, gfx::NativeWindow* native_window) {
16 BrowserWindow* window = browser->window(); 19 BrowserWindow* window = browser->window();
17 if (!window) 20 if (!window)
18 return false; 21 return false;
19 22
20 *native_window = window->GetNativeWindow(); 23 *native_window = window->GetNativeWindow();
21 return *native_window; 24 return *native_window;
22 } 25 }
(...skipping 19 matching lines...) Expand all
42 return false; 45 return false;
43 return SendKeyPressToWindowSync(window, key, control, shift, alt, command); 46 return SendKeyPressToWindowSync(window, key, control, shift, alt, command);
44 } 47 }
45 48
46 bool SendKeyPressToWindowSync(const gfx::NativeWindow window, 49 bool SendKeyPressToWindowSync(const gfx::NativeWindow window,
47 ui::KeyboardCode key, 50 ui::KeyboardCode key,
48 bool control, 51 bool control,
49 bool shift, 52 bool shift,
50 bool alt, 53 bool alt,
51 bool command) { 54 bool command) {
55 if (g_crbug_639350_logging)
56 LOG(ERROR) << "crbug.com/639350 SendKeyPressToWindowSync A";
52 scoped_refptr<content::MessageLoopRunner> runner = 57 scoped_refptr<content::MessageLoopRunner> runner =
53 new content::MessageLoopRunner; 58 new content::MessageLoopRunner;
54 bool result; 59 bool result;
55 result = ui_controls::SendKeyPressNotifyWhenDone( 60 result = ui_controls::SendKeyPressNotifyWhenDone(
56 window, key, control, shift, alt, command, runner->QuitClosure()); 61 window, key, control, shift, alt, command, runner->QuitClosure());
62 if (g_crbug_639350_logging)
63 LOG(ERROR) << "crbug.com/639350 SendKeyPressToWindowSync B";
57 #if defined(OS_WIN) 64 #if defined(OS_WIN)
65 if (g_crbug_639350_logging)
66 LOG(ERROR) << "crbug.com/639350 SendKeyPressToWindowSync C";
58 if (!result && ui_test_utils::ShowAndFocusNativeWindow(window)) { 67 if (!result && ui_test_utils::ShowAndFocusNativeWindow(window)) {
68 if (g_crbug_639350_logging)
69 LOG(ERROR) << "crbug.com/639350 SendKeyPressToWindowSync D";
59 result = ui_controls::SendKeyPressNotifyWhenDone( 70 result = ui_controls::SendKeyPressNotifyWhenDone(
60 window, key, control, shift, alt, command, runner->QuitClosure()); 71 window, key, control, shift, alt, command, runner->QuitClosure());
61 } 72 }
73 if (g_crbug_639350_logging)
74 LOG(ERROR) << "crbug.com/639350 SendKeyPressToWindowSync E";
62 #endif 75 #endif
63 if (!result) { 76 if (!result) {
64 LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed"; 77 LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed";
65 return false; 78 return false;
66 } 79 }
67 80
81 if (g_crbug_639350_logging)
82 LOG(ERROR) << "crbug.com/639350 SendKeyPressToWindowSync F: RUN RUNNER";
68 // Run the message loop. It'll stop running when either the key was received 83 // Run the message loop. It'll stop running when either the key was received
69 // or the test timed out (in which case testing::Test::HasFatalFailure should 84 // or the test timed out (in which case testing::Test::HasFatalFailure should
70 // be set). 85 // be set).
71 runner->Run(); 86 runner->Run();
87 if (g_crbug_639350_logging)
88 LOG(ERROR) << "crbug.com/639350 SendKeyPressToWindowSync G: RUNNER DONE";
72 return !testing::Test::HasFatalFailure(); 89 return !testing::Test::HasFatalFailure();
73 } 90 }
74 91
75 bool SendKeyPressAndWait(const Browser* browser, 92 bool SendKeyPressAndWait(const Browser* browser,
76 ui::KeyboardCode key, 93 ui::KeyboardCode key,
77 bool control, 94 bool control,
78 bool shift, 95 bool shift,
79 bool alt, 96 bool alt,
80 bool command, 97 bool command,
81 int type, 98 int type,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 const base::Closure& followup) { 135 const base::Closure& followup) {
119 if (!followup.is_null()) 136 if (!followup.is_null())
120 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); 137 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup);
121 else 138 else
122 ui_controls::SendMouseEvents(button, state); 139 ui_controls::SendMouseEvents(button, state);
123 } 140 }
124 141
125 } // namespace internal 142 } // namespace internal
126 143
127 } // namespace ui_test_utils 144 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/interactive_test_utils.h ('k') | chrome/test/base/interactive_test_utils_common_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698