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

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

Issue 2069103004: MacViews: Attach child windows when parent is on the screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits in test. Created 4 years, 6 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
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 int paint_count() { return paint_count_; } 366 int paint_count() { return paint_count_; }
367 367
368 private: 368 private:
369 int paint_count_ = 0; 369 int paint_count_ = 0;
370 int target_paint_count_ = 0; 370 int target_paint_count_ = 0;
371 base::RunLoop* run_loop_ = nullptr; 371 base::RunLoop* run_loop_ = nullptr;
372 372
373 DISALLOW_COPY_AND_ASSIGN(PaintCountView); 373 DISALLOW_COPY_AND_ASSIGN(PaintCountView);
374 }; 374 };
375 375
376 // Test for correct child window restore when parent window is minimized
377 // and restored using -makeKeyAndOrderFront:.
378 // Parent-child window relationships in AppKit are not supported when window
379 // visibility changes.
380 TEST_F(NativeWidgetMacTest, OrderFrontAfterMiniaturize) {
tapted 2016/06/30 12:02:37 Let's just make this DISABLED_OrderFrontAfterMinia
381 Widget* widget = CreateTopLevelPlatformWidget();
382 NSWindow* ns_window = widget->GetNativeWindow();
383
384 Widget* child_widget = CreateChildPlatformWidget(widget->GetNativeView());
385 NSWindow* child_ns_window = child_widget->GetNativeWindow();
386
387 // Set parent bounds that overlap child.
388 widget->SetBounds(gfx::Rect(100, 100, 300, 300));
389 child_widget->SetBounds(gfx::Rect(110, 110, 100, 100));
390
391 widget->Show();
392 base::RunLoop().RunUntilIdle();
393
394 EXPECT_FALSE(widget->IsMinimized());
395
396 // Minimize parent.
397 [ns_window performMiniaturize:nil];
398 base::RunLoop().RunUntilIdle();
399
400 EXPECT_TRUE(widget->IsMinimized());
401 EXPECT_FALSE(widget->IsVisible());
402 EXPECT_FALSE(child_widget->IsVisible());
403
404 // Restore parent window as AppController does.
405 [ns_window makeKeyAndOrderFront:nil];
406
407 // Wait and check that child is really visible.
408 // TODO(kirr): remove the fixed delay.
409 base::MessageLoop::current()->PostDelayedTask(
410 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
411 base::TimeDelta::FromSeconds(2));
412 base::MessageLoop::current()->Run();
413
414 EXPECT_FALSE(widget->IsMinimized());
415 EXPECT_TRUE(widget->IsVisible());
416 EXPECT_TRUE(child_widget->IsVisible());
417 // Check that child window is visible.
418 EXPECT_TRUE([child_ns_window occlusionState] & NSWindowOcclusionStateVisible);
419 EXPECT_TRUE(IsWindowStackedAbove(child_widget, widget));
420 widget->Close();
421 }
422
376 // Test minimized states triggered externally, implied visibility and restored 423 // Test minimized states triggered externally, implied visibility and restored
377 // bounds whilst minimized. 424 // bounds whilst minimized.
378 TEST_F(NativeWidgetMacTest, MiniaturizeExternally) { 425 TEST_F(NativeWidgetMacTest, MiniaturizeExternally) {
379 Widget* widget = new Widget; 426 Widget* widget = new Widget;
380 Widget::InitParams init_params(Widget::InitParams::TYPE_WINDOW); 427 Widget::InitParams init_params(Widget::InitParams::TYPE_WINDOW);
381 widget->Init(init_params); 428 widget->Init(init_params);
382 429
383 PaintCountView* view = new PaintCountView(); 430 PaintCountView* view = new PaintCountView();
384 widget->GetContentsView()->AddChildView(view); 431 widget->GetContentsView()->AddChildView(view);
385 NSWindow* ns_window = widget->GetNativeWindow(); 432 NSWindow* ns_window = widget->GetNativeWindow();
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 // -[NSWindow orderOut:] call that is triggered from -[ViewsNSWindowDelegate 970 // -[NSWindow orderOut:] call that is triggered from -[ViewsNSWindowDelegate
924 // sheetDidEnd:]. |sheet_widget| will be destroyed next, so it's still safe to 971 // sheetDidEnd:]. |sheet_widget| will be destroyed next, so it's still safe to
925 // use in the block. However, since the orderOut just happened, it's not very 972 // use in the block. However, since the orderOut just happened, it's not very
926 // interesting. 973 // interesting.
927 observer = [[NSNotificationCenter defaultCenter] 974 observer = [[NSNotificationCenter defaultCenter]
928 addObserverForName:NSWindowDidEndSheetNotification 975 addObserverForName:NSWindowDidEndSheetNotification
929 object:native_parent 976 object:native_parent
930 queue:nil 977 queue:nil
931 usingBlock:^(NSNotification* note) { 978 usingBlock:^(NSNotification* note) {
932 EXPECT_TRUE([sheet_window delegate]); 979 EXPECT_TRUE([sheet_window delegate]);
933 EXPECT_FALSE(sheet_widget->IsVisible());
934 EXPECT_FALSE(sheet_widget->GetLayer()->IsDrawn());
935 *did_observe_ptr = true; 980 *did_observe_ptr = true;
936 }]; 981 }];
937 982
938 // Pump in order to trigger -[NSWindow endSheet:..], which will block while 983 // Pump in order to trigger -[NSWindow endSheet:..], which will block while
939 // the animation runs, then delete |sheet_widget|. 984 // the animation runs, then delete |sheet_widget|.
940 TestWidgetObserver widget_observer(sheet_widget); 985 TestWidgetObserver widget_observer(sheet_widget);
941 EXPECT_TRUE([sheet_window delegate]); 986 EXPECT_TRUE([sheet_window delegate]);
942 base::RunLoop().RunUntilIdle(); 987 base::RunLoop().RunUntilIdle();
943 EXPECT_FALSE([sheet_window delegate]); 988 EXPECT_FALSE([sheet_window delegate]);
944 989
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 lastDirtyRect_ = dirtyRect; 1630 lastDirtyRect_ = dirtyRect;
1586 } 1631 }
1587 1632
1588 @end 1633 @end
1589 1634
1590 @implementation FocusableTestNSView 1635 @implementation FocusableTestNSView
1591 - (BOOL)acceptsFirstResponder { 1636 - (BOOL)acceptsFirstResponder {
1592 return YES; 1637 return YES;
1593 } 1638 }
1594 @end 1639 @end
OLDNEW
« ui/views/cocoa/bridged_native_widget.h ('K') | « ui/views/cocoa/views_nswindow_delegate.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698