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 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 // height). | 1333 // height). |
1334 gfx::Rect expected_appkit_bounds(25, 55, 10, 15); | 1334 gfx::Rect expected_appkit_bounds(25, 55, 10, 15); |
1335 EXPECT_NSEQ(expected_appkit_bounds.ToCGRect(), | 1335 EXPECT_NSEQ(expected_appkit_bounds.ToCGRect(), |
1336 [mock_bridged_view lastDirtyRect]); | 1336 [mock_bridged_view lastDirtyRect]); |
1337 widget->CloseNow(); | 1337 widget->CloseNow(); |
1338 } | 1338 } |
1339 | 1339 |
1340 // Ensure traversing NSView focus correctly updates the views::FocusManager. | 1340 // Ensure traversing NSView focus correctly updates the views::FocusManager. |
1341 TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) { | 1341 TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) { |
1342 Widget* widget = CreateTopLevelPlatformWidget(); | 1342 Widget* widget = CreateTopLevelPlatformWidget(); |
1343 widget->GetRootView()->SetFocusable(true); | 1343 widget->GetRootView()->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); |
1344 widget->Show(); | 1344 widget->Show(); |
1345 | 1345 |
1346 base::scoped_nsobject<NSView> child_view([[FocusableTestNSView alloc] | 1346 base::scoped_nsobject<NSView> child_view([[FocusableTestNSView alloc] |
1347 initWithFrame:[widget->GetNativeView() bounds]]); | 1347 initWithFrame:[widget->GetNativeView() bounds]]); |
1348 [widget->GetNativeView() addSubview:child_view]; | 1348 [widget->GetNativeView() addSubview:child_view]; |
1349 EXPECT_TRUE([child_view acceptsFirstResponder]); | 1349 EXPECT_TRUE([child_view acceptsFirstResponder]); |
1350 EXPECT_TRUE(widget->GetRootView()->IsFocusable()); | 1350 EXPECT_TRUE(widget->GetRootView()->IsFocusable()); |
1351 | 1351 |
1352 FocusManager* manager = widget->GetFocusManager(); | 1352 FocusManager* manager = widget->GetFocusManager(); |
1353 manager->SetFocusedView(widget->GetRootView()); | 1353 manager->SetFocusedView(widget->GetRootView()); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 lastDirtyRect_ = dirtyRect; | 1499 lastDirtyRect_ = dirtyRect; |
1500 } | 1500 } |
1501 | 1501 |
1502 @end | 1502 @end |
1503 | 1503 |
1504 @implementation FocusableTestNSView | 1504 @implementation FocusableTestNSView |
1505 - (BOOL)acceptsFirstResponder { | 1505 - (BOOL)acceptsFirstResponder { |
1506 return YES; | 1506 return YES; |
1507 } | 1507 } |
1508 @end | 1508 @end |
OLD | NEW |