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

Side by Side Diff: chrome/test/ui_test_utils.h

Issue 3117030: Adds ui_test_utils::SendAndWaitForKeyPress and converts callers (where (Closed)
Patch Set: Addressed review comments Created 10 years, 4 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_UI_TEST_UTILS_H_ 5 #ifndef CHROME_TEST_UI_TEST_UTILS_H_
6 #define CHROME_TEST_UI_TEST_UTILS_H_ 6 #define CHROME_TEST_UI_TEST_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <set> 11 #include <set>
12 12
13 #include "gfx/native_widget_types.h"
14 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/keyboard_codes.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/scoped_temp_dir.h" 16 #include "base/scoped_temp_dir.h"
17 #include "base/string16.h" 17 #include "base/string16.h"
18 #include "chrome/browser/view_ids.h" 18 #include "chrome/browser/view_ids.h"
19 #include "chrome/common/notification_observer.h" 19 #include "chrome/common/notification_observer.h"
20 #include "chrome/common/notification_registrar.h" 20 #include "chrome/common/notification_registrar.h"
21 #include "chrome/common/notification_type.h" 21 #include "chrome/common/notification_type.h"
22 #include "chrome/common/notification_service.h" 22 #include "chrome/common/notification_service.h"
23 #include "chrome/test/automation/dom_element_proxy.h" 23 #include "chrome/test/automation/dom_element_proxy.h"
24 #include "gfx/native_widget_types.h"
24 25
25 class AppModalDialog; 26 class AppModalDialog;
26 class BookmarkModel; 27 class BookmarkModel;
27 class BookmarkNode; 28 class BookmarkNode;
28 class Browser; 29 class Browser;
29 class CommandLine; 30 class CommandLine;
30 class DownloadManager; 31 class DownloadManager;
31 class ExtensionAction; 32 class ExtensionAction;
32 class FilePath; 33 class FilePath;
33 class GURL; 34 class GURL;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 182
182 // Register |observer| for the given |type| and |source| and run 183 // Register |observer| for the given |type| and |source| and run
183 // the message loop until the observer posts a quit task. 184 // the message loop until the observer posts a quit task.
184 void RegisterAndWait(NotificationObserver* observer, 185 void RegisterAndWait(NotificationObserver* observer,
185 NotificationType::Type type, 186 NotificationType::Type type,
186 const NotificationSource& source); 187 const NotificationSource& source);
187 188
188 // Blocks until |model| finishes loading. 189 // Blocks until |model| finishes loading.
189 void WaitForBookmarkModelToLoad(BookmarkModel* model); 190 void WaitForBookmarkModelToLoad(BookmarkModel* model);
190 191
192 // Sends a key press blocking until the key press is received or the test times
193 // out. This uses ui_controls::SendKeyPress, see it for details. Returns true
194 // if the event was successfully sent and received.
195 // The proper way to use this in a test is:
Paweł Hajdan Jr. 2010/08/21 02:44:28 nit: I suggest to remove the "The proper way to us
196 // ASSERT_TRUE(ui_test_utils::Send...).
197 bool SendKeyPressSync(gfx::NativeWindow window,
198 base::KeyboardCode key,
199 bool control,
200 bool shift,
201 bool alt,
202 bool command) WARN_UNUSED_RESULT;
203
191 // Run a message loop only for the specified amount of time. 204 // Run a message loop only for the specified amount of time.
192 class TimedMessageLoopRunner { 205 class TimedMessageLoopRunner {
193 public: 206 public:
194 // Create new MessageLoopForUI and attach to it. 207 // Create new MessageLoopForUI and attach to it.
195 TimedMessageLoopRunner(); 208 TimedMessageLoopRunner();
196 209
197 // Attach to an existing message loop. 210 // Attach to an existing message loop.
198 explicit TimedMessageLoopRunner(MessageLoop* loop) 211 explicit TimedMessageLoopRunner(MessageLoop* loop)
199 : loop_(loop), owned_(false), quit_loop_invoked_(false) {} 212 : loop_(loop), owned_(false), quit_loop_invoked_(false) {}
200 213
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 433
421 // Hide a native window. 434 // Hide a native window.
422 void HideNativeWindow(gfx::NativeWindow window); 435 void HideNativeWindow(gfx::NativeWindow window);
423 436
424 // Show and focus a native window. 437 // Show and focus a native window.
425 void ShowAndFocusNativeWindow(gfx::NativeWindow window); 438 void ShowAndFocusNativeWindow(gfx::NativeWindow window);
426 439
427 } // namespace ui_test_utils 440 } // namespace ui_test_utils
428 441
429 #endif // CHROME_TEST_UI_TEST_UTILS_H_ 442 #endif // CHROME_TEST_UI_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698