Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_nsobject.h" | 8 #include "base/memory/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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 NSData* hiddenTitleData = WindowContentsAsTIFF(); | 93 NSData* hiddenTitleData = WindowContentsAsTIFF(); |
| 94 | 94 |
| 95 // With our magic setting, the window with a title should look the | 95 // With our magic setting, the window with a title should look the |
| 96 // same as the window with an empty title. | 96 // same as the window with an empty title. |
| 97 EXPECT_TRUE([window_ _isTitleHidden]); | 97 EXPECT_TRUE([window_ _isTitleHidden]); |
| 98 EXPECT_TRUE([emptyTitleData isEqualToData:hiddenTitleData]); | 98 EXPECT_TRUE([emptyTitleData isEqualToData:hiddenTitleData]); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Test to make sure that our window widgets are in the right place. | 101 // Test to make sure that our window widgets are in the right place. |
| 102 TEST_F(FramedBrowserWindowTest, WindowWidgetLocation) { | 102 TEST_F(FramedBrowserWindowTest, WindowWidgetLocation) { |
| 103 // First without tabstrip. | 103 BOOL yes = YES; |
| 104 BOOL no = NO; | |
| 105 | |
| 106 // First without a tabstrip. | |
| 107 id controller = [OCMockObject mockForClass:[BrowserWindowController class]]; | |
| 108 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] | |
| 109 isKindOfClass:[BrowserWindowController class]]; | |
|
Robert Sesek
2011/11/15 15:22:43
nit: indent 4
| |
| 110 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTabStrip]; | |
| 111 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTitleBar]; | |
| 112 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] isTabbedWindow]; | |
| 113 [window_ setWindowController:controller]; | |
| 114 | |
| 104 NSView* closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; | 115 NSView* closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; |
| 105 EXPECT_TRUE(closeBoxControl); | 116 EXPECT_TRUE(closeBoxControl); |
| 106 NSRect closeBoxFrame = [closeBoxControl frame]; | 117 NSRect closeBoxFrame = [closeBoxControl frame]; |
| 107 NSRect windowBounds = [window_ frame]; | 118 NSRect windowBounds = [window_ frame]; |
| 108 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; | 119 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; |
| 109 windowBounds.origin = NSZeroPoint; | 120 windowBounds.origin = NSZeroPoint; |
| 110 EXPECT_EQ(NSMaxY(closeBoxFrame), | 121 EXPECT_EQ(NSMaxY(closeBoxFrame), |
| 111 NSMaxY(windowBounds) - | 122 NSMaxY(windowBounds) - |
| 112 kFramedWindowButtonsWithoutTabStripOffsetFromTop); | 123 kFramedWindowButtonsWithoutTabStripOffsetFromTop); |
| 113 EXPECT_EQ(NSMinX(closeBoxFrame), | 124 EXPECT_EQ(NSMinX(closeBoxFrame), |
| 114 kFramedWindowButtonsWithoutTabStripOffsetFromLeft); | 125 kFramedWindowButtonsWithoutTabStripOffsetFromLeft); |
| 115 | 126 |
| 116 NSView* miniaturizeControl = | 127 NSView* miniaturizeControl = |
| 117 [window_ standardWindowButton:NSWindowMiniaturizeButton]; | 128 [window_ standardWindowButton:NSWindowMiniaturizeButton]; |
| 118 EXPECT_TRUE(miniaturizeControl); | 129 EXPECT_TRUE(miniaturizeControl); |
| 119 NSRect miniaturizeFrame = [miniaturizeControl frame]; | 130 NSRect miniaturizeFrame = [miniaturizeControl frame]; |
| 120 EXPECT_EQ(NSMaxY(miniaturizeFrame), | 131 EXPECT_EQ(NSMaxY(miniaturizeFrame), |
| 121 NSMaxY(windowBounds) - | 132 NSMaxY(windowBounds) - |
| 122 kFramedWindowButtonsWithoutTabStripOffsetFromTop); | 133 kFramedWindowButtonsWithoutTabStripOffsetFromTop); |
| 123 EXPECT_EQ(NSMinX(miniaturizeFrame), | 134 EXPECT_EQ(NSMinX(miniaturizeFrame), |
| 124 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); | 135 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); |
| 125 | 136 |
| 126 // Then with a tabstrip. | 137 // Then with a tabstrip. |
| 127 id controller = [OCMockObject mockForClass:[BrowserWindowController class]]; | 138 controller = [OCMockObject mockForClass:[BrowserWindowController class]]; |
| 128 BOOL yes = YES; | |
| 129 BOOL no = NO; | |
| 130 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] | 139 [[[controller stub] andReturnValue:OCMOCK_VALUE(yes)] |
| 131 isKindOfClass:[BrowserWindowController class]]; | 140 isKindOfClass:[BrowserWindowController class]]; |
| 132 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip]; | 141 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip]; |
| 133 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar]; | 142 [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar]; |
| 134 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow]; | 143 [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow]; |
| 135 [window_ setWindowController:controller]; | 144 [window_ setWindowController:controller]; |
| 136 | 145 |
| 137 closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; | 146 closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; |
| 138 EXPECT_TRUE(closeBoxControl); | 147 EXPECT_TRUE(closeBoxControl); |
| 139 closeBoxFrame = [closeBoxControl frame]; | 148 closeBoxFrame = [closeBoxControl frame]; |
| 140 windowBounds = [window_ frame]; | 149 windowBounds = [window_ frame]; |
| 141 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; | 150 windowBounds = [[window_ contentView] convertRect:windowBounds fromView:nil]; |
| 142 windowBounds.origin = NSZeroPoint; | 151 windowBounds.origin = NSZeroPoint; |
| 143 EXPECT_EQ(NSMaxY(closeBoxFrame), | 152 EXPECT_EQ(NSMaxY(closeBoxFrame), |
| 144 NSMaxY(windowBounds) - | 153 NSMaxY(windowBounds) - |
| 145 kFramedWindowButtonsWithTabStripOffsetFromTop); | 154 kFramedWindowButtonsWithTabStripOffsetFromTop); |
| 146 EXPECT_EQ(NSMinX(closeBoxFrame), | 155 EXPECT_EQ(NSMinX(closeBoxFrame), |
| 147 kFramedWindowButtonsWithTabStripOffsetFromLeft); | 156 kFramedWindowButtonsWithTabStripOffsetFromLeft); |
| 148 | 157 |
| 149 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton]; | 158 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton]; |
| 150 EXPECT_TRUE(miniaturizeControl); | 159 EXPECT_TRUE(miniaturizeControl); |
| 151 miniaturizeFrame = [miniaturizeControl frame]; | 160 miniaturizeFrame = [miniaturizeControl frame]; |
| 152 EXPECT_EQ(NSMaxY(miniaturizeFrame), | 161 EXPECT_EQ(NSMaxY(miniaturizeFrame), |
| 153 NSMaxY(windowBounds) - | 162 NSMaxY(windowBounds) - |
| 154 kFramedWindowButtonsWithTabStripOffsetFromTop); | 163 kFramedWindowButtonsWithTabStripOffsetFromTop); |
| 155 EXPECT_EQ(NSMinX(miniaturizeFrame), | 164 EXPECT_EQ(NSMinX(miniaturizeFrame), |
| 156 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); | 165 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); |
| 157 [window_ setWindowController:nil]; | 166 [window_ setWindowController:nil]; |
| 158 } | 167 } |
| 159 | |
| OLD | NEW |