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/mac_util.h" |
8 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
9 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
12 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 13 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #import "testing/gtest_mac.h" | 15 #import "testing/gtest_mac.h" |
15 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
16 #import "third_party/ocmock/OCMock/OCMock.h" | 17 #import "third_party/ocmock/OCMock/OCMock.h" |
17 | 18 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 64 |
64 FramedBrowserWindow* window_; | 65 FramedBrowserWindow* window_; |
65 }; | 66 }; |
66 | 67 |
67 // Baseline test that the window creates, displays, closes, and | 68 // Baseline test that the window creates, displays, closes, and |
68 // releases. | 69 // releases. |
69 TEST_F(FramedBrowserWindowTest, ShowAndClose) { | 70 TEST_F(FramedBrowserWindowTest, ShowAndClose) { |
70 [window_ display]; | 71 [window_ display]; |
71 } | 72 } |
72 | 73 |
73 // Test that undocumented title-hiding API we're using does the job. | 74 // Test that the title-hiding API we're using does the job. |
74 TEST_F(FramedBrowserWindowTest, DoesHideTitle) { | 75 TEST_F(FramedBrowserWindowTest, DoesHideTitle) { |
75 // The -display calls are not strictly necessary, but they do | 76 // The -display calls are not strictly necessary, but they do |
76 // make it easier to see what's happening when debugging (without | 77 // make it easier to see what's happening when debugging (without |
77 // them the changes are never flushed to the screen). | 78 // them the changes are never flushed to the screen). |
78 | 79 |
79 [window_ setTitle:@""]; | 80 [window_ setTitle:@""]; |
80 [window_ display]; | 81 [window_ display]; |
81 NSData* emptyTitleData = WindowContentsAsTIFF(); | 82 NSData* emptyTitleData = WindowContentsAsTIFF(); |
82 | 83 |
83 [window_ setTitle:@"This is a title"]; | 84 [window_ setTitle:@"This is a title"]; |
84 [window_ display]; | 85 [window_ display]; |
85 NSData* thisTitleData = WindowContentsAsTIFF(); | 86 NSData* thisTitleData = WindowContentsAsTIFF(); |
86 | 87 |
87 // The default window with a title should look different from the | 88 // The default window with a title should look different from the |
88 // window with an empty title. | 89 // window with an empty title. |
89 EXPECT_FALSE([emptyTitleData isEqualToData:thisTitleData]); | 90 EXPECT_FALSE([emptyTitleData isEqualToData:thisTitleData]); |
90 | 91 |
91 [window_ setShouldHideTitle:YES]; | 92 [window_ setShouldHideTitle:YES]; |
92 [window_ setTitle:@""]; | 93 [window_ setTitle:@""]; |
93 [window_ display]; | 94 [window_ display]; |
94 [window_ setTitle:@"This is a title"]; | 95 [window_ setTitle:@"This is a title"]; |
95 [window_ display]; | 96 [window_ display]; |
96 NSData* hiddenTitleData = WindowContentsAsTIFF(); | 97 NSData* hiddenTitleData = WindowContentsAsTIFF(); |
97 | 98 |
98 // 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 |
99 // same as the window with an empty title. | 100 // same as the window with an empty title. |
100 EXPECT_TRUE([window_ _isTitleHidden]); | |
101 EXPECT_TRUE([emptyTitleData isEqualToData:hiddenTitleData]); | 101 EXPECT_TRUE([emptyTitleData isEqualToData:hiddenTitleData]); |
| 102 |
| 103 // Test the secret API only on versions of the system in which it exists. |
| 104 if (base::mac::IsOSMavericksOrEarlier()) |
| 105 EXPECT_TRUE([window_ _isTitleHidden]); |
102 } | 106 } |
103 | 107 |
104 // Test to make sure that our window widgets are in the right place. | 108 // Test to make sure that our window widgets are in the right place. |
105 TEST_F(FramedBrowserWindowTest, WindowWidgetLocation) { | 109 TEST_F(FramedBrowserWindowTest, WindowWidgetLocation) { |
106 BOOL yes = YES; | 110 BOOL yes = YES; |
107 BOOL no = NO; | 111 BOOL no = NO; |
108 | 112 |
109 // First without a tabstrip. | 113 // First without a tabstrip. |
110 [window_ close]; | 114 [window_ close]; |
111 window_ = [[FramedBrowserWindow alloc] | 115 window_ = [[FramedBrowserWindow alloc] |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton]; | 174 miniaturizeControl = [window_ standardWindowButton:NSWindowMiniaturizeButton]; |
171 EXPECT_TRUE(miniaturizeControl); | 175 EXPECT_TRUE(miniaturizeControl); |
172 miniaturizeFrame = [miniaturizeControl frame]; | 176 miniaturizeFrame = [miniaturizeControl frame]; |
173 EXPECT_EQ(NSMaxY(miniaturizeFrame), | 177 EXPECT_EQ(NSMaxY(miniaturizeFrame), |
174 NSMaxY(windowBounds) - | 178 NSMaxY(windowBounds) - |
175 kFramedWindowButtonsWithTabStripOffsetFromTop); | 179 kFramedWindowButtonsWithTabStripOffsetFromTop); |
176 EXPECT_EQ(NSMinX(miniaturizeFrame), | 180 EXPECT_EQ(NSMinX(miniaturizeFrame), |
177 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); | 181 NSMaxX(closeBoxFrame) + [window_ windowButtonsInterButtonSpacing]); |
178 [window_ setWindowController:nil]; | 182 [window_ setWindowController:nil]; |
179 } | 183 } |
OLD | NEW |