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

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

Issue 1678163002: mac_views_browser: fixed interactive_ui_tests compilation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unneeded header, enable ActivateOverflowedToolbarActionWithKeyboard test compilation on Mac Created 4 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
« no previous file with comments | « chrome/test/base/interactive_test_utils_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/logging.h"
8 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
9 #include "build/build_config.h"
10 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/views/frame/browser_view.h" 9 #include "chrome/browser/ui/views/frame/browser_view.h"
12 #include "ui/base/test/ui_controls.h"
13 #include "ui/compositor/layer.h"
14 #include "ui/compositor/layer_animator.h"
15 #include "ui/views/focus/focus_manager.h" 10 #include "ui/views/focus/focus_manager.h"
16 11
17 namespace ui_test_utils { 12 namespace ui_test_utils {
18 13
19 // Until the whole browser UI is ported to tookit-views on Mac, these need to
20 // use the definitions in interactive_test_utils_mac.mm.
21 #if !defined(OS_MACOSX)
22
23 bool IsViewFocused(const Browser* browser, ViewID vid) { 14 bool IsViewFocused(const Browser* browser, ViewID vid) {
24 BrowserWindow* browser_window = browser->window(); 15 BrowserWindow* browser_window = browser->window();
25 DCHECK(browser_window); 16 DCHECK(browser_window);
26 gfx::NativeWindow window = browser_window->GetNativeWindow(); 17 gfx::NativeWindow window = browser_window->GetNativeWindow();
27 DCHECK(window); 18 DCHECK(window);
28 const views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); 19 const views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
29 DCHECK(widget); 20 DCHECK(widget);
30 const views::FocusManager* focus_manager = widget->GetFocusManager(); 21 const views::FocusManager* focus_manager = widget->GetFocusManager();
31 DCHECK(focus_manager); 22 DCHECK(focus_manager);
32 DCHECK(focus_manager->GetFocusedView()); 23 DCHECK(focus_manager->GetFocusedView());
(...skipping 10 matching lines...) Expand all
43 content::RunMessageLoop(); 34 content::RunMessageLoop();
44 } 35 }
45 36
46 void FocusView(const Browser* browser, ViewID vid) { 37 void FocusView(const Browser* browser, ViewID vid) {
47 views::View* view = 38 views::View* view =
48 BrowserView::GetBrowserViewForBrowser(browser)->GetViewByID(vid); 39 BrowserView::GetBrowserViewForBrowser(browser)->GetViewByID(vid);
49 DCHECK(view); 40 DCHECK(view);
50 view->RequestFocus(); 41 view->RequestFocus();
51 } 42 }
52 43
53 #endif // defined(OS_MACOSX) 44 gfx::Point GetCenterInScreenCoordinates(const views::View* view) {
54 45 gfx::Point center(view->width() / 2, view->height() / 2);
55 void MoveMouseToCenterAndPress(views::View* view, 46 views::View::ConvertPointToScreen(view, &center);
56 ui_controls::MouseButton button, 47 return center;
57 int state,
58 const base::Closure& closure) {
59 DCHECK(view);
60 DCHECK(view->GetWidget());
61 // Complete any in-progress animation before sending the events so that the
62 // mouse-event targetting happens reliably, and does not flake because of
63 // unreliable animation state.
64 ui::Layer* layer = view->GetWidget()->GetLayer();
65 if (layer) {
66 ui::LayerAnimator* animator = layer->GetAnimator();
67 if (animator && animator->is_animating())
68 animator->StopAnimating();
69 }
70
71 gfx::Point view_center(view->width() / 2, view->height() / 2);
72 views::View::ConvertPointToScreen(view, &view_center);
73 ui_controls::SendMouseMoveNotifyWhenDone(
74 view_center.x(),
75 view_center.y(),
76 base::Bind(&internal::ClickTask, button, state, closure));
77 } 48 }
78 49
79 } // namespace ui_test_utils 50 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/interactive_test_utils_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698