| 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/interactive_test_utils.h" | 5 #include "chrome/test/base/interactive_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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 NSWindow* window = browser->window()->GetNativeWindow(); | 47 NSWindow* window = browser->window()->GetNativeWindow(); |
| 48 DCHECK(window); | 48 DCHECK(window); |
| 49 NSView* view = view_id_util::GetView(window, vid); | 49 NSView* view = view_id_util::GetView(window, vid); |
| 50 if (!view) | 50 if (!view) |
| 51 return false; | 51 return false; |
| 52 | 52 |
| 53 NSResponder* firstResponder = [window firstResponder]; | 53 NSResponder* firstResponder = [window firstResponder]; |
| 54 if (firstResponder == static_cast<NSResponder*>(view)) | 54 if (firstResponder == static_cast<NSResponder*>(view)) |
| 55 return true; | 55 return true; |
| 56 | 56 |
| 57 // Handle special case for VIEW_ID_TAB_CONTAINER. The tab container NSView |
| 58 // always transfers first responder status to its subview, so test whether |
| 59 // |firstResponder| is a descendant. |
| 60 if (vid == VIEW_ID_TAB_CONTAINER && |
| 61 [firstResponder isKindOfClass:[NSView class]]) |
| 62 return [static_cast<NSView*>(firstResponder) isDescendantOf:view]; |
| 63 |
| 57 // Handle the special case of focusing a TextField. | 64 // Handle the special case of focusing a TextField. |
| 58 if ([firstResponder isKindOfClass:[NSTextView class]]) { | 65 if ([firstResponder isKindOfClass:[NSTextView class]]) { |
| 59 NSView* delegate = static_cast<NSView*>([(NSTextView*)firstResponder | 66 NSView* delegate = static_cast<NSView*>([(NSTextView*)firstResponder |
| 60 delegate]); | 67 delegate]); |
| 61 if (delegate == view) | 68 if (delegate == view) |
| 62 return true; | 69 return true; |
| 63 } | 70 } |
| 64 | 71 |
| 65 return false; | 72 return false; |
| 66 } | 73 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 94 // Make sure an unbundled program can get the input focus. | 101 // Make sure an unbundled program can get the input focus. |
| 95 ProcessSerialNumber psn = { 0, kCurrentProcess }; | 102 ProcessSerialNumber psn = { 0, kCurrentProcess }; |
| 96 TransformProcessType(&psn,kProcessTransformToForegroundApplication); | 103 TransformProcessType(&psn,kProcessTransformToForegroundApplication); |
| 97 SetFrontProcess(&psn); | 104 SetFrontProcess(&psn); |
| 98 | 105 |
| 99 [window makeKeyAndOrderFront:nil]; | 106 [window makeKeyAndOrderFront:nil]; |
| 100 return true; | 107 return true; |
| 101 } | 108 } |
| 102 | 109 |
| 103 } // namespace ui_test_utils | 110 } // namespace ui_test_utils |
| OLD | NEW |