Chromium Code Reviews| Index: ui/views/widget/native_widget_mac_unittest.mm |
| diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm |
| index 0783ac078c3a1a454fdd1ee49c89f9f0e1b1dd5f..2632c77cffb1f868883adac1b8a3c2c58b5893dc 100644 |
| --- a/ui/views/widget/native_widget_mac_unittest.mm |
| +++ b/ui/views/widget/native_widget_mac_unittest.mm |
| @@ -71,6 +71,9 @@ |
| @property(assign, nonatomic) NSRect lastDirtyRect; |
| @end |
| +@interface FocusableTestNSView : NSView |
| +@end |
| + |
| namespace views { |
| namespace test { |
| @@ -1309,6 +1312,30 @@ TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Borderless) { |
| widget->CloseNow(); |
| } |
| +TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) { |
|
tapted
2016/03/07 00:12:42
nit: comment before to explain the test, e.g.
//
|
| + Widget* widget = CreateTopLevelPlatformWidget(); |
| + widget->GetRootView()->SetFocusable(true); |
| + widget->Show(); |
| + |
| + base::scoped_nsobject<NSView> child_view([[FocusableTestNSView alloc] |
| + initWithFrame:[widget->GetNativeView() bounds]]); |
| + [widget->GetNativeView() addSubview:child_view]; |
| + EXPECT_TRUE([child_view acceptsFirstResponder]); |
| + EXPECT_TRUE(widget->GetRootView()->IsFocusable()); |
| + |
| + FocusManager* manager = widget->GetFocusManager(); |
| + manager->SetFocusedView(widget->GetRootView()); |
| + EXPECT_EQ(manager->GetFocusedView(), widget->GetRootView()); |
| + |
| + [widget->GetNativeWindow() makeFirstResponder:child_view]; |
| + EXPECT_FALSE(manager->GetFocusedView()); |
| + |
| + [widget->GetNativeWindow() makeFirstResponder:widget->GetNativeView()]; |
| + EXPECT_EQ(manager->GetFocusedView(), widget->GetRootView()); |
| + |
| + widget->CloseNow(); |
| +} |
| + |
| } // namespace test |
| } // namespace views |
| @@ -1340,3 +1367,9 @@ TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Borderless) { |
| } |
| @end |
| + |
| +@implementation FocusableTestNSView |
| +- (BOOL)acceptsFirstResponder { |
| + return YES; |
| +} |
| +@end |