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 a320ad3e873dd3f2cf0e562f1550123ed7d98e1d..ca549c9695f344043cd117a2eda849367a64bdc6 100644 |
--- a/ui/views/widget/native_widget_mac_unittest.mm |
+++ b/ui/views/widget/native_widget_mac_unittest.mm |
@@ -373,6 +373,56 @@ class PaintCountView : public View { |
DISALLOW_COPY_AND_ASSIGN(PaintCountView); |
}; |
+// Test for correct child window restore when parent window is minimized |
+// and restored using makeKeyAndOrderFront. |
tapted
2016/06/22 04:09:15
nit: -makeKeyAndOrderFront:.
kirr
2016/06/22 12:59:03
Done.
|
+// Child window could become occluded (because of cocoa bug?). |
tapted
2016/06/22 04:09:14
You can say:
Parent-child window relationships i
kirr
2016/06/22 12:59:03
Done.
|
+TEST_F(NativeWidgetMacTest, OrderFrontAfterMiniturize) { |
tapted
2016/06/22 04:09:14
Miniturize -> Miniaturize (or Minimize)
kirr
2016/06/22 12:59:04
Done.
|
+ Widget* widget = new Widget; |
tapted
2016/06/22 04:09:14
You should be able to avoid using InitParams with
kirr
2016/06/22 12:59:04
Done.
|
+ Widget::InitParams init_params(Widget::InitParams::TYPE_WINDOW); |
+ widget->Init(init_params); |
+ NSWindow* ns_window = widget->GetNativeWindow(); |
+ |
+ Widget* child_widget = new Widget; |
tapted
2016/06/22 04:09:14
Widget* child = CreateChildPlatformWidget(widget->
kirr
2016/06/22 12:59:04
Done.
|
+ Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); |
+ child_params.parent = widget->GetNativeView(); |
+ child_widget->Init(child_params); |
+ NSWindow* child_ns_window = child_widget->GetNativeWindow(); |
+ |
+ // Set parent bounds that overlap child. |
+ widget->SetBounds(gfx::Rect(100, 100, 300, 300)); |
+ child_widget->SetBounds(gfx::Rect(110, 110, 100, 100)); |
tapted
2016/06/22 04:09:14
note with TYPE_CONTROL, I think the bounds will be
|
+ |
+ widget->Show(); |
tapted
2016/06/22 04:09:14
show the child too?
kirr
2016/06/22 12:59:04
I think no.
Test visually works fine without it.
B
tapted
2016/06/23 12:09:26
hm - I'm pretty sure you need to show it. It's val
|
+ base::RunLoop().RunUntilIdle(); |
tapted
2016/06/22 04:09:14
is this needed?
kirr
2016/06/22 12:59:04
Yes, seems like it is also related to window activ
|
+ |
+ EXPECT_FALSE(widget->IsMinimized()); |
+ |
+ // Minimize parent. |
+ [ns_window performMiniaturize:nil]; |
+ base::RunLoop().RunUntilIdle(); |
tapted
2016/06/22 04:09:14
this shouldn't be needed - miniaturize is synchron
kirr
2016/06/22 12:59:04
It's also not for the expectations below, bot for
|
+ |
+ EXPECT_TRUE(widget->IsMinimized()); |
+ EXPECT_FALSE(widget->IsVisible()); |
+ EXPECT_FALSE(child_widget->IsVisible()); |
+ |
+ // Restore parent window as AppController does. |
+ [ns_window makeKeyAndOrderFront:nil]; |
+ |
+ // Wait and check that child is really visible. |
+ // TODO(kirr): remove the fixed timeout. |
+ base::MessageLoop::current()->PostDelayedTask( |
kirr
2016/06/21 16:33:47
I've added the test to show the problem.
But I don
tapted
2016/06/22 04:09:14
Can you get a stack trace from the visibility chan
kirr
2016/06/22 12:59:04
Here is NSNotifications trace for the test (+ orde
tapted
2016/06/23 12:09:26
You can get the stack with something like base::de
|
+ FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
+ base::TimeDelta::FromSeconds(2)); |
+ base::MessageLoop::current()->Run(); |
+ |
+ EXPECT_FALSE(widget->IsMinimized()); |
+ EXPECT_TRUE(widget->IsVisible()); |
+ EXPECT_TRUE(child_widget->IsVisible()); |
+ // Check that child window is visible. |
+ EXPECT_TRUE([child_ns_window occlusionState] & NSWindowOcclusionStateVisible); |
tapted
2016/06/22 04:09:14
ah, occlusion states are updated from the window s
kirr
2016/06/22 12:59:04
WidgetTest::IsWindowStackedAbove(..) returns the s
tapted
2016/06/23 12:09:25
So, like you probably saw, we can't guarantee that
kirr
2016/06/23 16:20:11
Ok, I agree that we can't commit with a fixed dela
|
+ widget->Close(); |
+} |
+ |
// Test minimized states triggered externally, implied visibility and restored |
// bounds whilst minimized. |
TEST_F(NativeWidgetMacTest, MiniaturizeExternally) { |
@@ -930,8 +980,6 @@ TEST_F(NativeWidgetMacTest, WindowModalSheet) { |
queue:nil |
usingBlock:^(NSNotification* note) { |
EXPECT_TRUE([sheet_window delegate]); |
- EXPECT_FALSE(sheet_widget->IsVisible()); |
- EXPECT_FALSE(sheet_widget->GetLayer()->IsDrawn()); |
*did_observe_ptr = true; |
}]; |