| OLD | NEW |
| 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/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 if ([[NSScreen screens] count] > 0) { | 22 if ([[NSScreen screens] count] > 0) { |
| 23 new_bounds.origin.y = | 23 new_bounds.origin.y = |
| 24 [[[NSScreen screens] objectAtIndex:0] frame].size.height - | 24 [[[NSScreen screens] objectAtIndex:0] frame].size.height - |
| 25 new_bounds.origin.y - new_bounds.size.height; | 25 new_bounds.origin.y - new_bounds.size.height; |
| 26 } | 26 } |
| 27 | 27 |
| 28 [window setFrame:new_bounds display:NO]; | 28 [window setFrame:new_bounds display:NO]; |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool IsViewFocused(const Browser* browser, ViewID vid) { | 31 bool IsViewFocused(const Browser* browser, ViewID vid) { |
| 32 NSWindow* window = browser->window()->GetNativeHandle(); | 32 NSWindow* window = browser->window()->GetNativeWindow(); |
| 33 DCHECK(window); | 33 DCHECK(window); |
| 34 NSView* view = view_id_util::GetView(window, vid); | 34 NSView* view = view_id_util::GetView(window, vid); |
| 35 if (!view) | 35 if (!view) |
| 36 return false; | 36 return false; |
| 37 | 37 |
| 38 NSResponder* firstResponder = [window firstResponder]; | 38 NSResponder* firstResponder = [window firstResponder]; |
| 39 if (firstResponder == static_cast<NSResponder*>(view)) | 39 if (firstResponder == static_cast<NSResponder*>(view)) |
| 40 return true; | 40 return true; |
| 41 | 41 |
| 42 // Handle the special case of focusing a TextField. | 42 // Handle the special case of focusing a TextField. |
| 43 if ([firstResponder isKindOfClass:[NSTextView class]]) { | 43 if ([firstResponder isKindOfClass:[NSTextView class]]) { |
| 44 NSView* delegate = static_cast<NSView*>([(NSTextView*)firstResponder | 44 NSView* delegate = static_cast<NSView*>([(NSTextView*)firstResponder |
| 45 delegate]); | 45 delegate]); |
| 46 if (delegate == view) | 46 if (delegate == view) |
| 47 return true; | 47 return true; |
| 48 } | 48 } |
| 49 | 49 |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void ClickOnView(const Browser* browser, ViewID vid) { | 53 void ClickOnView(const Browser* browser, ViewID vid) { |
| 54 NSWindow* window = browser->window()->GetNativeHandle(); | 54 NSWindow* window = browser->window()->GetNativeWindow(); |
| 55 DCHECK(window); | 55 DCHECK(window); |
| 56 NSView* view = view_id_util::GetView(window, vid); | 56 NSView* view = view_id_util::GetView(window, vid); |
| 57 DCHECK(view); | 57 DCHECK(view); |
| 58 MoveMouseToCenterAndPress( | 58 MoveMouseToCenterAndPress( |
| 59 view, | 59 view, |
| 60 ui_controls::LEFT, | 60 ui_controls::LEFT, |
| 61 ui_controls::DOWN | ui_controls::UP, | 61 ui_controls::DOWN | ui_controls::UP, |
| 62 MessageLoop::QuitClosure()); | 62 MessageLoop::QuitClosure()); |
| 63 RunMessageLoop(); | 63 RunMessageLoop(); |
| 64 } | 64 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 95 center = [view convertPoint:center toView:nil]; | 95 center = [view convertPoint:center toView:nil]; |
| 96 center = [window convertBaseToScreen:center]; | 96 center = [window convertBaseToScreen:center]; |
| 97 center = NSMakePoint(center.x, [screen frame].size.height - center.y); | 97 center = NSMakePoint(center.x, [screen frame].size.height - center.y); |
| 98 | 98 |
| 99 ui_controls::SendMouseMoveNotifyWhenDone( | 99 ui_controls::SendMouseMoveNotifyWhenDone( |
| 100 center.x, center.y, | 100 center.x, center.y, |
| 101 base::Bind(&internal::ClickTask, button, state, task)); | 101 base::Bind(&internal::ClickTask, button, state, task)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace ui_test_utils | 104 } // namespace ui_test_utils |
| OLD | NEW |