| 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 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 object:native_parent | 1098 object:native_parent |
| 1099 queue:nil | 1099 queue:nil |
| 1100 usingBlock:^(NSNotification* note) { | 1100 usingBlock:^(NSNotification* note) { |
| 1101 // Ensure that before the sheet runs, the window contents would | 1101 // Ensure that before the sheet runs, the window contents would |
| 1102 // be drawn. | 1102 // be drawn. |
| 1103 EXPECT_TRUE(sheet_widget->IsVisible()); | 1103 EXPECT_TRUE(sheet_widget->IsVisible()); |
| 1104 EXPECT_TRUE(sheet_widget->GetLayer()->IsDrawn()); | 1104 EXPECT_TRUE(sheet_widget->GetLayer()->IsDrawn()); |
| 1105 *did_observe_ptr = true; | 1105 *did_observe_ptr = true; |
| 1106 }]; | 1106 }]; |
| 1107 | 1107 |
| 1108 Widget::Widgets children; |
| 1109 Widget::GetAllChildWidgets([native_parent contentView], &children); |
| 1110 EXPECT_TRUE(children.empty()); |
| 1111 |
| 1108 sheet_widget->Show(); // Should run the above block, then animate the sheet. | 1112 sheet_widget->Show(); // Should run the above block, then animate the sheet. |
| 1109 EXPECT_TRUE(did_observe); | 1113 EXPECT_TRUE(did_observe); |
| 1110 [[NSNotificationCenter defaultCenter] removeObserver:observer]; | 1114 [[NSNotificationCenter defaultCenter] removeObserver:observer]; |
| 1111 | 1115 |
| 1116 // Ensure sheets are included as a child. |
| 1117 Widget::GetAllChildWidgets([native_parent contentView], &children); |
| 1118 ASSERT_EQ(1u, children.size()); |
| 1119 EXPECT_EQ(sheet_widget, *children.begin()); |
| 1120 |
| 1112 // Modal, so the close button in the parent window should get disabled. | 1121 // Modal, so the close button in the parent window should get disabled. |
| 1113 EXPECT_FALSE([parent_close_button isEnabled]); | 1122 EXPECT_FALSE([parent_close_button isEnabled]); |
| 1114 | 1123 |
| 1115 // The sheet should be hidden and shown in step with the parent. | 1124 // The sheet should be hidden and shown in step with the parent. |
| 1116 widget_observer.WaitForVisibleCounts(1, 0); | 1125 widget_observer.WaitForVisibleCounts(1, 0); |
| 1117 EXPECT_TRUE(sheet_widget->IsVisible()); | 1126 EXPECT_TRUE(sheet_widget->IsVisible()); |
| 1118 | 1127 |
| 1119 // TODO(tapted): Ideally [native_parent orderOut:nil] would also work here. | 1128 // TODO(tapted): Ideally [native_parent orderOut:nil] would also work here. |
| 1120 // But it does not. AppKit's childWindow management breaks down after an | 1129 // But it does not. AppKit's childWindow management breaks down after an |
| 1121 // -orderOut: (see BridgedNativeWidget::OnVisibilityChanged()). For regular | 1130 // -orderOut: (see BridgedNativeWidget::OnVisibilityChanged()). For regular |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1909 | 1918 |
| 1910 - (void)dealloc { | 1919 - (void)dealloc { |
| 1911 if (deallocFlag_) { | 1920 if (deallocFlag_) { |
| 1912 DCHECK(!*deallocFlag_); | 1921 DCHECK(!*deallocFlag_); |
| 1913 *deallocFlag_ = true; | 1922 *deallocFlag_ = true; |
| 1914 } | 1923 } |
| 1915 [super dealloc]; | 1924 [super dealloc]; |
| 1916 } | 1925 } |
| 1917 | 1926 |
| 1918 @end | 1927 @end |
| OLD | NEW |