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

Side by Side Diff: chrome/browser/ui/cocoa/framed_browser_window_unittest.mm

Issue 2418703002: [mac] Fixed FramedBrowserWindowTest.WindowWidgetLocation. (Closed)
Patch Set: Removed extra logs 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 | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/debug/debugger.h" 7 #include "base/debug/debugger.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 [window_ display]; 96 [window_ display];
97 NSData* hiddenTitleData = WindowContentsAsTIFF(); 97 NSData* hiddenTitleData = WindowContentsAsTIFF();
98 98
99 // With our magic setting, the window with a title should look the 99 // With our magic setting, the window with a title should look the
100 // same as the window with an empty title. 100 // same as the window with an empty title.
101 EXPECT_TRUE([window_ _isTitleHidden]); 101 EXPECT_TRUE([window_ _isTitleHidden]);
102 EXPECT_TRUE([emptyTitleData isEqualToData:hiddenTitleData]); 102 EXPECT_TRUE([emptyTitleData isEqualToData:hiddenTitleData]);
103 } 103 }
104 104
105 // Test to make sure that our window widgets are in the right place. 105 // Test to make sure that our window widgets are in the right place.
106 // TODO(crbug.com/655112): Fails on Mac 10.11 Tests. 106 TEST_F(FramedBrowserWindowTest, WindowWidgetLocation) {
107 TEST_F(FramedBrowserWindowTest, DISABLED_WindowWidgetLocation) {
108 BOOL yes = YES; 107 BOOL yes = YES;
109 BOOL no = NO; 108 BOOL no = NO;
110 109
111 // First without a tabstrip. 110 // First without a tabstrip.
112 [window_ close]; 111 [window_ close];
113 window_ = [[FramedBrowserWindow alloc] 112 window_ = [[FramedBrowserWindow alloc]
114 initWithContentRect:NSMakeRect(0, 0, 800, 600) 113 initWithContentRect:NSMakeRect(0, 0, 800, 600)
115 hasTabStrip:NO]; 114 hasTabStrip:NO];
115 [window_ layoutIfNeeded];
erikchen 2016/10/13 21:57:54 Why is this necessary? Is it because when I presen
Eugene But (OOO till 7-30) 2016/10/13 22:03:26 Yes, layout constraints are not kicked in otherwis
116 id controller = [OCMockObject mockForClass:[BrowserWindowController class]]; 116 id controller = [OCMockObject mockForClass:[BrowserWindowController class]];
117 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] 117 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)]
118 isKindOfClass:[BrowserWindowController class]]; 118 isKindOfClass:[BrowserWindowController class]];
119 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTabStrip]; 119 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTabStrip];
120 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTitleBar]; 120 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTitleBar];
121 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] isTabbedWindow]; 121 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] isTabbedWindow];
122 [window_ setWindowController:controller]; 122 [window_ setWindowController:controller];
123 123
124 NSView* closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; 124 NSView* closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton];
125 EXPECT_TRUE(closeBoxControl); 125 EXPECT_TRUE(closeBoxControl);
126 NSRect closeBoxFrame = [closeBoxControl frame]; 126 NSRect closeBoxFrame = [closeBoxControl convertRect:[closeBoxControl bounds]
127 toView:nil];
127 NSRect windowBounds = [window_ frame]; 128 NSRect windowBounds = [window_ frame];
128 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; 129 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil];
129 windowBounds.origin = NSZeroPoint; 130 windowBounds.origin = NSZeroPoint;
130 EXPECT_EQ(NSMaxY(closeBoxFrame), 131 EXPECT_EQ(NSMaxY(closeBoxFrame),
131 NSMaxY(windowBounds) - 132 NSMaxY(windowBounds) -
132 kFramedWindowButtonsWithoutTabStripOffsetFromTop); 133 kFramedWindowButtonsWithoutTabStripOffsetFromTop);
133 EXPECT_EQ(NSMinX(closeBoxFrame), 134 EXPECT_EQ(NSMinX(closeBoxFrame),
134 kFramedWindowButtonsWithoutTabStripOffsetFromLeft); 135 kFramedWindowButtonsWithoutTabStripOffsetFromLeft);
135 136
136 NSView* miniaturizeControl = 137 NSView* miniaturizeControl =
137 [window_ standardWindowButton:NSWindowMiniaturizeButton]; 138 [window_ standardWindowButton:NSWindowMiniaturizeButton];
138 EXPECT_TRUE(miniaturizeControl); 139 EXPECT_TRUE(miniaturizeControl);
139 NSRect miniaturizeFrame = [miniaturizeControl frame]; 140 NSRect miniaturizeFrame =
141 [miniaturizeControl convertRect:[miniaturizeControl bounds]
142 toView:nil];
140 EXPECT_EQ(NSMaxY(miniaturizeFrame), 143 EXPECT_EQ(NSMaxY(miniaturizeFrame),
141 NSMaxY(windowBounds) - 144 NSMaxY(windowBounds) -
142 kFramedWindowButtonsWithoutTabStripOffsetFromTop); 145 kFramedWindowButtonsWithoutTabStripOffsetFromTop);
143 EXPECT_EQ(NSMinX(miniaturizeFrame), 146 EXPECT_EQ(NSMinX(miniaturizeFrame),
144 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); 147 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]);
145 [window_ setWindowController:nil]; 148 [window_ setWindowController:nil];
146 149
147 // Then with a tabstrip. 150 // Then with a tabstrip.
148 [window_ close]; 151 [window_ close];
149 window_ = [[FramedBrowserWindow alloc] 152 window_ = [[FramedBrowserWindow alloc]
150 initWithContentRect:NSMakeRect(0, 0, 800, 600) 153 initWithContentRect:NSMakeRect(0, 0, 800, 600)
151 hasTabStrip:YES]; 154 hasTabStrip:YES];
155 [window_ layoutIfNeeded];
152 controller = [OCMockObject mockForClass:[BrowserWindowController class]]; 156 controller = [OCMockObject mockForClass:[BrowserWindowController class]];
153 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] 157 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)]
154 isKindOfClass:[BrowserWindowController class]]; 158 isKindOfClass:[BrowserWindowController class]];
155 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip]; 159 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip];
156 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar]; 160 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar];
157 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow]; 161 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow];
158 [window_ setWindowController:controller]; 162 [window_ setWindowController:controller];
159 163
160 closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; 164 closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton];
161 EXPECT_TRUE(closeBoxControl); 165 EXPECT_TRUE(closeBoxControl);
162 closeBoxFrame = [closeBoxControl frame]; 166 closeBoxFrame = [closeBoxControl convertRect:[closeBoxControl bounds]
167 toView:nil];
163 windowBounds = [window_ frame]; 168 windowBounds = [window_ frame];
164 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; 169 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil];
165 windowBounds.origin = NSZeroPoint; 170 windowBounds.origin = NSZeroPoint;
166 EXPECT_EQ(NSMaxY(closeBoxFrame), 171 EXPECT_EQ(NSMaxY(closeBoxFrame),
167 NSMaxY(windowBounds) - 172 NSMaxY(windowBounds) -
168 kFramedWindowButtonsWithTabStripOffsetFromTop); 173 kFramedWindowButtonsWithTabStripOffsetFromTop);
169 EXPECT_EQ(NSMinX(closeBoxFrame), 174 EXPECT_EQ(NSMinX(closeBoxFrame),
170 kFramedWindowButtonsWithTabStripOffsetFromLeft); 175 kFramedWindowButtonsWithTabStripOffsetFromLeft);
171 176
172 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton]; 177 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton];
173 EXPECT_TRUE(miniaturizeControl); 178 EXPECT_TRUE(miniaturizeControl);
174 miniaturizeFrame = [miniaturizeControl frame]; 179 miniaturizeFrame = [miniaturizeControl convertRect:[miniaturizeControl bounds]
180 toView:nil];
175 EXPECT_EQ(NSMaxY(miniaturizeFrame), 181 EXPECT_EQ(NSMaxY(miniaturizeFrame),
176 NSMaxY(windowBounds) - 182 NSMaxY(windowBounds) -
177 kFramedWindowButtonsWithTabStripOffsetFromTop); 183 kFramedWindowButtonsWithTabStripOffsetFromTop);
178 EXPECT_EQ(NSMinX(miniaturizeFrame), 184 EXPECT_EQ(NSMinX(miniaturizeFrame),
179 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); 185 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]);
180 [window_ setWindowController:nil]; 186 [window_ setWindowController:nil];
181 } 187 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698