| OLD | NEW |
| 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 Loading... |
| 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 // Update window layout according to existing layout constraints. |
| 116 [window_ layoutIfNeeded]; |
| 116 id controller = [OCMockObject mockForClass:[BrowserWindowController class]]; | 117 id controller = [OCMockObject mockForClass:[BrowserWindowController class]]; |
| 117 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] | 118 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] |
| 118 isKindOfClass:[BrowserWindowController class]]; | 119 isKindOfClass:[BrowserWindowController class]]; |
| 119 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTabStrip]; | 120 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTabStrip]; |
| 120 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTitleBar]; | 121 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTitleBar]; |
| 121 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] isTabbedWindow]; | 122 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] isTabbedWindow]; |
| 122 [window_ setWindowController:controller]; | 123 [window_ setWindowController:controller]; |
| 123 | 124 |
| 124 NSView* closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; | 125 NSView* closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; |
| 125 EXPECT_TRUE(closeBoxControl); | 126 EXPECT_TRUE(closeBoxControl); |
| 126 NSRect closeBoxFrame = [closeBoxControl frame]; | 127 NSRect closeBoxFrame = [closeBoxControl convertRect:[closeBoxControl bounds] |
| 128 toView:nil]; |
| 127 NSRect windowBounds = [window_ frame]; | 129 NSRect windowBounds = [window_ frame]; |
| 128 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; | 130 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; |
| 129 windowBounds.origin = NSZeroPoint; | 131 windowBounds.origin = NSZeroPoint; |
| 130 EXPECT_EQ(NSMaxY(closeBoxFrame), | 132 EXPECT_EQ(NSMaxY(closeBoxFrame), |
| 131 NSMaxY(windowBounds) - | 133 NSMaxY(windowBounds) - |
| 132 kFramedWindowButtonsWithoutTabStripOffsetFromTop); | 134 kFramedWindowButtonsWithoutTabStripOffsetFromTop); |
| 133 EXPECT_EQ(NSMinX(closeBoxFrame), | 135 EXPECT_EQ(NSMinX(closeBoxFrame), |
| 134 kFramedWindowButtonsWithoutTabStripOffsetFromLeft); | 136 kFramedWindowButtonsWithoutTabStripOffsetFromLeft); |
| 135 | 137 |
| 136 NSView* miniaturizeControl = | 138 NSView* miniaturizeControl = |
| 137 [window_ standardWindowButton:NSWindowMiniaturizeButton]; | 139 [window_ standardWindowButton:NSWindowMiniaturizeButton]; |
| 138 EXPECT_TRUE(miniaturizeControl); | 140 EXPECT_TRUE(miniaturizeControl); |
| 139 NSRect miniaturizeFrame = [miniaturizeControl frame]; | 141 NSRect miniaturizeFrame = |
| 142 [miniaturizeControl convertRect:[miniaturizeControl bounds] |
| 143 toView:nil]; |
| 140 EXPECT_EQ(NSMaxY(miniaturizeFrame), | 144 EXPECT_EQ(NSMaxY(miniaturizeFrame), |
| 141 NSMaxY(windowBounds) - | 145 NSMaxY(windowBounds) - |
| 142 kFramedWindowButtonsWithoutTabStripOffsetFromTop); | 146 kFramedWindowButtonsWithoutTabStripOffsetFromTop); |
| 143 EXPECT_EQ(NSMinX(miniaturizeFrame), | 147 EXPECT_EQ(NSMinX(miniaturizeFrame), |
| 144 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); | 148 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); |
| 145 [window_ setWindowController:nil]; | 149 [window_ setWindowController:nil]; |
| 146 | 150 |
| 147 // Then with a tabstrip. | 151 // Then with a tabstrip. |
| 148 [window_ close]; | 152 [window_ close]; |
| 149 window_ = [[FramedBrowserWindow alloc] | 153 window_ = [[FramedBrowserWindow alloc] |
| 150 initWithContentRect:NSMakeRect(0, 0, 800, 600) | 154 initWithContentRect:NSMakeRect(0, 0, 800, 600) |
| 151 hasTabStrip:YES]; | 155 hasTabStrip:YES]; |
| 156 // Update window layout according to existing layout constraints. |
| 157 [window_ layoutIfNeeded]; |
| 152 controller = [OCMockObject mockForClass:[BrowserWindowController class]]; | 158 controller = [OCMockObject mockForClass:[BrowserWindowController class]]; |
| 153 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] | 159 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] |
| 154 isKindOfClass:[BrowserWindowController class]]; | 160 isKindOfClass:[BrowserWindowController class]]; |
| 155 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip]; | 161 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip]; |
| 156 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar]; | 162 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar]; |
| 157 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow]; | 163 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow]; |
| 158 [window_ setWindowController:controller]; | 164 [window_ setWindowController:controller]; |
| 159 | 165 |
| 160 closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; | 166 closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; |
| 161 EXPECT_TRUE(closeBoxControl); | 167 EXPECT_TRUE(closeBoxControl); |
| 162 closeBoxFrame = [closeBoxControl frame]; | 168 closeBoxFrame = [closeBoxControl convertRect:[closeBoxControl bounds] |
| 169 toView:nil]; |
| 163 windowBounds = [window_ frame]; | 170 windowBounds = [window_ frame]; |
| 164 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; | 171 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; |
| 165 windowBounds.origin = NSZeroPoint; | 172 windowBounds.origin = NSZeroPoint; |
| 166 EXPECT_EQ(NSMaxY(closeBoxFrame), | 173 EXPECT_EQ(NSMaxY(closeBoxFrame), |
| 167 NSMaxY(windowBounds) - | 174 NSMaxY(windowBounds) - |
| 168 kFramedWindowButtonsWithTabStripOffsetFromTop); | 175 kFramedWindowButtonsWithTabStripOffsetFromTop); |
| 169 EXPECT_EQ(NSMinX(closeBoxFrame), | 176 EXPECT_EQ(NSMinX(closeBoxFrame), |
| 170 kFramedWindowButtonsWithTabStripOffsetFromLeft); | 177 kFramedWindowButtonsWithTabStripOffsetFromLeft); |
| 171 | 178 |
| 172 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton]; | 179 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton]; |
| 173 EXPECT_TRUE(miniaturizeControl); | 180 EXPECT_TRUE(miniaturizeControl); |
| 174 miniaturizeFrame = [miniaturizeControl frame]; | 181 miniaturizeFrame = [miniaturizeControl convertRect:[miniaturizeControl bounds] |
| 182 toView:nil]; |
| 175 EXPECT_EQ(NSMaxY(miniaturizeFrame), | 183 EXPECT_EQ(NSMaxY(miniaturizeFrame), |
| 176 NSMaxY(windowBounds) - | 184 NSMaxY(windowBounds) - |
| 177 kFramedWindowButtonsWithTabStripOffsetFromTop); | 185 kFramedWindowButtonsWithTabStripOffsetFromTop); |
| 178 EXPECT_EQ(NSMinX(miniaturizeFrame), | 186 EXPECT_EQ(NSMinX(miniaturizeFrame), |
| 179 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); | 187 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); |
| 180 [window_ setWindowController:nil]; | 188 [window_ setWindowController:nil]; |
| 181 } | 189 } |
| OLD | NEW |