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

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

Issue 2393843002: MacViews: Implement CloseNow() as just -[NSWindow close]. (Closed)
Patch Set: Respond to comments Created 4 years, 2 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/widget/native_widget_mac.mm ('k') | no next file » | 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_nsautorelease_pool.h" 10 #import "base/mac/scoped_nsautorelease_pool.h"
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 parent_nswindow_.reset([[child->GetNativeWindow() parentWindow] retain]); 1147 parent_nswindow_.reset([[child->GetNativeWindow() parentWindow] retain]);
1148 EXPECT_TRUE(parent_nswindow_); 1148 EXPECT_TRUE(parent_nswindow_);
1149 EXPECT_TRUE([parent_nswindow_ delegate]); 1149 EXPECT_TRUE([parent_nswindow_ delegate]);
1150 } 1150 }
1151 1151
1152 ~ParentCloseMonitor() override { 1152 ~ParentCloseMonitor() override {
1153 EXPECT_TRUE(child_closed_); // Otherwise the observer wasn't removed. 1153 EXPECT_TRUE(child_closed_); // Otherwise the observer wasn't removed.
1154 } 1154 }
1155 1155
1156 void OnWidgetDestroying(Widget* child) override { 1156 void OnWidgetDestroying(Widget* child) override {
1157 // Upon a parent-triggered close, the NSWindow relationship will already be 1157 // Upon a parent-triggered close, the NSWindow relationship will still exist
1158 // removed. The parent should still be open (children are always closed 1158 // (it's removed just after OnWidgetDestroying() returns). The parent should
1159 // first), but not have a delegate (since it is being torn down). 1159 // still be open (children are always closed first), but not have a delegate
1160 // (since it is being torn down).
1161 EXPECT_TRUE([child->GetNativeWindow() parentWindow]);
1162 EXPECT_TRUE([parent_nswindow_ isVisible]);
1163 EXPECT_FALSE([parent_nswindow_ delegate]);
1164
1165 EXPECT_FALSE(child_closed_);
1166 }
1167
1168 void OnWidgetDestroyed(Widget* child) override {
1160 EXPECT_FALSE([child->GetNativeWindow() parentWindow]); 1169 EXPECT_FALSE([child->GetNativeWindow() parentWindow]);
1161 EXPECT_TRUE([parent_nswindow_ isVisible]); 1170 EXPECT_TRUE([parent_nswindow_ isVisible]);
1162 EXPECT_FALSE([parent_nswindow_ delegate]); 1171 EXPECT_FALSE([parent_nswindow_ delegate]);
1163 1172
1164 EXPECT_FALSE(child_closed_); 1173 EXPECT_FALSE(child_closed_);
1165 child->RemoveObserver(this); 1174 child->RemoveObserver(this);
1166 child_closed_ = true; 1175 child_closed_ = true;
1167 } 1176 }
1168 1177
1169 bool child_closed() const { return child_closed_; } 1178 bool child_closed() const { return child_closed_; }
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 1802
1794 - (void)dealloc { 1803 - (void)dealloc {
1795 if (deallocFlag_) { 1804 if (deallocFlag_) {
1796 DCHECK(!*deallocFlag_); 1805 DCHECK(!*deallocFlag_);
1797 *deallocFlag_ = true; 1806 *deallocFlag_ = true;
1798 } 1807 }
1799 [super dealloc]; 1808 [super dealloc];
1800 } 1809 }
1801 1810
1802 @end 1811 @end
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698