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

Side by Side Diff: chrome/test/ui_test_utils_linux.cc

Issue 268035: Implements tests for testing browser's overall key events handling behavior.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/test/ui_test_utils.h ('k') | chrome/test/ui_test_utils_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/test/ui_test_utils.h"
6
7 #include "base/logging.h"
8 #include "base/message_loop.h"
9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/browser_window.h"
11 #include "chrome/browser/automation/ui_controls.h"
12 #if defined(TOOLKIT_VIEWS)
13 #include "chrome/browser/views/frame/browser_view.h"
14 #endif
15
16 #include "chrome/browser/gtk/view_id_util.h"
17
18 namespace ui_test_utils {
19
20 namespace {
21
22 // Check if the focused widget for |root| is |target| or a child of |target|.
23 static bool IsWidgetInFocusChain(GtkWidget* root, GtkWidget* target) {
24 GtkWidget* iter = root;
25
26 while (iter) {
27 if (iter == target)
28 return true;
29
30 if (!GTK_IS_CONTAINER(iter))
31 return false;
32
33 iter = GTK_CONTAINER(iter)->focus_child;
34 }
35
36 return false;
37 }
38
39 } // namespace
40
41 bool IsViewFocused(const Browser* browser, ViewID vid) {
42 BrowserWindow* browser_window = browser->window();
43 DCHECK(browser_window);
44 gfx::NativeWindow window = browser_window->GetNativeHandle();
45 DCHECK(window);
46 GtkWidget* widget = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid);
47 DCHECK(widget);
48 return IsWidgetInFocusChain(GTK_WIDGET(window), widget);
49 }
50
51 void ClickOnView(const Browser* browser, ViewID vid) {
52 BrowserWindow* browser_window = browser->window();
53 DCHECK(browser_window);
54 #if defined(TOOLKIT_VIEWS)
55 views::View* view =
56 reinterpret_cast<BrowserView*>(browser_window)->GetViewByID(vid);
57 #else
58 gfx::NativeWindow window = browser_window->GetNativeHandle();
59 DCHECK(window);
60 GtkWidget* view = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid);
61 #endif
62
63 DCHECK(view);
64 ui_controls::MoveMouseToCenterAndPress(
65 view,
66 ui_controls::LEFT,
67 ui_controls::DOWN | ui_controls::UP,
68 new MessageLoop::QuitTask());
69 RunMessageLoop();
70 }
71
72 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/ui_test_utils.h ('k') | chrome/test/ui_test_utils_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698