| 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..635de898aed2db3dda2792532f0ebdaa202bde43 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,31 @@ TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Borderless) {
|
| widget->CloseNow();
|
| }
|
|
|
| +// Ensure traversing NSView focus correctly updates the views::FocusManager.
|
| +TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) {
|
| + 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 +1368,9 @@ TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Borderless) {
|
| }
|
|
|
| @end
|
| +
|
| +@implementation FocusableTestNSView
|
| +- (BOOL)acceptsFirstResponder {
|
| + return YES;
|
| +}
|
| +@end
|
|
|