OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/widget/native_widget_mac.h" | 5 #import "ui/views/widget/native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 // height). | 1344 // height). |
1345 gfx::Rect expected_appkit_bounds(25, 55, 10, 15); | 1345 gfx::Rect expected_appkit_bounds(25, 55, 10, 15); |
1346 EXPECT_NSEQ(expected_appkit_bounds.ToCGRect(), | 1346 EXPECT_NSEQ(expected_appkit_bounds.ToCGRect(), |
1347 [mock_bridged_view lastDirtyRect]); | 1347 [mock_bridged_view lastDirtyRect]); |
1348 widget->CloseNow(); | 1348 widget->CloseNow(); |
1349 } | 1349 } |
1350 | 1350 |
1351 // Ensure traversing NSView focus correctly updates the views::FocusManager. | 1351 // Ensure traversing NSView focus correctly updates the views::FocusManager. |
1352 TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) { | 1352 TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) { |
1353 Widget* widget = CreateTopLevelPlatformWidget(); | 1353 Widget* widget = CreateTopLevelPlatformWidget(); |
1354 widget->GetRootView()->SetFocusable(true); | 1354 widget->GetRootView()->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
1355 widget->Show(); | 1355 widget->Show(); |
1356 | 1356 |
1357 base::scoped_nsobject<NSView> child_view([[FocusableTestNSView alloc] | 1357 base::scoped_nsobject<NSView> child_view([[FocusableTestNSView alloc] |
1358 initWithFrame:[widget->GetNativeView() bounds]]); | 1358 initWithFrame:[widget->GetNativeView() bounds]]); |
1359 [widget->GetNativeView() addSubview:child_view]; | 1359 [widget->GetNativeView() addSubview:child_view]; |
1360 EXPECT_TRUE([child_view acceptsFirstResponder]); | 1360 EXPECT_TRUE([child_view acceptsFirstResponder]); |
1361 EXPECT_TRUE(widget->GetRootView()->IsFocusable()); | 1361 EXPECT_TRUE(widget->GetRootView()->IsFocusable()); |
1362 | 1362 |
1363 FocusManager* manager = widget->GetFocusManager(); | 1363 FocusManager* manager = widget->GetFocusManager(); |
1364 manager->SetFocusedView(widget->GetRootView()); | 1364 manager->SetFocusedView(widget->GetRootView()); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 lastDirtyRect_ = dirtyRect; | 1510 lastDirtyRect_ = dirtyRect; |
1511 } | 1511 } |
1512 | 1512 |
1513 @end | 1513 @end |
1514 | 1514 |
1515 @implementation FocusableTestNSView | 1515 @implementation FocusableTestNSView |
1516 - (BOOL)acceptsFirstResponder { | 1516 - (BOOL)acceptsFirstResponder { |
1517 return YES; | 1517 return YES; |
1518 } | 1518 } |
1519 @end | 1519 @end |
OLD | NEW |