Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: ui/views/widget/native_widget_mac_unittest.mm

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/view_unittest.cc ('k') | ui/views/widget/root_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/views/view_unittest.cc ('k') | ui/views/widget/root_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698